From fa8dafba7684f653f0382f17a5e6e7b06d6dcbea Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 11 May 2017 18:44:18 +0300 Subject: [PATCH] -User's password change done --- frontend/controllers/AccountController.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- frontend/models/Order.php | 12 ++++++------ frontend/views/account/_menu.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/account/account.php | 185 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/account/index.php | 26 +------------------------- frontend/views/account/order.php | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/account/wishlist.php | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/web/css/style.css | 4 ++++ 8 files changed, 707 insertions(+), 33 deletions(-) create mode 100644 frontend/views/account/_menu.php create mode 100644 frontend/views/account/account.php create mode 100644 frontend/views/account/order.php create mode 100644 frontend/views/account/wishlist.php diff --git a/frontend/controllers/AccountController.php b/frontend/controllers/AccountController.php index 1a25d20..d8aacea 100644 --- a/frontend/controllers/AccountController.php +++ b/frontend/controllers/AccountController.php @@ -4,6 +4,7 @@ use artbox\order\models\Customer; use artbox\order\models\Order; + use artbox\order\models\PasswordForm; use yii\web\Controller; use yii\web\ForbiddenHttpException; use yii\web\NotFoundHttpException; @@ -47,19 +48,74 @@ * @var Order $order */ $order = Order::find() - ->with('orderProducts') + ->with('orderProducts.variant.product.lang') ->where( [ 'id' => $id, ] ) ->one(); - + if (empty($order)) { throw new NotFoundHttpException(\Yii::t('app', 'Order not found')); } elseif ($order->user_id !== \Yii::$app->user->identity->getId()) { throw new ForbiddenHttpException(); } + + return $this->render( + 'order', + [ + 'order' => $order, + ] + ); + } + + public function actionAccount() + { + return $this->render( + 'account', + [ + 'passwordModel' => new PasswordForm(), + ] + ); + } + + public function actionChangePassword() + { + /** + * @var Customer $modeluser + */ + $model = new PasswordForm(); + $modeluser = \Yii::$app->user->identity; + if ($model->load(\Yii::$app->request->post())) { + if ($model->validate()) { + $modeluser->setPassword($model->newpass); + if ($modeluser->save()) { + return $this->redirect([ 'index' ]); + } else { + return $this->render( + 'account', + [ + 'passwordModel' => $model, + ] + ); + } + } else { + return $this->render( + 'account', + [ + 'passwordModel' => $model, + ] + ); + } + } else { + return $this->render( + 'account', + [ + 'passwordModel' => $model, + ] + ); + } } } \ No newline at end of file diff --git a/frontend/models/Order.php b/frontend/models/Order.php index e0333cc..1af6082 100644 --- a/frontend/models/Order.php +++ b/frontend/models/Order.php @@ -50,13 +50,13 @@ public function behaviors() { - return [ - [ - 'class' => BlameableBehavior::className(), - 'createdByAttribute' => 'user_id', - 'updatedByAttribute' => false, - ], + $behaviors = parent::behaviors(); + $behaviors[] = [ + 'class' => BlameableBehavior::className(), + 'createdByAttribute' => 'user_id', + 'updatedByAttribute' => false, ]; + return $behaviors; } /** diff --git a/frontend/views/account/_menu.php b/frontend/views/account/_menu.php new file mode 100644 index 0000000..58c3206 --- /dev/null +++ b/frontend/views/account/_menu.php @@ -0,0 +1,49 @@ + + + diff --git a/frontend/views/account/account.php b/frontend/views/account/account.php new file mode 100644 index 0000000..b60d7d5 --- /dev/null +++ b/frontend/views/account/account.php @@ -0,0 +1,185 @@ +params[ 'breadcrumbs' ][] = \Yii::t('app', 'Мой аккаунт'); + +?> + +
+ +
+ +
+ + + +
+ +

Измените ваши персональные данные или пароль здесь.

+ +
+ +
+

Изменить пароль

+
+ + [ 'account/change-password' ], + ] + ) ?> +
+
+ field($passwordModel, 'oldpass') + ->passwordInput() ?> +
+
+
+
+ field($passwordModel, 'newpass') + ->passwordInput() ?> +
+
+ field($passwordModel, 'repeatnewpass') + ->passwordInput() ?> +
+
+ + +
+ Сохранить новый пароль', + [ 'class' => 'btn btn-template-main' ] + ) ?> +
+ + +
+ + + +
+
+

Персональные данные

+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+ + +
+ +
+ +
+ +
+ +
+ + + + + + +
+ + render('_menu') ?> + + + +
+ + + +
+ + +
+ +
+ + \ No newline at end of file diff --git a/frontend/views/account/index.php b/frontend/views/account/index.php index 5e1d94e..f577ffb 100644 --- a/frontend/views/account/index.php +++ b/frontend/views/account/index.php @@ -91,31 +91,7 @@ _________________________________________________________ -->
- + render('_menu'); ?> diff --git a/frontend/views/account/order.php b/frontend/views/account/order.php new file mode 100644 index 0000000..17f5a2e --- /dev/null +++ b/frontend/views/account/order.php @@ -0,0 +1,137 @@ +params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('app', 'Заказы'), + 'url' => [ + 'account/index', + ], + ]; + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Заказ') . ' № ' . $order->id; + +?> + +
+
+ +
+ + + +
+ +

Order #id ?> was placed on created_at + ) ?>label)) { + ?> and is currently + label->lang->title ?>.

+

If you have any questions, please feel free to + contact us, our customer service center is working for you 24/7.

+ +
+
+ + + + + + + + + + + orderProducts as $product) { + $total += $product->price * $product->count; + ?> + + + + + + + + + + + + + + + +
ProductQuantityUnit priceTotal
+ + variant ? $product->variant->product->image->getPath( + ) : '@frontend/web/img/no-image.png' + ) + ->cropResize(50, 50) + ->renderImage( + [ + 'alt' => $product->variant->product->lang->title, + ] + ) ?> + + variant->product->lang->title ?> + count ?>price ?>count * $product->price ?>
Total
+ +
+ + +
+
+

+

name ?> +
phone ?> +
city ?> +
address ?> +
payment->lang->title ?> +
delivery->lang->title ?>

+
+
+ + +
+ + +
+ + + + + + +
+ + render('_menu') ?> + + + +
+ + + +
+ + + +
+ +
+ + + \ No newline at end of file diff --git a/frontend/views/account/wishlist.php b/frontend/views/account/wishlist.php new file mode 100644 index 0000000..2a2ea0d --- /dev/null +++ b/frontend/views/account/wishlist.php @@ -0,0 +1,267 @@ + + +
+
+ +
+ + + +
+ +
+ + + +
+
+
+ + + +
+ + + + +
+
SALE
+
+
+ + +
+
NEW
+
+
+ +
+ +
+ +
+
+
+ + + +
+ + + +
+ +
+ +
+
+
+ + + +
+ + + +
+ +
+ +
+
+
+ + + +
+ + + + +
+
SALE
+
+
+ + +
+
NEW
+
+
+ +
+ +
+ +
+
+
+ + + +
+ + + + +
+
NEW
+
+
+ +
+ +
+ +
+
+
+ + + +
+ + + + +
+
NEW
+
+
+ +
+ +
+ +
+
+
+ + + +
+ + + +
+ +
+ +
+ + +
+ + + + + + +
+ + render('_menu') ?> + + + +
+ + + +
+ + +
+ +
+ + \ No newline at end of file diff --git a/frontend/web/css/style.css b/frontend/web/css/style.css index f4c1cbd..1e17439 100755 --- a/frontend/web/css/style.css +++ b/frontend/web/css/style.css @@ -1,3 +1,7 @@ +#content { + min-height: calc(100vh - 107px - 260px); +} + .link-underline { border-bottom: 1px solid #a3d4ff; } -- libgit2 0.21.4