CAllCrmInvoice::getPropertiesList

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmInvoice
  4. getPropertiesList
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_invoice.php
  • Класс: \CAllCrmInvoice
  • Вызов: CAllCrmInvoice::getPropertiesList
static function getPropertiesList($idInvoices)
{
	$result = array();
	$propsIdList = array();
	$valueList = array();
	$propertyList = array();

	if(!\Bitrix\Main\Loader::includeModule('sale'))
	{
		return array();
	}

	$idInvoices = !is_array($idInvoices) ? array($idInvoices) : $idInvoices;
	$valueData = \Bitrix\Crm\Invoice\Internals\InvoicePropsValueTable::getList(
		array(
			"filter" => array("ORDER_ID" => $idInvoices)
		)
	);

	while ($value = $valueData->fetch())
	{
		$propsIdList[] = $value['ORDER_PROPS_ID'];
		$valueList[$value['ORDER_ID']][] = $value;
	}

	$propsIdList = array_unique($propsIdList);

	$propsData = \Bitrix\Crm\Invoice\Property::getList(
		array(
			"filter" => array(
				"ID" => $propsIdList,
				"ACTIVE" => "Y"
			)
		)
	);
	while ($property = $propsData->fetch())
	{
		$propertyList[$property['ID']] = $property;
	}

	foreach($idInvoices as $id)
	{
		if (!is_array($valueList[$id]))
		{
			continue;
		}
		foreach ($valueList[$id] as $value)
		{
			$result[$id]['PR_INVOICE_'.$value['ORDER_PROPS_ID']] = array(
				'FIELDS' => $propertyList[$value['ORDER_PROPS_ID']],
				'VALUE' => $value
			);

			if ($value['CODE'] === "LOCATION")
			{
				$arResult['PR_LOCATION'] = array(
					'FIELDS' => $propertyList[$value['ORDER_PROPS_ID']],
					'VALUE' => $value == '0' ? '' : $value
				);
			}

		}
	}

	return $result;
}

Добавить комментарий