From 8d98f510d1c17c9110ff07ad9398f22f4be8006b Mon Sep 17 00:00:00 2001 From: Schneider Roland Date: Thu, 9 Mar 2023 17:44:43 +0100 Subject: [PATCH] implement customer comment in frontend --- frontend/models/CustomerUpdate.php | 56 +++++++++++---------- frontend/views/common/_reception_ticket.php | 18 +++++++ frontend/views/customer/_form_update.php | 26 ++++++---- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/frontend/models/CustomerUpdate.php b/frontend/models/CustomerUpdate.php index a638f80..6b9d583 100644 --- a/frontend/models/CustomerUpdate.php +++ b/frontend/models/CustomerUpdate.php @@ -36,19 +36,19 @@ use common\models\Ticket; */ class CustomerUpdate extends \common\models\Customer { - + public $cardNumber; public $partnerCardNumber; - + public $password_plain; public $password_repeat; - + public $replacementCardNumber; public $replacementCard; public $originalCard; - - - + + + /** * @inheritdoc */ @@ -66,19 +66,19 @@ class CustomerUpdate extends \common\models\Customer // [['cardNumber'], 'required' ], // [['cardNumber'], 'string', 'max' => 10], // [['cardNumber'], 'validateCustomerCard' ], - + [['partnerCardNumber'], 'string', 'max' => 10], // [['partnerCardNumber'], 'validatePartnerCard' ], [['replacementCardNumber'], 'filter', 'filter' => function($value){return Helper::fixAsciiChars($value);}], [['replacementCardNumber'], 'validateReplacementCard' ], - + [['name'], 'required' ], [['name'], 'string', 'max' => 128], [['email'], 'string', 'max' => 255], [['email'], 'email' ], [['email'], 'unique' ], - + [['email'], 'required', 'when' => function($model) { return !isset( $model->email ) || empty($model->phone) ; } , @@ -87,22 +87,22 @@ class CustomerUpdate extends \common\models\Customer }", 'message' => Yii::t('customer/frontend','E-mail or phone number required!') ], - - + + // [['password_plain','password_repeat'], 'string', 'max' => 32], - + [['sex'], 'integer'], - + [[ 'birthdate', ], 'date' ], [[ 'date_stundent_card_expire', ], 'date' ], - + [[ 'description', 'address'], 'string', 'max' => 255], - + [['phone', 'tax_number', 'country'], 'string', 'max' => 20], - + [['bank_account'], 'string', 'max' => 24], [['bank_name'], 'string', 'max' => 100], - + [['phone'], 'required', 'when' => function($model) { return !isset( $model->email ) || empty( $model->email ) ; } , @@ -111,18 +111,20 @@ class CustomerUpdate extends \common\models\Customer }", 'message' => Yii::t('customer/frontend','E-mail or phone number required!') ], - + [['zip'], 'string', 'max' => 8], - + [['city'], 'string', 'max' => 30], [['photo_data'] ,'safe'], [['birth_place'] ,'safe'], [['mother_name'] ,'safe'], - [['warn_mail_ticket_expire_enabled' ],'integer'] + [['warn_mail_ticket_expire_enabled' ],'integer'], + [['comment'], 'string', 'max' => 255], + ]; } - + public function validateCustomerCard($a,$p){ // Customer::find()->andWhere( [$this->cardNumber ) } @@ -133,7 +135,7 @@ class CustomerUpdate extends \common\models\Customer $query = Card::find(); Card::addCardNumberCondition($query, $this->replacementCardNumber); $rcard = $query->one(); - + if ( !isset($rcard) ){ \Yii::info("csere kártya nem található"); $this->addError($a,"Csere kártya nem található"); @@ -141,7 +143,7 @@ class CustomerUpdate extends \common\models\Customer } \Yii::info("csere kártya megtalálva"); $customer = $rcard->customer; - + if ( isset($customer) ){ \Yii::info("A csere kártyát már valaki használja!"); $this->addError($a ,"A csere kártya már használatban van"); @@ -149,9 +151,9 @@ class CustomerUpdate extends \common\models\Customer } \Yii::info("A csere kártyát megfelel!"); $this->replacementCard = $rcard; - + } - + public function beforeSave($insert){ parent::beforeSave($insert); if ( isset($this->replacementCard ) ){ @@ -160,7 +162,7 @@ class CustomerUpdate extends \common\models\Customer } return true; } - + public function afterSave($insert, $changedAttributes){ if ( isset($this->replacementCard)){ Ticket::updateAll( ['id_card' => $this->replacementCard->id_card ], ['id_card' => $this->originalCard->id_card] ); @@ -170,5 +172,5 @@ class CustomerUpdate extends \common\models\Customer } } - + } diff --git a/frontend/views/common/_reception_ticket.php b/frontend/views/common/_reception_ticket.php index caab650..32a30d5 100644 --- a/frontend/views/common/_reception_ticket.php +++ b/frontend/views/common/_reception_ticket.php @@ -236,4 +236,22 @@ if (isset($model->customer)) { } + +if (isset($model->customer)) { + + if ( isset($model->customer->comment )) { + $commentClass = "alert alert-danger"; + echo Html::beginTag("div", ['class' => $commentClass, "role" => "alert"]); + echo Html::beginTag("div"); + echo "Megjegyzés:"; + echo Html::endTag("div"); + echo Html::beginTag("strong", []); + + echo $model->customer->comment; + echo Html::endTag("strong"); + echo Html::endTag("div"); + } + +} + ?> diff --git a/frontend/views/customer/_form_update.php b/frontend/views/customer/_form_update.php index 4374959..56212e2 100644 --- a/frontend/views/customer/_form_update.php +++ b/frontend/views/customer/_form_update.php @@ -19,7 +19,7 @@ use yii\base\Widget; field($model, 'photo_data')->hiddenInput()->label(false) ?> - +
field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?> @@ -34,6 +34,12 @@ use yii\base\Widget;
+
+
+ field($model, 'comment')->textInput(['maxlength' => true]) ?> +
+
+
field($model, 'name')->textInput(['maxlength' => true]) ?> @@ -44,19 +50,19 @@ use yii\base\Widget; field($model, 'email')->textInput(['maxlength' => true]) ?>
- +
field($model, 'sex')->dropDownList(Customer::sexes()) ?>
- +
field($model, 'mother_name')->textInput(['maxlength' => true]) ?>
- +
field($model, 'birth_place')->textInput(['maxlength' => true]) ?> @@ -69,9 +75,9 @@ use yii\base\Widget; ] ]) ?>
-
+
+ -
@@ -124,16 +130,16 @@ use yii\base\Widget;
field($model, 'city')->widget(CityNameTypeahead::className(),[ - 'pluginEvents' =>[ + 'pluginEvents' =>[ "typeahead:select" => "function(a,b) { $('#customercreate-zip').typeahead( 'val', b.zip ); }",] - + ])?>
- + field($model, 'address')->textInput(['maxlength' => true]) ?> @@ -144,7 +150,7 @@ use yii\base\Widget; - +
isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>