implement customer comment in frontend
This commit is contained in:
parent
31edf22e0e
commit
8d98f510d1
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -19,7 +19,7 @@ use yii\base\Widget;
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'photo_data')->hiddenInput()->label(false) ?>
|
||||
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-3'>
|
||||
<?php //echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
|
||||
@ -34,6 +34,12 @@ use yii\base\Widget;
|
||||
</div>
|
||||
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
@ -44,19 +50,19 @@ use yii\base\Widget;
|
||||
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-3'>
|
||||
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-6'>
|
||||
<?= $form->field($model, 'mother_name')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-3'>
|
||||
<?= $form->field($model, 'birth_place')->textInput(['maxlength' => true]) ?>
|
||||
@ -69,9 +75,9 @@ use yii\base\Widget;
|
||||
]
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-3'>
|
||||
@ -124,16 +130,16 @@ use yii\base\Widget;
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?php echo $form->field($model, 'city')->widget(CityNameTypeahead::className(),[
|
||||
'pluginEvents' =>[
|
||||
'pluginEvents' =>[
|
||||
"typeahead:select" => "function(a,b) {
|
||||
$('#customercreate-zip').typeahead( 'val', b.zip );
|
||||
}",]
|
||||
|
||||
|
||||
])?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
|
||||
@ -144,7 +150,7 @@ use yii\base\Widget;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user