Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
shipment.php
1<?php
2
3
5
6
12
13Loc::loadMessages(__FILE__);
14
15class Shipment extends Base
16{
17 static public function statusNotify(Event $event)
18 {
20 $shipment = $event->getParameters()['ENTITY'];
21
23 $collection = $shipment->getCollection();
24 $order = $collection->getOrder();
25
26 if(static::isSync($order) == true)
27 {
28 $idOld = $shipment->getFields()->getOriginalValues()['STATUS_ID'] ?? '';
29 $nameOld = DeliveryStatus::getAllStatusesNames()[$idOld] ?? $idOld;
30 $id = $shipment->getField('STATUS_ID');
31 $name = DeliveryStatus::getAllStatusesNames()[$id] ?? $id;
32
33 $settings = [
34 'ENTITY_TYPE_ID' => Integration\CRM\EntityType::ORDER_SHIPMENT,
35 'FIELD_NAME' => 'STATUS_ID',
36 'CURRENT_VALUE' => $name,
37 'PREVIOUS_VALUE' => $nameOld,
38 'LEGEND' => Loc::getMessage('SALE_INTEGRATION_B24_TIMELINE_SHIPMENT_NUMBER').$shipment->getId().'. '.$shipment->getDeliveryName(),
39 ];
40
41 static::onReceive($order->getId(), $settings);
42 }
43 }
44 static public function allowDeliveryNotify(Event $event)
45 {
47 $shipment = $event->getParameters()['ENTITY'];
48
49 if($shipment->isAllowDelivery())
50 {
52 $collection = $shipment->getCollection();
53 $order = $collection->getOrder();
54
55 if(static::isSync($order) == true)
56 {
57 $settings = [
58 'ENTITY_TYPE_ID' => Integration\CRM\EntityType::ORDER_SHIPMENT,
59 'FIELD_NAME' => 'ALLOW_DELIVERY',
60 'CURRENT_VALUE' => 'Y',
61 'LEGEND' => Loc::getMessage('SALE_INTEGRATION_B24_TIMELINE_SHIPMENT_NUMBER').$shipment->getId().'. '.$shipment->getDeliveryName(),
62 ];
63
64 static::onReceive($order->getId(), $settings);
65 }
66 }
67 }
68 static public function deductedNotify(Event $event)
69 {
71 $shipment = $event->getParameters()['ENTITY'];
72
73 if($shipment->isShipped())
74 {
76 $collection = $shipment->getCollection();
77 $order = $collection->getOrder();
78
79 if(static::
80 isSync($order) == true)
81 {
82 $settings = [
83 'ENTITY_TYPE_ID' => Integration\CRM\EntityType::ORDER_SHIPMENT,
84 'FIELD_NAME' => 'DEDUCTED',
85 'CURRENT_VALUE' => 'Y',
86 'LEGEND' => Loc::getMessage('SALE_INTEGRATION_B24_TIMELINE_SHIPMENT_NUMBER').$shipment->getId().'. '.$shipment->getDeliveryName(),
87 ];
88
89 static::onReceive($order->getId(), $settings);
90 }
91 }
92 }
93}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getAllStatusesNames($lang=null)