CCrmViewHelper::RenderListMultiFieldValues

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmViewHelper
  4. RenderListMultiFieldValues
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_view_helper.php
  • Класс: \CCrmViewHelper
  • Вызов: CCrmViewHelper::RenderListMultiFieldValues
static function RenderListMultiFieldValues($ID, &$arValues, $typeName, &$arValueTypes, $arOptions = null)
{
	CCrmComponentHelper::RegisterScriptLink('/bitrix/js/crm/common.js');

	$ID = strval($ID);
	if($ID === '')
	{
		$ID = uniqid('CRM_MULTI_FIELD_');
	}

	$typeName = mb_strtoupper(strval($typeName));
	$result = '';
	$arValueData = array();
	foreach($arValueTypes as $valueTypeID => &$arValueType)
	{
		if(!isset($arValues[$valueTypeID]) || empty($arValues[$valueTypeID]))
		{
			continue;
		}

		foreach($arValues[$valueTypeID] as $value)
		{
			$arValueData[] = array(
				'VALUE_TYPE_ID' => $valueTypeID,
				'VALUE' => $value
			);
		}
	}
	unset($arValueType);

	$qty = count($arValueData);
	if($qty === 0)
	{
		return '';
	}

	$enableSip = is_array($arOptions) && isset($arOptions['ENABLE_SIP']) && (bool)$arOptions['ENABLE_SIP'];
	$sipParams =  $enableSip && isset($arOptions['SIP_PARAMS']) ? $arOptions['SIP_PARAMS'] : null;

	$first = $arValueData[0];
	$firstValueType = isset($arValueTypes[$first['VALUE_TYPE_ID']]) ? $arValueTypes[$first['VALUE_TYPE_ID']] : null;
	if($firstValueType)
	{
		if($typeName === 'PHONE' && $enableSip)
		{
			$additionalHtml = self::PrepareSipCallHtml($first['VALUE'], $sipParams);
			$result .= '
' .self::PrepareMultiFieldHtml($typeName, array('VALUE_TYPE_ID' => $first['VALUE_TYPE_ID'], 'VALUE_TYPE' => $firstValueType, 'VALUE' => $first['VALUE'])) .$additionalHtml.'
'; } else { $result .= '
' .self::PrepareMultiFieldHtml($typeName, array('VALUE_TYPE_ID' => $first['VALUE_TYPE_ID'], 'VALUE_TYPE' => $firstValueType, 'VALUE' => $first['VALUE'])) .'
'; } } if($qty > 1) { $arPopupItems = array(); for($i = 1; $i < $qty; $i++) { $current = $arValueData[$i]; $valueType = isset($arValueTypes[$current['VALUE_TYPE_ID']]) ? $arValueTypes[$current['VALUE_TYPE_ID']] : null; if(!$valueType) { continue; } $popupItemData = array( 'value' => htmlspecialcharsbx( self::PrepareMultiFieldHtml($typeName, array('VALUE_TYPE_ID' => $current['VALUE_TYPE_ID'], 'VALUE_TYPE' => $valueType, 'VALUE' => $current['VALUE'])) ), 'type' => htmlspecialcharsbx( isset($valueType['SHORT'])? mb_strtolower($valueType['SHORT']) : '' ) ); if($typeName === 'PHONE' && $enableSip) { $popupItemData['sipCallHtml'] = htmlspecialcharsbx(self::PrepareSipCallHtml($current['VALUE'], $sipParams)); } $arPopupItems[] = &$popupItemData; unset($popupItemData); } $buttonID = $ID.'_BTN'; $result .= '
'; $result .= ''.htmlspecialcharsbx(GetMessage('CRM_ENTITY_MULTI_FIELDS_MORE')).' '.($qty - 1).''; $result .= '
'; } return $result; }

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