add contraint , that everybody expect admin is limited to 3 days, Add card package

This commit is contained in:
2016-02-13 17:23:43 +01:00
parent 556bdc3066
commit 70f43468af
37 changed files with 1418 additions and 19 deletions

View File

@@ -14,12 +14,19 @@ use common\models\Account;
use yii\helpers\ArrayHelper;
use common\models\MoneyMovement;
use common\components\RoleDefinition;
use common\components\Helper;
/**
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
*/
class TransferTicketSearch extends Transfer
{
/**
* if mode is recepion, date restriction will be used
* if mode is admin, date restriction will be used based on user role
* */
public $mode = 'reception';
public $start;
public $end;
@@ -126,6 +133,8 @@ class TransferTicketSearch extends Transfer
}
protected function calcTotal(){
$this->total = 0;
$this->total += $this->ticketMoney;
@@ -166,9 +175,24 @@ class TransferTicketSearch extends Transfer
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
$this->restrictStartDate($query);
}
function restrictStartDate($query){
$needRestriction = false;
if ( $this->mode == 'admin'){
$needRestriction = !RoleDefinition::isAdmin( ) ;
}else{
$needRestriction = true;
}
if ( $needRestriction ){
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart);
}
}
protected function readTicketStas(){
$query = (new \yii\db\Query());