Browse Source

v1.21 add 按时间筛选

pull/16/head
xiaoz 6 years ago
parent
commit
0f8a9df6aa
  1. 8
      admin/index.php
  2. 39
      admin/senioradmin.php
  3. 20
      functions/class/class.admin.php
  4. 2
      functions/version.txt
  5. 17
      static/embed.js
  6. 15
      tpl/admin/footer.php

8
admin/index.php

@ -16,14 +16,17 @@ @@ -16,14 +16,17 @@
<!-- 后台内容部分 -->
<div class="layui-col-lg9">
<div>
<h2>数据统计</h2>
<table class="layui-table">
<colgroup>
<col width="33%">
<col width="33%">
<col width="25%">
<col width="25%">
<col width="25%">
<col>
</colgroup>
<thead>
<tr>
<th>累积上传</th>
<th>本月上传数量</th>
<th>今日上传</th>
<th>可疑图片</th>
@ -31,6 +34,7 @@ @@ -31,6 +34,7 @@
</thead>
<tbody>
<tr>
<td><?php echo $data['all']; ?></td>
<td><?php echo $data['month']; ?></td>
<td><?php echo $data['day']; ?></td>
<td><?php echo $data['level']; ?></td>

39
admin/senioradmin.php

@ -8,14 +8,32 @@ @@ -8,14 +8,32 @@
$type = $_GET['type'];
//获取页数
$page = $_GET['page'];
//获取时间
@$date = $_GET['date'];
//如果时间不为空
if($date != ''){
$thedate = explode("|",$date);
$starttime = $thedate[0];
$endtime = $thedate[1];
//翻页选项
$thepage = '&date='.$date;
}
else{
$starttime = '';
//获取当前日期
$endtime = date("Y-m-d",time());
//翻页选项
$thepage = '';
}
//查询图片
$imgs = $pic->querypic($type,$page);
$imgs = $pic->querypic($type,$page,$date);
$up = (int)$page - 1;
if($up <= 0){
$up = 1;
}
$down = (int)$page +1;
?>
<div class="layui-container" style = "margin-top:2em;">
@ -27,6 +45,21 @@ @@ -27,6 +45,21 @@
<!-- 后台内容部分 -->
<div id = "adminpic">
<div class="layui-col-lg9">
<!--时间筛选-->
<div id="date">
<table class="layui-table" lay-skin="nob">
<tbody>
<tr>
<td>按时间筛选:</td>
<td><input type="text" class="layui-input" id="starttime" value = "<?php echo $starttime; ?>"></td>
<td> - </td>
<td><input type="text" class="layui-input" id="endtime" value = "<?php echo $endtime; ?>"></td>
<td><button lay-submit class="layui-btn" onclick = "screen()">筛选</button></td>
</tr>
</tbody>
</table>
</div>
<!--时间筛选END-->
<!-- 表格 -->
<table class="layui-table">
<colgroup>
@ -100,8 +133,8 @@ @@ -100,8 +133,8 @@
<!-- 翻页按钮 -->
<div class="layui-col-lg9 layui-col-md-offset3">
<div class="page">
<a href="?type=<?php echo $type; ?>&page=<?php echo $up; ?>" class="layui-btn">上一页</a>
<a href="?type=<?php echo $type; ?>&page=<?php echo $down; ?>" class="layui-btn">下一页</a>
<a href="?type=<?php echo $type; ?>&page=<?php echo $up.$thepage; ?>" class="layui-btn">上一页</a>
<a href="?type=<?php echo $type; ?>&page=<?php echo $down.$thepage; ?>" class="layui-btn">下一页</a>
</div>
</div>
<!-- 翻页按钮END -->

20
functions/class/class.admin.php

@ -25,7 +25,15 @@ @@ -25,7 +25,15 @@
}
}
//查询图片
function querypic($type,$page){
function querypic($type,$page,$date = null){
//对时间进行拆分
if($date != null){
$date = explode("|",$date);
$starttime = $date[0];
$endttime = $date[1];
}
$config = $this->config;
$database = $this->database;
@ -78,7 +86,10 @@ @@ -78,7 +86,10 @@
return $datas;
break;
default:
echo 'dsddsd';
$sql = "SELECT * FROM imginfo WHERE date(date) BETWEEN '$starttime' AND '$endttime' ORDER BY `id` DESC LIMIT $num OFFSET $start";
$datas = $database->query($sql);
return $datas;
break;
}
}
@ -125,12 +136,15 @@ @@ -125,12 +136,15 @@
$level = $this->database->count("imginfo",[
"level" => 3
]);
//统计全部图片
$all = $this->database->count("imginfo");
//返回数据
$redata = array(
"month" => $month,
"day" => $day,
"level" => $level
"level" => $level,
"all" => $all
);
return $redata;
}

2
functions/version.txt

@ -1 +1 @@ @@ -1 +1 @@
v1.20(20180811)
v1.21(20180831)

17
static/embed.js

@ -452,3 +452,20 @@ function urlup(){ @@ -452,3 +452,20 @@ function urlup(){
}
});
}
//时间筛选
function screen(){
var starttime = $("#starttime").val();
var endtime = $("#endtime").val();
if((starttime == '') || (endtime == '')){
layui.use('layer', function(){
var layer = layui.layer;
layer.msg('请选择时间!');
});
}
else{
window.location.href = "./senioradmin.php?page=1&date=" + starttime + '|' + endtime;
}
}

15
tpl/admin/footer.php

@ -13,6 +13,19 @@ @@ -13,6 +13,19 @@
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="../static/layui/layui.js"></script>
<script src="../static/embed.js?v=1.21"></script>
<script src="../static/embed.js?v=1.22"></script>
<script>
layui.use('laydate', function(){
var laydate = layui.laydate;
//执行一个laydate实例
laydate.render({
elem: '#starttime' //指定元素
});
laydate.render({
elem: '#endtime' //指定元素
});
});
</script>
</body>
</html>
Loading…
Cancel
Save