<?php
/**
 * Created by JetBrains PhpStorm.
 * User: yzxh24
 * Date: 11-10-23
 * Time: 上午11:13
 * To change this template use File | Settings | File Templates.
 */
class RewardsAction extends BaseAction
{
    public function run()
    {
        $ruid = Yii::app()->request->getQuery('ruid');
        $criteria = $this->_buildCriteria(new CDbCriteria(array('condition'=>'ruid='.$ruid)));
        $dataProvider = new CActiveDataProvider('RewardFlux',array('pagination' => array('pageSize' => 100), 'sort'=>array('defaultOrder'=>'date DESC')));
        $dataProvider->setCriteria($criteria);

        //$dataSum = FluxData::dataSum($criteria);

        $this->getController()->render('rewards', array(
			'dataProvider' => $dataProvider,
            //'dataSum' => $dataSum,
            'ruid' => $ruid,
		));
    }

    /**
     * 根据url后面传递进来的参数获取一个查询条件
     * @param CDbCriteria $criteria
     * @return CDbCriteria
     */
    private function _buildCriteria(CDbCriteria $criteria)
    {
        return Helper::buildCriteria($criteria, $_GET);
    }
}
