<?php echo $this->fetch('header.html'); ?>
<script language="javascript" src="/static/js/My97DatePicker/WdatePicker.js"></script>
<div class="row">
<div class="span12">
<?php echo $this->fetch('admin_product_nav.html'); ?>
<p><h3>总计<?php echo $this->_var['rscount']; ?>件商品 <small><?php echo $this->_var['cat']['cname']; ?></small></h3></p>
<form method="get" action="<?php echo APPADMIN; ?>" class="form form-inline">
<input type="hidden" name="status" value="<?php echo $_GET['status']; ?>" />
<input type="hidden" name="m" value="admin_product" />
<input type="hidden" name="a" value="default" />
<p>
ID:<input type="text" name="id" value="<?php echo $_GET['id']; ?>" class="w50" />
名称：<input type="text" name="title" value="<?php echo $_GET['title']; ?>" />
开始时间：<input name="start_time" type="text"  value="<?php echo $_GET['start_time']; ?>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="w100">
结束时间:<input type="text" name="end_time" value="<?php echo $_GET['end_time']; ?>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd  HH:mm:ss'})" class="w100">
</p>
<p>
分类：<select name="catid[]" id="catid"  class="w150" >
	<option value="0">请选择</option>
    <?php $_from = $this->_var['cat_1_list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
        <option value="<?php echo $this->_var['c']['id']; ?>" <?php if ($this->_var['parent_1_id'] == $this->_var['c']['id']): ?> selected="selected"<?php endif; ?>><?php echo $this->_var['c']['cname']; ?></option>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
</select>
二级分类：<select name="catid[]"  id="catid_2nd"   class="w150"  >
<option value="0">请选择</option>
<?php $_from = $this->_var['cat_2_list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
        <option value="<?php echo $this->_var['c']['id']; ?>" <?php if ($this->_var['parent_2_id'] == $this->_var['c']['id']): ?> selected="selected"<?php endif; ?>><?php echo $this->_var['c']['cname']; ?></option>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
</select>
三级分类：<select name="catid[]"  id="catid_3nd"   class="w150"  >
<option value="0">请选择</option>
<?php $_from = $this->_var['cat_3_list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
        <option value="<?php echo $this->_var['c']['id']; ?>" <?php if ($this->_var['parent_3_id'] == $this->_var['c']['id']): ?> selected="selected"<?php endif; ?>><?php echo $this->_var['c']['cname']; ?></option>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
</select>


缺货：<select name="unsold" class="w100">
<option value="0">正常</option>
<option value="1" <?php if ($_GET['unsold']): ?> selected="selected"<?php endif; ?>>缺货</option>
</select>
</p>
<input type="submit" value="搜索" class="btn btn-success" />
</form>
<table class="table table-bordered">
<tr>
	<td>ID</td>
    <td>图片</td>
    <td>名称</td>
    <td>价格</td>
    
    <td>操作</td>
</tr>
<?php $_from = $this->_var['list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
<tr>
	<td><?php echo $this->_var['c']['id']; ?></td>
    
     <td><?php if ($this->_var['c']['imgurl']): ?><a href="/index.php?m=show&a=default&id=<?php echo $this->_var['c']['id']; ?>" target="_blank"><img src="/<?php echo $this->_var['c']['imgurl']; ?>.100x100.jpg"></a><?php else: ?><a href="/index.php?m=show&a=default&id=<?php echo $this->_var['c']['id']; ?>" target="_blank">前台查看</a><?php endif; ?></td>
     <td><a href="<?php echo APPADMIN; ?>?m=admin_product&a=add&id=<?php echo $this->_var['c']['id']; ?>" ><?php echo $this->_var['c']['title']; ?></a></td>
   
     <td><?php echo $this->_var['c']['price']; ?></td>
    <td><?php if ($this->_var['c']['status'] == 2): ?><a href="javascript:;" class="undel" pid="<?php echo $this->_var['c']['id']; ?>">通过</a> 
    <br /><br /><br /><br />
  <a href="javascript:;" class="del" pid="<?php echo $this->_var['c']['id']; ?>"> 删除</a>
    <?php elseif ($this->_var['c']['status'] == 3): ?>
    <a href="javascript:;" class="del" pid="<?php echo $this->_var['c']['id']; ?>"> 删除</a>
    <br /><br /> 
    
    <?php elseif ($this->_var['c']['status'] == 1): ?>
    <a href="javascript:;" class="del" pid="<?php echo $this->_var['c']['id']; ?>"> 删除</a> 
    <br /><br /><br /><br />
    <a href="javascript:;" class="ajax_clear" url="<?php echo APPADMIN; ?>?m=admin_product&a=changestatus&id=<?php echo $this->_var['c']['id']; ?>&status=2">发微博</a>
    <?php elseif ($this->_var['c']['status'] == 98): ?>
    <a href="javascript:;" class="undel" pid="<?php echo $this->_var['c']['id']; ?>">通过</a> <br /><br /> <br /><br />
    <a href="javascript:;" class="ajax_clear" url="<?php echo APPADMIN; ?>?m=admin_product&a=Clear&id=<?php echo $this->_var['c']['id']; ?>" > 清除</a>  
    <?php else: ?>
    <a href="javascript:;" class="undel" pid="<?php echo $this->_var['c']['id']; ?>">通过</a> <br /><br /> <br /><br />
    <a href="javascript:;" class="del" pid="<?php echo $this->_var['c']['id']; ?>"> 删除</a><?php endif; ?>  </td>
</tr>
<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>

</table>
<?php echo $this->_var['pagelist']; ?>
</div>

</div>
<script language="javascript">
$(document).ready(function(){
	$(".ajax_clear").click(function(){		
			$.get($(this).attr("url"));
			$(this).parents("tr").remove();
		
	});
	
	$("#catid").bind("change",function(){
		var v=$(this).val();
		$.get("<?php echo APPADMIN; ?>?m=admin_product&a=catChild",{id:v},function(data){
			$("#catid_2nd").empty().append(data);
			$("#catid_3nd").empty();
		})
	});
	$("#catid_2nd").bind("change",function(){
		var v=$(this).val();
		$.get("<?php echo APPADMIN; ?>?m=admin_product&a=catChild",{id:v},function(data){
			$("#catid_3nd").empty().append(data);
		})
	});
});
</script>
<?php echo $this->fetch('footer.html'); ?>