• Модуль: 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();

	?>
	
'; if (isset($item['SKU_PROPS']) && is_array($item['SKU_PROPS'])) { foreach ($item['SKU_PROPS'] as $skuProp) { $properties .= ''; $properties .= ''; if (isset($skuProp['VALUE']['PICT']) && $skuProp['VALUE']['PICT']) $properties .= ''; else $properties .= ''; $properties .= ''; } } $properties .= '
'. htmlspecialcharsbx($skuProp['NAME']).' : '.''.htmlspecialcharsbx($skuProp['VALUE']['NAME']).'
'; $quantity = (float)($item['QUANTITY'] ?? 0); $shippedQuantity = (float)($item['SHIPPED_QUANTITY'] ?? 0); ?>
:
$order])?>
getField('DATE_INSERT'), $order->getField('RESPONSIBLE_ID'))?>
getId()?>
isPaid()):?> isReturn()):?> $document])?> isShipped()):?> isCanceled()):?> isAllowDelivery()):?> $document])?>
getField($isPayment ? 'DATE_BILL' : 'DATE_INSERT'), $document->getField('RESPONSIBLE_ID'))?>
getId());?>