implement ticket_type comment in frontend/backend

This commit is contained in:
Schneider Roland 2023-03-09 19:05:28 +01:00
parent 8d98f510d1
commit 176d42ea76
4 changed files with 73 additions and 57 deletions

View File

@ -9,7 +9,7 @@ use yii\helpers\ArrayHelper;
/* @var $model common\models\TicketType */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
<?php
function mkTitle($name){
$s = "";
$tag = "h4";
@ -25,12 +25,15 @@ use yii\helpers\ArrayHelper;
<div class="ticket-type-form">
<?php $form = ActiveForm::begin(); ?>
<?= mkTitle("Általános")?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'type')->dropDownList(TicketType::ticketTypes() ) ?>
<?= mkTitle("Megjegyzés")?>
<?= $form->field($model, 'comment')->textInput()->label("Megjegyzés") ?>
<?= mkTitle("Alkalmak")?>
<?= $form->field($model, 'max_usage_count')->textInput() ?>
<?= $form->field($model, 'max_reservation_count')->textInput() ?>
@ -53,7 +56,7 @@ use yii\helpers\ArrayHelper;
<?= $form->field($model, 'id_account')->dropDownList($account_options) ?>
<?= mkTitle("További beállítások")?>
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/ticket_type', "Active") ]) ?>
<?= $form->field($model, 'flag_student')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Student") ]) ?>

View File

@ -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',

View File

@ -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
],
]);
}
}

View File

@ -16,90 +16,99 @@ use common\components\Helper;
/* @var $form yii\widgets\ActiveForm */
?>
<?php
<?php
$accountOptions = [];
$discountOptions= [];
$ticketTypeOptions= [];
$accountOptions = HtmlHelper::mkAccountOptions($accounts);
$discountOptions = ['' => ''] + 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;
?>
<div class="row" >
<div class="col-md-12" >
<div class="ticket-form">
<?php $form = ActiveForm::begin([
'id' => 'ticket_form',
]); ?>
<?= Html::activeHiddenInput($model, 'cart')?>
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
<?php echo $form->field($model,'payment_method')->dropDownList(Transfer::paymentMethods()) ?>
<?php echo $form->field($model, 'id_discount')->dropDownList($discountOptions) ?>
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
<?= $form->field($model, 'end')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
<?= $form->field($model, 'max_usage_count')->input('number') ?>
<?php
<?php
if ( Helper::isTicketCreatePriceEditable()){
echo $form->field($model, 'price_brutto')->input('number' );
}else{
echo $form->field($model, 'price_brutto')->input('number' ,['readonly' => true] );
}
?>
<?= $form->field($model, 'comment')->textarea(['maxlength' => true]) ?>
<div class="row">
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/ticket","Fizetve"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
</div>
<div class='col-md-4'>
<?php
if ( Helper::isUserCartOn()){
<?php
if ( Helper::isUserCartOn()){
echo Html::a(Yii::t("frontend/ticket","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_user_cart'] );
}
?>
</div>
<div class='col-md-4'>
<?php
<?php
if ( $receptionForm->isCardWithCustomer() ){
echo Html::a(Yii::t("frontend/ticket","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] );
}
}
?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>