<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>abc</title>
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<link href="admin/styles/general.css" rel="stylesheet" type="text/css" />
{script src='ecmall,ui.utils,ajax'}
<script type="text/javascript">
  function onchange(span)
  {
    if (span.toString() != '[object HTMLSpanElement]')
    {
      return;
    }
    for (i = 0; i < span.attributes.length; i++)
    {
      if (span.attributes[i].nodeName == 'region_id')
      {
        region_id = span.attributes[i].nodeValue;
      }
      else if (span.attributes[i].nodeName == 'parent_id')
      {
        parent_id = span.attributes[i].nodeValue;
      }
    }
    var res = update(region_id, span.innerText, parent_id);
    if (!res.done)
    {
      alert(res.msg);
      span.innerHTML = res.retval;
    }
  }
  function update(region_id, region_name, parent_id)
  {
    Ajax.setReturnType('json');
    Ajax.addVal("region_id", region_id);
    Ajax.addVal("region_name", region_name);
    Ajax.addVal("parent_id", parent_id);
    var res = Ajax.call("admin.php?app=region&act=update&", null, "GET", false);
    return res;
  }
  </script>
</head>
<body>
<ul id="container">
  <li id="header">
    <h1>{$lang.regions}</h1>
    <div class="link"> [<a href="admin.php?app=region&amp;act=view&amp;pid=0">{$lang.root_region}</a>]
      {foreach from=$ancestors item=region}
      [<a href="admin.php?app=region&amp;act=view&amp;pid={$region.region_id}">{$region.region_name}</a>]
      {/foreach}
      {if $parent}{$parent.region_name}{/if} </div>
    <div id="desc"> <span></span> </div>
  </li>
  {if not $add_disabled}
  <li id="tips">
    <form method="post" action="admin.php?app=region&amp;act=add">
      {$lang.add_region}:
      <input type="text" name="region_name" />
      <input type="submit" value="{$lang.button_submit}">
      <input type="hidden" name="parent_id" value="{$pid}" />
    </form>
  </li>
  {/if}
  <li id="wrapper">
    <table class="grid" cellspacing="0">
      {foreach from=$region_list item=row}
      <tr> {foreach from=$row item=region}
        <td class="first-cell"><span id="editable" onclick="ui.inlineEditBox.edit(this, onchange)" region_id="{$region.region_id}" parent_id="{$smarty.get.pid}">{$region.region_name|escape:"html"}</span> | {if not $manage_disabled}<a href="admin.php?app=region&amp;act=view&amp;pid={$region.region_id}">{$lang.manage}</a>{/if} <a href="admin.php?app=region&amp;act=drop&amp;region_id={$region.region_id}" onclick="return confirm('{$lang.drop_confirm}')">{$lang.delete}</a> </td>
        {/foreach} </tr>
      {foreachelse}
      <tr>
        <td class="first-cell">{$lang.no_region}</td>
      </tr>
      {/foreach}
    </table>
  </li>
  {include file="admin/templates/footer.html"}
</ul>
</body>
</html>