Commit 977f4921154cd962e7234215f050d81e73a3f7c1
1 parent
e67c95f9
Callback
Showing
2 changed files
with
113 additions
and
9 deletions
Show diff stats
frontend/controllers/SiteController.php
| @@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
| 13 | use common\models\SignupForm; | 13 | use common\models\SignupForm; |
| 14 | use Yii; | 14 | use Yii; |
| 15 | use yii\base\InvalidParamException; | 15 | use yii\base\InvalidParamException; |
| 16 | + use yii\bootstrap\Html; | ||
| 16 | use yii\web\BadRequestHttpException; | 17 | use yii\web\BadRequestHttpException; |
| 17 | use yii\web\Controller; | 18 | use yii\web\Controller; |
| 18 | use yii\filters\VerbFilter; | 19 | use yii\filters\VerbFilter; |
| @@ -180,12 +181,46 @@ | @@ -180,12 +181,46 @@ | ||
| 180 | } | 181 | } |
| 181 | } | 182 | } |
| 182 | 183 | ||
| 184 | + public function actionCallback() | ||
| 185 | + { | ||
| 186 | + Yii::$app->response->format = Response::FORMAT_JSON; | ||
| 187 | + $model = new Feedback( | ||
| 188 | + [ | ||
| 189 | + 'scenario' => Feedback::SCENARIO_CALLBACK, | ||
| 190 | + ] | ||
| 191 | + ); | ||
| 192 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 193 | + \Yii::$app->session->setFlash( | ||
| 194 | + 'success', | ||
| 195 | + Html::tag( | ||
| 196 | + 'div', | ||
| 197 | + Html::tag( | ||
| 198 | + 'h3', | ||
| 199 | + \Yii::t('app', 'Обратный звонок') | ||
| 200 | + ) . Html::tag( | ||
| 201 | + 'p', | ||
| 202 | + \Yii::t( | ||
| 203 | + 'app', | ||
| 204 | + 'Ваша заявка успешно отправлена. Мы свяжемся с Вами в ближайшее время.' | ||
| 205 | + ) | ||
| 206 | + ) | ||
| 207 | + ) | ||
| 208 | + ); | ||
| 209 | + return $this->redirect($model->returnUrl ? : [ 'index' ]); | ||
| 210 | + } else { | ||
| 211 | + return [ | ||
| 212 | + 'success' => false, | ||
| 213 | + 'error' => $model->errors, | ||
| 214 | + ]; | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | + | ||
| 183 | public function actionLogin() | 218 | public function actionLogin() |
| 184 | { | 219 | { |
| 185 | if (!\Yii::$app->user->isGuest) { | 220 | if (!\Yii::$app->user->isGuest) { |
| 186 | return $this->redirect([ 'index' ]); | 221 | return $this->redirect([ 'index' ]); |
| 187 | } | 222 | } |
| 188 | - | 223 | + |
| 189 | $loginForm = new LoginForm(); | 224 | $loginForm = new LoginForm(); |
| 190 | $signupForm = new SignupForm(); | 225 | $signupForm = new SignupForm(); |
| 191 | if ($loginForm->load(\Yii::$app->request->post()) && $loginForm->login()) { | 226 | if ($loginForm->load(\Yii::$app->request->post()) && $loginForm->login()) { |
| @@ -216,7 +251,7 @@ | @@ -216,7 +251,7 @@ | ||
| 216 | public function actionLogout() | 251 | public function actionLogout() |
| 217 | { | 252 | { |
| 218 | \Yii::$app->user->logout(); | 253 | \Yii::$app->user->logout(); |
| 219 | - | 254 | + |
| 220 | return $this->redirect([ 'index' ]); | 255 | return $this->redirect([ 'index' ]); |
| 221 | } | 256 | } |
| 222 | 257 | ||
| @@ -231,7 +266,7 @@ | @@ -231,7 +266,7 @@ | ||
| 231 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { | 266 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
| 232 | if ($model->sendEmail()) { | 267 | if ($model->sendEmail()) { |
| 233 | Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); | 268 | Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); |
| 234 | - | 269 | + |
| 235 | return $this->redirect([ 'index' ]); | 270 | return $this->redirect([ 'index' ]); |
| 236 | } else { | 271 | } else { |
| 237 | Yii::$app->session->setFlash( | 272 | Yii::$app->session->setFlash( |
| @@ -240,7 +275,7 @@ | @@ -240,7 +275,7 @@ | ||
| 240 | ); | 275 | ); |
| 241 | } | 276 | } |
| 242 | } | 277 | } |
| 243 | - | 278 | + |
| 244 | return $this->render( | 279 | return $this->render( |
| 245 | 'requestPasswordResetToken', | 280 | 'requestPasswordResetToken', |
| 246 | [ | 281 | [ |
| @@ -264,13 +299,13 @@ | @@ -264,13 +299,13 @@ | ||
| 264 | } catch (InvalidParamException $e) { | 299 | } catch (InvalidParamException $e) { |
| 265 | throw new BadRequestHttpException($e->getMessage()); | 300 | throw new BadRequestHttpException($e->getMessage()); |
| 266 | } | 301 | } |
| 267 | - | 302 | + |
| 268 | if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { | 303 | if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { |
| 269 | Yii::$app->session->setFlash('success', 'New password saved.'); | 304 | Yii::$app->session->setFlash('success', 'New password saved.'); |
| 270 | - | 305 | + |
| 271 | return $this->redirect([ 'index' ]); | 306 | return $this->redirect([ 'index' ]); |
| 272 | } | 307 | } |
| 273 | - | 308 | + |
| 274 | return $this->render( | 309 | return $this->render( |
| 275 | 'resetPassword', | 310 | 'resetPassword', |
| 276 | [ | 311 | [ |
frontend/views/layouts/main.php
| @@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
| 19 | use yii\base\Model; | 19 | use yii\base\Model; |
| 20 | use yii\bootstrap\ActiveForm; | 20 | use yii\bootstrap\ActiveForm; |
| 21 | use yii\bootstrap\Html; | 21 | use yii\bootstrap\Html; |
| 22 | + use yii\helpers\Url; | ||
| 22 | use yii\web\View; | 23 | use yii\web\View; |
| 23 | use yii\widgets\Breadcrumbs; | 24 | use yii\widgets\Breadcrumbs; |
| 24 | 25 | ||
| @@ -138,8 +139,8 @@ _________________________________________________________ --> | @@ -138,8 +139,8 @@ _________________________________________________________ --> | ||
| 138 | </div> | 139 | </div> |
| 139 | <div class="inline-block"> | 140 | <div class="inline-block"> |
| 140 | <span class="top-phone"><i class="fa fa-phone"></i> <?php echo $settings->phone; ?></span> | 141 | <span class="top-phone"><i class="fa fa-phone"></i> <?php echo $settings->phone; ?></span> |
| 141 | - <a href="#" class="link-underline_dott"> | ||
| 142 | - Обратный звонок | 142 | + <a href="#" data-toggle="modal" data-target="#callback-modal" class="link-underline_dott"> |
| 143 | + <?php echo "Обратный звонок"; ?> | ||
| 143 | </a> | 144 | </a> |
| 144 | </div> | 145 | </div> |
| 145 | <div class="inline-block login"> | 146 | <div class="inline-block login"> |
| @@ -440,6 +441,74 @@ _________________________________________________________ --> | @@ -440,6 +441,74 @@ _________________________________________________________ --> | ||
| 440 | ?> | 441 | ?> |
| 441 | 442 | ||
| 442 | <!-- *** Breadcrumbs *** --> | 443 | <!-- *** Breadcrumbs *** --> |
| 444 | + <!-- *** FEEDBACK MODAL BEGIN *** --> | ||
| 445 | + <?php | ||
| 446 | + ?> | ||
| 447 | + | ||
| 448 | + <?php | ||
| 449 | + $callback = new Feedback( | ||
| 450 | + [ | ||
| 451 | + 'scenario' => Feedback::SCENARIO_CALLBACK, | ||
| 452 | + 'returnUrl' => Url::current([], true), | ||
| 453 | + ] | ||
| 454 | + ); | ||
| 455 | + ?> | ||
| 456 | + <div class="modal fade" id="callback-modal" tabindex="-1" role="dialog" aria-labelledby="Login" aria-hidden="true"> | ||
| 457 | + <div class="modal-dialog modal-sm"> | ||
| 458 | + | ||
| 459 | + <div class="modal-content"> | ||
| 460 | + <div class="modal-header"> | ||
| 461 | + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | ||
| 462 | + <h4 class="modal-title callback" id="Login">Обратный звонок</h4> | ||
| 463 | + </div> | ||
| 464 | + <div class="modal-body"> | ||
| 465 | + <?php | ||
| 466 | + $form = ActiveForm::begin( | ||
| 467 | + [ | ||
| 468 | + 'action' => [ 'site/callback' ], | ||
| 469 | + ] | ||
| 470 | + ); | ||
| 471 | + echo $form->field($callback, 'returnUrl') | ||
| 472 | + ->label(false) | ||
| 473 | + ->hiddenInput(); | ||
| 474 | + echo $form->field($callback, 'name') | ||
| 475 | + ->label(false) | ||
| 476 | + ->textInput( | ||
| 477 | + [ | ||
| 478 | + 'placeholder' => $callback->getAttributeLabel('name'), | ||
| 479 | + ] | ||
| 480 | + ); | ||
| 481 | + echo $form->field($callback, 'phone') | ||
| 482 | + ->label(false) | ||
| 483 | + ->textInput( | ||
| 484 | + [ | ||
| 485 | + 'placeholder' => $callback->getAttributeLabel('phone'), | ||
| 486 | + ] | ||
| 487 | + ); | ||
| 488 | + echo Html::tag( | ||
| 489 | + 'p', | ||
| 490 | + Html::submitButton( | ||
| 491 | + Html::icon( | ||
| 492 | + 'sign-in', | ||
| 493 | + [ | ||
| 494 | + 'prefix' => 'fa fa-', | ||
| 495 | + ] | ||
| 496 | + ) . \Yii::t('app', 'Отправить'), | ||
| 497 | + [ | ||
| 498 | + 'class' => 'btn btn-template-main', | ||
| 499 | + ] | ||
| 500 | + ), | ||
| 501 | + [ | ||
| 502 | + 'class' => 'text-center', | ||
| 503 | + ] | ||
| 504 | + ); | ||
| 505 | + $form::end(); | ||
| 506 | + ?> | ||
| 507 | + </div> | ||
| 508 | + </div> | ||
| 509 | + </div> | ||
| 510 | + </div> | ||
| 511 | + <!-- *** FEEDBACK MODAL END *** --> | ||
| 443 | <?php | 512 | <?php |
| 444 | if (!$isHome) { | 513 | if (!$isHome) { |
| 445 | ?> | 514 | ?> |