{include file="templates/html_header.html"}
		<!-- /section:basics/navbar.layout -->
		<div class="main-container ace-save-state" id="main-container">
			<script type="text/javascript">
			{literal}
				try{ace.settings.loadState('main-container')}catch(e){}
			{/literal}
			</script>
			<!-- #section:basics/sidebar -->
			{include file="templates/html_sidebar.html"}
			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<!-- #section:basics/content.breadcrumbs -->
					<div class="breadcrumbs ace-save-state" id="breadcrumbs">
						<ul class="breadcrumb">
							<li>
								<i class="ace-icon fa fa-home home-icon"></i>
								<a href="index.php">首页</a>
							</li>

							<li>
								<a href="#">幸运号码</a>
							</li>
							<li class="active">{$title}</li>
						</ul><!-- /.breadcrumb -->
						<!-- /section:basics/content.searchbox -->
					</div>

					<!-- /section:basics/content.breadcrumbs -->
					<div class="page-content">
					<h3 class="header smaller lighter blue">
						{$title}
						<small>幸运号码中奖记录和内定设置</small>
					</h3>
						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
									<div class="widget-box widget-color-blue" id="widget-box-2">
										<div class="widget-header">
											<h5 class="widget-title bigger lighter">
												<i class="ace-icon fa fa-users"></i>
												幸运号码中奖记录和内定列表
											</h5>
											<div class="widget-toolbar no-border">
												<label>
												<button class="btn btn-xs btn-warning btn_add" onclick="opendesignatedform()">添加内定</button>
												</label>
											</div>
										</div>
										<div class="widget-body">
													<div class="widget-main no-padding">
														<table class="table table-striped table-bordered table-hover">
															<thead class="thin-border-bottom">
																<tr>
																	<th>
																		中奖顺序
																	</th>
																	<th>
																		中奖号码
																	</th>
																	<th>
																		中奖状态
																	</th>
																	<th>
																		内定状态
																	</th>
																	<th >操作</th>
																</tr>
															</thead>

															<tbody>
															{foreach $xingyunhaoma $item}

																<tr id="item{$item['id']}">
																	<td class="ordernum">{$item['ordernum']}</td>
																	<td class="lucknum">{$item['lucknum']}</td>
																	<td class="designated" data="{$item['designated']}">{$item['designatedtext']}</td>
																	<td >{$item['statustext']}</td>
																	<td >
																		<a href="###" onclick="opendesignatedform('{$item['id']}')"><span class="label label-info">修改</span></a>
																		<a href="###" onclick="del('{$item['id']}')"><span class="label label-danger">删除...</span></a>
																	</td>
																</tr>
															{/foreach}
															</tbody>
														</table>
													</div>
											{$pagehtml}
												</div>
										
									</div>
									<div id="designatedmodal" class="modal" tabindex="-1">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal">&times;</button>
												<h4 class="blue bigger">内定设置</h4>
											</div>
											<div class="modal-body">
												<div class="row">
													<div class="col-sm-12">
														<div class="form-group">
															<label for="form-field-select-3">中奖序号：</label>
															<div>
																<input class="form-control" name="ordernum" value="" placeholder="设置第几位执行，要第5位中奖就设置5"/>
															</div>
														</div>
														<div class="form-group">
															<label for="form-field-select-3">中奖数字：</label>
															<div>
																<input class="form-control" name="lucknum" value="" placeholder="不能小于最小值，或者大于最大值"/>
															</div>
														</div>

														<div class="space-4"></div>
														<div class="form-group">
															<label >内定状态</label>
															<div>
																<select class="chosen-select" name="designated" >
										                          	<option value="2">必中</option>
										                          	<option value="3">不会中</option>
																</select>
															</div>
														</div>
													</div>
												</div>
											</div>

											<div class="modal-footer">
												<input type="hidden" name="id" value=""/>
												<button class="btn btn-sm" data-dismiss="modal" >
													<i class="ace-icon fa fa-times"></i>
													取消
												</button>
												<button class="btn btn-sm btn-primary" onclick="submitdesignatedform();">
													<i class="ace-icon fa fa-check"></i>
													保存
												</button>
											</div>
										</div>
									</div>
								</div>
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->
{include file="templates/html_footercontent.html"}
<!-- 写每个页面自定的js -->
<script type="text/javascript">
{literal}
function opendesignatedform(id){
	id=id==undefined?0:id;
	if(id==0){
		$('input[name=ordernum]').val('');
		$('input[name=lucknum]').val('');
		$('select[name=designated]').val(2);
	}else{
		var ordernum=$('#item'+id).find('.ordernum').text();
		var lucknum=$('#item'+id).find('.lucknum').text();
		var designated=$('#item'+id).find('.designated').attr('data');
		$('input[name=ordernum]').val(ordernum);
		$('input[name=lucknum]').val(lucknum);
		$('select[name=designated]').val(designated);
	}
	$('input[name=id]').val(id);
	$('#designatedmodal').modal('show');
}
function submitdesignatedform(){
	var ordernum=$('input[name=ordernum]').val();;
	var lucknum=$('input[name=lucknum]').val();
	var designated=$('select[name=designated]').val();
	var id=$('input[name=id]').val();
	$.ajax({
		"url":"doxingyunhaoma.php?action=setdesignated",
		"type":"post",
		"data":{"ordernum":ordernum,"lucknum":lucknum,"designated":designated,"id":id},
		"dataType":"json",
		"success":function(json){
			alert(json.message);
			if(json.code>0){
				window.location.reload();
				//$('#designatedmodal').modal('hide');
			}
			
		}
	});
}
function del(id){
	if(!confirm('确认要删除这条记录吗？'))return false;
	$.ajax({
		"url":"doxingyunhaoma.php?action=deletelucknum",
		"type":"post",
		"data":{"id":id},
		"dataType":"json",
		"success":function(json){
			alert(json.message);
			if(json.code>0){
				window.location.reload();
			}
		}
	});
}
{/literal}
</script>
{include file="templates/html_footer.html"}