add limit, that users can see only 3 days old data
This commit is contained in:
@@ -48,51 +48,51 @@ class TransferListSearch extends Transfer
|
||||
/**
|
||||
* all money gained with ticket sell
|
||||
* */
|
||||
public $ticketMoney;
|
||||
public $ticketMoney = 0;
|
||||
/**
|
||||
* all money gained with product sell
|
||||
* */
|
||||
public $productMoney;
|
||||
public $productMoney = 0;
|
||||
/**
|
||||
* all money gained with product sell
|
||||
* */
|
||||
public $productMoneyNetto;
|
||||
public $productMoneyNetto = 0;
|
||||
/**
|
||||
* all money gained with product sell grouped by category
|
||||
* */
|
||||
public $productMoneies;
|
||||
public $productMoneies = [];
|
||||
/**
|
||||
* all money lost by money movement
|
||||
* */
|
||||
public $moneyMovementMoneis;
|
||||
public $moneyMovementMoney;
|
||||
public $moneyMovementMoneis = 0;
|
||||
public $moneyMovementMoney = 0;
|
||||
/**
|
||||
* total gained money brutto
|
||||
* */
|
||||
public $total;
|
||||
public $total = 0;
|
||||
/**
|
||||
* total gained money netto
|
||||
* */
|
||||
public $totalNetto;
|
||||
public $totalNetto = 0;
|
||||
|
||||
/**
|
||||
* ticket sale statisitc
|
||||
* */
|
||||
public $ticketStats;
|
||||
public $ticketStats =[];
|
||||
|
||||
/**
|
||||
* money movements by type
|
||||
* */
|
||||
public $moneyMovementsByType;
|
||||
public $moneyMovementsByType = [];
|
||||
|
||||
public $tickets;
|
||||
/**
|
||||
* all product transfer
|
||||
* */
|
||||
public $products;
|
||||
public $moneyMovements;
|
||||
public $products = [];
|
||||
public $moneyMovements = [];
|
||||
|
||||
public $productsByCategory;
|
||||
public $productsByCategory = [];
|
||||
|
||||
public $currentUser;
|
||||
public $currentAccount;
|
||||
@@ -112,14 +112,43 @@ class TransferListSearch extends Transfer
|
||||
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
|
||||
[['start','end' ], 'required'],
|
||||
[ [ 'id_account','id_user' ] , 'integer'],
|
||||
['types', 'each', 'rule' => ['integer']],
|
||||
['output', 'safe' ],
|
||||
['outputView', 'safe' ],
|
||||
// ['start', 'validateStart']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function validateStart($attribute,$param){
|
||||
|
||||
|
||||
|
||||
if ( $this->isStartDateToEarly() ){
|
||||
$this->addError($attribute,"Érvénytelen kezdő dátum");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function calcStartDaysSinceToday(){
|
||||
$start = $this->timestampStart;
|
||||
$now = time();
|
||||
|
||||
$d = \DateTime::createFromFormat("Y-m-d H:i", $start)->getTimeStamp();
|
||||
$days_between = ceil(abs($now - $d) / 86400);
|
||||
|
||||
return $days_between;
|
||||
}
|
||||
|
||||
protected function isStartDateToEarly(){
|
||||
$days_visiblity = Helper::getReceptionVisibilityDays();
|
||||
$days_between = $this->calcStartDaysSinceToday();
|
||||
return $days_between > $days_visiblity;
|
||||
}
|
||||
|
||||
|
||||
public function isModeAdmin(){
|
||||
return $this->mode == 'admin';
|
||||
}
|
||||
@@ -253,9 +282,33 @@ class TransferListSearch extends Transfer
|
||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||
|
||||
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
|
||||
|
||||
if ( !$this->isModeAdmin()){
|
||||
$query->andWhere(['transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( !RoleDefinition::isAdmin() ){
|
||||
/**
|
||||
* Csak az admin láthat minden adatot
|
||||
* ha a start dátum korábbi, mint ahogy azt a recepciósok láthatják,
|
||||
* hozzáadjuk a querykhez a dátum korlátozást
|
||||
* */
|
||||
if ( $this->isStartDateToEarly() ){
|
||||
|
||||
$days = Helper::getReceptionVisibilityDays();
|
||||
$time = date( "Y-m-d H:i:s", strtotime("today -$days day") );
|
||||
|
||||
$start_date_condition = ['or',[ '>=', 'transfer.created_at', $time ] ,[ '>=', 'transfer.paid_at', $time] ];
|
||||
|
||||
$query->andFilterWhere( $start_date_condition );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user