<!-- $Id: category_info.htm 16752 2009-10-20 09:59:38Z wangleisvn $ -->
{include file="pageheader.htm"}
<!-- start add new category form -->
<div class="main-div">
  <form action="category.php" method="post" name="theForm" enctype="multipart/form-data" onsubmit="return validate()">
  <table width="100%" id="general-table">
      <tr>
        <td class="label">{$lang.cat_name}:</td>
        <td>
          <input type='text' name='cat_name' maxlength="20" value='{$cat_info.cat_name|escape:html}' size='27' /> <font color="red">*</font>
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.parent_id}:</td>
        <td>
          <select name="parent_id">
            <option value="0">{$lang.cat_top}</option>
            {$cat_select}
          </select>
        </td>
      </tr>

      <tr id="measure_unit">
        <td class="label">{$lang.measure_unit}:</td>
        <td>
          <input type="text" name='measure_unit' value='{$cat_info.measure_unit}' size="12" />
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.sort_order}:</td>
        <td>
          <input type="text" name='sort_order' {if $cat_info.sort_order}value='{$cat_info.sort_order}'{else} value="50"{/if} size="15" />
        </td>
      </tr>

      <tr>
        <td class="label">{$lang.is_show}:</td>
        <td>
          <input type="radio" name="is_show" value="1" {if $cat_info.is_show neq 0} checked="true"{/if}/> {$lang.yes}
          <input type="radio" name="is_show" value="0" {if $cat_info.is_show eq 0} checked="true"{/if} /> {$lang.no}
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.show_in_nav}:</td>
        <td>
          <input type="radio" name="show_in_nav" value="1" {if $cat_info.show_in_nav neq 0} checked="true"{/if}/> {$lang.yes}
          <input type="radio" name="show_in_nav" value="0" {if $cat_info.show_in_nav eq 0} checked="true"{/if} /> {$lang.no}
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.show_in_index}:</td>
        <td>
          <input type="checkbox" name="cat_recommend[]" value="1" {if $cat_recommend[1] eq 1} checked="true"{/if}/> {$lang.index_best}
          <input type="checkbox" name="cat_recommend[]" value="2" {if $cat_recommend[2] eq 1} checked="true"{/if} /> {$lang.index_new}
          <input type="checkbox" name="cat_recommend[]" value="3" {if $cat_recommend[3] eq 1} checked="true"{/if} /> {$lang.index_hot}
        </td>
      </tr>
      <tr>
        <td class="label"><a href="javascript:showNotice('noticeFilterAttr');" title="{$lang.form_notice}"><img src="images/notice.svg" width="16" height="16" border="0" alt="{$lang.notice_style}"></a>{$lang.filter_attr}:</td>
        <td>
          <script type="text/javascript">
          var arr = new Array();
          var sel_filter_attr = "{$lang.sel_filter_attr}";
          {foreach from=$attr_list item=val key=att_cat_id}
            arr[{$att_cat_id}] = new Array();
            {foreach from=$val item=item key=i}
              {foreach from=$item item=attr_val key=attr_id}
                arr[{$att_cat_id}][{$i}] = ["{$attr_val}", {$attr_id}];
              {/foreach}
            {/foreach}
          {/foreach}

          function changeCat(obj)
          {
            var key = obj.value;
            var sel = window.ActiveXObject ? obj.parentNode.childNodes[4] : obj.parentNode.childNodes[5];
            sel.length = 0;
            sel.options[0] = new Option(sel_filter_attr, 0);
            if (arr[key] == undefined)
            {
              return;
            }
            for (var i= 0; i < arr[key].length ;i++ )
            {
              sel.options[i+1] = new Option(arr[key][i][0], arr[key][i][1]);
            }

          }

          </script>

         
          <table width="100%" id="tbody-attr" align="center">
            {if $attr_cat_id eq 0}
            <tr>
              <td>   
                   <a href="javascript:;" onclick="addFilterAttr(this)">[+]</a> 
                   <select onChange="changeCat(this)"><option value="0">{$lang.sel_goods_type}</option>{$goods_type_list}</select>&nbsp;&nbsp;
                   <select name="filter_attr[]"><option value="0">{$lang.sel_filter_attr}</option></select><br />                   
              </td>
            </tr> 
            {/if}           
            {foreach from=$filter_attr_list item=filter_attr name="filter_attr_tab"}
            <tr>
              <td>
                 {if $smarty.foreach.filter_attr_tab.iteration eq 1}
                   <a href="javascript:;" onclick="addFilterAttr(this)">[+]</a>
                 {else}
                   <a href="javascript:;" onclick="removeFilterAttr(this)">[-]&nbsp;</a>
                 {/if}
                 <select onChange="changeCat(this)"><option value="0">{$lang.sel_goods_type}</option>{$filter_attr.goods_type_list}</select>&nbsp;&nbsp;
                 <select name="filter_attr[]"><option value="0">{$lang.sel_filter_attr}</option>{html_options options=$filter_attr.option selected=$filter_attr.filter_attr}</select><br />
              </td>
            </tr>
            {/foreach}
          </table>

          <span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="noticeFilterAttr">{$lang.filter_attr_notic}</span>
        </td>
      </tr>
      <tr>
        <td class="label"><a href="javascript:showNotice('noticeGrade');" title="{$lang.form_notice}"><img src="images/notice.svg" width="16" height="16" border="0" alt="{$lang.notice_style}"></a>{$lang.grade}:</td>
        <td>
          <input type="text" name="grade" value="{$cat_info.grade|default:0}" size="40" /> <br />
          <span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="noticeGrade">{$lang.notice_grade}</span>
        </td>
      </tr>
      <tr>
        <td class="label"><a href="javascript:showNotice('noticeGoodsSN');" title="{$lang.form_notice}"><img src="images/notice.svg" width="16" height="16" border="0" alt="{$lang.notice_style}"></a>{$lang.cat_style}:</td>
        <td>
          <input type="text" name="style" value="{$cat_info.style|escape}" size="40" /> <br />
          <span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="noticeGoodsSN">{$lang.notice_style}</span>
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.keywords}:</td>
        <td><input type="text" name="keywords" value='{$cat_info.keywords}' size="50">
        </td>
      </tr>

      <tr>
        <td class="label">{$lang.cat_desc}:</td>
        <td>
          <textarea name='cat_desc' rows="6" cols="48">{$cat_info.cat_desc}</textarea>
        </td>
      </tr>
      </table>
      <div class="button-div">
        <input type="submit" class="btn" value="{$lang.button_submit}" />
        <input type="reset" class="btn btn-def" value="{$lang.button_reset}" />
      </div>
    <input type="hidden" name="act" value="{$form_act}" />
    <input type="hidden" name="old_cat_name" value="{$cat_info.cat_name}" />
    <input type="hidden" name="cat_id" value="{$cat_info.cat_id}" />
  </form>
</div>
{insert_scripts files="../js/utils.js,validator.js"}
{literal}
<script language="JavaScript">
<!--
document.forms['theForm'].elements['cat_name'].focus();
/**
 * 检查表单输入的数据
 */
function validate()
{
  validator = new Validator("theForm");
  validator.required("cat_name",      catname_empty);
  if (parseInt(document.forms['theForm'].elements['grade'].value) >10 || parseInt(document.forms['theForm'].elements['grade'].value) < 0)
  {
    validator.addErrorMsg('{$lang.grade_error}');
  }
  return validator.passed();
}
onload = function()
{
  // 开始检查订单
  startCheckOrder();
}

/**
 * 新增一个筛选属性
 */
function addFilterAttr(obj)
{
  var src = obj.parentNode.parentNode;
  var tbl = document.getElementById('tbody-attr');

  var validator  = new Validator('theForm');
  var filterAttr = document.getElementsByName("filter_attr[]");

  if (filterAttr[filterAttr.length-1].selectedIndex == 0)
  {
    validator.addErrorMsg(filter_attr_not_selected);
  }
  
  for (i = 0; i < filterAttr.length; i++)
  {
    for (j = i + 1; j <filterAttr.length; j++)
    {
      if (filterAttr.item(i).value == filterAttr.item(j).value)
      {
        validator.addErrorMsg(filter_attr_not_repeated);
      } 
    } 
  }

  if (!validator.passed())
  {
    return false;
  }

  var row  = tbl.insertRow(tbl.rows.length);
  var cell = row.insertCell(-1);
  cell.innerHTML = src.cells[0].innerHTML.replace(/(.*)(addFilterAttr)(.*)(\[)(\+)/i, "$1removeFilterAttr$3$4-");
  filterAttr[filterAttr.length-1].selectedIndex = 0;
}

/**
 * 删除一个筛选属性
 */
function removeFilterAttr(obj)
{
  var row = rowindex(obj.parentNode.parentNode);
  var tbl = document.getElementById('tbody-attr');

  tbl.deleteRow(row);
}
//-->
</script>
{/literal}
{include file="pagefooter.htm"}