- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_document.php
- Класс: \CCrmDocument
- Вызов: CCrmDocument::GetFieldInputControl
static function GetFieldInputControl($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection = false, $publicMode = false)
{
global $USER_FIELD_MANAGER, $APPLICATION;
$arDocumentID = static::GetDocumentInfo($documentType.'_0');
if (empty($arDocumentID))
{
throw new CBPArgumentNullException('documentId');
}
static $arDocumentFieldTypes = array();
if (!array_key_exists($documentType, $arDocumentFieldTypes))
$arDocumentFieldTypes[$documentType] = static::GetDocumentFieldTypes($documentType);
$arFieldType["BaseType"] = "string";
$arFieldType["Complex"] = false;
if (array_key_exists($arFieldType["Type"], $arDocumentFieldTypes[$documentType]))
{
$arFieldType["BaseType"] = $arDocumentFieldTypes[$documentType][$arFieldType["Type"]]["BaseType"];
$arFieldType["Complex"] = $arDocumentFieldTypes[$documentType][$arFieldType["Type"]]["Complex"];
}
//$customMethodName = '';
$_fieldValue = $fieldValue;
if (!is_array($fieldValue) || is_array($fieldValue) && CBPHelper::IsAssociativeArray($fieldValue))
$fieldValue = array($fieldValue);
ob_start();
if ($arFieldType['Type'] == 'select')
{
$fieldValueTmp = $fieldValue;
?>
if ($bAllowSelection)
{
?>
}
}
elseif ($arFieldType['Type'] == 'web' || $arFieldType['Type'] == 'phone' || $arFieldType['Type'] == 'email' || $arFieldType['Type'] == 'im')
{
/*$fkeys = array_keys($fieldValue);
foreach ($fkeys as $key)
{
if (preg_match("#^\{=[a-z0-9_]+:[a-z0-9_]+\}$#i", trim($fieldValue[$key])) || substr(trim($fieldValue[$key]), 0, 1) == "=")
{
$
}
}*/
$value1 = $_fieldValue;
$value2 = null;
if ($bAllowSelection && !is_array($value1) && CBPDocument::IsExpression(trim($value1)))
{
$value1 = null;
$value2 = $_fieldValue;
}
$APPLICATION->IncludeComponent('bitrix:crm.field_multi.edit', '',
Array(
'FM_MNEMONIC' => $arFieldName['Field'],
'ENTITY_ID' => $arDocumentID['TYPE'],
'ELEMENT_ID' => $arDocumentID['ID'],
'TYPE_ID' => mb_strtoupper($arFieldType['Type']),
'VALUES' => $value1
),
null,
array('HIDE_ICONS' => 'Y')
);
if ($bAllowSelection)
{
?>
}
}
elseif ($arFieldType['Type'] == 'user')
{
$fieldValue = CBPHelper::UsersArrayToString($fieldValue, null, $arDocumentID["DOCUMENT_TYPE"]);
?>
}
else
{
if($arFieldType['Type'] == 'UF:disk_file')
{
$arFieldType['Multiple'] = false;
}
if (!array_key_exists('CBPVirtualDocumentCloneRowPrinted_'.$documentType, $GLOBALS) && $arFieldType['Multiple'])
{
$GLOBALS['CBPVirtualDocumentCloneRowPrinted_'.$documentType] = 1;
?>
}
if ($arFieldType['Multiple'])
echo '| '; if (mb_strpos($arFieldType['Type'], 'UF:') === 0) { $value1 = $value; if ($bAllowSelection && CBPDocument::IsExpression(trim($value1))) $value1 = null; else unset($fieldValueTmp[$key]); $sType = str_replace('UF:', '', $arFieldType['Type']); $_REQUEST[$arFieldName['Field']] = $value1; if ($sType == 'crm') { ?> } $arUserFieldType = $USER_FIELD_MANAGER->GetUserType($sType); $fields = $USER_FIELD_MANAGER->GetUserFields('CRM_'.$arDocumentID['TYPE']); $ufId = isset($fields[$fieldNameName]) ? $fields[$fieldNameName]['ID'] : null; $arUserField = array( 'ID' => $ufId, 'ENTITY_ID' => 'CRM_'.$arDocumentID['TYPE'], 'FIELD_NAME' => $arFieldName['Field'], 'USER_TYPE_ID' => $sType, 'SORT' => 100, 'MULTIPLE' => $arFieldType['Multiple'] ? 'Y' : 'N', 'MANDATORY' => $arFieldType['Required'] ? 'Y' : 'N', 'EDIT_IN_LIST' => 'Y', 'EDIT_FORM_LABEL' => $arUserFieldType['DESCRIPTION'], 'VALUE' => $value1, 'USER_TYPE' => $arUserFieldType, 'SETTINGS' => array(), 'ENTITY_VALUE_ID' => 1, ); if ($arFieldType['Type'] == 'UF:boolean' && ($arUserField['VALUE'] == "Y" || $arUserField['VALUE'] == "N")) $arUserField['VALUE'] = ($arUserField['VALUE'] == "Y") ? 1 : 0; if ( $arFieldType['Type'] == 'UF:iblock_element' || $arFieldType['Type'] == 'UF:iblock_section' || $arFieldType['Type'] == 'UF:crm_status' || $arFieldType['Type'] == 'UF:boolean' ) { $options = $arFieldType['Options']; if(is_string($options)) { if ($arFieldType['Type'] == 'UF:crm_status') { $arUserField['SETTINGS']['ENTITY_TYPE'] = $options; } else { $arUserField['SETTINGS']['IBLOCK_ID'] = $options; } } elseif(is_array($options)) { $arUserField['SETTINGS']= $options; } } elseif ($arFieldType['Type'] == 'UF:crm') { $arUserField['SETTINGS'] = $arFieldType['Options']; if (empty($arUserField['SETTINGS'])) $arUserField['SETTINGS'] = array('LEAD' => 'Y', 'CONTACT' => 'Y', 'COMPANY' => 'Y', 'DEAL' => 'Y'); } $APPLICATION->IncludeComponent( 'bitrix:system.field.edit', $sType, array( 'arUserField' => $arUserField, 'bVarsFromForm' => false, 'form_name' => $arFieldName['Form'], 'FILE_MAX_HEIGHT' => 400, 'FILE_MAX_WIDTH' => 400, 'FILE_SHOW_POPUP' => true ), false, array('HIDE_ICONS' => 'Y') ); } else { switch ($arFieldType['Type']) { case 'int': unset($fieldValueTmp[$key]); ?> break; case 'file': if ($publicMode) { //unset($fieldValueTmp[$key]); ?> } break; case 'bool': if (in_array($value, array('Y', 'N'))) unset($fieldValueTmp[$key]); ?> break; case "date": case "datetime": $v = ""; if (!CBPDocument::IsExpression(trim($value))) { $v = $value; unset($fieldValueTmp[$key]); } $APPLICATION->IncludeComponent( 'bitrix:main.calendar', '', array( 'SHOW_INPUT' => 'Y', 'FORM_NAME' => $arFieldName['Form'], 'INPUT_NAME' => $fieldNameName, 'INPUT_VALUE' => $v, 'SHOW_TIME' => $arFieldType['Type'] === 'datetime' ? 'Y' : 'N' ), false, array('HIDE_ICONS' => 'Y') ); break; case 'text': unset($fieldValueTmp[$key]); ?> break; default: unset($fieldValueTmp[$key]); ?> } } if ($bAllowSelection) { if (!in_array($arFieldType["Type"], array("file", "bool", "date", "datetime")) && (mb_strpos($arFieldType['Type'], 'UF:') !== 0)) { ?>');"> } } if ($arFieldType['Multiple']) echo ' |
'; } if ($bAllowSelection) { if (in_array($arFieldType['Type'], array('file', 'bool', "date", "datetime")) || (mb_strpos($arFieldType['Type'], 'UF:') === 0)) { ?> _text" name="= htmlspecialcharsbx($arFieldName["Field"]) ?>_text" value=" if (count($fieldValueTmp) > 0) { $a = array_values($fieldValueTmp); echo htmlspecialcharsbx($a[0]); } ?>"> _text', '= htmlspecialcharsbx($arFieldType["BaseType"]) ?>');"> } } } $s = ob_get_contents(); ob_end_clean(); return $s; }