<?php
if ( !defined( "SAXUE_CORE_INCLUDE" ) ) {
		include "../../core.php";
} 
saxue_checkpower( 'memberbill' );
if ( empty( $_REQUEST['pagesize'] ) || !is_numeric( $_REQUEST['pagesize'] ) || !in_array( $_REQUEST['pagesize'], array( '10', '30', '50', '100' ) ) ) $_REQUEST['pagesize'] = 30;
if ( empty( $_REQUEST['page'] ) || !is_numeric( $_REQUEST['page'] ) ) $GLOBALS['_REQUEST']['page'] = 1;
include SAXUE_ROOT_PATH . "/model/member_bill.php";
$bill_handler = &saxuememberbillhandler :: getinstance( "saxuememberbillhandler" );
if ( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'delete' && !empty( $_REQUEST['ids'] ) && is_array( $_REQUEST['ids'] ) && count( $_REQUEST['ids'] ) > 0 ) {
		$bill_handler -> db -> query( "DELETE FROM " . saxue_dbprefix( "member_bill" ) . " WHERE uid IN(" . implode( ',', $_REQUEST['ids'] ) . ")" );
		if ( empty( $_REQUEST['jumpurl'] ) ) {
				saxue_jumppage( 'bill.php', LANG_DO_SUCCESS );
		} else {
				saxue_jumppage( $_REQUEST['jumpurl'], LANG_DO_SUCCESS );
		}
}
$criteria = new criteriacompo();
if ( !empty( $_REQUEST['uid'] ) ) {
		$criteria -> add( new criteria( 'uid', $_REQUEST['uid'] ) );
} 
if ( isset( $_REQUEST['status'] ) && $_REQUEST['status'] != '' ) {
		$criteria -> add( new criteria( 'status', $_REQUEST['status'] ) );
} 
$criteria -> setsort( "id" );
$criteria -> setorder( "DESC" );
$criteria -> setlimit( $_REQUEST['pagesize'] );
$criteria -> setstart( ( $_REQUEST['page'] - 1 ) * $_REQUEST['pagesize'] );
$bill_handler -> queryobjects( $criteria );
$rows = array();
$k = 0;
while ( $v = $bill_handler -> getobject() ) {
		$rows[$k] = $v -> getvars( "n" );
		++$k;
} 
include SAXUE_ADMIN_PATH . "/header.php";
$saxueTpl -> assign_by_ref( "rows", $rows );
include SAXUE_ROOT_PATH . "/lib/util/page.php";
$jumppage = new saxuepage( $bill_handler -> getcount( $criteria ), $_REQUEST['pagesize'], $_REQUEST['page'] );
$jumppage -> setlink( "", true, true );
$saxueTpl -> assign( "url_jumppage", $jumppage -> whole_bar() );
$saxueTpl -> setcaching( 0 );
$saxueTset['saxue_contents_template'] = SAXUE_WEB_PATH . "/member/templates/bill.html";
include SAXUE_ADMIN_PATH . "/footer.php";
