<?php 
define('IN_PHPMPS', true);
require_once dirname(__FILE__) . '/include/common.php';
extract($_REQUEST);
$page = empty($page)? 1 : intval($page);
$sql = '';
if($userid) $sql .= " AND userid='$userid' ";
if($begindate) {
	$begintime = strtotime($begindate.' 00:00:00');
	$sql .= " AND addtime>=$begintime ";
}
if($enddate) {
	$endtime = strtotime($enddate.' 23:59:59');
	$sql .= " AND addtime<=$endtime";
}
if($sql) $sql = " WHERE 1 $sql";
$count = $db->getOne("SELECT count(*) as number FROM {$table}pay_credit $sql");
$pager = get_pager('credit_money.php', array(), $count, $page,'20');
$creditname = array('0'=>'积分兑现','1'=>'系统发放','2'=>'系统扣减');//积分兑现项名
$exchanges = array();
$result = $db->query("SELECT * FROM {$table}pay_credit $sql ORDER BY cid DESC LIMIT $pager[start],$pager[size]");
while($r = $db->fetchrow($result)) {
	$r['tid'] = $creditname[$r['tid']];
	$r['addtime'] = date('Y-m-d h:i:s', $r['addtime']);
	$exchanges[] = $r;
}
include tpl('list_credit_money');
?>