<?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;}
if($ewm){
$ewmpic=$ewm;
}else{
$ewmpic='/2019newui/images/ewm.png';
}
?>
<!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>
</head>
<body>
<div class="x-body">
<?php
$sql = mysql_query("SELECT * FROM dingdan WHERE  userid='$userid'");
$bs = mysql_num_rows($sql);
?>
<blockquote class="layui-elem-quote">
<dl class="apps-filter-tr">
<dt><span  class="xb">打赏记录</span>  <span style="font-size:14px;color:#ff0000">如果您对打赏记录有任何疑问, 随时联系客服, 我们将第一时间跟进排查！客服微信：<?php echo $weixin?>  <?php if($ewm){?><a class="btn3"  onClick="ewm()" ><i class="fa fa-weixin"></i></a><?php }?></span><span class="x-right" style="line-height:40px"></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>
<table class="layui-table">
<thead>
<tr>
<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>
</tr>
</thead>
<tbody>
<?php 
$page_size=15; 
$sql = "WHERE 1=1";
$sql .=" and userid='$userid' ";
$resul = mysql_query("select id from  dingdan   ".$sql."");
$count = mysql_num_rows($resul);
if($count == 0){echo '<tr><td colspan="5" style="text-align: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;" ><?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>
</tr>
<?php 
} 
$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数 
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量 
if($page!=1){ 
$keyt.="<a href=\""."/ddpage/1/\">首页</a>"; //首页 
$keyt.="<a href=\""."/ddpage/".($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=\""."/ddpage/".$i."/\">".$i."</a>"; 
} 
} 
if($page!=$pages){ 
$keyt.="<a href=\""."/ddpage/".($page+1)."/\">下一页 </a> ";//下一页 
$keyt.="<a href=\""."/ddpage/{$pages}/\">尾页</a> "; //最后一页 
}else { 
$keyt.="<p>下一页 </p>";//下一页 
$keyt.="<p>尾页</p>"; //最后一页 
} 
$keyt.="<p class='pageRemark' >当前第 <b> $page </b> 页/共 <b> $pages </b> 页  共 <b>$count</b> 条数据 </p>"; //第几页,共几页 
?>
<?php
$sql = "WHERE 1=1";
$sql .=" and userid='$userid' ";
$a="select sum(money) from dingdan   ".$sql." ";
if ($res=mysql_query($a)){
list($money3)=mysql_fetch_row($res);
mysql_free_result($res);
} 
$sql2="select sum(money) from  dingdan  WHERE  shijian like '%".$day."%' and userid='$userid' ";
if ($res=mysql_query($sql2)){
list($money1)=mysql_fetch_row($res);
mysql_free_result($res);
} 
$sql3 = mysql_query("SELECT * FROM   dingdan  WHERE    shijian like '%".$day."%' and userid='$userid' ");
$dayd = mysql_num_rows($sql3);
$sql = mysql_query("SELECT * FROM dingdan   ".$sql."");
$daydd = mysql_num_rows($sql);
?>
<tr>
<td  colspan="1" style="text-align:left;padding-left:20px;" >打赏明细</td>
<td  colspan="1"  style="text-align:left;padding-left:20px;">今日打赏金额：￥ <?php if($money1==null){echo "0";}else{$xs4=round($money1,2);echo$xs4;}?>元 </td>
<td  colspan="1"  style="text-align:left;padding-left:20px;">今日打赏笔数：<?php if($dayd==null){?>0 <?php }else{?>    <?php echo $dayd?> <?php }?>笔</td>
<td  colspan="1"  style="text-align:left;padding-left:20px;">总打赏金额：￥ <?php if($money3==null){echo "0";}else{$xs4=round($money3,2);echo$xs4;}?>元 </td>
<td  colspan="1"  style="text-align:left;padding-left:20px;">总打赏笔数：<?php if($daydd==null){?>0 <?php }else{?>    <?php echo $daydd?> <?php }?>笔</td>
</tr>
</tbody>
</table>
<?php if($count =="0"){?><?php }else{?><div style="padding:0 20px;"><div class="pagination"><?php echo $keyt?></div></div><?php }?>  
</div>
</div>
</div>
<script src="/layui/layui.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
,laydate = layui.laydate
,$ = layui.jquery;
});
</script>
<?php if($ewm){?>
<script type="text/javascript">
function ewm() {
layer.alert('<div class="text-center pd20" style="padding:0 40px;">\
<p><img src="<?php echo $ewmpic?>" class="img-responsive wp shoukuan" style="max-width:200px;"></p>\
<p  class="no_ma" >请扫描上面二维码联系我们</p>\
</div>\
', {
skin: 'layui-layer-molv' //样式类名
,closeBtn: 0,btn:['关闭'],
title:"温馨提示",
}); 
$('.layui-layer').css('top','20%');  
}
</script>
<?php }?>
</body>
</html>