From b6b51931208d9a90f19712db21782882394b09c2 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Mon, 2 Nov 2015 18:41:36 +0100 Subject: [PATCH] Fix customer backend forms , fix site\index backend create\update customer forms must display the same as the frontend forms site\index action should be friendly and related to this app --- backend/controllers/CardController.php | 7 +++- backend/controllers/CustomerController.php | 2 + backend/models/CustomerCreate.php | 18 +++++++++ backend/models/CustomerUpdate.php | 19 +++++++++ backend/views/card/_form.php | 1 + backend/views/customer/_form_create.php | 14 ------- backend/views/customer/_form_update.php | 14 ------- backend/views/site/index.php | 44 ++------------------- frontend/models/CustomerCreate.php | 2 - frontend/views/site/index.php | 45 ++-------------------- 10 files changed, 53 insertions(+), 113 deletions(-) diff --git a/backend/controllers/CardController.php b/backend/controllers/CardController.php index 5b537a8..c06d8a4 100644 --- a/backend/controllers/CardController.php +++ b/backend/controllers/CardController.php @@ -75,7 +75,12 @@ class CardController extends \backend\controllers\BackendController $model->status = Card::STATUS_ACTIVE; $model->type = Card::TYPE_RFID; if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id_card]); + \Yii::$app->session->setFlash( 'success','Card created!' ); + if ( isset($_POST['create_next'])){ + return $this->redirect(['create' ]); + }else{ + return $this->redirect(['view', 'id' => $model->id_card]); + } } else { return $this->render('create', [ 'model' => $model, diff --git a/backend/controllers/CustomerController.php b/backend/controllers/CustomerController.php index c18a626..c1482af 100644 --- a/backend/controllers/CustomerController.php +++ b/backend/controllers/CustomerController.php @@ -79,6 +79,8 @@ class CustomerController extends \backend\controllers\BackendController throw new NotFoundHttpException('The requested page does not exist.'); } + $model->birthdate= isset($model->birthdate ) ? Yii::$app->formatter->asDate($model->birthdate) :''; + if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id_customer]); diff --git a/backend/models/CustomerCreate.php b/backend/models/CustomerCreate.php index 1e6cb40..2f00b07 100644 --- a/backend/models/CustomerCreate.php +++ b/backend/models/CustomerCreate.php @@ -68,6 +68,15 @@ class CustomerCreate extends \common\models\Customer [['email'], 'string', 'max' => 255], [['email'], 'email' ], [['email'], 'unique' ], + [['email'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty($model->phone) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + [['password_plain','password_repeat'], 'string', 'max' => 32], @@ -80,6 +89,15 @@ class CustomerCreate extends \common\models\Customer [['phone', 'tax_number', 'country'], 'string', 'max' => 20], + [['phone'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty( $model->email ) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + [['zip'], 'string', 'max' => 8], [['city'], 'string', 'max' => 30] diff --git a/backend/models/CustomerUpdate.php b/backend/models/CustomerUpdate.php index c715954..cef9ec9 100644 --- a/backend/models/CustomerUpdate.php +++ b/backend/models/CustomerUpdate.php @@ -68,6 +68,16 @@ class CustomerUpdate extends \common\models\Customer [['email'], 'email' ], [['email'], 'unique' ], + [['email'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty($model->phone) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + + [['password_plain','password_repeat'], 'string', 'max' => 32], [['sex'], 'integer'], @@ -79,6 +89,15 @@ class CustomerUpdate extends \common\models\Customer [['phone', 'tax_number', 'country'], 'string', 'max' => 20], + [['phone'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty( $model->email ) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/backend','E-mail or phone number required!') + ], + [['zip'], 'string', 'max' => 8], [['city'], 'string', 'max' => 30] diff --git a/backend/views/card/_form.php b/backend/views/card/_form.php index df5a94b..dfa41b0 100644 --- a/backend/views/card/_form.php +++ b/backend/views/card/_form.php @@ -22,6 +22,7 @@ use common\models\Card;
isNewRecord ? Yii::t('common/card', 'Create') : Yii::t('common/card', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> + 'btn btn-primary','name'=>'create_next']) ?>
diff --git a/backend/views/customer/_form_create.php b/backend/views/customer/_form_create.php index 036d453..1b9949e 100644 --- a/backend/views/customer/_form_create.php +++ b/backend/views/customer/_form_create.php @@ -22,9 +22,6 @@ use kartik\widgets\DatePicker;
field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
-
- field($model, 'partnerCardNumber')->textInput() ?> -
@@ -39,17 +36,6 @@ use kartik\widgets\DatePicker; - - -
-
- field($model, 'password_plain')->passwordInput(['maxlength' => true]) ?> -
-
- field($model, 'password_repeat')->passwordInput(['maxlength' => true]) ?> -
-
-
field($model, 'sex')->dropDownList(Customer::sexes()) ?> diff --git a/backend/views/customer/_form_update.php b/backend/views/customer/_form_update.php index 020ed85..ed36c4e 100644 --- a/backend/views/customer/_form_update.php +++ b/backend/views/customer/_form_update.php @@ -26,9 +26,6 @@ use kartik\widgets\DatePicker; customerCardNumber ?>
-
- field($model, 'partnerCardNumber')->textInput() ?> -
@@ -43,17 +40,6 @@ use kartik\widgets\DatePicker; - - -
-
- field($model, 'password_plain')->passwordInput(['maxlength' => true]) ?> -
-
- field($model, 'password_repeat')->passwordInput(['maxlength' => true]) ?> -
-
-
field($model, 'sex')->dropDownList(Customer::sexes()) ?> diff --git a/backend/views/site/index.php b/backend/views/site/index.php index f780610..8b029ca 100644 --- a/backend/views/site/index.php +++ b/backend/views/site/index.php @@ -7,47 +7,11 @@ $this->title = 'My Yii Application';
-

Congratulations!

+

Web Admin

-

You have successfully created your Yii-powered application.

- -

Get started with Yii

-
- -
- -
-
-

Heading

- -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.

- -

Yii Documentation »

-
-
-

Heading

- -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.

- -

Yii Forum »

-
-
-

Heading

- -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.

- -

Yii Extensions »

-
-
+

Üdvözöljük adminisztrációs felületünkön

+ +
diff --git a/frontend/models/CustomerCreate.php b/frontend/models/CustomerCreate.php index 7b88074..6ce1f7b 100644 --- a/frontend/models/CustomerCreate.php +++ b/frontend/models/CustomerCreate.php @@ -71,7 +71,6 @@ class CustomerCreate extends \common\models\Customer [['email'], 'required', 'when' => function($model) { return !isset( $model->email ) || empty($model->phone) ; } , -// 'enableClientValidation' => false, 'whenClient' => "function (attribute, value) { return false; }", @@ -92,7 +91,6 @@ class CustomerCreate extends \common\models\Customer [['phone'], 'required', 'when' => function($model) { return !isset( $model->email ) || empty( $model->email ) ; } , -// 'enableClientValidation' => false, 'whenClient' => "function (attribute, value) { return false; }", diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php index f780610..6aa245e 100644 --- a/frontend/views/site/index.php +++ b/frontend/views/site/index.php @@ -7,47 +7,8 @@ $this->title = 'My Yii Application';
-

Congratulations!

- -

You have successfully created your Yii-powered application.

- -

Get started with Yii

+

Web Recepció

+

Üdvözöljük Web Recepció oldalunkon!

-
- -
-
-

Heading

- -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.

- -

Yii Documentation »

-
-
-

Heading

- -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.

- -

Yii Forum »

-
-
-

Heading

- -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.

- -

Yii Extensions »

-
-
- -
-
+