add role checking to controllers
This commit is contained in:
@@ -9,6 +9,7 @@ use yii\helpers\ArrayHelper;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use common\components\RoleDefinition;
|
||||
|
||||
/**
|
||||
* This is the model class for table "collection".
|
||||
@@ -115,6 +116,11 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty
|
||||
|
||||
$query = new Query();
|
||||
|
||||
if ( !RoleDefinition::isAdmin() ){
|
||||
$query->innerJoin("user_account_assignment",'collection.id_account = user_account_assignment.id_account' );
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||
}
|
||||
|
||||
$query->addSelect( [
|
||||
new Expression( ' collection.id_account as account'),
|
||||
new Expression( ' COALESCE(sum( collection.money ) ,0) as money /** collections total money */' )
|
||||
@@ -126,8 +132,8 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty
|
||||
'id_account' => $idAccount,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['id_user' => $idUser]);
|
||||
$query->andFilterWhere(['in' ,'type', $types]);
|
||||
$query->andFilterWhere(['collection.id_user' => $idUser]);
|
||||
$query->andFilterWhere(['in' ,'collection.type', $types]);
|
||||
self::inInterval($query, 'collection.end' , $start, $end);
|
||||
|
||||
$query->groupBy('collection.id_account');
|
||||
|
||||
Reference in New Issue
Block a user