{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">
								<!-- 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_addaward">添加奖品</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>
																</tr>
															</thead>
															<tbody>
															{foreach $awardlist $item}
																<tr>
																<td class="">{$item['id']}</td>
																	<td class="">{$item['awardname']}</td>
																	<td class=""><img src="{$item['imagepath']}" style="width:60px;height:60px;" /></td>
																	<td>
																		<a href="###" onclick="editaward('{$item['id']}')"><span class="label label-info">修改</span></a>
																		<a href="###" onclick="delaward('{$item['id']}')"><span class="label label-danger">删除</span></a>
																	</td>
																</tr>
															{/foreach}
															</tbody>
														</table>
													</div>
												</div>
									</div>
									<div id="award-form" class="modal" tabindex="-1">
									<div class="modal-dialog">
									
										<div class="modal-content">
										<form id="saveawardform" action="doawardlist.php?action=save" method="post" enctype="multipart/form-data">
											<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">
											
											<!-- #section:elements.tab -->
											<div class="form-group">
												<label for="text3d" class="col-md-3">奖品名称：</label>
												<div class="col-md-9">
													<input type="text" id="awardname" name="awardname" placeholder="请输入奖品名称" value="" style="width:80%;"/>
												</div>
											</div>
											<div class="form-group">
											<label for="awardimage" class="col-md-3">奖品图片：</label>
											<div class="col-md-9">
											<input type="file" class="imageuploader" name="imagepath"/>
											</div>
											</div>
											
											</div>
											</div>

											<div class="modal-footer">
												<input type="hidden" name="id" value="0" />
												<input type="hidden" name="fromplug" value="{$currentplug}" />
												<button class="btn btn-sm" data-dismiss="modal">
													<i class="ace-icon fa fa-times"></i>
													取消
												</button>
												<button class="btn btn-sm btn-primary btn-save-item">
													<i class="ace-icon fa fa-check"></i>
													保存
												</button>
											</div>
											</form>
										</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 src="assets/ace_v1.4/components/jqGrid/js/jquery.jqGrid.js"></script>
<script src="assets/ace_v1.4/components/jqGrid/js/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="assets/js/jquery.form.js"></script>
<script type="text/javascript">
{literal}
function editaward(id){
	$.ajax({
		"url":"doawardlist.php?action=get",
		"type":"post",
		"dataType":"json",
		"data":{"id":id},
		"success":function(json){
			if(json.code>0){
				$('input[name=id]').val(id);
				$('#awardname').val(json.data.awardname);
				//$('.imageuploader').val();
				if(json.data.imagepath!=null){
					$('input[name=imagepath]')
					.ace_file_input('show_file_list', [
						{type: 'image', name: '背景图', path:json.data.imagepath },
					]);
				}
				
				
				$('#award-form').modal('show');
			}else{
				alert(json.message);
			}
		}
	})
	
}
function delaward(id){
	if(!confirm("确认要删除奖品吗？"))return false;
	$.ajax({
		"url":"doawardlist.php?action=del",
		"type":"post",
		"dataType":"json",
		"data":{"id":id},
		"success":function(json){
			if(json.code>0){
				window.location.reload();
			}else{
				alert(json.message);
			}
		}
	})
}
$(function(){
	$('.btn_addaward').bind('click',function(){
		$('input[name=id]').val(0);
		$('#awardname').val('');
		$('.imageuploader').val();
		$('#award-form').modal('show');
	});
	
	$('.imageuploader').ace_file_input({
		style: 'well',
		btn_choose: '点击此处选择图片',
		btn_change: null,
		no_icon: 'ace-icon fa fa-cloud-upload',
		droppable: true,
		maxSize: 550000,
		allowExt: ["jpeg", "jpg", "png", "gif"],
		allowMime: ["image/jpg", "image/jpeg", "image/png", "image/gif"],
		thumbnail: 'large',//large | fit
		previewHeight:200,
		preview_error : function(filename, error_code) {
		}
	}).on('change', function(){
		
	});
	//保存信息
	$('.btn-save-item').bind('click',function(){
		$('#saveawardform').ajaxSubmit({
			dataType: 'json',
			success:function(json){
				if(json.code>0){
					window.location.reload();
				}else{
					alert(json.message);
				}
			}
		});
		return false;
	});
})

{/literal}
</script>
{include file="templates/html_footer.html"}