fix displaying available accounts on frontend/sellTicket
This commit is contained in:
@@ -6,6 +6,8 @@ use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||
|
||||
/**
|
||||
* This is the model class for table "account".
|
||||
*
|
||||
@@ -86,7 +88,7 @@ class Account extends \yii\db\ActiveRecord
|
||||
|
||||
public function getStatusHuman(){
|
||||
$result = null;
|
||||
$s = self::statuses($this->status);
|
||||
$s = self::statuses();
|
||||
if ( array_key_exists($this->status, $s)){
|
||||
$result = $s[$this->status];
|
||||
}
|
||||
@@ -102,7 +104,7 @@ class Account extends \yii\db\ActiveRecord
|
||||
|
||||
public function getTypeHuman(){
|
||||
$result = null;
|
||||
$s = self::types($this->type);
|
||||
$s = self::types();
|
||||
if ( array_key_exists($this->type, $s)){
|
||||
$result = $s[$this->type];
|
||||
}
|
||||
@@ -112,14 +114,17 @@ class Account extends \yii\db\ActiveRecord
|
||||
public function isInactive(){
|
||||
return $this->status == self::STATUS_DELETED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
|
||||
* */
|
||||
* @param null $forceIncludeAccount the next account should be included too, even if it is not
|
||||
* allowed for user
|
||||
* @return array|null|\yii\db\ActiveRecord[]
|
||||
*/
|
||||
public static function readAccounts($forceIncludeAccount = null){
|
||||
$accounts = null;
|
||||
|
||||
if ( $forceIncludeAccount == null){
|
||||
if ( $forceIncludeAccount == null) {
|
||||
$accounts = Account::find()->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||
}else{
|
||||
$accounts = Account::find()->andWhere( ['or', ['status' => Account::STATUS_ACTIVE], ['id_account' => $forceIncludeAccount ] ])->all();
|
||||
@@ -134,6 +139,7 @@ class Account extends \yii\db\ActiveRecord
|
||||
|
||||
$query->innerJoinWith('userAccountAssignments');
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||
|
||||
if ( $forceIncludeAccount == null){
|
||||
$query->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||
}else{
|
||||
@@ -166,7 +172,7 @@ class Account extends \yii\db\ActiveRecord
|
||||
/**
|
||||
* read default transfer object
|
||||
* return the default account or null, if not found
|
||||
* @return common\models\Account
|
||||
* @return \common\models\Account
|
||||
* */
|
||||
public static function readDefaultObject( ){
|
||||
$account = null;
|
||||
@@ -176,11 +182,13 @@ class Account extends \yii\db\ActiveRecord
|
||||
}
|
||||
return $account;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* read assigned account
|
||||
* */
|
||||
* read assigned account.
|
||||
* @param $idAccount integer The id of the account to read
|
||||
* @return array|null|\yii\db\ActiveRecord
|
||||
*/
|
||||
public static function readOne($idAccount){
|
||||
$accounts = null;
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use common\components\Helper;
|
||||
|
||||
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||
|
||||
/**
|
||||
* This is the model class for table "ticket".
|
||||
*
|
||||
@@ -30,6 +32,8 @@ use common\components\Helper;
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int id_contract
|
||||
*
|
||||
* @property \common\models\Card card
|
||||
*/
|
||||
class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user