Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
presetmailing.php
1<?
2
3namespace Bitrix\Sale\Sender;
4
6
7Loc::loadMessages(__FILE__);
8
10{
11 protected static function getMailTemplate(array $params = null)
12 {
13 if(!isset($params['TITLE']))
14 {
15 $params['TITLE'] = '%TITLE%';
16 }
17
18 if(!isset($params['TEXT']))
19 {
20 $params['TEXT'] = '%TEXT%';
21 }
22
23 return '
24<style>
25 body
26 {
27 font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;
28 font-size: 14px;
29 color: #000;
30 }
31</style>
32<table cellpadding="0" cellspacing="0" width="850" style="background-color: #d1d1d1; border-radius: 2px; border:1px solid #d1d1d1; margin: 0 auto;" border="1" bordercolor="#d1d1d1">
33<tbody>
34<tr>
35 <td height="83" width="850" bgcolor="#eaf3f5" style="border: none; padding-top: 23px; padding-right: 17px; padding-bottom: 24px; padding-left: 17px;">
36 <table cellpadding="0" cellspacing="0" width="100%">
37 <tbody>
38 <tr>
39 <td bgcolor="#ffffff" height="75" style="font-weight: bold; text-align: center; font-size: 26px; color: #0b3961;">
40 #SITE_NAME#: ' . $params['TITLE'] . '
41 </td>
42 </tr>
43 <tr>
44 <td bgcolor="#bad3df" height="11">
45 </td>
46 </tr>
47 </tbody>
48 </table>
49 </td>
50</tr>
51<tr>
52 <td width="850" bgcolor="#f7f7f7" valign="top" style="border: none; padding-top: 0; padding-right: 44px; padding-bottom: 16px; padding-left: 44px;">
53 <br>
54 <p style="margin-top: 0px; margin-bottom: 20px;">
55 ' . $params['TEXT'] . '
56 </p>
57 </td>
58</tr>
59<tr>
60 <td height="40px" width="850" bgcolor="#f7f7f7" valign="top" style="border: none; padding-top: 0; padding-right: 44px; padding-bottom: 30px; padding-left: 44px;">
61 <p style="border-top: 1px solid #d1d1d1; margin-bottom: 5px; margin-top: 0; padding-top: 20px; line-height:21px;">
62 ' . Loc::getMessage('PRESET_MAIL_TEMPLATE_REGARDS', array('%LINK_START%' => '<a href="http://#SERVER_NAME#" style="color:#2e6eb6;">', '%LINK_END%' => '</a>')) . '
63 <br><br>
64 ' . Loc::getMessage('PRESET_MAIL_TEMPLATE_UNSUB') . '
65 </p>
66 </td>
67</tr>
68</tbody>
69</table>';
70 }
71
72 protected static function getCoupon($perc = 5)
73 {
74 if(!is_numeric($perc))
75 $perc = 5;
76
77 return '<?EventMessageThemeCompiler::includeComponent(
78 "bitrix:sale.discount.coupon.mail",
79 "",
80 Array(
81 "COMPONENT_TEMPLATE" => ".default",
82 "DISCOUNT_XML_ID" => "{#SENDER_CHAIN_CODE#}",
83 "DISCOUNT_VALUE" => "' . $perc . '",
84 "DISCOUNT_UNIT" => "Perc",
85 "COUPON_TYPE" => "Order",
86 "COUPON_DESCRIPTION" => "{#EMAIL_TO#}"
87 )
88 );?>';
89 }
90
91 protected static function getBasketCart()
92 {
93 return '<?EventMessageThemeCompiler::includeComponent(
94 "bitrix:sale.basket.basket.small.mail",
95 "",
96 Array(
97 "USER_ID" => "{#USER_ID#}",
98 "PATH_TO_BASKET" => "/",
99 "PATH_TO_ORDER" => "/",
100 )
101 );?>';
102 }
103
104 protected static function getMessagePlaceHolders()
105 {
106 return array(
107 '%BASKET_CART%' => self::getBasketCart(),
108 '%COUPON%' => self::getCoupon(5),
109 '%COUPON_3%' => self::getCoupon(3),
110 '%COUPON_5%' => self::getCoupon(5),
111 '%COUPON_7%' => self::getCoupon(7),
112 '%COUPON_10%' => self::getCoupon(10),
113 '%COUPON_11%' => self::getCoupon(11),
114 '%COUPON_15%' => self::getCoupon(15),
115 '%COUPON_20%' => self::getCoupon(20),
116 );
117 }
118
119 public static function getForgottenCart($days)
120 {
121 return array(
122 'TYPE' => Loc::getMessage('PRESET_TYPE_BASKET'),
123 'CODE' => 'sale_basket',
124 'NAME' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_NAME'),
125 'DESC_USER' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_DESC_USER'),
126 'DESC' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_DESC'),
127 'TRIGGER' => array(
128 'START' => array(
129 'ENDPOINT' => array(
130 'MODULE_ID' => 'sale',
131 'CODE' => 'basket_forgotten',
132 'FIELDS' => array('DAYS_BASKET_FORGOTTEN' => $days)
133 )
134 ),
135 'END' => array(
136 'ENDPOINT' => array(
137 'MODULE_ID' => 'sale',
138 'CODE' => 'order_paid',
139 'FIELDS' => array()
140 )
141 ),
142 ),
143 'CHAIN' => array(
144 array(
145 'TIME_SHIFT' => 0,
146 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_1_SUBJECT'),
147 'MESSAGE' => self::getMailTemplate(array(
148 'TITLE' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_1_SUBJECT'),
149 'TEXT' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_1_MESSAGE', static::getMessagePlaceHolders()),
150 )),
151 ),
152 array(
153 'TIME_SHIFT' => 1440,
154 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_2_SUBJECT'),
155 'MESSAGE' => self::getMailTemplate(array(
156 'TITLE' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_2_SUBJECT'),
157 'TEXT' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_2_MESSAGE', static::getMessagePlaceHolders()),
158 )),
159 ),
160 array(
161 'TIME_SHIFT' => 1440,
162 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_3_SUBJECT'),
163 'MESSAGE' => self::getMailTemplate(array(
164 'TITLE' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_3_SUBJECT'),
165 'TEXT' => Loc::getMessage('PRESET_FORGOTTEN_BASKET_LETTER_3_MESSAGE', static::getMessagePlaceHolders()),
166 )),
167 ),
168 )
169 );
170 }
171
172 public static function getCanceledOrder()
173 {
174 return array(
175 'TYPE' => Loc::getMessage('PRESET_TYPE_ORDER'),
176 'CODE' => 'sale_order_cancel',
177 'NAME' => Loc::getMessage('PRESET_CANCELED_ORDER_NAME'),
178 'DESC_USER' => Loc::getMessage('PRESET_CANCELED_ORDER_DESC_USER'),
179 'DESC' => Loc::getMessage('PRESET_CANCELED_ORDER_DESC'),
180 'TRIGGER' => array(
181 'START' => array(
182 'ENDPOINT' => array(
183 'MODULE_ID' => 'sale',
184 'CODE' => 'order_cancel',
185 'FIELDS' => array()
186 )
187 ),
188 'END' => array(
189 'ENDPOINT' => array(
190 'MODULE_ID' => 'sale',
191 'CODE' => 'order_paid',
192 'FIELDS' => array()
193 )
194 ),
195 ),
196 'CHAIN' => array(
197 array(
198 'TIME_SHIFT' => 0,
199 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_1_SUBJECT'),
200 'MESSAGE' => self::getMailTemplate(array(
201 'TITLE' => Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_1_SUBJECT'),
202 'TEXT' => Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_1_MESSAGE', static::getMessagePlaceHolders()),
203 )),
204 ),
205 array(
206 'TIME_SHIFT' => 1440,
207 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_2_SUBJECT'),
208 'MESSAGE' => self::getMailTemplate(array(
209 'TITLE' => Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_2_SUBJECT'),
210 'TEXT' => Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_2_MESSAGE', static::getMessagePlaceHolders()),
211 )),
212 ),
213 array(
214 'TIME_SHIFT' => 1440,
215 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_3_SUBJECT'),
216 'MESSAGE' => self::getMailTemplate(array(
217 'TITLE' => Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_3_SUBJECT'),
218 'TEXT' => Loc::getMessage('PRESET_CANCELED_ORDER_LETTER_3_MESSAGE', static::getMessagePlaceHolders()),
219 )),
220 ),
221 )
222 );
223 }
224
225 public static function getPaidOrder()
226 {
227 return array(
228 'TYPE' => Loc::getMessage('PRESET_TYPE_ORDER'),
229 'CODE' => 'sale_order_pay',
230 'NAME' => Loc::getMessage('PRESET_PAID_ORDER_NAME'),
231 'DESC_USER' => Loc::getMessage('PRESET_PAID_ORDER_DESC_USER'),
232 'DESC' => Loc::getMessage('PRESET_PAID_ORDER_DESC'),
233 'TRIGGER' => array(
234 'START' => array(
235 'ENDPOINT' => array(
236 'MODULE_ID' => 'sale',
237 'CODE' => 'order_paid',
238 'FIELDS' => array()
239 )
240 ),
241 'END' => array(
242 'ENDPOINT' => array(
243 'MODULE_ID' => 'sale',
244 'CODE' => 'order_paid',
245 'FIELDS' => array()
246 )
247 ),
248 ),
249 'CHAIN' => array(
250 array(
251 'TIME_SHIFT' => 1440,
252 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_PAID_ORDER_LETTER_1_SUBJECT'),
253 'MESSAGE' => self::getMailTemplate(array(
254 'TITLE' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_1_SUBJECT'),
255 'TEXT' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_1_MESSAGE', static::getMessagePlaceHolders()),
256 )),
257 ),
258 array(
259 'TIME_SHIFT' => 1440,
260 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_PAID_ORDER_LETTER_2_SUBJECT'),
261 'MESSAGE' => self::getMailTemplate(array(
262 'TITLE' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_2_SUBJECT'),
263 'TEXT' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_2_MESSAGE', static::getMessagePlaceHolders()),
264 )),
265 ),
266 array(
267 'TIME_SHIFT' => 1440,
268 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_PAID_ORDER_LETTER_3_SUBJECT'),
269 'MESSAGE' => self::getMailTemplate(array(
270 'TITLE' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_3_SUBJECT'),
271 'TEXT' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_3_MESSAGE', static::getMessagePlaceHolders()),
272 )),
273 ),
274 array(
275 'TIME_SHIFT' => 1440,
276 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_PAID_ORDER_LETTER_4_SUBJECT'),
277 'MESSAGE' => self::getMailTemplate(array(
278 'TITLE' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_4_SUBJECT'),
279 'TEXT' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_4_MESSAGE', static::getMessagePlaceHolders()),
280 )),
281 ),
282 array(
283 'TIME_SHIFT' => 1440,
284 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_PAID_ORDER_LETTER_5_SUBJECT'),
285 'MESSAGE' => self::getMailTemplate(array(
286 'TITLE' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_5_SUBJECT'),
287 'TEXT' => Loc::getMessage('PRESET_PAID_ORDER_LETTER_5_MESSAGE', static::getMessagePlaceHolders()),
288 )),
289 ),
290 )
291 );
292 }
293
294 public static function getDontBuy($days)
295 {
296 return array(
297 'TYPE' => Loc::getMessage('PRESET_TYPE_ORDER'),
298 'CODE' => 'sale_order_not_create'.$days,
299 'NAME' => Loc::getMessage('PRESET_DONT_BUY_NAME', array('%DAYS%' => $days)),
300 'DESC_USER' => Loc::getMessage('PRESET_DONT_BUY_DESC_USER', array('%DAYS%' => $days)),
301 'DESC' => Loc::getMessage('PRESET_DONT_BUY_DESC_' . $days),
302 'TRIGGER' => array(
303 'START' => array(
304 'ENDPOINT' => array(
305 'MODULE_ID' => 'sale',
306 'CODE' => 'dont_buy',
307 'FIELDS' => array('DAYS_DONT_BUY' => $days),
308 'RUN_FOR_OLD_DATA' => ($days > 300 ? 'Y' : 'N')
309 )
310 ),
311 'END' => array(
312 'ENDPOINT' => array(
313 'MODULE_ID' => 'sale',
314 'CODE' => 'order_paid',
315 'FIELDS' => array()
316 )
317 ),
318 ),
319 'CHAIN' => array(
320 array(
321 'TIME_SHIFT' => 0,
322 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_DONT_BUY_LETTER_1_SUBJECT_' . $days),
323 'MESSAGE' => self::getMailTemplate(array(
324 'TITLE' => Loc::getMessage('PRESET_DONT_BUY_LETTER_1_SUBJECT_' . $days),
325 'TEXT' => Loc::getMessage('PRESET_DONT_BUY_LETTER_1_MESSAGE_' . $days, static::getMessagePlaceHolders()),
326 )),
327 ),
328 array(
329 'TIME_SHIFT' => 1440,
330 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_DONT_BUY_LETTER_2_SUBJECT_' . $days),
331 'MESSAGE' => self::getMailTemplate(array(
332 'TITLE' => Loc::getMessage('PRESET_DONT_BUY_LETTER_2_SUBJECT_' . $days),
333 'TEXT' => Loc::getMessage('PRESET_DONT_BUY_LETTER_2_MESSAGE_' . $days, static::getMessagePlaceHolders()),
334 )),
335 ),
336 array(
337 'TIME_SHIFT' => 1440,
338 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_DONT_BUY_LETTER_3_SUBJECT_' . $days),
339 'MESSAGE' => self::getMailTemplate(array(
340 'TITLE' => Loc::getMessage('PRESET_DONT_BUY_LETTER_3_SUBJECT_' . $days),
341 'TEXT' => Loc::getMessage('PRESET_DONT_BUY_LETTER_3_MESSAGE_' . $days, static::getMessagePlaceHolders()),
342 )),
343 ),
344 )
345 );
346
347 }
348
349 public static function getDontAuth($days)
350 {
351 return array(
352 'TYPE' => Loc::getMessage('PRESET_TYPE_ORDER'),
353 'CODE' => 'sale_user_dontauth',
354 'NAME' => Loc::getMessage('PRESET_DONT_AUTH_NAME'),
355 'DESC_USER' => Loc::getMessage('PRESET_DONT_AUTH_DESC_USER'),
356 'DESC' => Loc::getMessage('PRESET_DONT_AUTH_DESC', array('%DAYS%' => $days)),
357 'TRIGGER' => array(
358 'START' => array(
359 'ENDPOINT' => array(
360 'MODULE_ID' => 'sender',
361 'CODE' => 'user_dontauth',
362 'FIELDS' => array('DAYS_DONT_AUTH' => $days)
363 )
364 ),
365 'END' => array(
366 'ENDPOINT' => array(
367 'MODULE_ID' => 'sender',
368 'CODE' => 'user_auth',
369 'FIELDS' => array()
370 )
371 ),
372 ),
373 'CHAIN' => array(
374 array(
375 'TIME_SHIFT' => 0,
376 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_DONT_AUTH_LETTER_1_SUBJECT'),
377 'MESSAGE' => self::getMailTemplate(array(
378 'TITLE' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_1_SUBJECT'),
379 'TEXT' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_1_MESSAGE', static::getMessagePlaceHolders()),
380 )),
381 ),
382 array(
383 'TIME_SHIFT' => 1440,
384 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_DONT_AUTH_LETTER_2_SUBJECT'),
385 'MESSAGE' => self::getMailTemplate(array(
386 'TITLE' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_2_SUBJECT'),
387 'TEXT' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_2_MESSAGE', static::getMessagePlaceHolders()),
388 )),
389 ),
390 array(
391 'TIME_SHIFT' => 1440,
392 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_DONT_AUTH_LETTER_3_SUBJECT'),
393 'MESSAGE' => self::getMailTemplate(array(
394 'TITLE' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_3_SUBJECT'),
395 'TEXT' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_3_MESSAGE', static::getMessagePlaceHolders()),
396 )),
397 ),
398 array(
399 'TIME_SHIFT' => 1440,
400 'SUBJECT' => '#SITE_NAME#: ' . Loc::getMessage('PRESET_DONT_AUTH_LETTER_4_SUBJECT'),
401 'MESSAGE' => self::getMailTemplate(array(
402 'TITLE' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_4_SUBJECT'),
403 'TEXT' => Loc::getMessage('PRESET_DONT_AUTH_LETTER_4_MESSAGE', static::getMessagePlaceHolders()),
404 )),
405 ),
406 )
407 );
408
409 }
410}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getMailTemplate(array $params=null)