<?php
error_reporting(0); 
include("../../config/ht.php");
session_start();
if(!isset($_SESSION['adminname'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/houtai/'</script>";exit;}
$adminname=$_SESSION['adminname'];
$type="where name='$adminname'";
$adminpd=queryall(admin,$type);
if(!$adminpd){echo "<script>alert('请重新登录!')</script><script>top.location.href='/houtai/'</script>";exit;}
if($adminpd[qx]=='超级管理员'){}else{echo "<script>alert('无权限')</script><script>top.location.href='/houtai/'</script>";exit;}
$ddh=ubo($_GET["ddh"]);
?>
<!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">
<link rel="stylesheet" href="/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/font-awesome.min.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/admin.css" media="all">
<script src="/layui/layui.js"></script>
<script src="/2019newui/js/jquery.min.js"></script>
<style type="text/css">
#tooltip{position:absolute;border:1px solid #ccc;background:#333;padding:2px;display:none;color:#fff;}
</style>
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;"><legend>订单列表</legend></fieldset>
<form  action="" method="get">
<div class="layui-tab layui-tab-brief">
<div class="layui-tab layui-tab-brief">
<div class="layui-tab-content">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">订单号</label>
<div class="layui-input-block">
<input type="text"  name="ddh"  id="ddh"  autocomplete="off" class="layui-input" value="<?php if($ddh){echo $ddh;}?>">
</div>
</div>
<button class="layui-btn" style="margin-top:-5px;"><i class="layui-icon" style="">&#xe615;</i> 查询</button>
</div>
</div> 
</form>
<table class="layui-table">
<?php 
$sql = "WHERE 1=1";
$sql .="   and shijian  like '%".$day."%'";
if($ddh){
$sql .="   and ddh='$ddh'";
}
$sql2 = "WHERE 1=1";
$sql2 .="   and shijian  like '%".$zuori."%' ";
if($ddh){
$sql2 .="   and ddh='$ddh'";
}
$sql3 = "WHERE 1=1";
if($ddh){
$sql3 .="   and ddh='$ddh'";
}
$sqlt="select sum(money) from dingdan   ".$sql." ";
if ($res=mysql_query($sqlt)){
list($money1)=mysql_fetch_row($res);
mysql_free_result($res);
} 
$sqlb="select sum(money) from dingdan  ".$sql2." ";
if ($res=mysql_query($sqlb)){
list($money2)=mysql_fetch_row($res);
mysql_free_result($res);
} 
$sqlq = mysql_query("SELECT * FROM dingdan  ".$sql."  ");
$daydd = mysql_num_rows($sqlq);
$sqlx = mysql_query("SELECT * FROM dingdan  ".$sql2." ");
$zdd = mysql_num_rows($sqlx);
$sqle = mysql_query("SELECT * FROM dingdan   ".$sql3."");
$z = mysql_num_rows($sqle);
$sqlc="select sum(money) from dingdan  ".$sql3." ";
if ($res=mysql_query($sqlc)){
list($money5)=mysql_fetch_row($res);
mysql_free_result($res);
} 
?>
<thead>
<tr>
<th style="text-align:center;">今日订单笔数</th>
<th style="text-align:center;">昨日订单笔数</th>
<th style="text-align:center;">今日订单总金额</th>
<th style="text-align:center;">昨日订单总金额</th>
<th style="text-align:center;">历史总笔数</th>
<th style="text-align:center;">历史总金额</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center;"><?php echo $daydd?> 笔</td>
<td style="text-align:center;"><?php echo $zdd?> 笔</td>
<td style="text-align:center;"><?php if($money1 == null){ ?>￥0元<?php }else{  ?>￥<?php $xs1=round($money1,2);echo $xs1;?> 元<?php } ?></td>
<td style="text-align:center;"><?php if($money2 == null){ ?>￥0元<?php }else{  ?>￥<?php $xs1=round($money2,2);echo $xs1;?> 元<?php } ?></td>
<td style="text-align:center;"><?php echo $z?> 笔</td>
<td style="text-align:center;"><?php if($money5 == null){ ?>￥0元<?php }else{  ?>￥<?php $xs1=round($money5,2);echo $xs1;?> 元<?php } ?></td>
</tr>
</tbody>
</table>
<hr>
<table class="layui-table">
<thead>
<tr>
<th style="text-align:center;width:34px;" >勾选</th>
<th style="text-align:center;"  >代理ID</th>
<th style="text-align:center;"  >视频ID</th>
<th style="text-align:center;"  >视频名称</th>
<th style="text-align:center;"  >打赏金额</th>
<th style="text-align:center;"  >订单日期</th>
<th style="text-align:center;"  >订单号</th>
<th style="text-align:center;"  >微信订单号</th>
</tr>
</thead>
<tbody>
<?php 
$page_size=10; 
$sql = "WHERE 1=1";
if($ddh){
$sql .="   and ddh='$ddh'";
}
$resultyttrt = mysql_query("select id from dingdan   ".$sql."  ");
$count = mysql_num_rows($resultyttrt); 
if($count == 0){echo '<tr> <td  colspan=18  style="text-align:center;"><center>没有记录</center></td></tr>';}
$page_count = ceil($count/$page_size); 
$init=1; 
$page_len=7; 
$max_p=$page_count; 
$pages=$page_count; 
//判断当前页码 
if(empty($_GET['page'])||$_GET['page']<0){ 
$page=1; 
}else { 
$page=$_GET['page']; 
} 
$offset=$page_size*($page-1); 
$query = mysql_query("select * from  dingdan   ".$sql." order by id desc   limit $offset, $page_size");
while ($a=mysql_fetch_array($query)) { 
?> 	
<tr>
<td style="text-align:center;" ><label class="demo--label2"><input class="demo--radio" type="checkbox"   name="ids[]" id="ck-<?php echo $a['id']?>" value="<?php echo $a['id']?>"><span class="demo--checkbox demo--radioInput"></span>   </label></td>
<td style="text-align:center;" ><?php echo $a[userid]?></td>
<td style="text-align:center;" ><?php echo $a[zyid]?></td>
<td style="text-align:center;" ><?php echo $a[zymc]?></td>
<td style="text-align:center;" ><?php echo $a[money]?></td>
<td style="text-align:center;" ><?php echo $a[shijian]?></td>
<td style="text-align:center;" ><?php echo $a[ddh]?></td>
<td style="text-align:center;" ><?php echo $a[wxddh]?></td>
</tr>
<?php 
} 
$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数 
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量 
if($page!=1){ 
$keyt.="<a href=\""."/htdingdanpage/1/\">首页</a>"; //首页 
$keyt.="<a href=\""."/htdingdanpage/".($page-1)."/\">上一页 </a>"; //上一页 
}else { 
$keyt.="<p>首页</p>"; //首页 
$keyt.="<p>上一页 </p>"; //上一页  
} 
if($pages>$page_len){ 
//如果当前页小于等于左偏移 
if($page<=$pageoffset){ 
$init=1; 
$max_p = $page_len; 
}else{//如果当前页大于左偏移 
//如果当前页码右偏移超出最大分页数 
if($page+$pageoffset>=$pages+1){ 
$init = $pages-$page_len+1; 
}else{ 
//左右偏移都存在时的计算 
$init = $page-$pageoffset; 
$max_p = $page+$pageoffset; 
} 
} 
} 
for($i=$init;$i<=$max_p;$i++){ 
if($i==$page){ 
$keyt.='<a class="cur">'.$i.'</a>'; 
} else { 
$keyt.="<a href=\""."/htdingdanpage/".$i."/\">".$i."</a>"; 
} 
} 
if($page!=$pages){ 
$keyt.="<a href=\""."/htdingdanpage/".($page+1)."/\">下一页 </a> ";//下一页 
$keyt.="<a href=\""."/htdingdanpage/{$pages}/\">尾页</a> "; //最后一页 
}else { 
$keyt.="<p>下一页 </p>";//下一页 
$keyt.="<p>尾页</p>"; //最后一页 
} 
$keyt.="<p class='pageRemark' >当前第 <b>$page</b> 页/共 <b>$pages</b> 页  共 <b>$count</b> 条数据 </p>"; //第几页,共几页 
?> 
<?php if($count =="0"){?>
<?php }else{?>
<tr>
<td  colspan="18" style="text-align:left;padding-left:20px;" >
<a class="btn btn-success btn-xs chk-all" href="#" role="button">全选</a>  
<a class="btn btn-danger btn-xs unchk-all" href="#" role="button">全不选</a>
<a class="btn  btn-success  btn-xs btn-jiage ddsc"  role="button">批量删除</a>
<?php if(!$ddh){?>
<a class="btn btn-success btn-xs"  role="button" onClick="zr()">删除昨日订单</a>  
<a class="btn btn-danger btn-xs"   role="button" onClick="qt()">删除7天内订单</a>
<a class="btn  btn-success  btn-xs btn-jiage"  role="button" onClick="yy()">删除30天内订单</a>
<a class="btn  btn-success  btn-xs btn-jiage"  role="button"  onClick="sy()">删除所有订单</a>
<?php }?>
</td>
</tr>
<?php }?>
</tbody>
</table>
<div style="padding:0 20px;">
<div class="pagination">
<?php if(!$ddh){?>
<?php if($count =="0"){?><?php }else{?><?php echo $keyt?><?php }?>
<?php }?>
</div>
</div>
</div>

<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>
<?php if($count =="0"){?>
<?php }else{?>
<script>
$(document).on('click', '.chk-all', function(event) {
event.preventDefault();
$('input[name="ids[]"]').prop('checked', 'checked');
});
$(document).on('click', '.unchk-all', function(event) {
event.preventDefault();
$('input[name="ids[]"]').prop('checked', false);
});
$(document).on('click', '.ddsc', function(event) {
event.preventDefault();
var _ids = '';
$.each($('input[name="ids[]"]:checked'), function(index, val) {
_ids += $(val).val()+',';
});
if (_ids == '') {
layer.msg('请选择ID');
return false;
}
layer.open({
title: '请输入安全码',
area: '220px',
shade: 0.8,
content: '<div class="mark"><div style="margin: 0px 0px 10px 1px;"><span><input type="text" value=""  id="aqm" style="width: 88%;height:30px;" placeholder="安全码" ><br><br><div>请输入安全码，以保证数据安全</div></div></div>',
btn: ['确认'],
shadeClose: false,
yes: function(){
var aqm = $("#aqm").val();
if (aqm == '') {
layer.msg('请输入安全码');
return false;
}
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {aqm:aqm, lx: 'ddsc',id:_ids},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
},
});
});
function zr() {
layer.open({
title: '请输入安全码',
area: '220px',
shade: 0.8,
content: '<div class="mark"><div style="margin: 0px 0px 10px 1px;"><span><input type="text" value=""  id="aqm" style="width: 88%;height:30px;" placeholder="安全码" ><br><br><div>请输入安全码，以保证数据安全</div></div></div>',
btn: ['确认'],
shadeClose: false,
yes: function(){
var aqm = $("#aqm").val();
if (aqm == '') {
layer.msg('请输入安全码');
return false;
}
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {aqm:aqm, lx: 'ddzr'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
},
});
}
function qt() {
layer.open({
title: '请输入安全码',
area: '220px',
shade: 0.8,
content: '<div class="mark"><div style="margin: 0px 0px 10px 1px;"><span><input type="text" value=""  id="aqm" style="width: 88%;height:30px;" placeholder="安全码" ><br><br><div>请输入安全码，以保证数据安全</div></div></div>',
btn: ['确认'],
shadeClose: false,
yes: function(){
var aqm = $("#aqm").val();
if (aqm == '') {
layer.msg('请输入安全码');
return false;
}
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {aqm:aqm, lx: 'ddqt'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
},
});
}
function yy() {
layer.open({
title: '请输入安全码',
area: '220px',
shade: 0.8,
content: '<div class="mark"><div style="margin: 0px 0px 10px 1px;"><span><input type="text" value=""  id="aqm" style="width: 88%;height:30px;" placeholder="安全码" ><br><br><div>请输入安全码，以保证数据安全</div></div></div>',
btn: ['确认'],
shadeClose: false,
yes: function(){
var aqm = $("#aqm").val();
if (aqm == '') {
layer.msg('请输入安全码');
return false;
}
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {aqm:aqm, lx: 'ddyy'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
},
});
}
function sy() {
layer.open({
title: '请输入安全码',
area: '220px',
shade: 0.8,
content: '<div class="mark"><div style="margin: 0px 0px 10px 1px;"><span><input type="text" value=""  id="aqm" style="width: 88%;height:30px;" placeholder="安全码" ><br><br><div>请输入安全码，以保证数据安全</div></div></div>',
btn: ['确认'],
shadeClose: false,
yes: function(){
var aqm = $("#aqm").val();
if (aqm == '') {
layer.msg('请输入安全码');
return false;
}
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {aqm:aqm, lx: 'ddsy'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
},
});
}
</script>
<?php }?>
</body>
</html>