{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 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">
							<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="openconfigform(0)">添加</button>
										</label>
										
									</div>
								</div>
							<div class="widget-body">
								<div class="widget-main no-padding">
									<!-- PAGE CONTENT BEGINS -->
									<table class="table table-striped table-bordered table-hover">
										<thead class="thin-border-bottom">
											<tr>
												<th>序号</th>
												<th>
													摇晃次数
												</th>
												<th>
													前N名中奖
												</th>
												<th>
													状态
												</th>
												<th>
													是否可重复中奖
												</th>
												<th>
													结果显示方式
												</th>
												<th >操作</th>
											</tr>
										</thead>
										<tbody>
										{foreach $pashu_config as $item}
											<tr >
												<td >{$item['id']}</td>
												<td >{$item['times']}</td>
												<td >{$item['toprank']}</td>
												<td >{$item['statustext']}</td>
												<td >{$item['winningagaintext']}</td>
												<td >{$item['showstyletext']}</td>
												<td >
													<a href="###" onclick="openconfigform({$item['id']})"><span class="label label-primary">修改</span></a>
													<a href="pashurecord.php?id={$item['id']}" ><span class="label label-primary">游戏结果</span></a>
													<a href="###" onclick="clearpashu({$item['id']})"><span class="label label-danger">重置游戏</span></a>
													<a href="###" onclick="del({$item['id']})"><span class="label label-danger">删除</span></a>
												</td>
											</tr>
										{/foreach}
										</tbody>
									</table>
									{$pagehtml}
									</div>
									</div>
								</div>

								<div id="configmodal" 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="row">
														<div class="form-group">
															<label  class="col-xs-4" style="text-align: right;">摇晃次数：</label>
															<div>
																<input type="number"  name="times"  class="col-xs-5" value="" />
															</div>
														</div>
													</div>

													<div class="space-4"></div>
													<div class="row">
														<div class="form-group">
															<label  class="col-xs-4" style="text-align: right;">前N名中奖：</label>
															<div>
																<input type="number"  name="toprank"  class="col-xs-5" value="" />
															</div>
														</div>
													</div>

													<div class="space-4"></div>
													<div class="row">
														<div class="form-group">
															<label  class="col-xs-4" style="text-align: right;">状态：</label>
															<div>
																<select class="chosen-select col-xs-5"  name="status" >
																	<option value="1">未开始</option>
																	<option value="2">进行中</option>
										                          	<option value="3">结束</option>
																</select>
															</div>
														</div>
													</div>
														
													<div class="space-4"></div>
													<div class="row">
														<div class="form-group">
															<label class="col-xs-4" style="text-align: right;">可重复中奖：</label>
															<div>
																<select class="chosen-select col-xs-5" name="winningagain" data-placeholder="请选择显示类型">
																	<option value="1">不可</option>
										                          	<option value="2">可以</option>
																</select>
															</div>
														</div>
													</div>
													
													<div class="space-4"></div>
													<div class="row">
														<div class="form-group">
															<label class="col-xs-4" style="text-align: right;">显示类型：</label>
															<div>
																<select class="chosen-select col-xs-5" name="showstyle" data-placeholder="请选择显示类型">
																	<option value="1">昵称</option>
										                          	<option value="2">姓名</option>
										                          	<option value="3">手机号</option>
																</select>
															</div>
														</div>
													</div>
													
													<div class="space-4"></div>
												</div>
											</div>

											<div class="modal-footer">
												<input name="id" type="hidden" value="0"/>
												<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="saveconfig();">
													<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 del(id){
	if(!confirm("确认删除这条配置记录吗？"))return false;
	$.ajax({
		"url":"dopashu.php?action=delitem",
		"data":{"id":id},
		"type":"post",
		"dataType":"json",
		"success":function(json){
			if(json.code>0){
				alert(json.message);
				window.location.reload();
			}else
				alert(json.message);
		}
		
	});
}
function clearpashu(id){
	if(!confirm("确认删除这个配置的数据吗？"))return false;
	$.ajax({
		"url":"dopashu.php?action=clearpashu",
		"data":{"id":id},
		"type":"post",
		"dataType":"json",
		"success":function(json){
			if(json.code>0){
				alert(json.message);
				window.location.reload();
			}else
				alert(json.message);
		}
	});
}
function openconfigform(id){
	$('input[name=id]').val(id);
	if(id>0){
		$.ajax({
			"url":"dopashu.php?action=getconfig",
			"type":"post",
			"data":{"id":id},
			"dataType":"json",
			"success":function(json){
				if(json.code>0){
					console.log(json.data);
					$('input[name=times]').val(json.data.times);
					$('input[name=toprank]').val(json.data.toprank);
					$('select[name=status]').val(json.data.status);
					$('select[name=winningagain]').val(json.data.winningagain);
					$('select[name=showstyle]').val(json.data.showstyle);
					// $('select[name=editable]').val(json.data.editable);
				}
			}
		})
	}else{
		$('input[name=times]').val(30);
		$('input[name=toprank]').val(3);
		$('select[name=status]').val(1);
		$('select[name=winningagain]').val(1);
		$('select[name=showstyle]').val(1);
	}
	
	$('#configmodal').modal('show');
}

function saveconfig(){
	var id=$('input[name=id]').val();
	var times=$('input[name=times]').val();
	var toprank=$('input[name=toprank]').val();
	var status=$('select[name=status]').val();
	var winningagain=$('select[name=winningagain]').val();
	var showstyle=$('select[name=showstyle]').val();
	
	$.ajax({
		"url":"dopashu.php?action=saveconfig",
		"type":"post",
		"data":{"id":id,"times":times,"toprank":toprank,"status":status,"winningagain":winningagain,"showstyle":showstyle},
		"dataType":"json",
		"success":function(json){
			if(json.code>0){
				window.location.reload();
			}else{
				alert(json.message);
			}
		}
	});
}
{/literal}
</script>
{include file="templates/html_footer.html"}