133 lines
3.7 KiB
PHP
133 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use Yii;
|
|
|
|
/**
|
|
* This is the model class for table "ticket_type".
|
|
*
|
|
* @property integer $id_ticket_type
|
|
* @property string $name
|
|
* @property integer $type
|
|
* @property integer $max_usage_count
|
|
* @property integer $time_unit_type
|
|
* @property integer $time_unit_count
|
|
* @property integer $price_brutto
|
|
* @property integer $id_account
|
|
* @property integer $flag_student
|
|
* @property integer $status
|
|
* @property string $created_at
|
|
* @property string $updated_at
|
|
*/
|
|
class TicketType extends \common\models\BaseFitnessActiveRecord
|
|
{
|
|
|
|
const STATUS_DELETED = 0;
|
|
const STATUS_ACTIVE = 10;
|
|
|
|
CONST TIME_UNIT_DAY = 10;
|
|
CONST TIME_UNIT_MONTH = 20;
|
|
CONST TIME_UNIT_MONTH_REFERENCE = 30;
|
|
|
|
const TYPE_NORMAL = 10;
|
|
const TYPE_DEFAULT = self::TYPE_NORMAL;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'ticket_type';
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['name', 'id_account'], 'required'],
|
|
[['type', 'max_usage_count', 'time_unit_type', 'time_unit_count', 'price_brutto', 'id_account', 'flag_student', 'status'], 'integer'],
|
|
[['created_at', 'updated_at'], 'safe'],
|
|
[['name'], 'string', 'max' => 64]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id_ticket_type' => Yii::t('common/ticket_type', 'Id Ticket Type'),
|
|
'name' => Yii::t('common/ticket_type', 'Name'),
|
|
'type' => Yii::t('common/ticket_type', 'Type'),
|
|
'max_usage_count' => Yii::t('common/ticket_type', 'Max Usage Count'),
|
|
'time_unit_type' => Yii::t('common/ticket_type', 'Time Unit Type'),
|
|
'time_unit_count' => Yii::t('common/ticket_type', 'Time Unit Count'),
|
|
'price_brutto' => Yii::t('common/ticket_type', 'Price Brutto'),
|
|
'id_account' => Yii::t('common/ticket_type', 'Id Account'),
|
|
'flag_student' => Yii::t('common/ticket_type', 'Flag Student'),
|
|
'status' => Yii::t('common/ticket_type', 'Status'),
|
|
'created_at' => Yii::t('common/ticket_type', 'Created At'),
|
|
'updated_at' => Yii::t('common/ticket_type', 'Updated At'),
|
|
];
|
|
}
|
|
|
|
|
|
static function statuses() {
|
|
return [
|
|
self::STATUS_ACTIVE => Yii::t('common/ticket_type', 'Active'),
|
|
self::STATUS_DELETED => Yii::t('common/ticket_type', 'Inactive'),
|
|
];
|
|
}
|
|
|
|
public function getStatusHuman(){
|
|
$result = null;
|
|
$s = self::statuses($this->status);
|
|
if ( array_key_exists($this->status, $s)){
|
|
$result = $s[$this->status];
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
static function timeUnitTypes() {
|
|
return [
|
|
self::TIME_UNIT_DAY => Yii::t('common/ticket_type', 'Nap'),
|
|
self::TIME_UNIT_MONTH => Yii::t('common/ticket_type', 'Hónap'),
|
|
self::TIME_UNIT_MONTH_REFERENCE => Yii::t('common/ticket_type', 'Tárgyhónap'),
|
|
];
|
|
}
|
|
|
|
public function getTimeUnitHuman(){
|
|
$result = null;
|
|
$s = self::timeUnitTypes($this->time_unit_type);
|
|
if ( array_key_exists($this->time_unit_type, $s)){
|
|
$result = $s[$this->time_unit_type];
|
|
}
|
|
return $result;
|
|
}
|
|
static function ticketTypes() {
|
|
return [
|
|
self::TYPE_NORMAL => Yii::t('common/ticket_type', 'Normal'),
|
|
];
|
|
}
|
|
|
|
public function getTypeHuman(){
|
|
$result = null;
|
|
$s = self::ticketTypes( );
|
|
if ( array_key_exists($this->type, $s)){
|
|
$result = $s[$this->type];
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
public function getAccount(){
|
|
return $this->hasOne(Account::className(), [ 'id_account' => 'id_account' ]);
|
|
}
|
|
|
|
}
|