From 7832919c344e8ae3bebfbb117b5a2c8ca6c7f01c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 4 May 2017 13:13:56 +0300 Subject: [PATCH] -Ready --- common/images/2_c1QuUp7SqsGSGjyECfQWlcwkl4YRrvZr.png | Bin 0 -> 1473 bytes composer.json | 3 ++- composer.lock | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- frontend/assets/MapAsset.php | 3 ++- frontend/controllers/SiteController.php | 34 +++++++++++++++++++++++++++++++++- frontend/views/layouts/main.php | 57 ++------------------------------------------------------- frontend/views/page/view.php | 85 ++++++++++++++++--------------------------------------------------------------------- frontend/views/site/contact.php | 298 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------- frontend/views/site/index.php | 49 +++++++++++++++++++++++++++---------------------- frontend/views/site/mail.php | 18 ++++++++++++++++++ frontend/web/js/gmaps.init.js | 82 ++++++++++++++++++++++++++++++++++++++-------------------------------------------- frontend/web/js/script.js | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 468 insertions(+), 348 deletions(-) create mode 100644 common/images/2_c1QuUp7SqsGSGjyECfQWlcwkl4YRrvZr.png create mode 100644 frontend/views/site/mail.php mode change 100644 => 100755 frontend/web/js/gmaps.init.js create mode 100755 frontend/web/js/script.js diff --git a/common/images/2_c1QuUp7SqsGSGjyECfQWlcwkl4YRrvZr.png b/common/images/2_c1QuUp7SqsGSGjyECfQWlcwkl4YRrvZr.png new file mode 100644 index 0000000..f1f76e6 Binary files /dev/null and b/common/images/2_c1QuUp7SqsGSGjyECfQWlcwkl4YRrvZr.png differ diff --git a/composer.json b/composer.json index 32764c0..aae6ee7 100755 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "bower-asset/amcharts-stock": "@dev", "speixoto/yii2-amcharts": "^0.1.1", "2amigos/yii2-tinymce-widget": "~1.1", - "kartik-v/yii2-widget-select2": "@dev" + "kartik-v/yii2-widget-select2": "@dev", + "phpmailer/phpmailer": "^5.2" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", diff --git a/composer.lock b/composer.lock index 7a5c394..976ad6e 100755 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "b9f0c4f1da5a4f2f939a03b55e9fc2c7", - "content-hash": "1ad205bd41e4dfbc52bad09c7e6c1677", + "hash": "c4717cdb9e018120896d37d79340e280", + "content-hash": "81a62fa9cc9a08418dec4f3396afeec0", "packages": [ { "name": "2amigos/yii2-tinymce-widget", @@ -1645,6 +1645,82 @@ "time": "2016-11-29 18:17:37" }, { + "name": "phpmailer/phpmailer", + "version": "v5.2.23", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "7115df4a6f76281109ebe352900c42403b728bb4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/7115df4a6f76281109ebe352900c42403b728bb4", + "reference": "7115df4a6f76281109ebe352900c42403b728bb4", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "doctrine/annotations": "1.2.*", + "jms/serializer": "0.16.*", + "phpdocumentor/phpdocumentor": "2.*", + "phpunit/phpunit": "4.8.*", + "symfony/debug": "2.8.*", + "symfony/filesystem": "2.8.*", + "symfony/translation": "2.8.*", + "symfony/yaml": "2.8.*", + "zendframework/zend-cache": "2.5.1", + "zendframework/zend-config": "2.5.1", + "zendframework/zend-eventmanager": "2.5.1", + "zendframework/zend-filter": "2.5.1", + "zendframework/zend-i18n": "2.5.1", + "zendframework/zend-json": "2.5.1", + "zendframework/zend-math": "2.5.1", + "zendframework/zend-serializer": "2.5.*", + "zendframework/zend-servicemanager": "2.5.*", + "zendframework/zend-stdlib": "2.5.1" + }, + "suggest": { + "league/oauth2-google": "Needed for Google XOAUTH2 authentication" + }, + "type": "library", + "autoload": { + "classmap": [ + "class.phpmailer.php", + "class.phpmaileroauth.php", + "class.phpmaileroauthgoogle.php", + "class.smtp.php", + "class.pop3.php", + "extras/EasyPeasyICS.php", + "extras/ntlm_sasl_client.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" + }, + { + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "time": "2017-03-15 19:32:56" + }, + { "name": "phpseclib/phpseclib", "version": "2.0.4", "source": { diff --git a/frontend/assets/MapAsset.php b/frontend/assets/MapAsset.php index 23143c3..aab26dd 100755 --- a/frontend/assets/MapAsset.php +++ b/frontend/assets/MapAsset.php @@ -15,7 +15,8 @@ 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=AIzaSyCoR1Jb-mIFUjPwKiuSlmtYBEwnJOBnAgg&callback', + 'js/gmaps.js', 'js/gmaps.init.js', ]; public $depends = [ diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 8575678..1c74e9c 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -101,11 +101,12 @@ public function actionFeedback() { Yii::$app->response->format = Response::FORMAT_JSON; - if (empty( Yii::$app->request->post() )) { + if (empty(Yii::$app->request->post())) { throw new BadRequestHttpException(); } else { $model = new Feedback(); if ($model->load(Yii::$app->request->post()) && $model->save()) { + $this->sendFeedback($model); return [ 'success' => true, 'message' => 'Success message', @@ -124,4 +125,35 @@ } } } + + protected function sendFeedback(Feedback $model) + { + $settings = Settings::getInstance(); + + require_once '../../vendor/phpmailer/phpmailer/PHPMailerAutoload.php'; + + $mail = new \PHPMailer(); + + //$mail->SMTPDebug = 3; // Enable verbose debug output + + $mail->isSMTP(); // Set mailer to use SMTP + $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers + $mail->SMTPAuth = true; // Enable SMTP authentication + $mail->Username = 'hugeloginnamefortest@gmail.com'; // SMTP username + $mail->Password = 'hugepasswordfortest'; // SMTP password + $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->Port = 587; // TCP port to connect to + + $mail->setFrom('total-automation@mailer.com', 'Mailer'); + $mail->addAddress($settings->email); // Add a recipient + + $mail->isHTML(true); // Set email format to HTML + + $mail->Subject = 'Отзыв'; + $mail->Body = $this->renderPartial('mail', [ + 'model' => $model, + ]); + + $mail->send(); + } } diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 20a6140..48329ac 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -42,6 +42,7 @@ 0 ]) ->with('lang.alias') + ->orderBy('sort') ->all(); $solutions = Page::find() ->where([ 'in_menu' => true ]) @@ -51,6 +52,7 @@ 0 ]) ->with('lang.alias') + ->orderBy('sort') ->all(); $about = Page::find() ->where([ 'in_menu' => true ]) @@ -380,61 +382,6 @@ _________________________________________________________ --> - - - - - - diff --git a/frontend/views/site/mail.php b/frontend/views/site/mail.php new file mode 100644 index 0000000..d1e81f0 --- /dev/null +++ b/frontend/views/site/mail.php @@ -0,0 +1,18 @@ + + + + + + + +
Имя :name;?>
Email :email; ?>
Телефон :phone; ?>
Сообщение :message ?>
diff --git a/frontend/web/js/gmaps.init.js b/frontend/web/js/gmaps.init.js old mode 100644 new mode 100755 index a5ca4cb..13ae12e --- a/frontend/web/js/gmaps.init.js +++ b/frontend/web/js/gmaps.init.js @@ -1,48 +1,42 @@ -$(function () { +$( + function() { - map(); + function initMap() { + var newLat = window.lat; + var lng = window.lon; + var styles = [{ + stylers: [ + { saturation: -100 } + ] + }]; + map = new GMaps({ + el: '#map', + lat: newLat, + lng: lng, + zoomControl: true, + zoomControlOpt: { + style: 'SMALL', + position: 'TOP_LEFT' + }, + panControl: false, + streetViewControl: false, + mapTypeControl: false, + overviewMapControl: false, + scrollwheel: false, + draggable: false, + styles: styles, + zoom: 14 + }); -}); + var image = '/img/marker2.png'; -/* map */ + map.addMarker({ + lat: newLat, + lng: lng, + icon: image + }); + } -function map() { - var newLat = 50.4534482; - var lng = 30.4249462; - // var styles = [{"featureType": "landscape", "stylers": [{"saturation": -100}, {"lightness": 65}, {"visibility": "on"}]}, {"featureType": "poi", "stylers": [{"saturation": -100}, {"lightness": 51}, {"visibility": "simplified"}]}, {"featureType": "road.highway", "stylers": [{"saturation": -100}, {"visibility": "simplified"}]}, {"featureType": "road.arterial", "stylers": [{"saturation": -100}, {"lightness": 30}, {"visibility": "on"}]}, {"featureType": "road.local", "stylers": [{"saturation": -100}, {"lightness": 40}, {"visibility": "on"}]}, {"featureType": "transit", "stylers": [{"saturation": -100}, {"visibility": "simplified"}]}, {"featureType": "administrative.province", "stylers": [{"visibility": "off"}]}, {"featureType": "water", "elementType": "labels", "stylers": [{"visibility": "on"}, {"lightness": -25}, {"saturation": -100}]}, {"featureType": "water", "elementType": "geometry", "stylers": [{"hue": "#ffff00"}, {"lightness": -25}, {"saturation": -97}]}]; - var styles = [{ - stylers: [ - { saturation: -100 } - ] - }]; - map = new GMaps({ - el: '#map', - lat: newLat, - lng: lng, - zoomControl: true, - zoomControlOpt: { - style: 'SMALL', - position: 'TOP_LEFT' - }, - panControl: false, - streetViewControl: false, - mapTypeControl: false, - overviewMapControl: false, - scrollwheel: false, - draggable: false, - styles: styles, - zoom: 14 - }); - - var image = 'img/marker2.png'; - - map.addMarker({ - lat: newLat, - lng: lng, - icon: image/* , - title: '', - infoWindow: { - content: '

HTML Content

' - }*/ - }); -} \ No newline at end of file + window.initMap = initMap(); + } +); diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js new file mode 100755 index 0000000..a91d0ea --- /dev/null +++ b/frontend/web/js/script.js @@ -0,0 +1,107 @@ +$( + function() { + + /** + * Modal form submit code + */ + $(document) + .on( + 'beforeSubmit', '#feedback-form', function(e) { + var f = this; + var form = $(this); + var formData = form.serialize(); + $.ajax( + { + url: form.attr("action"), + type: form.attr("method"), + data: formData, + success: function(data) { + f.reset(); + $('#myModal') + .modal('hide'); + $('#success-modal') + .modal('show'); + }, + error: function() { + $('#feedback-modal') + .modal('hide'); + } + } + ); + } + ) + .on( + 'submit', '#feedback-form', function(e) { + e.preventDefault(); + } + ); + + /** + * Contact form submitting + */ + $(document) + .on( + 'beforeSubmit', '#contact-form', function(e) { + var f = this; + var form = $(this); + var formData = form.serialize(); + $.ajax( + { + url: form.attr("action"), + type: form.attr("method"), + data: formData, + success: function(data) { + f.reset(); + form.replaceWith(data.alert) + }, + error: function() { + + } + } + ); + } + ) + .on( + 'submit', '#contact-form', function(e) { + e.preventDefault(); + } + ); + + /** + * Button UP code + */ + if ($('#back-to-top').length) { + var scrollTrigger = 100, // px + backToTop = function() { + var scrollTop = $(window) + .scrollTop(); + if (scrollTop > scrollTrigger) { + $('#back-to-top') + .addClass('show'); + } else { + $('#back-to-top') + .removeClass('show'); + } + }; + backToTop(); + $(window) + .on( + 'scroll', function() { + backToTop(); + } + ); + $('#back-to-top') + .on( + 'click', function(e) { + e.preventDefault(); + $('html,body') + .animate( + { + scrollTop: 0 + }, 700 + ); + } + ); + } + } +); \ No newline at end of file -- libgit2 0.21.4