26 private static function sortDocumentsByDate($doc1, $doc2)
28 $date1 = $doc1->getField($doc1 instanceof
Payment ?
'DATE_PAID' :
'DATE_INSERT');
29 $date2 = $doc2->getField($doc2 instanceof
Payment ?
'DATE_PAID' :
'DATE_INSERT');
30 return $date1 > $date2 ? 1 : -1;
33 public static function getView(
Order $order,
OrderBasket $orderBasket, $selectPayment =
null, $selectId =
null)
35 global $APPLICATION, $USER;
38 $orderId = $order->getId();
39 $data = $orderBasket->prepareData();
40 $items = $data[
'ITEMS'];
42 $documentAllowList = array();
43 static $userCompanyList = array();
44 $isUserResponsible =
false;
45 $isAllowCompany =
false;
50 $saleModulePermissions = $APPLICATION->GetGroupRight(
"sale");
52 if($saleModulePermissions ==
"P")
54 if (empty($userCompanyList))
56 $userCompanyList = Manager::getUserCompanyList($USER->GetID());
59 if ($order->getField(
'RESPONSIBLE_ID') == $USER->GetID())
61 $isUserResponsible =
true;
64 if (in_array($order->getField(
'COMPANY_ID'), $userCompanyList))
66 $isAllowCompany =
true;
71 foreach ($order->getPaymentCollection() as $payment)
73 $documents []= $payment;
75 $documentAllowList[
'PAYMENT'][$payment->getId()] =
true;
77 if ($saleModulePermissions ==
"P")
79 $isPaymentUserResponsible = ($isUserResponsible || $payment->getField(
'RESPONSIBLE_ID') == $USER->GetID());
80 $isPaymentAllowCompany = ($isAllowCompany || in_array($payment->getField(
'COMPANY_ID'), $userCompanyList));
81 $documentAllowList[
'PAYMENT'][$payment->getId()] = ($isPaymentUserResponsible || $isPaymentAllowCompany);
87 foreach ($order->getShipmentCollection() as $shipment)
89 if (! $shipment->isSystem())
91 if (! $shipment->isCanceled() && $shipment->isShipped())
94 foreach ($shipment->getShipmentItemCollection() as $shipmentItem)
96 $basketCode = $shipmentItem->getBasketCode();
98 if ($basketCode && isset($items[$basketCode]))
100 $item = &$items[$basketCode];
101 if ($shippedQuantity = &$item[
'SHIPPED_QUANTITY'])
102 $shippedQuantity += (float) $shipmentItem->getField(
'QUANTITY');
104 $shippedQuantity = (float) $shipmentItem->getField(
'QUANTITY');
109 $documents []= $shipment;
111 $documentAllowList[
'SHIPMENT'][$shipment->getId()] =
true;
113 if ($saleModulePermissions ==
"P")
115 $isShipmentUserResponsible = ($isUserResponsible || $shipment->getField(
'RESPONSIBLE_ID') == $USER->GetID());
116 $isShipmentAllowCompany = ($isAllowCompany || in_array($shipment->getField(
'COMPANY_ID'), $userCompanyList));
117 $documentAllowList[
'SHIPMENT'][$shipment->getId()] = ($isShipmentUserResponsible || $isShipmentAllowCompany);
122 unset($item, $shippedQuantity);
124 usort($documents, array(__CLASS__,
'sortDocumentsByDate'));
131 <div
class=
"adm-s-order-table-ddi">
132 <table
class=
"adm-s-order-table-ddi-table adm-s-bus-ordertable-option" style=
"width: 100%;">
135 <td
class=
"tac"><?=
Loc::getMessage(
'SALE_OANALYSIS_ITEM_NUMBER')?></td>
137 <td
class=
"tac"><?=
Loc::getMessage(
'SALE_OANALYSIS_ITEM_PROPERTIES')?></td>
138 <td
class=
"tac"><?=
Loc::getMessage(
'SALE_OANALYSIS_ITEM_PLANNED')?></td>
139 <td
class=
"tac"><?=
Loc::getMessage(
'SALE_OANALYSIS_ITEM_SHIPPED')?></td>
140 <td
class=
"tac"><?=
Loc::getMessage(
'SALE_OANALYSIS_ITEM_TO_SHIP')?></td>
144 <?
foreach ($items as $item):
145 $properties =
'<table style="margin: auto; width: 50%;">';
146 if (isset($item[
'SKU_PROPS']) && is_array($item[
'SKU_PROPS']))
148 foreach ($item[
'SKU_PROPS'] as $skuProp)
150 $properties .=
'<tr>';
151 $properties .=
'<td style="text-align: left; padding-left: 0;">'. htmlspecialcharsbx($skuProp[
'NAME']).
' : '.
'</td>';
153 if (isset($skuProp[
'VALUE'][
'PICT']) && $skuProp[
'VALUE'][
'PICT'])
154 $properties .=
'<td><span class="color"><img src="'.$skuProp[
'VALUE'][
'PICT'].
'" alt=""></span></td>';
156 $properties .=
'<td><span>'.htmlspecialcharsbx($skuProp[
'VALUE'][
'NAME']).
'</span></td>';
158 $properties .=
'</tr>';
161 $properties .=
'</table>';
163 $quantity = (float)($item[
'QUANTITY'] ?? 0);
165 $shippedQuantity = (float)($item[
'SHIPPED_QUANTITY'] ?? 0);
168 <tr
class=
"bdb-line">
169 <td
class=
"tac"><?=++$itemNo?></td>
170 <td style=
"text-align: left;"><?=static::renderShipmentItemLink($item)?></td>
171 <td
class=
"tac"><?=$properties;?></td>
172 <td
class=
"tac" style=
"text-align: right !important;"><?=$quantity.
' '.htmlspecialcharsEx($item[
'MEASURE_TEXT'])?></td>
173 <td
class=
"tac" style=
"text-align: right !important;;"><?=$shippedQuantity.
' '.htmlspecialcharsEx($item[
'MEASURE_TEXT'])?></td>
174 <td
class=
"tac" style=
"text-align: right !important;;"><?=($quantity - $shippedQuantity).
' '.htmlspecialcharsEx($item[
'MEASURE_TEXT'])?></td>
177 <tr><td colspan=
"8" style=
"padding: 16px; background: #f7fafa; text-align: right;" class=
"fwb"><?=
Loc::getMessage(
'SALE_OANALYSIS_ITEMS_QUANTITY').
': '.count($items)?></td></tr>
180 <div
class=
"adm-bus-table-contaier-white caption border" style=
"margin-top: 25px;">
181 <div
class=
"adm-bus-table-caption-white-title"><?=
Loc::getMessage(
'SALE_OANALYSIS_DOCUMENTS')?>:</div>
182 <div
class=
"adm-bus-orderdocs-threelist-container">
183 <div
class=
"adm-bus-orderdocs-threelist-block-top<?=$selectPayment === null ? ' adm-bus-orderdocs-threelist-block-children-open' : ''?>">
184 <div
class=
"adm-bus-orderdocs-threelist-block-img adm-bus-orderdocs-threelist-block-img-order"></div>
185 <div
class=
"adm-bus-orderdocs-threelist-block-content">
186 <div
class=
"adm-bus-orderdocs-threelist-block-title">
187 <?=static::renderOrderLink([
'order'=>$order])?>
189 <?self::renderBottomBlocks($order->getField(
'DATE_INSERT'), $order->getField(
'RESPONSIBLE_ID'))?>
191 <div
class=
"clb"></div>
193 <?
foreach ($documents as $document): $isPayment = $document instanceof Payment; $documentId = $document->getId()?>
194 <div
class=
"adm-bus-orderdocs-threelist-block-children<?=$selectPayment === $isPayment && $selectId == $documentId ? ' adm-bus-orderdocs-threelist-block-children-open' : ''?>">
195 <div
class=
"adm-bus-orderdocs-threelist-block-img adm-bus-orderdocs-threelist-block-img-doc_<?=$isPayment ? 'payment' : 'shipping'?>"></div>
196 <div
class=
"adm-bus-orderdocs-threelist-block-content">
197 <div
class=
"adm-bus-orderdocs-threelist-block-title">
199 $isAllowCompany = $documentAllowList[
'PAYMENT'][$documentId];
201 <?
if ($document->isPaid()):?>
202 <span
class=
"adm-bus-orderdocs-docstatus adm-bus-orderdocs-docstatus-paid"><?=
Loc::getMessage(
'SALE_OANALYSIS_PAYMENT_PAID')?></span>
203 <?elseif ($document->isReturn()):?>
204 <span class=
"adm-bus-orderdocs-docstatus"><?=Loc::getMessage(
'SALE_OANALYSIS_PAYMENT_RETURN')?></span>
206 <?
if ($isAllowCompany):?>
207 <?=static::renderPaymentEditLink([
'payment'=>$document])?>
209 <?= Loc::getMessage(
'SALE_OANALYSIS_HIDDEN');?>
212 $isAllowCompany = $documentAllowList[
'SHIPMENT'][$documentId];
214 <?
if ($document->isShipped()):?>
215 <span
class=
"adm-bus-orderdocs-docstatus adm-bus-orderdocs-docstatus-shippingallowed"><?=
Loc::getMessage(
'SALE_OANALYSIS_SHIPMENT_SHIPPED')?></span>
216 <?elseif ($document->isCanceled()):?>
217 <span class=
"adm-bus-orderdocs-docstatus adm-bus-orderdocs-docstatus-canceled"><?=Loc::getMessage(
'SALE_OANALYSIS_SHIPMENT_CANCELED')?></span>
218 <?elseif ($document->isAllowDelivery()):?>
219 <span class=
"adm-bus-orderdocs-docstatus adm-bus-orderdocs-docstatus-shippingallowed"><?=Loc::getMessage(
'SALE_OANALYSIS_SHIPMENT_ALLOWED')?></span>
221 <?
if ($isAllowCompany): ?>
222 <?=static::renderShipmentEditLink([
'shipment'=>$document])?>
224 <?= Loc::getMessage(
'SALE_OANALYSIS_HIDDEN');?>
228 <?self::renderBottomBlocks($document->getField($isPayment ?
'DATE_BILL' :
'DATE_INSERT'), $document->getField(
'RESPONSIBLE_ID'))?>
230 <div class=
"clb"></div>
233 <?self::printDeliveryRequestBlock($document->getId());?>
241 $result = ob_get_contents();
246 private static function printDeliveryRequestBlock($shipmentId)
248 $res = ShipmentTable::getList(
250 'filter' => array(
'=SHIPMENT_ID' => $shipmentId),
253 'REQUEST_DATE' =>
'REQUEST.DATE',
258 $shipment = $res->fetch();
260 if ($shipment && intval($shipment[
'REQUEST_ID']) > 0)
263 <div
class=
"adm-bus-orderdocs-threelist-block-children" style=
"padding-left: 60px;">
264 <div
class=
"adm-bus-orderdocs-threelist-block-img adm-bus-orderdocs-threelist-block-img-doc_shipping"></div>
265 <div
class=
"adm-bus-orderdocs-threelist-block-content">
266 <div
class=
"adm-bus-orderdocs-threelist-block-title">
267 <?=static::renderDeliveryRequestView([
'ID'=>$shipment[
'REQUEST_ID']])?>
269 <div
class=
"adm-bus-orderdocs-threelist-block-date-block">
270 <?=
Loc::getMessage(
'SALE_OANALYSIS_CREATED_AT')?>: <span
class=
"adm-bus-orderdocs-threelist-block-date"><?=$shipment[
'REQUEST_DATE']?></span>
273 <div
class=
"clb"></div>
279 private static function renderBottomBlocks($creationDate, $userId)
283 if ($userId && ($user = \CUser::GetByID($userId)->Fetch()))
286 $userName = $user[
'NAME'];
287 if ($user[
'LAST_NAME'])
288 $userName .= ($userName ?
' ' :
'').$user[
'LAST_NAME'];
290 $userName = $user[
'LOGIN'];
294 <div
class=
"adm-bus-orderdocs-threelist-block-date-block">
295 <?=
Loc::getMessage(
'SALE_OANALYSIS_CREATED_AT')?>: <span
class=
"adm-bus-orderdocs-threelist-block-date"><?=$creationDate?></span>
298 <div
class=
"adm-bus-orderdocs-threelist-block-responsible-block">
300 <?=static::renderResponsibleLink([
'RESPONSIBLE_ID'=>$userId,
'RESPONSIBLE'=>$userName])?>
307 if (!isset($item[
'EDIT_PAGE_URL']))
309 return htmlspecialcharsEx($item[
'NAME']);
312 '<a class="fwb" href="' . htmlspecialcharsbx($item[
'EDIT_PAGE_URL']) .
'">'
313 . htmlspecialcharsEx($item[
'NAME'])
317 protected static function renderOrderLink($data)
320 $order = $data[
'order'];
322 $url = Link::getInstance()
324 ->setPageByType(Registry::SALE_ORDER_EDIT)
325 ->setFilterParams(
false)
326 ->setField(
'ID', $order->getId())
330 return '<a class="adm-bus-orderdocs-threelist-block-title-link fwb" href="'.$url.
'">'.
332 '#USER_ID#' => $order->getField(
'USER_ID'),
333 '#ORDER_ID#' => $order->getId())
336 protected static function renderPaymentEditLink($data)
339 $payment = $data[
'payment'];
341 $url = Link::getInstance()
343 ->setPageByType(Registry::SALE_ORDER_PAYMENT_EDIT)
344 ->setFilterParams(
false)
346 ->setField(
'order_id', $payment->getOrderId())
347 ->setField(
'payment_id', $payment->getId())
351 return '<a href="'.$url.
'" class="adm-bus-orderdocs-threelist-block-title-link">'.
Loc::getMessage(
'SALE_OANALYSIS_PAYMENT_TITLE', array(
352 '#SYSTEM_NAME#' => htmlspecialcharsbx($payment->getField(
'PAY_SYSTEM_NAME')),
353 '#PAYMENT_ID#' => $payment->getId(),
354 '#SUM#' => SaleFormatCurrency($payment->getField(
'SUM'), $payment->getField(
'CURRENCY')),
357 protected static function renderShipmentEditLink($data)
360 $shipment = $data[
'shipment'];
362 $url = Link::getInstance()
364 ->setPageByType(Registry::SALE_ORDER_SHIPMENT_EDIT)
365 ->setFilterParams(
false)
367 ->setField(
'order_id', $shipment->getOrder()->getId())
368 ->setField(
'shipment_id', $shipment->getId())
372 return '<a href="'.$url.
'" class="adm-bus-orderdocs-threelist-block-title-link'.($shipment->isCanceled() ?
"adm-bus-orderdocs-threelist-block-title-link-canceled" :
"").
'">'.
374 '#SHIPMENT_ID#' => $shipment->getId(),
375 '#ORDER_ID#' => $shipment->getOrder()->getId()
380 return '<a class="adm-bus-orderdocs-threelist-block-responsible-name" href="/bitrix/admin/user_edit.php?ID='.$data[
'RESPONSIBLE_ID'].
'">'.htmlspecialcharsbx($data[
'RESPONSIBLE']).
'</a>';
386 $url = Link::getInstance()
388 ->setPageByType(Registry::SALE_DELIVERY_REQUEST_VIEW)
389 ->setFilterParams(
false)
390 ->setField(
'ID', $id)
394 return '<a href="'.$url.
'" class="adm-bus-orderdocs-threelist-block-title-link">'.
396 '#REQUEST_ID#' => $id
if(!function_exists(__NAMESPACE__.'\\___1034172934'))