From cab7e1c61df114ecfaf194b6a773ce0d4295b215 Mon Sep 17 00:00:00 2001 From: timur Date: Tue, 5 Dec 2017 14:37:40 +0200 Subject: [PATCH] mail sending --- common/mail/feedback.php | 10 +++++++--- common/messages/ru/app.php | 10 +++++++++- common/models/Feedback.php | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ console/migrations/m171205_114149_add_promocode_column_to_feedback_table.php | 27 +++++++++++++++++++++++++++ frontend/assets/AppAsset.php | 2 -- frontend/assets/MapAsset.php | 2 +- frontend/controllers/SiteController.php | 14 ++++++++++---- frontend/views/layouts/main.php | 42 +++++++++++++++++++++++++++--------------- 8 files changed, 211 insertions(+), 26 deletions(-) create mode 100644 common/models/Feedback.php create mode 100644 console/migrations/m171205_114149_add_promocode_column_to_feedback_table.php diff --git a/common/mail/feedback.php b/common/mail/feedback.php index 3b0eabf..31af032 100644 --- a/common/mail/feedback.php +++ b/common/mail/feedback.php @@ -1,5 +1,5 @@ email ?> - - message ?> + + promocode)? $model->promocode : 'без промокода' ?> + + + + oplata ?> diff --git a/common/messages/ru/app.php b/common/messages/ru/app.php index e3b6834..121fc8e 100644 --- a/common/messages/ru/app.php +++ b/common/messages/ru/app.php @@ -1,2 +1,10 @@ 'оплата', + 'promocode' => 'промокод', + 'Name: ' => 'Имя :', + 'Phone: ' => 'Телефон: ', + 'Email: ' => 'Email: ', + 'Promocode: ' => 'Промокод: ', + 'Oplata: ' => 'Оплата: ', + ]; \ No newline at end of file diff --git a/common/models/Feedback.php b/common/models/Feedback.php new file mode 100644 index 0000000..e19de9b --- /dev/null +++ b/common/models/Feedback.php @@ -0,0 +1,130 @@ + [ + 'name', + 'email', + 'message', + 'returnUrl', + 'phone', + 'oplata', + 'promocode', + ], + self::SCENARIO_CALLBACK => [ + 'name', + 'phone', + 'message', + 'returnUrl', + ], + ] + ); + return $scenarios; + } + + public function rules() + { + return [ + [ + [ + 'name', + 'email', + 'phone', + ], + 'required', + 'on' => self::SCENARIO_DEFAULT, + ], + [ + [ + 'name', + 'email', + 'phone', + 'oplata' + ], + 'required', + 'on' => self::SCENARIO_FEEDBACK, + ], + [ + [ + 'phone', + 'name', + ], + 'required', + 'on' => self::SCENARIO_CALLBACK, + ], + [ + [ 'email' ], + 'email', + ], + // [ + // [ 'phone' ], + // 'match', + // 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', + // ], + [ + [ + 'name', + 'phone', + 'email', + 'oplata', + 'promocode', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'message', + ], + 'string', + ], + [ + [ + 'status', + ], + 'boolean', + ], + [ + 'returnUrl', + 'safe', + ], + ]; + } + + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'id'), + 'name' => Yii::t('core', 'name'), + 'phone' => Yii::t('core', 'phone'), + 'created_at' => Yii::t('core', 'created_at'), + 'ip' => Yii::t('core', 'ip'), + 'url' => Yii::t('core', 'url'), + 'status' => Yii::t('core', 'status'), + 'message' => Yii::t('core', 'message'), + 'email' => Yii::t('core', 'email'), + 'oplata' => Yii::t('app', 'oplata'), + 'promocode' => Yii::t('app', 'promocode'), + ]; + } + + } + \ No newline at end of file diff --git a/console/migrations/m171205_114149_add_promocode_column_to_feedback_table.php b/console/migrations/m171205_114149_add_promocode_column_to_feedback_table.php new file mode 100644 index 0000000..50aa462 --- /dev/null +++ b/console/migrations/m171205_114149_add_promocode_column_to_feedback_table.php @@ -0,0 +1,27 @@ +addColumn('feedback', 'promocode', $this->string(255)); + $this->addColumn('feedback', 'oplata', $this->string(150)); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropColumn('feedback', 'promocode'); + $this->dropColumn('feedback', 'oplata'); + } +} diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 9bf2a13..3bf0e9f 100644 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -27,8 +27,6 @@ 'js/jquery.parallax-1.1.3.js', 'js/front.js', 'js/owl.carousel.min.js', - '//maps.googleapis.com/maps/api/js?key=AIzaSyCgyPQhOmGEwyAdZ0uS6fJLLvnNxgncfy0&callback=initMap', - '/js/gmaps.init.js', 'js/script.js', ]; public $depends = [ diff --git a/frontend/assets/MapAsset.php b/frontend/assets/MapAsset.php index 23143c3..33a6b48 100644 --- a/frontend/assets/MapAsset.php +++ b/frontend/assets/MapAsset.php @@ -15,7 +15,7 @@ public $baseUrl = '@web'; public $css = []; public $js = [ - '//maps.googleapis.com/maps/api/js?key=AIzaSyCoR1Jb-mIFUjPwKiuSlmtYBEwnJOBnAgg&callback=initMap', + '//maps.googleapis.com/maps/api/js?key=AIzaSyCgyPQhOmGEwyAdZ0uS6fJLLvnNxgncfy0', 'js/gmaps.init.js', ]; public $depends = [ diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index af69a76..25214b8 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -1,7 +1,7 @@ $model, ] ) - ->setFrom('artbox@domain.com') - ->setTo($settings->email) - ->setSubject(\Yii::t('app', 'Feedback')) + ->setFrom(['artwebdev17@gmail.com'=> 'artweb']) + ->setTo( + [ +// 'kotets.nik@gmail.com', +// 'kazimirova.artweb@gmail.com', + 'tamerlan8.05.92@gmail.com', + ] + ) + ->setSubject('Bitcoin Invest участие в форуме') ->send(); return [ diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index dbbc023..c99d839 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -10,11 +10,12 @@ use artbox\core\components\SeoComponent; use artbox\core\helpers\ImageHelper; - use artbox\core\models\Feedback; + use common\models\Feedback; use artbox\core\models\PageCategory; use artbox\core\models\User; use common\models\Settings; use frontend\assets\AppAsset; + use frontend\assets\MapAsset; use artbox\core\components\imagemanager\models\ImageManager; use yii\bootstrap\ActiveForm; use yii\bootstrap\Nav; @@ -25,9 +26,10 @@ use yii\widgets\Breadcrumbs; AppAsset::register($this); + MapAsset::register($this); $user = \Yii::$app->user->identity; $seo = Yii::$app->get('seo'); - $feedback = new Feedback(); + $feedback = new Feedback(['scenario' => Feedback::SCENARIO_FEEDBACK]); $settings = Settings::getInstance(); $controller = Yii::$app->controller; $default_controller = Yii::$app->defaultRoute; @@ -190,25 +192,35 @@ _________________________________________________________ --> ->textInput()->Label('Номер телефона'); ?>
- field($feedback, 'message') + field($feedback, 'promocode') ->textInput()->Label('Впишите промокод для получения скидки -20%'); ?>
Как вам удобно оплатить?*
- - - + field($feedback, 'oplata') + ->radioList( + [ + "Перевод на карту Приватбанка без промокода (150 грн)" => 'Перевод на карту Приватбанка (до 16 декабря стоимость билета 150 грн)', + "Перевод на карту Приватбанка с промокода (120 грн)" => 'Перевод на карту Приватбанка (с промокодом стоимость до 16 декабря 120 грн)', + "Наличными представителю" => 'Наличными представителю (в день мероприятия, 16 декабря, цена 200 грн)', + ], + [ + 'unselect' => null, + ] + )->label(false); + ?>
-
-

- 'send-form btn btn-lg btn-template-primary', - ] - ) ?> -

+
+

+ 'send-form btn btn-lg btn-template-primary', + ] + ) ?> +

+
-- libgit2 0.21.4