Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
helper.php
1<?
3
9
10
16class Helper
17{
25 public static function getShipmentEditLink($shipmentId, $text = '', $orderId = 0, $languageId = LANGUAGE_ID)
26 {
27 if($text == '')
28 $text = strval($shipmentId);
29
30 if(intval($orderId) <= 0)
31 {
32 $res = Internals\ShipmentTable::getList(array(
33 'filter' => array(
34 '=ID' => $shipmentId
35 ),
36 'select' => array('ID', 'ORDER_ID')
37 ));
38
39 if($row = $res->fetch())
40 $orderId = $row['ORDER_ID'];
41 }
42
43 return '<a href="/bitrix/admin/sale_order_shipment_edit.php'.
44 '?order_id='.intval($orderId).
45 '&shipment_id='.intval($shipmentId).
46 '&lang='.htmlspecialcharsbx($languageId).
47 '">'.
48 htmlspecialcharsbx($text).
49 '</a>';
50 }
51
58 public static function getDeliveryEditLink($deliveryId, $deliveryName = '', $languageId = LANGUAGE_ID)
59 {
60 if($deliveryName == '')
61 {
62 $delivery = Services\Manager::getObjectById($deliveryId);
63 $deliveryName = !!$delivery ? $delivery->getNameWithParent().' ['.intval($deliveryId).']' : intval($deliveryId);
64 }
65
66 return '<a href="/bitrix/admin/sale_delivery_service_edit.php'.
67 '?ID='.intval($deliveryId).
68 '&lang='.htmlspecialcharsbx($languageId).
69 '">'.
70 htmlspecialcharsbx($deliveryName).
71 '</a>';
72 }
73
80 public static function getRequestViewLink($requestId, $text = '', $languageId = LANGUAGE_ID)
81 {
82 if($text == '')
83 $text = strval($requestId);
84
85 return '<a href="/bitrix/admin/sale_delivery_request_view.php'.
86 '?ID='.intval($requestId).
87 '&lang='.htmlspecialcharsbx($languageId).
88 '">'.
89 htmlspecialcharsbx($text).
90 '</a>';
91 }
92
99 public static function getShipmentsByIds(array $shipmentIds)
100 {
101 if(empty($shipmentIds))
102 return array();
103
104 $registry = Sale\Registry::getInstance(Sale\Registry::REGISTRY_TYPE_ORDER);
106 $orderClass = $registry->getOrderClassName();
107
108 $result = array();
109
110 $res = Internals\ShipmentTable::getList(array(
111 'filter' => array(
112 '=ID' => $shipmentIds
113 ),
114 'select' => array('ID', 'ORDER_ID')
115 ));
116
117 while($shp = $res->fetch())
118 {
119 $order = $orderClass::load($shp['ORDER_ID']);
120
121 foreach($order->getShipmentCollection() as $shipment)
122 {
123 if($shp['ID'] != $shipment->getId())
124 continue;
125
126 if(!in_array($shp['ID'], $shipmentIds))
127 continue;
128
129 $result[$shp['ID']] = $shipment;
130 break;
131 }
132 }
133
134 return $result;
135 }
136
141 public static function getShipmentsByRequestId(int $requestId): ?array
142 {
143 $deliveryRequest = RequestTable::getByPrimary(
144 $requestId,
145 [
146 'select' => ['*', 'SHIPMENTS']
147 ]
148 )->fetchObject();
149
150 if (is_null($deliveryRequest))
151 {
152 return null;
153 }
154
155 $result = [];
156
157 foreach ($deliveryRequest->getShipments() as $requestShipment)
158 {
159 $shipment = ShipmentRepository::getInstance()->getById(
160 $requestShipment->getShipmentId()
161 );
162
163 $result[] = $shipment;
164 }
165
166 return $result;
167 }
168}
static getDeliveryEditLink($deliveryId, $deliveryName='', $languageId=LANGUAGE_ID)
Definition helper.php:58
static getShipmentsByRequestId(int $requestId)
Definition helper.php:141
static getShipmentEditLink($shipmentId, $text='', $orderId=0, $languageId=LANGUAGE_ID)
Definition helper.php:25
static getRequestViewLink($requestId, $text='', $languageId=LANGUAGE_ID)
Definition helper.php:80