1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
deliveryrequest.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\Controller;
4
5use Bitrix\Main\Error;
6use Bitrix\Sale\Delivery\Requests;
7use Bitrix\Sale\Repository\ShipmentRepository;
8
14{
21 public function createAction(array $shipmentIds, array $additional = [], int $deliveryId = null)
22 {
23 if (!$this->checkPermission('U'))
24 {
25 return null;
26 }
27
28 if (is_null($deliveryId))
29 {
30 if ($shipmentIds && $shipmentIds[0])
31 {
32 $shipment = ShipmentRepository::getInstance()->getById((int)$shipmentIds[0]);
33 if ($shipment && $shipment->getDelivery())
34 {
35 $deliveryId = $shipment->getDelivery()->getId();
36 }
37 }
38 }
39
41 $result = Requests\Manager::createDeliveryRequest($deliveryId, $shipmentIds, $additional);
42
43 if (!$result->isSuccess())
44 {
45 $this->addErrors($result->getErrors());
46 return null;
47 }
48
49 return [
50 'result' => true,
51 'message' => $this->getMessageFromResult($result)
52 ];
53 }
54
61 public function executeAction(int $requestId, string $actionType, array $additional = [])
62 {
63 if (!$this->checkPermission('U'))
64 {
65 return null;
66 }
67
69 $result = Requests\Manager::executeDeliveryRequestAction($requestId, $actionType, $additional);
70
71 if (!$result->isSuccess())
72 {
73 $this->addErrors($result->getErrors());
74 return null;
75 }
76
77 return [
78 'result' => true,
79 'message' => $this->getMessageFromResult($result)
80 ];
81 }
82
87 public function deleteAction(int $requestId)
88 {
89 if (!$this->checkPermission('U'))
90 {
91 return null;
92 }
93
96
97 if (!$result->isSuccess())
98 {
99 $this->addErrors($result->getErrors());
100 return null;
101 }
102
103 return [
104 'result' => true,
105 'message' => $this->getMessageFromResult($result)
106 ];
107 }
108
113 private function getMessageFromResult(Requests\Result $result): string
114 {
115 return implode(
116 '; ',
117 array_map(
118 function ($message)
119 {
120 return $message->getMessage();
121 },
122 $result->getMessages()
123 )
124 );
125 }
126
131 private function checkPermission(string $permissionType): bool
132 {
133 $result = $GLOBALS['APPLICATION']->GetGroupRight('sale') >= $permissionType;
134
135 if (!$result)
136 {
137 $this->addError(new Error('Access denied'));
138 }
139
140 return $result;
141 }
142}
addError(Error $error)
Определения controller.php:1070
addErrors(array $errors)
Определения controller.php:1083
Определения error.php:15
static executeDeliveryRequestAction($requestId, $actionType, array $additional=array())
Определения manager.php:724
static deleteDeliveryRequest($requestId)
Определения manager.php:429
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$GLOBALS['____1690880296']
Определения license.php:1
$message
Определения payment.php:8