• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/bizproc/fieldtype/crm.php
  • Класс: Bitrix\Crm\Integration\BizProc\FieldType\Crm
  • Вызов: Crm::renderSettingsHtmlPieces
static function renderSettingsHtmlPieces(
	string $callbackFunctionName,
	array $settings = []
): array
{
	$idsPrefix = $settings['idsPrefix'] ?? 'WFSFormOptionsX';
	$buttonLabel = $settings['buttonLabel'] ?? 'OK';
	$settingsName = $settings['settingsName'] ?? 'ENTITY';
	$isAssociativeValues = $settings['isAssociativeValues'] ?? false;
	$collectSettingsFunctionName = $settings['collectSettingsFunctionName'] ?? $idsPrefix . 'CRM';
	$inputs = '';
	$collectSettingsFunction = "function " . $collectSettingsFunctionName . "()\n{\n\tvar a = {};";

	$entityTypeIds = [
		\CCrmOwnerType::Lead,
		\CCrmOwnerType::Contact,
		\CCrmOwnerType::Company,
		\CCrmOwnerType::Deal,
	];
	if (InvoiceSettings::getCurrent()->isSmartInvoiceEnabled())
	{
		$entityTypeIds[] = \CCrmOwnerType::SmartInvoice;
	}
	$dynamicTypes = Container::getInstance()->getDynamicTypesMap()->load([
		'isLoadCategories' => false,
		'isLoadStages' => false,
	])->getTypes();

	foreach ($dynamicTypes as $type)
	{
		if ($type->getIsUseInUserfieldEnabled())
		{
			$entityTypeIds[] = $type->getEntityTypeId();
		}
	}

	foreach ($entityTypeIds as $entityTypeId)
	{
		$entityName = \CCrmOwnerType::ResolveName($entityTypeId);
		$idAttribute = $idsPrefix . \CCrmOwnerTypeAbbr::ResolveByTypeID($entityTypeId);
		$isChecked = (isset($settings[$entityName]) && $settings[$entityName] === 'Y');
		$name = $isAssociativeValues ? $settingsName . '[' . $entityName . ']' : $settingsName . '[]';
		$value = $isAssociativeValues ? 'Y' : $entityName;
		$inputs .= ' '
			. htmlspecialcharsbx(\CCrmOwnerType::GetDescription($entityTypeId)) . '
'; $collectSettingsFunction .= "\n\ta[\"" . $entityName . "\"] = document.getElementById(\"" . $idAttribute . "\").checked ? \"Y\" : \"N\";"; } $button = ''; $collectSettingsFunction .= "\n\treturn a;\n}"; return [ 'inputs' => $inputs, 'button' => $button, 'collectSettingsFunctionName' => $collectSettingsFunctionName, 'collectSettingsFunction' => $collectSettingsFunction, ]; }