• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/component/entitydetails/factorybased.php
  • Класс: Bitrix\Crm\Component\EntityDetails\FactoryBased
  • Вызов: FactoryBased::getDefaultTabInfoByCode
protected function getDefaultTabInfoByCode(string $tabCode): ?array
{
	if($tabCode === static::TAB_NAME_EVENT)
	{
		$entityName = $this->factory->getEntityName();
		$entityId = $this->item->getId();

		$tabParams = [
			'id' => static::TAB_NAME_EVENT,
			'name' => Loc::getMessage('CRM_TYPE_ITEM_DETAILS_TAB_HISTORY'),
		];

		if ($this->item->isNew())
		{
			$tabParams['enabled'] = false;
		}
		else
		{
			if (!RestrictionManager::isHistoryViewPermitted())
			{
				$tabParams['tariffLock']  = RestrictionManager::getHistoryViewRestriction()->prepareInfoHelperScript();
			}
			else
			{
				$tabParams['loader'] = [
					'serviceUrl' =>
						'/bitrix/components/bitrix/crm.event.view/lazyload.ajax.php?&site='
						. SITE_ID . '&' . bitrix_sessid_get()
					,
					'componentData' => [
						'template' => '',
						'contextId' => $entityName."_{$entityId}_EVENT",
						'signedParameters' => \CCrmInstantEditorHelper::signComponentParams([
							'AJAX_OPTION_ADDITIONAL' => $entityName."_{$entityId}_EVENT",
							'ENTITY_TYPE' => $entityName,
							'ENTITY_ID' => $entityId,
							'TAB_ID' => static::TAB_NAME_EVENT,
							'INTERNAL' => 'Y',
							'SHOW_INTERNAL_FILTER' => 'Y',
							'PRESERVE_HISTORY' => true,
						], 'crm.event.view')
					],
				];
			}
		}

		return $tabParams;
	}
	if ($tabCode === static::TAB_NAME_PRODUCTS)
	{
		return [
			'id' => static::TAB_NAME_PRODUCTS,
			'name' => Loc::getMessage('CRM_COMMON_PRODUCTS'),
			'html' => $this->getProductsTabHtml(),
		];
	}
	if($tabCode === static::TAB_NAME_TREE)
	{
		return [
			'id' => static::TAB_NAME_TREE,
			'name' => Loc::getMessage('CRM_TYPE_ITEM_DETAILS_TAB_TREE'),
			'loader' => [
				'serviceUrl' => '/bitrix/components/bitrix/crm.entity.tree/lazyload.ajax.php?&site='.SITE_ID.'&'.bitrix_sessid_get(),
				'componentData' => [
					'template' => '.default',
					'signedParameters' => \CCrmInstantEditorHelper::signComponentParams([
						'ENTITY_ID' => $this->getEntityID(),
						'ENTITY_TYPE_NAME' => $this->getEntityName(),
					], 'crm.entity.tree')
				]
			],
			'enabled' => !$this->item->isNew(),
		];
	}
	if ($tabCode === static::TAB_NAME_BIZPROC)
	{
		return [
			'id' => static::TAB_NAME_BIZPROC,
			'name' => Loc::getMessage('CRM_TYPE_ITEM_DETAILS_TAB_BIZPROC'),
			'loader' => [
				'serviceUrl' => '/bitrix/components/bitrix/bizproc.document/lazyload.ajax.php?&site='.SITE_ID.'&'.bitrix_sessid_get(),
				'componentData' => [
					'template' => 'frame',
					'params' => [
						'MODULE_ID' => 'crm',
						'ENTITY' => \CCrmBizProcHelper::ResolveDocumentName($this->item->getEntityTypeId()),
						'DOCUMENT_TYPE' => $this->factory->getEntityName(),
						'DOCUMENT_ID' => $this->factory->getEntityName() . '_' . $this->item->getId(),
					]
				]
			],
			'enabled' => !$this->item->isNew(),
		];
	}
	if ($tabCode === static::TAB_NAME_AUTOMATION)
	{
		return [
			'id' => static::TAB_NAME_AUTOMATION,
			'name' => Loc::getMessage('CRM_TYPE_ITEM_DETAILS_TAB_AUTOMATION'),
			'url' => Container::getInstance()->getRouter()
				->getAutomationUrl($this->factory->getEntityTypeId(), $this->item->getCategoryId())
				->addParams(['id' => $this->item->getId()]),
			'enabled' => !$this->item->isNew(),
		];
	}
	if ($tabCode === static::TAB_NAME_ORDERS)
	{
		return [
			'id' => static::TAB_NAME_ORDERS,
			'name' => \CCrmOwnerType::GetCategoryCaption(\CCrmOwnerType::Order),
			'loader' => [
				'serviceUrl' => '/bitrix/components/bitrix/crm.order.list/lazyload.ajax.php?&site='.SITE_ID.'&'.bitrix_sessid_get(),
				'componentData' => [
					'template' => '',
					'signedParameters' => \CCrmInstantEditorHelper::signComponentParams([
						'INTERNAL_FILTER' => [
							'ASSOCIATED_ENTITY_ID' => $this->item->getId(),
							'ASSOCIATED_ENTITY_TYPE_ID' => $this->factory->getEntityTypeId(),
						],
						'SUM_PAID_CURRENCY' => \Bitrix\Crm\Currency::getBaseCurrencyId(),
						'GRID_ID_SUFFIX' => $this->getGuid(),
						'TAB_ID' => static::TAB_NAME_ORDERS,
						'PRESERVE_HISTORY' => true,
						'BUILDER_CONTEXT' => ProductBuilder::TYPE_ID,
					], 'crm.order.list')
				]
			],
			'enabled' => !$this->item->isNew(),
		];
	}

	return [];
}