CCrmUserType::ListAddFilterFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmUserType
  4. ListAddFilterFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_usertype.php
  • Класс: \CCrmUserType
  • Вызов: CCrmUserType::ListAddFilterFields
public function ListAddFilterFields(&$arFilterFields, &$arFilterLogic, $sFormName = 'form1', $bVarsFromForm = true)
{
	global $APPLICATION;
	$arUserFields = $this->GetAbstractFields();
	foreach($arUserFields as $FIELD_NAME => $arUserField)
	{
		$userTypeID = $arUserField['USER_TYPE']['USER_TYPE_ID'];
		if ($arUserField['SHOW_FILTER'] != 'N' && $arUserField['USER_TYPE']['BASE_TYPE'] != 'file')
		{
			if($userTypeID === 'employee')
			{
				$arFilterFields[] = array(
					'id' => $FIELD_NAME,
					'name' => htmlspecialcharsex($arUserField['LIST_FILTER_LABEL']),
					'type' => 'user',
					'enable_settings' => false
				);
				continue;
			}

			if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'enum' ||
				$userTypeID == 'iblock_element' || $userTypeID == 'iblock_section')
			{
				// Fix #29649. Allow user to add not multiple fields with height 1 item.
				if($arUserField['MULTIPLE'] !== 'Y'
					&& isset($arUserField['SETTINGS']['LIST_HEIGHT'])
					&& intval($arUserField['SETTINGS']['LIST_HEIGHT']) > 1)
				{
					$arUserField['MULTIPLE'] = 'Y';
				}

				//as the system presets the filter can not work with the field names containing []
				if ($arUserField['SETTINGS']['DISPLAY'] == 'CHECKBOX')
					$arUserField['SETTINGS']['DISPLAY'] = '';
			}

			$templateName = $userTypeID;
			$params = array(
				'arUserField' => $arUserField,
				'bVarsFromForm' => $bVarsFromForm,
				'form_name' => 'filter_'.$sFormName,
				'bShowNotSelected' => true
			);

			if($templateName === 'date')
			{
				$templateName = 'datetime';
				$params['bShowTime'] = false;
			}

			ob_start();
			$APPLICATION->IncludeComponent(
				'bitrix:crm.field.filter',
				$templateName,
				$params,
				false,
				array('HIDE_ICONS' => true)
			);
			$sVal = ob_get_contents();
			ob_end_clean();

			$arFilterFields[] = array(
				'id' => $FIELD_NAME,
				'name' => htmlspecialcharsex($arUserField['LIST_FILTER_LABEL']),
				'type' => 'custom',
				'value' => $sVal
			);

			// Fix issue #49771 - do not treat 'crm' type values as strings. To suppress filtration by LIKE.
			// Fix issue #56844 - do not treat 'crm_status' type values as strings. To suppress filtration by LIKE.
			if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'string' && $userTypeID !== 'crm' && $userTypeID !== 'crm_status')
				$arFilterLogic[] = $FIELD_NAME;
		}
	}
}

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