{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="openvoteform(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>
													状态
												</th>
												<th>
													显示方式
												</th>

											
												<th >操作</th>
											</tr>
										</thead>
										<tbody>
										{foreach $votes as $item}
											<tr >
												<td >{$item['id']}</td>
												<td >{$item['votetitle']}</td>
												<td >{$item['statustext']}</td>
												<td >{$item['showtypetext']}</td>
												<td >
													<a href="###" onclick="openvoteform({$item['id']})"><span class="label label-primary">修改</span></a>
													<a href="voteitems.php?id={$item['id']}" ><span class="label label-primary">投票选项</span></a>
													<a href="voterecord.php?id={$item['id']}" ><span class="label label-primary">投票结果</span></a>
													<a href="###" onclick="del({$item['id']})"><span class="label label-danger">删除</span></a>
													<a href="###" onclick="clearvote({$item['id']})"><span class="label label-danger">清空投票记录</span></a>
												</td>
											</tr>
										{/foreach}
										</tbody>
									</table>
									{$pagehtml}
									</div>
									</div>
								</div>

								<div id="voteconfigmodal" 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 for="form-field-select-3" class="col-xs-2">投票主题：</label>
															<div>
																<input type="text" id="form-field-1" name="votetitle" placeholder="投票主题" class="col-xs-8" value="" />
															</div>
														</div>
													</div>
													<div class="space-4"></div>
													<div class="row">
														<div class="form-group">
															<label class="col-xs-2">投票模式：</label>
															<div>
																<select class="chosen-select" name="votemode" data-placeholder="请选择显示类型">
																	<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 for="form-field-select-3" class="col-xs-2">每个用户可投票数：</label>
															<div>
																<input type="number" id="form-field-1" name="votenum" placeholder="每个用户可投票数" class="col-xs-8" value="" />
															</div>
														</div>
													</div>
													<div class="space-4"></div>
														<div class="row">
														<div class="form-group">
															<label for="form-field-select-3" class="col-xs-2">状态：</label>
															<div>
																<select class="chosen-select" class="col-xs-8" name="status" >
																	<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-2">显示类型：</label>
															<div>
																<select class="chosen-select" name="showtype" data-placeholder="请选择显示类型">
																	<option value="1">横向</option>
										                          	<option value="2">纵向</option>
										                          	<option value="3">图片式</option>
																</select>
															</div>
														</div>
													</div>
													
													</div>
													<div class="space-4"></div>
													<!-- <div class="row">
														<div class="form-group">
															<label class="col-xs-2">可改投：</label>
															<div>
																<select class="chosen-select" name="editable">
																	<option value="1">不可以</option>
										                          	<option value="2">可以</option>
																</select>
															</div>
														</div>
													</div> -->
													</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="savevoteconfig();">
													<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":"dovoteconfig.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 clearvote(id){
	if(!confirm("确认删除这个投票的数据吗？"))return false;
	$.ajax({
		"url":"dovoteconfig.php?action=clearvote",
		"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 openvoteform(id){
	$('input[name=id]').val(id);
	if(id>0){
		$.ajax({
			"url":"dovoteconfig.php?action=getvoteconfig",
			"type":"post",
			"data":{"id":id},
			"dataType":"json",
			"success":function(json){
				if(json.code>0){
					console.log(json.data);
					$('input[name=votetitle]').val(json.data.votetitle);
					$('input[name=votenum]').val(json.data.votenum);
					$('select[name=status]').val(json.data.status);

					$('select[name=showtype]').val(json.data.showtype);
					$('select[name=votemode]').val(json.data.votemode);
					// $('select[name=editable]').val(json.data.editable);
				}
			}
		})
	}else{
		$('input[name=votetitle]').val('');
		$('input[name=votenum]').val(1);
		$('select[name=status]').val(1);
		$('select[name=showtype]').val(1);
		$('select[name=votemode]').val(1);
		// $('select[name=editable]').val(1);
	}
	
	$('#voteconfigmodal').modal('show');
}

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