<extend name="Public:base" />
<block name="content">


<div class="page-header">
	<a href="{:U('SuperSpike/add')}" class="btn btn-primary">添加超值大牌活动</a>
</div>	

<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>											
						<th>ID</th>
						<th>活动名称</th>
						<th>线上活动商品数量</th>
						<th>待审核商品数量</th>
						<th>活动开始时间</th> 
						<th>活动结束时间</th>
						<th>活动添加时间</th> 
						<th>操作</th>				
					</tr>
				</thead>
				<tbody>
						<volist name="list" id="data" empty="$empty">
						<tr>						
							<td>{$data.id}</td>
							<td>{$data.name}</td>
							<td>
								
								<?php 
									if($data['on_goods'] > 0)
									{
								?>
									<b class="red">{$data.on_goods}</b>
								<?php }else{ ?>
									{$data.on_goods}
								<?php } ?>
							</td>
							<td>
								<?php 
									if($data['wait_goods'] > 0)
									{
								?>
									<b class="red">{$data.wait_goods}</b>
								<?php }else{ ?>
									{$data.wait_goods}
								<?php } ?>
							</td>
							<td>
								<?php echo date('Y-m-d H:i:s',$data['begin_time']); ?>
							</td>
							<td>
								<?php echo date('Y-m-d H:i:s',$data['end_time']); ?>
							</td>
							<td>
								<?php echo date('Y-m-d H:i:s',$data['add_time']); ?>
							</td>
							
							<td>
								<a  class="btn btn-xs btn-info" href='{:U("SuperSpike/edit",array("id"=>$data["id"]))}'>
									<i class="icon-check bigger-120"></i>
								</a> 
								<a  class="btn btn-xs btn-info" href='{:U("SuperSpike/activity_goods",array("id"=>$data["id"]))}'>
									<i class="icon-check bigger-120"></i>
									查看活动商品
								</a> 
								<a  class="btn btn-xs btn-info" href='{:U("SuperSpike/take_superspike",array("id"=>$data["id"]))}'>
									<i class="icon-check bigger-120"></i>
									添加活动商品
								</a> 
							</td>
						</tr>
						</volist>	
						
						<tr>
							<td colspan="20" class="page">{$page}</td>
						</tr>
				</tbody>
				
			</table>
		</div>
	</div>
</div>
<link rel="stylesheet" href="__CSS__/dialog.css" />	

<div class="ks-ext-mask" style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 999; display:none"></div>
	<div id="dialog" class="dialog" style="z-index: 9999; display:none">
    <div class="ks-contentbox">
      <div class="title">
      	<span>秒杀产品上线时间设置</span><a class="ks-ext-close" href="javascript:void(0)">X</a></div>
      
        <dl>
        	<dt>开始时间</dt>
    		<dd><input name="begin_time" id="begin_time" type="text" value="<?php echo date('Y-m-d H:i:s',time()); ?>" size="50"  /></dd>    		
    		<dt>结束时间</dt>
    		<dd><input name="end_time" id="end_time" type="text" value="<?php echo date('Y-m-d H:i:s',time()+86400); ?>" size="50"  /></dd>  
        </dl>
        
        <div class="J_DefaultMessage"></div>
        <div class="bottom">
        	<input type="hidden" id="sub_url" value="" />
        	 <a href="javascript:void(0);" class="J_SubmitPL ncsc-btn ncsc-btn-green">确认</a> 
        </div>
      
    </div>
  </div>  
  
</block>
<block name="javascript">
<script src="__PUBLIC__/js/moment/moment.js"></script>
<script src="__PUBLIC__/js/moment/locale/zh-cn.js"></script> 

<script src="__PUBLIC__/js/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"></script>
<link rel="stylesheet" href="__PUBLIC__/js/bootstrap-timepicker/css/bootstrap-timepicker.css" />
<script>

$(function(){
		$('#begin_time').datetimepicker({
		 format: 'YYYY/MM/DD H:mm:ss',//use this option to display seconds
		 icons: {
			time: 'btn btn-lg icon-time',
			date: 'btn btn-lg icon-calendar',
			up: 'fa icon-chevron-up',
			down: 'fa icon-chevron-down',
			previous: 'fa icon-chevron-left',
			next: 'fa icon-chevron-right',
			today: 'fa icon-arrows ',
			clear: 'fa icon-trash',
			close: 'fa icon-times'
		 }
		}).next().on(ace.click_event, function(){
			$(this).prev().focus();
		});
		
		$('#end_time').datetimepicker({
			 format: 'YYYY/MM/DD H:mm:ss',//use this option to display seconds
			 icons: {
				time: 'btn btn-lg icon-time',
				date: 'btn btn-lg icon-calendar',
				up: 'fa icon-chevron-up',
				down: 'fa icon-chevron-down',
				previous: 'fa icon-chevron-left',
				next: 'fa icon-chevron-right',
				today: 'fa icon-arrows ',
				clear: 'fa icon-trash',
				close: 'fa icon-times'
			 }
			}).next().on(ace.click_event, function(){
				$(this).prev().focus();
			});
		
		$('.J_SubmitPL').on('click',function(){
			var begin_time = $('#begin_time').val();
			var end_time = $('#end_time').val();
			
			var s_url = $('#sub_url').val();
			$.ajax({
				url:s_url,
				type:'post',
				data:{begin_time:begin_time,end_time:end_time},
				dataType:'json',
				success:function(result){
					if(result.code == 1) {
						alert('审核通过');
						location.href = location.href;
						return false;
					} else {
						alert(result.msg);
					}
				}
				
			})
		})
		
		$('.shenhe').click(function(){
			var s_url = $(this).attr('rel-url');
			$('#sub_url').val(s_url);
			$("#dialog").css({'position' : 'fixed','display' : 'block', 'z-index' : '9999'});
		})
		
		//关闭弹出层
		$('#dialog').on('click','.ks-ext-close',function(){	
		    $("#dialog").css('display','none');
		    $('.ks-ext-mask').css('display','none');
		    return false;
		});
		//关闭弹出层
		$('#dialog').on('click','.J_Cancel',function(){	
		    $("#dialog").css('display','none');
		    $('.ks-ext-mask').css('display','none');
		    return false;
		});
			
		
	
})
</script>						
</block>