• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/documentgenerator/dataprovider/dynamic.php
  • Класс: Bitrix\Crm\Integration\DocumentGenerator\DataProvider\Dynamic
  • Вызов: Dynamic::getEntityTypeId
static function getEntityTypeId(): int;

public function getFields(): array
{
	if ($this->fields !== null)
	{
		return $this->fields;
	}

	$this->fields = parent::getFields();

	$factory = $this->getFactory();
	if (!$factory)
	{
		return $this->fields;
	}

	if ($factory->isCategoriesSupported())
	{
		$this->fields['CATEGORY'] = [
			'TITLE' => Loc::getMessage('CRM_COMMON_CATEGORY'),
			'VALUE' => [$this, 'getCategory'],
		];
	}
	else
	{
		unset($this->fields[Item::FIELD_NAME_CATEGORY_ID]);
	}

	$fieldsWithStages = [
		'STAGE' => Item::FIELD_NAME_STAGE_ID,
		'PREVIOUS_STAGE' => Item::FIELD_NAME_PREVIOUS_STAGE_ID,
	];

	if ($factory->isStagesEnabled())
	{
		foreach ($fieldsWithStages as $providerFieldName => $valueFieldName)
		{
			$this->fields[$providerFieldName] = [
				'VALUE' => [$this, 'getStage'],
				'TITLE' => $factory->getFieldCaption($valueFieldName),
			];
		}
	}

	if ($factory->isClientEnabled() && !$this->isLightMode())
	{
		$this->fields['CONTACTS'] = [
			'TITLE' => GetMessage('CRM_DOCGEN_DATAPROVIDER_DEAL_CONTACTS_TITLE'),
			'PROVIDER' => ArrayDataProvider::class,
			'OPTIONS' => [
				'ITEM_PROVIDER' => Contact::class,
				'ITEM_NAME' => 'CONTACT',
				'ITEM_TITLE' => GetMessage('CRM_DOCGEN_DATAPROVIDER_DEAL_CONTACT_TITLE'),
				'ITEM_OPTIONS' => [
					'DISABLE_MY_COMPANY' => true,
					'isLightMode' => true,
				],
			],
			'VALUE' => [$this, 'getContacts'],
		];
	}
	else
	{
		unset(
			$this->fields['COMPANY'],
			$this->fields['CONTACT'],
			$this->fields['CONTACTS'],
			$this->fields['CLIENT_PHONE'],
			$this->fields['CLIENT_EMAIL'],
			$this->fields['CLIENT_WEB']
		);
	}

	if(!$factory->isMyCompanyEnabled())
	{
		unset(
			$this->fields['MY_COMPANY'],
			$this->fields['REQUISITE'],
			$this->fields['BANK_DETAIL']
		);
	}

	if ($factory->isLinkWithProductsEnabled())
	{
		$this->fields[Item::FIELD_NAME_OPPORTUNITY]['TYPE'] = Money::class;
		$this->fields[Item::FIELD_NAME_OPPORTUNITY]['FORMAT'] = ['CURRENCY_ID' => $this->getCurrencyId()];
	}
	else
	{
		unset(
			$this->fields[Item::FIELD_NAME_OPPORTUNITY],
			$this->fields[Item::FIELD_NAME_IS_MANUAL_OPPORTUNITY],
			$this->fields['PRODUCTS'],
			$this->fields['TAXES'],
			$this->fields[Item::FIELD_NAME_CURRENCY_ID],
			$this->fields['CURRENCY_NAME']
		);

		foreach ($this->getTotalFields() as $name => $field)
		{
			unset($this->fields[$name]);
		}
	}

	if ($factory->isSourceEnabled())
	{
		$this->fields['SOURCE'] = [
			'TITLE' => Loc::getMessage('CRM_DOCGEN_DATAPROVIDER_DEAL_SOURCE_TITLE'),
			'VALUE' => [$this, 'getSourceValue'],
		];
	}
	else
	{
		unset($this->fields[Item::FIELD_NAME_SOURCE_DESCRIPTION]);
	}

	if (!$factory->isBeginCloseDatesEnabled())
	{
		unset(
			$this->fields[Item::FIELD_NAME_BEGIN_DATE],
			$this->fields[Item::FIELD_NAME_CLOSE_DATE]
		);
	}

	return $this->fields;
}