<{import file="header.html" title="优惠券"}>
<!--datapiker--> 
<link rel="stylesheet" type="text/css" href="<{$__PUBLIC__}>plug/laydate/need/laydate.css"> 
<link rel="stylesheet" type="text/css" href="<{$__PUBLIC__}>plug/laydate/skins/default/laydate.css"> 
<!--data end---> 
<style type="text/css">
.table_span{  float:left; }
.table_span span{ margin:8px 0 0 20px; float:left; }
.chgs{ width:100%; float:left; }
.chgs a{ margin-top:10px; padding:5px 10px 4px; border-radius:2px; background:#1583EF; color:#fff; float:left; }
.nogoods{ width:100%; height:20px; float:left; }
</style> 
<div class="tab2">
	<a class="back" href="<{$__SELLER__}>promote/coupon">优惠券编辑</a>
</div> 
<div class="baseBox">
	<{uqcms m="promote" v="row" c="coupon_one:id=smarty.get.id"}>
	<form id="form" action="<{$__SELLER__}>promote/coupon_save" method="post"> 
		<{if $row.id}><input type="hidden" name="id" value="<{$row.id}>"><{/if}>
		<table width="100%" class="etable">  
			<tr>
				<td width="120">活动名称：</td>
				<td><input type="text" value="<{$row.name}>" name="name" size="32"></td>
			</tr>
			<tr>
				<td>购买满：</td>
				<td><input type="text" name="full_price" value="<{$row.full_price}>" autocomplete="off" size="10"> </td>
			</tr> 
			<tr>
				<td>减少：</td>
				<td> <input type="text" name="price" value="<{$row.price}>" autocomplete="off" size="10"/> </td>
			</tr>  
			<tr>
				<td>发放数量：</td>
				<td><input type="text" name="num" value="<{$row.num}>" autocomplete="off" size="10">
					<p>0为可以无限发放。</p>
				</td>
			</tr> 
			<tr>
				<td>开始时间：</td>
				<td>
					<input type="text" name="start_time" size="20" autocomplete="off" value="<{$row.start_time}>" id="start_time"/> 
					<div class="table_span"> 
						<span>结束时间：</span> 
						<input type="text" name="end_time" size="20" autocomplete="off" value="<{$row.end_time}>" id="end_time"/>
					</div> 
				</td>
			</tr> 
			<tr>
				<td>优惠范围：</td>
				<td>
					<label><input type="radio" name="range" value="0" <{if $row.range == '0' || $row.range == ''}>checked="checked"<{/if}>/>全部</label> 
					<label><input type="radio" name="range" value="1" <{if $row.range == '1'}>checked="checked"<{/if}>/>部分商品</label>
						
				</td>
			</tr>
			<tr class="gs_range_box" <{if $row.range == '1'}><{else}>style="display:none;"<{/if}>>
				<td valign="top" style="padding-top:18px;">选择列表：</td>
				<td>
					<table class="ltable" style="width:770px; ">
						<thead>
							<tr>
								<th width="50">产品</th>
								<th>标题</th>
								<th width="70">金额</th>
								<th width="70">库存</th>
								<th width="70">操作</th>
							</tr>
						</thead>
						<tbody class="ltablebox">
							<{uqcms m="promote" v="goods_list" c="coupon_goods:cpid=smarty.get.id"}>
							<{if $goods_list}>
								 <{foreach item=i from=$goods_list}>
									<tr><input type="hidden" name="ckgid[]" value="<{$i.id}>">
										<td><img src="<{$__IMG__}><{$i.images|img_size:30x30}>"></td>
										<td><{$i.title}></td>
										<td><{$i.price}></td>
										<td><{$i.stock}></td>
										<td><a href="javascript:;" class="gs_del" data-id="<{$i.id}>">删除</a></td>
									</tr>
								<{/foreach}>
							<{else}>
								<div class="nogoods">无产品选择</div>
							<{/if}>
						</tbody>
					</table>
					<div class="chgs">
						<a href="javascript:;" onclick="goods_edit('选择产品', '<{$__SELLER__}>promote/goods_list');" class="ckgoods" data-page="">选择产品</a>
					</div> 
				</td>
			</tr> 
			<tr>
				<td>状态：</td>
				<td>
					<label><input type="radio" name="status" value="1" <{if $row.status == '1' || $row.status == ''}>checked="checked"<{/if}>/>开启</label> 
					<label><input type="radio" name="status" value="0" <{if $row.status == '0'}>checked="checked"<{/if}>/>关闭</label> 
				</td>
			</tr> 
			<tr>
				<td>&nbsp;</td>
				<td><input type="submit" name="submit" class="submit"  value="确认"/></td>
			</tr>
		</table> 
	</form>
</div>
<{import file="footer.html"}>  
<script type="text/javascript" src="<{$__PUBLIC__}>plug/laydate/laydate.js"></script>
<script type="text/javascript">
function goods_edit(name,url){
	ajax_dialog(name, url, 800, 500); 
}
laydate({elem:'#start_time', format:'YYYY-MM-DD hh:mm:ss', max:'2099-06-16 23:59:59', istime:true, 
		choose:function(datas){
			end.min = datas; 
			end.start = datas 
		}});
laydate({elem:'#end_time', format:'YYYY-MM-DD hh:mm:ss', max:'2099-06-16 23:59:59', istime:true, 
		choose:function(datas){
			start.max = datas; 
		}}); 

function ck_goods(html){ 
	length = $("tbody.ltablebox tr").length;
	if(length > 0){
		$("tbody.ltablebox tr:last").after(html);
	}else{
		$("tbody.ltablebox").html(html); 
	}
}
$(function(){
	$(document).on('click', 'input:radio[name=range]', function(){ 
		$this = $(this);
		if($this.val() == 1){
			$(".ckgoods,.gs_range_box").show();
		}else{
			$(".ckgoods,.gs_range_box").hide();
		}
	});
	
	$(document).on('click', 'a.gs_del', function(){ 
		 $this = $(this); 
		 $this.parent().parent('tr').remove();  
	}); 
}); 

</script>