add limit, that users can see only 3 days old data
This commit is contained in:
@@ -118,6 +118,23 @@ class DailyListing
|
||||
public $accountState; //the cassa object for we load the data
|
||||
|
||||
|
||||
|
||||
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 readTotalEasy(){
|
||||
$this->readTicketMoney();
|
||||
$this->readProductsMoney();
|
||||
@@ -173,9 +190,11 @@ class DailyListing
|
||||
public function isModeAdmin(){
|
||||
return $this->mode == 'admin';
|
||||
}
|
||||
|
||||
public function isModeAccountState(){
|
||||
return $this->mode == 'accountstate';
|
||||
}
|
||||
|
||||
public function isModeReception(){
|
||||
return $this->mode == 'reception';
|
||||
}
|
||||
@@ -255,6 +274,19 @@ class DailyListing
|
||||
if ( $this->isModeReception() || $this->isModeAccountState() ){
|
||||
$query->andWhere(['transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH]);
|
||||
}
|
||||
|
||||
if ( !RoleDefinition::isAdmin() ){
|
||||
|
||||
if ( $this->isStartDateToEarly() ){
|
||||
|
||||
$time = date( "Y-m-d H:i:s", strtotime("today -3 day") );
|
||||
|
||||
$start_date_condition = ['or',[ '>=', 'transfer.created_at', $time ] ,[ '>=', 'transfer.paid_at', $time] ];
|
||||
|
||||
$query->andFilterWhere( $start_date_condition );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,11 @@ class Helper {
|
||||
public static function isAccountStateClosePreloadMoney() {
|
||||
return \Yii::$app->params ['account_state_close_preload_money'] == true;
|
||||
}
|
||||
|
||||
public static function getReceptionVisibilityDays() {
|
||||
return \Yii::$app->params ['reception_visibility_days'] ;
|
||||
}
|
||||
|
||||
public static function getRealUserIp() {
|
||||
$client = @$_SERVER ['HTTP_CLIENT_IP'];
|
||||
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];
|
||||
|
||||
Reference in New Issue
Block a user