<?php
include "../core.php";
saxue_checklogin();
saxue_getconfigs( "configs", "member" );
saxue_getconfigs( "scoretype", "member" );
if ( empty( $_REQUEST['page'] ) || !is_numeric( $_REQUEST['page'] ) ) {
		$GLOBALS['_REQUEST']['page'] = 1;
} 
include SAXUE_ROOT_PATH . "/model/member_score.php";
$score_handler = &saxuememberscorehandler :: getinstance( "saxuememberscorehandler" );
$criteria = new criteriacompo( new criteria( "uid", $_SESSION['saxueUserId'] ) );
$criteria -> setsort( "id" );
$criteria -> setorder( "DESC" );
$criteria -> setlimit( $saxueConfigs['member']['logpnum'] );
$criteria -> setstart( ( $_REQUEST['page'] - 1 ) * $saxueConfigs['member']['logpnum'] );
$score_handler -> queryobjects( $criteria );
$rows = array();
$k = $income = $expense = 0;
while ( $v = $score_handler -> getobject() ) {
		$rows[$k] = $v -> getvars( "n" );
		$rows[$k]['typename'] = $saxueScoretype[$rows[$k]['type']];
		$rows[$k]['amount'] > 0 ? $income += $rows[$k]['amount'] : $expense += $rows[$k]['amount'];
		++$k;
} 
include SAXUE_WEB_PATH . "/member/header.php";
$saxueTpl -> assign_by_ref( "rows", $rows );
$saxueTpl -> assign( "income", $income );
$saxueTpl -> assign( "expense", $expense );
include SAXUE_ROOT_PATH . "/lib/util/page.php";
$jumppage = new saxuepage( $score_handler -> getcount( $criteria ), $saxueConfigs['member']['logpnum'], $_REQUEST['page'] );
$jumppage -> setlink( "", true, true );
$saxueTpl -> assign( "url_jumppage", $jumppage -> whole_bar() );
$saxueTpl -> assign( "totalpage", $jumppage -> total_page );
$saxueTpl -> setcaching( 0 );
$saxueTset['saxue_contents_template'] = SAXUE_THEME_PATH . "/member/score.html";
include SAXUE_WEB_PATH . "/member/footer.php";
