<?php 
require './include/common.inc.php';

//if(!$_userid) showmessage($LANG['please_login'], '/member/login.php?forward='.urlencode($PHP_URL));
if(!$_userid) header('location:/member/login.php?forward='.urlencode($PHP_URL));
$page = isset($page) ? intval($page) : 1;
$pagesize = $HS['pagesize'] ? $HS['pagesize'] : 30;
$offset = ($page-1)*$pagesize;

$sql = '';

if($begindate)
{
	$begintime = strtotime($begindate.' 00:00:00');
	$sql .= " AND addtime>=$begintime ";
}
if($enddate)
{
	$endtime = strtotime($enddate.' 23:59:59');
	$sql .= " AND addtime<=$endtime";
}

$r = $db->get_one("SELECT count(*) as number FROM ".TABLE_PAY_EXCHANGE." WHERE username='$_username' AND type='expen' $sql");
$pages = phppages($r['number'], $page, $pagesize);

$exchanges = array();
$result = $db->query("SELECT * FROM ".TABLE_PAY_EXCHANGE." WHERE username='$_username' AND type='expen' $sql ORDER BY exchangeid DESC LIMIT $offset,$pagesize");
while($r = $db->fetch_array($result))
{
	$r['extime'] = date('Y-m-d H:i:s',$r['addtime']);
	$exchanges[] = $r;
}
include template($mod, 'expen');
?>