示例#1
0
 function __CrmQuickPanelViewPrepareMultiFields(array $multiFields, $entityTypeName, $entityID, $typeID)
 {
     if (empty($multiFields)) {
         return null;
     }
     $arEntityTypeInfos = CCrmFieldMulti::GetEntityTypeInfos();
     $arEntityTypes = CCrmFieldMulti::GetEntityTypes();
     $sipConfig = array('STUB' => GetMessage('CRM_ENTITY_QPV_MULTI_FIELD_NOT_ASSIGNED'), 'ENABLE_SIP' => true, 'SIP_PARAMS' => array('ENTITY_TYPE' => 'CRM_' . $entityTypeName, 'ENTITY_ID' => $entityID));
     $typeInfo = isset($arEntityTypeInfos[$typeID]) ? $arEntityTypeInfos[$typeID] : array();
     $result = array('type' => 'multiField', 'caption' => isset($typeInfo['NAME']) ? $typeInfo['NAME'] : $typeID, 'data' => array('type' => $typeID, 'items' => array()));
     foreach ($multiFields as $multiField) {
         $value = isset($multiField['VALUE']) ? $multiField['VALUE'] : '';
         $valueType = isset($multiField['VALUE_TYPE']) ? $multiField['VALUE_TYPE'] : '';
         $entityType = $arEntityTypes[$typeID];
         $valueTypeInfo = isset($entityType[$valueType]) ? $entityType[$valueType] : null;
         $params = array('VALUE' => $value, 'VALUE_TYPE_ID' => $valueType, 'VALUE_TYPE' => $valueTypeInfo);
         $result['data']['items'][] = CCrmViewHelper::PrepareMultiFieldValueItemData($typeID, $params, $sipConfig);
     }
     return $result;
 }