- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/helpers/admin/blocks/orderanalysis.php
- Класс: BitrixSaleHelpersAdminBlocksOrderAnalysis
- Вызов: OrderAnalysis::getView
static function getView(Order $order, OrderBasket $orderBasket, $selectPayment = null, $selectId = null)
{
global $APPLICATION, $USER;
// prepare data
$orderId = $order->getId();
$data = $orderBasket->prepareData();
$items = $data['ITEMS'];
$documents = array();
$documentAllowList = array();
static $userCompanyList = array();
$isUserResponsible = false;
$isAllowCompany = false;
$itemNo = 0;
$saleModulePermissions = $APPLICATION->GetGroupRight("sale");
if($saleModulePermissions == "P")
{
if (empty($userCompanyList))
{
$userCompanyList = Manager::getUserCompanyList($USER->GetID());
}
if ($order->getField('RESPONSIBLE_ID') == $USER->GetID())
{
$isUserResponsible = true;
}
if (in_array($order->getField('COMPANY_ID'), $userCompanyList))
{
$isAllowCompany = true;
}
}
/** @var BitrixSalePayment $payment */
foreach ($order->getPaymentCollection() as $payment)
{
$documents []= $payment;
$documentAllowList['PAYMENT'][$payment->getId()] = true;
if ($saleModulePermissions == "P")
{
$isPaymentUserResponsible = ($isUserResponsible || $payment->getField('RESPONSIBLE_ID') == $USER->GetID());
$isPaymentAllowCompany = ($isAllowCompany || in_array($payment->getField('COMPANY_ID'), $userCompanyList));
$documentAllowList['PAYMENT'][$payment->getId()] = ($isPaymentUserResponsible || $isPaymentAllowCompany);
}
}
/** @var BitrixSaleShipment $shipment */
foreach ($order->getShipmentCollection() as $shipment)
{
if (! $shipment->isSystem())
{
if (! $shipment->isCanceled() && $shipment->isShipped())
{
/** @var BitrixSaleShipmentItem $shipmentItem */
foreach ($shipment->getShipmentItemCollection() as $shipmentItem)
{
$basketCode = $shipmentItem->getBasketCode();
if ($basketCode && isset($items[$basketCode]))
{
$item = &$items[$basketCode];
if ($shippedQuantity = &$item['SHIPPED_QUANTITY'])
$shippedQuantity += (float) $shipmentItem->getField('QUANTITY');
else
$shippedQuantity = (float) $shipmentItem->getField('QUANTITY');
}
}
}
$documents []= $shipment;
$documentAllowList['SHIPMENT'][$shipment->getId()] = true;
if ($saleModulePermissions == "P")
{
$isShipmentUserResponsible = ($isUserResponsible || $shipment->getField('RESPONSIBLE_ID') == $USER->GetID());
$isShipmentAllowCompany = ($isAllowCompany || in_array($shipment->getField('COMPANY_ID'), $userCompanyList));
$documentAllowList['SHIPMENT'][$shipment->getId()] = ($isShipmentUserResponsible || $isShipmentAllowCompany);
}
}
}
unset($item, $shippedQuantity);
usort($documents, array(__CLASS__, 'sortDocumentsByDate'));
// render view
ob_start();
?>
=Loc::getMessage('SALE_OANALYSIS_ITEM_NUMBER')?>
=Loc::getMessage('SALE_OANALYSIS_ITEM_NAME')?>
=Loc::getMessage('SALE_OANALYSIS_ITEM_PROPERTIES')?>
=Loc::getMessage('SALE_OANALYSIS_ITEM_PLANNED')?>
=Loc::getMessage('SALE_OANALYSIS_ITEM_SHIPPED')?>
=Loc::getMessage('SALE_OANALYSIS_ITEM_TO_SHIP')?>
';
if (isset($item['SKU_PROPS']) && is_array($item['SKU_PROPS']))
{
foreach ($item['SKU_PROPS'] as $skuProp)
{
$properties .= '';
$properties .= ''. htmlspecialcharsbx($skuProp['NAME']).' : '.' ';
if (isset($skuProp['VALUE']['PICT']) && $skuProp['VALUE']['PICT'])
$properties .= '
';
else
$properties .= ''.htmlspecialcharsbx($skuProp['VALUE']['NAME']).' ';
$properties .= ' ';
}
}
$properties .= '
';
$quantity = (float)($item['QUANTITY'] ?? 0);
$shippedQuantity = (float)($item['SHIPPED_QUANTITY'] ?? 0);
?>
=++$itemNo?>
=static::renderShipmentItemLink($item)?>
=$properties;?>
=$quantity.' '.htmlspecialcharsEx($item['MEASURE_TEXT'])?>
=$shippedQuantity.' '.htmlspecialcharsEx($item['MEASURE_TEXT'])?>
=($quantity - $shippedQuantity).' '.htmlspecialcharsEx($item['MEASURE_TEXT'])?>
=Loc::getMessage('SALE_OANALYSIS_ITEMS_QUANTITY').': '.count($items)?>
=Loc::getMessage('SALE_OANALYSIS_DOCUMENTS')?>:
=static::renderOrderLink(['order'=>$order])?>
getField('DATE_INSERT'), $order->getField('RESPONSIBLE_ID'))?>
getId()?>
isPaid()):?>
=Loc::getMessage('SALE_OANALYSIS_PAYMENT_PAID')?>
isReturn()):?>
=Loc::getMessage('SALE_OANALYSIS_PAYMENT_RETURN')?>
if ($isAllowCompany):?>
=static::renderPaymentEditLink(['payment'=>$document])?>
= Loc::getMessage('SALE_OANALYSIS_HIDDEN');?>
endif; ?>
isShipped()):?>
=Loc::getMessage('SALE_OANALYSIS_SHIPMENT_SHIPPED')?>
isCanceled()):?>
=Loc::getMessage('SALE_OANALYSIS_SHIPMENT_CANCELED')?>
isAllowDelivery()):?>
=Loc::getMessage('SALE_OANALYSIS_SHIPMENT_ALLOWED')?>
if ($isAllowCompany): ?>
=static::renderShipmentEditLink(['shipment'=>$document])?>
= Loc::getMessage('SALE_OANALYSIS_HIDDEN');?>
endif; ?>
getField($isPayment ? 'DATE_BILL' : 'DATE_INSERT'), $document->getField('RESPONSIBLE_ID'))?>
getId());?>
$result = ob_get_contents();
ob_end_clean();
return $result;
}