<!--<?php
require($this->getSegmentFile('manage.nav'));
$keyword = ($_viewer->keyword) ? stripslashes($_viewer->keyword) : '';
print <<<EOT
-->
		<div id="contentC" class="fl">
			<div class="p15">
				<div class="nav3 mb10">
					<ul class="cc">
						<li class="current"><a href="{$_viewer->baseName}&c=pmanage&dianpuid={$_viewer->dianpuid}">商品管理</a></li>
						<li><a href="{$_viewer->baseName}&c=pmanage&a=add&dianpuid={$_viewer->dianpuid}">商品添加</a></li>
					</ul>
				</div>
				<h2 class="h1">商品搜索</h2>
<script type="text/javascript">
function doSearch(form) {
	var keyword = form.act_title.value;
	var shelf = form.shelf.value;
	var url = form.action;
	if (keyword != '') url += '&act_title=' + keyword;
	if (shelf != '') url += '&shelf=' + shelf;
	setTimeout(function(){
		window.location.href = url;
	},100);
	return false;
}
</script>				
				<div class="admin_table mb10">
					<form action="{$_viewer->baseUrl}&a=search&dianpuid={$_viewer->dianpuid}" method="post" name="SEARCH" onsubmit="return doSearch(document.SEARCH)">
					<table width="100%">
						<tr class="tr1">
							<td class="td2">
								<input name="act_title" type="text" class="input input_wa mr5" value="{$keyword}" />
								<select name="shelf">
									<option value="-1" {$_viewer->checked[all]}>全部</option>
									<option value="1"  {$_viewer->checked[1]}>已上架</option>
									<option value="0" {$_viewer->checked[0]}>已下架</option>
								</select>
								<span class="btn2"><span><button type="submit">搜索</button></span></span>
							</td>
						</tr>
					</table>
					</form>
				</div>
				<h2 class="h1">商品列表</h2>
<!-- 
EOT;
if($_viewer->products){
print <<<EOT
-->				
				<script type="text/javascript" src="mode/dianpu/js/dianpu.js"></script>
				<script type="text/javascript">
					var product = {
						message : '',
						doShelf : function(obj){
						    product.message = obj.innerHTML.indexOf('已上架') != '-1'  ? '下架' : '上架' ;
							if(!obj.href) {
								DP.tips('error', product.message + '操作失败！', '2');
								return false;
							}
							DP.post(obj.href,'',function(){
								if (ajax.request.responseText == null) DP.tips('error','非法操作！');
								DP.tips('success', product.message + '操作成功！', '2');
								setTimeout(function(){
									window.location.reload(); 
								},2000);
							});
							return false;
						},
						doClose : function(title){
							var form = getObj('pmanageform');
							if(!DP.isClicked(form)){
								 DP.tips('error' , '请先选择要批量下架的商品' , '3');
								 return false;
							}
							DP.tips('confirm' , '你确定要批量下架吗？' , '' , function(){
								product.message = title;
								form.doing.value = 'shelf';
								return product.doSubmit(form);
							});
							return false;
						},
						doOpen : function(title){
							var form = getObj('pmanageform');
							if(!DP.isClicked(form)){
								 DP.tips('error' , '请先选择要批量上架的商品' , '3');
								 return false;
							}
							DP.tips('confirm' , '你确定要批量上架吗？' , '' , function(){
								product.message = title;
								form.doing.value = 'onshelf';
								return product.doSubmit(form);
							});
							return false;
						},
						doDelete:function(title){
							var form = getObj('pmanageform');
							if(!DP.isClicked(form)) {
								DP.tips('error' , '请先选择要批量删除的商品' , '3');
								return false;
							}
							DP.tips('confirm' , '你确定要批量删除吗？' , '' , function(){
								product.message = title;
								form.doing.value = 'delete';
								return product.doSubmit(form);
							});
							return false;
						},
						doSubmit : function(form){
							DP.post(form.action,form,function(){
								if (ajax.request.responseText == null) DP.tips('error','非法操作！');
								DP.tips('success', product.message + '操作成功！', '2');
								setTimeout(function(){
									DP.unClick(form);
									window.location.reload(); 
								},2000);
							});
						},
						remove : function(url){
							DP.tips('confirm' , '你确定要删除吗？' , '' , function(){
								DP.post(url,'',function(){
									if (ajax.request.responseText == null) DP.tips('error','非法操作！');
									DP.tips('success', '删除操作成功！', '2');
									setTimeout("window.location.reload();",2000);
								});
							});
							return false;
						}						
					};
				</script>
				<form action="{$_viewer->baseUrl}&a=operate&dianpuid={$_viewer->dianpuid}" method="post" name="FORM" id="pmanageform">
				<input type="hidden" name="step" value="2" />
				<input type="hidden" name="doing" value="shelf" />
				<div class="admin_table mb10">
					<table width="100%">
						<tr class="tr2">
							<td width="55"><input name="products[]" type="checkbox" value="" onclick="DP.CheckAll('products[]',this);" /><span OnClick="CheckAll(document.FORM)" style = "cursor:pointer;"> 全选</span></td>
							<td>商品名称</td>
							<td width="75">市场价</td>
							<td width="75">会员价</td>
							<td width="100">上架时间</td>
							<td width="140">操作</td>
						</tr>
<!-- 
EOT;
foreach($_viewer->products as $product){
$shelfname = ( $product[shelf] == 1 ) ? '<span style="color:#008800;">[已上架]</span>' : '<span class="s2">[未上架]</span>';
$shelf = ( $product[shelf] == 1 ) ? 0 : 1;
print <<<EOT
-->				
						<tr class="tr1">
							<td class="td2"><input name="products[]" type="checkbox" value="{$product[productid]}"></td>
							<td class="td2"><a target="_blank" href="{$_viewer->baseName}&c=product&id={$product[objectid]}&productid={$product[productid]}&a=detail">{$product[title]}</a></td>
							<td class="td2">{$product['market_price']}</td>
							<td class="td2">{$product['member_price']}</td>
							<td class="td2">{$product['format_createdtime']}</td>
							<td class="td2">
								<a href="{$_viewer->baseUrl}&a=edit&productid={$product[productid]}&dianpuid={$_viewer->dianpuid}" class="mr5">[编辑]</a>
								<a href="{$_viewer->baseUrl}&a=shelf&productid={$product[productid]}&shelf={$shelf}&dianpuid={$_viewer->dianpuid}" class="mr5" onclick="return product.doShelf(this)">{$shelfname}</a>
								<a href="javascript:;" onclick="product.remove('{$_viewer->baseUrl}&a=delete&productid={$product[productid]}&dianpuid={$_viewer->dianpuid}');">[删除]</a>
							</td>
						</tr>
<!-- 
EOT;
}
print <<<EOT
-->				
						<tr class="tr2 td_bgA">
							<td class="td2"><input name="products[]" type="checkbox" value="" onclick="DP.CheckAll('products[]',this);" /><span OnClick="CheckAll(document.FORM)" style = "cursor:pointer;"> 全选</span></td>
							<td class="td2">
								<span class="bt2"><span><button type="button" onclick="product.doClose(this.title);" title="批量下架">批量下架</button></span></span>
								<span class="bt2"><span><button type="button" onclick="product.doDelete(this.title);" title="批量删除">批量删除</button></span></span>
							</td>
							<td class="td2" colspan="4"></td>
						</tr>
					</table>
				</div>
				<div class="mb5">{$_viewer->pager}</div>
				<!--<div class="p10 tac"><span class="btn"><span><button type="button" onclick="product.doOpen(this.title);" title="批量上架">发 布</button></span></span></div>-->
				</form>
<!-- 
EOT;
}else{
print <<<EOT
-->
			<div class="p15 tac">啊哦，没有你要的信息！</div>
<!-- 
EOT;
}
print <<<EOT
-->
	</div>
</div>
<!--
EOT;
?>