<!-- $Id: goods_list.htm 17126 2010-04-23 10:30:26Z liuhui $ -->

{if $full_page}
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}

<!-- 商品搜索 -->
{include file="goods_search.htm"}
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start goods list -->
  <div class="list-div" id="listDiv">
{/if}
<table id="simple-table" class="table  table-bordered table-hover">
  <tr>
    <th>
      <a href="javascript:listTable.sort('id'); ">{$lang.record_id}</a>{$sort_id}
    </th>
    <th><a href="javascript:listTable.sort('cname'); ">名稱</a>{$sort_cname}</th>
    <th><a href="javascript:listTable.sort('is_on_sale'); ">是否上架</a>{$sort_is_on_sale}</th>
    <th><a href="javascript:listTable.sort('sort_order'); ">{$lang.sort_order}</a>{$sort_sort_order}</th>
    <th>{$lang.handler}</th>
  <tr>
  {foreach from=$room_list item=room}
  <tr>
    <td>&nbsp;{$room.id}</td>
    <td class="first-cell">{$room.name|escape:html}</td>
    <td align="center"><img src="images/{if $room.enable}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_enable', {$room.id})" /></td>
    <td align="center"><span onclick="listTable.edit(this, 'edit_sort_order', {$room.id})">{$room.sort_order}</span></td>
    <td align="center">
      <a href="room.php?act=edit&id={$room.id}" title="{$lang.edit}"><img src="images/icon_edit.gif" width="21" height="21" border="0" /></a>
      <a href="javascript:;" onclick="listTable.remove({$room.id}, '確認刪除')" title="刪除"><img src="images/icon_trash.gif" width="21" height="21" border="0" /></a>
    </td>
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
</table>
<!-- end goods list -->

<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    {include file="page.htm"}
    </td>
  </tr>
</table>

{if $full_page}
</div>
</form>

<script type="text/javascript">
  listTable.recordCount = {$record_count};
  listTable.pageCount = {$page_count};

  {foreach from=$filter item=item key=key}
  listTable.filter.{$key} = '{$item}';
  {/foreach}

  {literal}
  onload = function()
  {
    startCheckOrder(); // 开始检查订单
    document.forms['listForm'].reset();
  }

  /**
   * @param: bool ext 其他条件：用于转移分类
   */
  function confirmSubmit(frm, ext)
  {
      if (frm.elements['type'].value == 'trash')
      {
          return confirm(batch_trash_confirm);
      }
      else if (frm.elements['type'].value == 'not_on_sale')
      {
          return confirm(batch_no_on_sale);
      }
      else if (frm.elements['type'].value == 'move_to')
      {
          ext = (ext == undefined) ? true : ext;
          return ext && frm.elements['target_cat'].value != 0;
      }
      else if (frm.elements['type'].value == '')
      {
          return false;
      }
      else
      {
          return true;
      }
  }

  function changeAction()
  {
      var frm = document.forms['listForm'];

      // 切换分类列表的显示
      frm.elements['target_cat'].style.display = frm.elements['type'].value == 'move_to' ? '' : 'none';
			
			{if $suppliers_list > 0}
      frm.elements['suppliers_id'].style.display = frm.elements['type'].value == 'suppliers_move_to' ? '' : 'none';
			{/if}

      if (!document.getElementById('btnSubmit').disabled &&
          confirmSubmit(frm, false))
      {
          frm.submit();
      }
  }
{/literal}
</script>
{include file="pagefooter.htm"}
{/if}