1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
triggerdontbuy.php
См. документацию.
1
<?
2
3
namespace
Bitrix\Sale\Sender;
4
5
use Bitrix\Main\Localization\Loc;
6
use Bitrix\Main\Loader;
7
8
if
(!Loader::includeModule(
'sender'
))
9
{
10
return
;
11
}
12
13
Loc::loadMessages(__FILE__);
14
15
class
TriggerDontBuy
extends
\Bitrix\Sender\TriggerConnectorClosed
16
{
17
18
public
function
getName
()
19
{
20
return
Loc::getMessage(
'sender_trigger_dont_buy_name'
);
21
}
22
23
public
function
getCode
()
24
{
25
return
"dont_buy"
;
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
$daysDontBuy = $this->
getFieldValue
(
'DAYS_DONT_BUY'
);
45
if
(!is_numeric($daysDontBuy))
46
$daysDontBuy = 90;
47
48
$dateFrom = new \Bitrix\Main\Type\DateTime;
49
$dateTo = new \Bitrix\Main\Type\DateTime;
50
51
$dateFrom->setTime(0, 0, 0)->add(
'-'
. $daysDontBuy .
' days'
);
52
$dateTo->setTime(0, 0, 0)->add(
'1 days'
)->add(
'-'
. $daysDontBuy .
' days'
);
53
54
if
($this->isRunForOldData())
55
{
56
$filter
=
array
(
57
'<MAX_DATE_INSERT'
=> $dateTo->format(\
Bitrix
\
Main
\
UserFieldTable::MULTIPLE_DATETIME_FORMAT
),
58
);
59
}
60
else
61
{
62
$filter
=
array
(
63
'>MAX_DATE_INSERT'
=> $dateFrom->format(\
Bitrix
\
Main
\
UserFieldTable::MULTIPLE_DATETIME_FORMAT
),
64
'<MAX_DATE_INSERT'
=> $dateTo->format(\
Bitrix
\
Main
\
UserFieldTable::MULTIPLE_DATETIME_FORMAT
),
65
);
66
}
67
$filter
=
$filter
+
array
(
68
'=LID'
=> $this->getSiteId()
69
);
70
71
$userListDb = \Bitrix\Sale\Internals\OrderTable::getList(
array
(
72
'select'
=>
array
(
'BUYER_USER_ID'
=>
'USER.ID'
,
'EMAIL'
=>
'USER.EMAIL'
,
'BUYER_USER_NAME'
=>
'USER.NAME'
),
73
'filter'
=>
$filter
,
74
'runtime'
=>
array
(
75
new
\
Bitrix
\
Main
\
Entity
\
ExpressionField
(
'MAX_DATE_INSERT'
,
'MAX(%s)'
,
'DATE_INSERT'
),
76
),
77
'order'
=>
array
(
'USER_ID'
=>
'ASC'
)
78
));
79
80
if
($userListDb->getSelectedRowsCount() > 0)
81
{
82
$userListDb->addFetchDataModifier(
array
($this,
'getFetchDataModifier'
));
83
$this->recipient = $userListDb;
84
return
true
;
85
}
86
else
87
return
false
;
88
}
89
90
public
function
getForm
()
91
{
92
$daysDontBuyInput =
' <input size=3 type="text" name="'
.$this->getFieldName(
'DAYS_DONT_BUY'
).
'" value="'
.
htmlspecialcharsbx
($this->
getFieldValue
(
'DAYS_DONT_BUY'
, 90)).
'"> '
;
93
94
return
'
95
<table>
96
<tr>
97
<td>'
.Loc::getMessage(
'sender_trigger_dont_buy_days'
).
'</td>
98
<td>'
.$daysDontBuyInput.
'</td>
99
</tr>
100
</table>
101
'
;
102
}
103
104
public
function
getRecipient
()
105
{
106
return
$this->recipient;
107
}
108
109
public
function
getFetchDataModifier
(
$fields
)
110
{
111
if
(isset(
$fields
[
'BUYER_USER_NAME'
]))
112
{
113
$fields
[
'NAME'
] =
$fields
[
'BUYER_USER_NAME'
];
114
unset(
$fields
[
'BUYER_USER_NAME'
]);
115
}
116
if
(isset(
$fields
[
'BUYER_USER_ID'
]))
117
{
118
$fields
[
'USER_ID'
] =
$fields
[
'BUYER_USER_ID'
];
119
unset(
$fields
[
'BUYER_USER_ID'
]);
120
}
121
122
return
$fields
;
123
}
124
}
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Определения
loader.php:67
Bitrix\Main\ORM\Fields\ExpressionField
Определения
expressionfield.php:25
Bitrix\Main\UserFieldTable\MULTIPLE_DATETIME_FORMAT
const MULTIPLE_DATETIME_FORMAT
Определения
userfield.php:36
Bitrix\Sale\Sender\TriggerDontBuy
Определения
triggerdontbuy.php:16
Bitrix\Sale\Sender\TriggerDontBuy\getRecipient
getRecipient()
Определения
triggerdontbuy.php:104
Bitrix\Sale\Sender\TriggerDontBuy\getName
getName()
Определения
triggerdontbuy.php:18
Bitrix\Sale\Sender\TriggerDontBuy\canRunForOldData
static canRunForOldData()
Определения
triggerdontbuy.php:35
Bitrix\Sale\Sender\TriggerDontBuy\getForm
getForm()
Определения
triggerdontbuy.php:90
Bitrix\Sale\Sender\TriggerDontBuy\getFetchDataModifier
getFetchDataModifier($fields)
Определения
triggerdontbuy.php:109
Bitrix\Sale\Sender\TriggerDontBuy\filter
filter()
Определения
triggerdontbuy.php:40
Bitrix\Sale\Sender\TriggerDontBuy\getCode
getCode()
Определения
triggerdontbuy.php:23
Bitrix\Sale\Sender\TriggerDontBuy\canBeTarget
static canBeTarget()
Определения
triggerdontbuy.php:29
Bitrix\Sender\Connector\Base\getFieldValue
getFieldValue($name, $defaultValue=null)
Определения
base.php:195
Bitrix\Sender\Trigger\TriggerConnectorClosed
Определения
triggerconnectorclosed.php:12
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$filter
$filter
Определения
iblock_catalog_list.php:54
htmlspecialcharsbx
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
tools.php:2701
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main
Bitrix
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
sender
triggerdontbuy.php
Создано системой
1.14.0