Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
triggerbasketforgotten.php
1<?
2
3namespace Bitrix\Sale\Sender;
4
7
8if (!Loader::includeModule('sender'))
9{
10 return;
11}
12
13Loc::loadMessages(__FILE__);
14
16{
17
18 public function getName()
19 {
20 return Loc::getMessage('sender_trigger_basket_forgotten_name');
21 }
22
23 public function getCode()
24 {
25 return "basket_forgotten";
26 }
27
29 public static function canBeTarget()
30 {
31 return false;
32 }
33
35 public static function canRunForOldData()
36 {
37 return true;
38 }
39
40 public function filter()
41 {
42 \Bitrix\Main\Loader::includeModule('sale');
43
44 $daysBasketForgotten = $this->getFieldValue('DAYS_BASKET_FORGOTTEN');
45 if(!is_numeric($daysBasketForgotten))
46 $daysBasketForgotten = 90;
47
48 $dateFrom = new \Bitrix\Main\Type\DateTime;
49 $dateTo = new \Bitrix\Main\Type\DateTime;
50
51 $dateFrom->setTime(0, 0, 0)->add('-' . $daysBasketForgotten . ' days');
52 $dateTo->setTime(0, 0, 0)->add('1 days')->add('-' . $daysBasketForgotten . ' days');
53
54 if($this->isRunForOldData())
55 {
56 $filter = array(
57 '<MIN_DATE_INSERT' => $dateTo->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT),
58 );
59 }
60 else
61 {
62 $filter = array(
63 '>MIN_DATE_INSERT' => $dateFrom->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT),
64 '<MIN_DATE_INSERT' => $dateTo->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT),
65 );
66 }
67 $filter = $filter + array(
68 '!FUSER.USER_ID' => null,
69 '=ORDER_ID' => null,
70 '=LID' => $this->getSiteId(),
71 );
72
73 $userListDb = \Bitrix\Sale\Internals\BasketTable::getList(array(
74 'select' => array('USER_ID' => 'FUSER.USER_ID', 'EMAIL' => 'FUSER.USER.EMAIL', 'FUSER_USER_NAME' => 'FUSER.USER.NAME'),
75 'filter' => $filter,
76 'runtime' => array(
77 new \Bitrix\Main\Entity\ExpressionField('MIN_DATE_INSERT', 'MIN(%s)', 'DATE_INSERT'),
78 ),
79 'order' => array('USER_ID' => 'ASC')
80 ));
81
82 if($userListDb->getSelectedRowsCount() > 0)
83 {
84 $userListDb->addFetchDataModifier(array($this, 'getFetchDataModifier'));
85 $this->recipient = $userListDb;
86 return true;
87 }
88 else
89 return false;
90 }
91
92 public function getForm()
93 {
94 $daysBasketForgottenInput = ' <input size=3 type="text" name="'.$this->getFieldName('DAYS_BASKET_FORGOTTEN').'" value="'.htmlspecialcharsbx($this->getFieldValue('DAYS_BASKET_FORGOTTEN', 1)).'"> ';
95
96 return '
97 <table>
98 <tr>
99 <td>'.Loc::getMessage('sender_trigger_basket_forgotten_days').'</td>
100 <td>'.$daysBasketForgottenInput.'</td>
101 </tr>
102 </table>
103 ';
104 }
105
106 public function getRecipient()
107 {
108 return $this->recipient;
109 }
110
111 public function getFetchDataModifier($fields)
112 {
113 if(isset($fields['FUSER_USER_NAME']))
114 {
115 $fields['NAME'] = $fields['FUSER_USER_NAME'];
116 unset($fields['FUSER_USER_NAME']);
117 }
118
119 return $fields;
120 }
121}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
getFieldValue($name, $defaultValue=null)
Definition base.php:195