Commit d9a2909bd9cc1ba9214b8a721be792d334465173
1 parent
49fc6a1d
Mail Order save template and send dev
Showing
3 changed files
with
144 additions
and
1 deletions
Show diff stats
common/widgets/Mailer.php
@@ -37,7 +37,7 @@ class Mailer extends Widget{ | @@ -37,7 +37,7 @@ class Mailer extends Widget{ | ||
37 | if(!$mail->send()) { | 37 | if(!$mail->send()) { |
38 | 38 | ||
39 | \Yii::$app->getSession()->setFlash('error', 'Mailer Error: ' . $mail->ErrorInfo); | 39 | \Yii::$app->getSession()->setFlash('error', 'Mailer Error: ' . $mail->ErrorInfo); |
40 | - var_dump($mail->ErrorInfo);die(); | 40 | + |
41 | return 'Mailer Error: ' . $mail->ErrorInfo; | 41 | return 'Mailer Error: ' . $mail->ErrorInfo; |
42 | } else { | 42 | } else { |
43 | 43 |
1 | +<?php var_dump($params);die();?> | ||
2 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
3 | +<html lang="uk"> | ||
4 | +<head> | ||
5 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
6 | + <title>NAKED PRICE</title> | ||
7 | + <style type="text/css"> | ||
8 | + body { | ||
9 | + font-family: helvetica neue, arial, sans-serif; | ||
10 | + line-height: 1.5; | ||
11 | + padding: 0; | ||
12 | + margin: 0; | ||
13 | + } | ||
14 | + </style> | ||
15 | +</head> | ||
16 | +<body style="margin: 0;"> | ||
17 | +<div class="container" style=" | ||
18 | + margin: 0 auto; | ||
19 | + font-family: helvetica neue, arial, sans-serif; | ||
20 | + font-size: 16px; | ||
21 | + line-height: 1.5; | ||
22 | + width: 100%; | ||
23 | + max-width: 740px; | ||
24 | + min-width: 360px; | ||
25 | + "> | ||
26 | + <div style="text-align: center"> | ||
27 | + <br> | ||
28 | + <h1 style="margin: -5px 40px 10px; line-height: 1.2;">Добрый день, <?php=$this->account->name ?>!</h1> | ||
29 | + <h2 style="font-weight: 300; margin: 10px 40px 40px; line-height: 1.2;">Ваш заказ получен. В ближайшее время с Вами свяжется наш менеджер для уточнения деталей</h2> | ||
30 | + </div> | ||
31 | + <table cellpadding="0" cellspacing="0" border="0" valign="top" style=" | ||
32 | + background: #eee; border-radius: 4px; | ||
33 | + width: 100%; | ||
34 | + "> | ||
35 | + <tr> | ||
36 | + <td style="text-align: left; vertical-align: top; font-size: 85%; padding: 20px 15px 15px 20px; border-right: 1px solid #ddd;"> | ||
37 | + <strong>Заказ №<?php=$this->id ?></strong> | ||
38 | + <br> | ||
39 | + <?php=$this->created_at->format("d.m.Y"); ?> | ||
40 | + <br> | ||
41 | + На сумму <strong><?php=$this->total ?></strong> грн | ||
42 | + </td> | ||
43 | + <td style="text-align: left; vertical-align: top; font-size: 85%; padding: 20px 15px 15px 20px;"> | ||
44 | + <strong>Данные покупателя</strong> | ||
45 | + <br> | ||
46 | + <?php=$this->account->name ?> | ||
47 | + <br> | ||
48 | + <nobr><?php=$this->account->phone ?></nobr> | ||
49 | + <br> | ||
50 | + <?php=$this->account->email ?> | ||
51 | + </td> | ||
52 | + <td style="text-align: left; vertical-align: top; font-size: 85%; padding: 20px 15px 15px;"> | ||
53 | + <strong>Доставка</strong> | ||
54 | + <br> | ||
55 | + <?php=$this->city ?> | ||
56 | + <br> | ||
57 | + <?php=$this->address ?> | ||
58 | + | ||
59 | + </td> | ||
60 | + <td style="text-align: left; vertical-align: top; font-size: 85%; padding: 20px 20px 15px 15px;"> | ||
61 | + <strong>Спасибо за покупку!</strong> | ||
62 | + <br> | ||
63 | + <a href="http://www.rukzachok.com.ua" | ||
64 | + </td> | ||
65 | + </tr> | ||
66 | + <tr> | ||
67 | + <td colspan="4" style="background: #fff;"> | ||
68 | + <table cellpadding="0" cellspacing="0" border="0" valign="top" style=" | ||
69 | + width: 100%;"> | ||
70 | + <thead style="font-size: 70%;"> | ||
71 | + <tr> | ||
72 | + <th style="border-bottom: 2px solid #eee; padding: 10px 10px 5px 0;"> </th> | ||
73 | + <th style="border-bottom: 2px solid #eee; text-align: left; padding: 10px 10px 5px;">Название</th> | ||
74 | + <th style="border-bottom: 2px solid #eee; text-align: right; padding: 10px 10px 5px;">Количество</th> | ||
75 | + <th style="border-bottom: 2px solid #eee; text-align: right; padding: 10px 30px 5px 10px;">Цена</th> | ||
76 | + </tr> | ||
77 | + </thead> | ||
78 | + <tbody> | ||
79 | + <?php foreach ($this->orderItems as $thisItem) { ?> | ||
80 | + <tr> | ||
81 | + <td style="padding: 0; vertical-align: top; line-height: 0; text-align: left; border-bottom: 1px solid #ddd; border-left: 1px solid #eee;"> | ||
82 | + <img src="{{$thisItem->product->img?>" width="150"> | ||
83 | + </td> | ||
84 | + <td style="padding: 65px 10px 20px; vertical-align: top; text-align: left; border-bottom: 1px solid #ddd; font-size: 18px;"> | ||
85 | + <?php=$thisItem->product->name ?> | ||
86 | + </td> | ||
87 | + <td style="padding: 65px 10px 20px; vertical-align: top; text-align: right; border-bottom: 1px solid #ddd; font-size: 18px;"> | ||
88 | + <small style="margin-right: 1px;">×</small><?php=$thisItem->quantity ?> | ||
89 | + </td> | ||
90 | + <td style="padding: 65px 30px 20px 10px; vertical-align: top; text-align: right; border-bottom: 1px solid #ddd; border-right: 1px solid #eee; font-size: 18px;"> | ||
91 | + <?php=number_format($thisItem->total) ?> грн | ||
92 | + </td> | ||
93 | + </tr> | ||
94 | + <?php } ?> | ||
95 | + </tbody> | ||
96 | + <tfoot> | ||
97 | + <tr> | ||
98 | + <td colspan="3" style="background: #eee; vertical-align: top; border-radius: 0 0 0 4px; padding: 13px 10px 20px; border-top: 1px solid #ddd; text-align: right; font-size: 14px;"> | ||
99 | + <strong>Всего к оплате:</strong> | ||
100 | + </td> | ||
101 | + <td style="background: #eee; vertical-align: top; border-radius: 0 0 4px 0; padding: 10px 30px 20px 10px; border-top: 1px solid #ddd; text-align: right; font-size: 18px;"> | ||
102 | + <strong><?php=number_format($this->total) ?> грн</strong> | ||
103 | + </td> | ||
104 | + </tr> | ||
105 | + <tfoot> | ||
106 | + </table> | ||
107 | + </td> | ||
108 | + </tr> | ||
109 | + </table> | ||
110 | + <div style="padding: 40px;"> | ||
111 | + <h4 style="text-align: center"> | ||
112 | + NAKED PRICE – цены взрывают сознание | ||
113 | + </h4> | ||
114 | + <table cellpadding="0" cellspacing="0" border="0" valign="top" style=" | ||
115 | + width: 100%; margin: 20px 0;"> | ||
116 | + <tr> | ||
117 | + <td style="border-top: 1px solid #eee; text-align: right; font-size: 100%; padding: 30px 20px 0 0;"> | ||
118 | + +38 (067) 395 65 73 | ||
119 | + </td> | ||
120 | + <td style="border-top: 1px solid #eee; text-align: left; font-size: 100%; padding: 30px 0 0 20px;"> | ||
121 | + <a href="http://rukzachok.com.ua">rukzachok.com.ua</a> | ||
122 | + </td> | ||
123 | + </tr> | ||
124 | + </table> | ||
125 | + <div style="text-align: center; font-size: 65%; color: #ccc;">Дата покупки: <?php=$thisItem->created_at ?></div> | ||
126 | + </div> | ||
127 | +</div> | ||
128 | +</body> | ||
129 | +</html> | ||
0 | \ No newline at end of file | 130 | \ No newline at end of file |
frontend/controllers/BasketController.php
@@ -9,6 +9,7 @@ use Yii; | @@ -9,6 +9,7 @@ use Yii; | ||
9 | use yii\web\Controller; | 9 | use yii\web\Controller; |
10 | use common\modules\product\models\ProductVariant; | 10 | use common\modules\product\models\ProductVariant; |
11 | use common\models\Orders; | 11 | use common\models\Orders; |
12 | +use common\widgets\Mailer; | ||
12 | //use app\models\User; | 13 | //use app\models\User; |
13 | //use app\models\OrdersProducts; | 14 | //use app\models\OrdersProducts; |
14 | use yii\web\HttpException; | 15 | use yii\web\HttpException; |
@@ -66,6 +67,17 @@ class BasketController extends Controller | @@ -66,6 +67,17 @@ class BasketController extends Controller | ||
66 | $order = clone $modelOrder; | 67 | $order = clone $modelOrder; |
67 | $modelOrder->clearBasket(); | 68 | $modelOrder->clearBasket(); |
68 | 69 | ||
70 | + Mailer::widget( | ||
71 | + ['type' => 'order', | ||
72 | + 'subject'=> 'Спасибо за регистрацию', | ||
73 | + 'email' => $model->username, | ||
74 | + 'params' => [ | ||
75 | + 'name' => $modelOrder->name, | ||
76 | + 'order' => $order, | ||
77 | + 'variants' => $productV, | ||
78 | + ] | ||
79 | + ]); | ||
80 | + | ||
69 | return $this->render('success',[ | 81 | return $this->render('success',[ |
70 | 'order' => $order, | 82 | 'order' => $order, |
71 | 'variants' => $productV, | 83 | 'variants' => $productV, |
@@ -81,6 +93,8 @@ class BasketController extends Controller | @@ -81,6 +93,8 @@ class BasketController extends Controller | ||
81 | $modelOrder->phone = $user->phone; | 93 | $modelOrder->phone = $user->phone; |
82 | $modelOrder->name = $user->name; | 94 | $modelOrder->name = $user->name; |
83 | } | 95 | } |
96 | + | ||
97 | + | ||
84 | 98 | ||
85 | return $this->render('index', [ | 99 | return $this->render('index', [ |
86 | 'modelMod'=>$modelMod, | 100 | 'modelMod'=>$modelMod, |