CrmSmartInvoices::getData

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CrmSmartInvoices
  4. getData
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/main/uiselector/crmsmartinvoices.php
  • Класс: Bitrix\Crm\Integration\Main\UISelector\CrmSmartInvoices
  • Вызов: CrmSmartInvoices::getData
public function getData($params = [])
{
	$entityType = Handler::ENTITY_TYPE_CRMSMART_INVOICES;

	$result = [
		'ITEMS' => [],
		'ITEMS_LAST' => [],
		'ITEMS_HIDDEN' => [],
		'ADDITIONAL_INFO' => [
			'GROUPS_LIST' => [
				'crmsmart_invoices' => [
					'TITLE' => Loc::getMessage('MAIN_UI_SELECTOR_TITLE_CRMSMART_INVOICE'),
					'TYPE_LIST' => [ $entityType ],
					'DESC_LESS_MODE' => 'N',
					'SORT' => 40
				]
			],
			'SORT_SELECTED' => 400
		]
	];

	if (!InvoiceSettings::getCurrent()->isSmartInvoiceEnabled())
	{
		return $result;
	}

	$entityOptions = $params['options'] ?? [];
	$prefix = static::getPrefix($entityOptions);

	$lastItems = $params['lastItems'] ?? [];

	$lastEntitiesIdList = [];
	if(!empty($lastItems[$entityType . '_MULTI']))
	{
		if(!empty($lastItems[$entityType]))
		{
			$result['ITEMS_LAST'] = array_map(
				static function($code) use ($prefix) {
					return preg_replace('/^'.self::PREFIX_FULL . '(\d+)$/', $prefix . '$1', $code);
				},
				array_values($lastItems[$entityType])
			);
			foreach ($lastItems[$entityType] as $value)
			{
				$lastEntitiesIdList[] = str_replace(self::PREFIX_FULL, '', $value);
			}
		}
	}

	$entitiesList = [];

	$list = Container::getInstance()->getFactory(static::getOwnerType())->getItemsFilteredByPermissions([
		'order' => ['ID' => 'DESC'],
		'limit' => 10,
		'select' => [
			Item::FIELD_NAME_ID,
			Item::FIELD_NAME_TITLE,
			Item::FIELD_NAME_BEGIN_DATE,
			Item::FIELD_NAME_CREATED_TIME,
		],
	]);

	foreach ($list as $item)
	{
		$entitiesList[$prefix . $item['ID']] = static::prepareEntity($item, $entityOptions);
	}

	if (empty($lastEntitiesIdList))
	{
		$result['ITEMS_LAST'] = array_keys($entitiesList);
	}

	$result['ITEMS'] = $entitiesList;

	return $result;
}

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