{if $full_page}
{include file="page_header.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}
<form method="post" action="product.php" name="list_form" id="list_form">
<div class="list-div" id="listDiv">
{/if}
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:10px;">
<tr>
<td height="36" class="BotNavBg">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td width="50" align="left" style="padding-left:10px;">
	<label><input type="checkbox" name="check_all" onclick="select_all(this);" /> 全选</label></td>
	<td style="padding-left:5px;">
		<select name="type_up" id="sel_action_up" onchange="change_action(this)">
		<option value="">请选择...</option>
		<option value="drop">删除</option>
		<option value="status">显示</option>
		<option value="not_status">隐藏</option>
		<option value="featured">推荐</option>
		<option value="not_featured">取消推荐</option>
		<option value="move_to">转移到分类</option>
		</select>
		<select name="target_cat_up" id="target_cat_up" style="display:none">
		<option value="0">请选择...</option>
		{foreach from=$category_tree item=val}
		<option value="{$val.category_id}">{'--'|str_repeat:$val.level}{$val.name}</option>
		{/foreach}
		</select>
		<input type="button" value="确定" class="btnSubmit" name="btn_submit_up" id="btn_submit_up" onclick="move_category(this)"  style="display:none;"/>
	</td>
	<td align="right" style="padding-right:3px;">{include file="page.htm"}</td>
	</tr>
	</table>
</td>
</tr>
</table>

{foreach from=$language item=lang name=foo}
	<table width="100%" cellspacing="0" cellpadding="0" class="list-table" {if $smarty.foreach.foo.index>0} style="display:none" {/if} id="language_{$lang.language_id}-table">
		<tr class="thead">
		<th align="left" width="2%" ><input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox" /> </th>
		<th width="37%" align="left"><font color="#FFFFFF">产品名</font></th>
		<th width="17%"><font color="#FFFFFF">型号</font></th>
		<th width="6%"><font color="#FFFFFF">推荐</font></th>
		<th width="6%"><font color="#FFFFFF">显示</font></th>
		<th width="6%"><a href="javascript:listTable.sort('sort_order'); "><font color="#FFFFFF">排序</font></a>{$sort_sort_order}</th>
		<th width="6%"><a href="javascript:listTable.sort('click_cnt'); "><font color="#FFFFFF">点击</font></a>{$sort_click_cnt}</th>
		<th width="13%"><a href="javascript:listTable.sort('date_added'); "><font color="#FFFFFF">日期</font></a>{$sort_date_added}</th>
		<th width="7%" align="left">操作</th>
		</tr>
		
		{foreach from=$product_list[$lang.language_id] item=product}
		<tr>
		<td><input type="checkbox" name="checkboxes[]" value="{$product.product_id}" /></td>
		<td class="first-cell">
		{if $product.thumb}
		<a href="javascript:;" title="<img src='../{$product.thumb}'>"><span class="op_pic">{$product.name|escape:html}</span></a>
		{else}
		<span>{$product.name|escape:html}</span>
		{/if}
		</td>
		<td align="center"><span onclick="listTable.edit(this, 'edit_model', {$product.product_id})">{$product.model}</span></td>
		<td align="center"><img src="images/{if $product.is_featured}yes{else}no{/if}.gif" onclick="listTable.toggle(this,'toggle_featured',{$product.product_id})" /></td>
		<td align="center"><img src="images/{if $product.status}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_status', {$product.product_id})" /></td>
		<td align="center"><span onclick="listTable.edit(this,'edit_sort_order', {$product.product_id})">{$product.sort_order|escape:html}</span></td>
		<td align="center"><span>{$product.viewed}</span></td>
		<td align="center"><span>{$product.date_added}</span></td>
		<td align="right" nowrap="true" class="operation">
		<a href="product.php?act=edit&id={$product.product_id}" title="编辑" class="op_edit"></a>
		<a href="javascript:;" onclick="listTable.remove({$product.product_id}, '您确实要删除该产品吗?')" title="删除" class="op_del"></a>
		</td>
		</tr>
		{foreachelse}
		<tr><td class="no-records" colspan="16">没有产品</td></tr>
		{/foreach}
	</table>
{/foreach}

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td height="36" class="BotNavBg">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="50" align="left" style="padding-left:10px;">
			<label><input type="checkbox" name="check_all" onclick="select_all(this);" /> 全选</label>
			</td>
			<td style="padding-left:5px;">
				<input type="hidden" name="act" value="batch" />
				<input type="hidden" name="type" value="" id="type" />
				<input type="hidden" name="target_cat" value="" id="target_cat" />
				
				<select name="type_down" id="sel_action_down" onchange="change_action(this)">
				<option value="">请选择...</option>
				<option value="drop">删除</option>
				<option value="status">显示</option>
				<option value="not_status">隐藏</option>
				<option value="featured">推荐</option>
				<option value="not_featured">取消推荐</option>
				<option value="move_to">转移到分类</option>
				</select>
				<select name="target_cat_down" id="target_cat_down" style="display:none">
				<option value="0">请选择...</option>
				{foreach from=$category_tree item=val}
				<option value="{$val.category_id}">{'--'|str_repeat:$val.level}{$val.name}</option>
				{/foreach}
				</select>
				<input type="button" value="确定" class="btnSubmit" name="btn_submit_down" id="btn_submit_down" onclick="move_category(this)" style="display:none;"/>
			</td>
			<td align="right" style="padding-right:3px;">{include file="page.htm"}</td>
		</tr>
		</table>
	</td>
  </tr>
</table>
{if $full_page}
</div>
<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}
  
	function move_category(obj){
		if($(obj).attr('name') == 'btn_submit_up'){
			sel_target_cat = $('#target_cat_up').val();
		}else{
			sel_target_cat = $('#target_cat_down').val();
		}
		$('#target_cat').val(sel_target_cat);	
		$('#list_form').submit();
	}

	function change_action(obj){
		var sel_val = $(obj).val();	
		$('#type').val(sel_val);
		var sel_target_cat = '';
		if(sel_val == 'move_to'){
			if($(obj).attr('name') == 'type_down'){
				$('#target_cat_down').show();
				$('#btn_submit_down').show();
			}
			if($(obj).attr('name') == 'type_up'){
				$('#target_cat_up').show();
				$('#btn_submit_up').show();		
			}
		}else{
			$('#target_cat_up').hide();
			$('#target_cat_down').hide();
			$('#btn_submit_up').hide();		
			$('#btn_submit_down').hide();	
			$('#target_cat').val('');				
		}

		if(sel_val == 'drop' && confirm("确认删除?")){
			$("#list_form").submit();	
		}else if(sel_val == 'not_status' && confirm("确认隐藏?")){
			$("#list_form").submit();	
		}else if(sel_val == 'status' && confirm("确认显示?")){
			$("#list_form").submit();	
		}else if(sel_val == 'featured'  && confirm("确认推荐?")){
			$("#list_form").submit();	
		}else if(sel_val == 'not_featured'  && confirm("取消推荐?")){
			$("#list_form").submit();	
		}
		return false;
	}

	function select_all(obj){
		$('.list-table :checkbox').prop("checked",$(obj).prop('checked'));
	}
{/literal}
</script>
</form>
{insert_scripts files="tab.js"}
{include file="page_footer.htm"}
{/if}