CAllCrmActivity::CreateLogicalField

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmActivity
  4. CreateLogicalField
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity.php
  • Класс: \CAllCrmActivity
  • Вызов: CAllCrmActivity::CreateLogicalField
static function CreateLogicalField($fieldName, &$arFields)
{
	global $DB;

	$fieldName = strval($fieldName);

	if($fieldName === 'TYPE_NAME')
	{
		if(isset(self::$FIELDS_CACHE[LANGUAGE_ID]) && isset(self::$FIELDS_CACHE[LANGUAGE_ID]['TYPE_NAME']))
		{
			$arFields['TYPE_NAME'] = self::$FIELDS_CACHE[LANGUAGE_ID]['TYPE_NAME'];
			return;
		}

		$arTypeDescr = CCrmActivityType::GetAllDescriptions();
		if(count($arTypeDescr) == 0)
		{
			return;
		}

		$sql = 'CASE '.self::TABLE_ALIAS.'.TYPE_ID';
		foreach($arTypeDescr as $typeID=>&$typeDescr)
		{
			$sql .= " WHEN {$typeID} THEN '{$DB->ForSql($typeDescr)}'";
		}
		unset($typeDescr);
		$sql .= ' END';

		if(!isset(self::$FIELDS_CACHE[LANGUAGE_ID]))
		{
			self::$FIELDS_CACHE[LANGUAGE_ID] = array();
		}
		$arFields['TYPE_NAME'] = self::$FIELDS_CACHE[LANGUAGE_ID]['TYPE_NAME'] = array('FIELD' => $sql, 'TYPE' => 'string');
	}
}

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