... Link to shipment edit form */ public static function getShipmentEditLink($shipmentId, $text = '', $orderId = 0, $languageId = LANGUAGE_ID) { if($text == '') $text = strval($shipmentId); if(intval($orderId) <= 0) { $res = Internals\ShipmentTable::getList(array( 'filter' => array( '=ID' => $shipmentId ), 'select' => array('ID', 'ORDER_ID') )); if($row = $res->fetch()) $orderId = $row['ORDER_ID']; } return ''. htmlspecialcharsbx($text). ''; } /** * @param int $deliveryId * @param string $deliveryName * @param string $languageId * @return string ... Link to delivery edit form */ public static function getDeliveryEditLink($deliveryId, $deliveryName = '', $languageId = LANGUAGE_ID) { if($deliveryName == '') { $delivery = Services\Manager::getObjectById($deliveryId); $deliveryName = !!$delivery ? $delivery->getNameWithParent().' ['.intval($deliveryId).']' : intval($deliveryId); } return ''. htmlspecialcharsbx($deliveryName). ''; } /** * @param int $requestId * @param string $text * @param string $languageId * @return string ... Link to request view form */ public static function getRequestViewLink($requestId, $text = '', $languageId = LANGUAGE_ID) { if($text == '') $text = strval($requestId); return ''. htmlspecialcharsbx($text). ''; } /** * @param int[] $shipmentIds * @return Shipment[] * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ArgumentNullException */ public static function getShipmentsByIds(array $shipmentIds) { if(empty($shipmentIds)) return array(); $registry = Sale\Registry::getInstance(Sale\Registry::REGISTRY_TYPE_ORDER); /** @var Sale\Order $orderClass */ $orderClass = $registry->getOrderClassName(); $result = array(); $res = Internals\ShipmentTable::getList(array( 'filter' => array( '=ID' => $shipmentIds ), 'select' => array('ID', 'ORDER_ID') )); while($shp = $res->fetch()) { $order = $orderClass::load($shp['ORDER_ID']); foreach($order->getShipmentCollection() as $shipment) { if($shp['ID'] != $shipment->getId()) continue; if(!in_array($shp['ID'], $shipmentIds)) continue; $result[$shp['ID']] = $shipment; break; } } return $result; } /** * @param int $requestId * @return Shipment[] */ public static function getShipmentsByRequestId(int $requestId): ?array { $deliveryRequest = RequestTable::getByPrimary( $requestId, [ 'select' => ['*', 'SHIPMENTS'] ] )->fetchObject(); if (is_null($deliveryRequest)) { return null; } $result = []; foreach ($deliveryRequest->getShipments() as $requestShipment) { $shipment = ShipmentRepository::getInstance()->getById( $requestShipment->getShipmentId() ); $result[] = $shipment; } return $result; } }