diff --git a/backend/components/ImgResizer.php b/backend/components/ImgResizer.php index 9b8c372..fb18347 100755 --- a/backend/components/ImgResizer.php +++ b/backend/components/ImgResizer.php @@ -98,28 +98,6 @@ class ImgResizer extends Widget } - public function getImgSize($width,$height,$e){ - if($e>1){ - if($height>$width){ - $this->width = $width; - $this->height = $height/$e; - } else { - $this->height = $height; - $this->width= $width/$e; - } - - } else { - if($width >$height ){ - $this->height = $height; - $this->width = $width*$e; - } else { - $this->width = $width; - $this->height = $height*$e; - } - - } - } - @@ -132,40 +110,29 @@ class ImgResizer extends Widget $width = $size->getWidth(); $height = $size->getHeight(); - $e = $w/$h; - - if($this->isBigger($width,$height,$w,$h)){ - if($height > $width) { - - $x = 0; - $y = ($height - $width) / 2; - $e1 = $width/$height; - - $height = $height*($e1/$e); + $e_width = $w/$h; + $e_height = $h/$w; - }else if($height == $width){ - $x = 0; - $y = ($height - $width) / 2; + $e1_width = $width/$height; + $e1_height = $height/$width; - - $height = $height/$e; + if($this->isBigger($width,$height,$w,$h)){ + if($e_width<$e1_width){ + $new_width = $width*($e_width/$e1_width); + $width = $new_width; }else { - $y = 0; - $x = ($width - $height) / 2; - $e1 = $width/$height; - - $width = $width*($e/$e1); + $new_height = $height*($e_height/$e1_height); + $height = $new_height; } + + } else { $img->save($imageAliasSave, array('flatten' => false)); return true; } - - - - Image::crop($imageAlias, $width, $height,[$x,$y]) + Image::crop($imageAlias, $width, $height,[0,0]) ->save(Yii::getAlias($imageAliasSave), ['quality' => 100]); diff --git a/backend/controllers/NewsController.php b/backend/controllers/NewsController.php index f33dadf..22dc66d 100755 --- a/backend/controllers/NewsController.php +++ b/backend/controllers/NewsController.php @@ -131,4 +131,22 @@ class NewsController extends Controller echo ImgResizer::widget(); } + + public function actionPriceListUpload(){ + + $model = new ImageSizerForm(); + + if (Yii::$app->request->isPost) { + $model->file = UploadedFile::getInstance($model, 'price_list'); + + if ($model->validate()) { + $rout =Yii::getAlias( '@storage/files/file/' . time(). '.' . $model->file->extension); + $model->file->saveAs($rout); + $rout = '/storage/files/file/' . time(). '.' . $model->file->extension; + return json_encode(['name' =>$rout,]); + + } + } + + } } diff --git a/backend/views/news/_form.php b/backend/views/news/_form.php index 0e6e20b..d053a2f 100755 --- a/backend/views/news/_form.php +++ b/backend/views/news/_form.php @@ -73,6 +73,8 @@ use \yii\helpers\Url; ]);?> + + field(new \backend\models\ImageSizerForm(), 'price_list')->widget(FileInput::classname(), [ 'name' => 'file', 'options' => [ @@ -82,13 +84,14 @@ use \yii\helpers\Url; 'initialPreview'=>[ Html::img($model->price_list, ['class'=>'file-preview-image']), ], - 'uploadUrl' => Url::to(['/news/file-upload']), + 'showPreview'=> false, + 'uploadUrl' => Url::to(['/news/price-list-upload']), 'overwriteInitial'=>true, 'uploadExtraData'=> ['width' => 240, 'height' => 160] ], 'pluginEvents' => [ - 'fileuploaded' => 'function(event, key) { document.getElementsByName("News[img]")[0].value = key.response.name }', + 'fileuploaded' => 'function(event, key) { document.getElementsByName("News[price_list]")[0].value = key.response.name }', ] diff --git a/common/components/MailWidget.php b/common/components/MailWidget.php new file mode 100644 index 0000000..c56b3fd --- /dev/null +++ b/common/components/MailWidget.php @@ -0,0 +1,46 @@ +IsSMTP(); + + $mail->CharSet = 'UTF-8'; + + $mail->Username = "dockdep@gmail.com"; + $mail->Password = "k0l0b04eg"; + $mail->SetFrom($this->email); + $mail->Subject = $this->subject; + $mail->MsgHTML($this->text); + $address = "dockdep@gmail.com"; + $mail->AddAddress($address); + + if(!$mail->send()) { + return 'Mailer Error: ' . $mail->ErrorInfo; + } else { + return 'Message has been sent'; + } + } + + + +} + diff --git a/common/models/Callback.php b/common/models/Callback.php new file mode 100644 index 0000000..8ea9d14 --- /dev/null +++ b/common/models/Callback.php @@ -0,0 +1,46 @@ + 45] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'name' => 'Имя', + 'phone_num' => 'Номер телефона', + ]; + } +} diff --git a/composer.json b/composer.json index b41348b..cb04521 100755 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "codeception/codeception": "*", "2amigos/yii2-ckeditor-widget": "~1.0", "mihaildev/yii2-ckeditor": "*", - "kartik-v/yii2-widget-fileinput": "@dev" + "kartik-v/yii2-widget-fileinput": "@dev", + "phpmailer/phpmailer": "^5.2" }, "require-dev": { "yiisoft/yii2-codeception": "*", diff --git a/composer.lock b/composer.lock index cba5dc9..aeb66dc 100644 --- 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": "ee02abda5c7b7eca736817c3c0fc97c9", - "content-hash": "859f6a13927c8412991c47d4b2b7db86", + "hash": "730e64078443048be45853b3c5138188", + "content-hash": "82756055d7c5fb8a9d26bafc73ae0131", "packages": [ { "name": "2amigos/yii2-ckeditor-widget", @@ -822,6 +822,54 @@ "time": "2013-07-10 17:25:36" }, { + "name": "kartik-v/bootstrap-fileinput", + "version": "v4.2.7", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/bootstrap-fileinput.git", + "reference": "0468bbba9c28c1250aca83eba9b33e32ec135f78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/bootstrap-fileinput/zipball/0468bbba9c28c1250aca83eba9b33e32ec135f78", + "reference": "0468bbba9c28c1250aca83eba9b33e32ec135f78", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "kartik\\plugins\\fileinput\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "An enhanced HTML 5 file input for Bootstrap 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.", + "homepage": "https://github.com/kartik-v/bootstrap-fileinput", + "keywords": [ + "ajax", + "bootstrap", + "delete", + "file", + "image", + "input", + "jquery", + "multiple", + "preview", + "progress", + "upload" + ], + "time": "2015-09-13 17:39:44" + }, + { "name": "kartik-v/php-date-formatter", "version": "v1.3.1", "source": { @@ -1060,6 +1108,56 @@ "time": "2015-07-19 04:49:03" }, { + "name": "kartik-v/yii2-widget-fileinput", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-widget-fileinput.git", + "reference": "084447f095888ddb09a95a1a363842ca87e01c9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-fileinput/zipball/084447f095888ddb09a95a1a363842ca87e01c9d", + "reference": "084447f095888ddb09a95a1a363842ca87e01c9d", + "shasum": "" + }, + "require": { + "kartik-v/bootstrap-fileinput": "~4.2", + "kartik-v/yii2-krajee-base": "~1.7" + }, + "type": "yii2-extension", + "autoload": { + "psr-4": { + "kartik\\file\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "An enhanced FileInput widget for Bootstrap 3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)", + "homepage": "https://github.com/kartik-v/yii2-widget-fileinput", + "keywords": [ + "extension", + "file", + "form", + "input", + "jquery", + "plugin", + "upload", + "widget", + "yii2" + ], + "time": "2015-08-17 13:03:50" + }, + { "name": "mihaildev/yii2-ckeditor", "version": "1.0.1", "source": { @@ -1160,6 +1258,67 @@ "time": "2015-02-03 12:10:50" }, { + "name": "phpmailer/phpmailer", + "version": "v5.2.14", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "e774bc9152de85547336e22b8926189e582ece95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/e774bc9152de85547336e22b8926189e582ece95", + "reference": "e774bc9152de85547336e22b8926189e582ece95", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "*", + "phpunit/phpunit": "4.7.*" + }, + "suggest": { + "league/oauth2-client": "Needed for XOAUTH2 authentication", + "league/oauth2-google": "Needed for Gmail XOAUTH2" + }, + "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": "2015-11-01 10:15:28" + }, + { "name": "phpspec/prophecy", "version": "v1.5.0", "source": { @@ -3016,7 +3175,8 @@ "minimum-stability": "stable", "stability-flags": { "artweb/yii2-multiparser": 20, - "kartik-v/yii2-datecontrol": 20 + "kartik-v/yii2-datecontrol": 20, + "kartik-v/yii2-widget-fileinput": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 5adbe29..e5cb52b 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -12,7 +12,8 @@ use yii\web\BadRequestHttpException; use yii\web\Controller; use yii\filters\VerbFilter; use yii\filters\AccessControl; - +use common\models\Callback; +use common\components\MailWidget; /** * Site controller */ @@ -74,6 +75,20 @@ class SiteController extends Controller public function actionIndex() { $this->layout = '/outer'; + + if (Yii::$app->request->post()) { + + $post = Yii::$app->request->post(); + if(isset($post['Callback'])){ + $text = "Имя: ".$post['Callback']['name'].'
'; + $text .= "Телефон: ".$post['Callback']['phone_num']; + $model = new Callback(); + $model->load(Yii::$app->request->post()); + $model->save(); + MailWidget::widget(['email' => 'opel-master@test.com', 'text' => $text, 'subject' => 'Обратный звонок']); + } + + } return $this->render('index'); } diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 4a10613..f29b9e8 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -4,6 +4,7 @@ /* @var $content string */ use yii\helpers\Html; +use yii\widgets\ActiveForm; use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; @@ -11,7 +12,7 @@ use frontend\assets\AppAsset; use common\widgets\Alert; use \yii\widgets\Menu; use \yii\helpers\Url; - +use common\models\Callback; ?> beginPage() ?> @@ -114,6 +115,35 @@ use \yii\helpers\Url; + + + + + + + + + + +

Войти

diff --git a/frontend/views/news/view.php b/frontend/views/news/view.php index f5737f0..e2fe32b 100755 --- a/frontend/views/news/view.php +++ b/frontend/views/news/view.php @@ -15,7 +15,7 @@ $this->params['breadcrumbs'][] = $this->title; content ?>
- Скачать список товаров + Скачать список товаров
diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index bf77f5c..ba1e5c4 100755 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -854,7 +854,7 @@ $(document).ready(function(){ $("#get_user_number").click(function(){ var inputdata = $("#get_telephone").val(); if(inputdata != ''){ - $("#telephone_registration").val(inputdata);; + $(".telephone_registration").val(inputdata);; } }); -- libgit2 0.21.4