implement ticket_type comment in frontend/backend
This commit is contained in:
@@ -43,23 +43,23 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
CONST TIME_UNIT_MONTH_REFERENCE = 30;
|
||||
const TYPE_NORMAL = 10;
|
||||
const TYPE_DEFAULT = self::TYPE_NORMAL;
|
||||
|
||||
|
||||
const FLAG_STUDENT_OFF = 0;
|
||||
const FLAG_STUDENT_ON = 1;
|
||||
|
||||
|
||||
const INSTALLMENT_OFF = 0;
|
||||
const INSTALLMENT_ON = 1;
|
||||
|
||||
const FLAG_DOOR_ALLOWED_OFF = 0;
|
||||
const FLAG_DOOR_ALLOWED_ON = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'ticket_type';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @formatter:off
|
||||
* @inheritdoc
|
||||
@@ -113,13 +113,13 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
////////////////
|
||||
[['id_account',], 'integer'],
|
||||
[['id_account',], 'validateIdAccount'],
|
||||
|
||||
|
||||
/////////////////////
|
||||
//INSTALLMENT ENABLED
|
||||
/////////////////////
|
||||
[['installment_enabled',], 'integer'],
|
||||
[['installment_enabled',], 'in', 'range' => [ self::INSTALLMENT_ON, self::INSTALLMENT_OFF ]],
|
||||
|
||||
|
||||
[['installment_money',], 'integer'],
|
||||
[['installment_count',], 'integer'],
|
||||
|
||||
@@ -128,7 +128,7 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
////////////////
|
||||
[['door_allowed',], 'integer'],
|
||||
[['door_allowed',], 'in', 'range' => [ self::FLAG_DOOR_ALLOWED_OFF, self::FLAG_DOOR_ALLOWED_ON ]],
|
||||
|
||||
[['comment'], 'string' ],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -157,14 +157,14 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
'max_reservation_count' => Yii::t('common/ticket_type', 'Max Reservation Count'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @formatter:on
|
||||
*/
|
||||
static function statuses() {
|
||||
return [
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t ( 'common/ticket_type', 'Active' ),
|
||||
self::STATUS_DELETED => Yii::t ( 'common/ticket_type', 'Inactive' )
|
||||
self::STATUS_DELETED => Yii::t ( 'common/ticket_type', 'Inactive' )
|
||||
];
|
||||
}
|
||||
public function getStatusHuman() {
|
||||
@@ -176,10 +176,10 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
return $result;
|
||||
}
|
||||
static function timeUnitTypes() {
|
||||
return [
|
||||
return [
|
||||
self::TIME_UNIT_DAY => Yii::t ( 'common/ticket_type', 'Day' ),
|
||||
self::TIME_UNIT_MONTH => Yii::t ( 'common/ticket_type', 'Month' ),
|
||||
self::TIME_UNIT_MONTH_REFERENCE => Yii::t ( 'common/ticket_type', 'Reference month' )
|
||||
self::TIME_UNIT_MONTH_REFERENCE => Yii::t ( 'common/ticket_type', 'Reference month' )
|
||||
];
|
||||
}
|
||||
public function getTimeUnitHuman() {
|
||||
@@ -191,8 +191,8 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
return $result;
|
||||
}
|
||||
static function ticketTypes() {
|
||||
return [
|
||||
self::TYPE_NORMAL => Yii::t ( 'common/ticket_type', 'Normal' )
|
||||
return [
|
||||
self::TYPE_NORMAL => Yii::t ( 'common/ticket_type', 'Normal' )
|
||||
];
|
||||
}
|
||||
public function getTypeHuman() {
|
||||
@@ -204,14 +204,14 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
return $result;
|
||||
}
|
||||
public function getAccount() {
|
||||
return $this->hasOne ( Account::className (), [
|
||||
'id_account' => 'id_account'
|
||||
return $this->hasOne ( Account::className (), [
|
||||
'id_account' => 'id_account'
|
||||
] );
|
||||
}
|
||||
public function getAccountName() {
|
||||
return $this->account->name;
|
||||
}
|
||||
|
||||
|
||||
public function isStudent(){
|
||||
return $this->flag_student == ( self::FLAG_STUDENT_ON);
|
||||
}
|
||||
@@ -223,13 +223,13 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
public function isInstallment(){
|
||||
return $this->installment_enabled == ( self::INSTALLMENT_ON);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function validateIdAccount($attribute){
|
||||
$account = null;
|
||||
if ( !$this->hasErrors("id_account")){
|
||||
$account = Account::findOne($this->$attribute);
|
||||
|
||||
|
||||
if ( !isset($account)){
|
||||
$this->addError($attribute,Yii::t('common/ticket_type','Invalid account!'));
|
||||
}else{
|
||||
@@ -256,7 +256,7 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
*/
|
||||
public static function read($forceIncludeObjectWithId = null, $account = null){
|
||||
$ticketTypes = null;
|
||||
|
||||
|
||||
if ( $forceIncludeObjectWithId == null){
|
||||
$ticketTypes = TicketType::find()->andWhere(['status' => self::STATUS_ACTIVE ])
|
||||
->andWhere([ '<>', 'installment_enabled' , '1']) ->andFilterWhere(['ticket_type.id_account' => $account])->all();
|
||||
@@ -264,17 +264,17 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
$ticketTypes = TicketType::find()->andWhere( ['or', ['status' => self::STATUS_ACTIVE], ['id_ticket_type' => $forceIncludeObjectWithId ] ])
|
||||
->andWhere([ '<>', 'installment_enabled' , '1'])->andFilterWhere(['ticket_type.id_account' => $account])->all();
|
||||
}
|
||||
|
||||
|
||||
return $ticketTypes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function modelsToArray($models,$default = []){
|
||||
|
||||
|
||||
if ( $models == null ){
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
||||
return ArrayHelper::toArray($models, [
|
||||
'common\models\TicketType' => [
|
||||
'name',
|
||||
@@ -287,7 +287,7 @@ class TicketType extends BaseFitnessActiveRecord
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user