<?php
session_start();
require_once "../init.php";
//require_once "../security_a.inc.php";
require_once "../authority.inc.php";

$payresult = $_GET['payresult'];

$hot=1;
$iActive=100;
?>
<?php
$keyword=trim($keyword);
if($keyword){
	$wheres=" AND (oid like '%$keyword%' or UserName like '%$keyword%' or `datetime` like '%$keyword%' or paymode like '%$keyword%' )";
}
//按日期搜索
if($to){
	  $wheres=" AND (`datetime` between '$from' and  '$to' OR SUBSTRING(`datetime`,1,10)='$to')";
}
if($from){
	  $wheres=" AND (`datetime` >='$from')";
}
if($payresult!=""){
	$wheres.=" AND payresult='$payresult'";
}
//代理管理用户还是系统超管理用户,系统超级用户可以列出全部,代理管理用户只能列出代理本身的
//if($_SESSION['Perm_S']!="|SYSTEM|") $wheres .=" AND (AgentID='".$_SESSION['AgentID_S']."') ";
//得到总记录数
$sql="select count(*) from onlinepay where 1 $wheres";
$rs=$DB->query($sql);
$pageSize=30;
$totalRecord=$DB->result($rs,0,0);
$totalPage=ceil($totalRecord/$pageSize);
if(!$page)$page=1;
$offset=($page-1)*$pageSize;
//查询
$sql="select * from onlinepay where 1 $wheres order by `datetime` DESC limit $offset,$pageSize";
$result=$DB->query($sql);
$pageList=getPageList($_SERVER[PHP_SELF],"page","15",$totalPage,$page);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>财务管理--网上支付记录</title>
<LINK href="../share/style.css" rel=stylesheet>
<script src="../share/global.js"></script>
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
<script src="../share/cal.js"></script>
</head>
<body>
<? include "../share/top.php"?>
<div id="topLink">
<div id="topInfo">
	<span class="tTitle">财务记录</span>
	
</div>
</div><div class="page-container">
<!--子导航-->
<? include "financial_nav.inc.php"?>
<!--结束-->

<div id="search">
<form method='post' action='<?=$_SERVER['PHP_SELF']?>'>
<a href="<?=$_SERVER[PHP_SELF]?>">全部</a> -
<a href="<?=$_SERVER[PHP_SELF]?>?payresult=20">支付成功的</a> -
<a href="<?=$_SERVER[PHP_SELF]?>?payresult=30">支付失败的</a> -
<? include "../share/cal.php"?>
<select name='payresult'>
   <option value="">不限</option>
   <option value="20" <? if($payresult=="20")echo "selected"?>>支付成功</option>
   <option value="30" <? if($payresult=="30")echo "selected"?>>支付失败</option>
</select>
<input type="text" name="keyword" class="input">
<input type="submit" value="搜索" class="bt2">
</form>
</div>
<form method='post' action='financial_onlinepay_del.php'>
<div id="page">
<?
	$pageStr='<div id="dels"><input type="submit" value="删除选中" class="bt2"></div>';
	$pageStr.="共 $totalRecord 条记录,共 $totalPage 页,当前第 $page 页";
	echo $pageStr;
?>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table table-border table-bordered table-bg table-hover table-sort">
  <tr id="tr">
	<td><input type="checkbox" value="1" onClick="selectAll(this.form,this,'oid[]')" class='checkbox'></td>
	<td>订单号</td>
	<td>用户</td>
	<td>金额</td>
	<td>支付结果</td>
	<td>支付方式</td>
	<td>支付时间</td>
  </tr>
  <? 
	$status=array(0=>'未交费','1'=>'已提交','20'=>'支付成功','30'=>'支付失败');
	while($OInfo=$DB->fetch_array($result)){
  ?>
  <tr id="td" onMouseOut="outStyle(this)" onMouseOver="inStyle(this)">
	<td>
	  <?
		 $deadline=(strtotime("now")-strtotime("$OInfo[datetime]"))/86400>180;//只保留六个月内的网上支付数据
		 if(($OInfo[payresult]!=20)||$deadline){
			echo "<input type='checkbox' name='oid[]' value='$OInfo[oid]' class='checkbox'>";
		 }else{
			 echo "&nbsp;";
		}
	  ?>
	</td>
	<td><?=$OInfo[oid]?></td>
	<td><a href='../users/user_edit.php?UserName=<?=$OInfo[UserName]?>&key=<?=GetHashKey('users'.$OInfo[UserName])?>'><?=$OInfo[UserName]?></a></td>
	<td><?=$OInfo[amount]?></td>
	<td><?=$status[$OInfo[payresult]]?></td>
	<td><?=$OInfo[paymode]?></td>
	<td><?=$OInfo['datetime']?></td>
  </tr>
  <? }?>
</table>
<div id="page">
<?
	echo $pageStr;
?>
</div>
<center>
<input type="hidden" name="backUrl" value="<?=getUrl()?>">
<?		  
if($pageList) echo "$pageList[0] <br> $pageList[1]";
?>
</center>

  </form>
</div>
<? 
@$DB->close();
include "../share/bottom.php";
?>
</body>
</html>
