diff --git a/backend/views/ticket-type/_form.php b/backend/views/ticket-type/_form.php index 9e2e6b8..f86d610 100644 --- a/backend/views/ticket-type/_form.php +++ b/backend/views/ticket-type/_form.php @@ -9,7 +9,7 @@ use yii\helpers\ArrayHelper; /* @var $model common\models\TicketType */ /* @var $form yii\widgets\ActiveForm */ ?> - - + field($model, 'name')->textInput(['maxlength' => true]) ?> field($model, 'type')->dropDownList(TicketType::ticketTypes() ) ?> + + field($model, 'comment')->textInput()->label("Megjegyzés") ?> + field($model, 'max_usage_count')->textInput() ?> field($model, 'max_reservation_count')->textInput() ?> @@ -53,7 +56,7 @@ use yii\helpers\ArrayHelper; field($model, 'id_account')->dropDownList($account_options) ?> - + field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/ticket_type', "Active") ]) ?> field($model, 'flag_student')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Student") ]) ?> diff --git a/backend/views/ticket-type/view.php b/backend/views/ticket-type/view.php index 1180fd9..25febb8 100644 --- a/backend/views/ticket-type/view.php +++ b/backend/views/ticket-type/view.php @@ -31,6 +31,10 @@ $this->params['breadcrumbs'][] = $this->title; 'value' => $model->typeHuman ], 'max_usage_count', + [ + 'attribute' => 'comment', + 'label' => "Megjegyzés" + ], 'max_reservation_count', [ 'attribute' => 'time_unit_count', diff --git a/common/models/TicketType.php b/common/models/TicketType.php index ebff2d0..29c2747 100644 --- a/common/models/TicketType.php +++ b/common/models/TicketType.php @@ -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 ], ]); } - - - + + + } diff --git a/frontend/views/ticket/_form.php b/frontend/views/ticket/_form.php index 6a70e0d..dae6d55 100644 --- a/frontend/views/ticket/_form.php +++ b/frontend/views/ticket/_form.php @@ -16,90 +16,99 @@ use common\components\Helper; /* @var $form yii\widgets\ActiveForm */ ?> - ''] + HtmlHelper::mkDiscountOptions($discounts, [ 'emptyOption' => true] ); $ticketTypeOptions = HtmlHelper::mkTicketTypeOptions($ticketTypes); + $ticketTypeOptions = []; + foreach ($ticketTypes as $ticketType){ + $comment = ""; + if ( isset($ticketType->comment)){ + $comment = " (" . $ticketType->comment .")"; + } + $ticketTypeOptions[$ticketType->id_ticket_type] = $ticketType->name . $comment; + + } // echo "default kassza: " . Account::readDefault(); // echo " kassza: " . $model->id_account; - + ?>
- + 'ticket_form', ]); ?> - + - + field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?> - + field($model, 'id_account')->dropDownList($accountOptions) ?> - + field($model,'payment_method')->dropDownList(Transfer::paymentMethods()) ?> - + field($model, 'id_discount')->dropDownList($discountOptions) ?> - + field($model, 'start')->widget(DatePicker::classname(), [ 'pluginOptions' => [ 'autoclose'=>true, 'format' => 'yyyy.mm.dd' ] ]) ?> - - + + field($model, 'end')->widget(DatePicker::classname(), [ 'pluginOptions' => [ 'autoclose'=>true, 'format' => 'yyyy.mm.dd' ] ]) ?> - + field($model, 'max_usage_count')->input('number') ?> - - field($model, 'price_brutto')->input('number' ); }else{ echo $form->field($model, 'price_brutto')->input('number' ,['readonly' => true] ); - + } - + ?> - + field($model, 'comment')->textarea(['maxlength' => true]) ?> - +
'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
- - 'btn btn-success btn-block', 'id' => 'btn_add_to_user_cart'] ); } ?>
- isCardWithCustomer() ){ echo Html::a(Yii::t("frontend/ticket","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] ); - } + } ?>
- +
\ No newline at end of file