<?php
error_reporting(0); 
include("../../config/qiantai.php");
session_start();
if(!isset($_SESSION['username'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/index$dshz'</script>";exit;}
$username=ubo($_SESSION['username']);
$type="where name='$username'";
$user=queryall(user,$type);
$userid=$user['userid'];
if(!$user){echo "<script>alert('请重新登录!')</script><script>top.location.href='/index$dshz'</script>";exit;}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>盒子模板</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="/2019newui/qiantai/css/x-admin.css" media="all">
<script src="/2019newui/js/jquery.min.js"></script>
<link rel="stylesheet" href="/2019newui/qiantai/css/bootstrap.min.css">
</head>
<body>
<div class="x-body">
<?php
$sql = mysql_query("SELECT * FROM hzmb WHERE  sz='1'");
$bs = mysql_num_rows($sql);
?>
<blockquote class="layui-elem-quote">
<dl class="apps-filter-tr">
<dt><span  class="xb">盒子模板</span></dt>
</dl>
<span class="x-right" style="margin-top:-24px;line-height:10px">共有盒子模板：<?php echo $bs?> 套 <a class="layui-btn-small" style="line-height:10px;margin-top:-2px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="fa fa-refresh"></i></a></span>
</blockquote>
<div class="page-content">
<div class="content">
<blockquote class="layui-elem-quote">
第一步：选择你喜欢的盒子模板 <br>
第二步：预览模板，若没有问题即可设置该模板为您的盒子模板<br>
</blockquote>
<div class="row">
<?php 
$result = mysql_query("SELECT * FROM  hzmb where sz='1' ");
$count = mysql_num_rows($result);
?>
<?php if($count == 0){?><center>暂无模板可以选择</center><?php }?>
<?php
$query = mysql_query("SELECT * FROM hzmb where sz='1' order by id desc   ");
while($a = mysql_fetch_array($query)) {
?> 
<div class="col-md-2 text-center">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $a[mbmc]?></h3>
<div class="actions pull-right">
</div>
</div>
<div class="panel-body" >
<img src="<?php echo $a[pic]?>" style="height:400px;width:100%;"  onerror="this.src = '/2019newui/images/nopic.jpg'" >
</div>
<div class="panel-footer">
<button class="btn<?php if($user[hzmb]==$a[id]){?> btn-danger<?php }else{?> btn-info<?php }?>"   <?php if($user[hzmb]==$a[id]){?><?php }else{?>onclick="hezisz('<?php echo $a[id]?>')"<?php }?>><?php if($user[hzmb]==$a[id]){?>已使用<?php }else{?>使用<?php }?></button>
</div>
</div>
</div>
<?php }?>
</div>
</div>
</div>
</div>
</div>
<div style="height:80px;"></div>
<script src="/layui/layui.js" charset="utf-8"></script> 
<script src="/2019newui/js/x-admin.js"></script> 
<script>
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery', 'layer'], function(){
var form = layui.form
,layer   = layui.layer
,layedit = layui.layedit
,element = layui.element
,$= layui.jquery
,laydate = layui.laydate;
});
</script>
<script type="text/javascript">
function hezisz(id) {
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/post<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {lx:'hezisz',id:id},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('设置成功');
location.reload();
} 
},
error:function(){
}
});
}
</script>
</body>
</html>