add reception collection basics

This commit is contained in:
2015-11-03 17:27:14 +01:00
parent 33bf52df60
commit 931b83040b
12 changed files with 385 additions and 26 deletions

View File

@@ -132,13 +132,14 @@ class Account extends \yii\db\ActiveRecord
$query = Account::find();
$query->innerJoinWith('userAccountAssignments');
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
$query->andWhere(['status' => Account::STATUS_ACTIVE]);
if ( $forceIncludeAccount == null){
$query->andWhere(['status' => Account::STATUS_ACTIVE])->all();
}else{
$query->andWhere( ['or', ['status' => Account::STATUS_ACTIVE], ['id_account' => $forceIncludeAccount ] ])->all();
}
$query->orderBy( ['name' => SORT_ASC]);
$accounts = $query->all();
return $accounts;
}
@@ -156,4 +157,21 @@ class Account extends \yii\db\ActiveRecord
}
/**
* read assigned account
* */
public static function readOne($idAccount){
$accounts = null;
$query = Account::find();
$query->innerJoinWith('userAccountAssignments');
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
$query->andWhere(['status' => Account::STATUS_ACTIVE]);
$query->andWhere(['account.id_account' => $idAccount]);
$accounts = $query->one();
return $accounts;
}
}