Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
triggerorderstatuschange.php
1<?
2
3namespace Bitrix\Sale\Sender;
4
7
8if (!Loader::includeModule('sender'))
9{
10 return;
11}
12
13Loc::loadMessages(__FILE__);
14
16{
17 public function getName()
18 {
19 return Loc::getMessage('sender_trigger_order_status_change_name');
20 }
21
22 public function getCode()
23 {
24 return "order_status_change";
25 }
26
27 public function getEventModuleId()
28 {
29 return 'sale';
30 }
31
32 public function getEventType()
33 {
34 return "OnSaleStatusOrderChange";
35 }
36
38 public static function canBeTarget()
39 {
40 return true;
41 }
42
43 public function filter()
44 {
45 $eventData = $this->getParam('EVENT');
46 $statusId = $this->getFieldValue('STATUS_ID', null);
47
48 if(!($eventData['ENTITY'] instanceof \Bitrix\Sale\Order))
49 {
50 return false;
51 }
52
53 if($statusId != $eventData['ENTITY']->getField('STATUS_ID'))
54 {
55 return false;
56 }
57
58 return $this->filterConnectorData();
59 }
60
61 public function getConnector()
62 {
63 $connector = new \Bitrix\Sale\Sender\ConnectorOrder;
64 $connector->setModuleId('sale');
65
66 return $connector;
67 }
68
71 {
72 $eventData = $this->getParam('EVENT');
73 return array('ID' => $eventData['ENTITY']->getId(), 'LID' => $this->getSiteId());
74 }
75
76
80 public function getPersonalizeFields()
81 {
82 $result = array(
83 'ORDER_ID' => ''
84 );
85
86 $eventData = $this->getParam('EVENT');
87 if($eventData['ENTITY'] instanceof \Bitrix\Sale\Order)
88 {
89 $result['ORDER_ID'] = $eventData['ENTITY']->getField('ACCOUNT_NUMBER');
90 $result['ORDER_REAL_ID'] = $eventData['ENTITY']->getId();
91 }
92
93 return $result;
94 }
95
99 public static function getPersonalizeList()
100 {
101 return array(
102 array(
103 'CODE' => 'ORDER_ID',
104 'NAME' => Loc::getMessage('sender_trigger_order_status_change_name_order_id_name'),
105 'DESC' => Loc::getMessage('sender_trigger_order_status_change_name_order_id_desc')
106 ),
107 );
108 }
109
110 public function getForm()
111 {
112 $statusInput = '';
113 $statusDb = \Bitrix\Sale\Internals\StatusLangTable::getList(array(
114 'select' => array('STATUS_ID', 'NAME'),
115 'filter' => array('=LID' => LANGUAGE_ID, '=STATUS_ID' => \Bitrix\Sale\OrderStatus::getAllStatuses()),
116 'order' => array('STATUS.SORT')
117 ));
118 while($status = $statusDb->fetch())
119 {
120 $selected = $status['STATUS_ID'] == $this->getFieldValue('STATUS_ID') ? ' selected' : '';
121 $statusInput .= '<option value="' . $status['STATUS_ID'] . '"' . $selected . '>'
122 . htmlspecialcharsbx($status['NAME'])
123 . '</option>';
124 }
125 $statusInput = '<select name="' . $this->getFieldName('STATUS_ID') . '">' . $statusInput . '</select>';
126
127 return '
128 <table>
129 <tr>
130 <td>'.Loc::getMessage('sender_trigger_order_status_change_field').': </td>
131 <td>'.$statusInput.'</td>
132 </tr>
133 </table>
134 ';
135 }
136}
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