Commit a78f6f00df697d56072a7f54af26aa4813a98122
1 parent
6f862115
feedback mail
Showing
9 changed files
with
226 additions
and
50 deletions
Show diff stats
common/mail/feedback.php
| 1 | 1 | <?php |
| 2 | - use artbox\core\models\Feedback; | |
| 2 | + use common\models\Feedback; | |
| 3 | 3 | use yii\web\View; |
| 4 | 4 | |
| 5 | 5 | /** |
| ... | ... | @@ -10,22 +10,26 @@ |
| 10 | 10 | ?> |
| 11 | 11 | |
| 12 | 12 | <table> |
| 13 | - <tbody> | |
| 14 | - <tr> | |
| 15 | - <td><b><?= \Yii::t('app', 'Name: ') ?></b></td> | |
| 16 | - <td><?= $model->name ?></td> | |
| 17 | - </tr> | |
| 18 | - <tr> | |
| 19 | - <td><b><?= \Yii::t('app', 'Phone: ') ?></b></td> | |
| 20 | - <td><?= $model->phone ?></td> | |
| 21 | - </tr> | |
| 22 | - <tr> | |
| 23 | - <td><b><?= \Yii::t('app', 'Email: ') ?></b></td> | |
| 24 | - <td><?= $model->email ?></td> | |
| 25 | - </tr> | |
| 26 | - <tr> | |
| 27 | - <td><b><?= \Yii::t('app', 'Message: ') ?></b></td> | |
| 28 | - <td><?= $model->message ?></td> | |
| 29 | - </tr> | |
| 30 | - </tbody> | |
| 13 | + <tbody> | |
| 14 | + <tr> | |
| 15 | + <td><b><?= \Yii::t('app', 'Name: ') ?></b></td> | |
| 16 | + <td><?= $model->name ?></td> | |
| 17 | + </tr> | |
| 18 | + <tr> | |
| 19 | + <td><b><?= \Yii::t('app', 'Topic: ') ?></b></td> | |
| 20 | + <td><?= $model->topic ?></td> | |
| 21 | + </tr> | |
| 22 | + <tr> | |
| 23 | + <td><b><?= \Yii::t('app', 'Phone: ') ?></b></td> | |
| 24 | + <td><?= $model->phone ?></td> | |
| 25 | + </tr> | |
| 26 | + <tr> | |
| 27 | + <td><b><?= \Yii::t('app', 'Email: ') ?></b></td> | |
| 28 | + <td><?= $model->email ?></td> | |
| 29 | + </tr> | |
| 30 | + <tr> | |
| 31 | + <td><b><?= \Yii::t('app', 'Message: ') ?></b></td> | |
| 32 | + <td><?= $model->message ?></td> | |
| 33 | + </tr> | |
| 34 | + </tbody> | |
| 31 | 35 | </table> | ... | ... |
| 1 | +<?php | |
| 2 | + namespace common\models; | |
| 3 | + /** | |
| 4 | + * User: timur | |
| 5 | + * Date: 31.01.18 | |
| 6 | + * Time: 10:56 | |
| 7 | + */ | |
| 8 | + | |
| 9 | + use artbox\core\models\Feedback as ArtboxFeedback; | |
| 10 | + use yii\helpers\VarDumper; | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * Class Feedback | |
| 14 | + * | |
| 15 | + * @property string $topic | |
| 16 | + * | |
| 17 | + * @package common\models | |
| 18 | + */ | |
| 19 | + class Feedback extends ArtboxFeedback | |
| 20 | + { | |
| 21 | + | |
| 22 | + const SCENARIO_CALCULATOR = 'calculator'; | |
| 23 | + | |
| 24 | + public function scenarios() | |
| 25 | + { | |
| 26 | + return array_merge( | |
| 27 | + parent::scenarios(), | |
| 28 | + [ | |
| 29 | + parent::SCENARIO_FEEDBACK => [ | |
| 30 | + 'name', | |
| 31 | + 'email', | |
| 32 | + 'message', | |
| 33 | + 'returnUrl', | |
| 34 | + 'topic', | |
| 35 | + ], | |
| 36 | + parent::SCENARIO_CALLBACK => [ | |
| 37 | + 'name', | |
| 38 | + 'phone', | |
| 39 | + 'message', | |
| 40 | + 'returnUrl', | |
| 41 | + 'topic', | |
| 42 | + ], | |
| 43 | + self::SCENARIO_CALCULATOR => [ | |
| 44 | + 'name', | |
| 45 | + 'phone', | |
| 46 | + 'returnUrl', | |
| 47 | + 'topic', | |
| 48 | + 'calc_json_info', | |
| 49 | + | |
| 50 | + ] | |
| 51 | + ] | |
| 52 | + ); | |
| 53 | + } | |
| 54 | + | |
| 55 | + public function rules() | |
| 56 | + { | |
| 57 | + | |
| 58 | + return array_merge( | |
| 59 | + parent::rules(), | |
| 60 | + [ | |
| 61 | + [ | |
| 62 | + [ | |
| 63 | + 'topic', | |
| 64 | + ], | |
| 65 | + 'required', | |
| 66 | + ], | |
| 67 | + [ | |
| 68 | + [ | |
| 69 | + 'topic', | |
| 70 | + ], | |
| 71 | + 'string', | |
| 72 | + 'max' => 100, | |
| 73 | + ], | |
| 74 | + [ | |
| 75 | + [ | |
| 76 | + 'calc_json_info' | |
| 77 | + ], | |
| 78 | + 'required', | |
| 79 | + 'on' => self::SCENARIO_CALCULATOR, | |
| 80 | + ] | |
| 81 | + ] | |
| 82 | + ); | |
| 83 | + } | |
| 84 | + | |
| 85 | + | |
| 86 | + } | |
| 0 | 87 | \ No newline at end of file | ... | ... |
console/migrations/m180131_085430_add_topic_column_to_feedback_table.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +use yii\db\Migration; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Handles adding topic to table `feedback`. | |
| 7 | + */ | |
| 8 | +class m180131_085430_add_topic_column_to_feedback_table extends Migration | |
| 9 | +{ | |
| 10 | + /** | |
| 11 | + * @inheritdoc | |
| 12 | + */ | |
| 13 | + public function up() | |
| 14 | + { | |
| 15 | + $this->addColumn('feedback', 'topic', $this->string(100)); | |
| 16 | + } | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * @inheritdoc | |
| 20 | + */ | |
| 21 | + public function down() | |
| 22 | + { | |
| 23 | + $this->dropColumn('feedback', 'topic'); | |
| 24 | + } | |
| 25 | +} | ... | ... |
console/migrations/m180131_090632_add_calc_json_info_column_to_feedback_table.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +use yii\db\Migration; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Handles adding calc_json_info to table `feedback`. | |
| 7 | + */ | |
| 8 | +class m180131_090632_add_calc_json_info_column_to_feedback_table extends Migration | |
| 9 | +{ | |
| 10 | + /** | |
| 11 | + * @inheritdoc | |
| 12 | + */ | |
| 13 | + public function up() | |
| 14 | + { | |
| 15 | + $this->addColumn('feedback', 'calc_json_info', $this->text()); | |
| 16 | + } | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * @inheritdoc | |
| 20 | + */ | |
| 21 | + public function down() | |
| 22 | + { | |
| 23 | + $this->dropColumn('feedback', 'calc_json_info'); | |
| 24 | + } | |
| 25 | +} | ... | ... |
frontend/controllers/SiteController.php
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace frontend\controllers; |
| 3 | 4 | |
| 4 | - use artbox\core\models\Feedback; | |
| 5 | + use common\models\Feedback; | |
| 5 | 6 | use common\models\Settings; |
| 6 | 7 | use common\models\Slider; |
| 7 | 8 | use Yii; |
| ... | ... | @@ -10,7 +11,6 @@ |
| 10 | 11 | use yii\web\BadRequestHttpException; |
| 11 | 12 | use yii\web\Controller; |
| 12 | 13 | use yii\web\Response; |
| 13 | - use common\models\Objectkb; | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Site controller |
| ... | ... | @@ -52,9 +52,10 @@ |
| 52 | 52 | public function actionIndex() |
| 53 | 53 | { |
| 54 | 54 | |
| 55 | - $slider = Slider::find()->with("slides.lang.image") | |
| 56 | - ->where(['on_home_page'=>true]) | |
| 57 | - ->one(); | |
| 55 | + $slider = Slider::find() | |
| 56 | + ->with("slides.lang.image") | |
| 57 | + ->where([ 'on_home_page' => true ]) | |
| 58 | + ->one(); | |
| 58 | 59 | |
| 59 | 60 | return $this->render( |
| 60 | 61 | 'index', |
| ... | ... | @@ -89,7 +90,7 @@ |
| 89 | 90 | { |
| 90 | 91 | return $this->render('about'); |
| 91 | 92 | } |
| 92 | - | |
| 93 | + | |
| 93 | 94 | public function actionIndividual() |
| 94 | 95 | { |
| 95 | 96 | return $this->render('individual'); |
| ... | ... | @@ -114,7 +115,7 @@ |
| 114 | 115 | { |
| 115 | 116 | return $this->render('blog'); |
| 116 | 117 | } // блог |
| 117 | - | |
| 118 | + | |
| 118 | 119 | /** |
| 119 | 120 | * Action to view robots.txt file dinamycli |
| 120 | 121 | * |
| ... | ... | @@ -158,22 +159,23 @@ |
| 158 | 159 | 'model' => $model, |
| 159 | 160 | ] |
| 160 | 161 | ) |
| 161 | - ->setFrom('artbox@domain.com') | |
| 162 | - ->setTo($settings->email) | |
| 162 | + ->setFrom('artbox@domain.com')// ->setTo($settings->email) | |
| 163 | + ->setTo( | |
| 164 | + [ | |
| 165 | + 'tamerlan8.05.92@gmail.com', | |
| 166 | + 'mpav@artweb.ua', | |
| 167 | + ] | |
| 168 | + ) | |
| 163 | 169 | ->setSubject(\Yii::t('app', 'Feedback')) |
| 164 | 170 | ->send(); |
| 165 | 171 | |
| 166 | 172 | return [ |
| 167 | 173 | 'success' => true, |
| 168 | 174 | 'message' => 'Success message', |
| 169 | - 'alert' => '<div class="alert alert-success"> | |
| 170 | - <h3>Success</h3> | |
| 171 | - <p> | |
| 172 | - Success text | |
| 173 | - </p> | |
| 174 | - </div>', | |
| 175 | + 'alert' => $this->renderPartial('success_alert'), | |
| 175 | 176 | ]; |
| 176 | 177 | } else { |
| 178 | + Yii::$app->response->setStatusCode(500); | |
| 177 | 179 | return [ |
| 178 | 180 | 'success' => false, |
| 179 | 181 | 'error' => $model->errors, | ... | ... |
frontend/views/layouts/main.php
| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | |
| 11 | 11 | use artbox\core\components\SeoComponent; |
| 12 | 12 | use artbox\core\helpers\ImageHelper; |
| 13 | - use artbox\core\models\Feedback; | |
| 14 | 13 | use artbox\core\models\PageCategory; |
| 15 | 14 | use artbox\core\models\User; |
| 16 | 15 | use common\models\Settings; |
| ... | ... | @@ -23,6 +22,7 @@ |
| 23 | 22 | use yii\helpers\Url; |
| 24 | 23 | use yii\web\View; |
| 25 | 24 | use yii\widgets\Breadcrumbs; |
| 25 | + use common\models\Feedback; | |
| 26 | 26 | |
| 27 | 27 | AppAsset::register($this); |
| 28 | 28 | $user = \Yii::$app->user->identity; |
| ... | ... | @@ -386,6 +386,10 @@ |
| 386 | 386 | ] |
| 387 | 387 | ); ?> |
| 388 | 388 | |
| 389 | + <?= $form->field($feedback, 'topic') | |
| 390 | + ->hiddenInput(['value' => Feedback::SCENARIO_FEEDBACK]) | |
| 391 | + ->label(false)?> | |
| 392 | + | |
| 389 | 393 | <?= $form->field($feedback, 'name') |
| 390 | 394 | ->textInput(); ?> |
| 391 | 395 | |
| ... | ... | @@ -601,7 +605,7 @@ |
| 601 | 605 | </div> |
| 602 | 606 | <div class="modal-body"> |
| 603 | 607 | |
| 604 | - <p>Thank for your reply, we will call you, maybe.</p> | |
| 608 | + <p>Thank for your reply, we will call you soon.</p> | |
| 605 | 609 | <p class="text-center"> |
| 606 | 610 | <button type="button" class="btn btn-template-primary" data-dismiss="modal">Close</button> |
| 607 | 611 | </p> | ... | ... |
frontend/views/site/index.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * @var $this yii\web\View | |
| 4 | + * @var $this yii\web\View | |
| 5 | 5 | * @var $slider \common\models\Slider |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -use common\models\Settings; | |
| 9 | -use frontend\assets\MapAsset; | |
| 10 | -use yii\web\View; | |
| 11 | - | |
| 12 | -MapAsset::register($this); | |
| 13 | -$settings = Settings::getInstance(); | |
| 14 | -$this->title = 'KB Energy'; | |
| 15 | - | |
| 16 | -$js = <<< JS | |
| 8 | + use common\models\Settings; | |
| 9 | + use frontend\assets\MapAsset; | |
| 10 | + use yii\web\View; | |
| 11 | + use yii\helpers\Url; | |
| 12 | + | |
| 13 | + MapAsset::register($this); | |
| 14 | + $settings = Settings::getInstance(); | |
| 15 | + $this->title = 'KB Energy'; | |
| 16 | + | |
| 17 | + $js = <<< JS | |
| 17 | 18 | window.lat = {$settings->lat}; |
| 18 | 19 | window.lon = {$settings->lon}; |
| 19 | 20 | JS; |
| 20 | - | |
| 21 | -$this->registerJs($js, View::POS_END); | |
| 21 | + | |
| 22 | + $this->registerJs($js, View::POS_END); | |
| 22 | 23 | ?> |
| 23 | 24 | |
| 24 | 25 | <div id="main-page"> |
| ... | ... | @@ -228,7 +229,13 @@ $this->registerJs($js, View::POS_END); |
| 228 | 229 | </div> |
| 229 | 230 | <div class="row"> |
| 230 | 231 | <div class="col-md-12 col-xs-12" style="text-align:center;margin-top: 20px;margin-bottom: -35px;"> |
| 231 | - <a href='site/objects' class="button1 more-projects" target="_blank"><?= Yii::t('app', 'sect2_6') ?></a> | |
| 232 | + <a | |
| 233 | + href="<?=Url::toRoute(['object/index'])?>" | |
| 234 | + class="button1 more-projects" | |
| 235 | + target="_blank" | |
| 236 | + > | |
| 237 | + <?= Yii::t('app', 'sect2_6') ?> | |
| 238 | + </a> | |
| 232 | 239 | </div> |
| 233 | 240 | </div> |
| 234 | 241 | </div> |
| ... | ... | @@ -335,7 +342,13 @@ $this->registerJs($js, View::POS_END); |
| 335 | 342 | </div> |
| 336 | 343 | </div> |
| 337 | 344 | <div class="col-md-12 col-xs-12" style="text-align:center;margin-top: 20px;margin-bottom: -35px;"> |
| 338 | - <a href="site/objects" class="button1 more-projects" target="_blank">Больше о наших проектах</a> | |
| 345 | + <a | |
| 346 | + href="<?=Url::toRoute(['object/index'])?>" | |
| 347 | + class="button1 more-projects" | |
| 348 | + target="_blank" | |
| 349 | + > | |
| 350 | + Больше о наших проектах | |
| 351 | + </a> | |
| 339 | 352 | </div> |
| 340 | 353 | </div> |
| 341 | 354 | </section> | ... | ... |