<?php
if ( !defined( "SAXUE_CORE_INCLUDE" ) ) {
		include "../../core.php";
} 
saxue_checkpower( 'scorelog' );
include_once( SAXUE_ROOT_PATH . "/model/member_score.php" );
$score_handler = &saxuememberscorehandler :: getinstance( "saxuememberscorehandler" );
if ( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'delete' && !empty( $_REQUEST['ids'] ) && is_array( $_REQUEST['ids'] ) && count( $_REQUEST['ids'] ) > 0 ) {
		$score_handler -> db -> query( "DELETE FROM " . saxue_dbprefix( "member_score" ) . " WHERE id IN(" . implode( ',', $_REQUEST['ids'] ) . ")" );
		if ( empty( $_REQUEST['jumpurl'] ) ) {
				saxue_jumppage( 'score.php', LANG_DO_SUCCESS );
		} else {
				saxue_jumppage( $_REQUEST['jumpurl'], LANG_DO_SUCCESS );
		}
}
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;
$criteria = new criteriacompo();
if ( isset( $_REQUEST['type'] ) && $_REQUEST['type'] != '' ) {
		$criteria -> add( new criteria( 'type', $_REQUEST['type'], '=' ) );
} 
if ( !empty( $_REQUEST['fromtime'] ) ) {
		$criteria -> add( new criteria( 'time', strtotime( $_REQUEST['fromtime'] . ' 00:00:00' ), '>=' ) );
} 
if ( !empty( $_REQUEST['totime'] ) ) {
		$criteria -> add( new criteria( 'time', strtotime( $_REQUEST['totime'] . ' 23:59:59' ), '<=' ) );
} 
if ( 1 == $_REQUEST['op'] ) {
		$criteria -> add( new criteria( 'amount', 0, '>' ) );
} elseif ( 2 == $_REQUEST['op'] ) {
		$criteria -> add( new criteria( 'amount', 0, '<' ) );
} 
if ( !empty( $_REQUEST['keytype'] ) && !empty( $_REQUEST['keyword'] ) ) {
		$criteria -> add( new criteria( $_REQUEST['keytype'], $_REQUEST['keyword'] ) );
} 
$criteria -> setsort( "id" );
$criteria -> setorder( "DESC" );
$criteria -> setlimit( $_REQUEST['pagesize'] );
$criteria -> setstart( ( $_REQUEST['page'] - 1 ) * $_REQUEST['pagesize'] );
$score_handler -> queryobjects( $criteria );
$rows = array();
$k = 0;
saxue_getconfigs( "scoretype", "member" );
while ( $v = $score_handler -> getobject() ) {
		$rows[$k] = $v -> getvars( "n" );
		$rows[$k]['typename'] = $saxueScoretype[$rows[$k]['type']];
		++$k;
} 
include_once( SAXUE_ADMIN_PATH . "/header.php" );
$saxueTpl -> assign_by_ref( "rows", $rows );
$saxueTpl -> assign_by_ref( "scoretype", $saxueScoretype );
include_once( SAXUE_ROOT_PATH . "/lib/util/page.php" );
$jumppage = new saxuepage( $score_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/score.html";
include_once( SAXUE_ADMIN_PATH . "/footer.php" );
