• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_document.php
  • Класс: \CCrmDocument
  • Вызов: CCrmDocument::GetDocumentFieldTypes
static function GetDocumentFieldTypes($documentType)
{
	global $USER_FIELD_MANAGER;
	$arDocumentID = static::GetDocumentInfo($documentType.'_0');
	if (empty($arDocumentID))
	{
		throw new CBPArgumentNullException('documentId');
	}

	$arResult = array(
		'string' => array('Name' => GetMessage('BPVDX_STRING'), 'BaseType' => 'string'),
		'int' => array('Name' => GetMessage('BPVDX_NUMINT'), 'BaseType' => 'int'),
		'email' => array(
			'Name' => GetMessage('BPVDX_EMAIL'),
			'BaseType' => 'string',
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\Email::class
		),
		'phone' => array(
			'Name' => GetMessage('BPVDX_PHONE'),
			'BaseType' => 'string',
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\Phone::class
		),
		'web' => array(
			'Name' => GetMessage('BPVDX_WEB'),
			'BaseType' => 'string',
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\Web::class
		),
		'im' => array(
			'Name' => GetMessage('BPVDX_MESSANGER'),
			'BaseType' => 'string',
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\Im::class
		),
		'text' => array('Name' => GetMessage('BPVDX_TEXT'), 'BaseType' => 'text'),
		'double' => array('Name' => GetMessage('BPVDX_NUM'), 'BaseType' => 'double'),
		'select' => array('Name' => GetMessage('BPVDX_LIST'), 'BaseType' => 'select', "Complex" => true),
		'file' => array('Name' => GetMessage('BPVDX_FILE'), 'BaseType' => 'file'),
		'user' => array('Name' => GetMessage('BPVDX_USER'), 'BaseType' => 'user'),
		'bool' => array('Name' => GetMessage('BPVDX_YN'), 'BaseType' => 'bool'),
		'datetime' => array('Name' => GetMessage('BPVDX_DATETIME'), 'BaseType' => 'datetime'),
		\Bitrix\Bizproc\FieldType::INTERNALSELECT => [
			'Name' => GetMessage("BPVDX_INTERNALSELECT"),
			'BaseType' => 'string',
			'Complex' => true,
		],
		'deal_category' => [
			'Name' => \Bitrix\Crm\Integration\BizProc\FieldType\DealCategory::getName(),
			'BaseType' => \Bitrix\Crm\Integration\BizProc\FieldType\DealCategory::getType(),
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\DealCategory::class,
		],
		'deal_stage' => [
			'Name' => \Bitrix\Crm\Integration\BizProc\FieldType\DealStage::getName(),
			'BaseType' => \Bitrix\Crm\Integration\BizProc\FieldType\DealStage::getType(),
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\DealStage::class,
		],
		'lead_status' => [
			'Name' => \Bitrix\Crm\Integration\BizProc\FieldType\LeadStatus::getName(),
			'BaseType' => \Bitrix\Crm\Integration\BizProc\FieldType\LeadStatus::getType(),
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\LeadStatus::class,
		],
		'sms_sender' => [
			'Name' => \Bitrix\Crm\Integration\BizProc\FieldType\SmsSender::getName(),
			'BaseType' => \Bitrix\Crm\Integration\BizProc\FieldType\SmsSender::getType(),
			'typeClass' => \Bitrix\Crm\Integration\BizProc\FieldType\SmsSender::class,
		],
		'mail_sender' => [
			'Name' => \Bitrix\Bizproc\UserType\MailSender::getName(),
			'BaseType' => \Bitrix\Bizproc\UserType\MailSender::getType(),
			'typeClass' => \Bitrix\Bizproc\UserType\MailSender::class,
		]
	);

	//'Disk File' is disabled due to GUI issues (see CCrmFields::GetFieldTypes)
	$ignoredUserTypes = array(
		'string', 'double', 'boolean', 'integer', 'datetime', 'file', 'employee', 'enumeration', 'video',
		'string_formatted', 'webdav_element_history', 'disk_version', 'disk_file', 'vote', 'url_preview', 'hlblock',
		'mail_message'
	);
	$arTypes = $USER_FIELD_MANAGER->GetUserType();
	foreach ($arTypes as $arType)
	{
		if (in_array($arType['USER_TYPE_ID'], $ignoredUserTypes))
			continue;

		if ($arType['BASE_TYPE'] == 'enum')
		{
			$arType['BASE_TYPE'] = 'select';
		}

		$sType = 'UF:'.$arType['USER_TYPE_ID'];

		$arResult[$sType] = array(
			'Name' => $arType['DESCRIPTION'],
			'BaseType' => $arType['BASE_TYPE']
		);

		if ($arType['USER_TYPE_ID'] === 'date')
		{
			$arResult[$sType]['typeClass'] = '\Bitrix\Bizproc\BaseType\Date';
			$arResult[$sType]['BaseType'] = 'date';
		}
		elseif ($arType['USER_TYPE_ID'] === 'iblock_element')
		{
			$arResult[$sType]['typeClass'] = \Bitrix\Crm\Integration\BizProc\FieldType\IblockElement::class;
			$arResult[$sType]['Complex'] = true;
		}
		elseif ($arType['USER_TYPE_ID'] === 'iblock_section')
		{
			$arResult[$sType]['typeClass'] = \Bitrix\Crm\Integration\BizProc\FieldType\IblockSection::class;
			$arResult[$sType]['Complex'] = true;
		}
		elseif ($arType['USER_TYPE_ID'] === 'crm_status')
		{
			$arResult[$sType]['typeClass'] = \Bitrix\Crm\Integration\BizProc\FieldType\CrmStatus::class;
			$arResult[$sType]['Complex'] = true;
		}
		elseif ($arType['USER_TYPE_ID'] === 'crm')
		{
			$arResult[$sType]['typeClass'] = \Bitrix\Crm\Integration\BizProc\FieldType\Crm::class;
			$arResult[$sType]['Complex'] = true;
		}
		elseif ($arType['USER_TYPE_ID'] === 'resourcebooking')
		{
			//TODO
		}
		elseif ($arType['USER_TYPE_ID'] === 'money')
		{
			$arResult[$sType]['typeClass'] = \Bitrix\Crm\Integration\BizProc\FieldType\Money::class;
		}
		elseif ($arType['USER_TYPE_ID'] === 'address')
		{
			$arResult[$sType]['typeClass'] = \Bitrix\Crm\Integration\BizProc\FieldType\Address::class;
		}
		elseif ($arType['USER_TYPE_ID'] === 'url')
		{
			$arResult[$sType]['typeClass'] = \Bitrix\Crm\Integration\BizProc\FieldType\Url::class;
		}
	}
	return $arResult;
}