<?php
defined('IN_HS') or exit('Access Denied');

$sql = '';
if(isset($userid) && $userid)
{
	$userid = intval($userid);
	$sql .= " AND userid=$userid ";
}
if(isset($biller) && $biller) $sql .= " AND biller like '%$biller%' ";
if(isset($tgname) && $tgname) $sql .= " AND tgname like '%$tgname%' ";


if($sql) $sql = " WHERE 1 $sql";

$page = $page ? intval($page) : 1;
$pagesize = $HS['pagesize'];
$offset = ($page-1)*$pagesize;
$r = $db->get_one("SELECT count(*) as num FROM ".TABLE_BILL." $sql");
$pages = phppages($r['num'], $page, $pagesize);

$bills = array(); 
$result = $db->query("SELECT * FROM ".TABLE_BILL." $sql LIMIT $offset,$pagesize");
while($r = $db->fetch_array($result))
{
	$r['addtime'] = date('Y-m-d', $r['addtime']);
	$bills[] = $r;
}

if(!isset($userid)) $userid = '';
if(!isset($biller)) $biller = '';
if(!isset($tgname)) $tgname = '';


include admintpl('list');
?>