Exemple #1
1
 public static function GetDocument($documentId)
 {
     $arDocumentID = self::GetDocumentInfo($documentId);
     if (empty($arDocumentID)) {
         throw new CBPArgumentNullException('documentId');
     }
     $arResult = null;
     switch ($arDocumentID['TYPE']) {
         case 'CONTACT':
             $dbDocumentList = CCrmContact::GetListEx(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), false, false, array('*', 'UF_*'));
             break;
         case 'COMPANY':
             $dbDocumentList = CCrmCompany::GetListEx(array(), array('ID' => $arDocumentID['ID'], 'CHECK_PERMISSIONS' => 'N'), false, false, array('*', 'UF_*'));
             break;
         case 'DEAL':
             $dbDocumentList = CCrmDeal::GetListEx(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), false, false, array('*', 'UF_*'));
             break;
         case 'LEAD':
             $dbDocumentList = CCrmLead::GetListEx(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), false, false, array('*', 'UF_*'));
             break;
     }
     if (($objDocument = $dbDocumentList->Fetch()) !== false) {
         $assignedByID = isset($objDocument['ASSIGNED_BY_ID']) ? intval($objDocument['ASSIGNED_BY_ID']) : 0;
         if ($assignedByID > 0) {
             $dbUsers = CUser::GetList($sortBy = 'id', $sortOrder = 'asc', array('ID' => $assignedByID), array('SELECT' => array('EMAIL')));
             $arUser = is_object($dbUsers) ? $dbUsers->Fetch() : null;
             $objDocument['ASSIGNED_BY_EMAIL'] = is_array($arUser) ? $arUser['EMAIL'] : '';
         }
         $arUserField = array('CREATED_BY', 'CREATED_BY_ID', 'MODIFY_BY', 'MODIFY_BY_ID', 'ASSIGNED_BY', 'ASSIGNED_BY_ID');
         foreach ($arUserField as $sField) {
             if (isset($objDocument[$sField])) {
                 $objDocument[$sField] = 'user_' . $objDocument[$sField];
             }
         }
         if (COption::GetOptionString('crm', 'bp_version', 2) == 2) {
             $userFieldsList = null;
             switch ($arDocumentID['TYPE']) {
                 case 'CONTACT':
                     $userFieldsList = CCrmContact::GetUserFields();
                     break;
                 case 'COMPANY':
                     $userFieldsList = CCrmCompany::GetUserFields();
                     break;
                 case 'DEAL':
                     $userFieldsList = CCrmDeal::GetUserFields();
                     break;
                 case 'LEAD':
                     $userFieldsList = CCrmLead::GetUserFields();
                     break;
             }
             if (is_array($userFieldsList)) {
                 foreach ($userFieldsList as $userFieldName => $userFieldParams) {
                     $fieldTypeID = isset($userFieldParams['USER_TYPE']) ? $userFieldParams['USER_TYPE']['USER_TYPE_ID'] : '';
                     $isFieldMultiple = isset($userFieldParams['MULTIPLE']) && $userFieldParams['MULTIPLE'] === 'Y';
                     $fieldSettings = isset($userFieldParams['SETTINGS']) ? $userFieldParams['SETTINGS'] : array();
                     if (isset($objDocument[$userFieldName])) {
                         $fieldValue = $objDocument[$userFieldName];
                     } elseif (isset($fieldSettings['DEFAULT_VALUE'])) {
                         $fieldValue = $fieldSettings['DEFAULT_VALUE'];
                     } else {
                         $objDocument[$userFieldName] = $objDocument[$userFieldName . '_PRINTABLE'] = '';
                         continue;
                     }
                     if ($fieldTypeID == 'employee') {
                         if (!$isFieldMultiple) {
                             $objDocument[$userFieldName] = 'user_' . $fieldValue;
                         } else {
                             $objDocument[$userFieldName] = array();
                             foreach ($fieldValue as $value) {
                                 $objDocument[$userFieldName][] = 'user_' . $value;
                             }
                         }
                     } elseif ($fieldTypeID == 'crm') {
                         $defaultTypeName = '';
                         foreach ($fieldSettings as $typeName => $flag) {
                             if ($flag === 'Y') {
                                 $defaultTypeName = $typeName;
                                 break;
                             }
                         }
                         if (!$isFieldMultiple) {
                             $objDocument[$userFieldName . '_PRINTABLE'] = self::PrepareCrmUserTypeValueView($fieldValue, $defaultTypeName);
                         } else {
                             $views = array();
                             foreach ($fieldValue as $value) {
                                 $views[] = self::PrepareCrmUserTypeValueView($value, $defaultTypeName);
                             }
                             $objDocument[$userFieldName . '_PRINTABLE'] = $views;
                         }
                     } elseif ($fieldTypeID == 'enumeration') {
                         self::ExternalizeEnumerationField($objDocument, $userFieldName);
                     } elseif ($fieldTypeID === 'boolean') {
                         //Convert UF boolean values (1/0) in to bizproc boolean values (Y/N) is display type checkbox
                         if (isset($fieldSettings['DISPLAY']) && $fieldSettings['DISPLAY'] === 'CHECKBOX') {
                             $objDocument[$userFieldName] = $fieldValue > 0 ? 'Y' : 'N';
                         }
                         $objDocument[$userFieldName . '_PRINTABLE'] = GetMessage($fieldValue > 0 ? 'MAIN_YES' : 'MAIN_NO');
                     }
                 }
             }
         }
         $res = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => $arDocumentID['TYPE'], 'ELEMENT_ID' => $arDocumentID['ID']));
         while ($ar = $res->Fetch()) {
             if (!isset($objDocument[$ar['TYPE_ID']])) {
                 $objDocument[$ar['TYPE_ID']] = array();
             }
             $objDocument[$ar['TYPE_ID']]['n0' . $ar['ID']] = array('VALUE' => $ar['VALUE'], 'VALUE_TYPE' => $ar['VALUE_TYPE']);
             if (!isset($objDocument[$ar['TYPE_ID'] . "_" . $ar['VALUE_TYPE']])) {
                 $objDocument[$ar['TYPE_ID'] . "_" . $ar['VALUE_TYPE']] = array();
             }
             $objDocument[$ar['TYPE_ID'] . "_" . $ar['VALUE_TYPE']][] = $ar['VALUE'];
             if (!isset($objDocument[$ar['TYPE_ID'] . "_" . $ar['VALUE_TYPE'] . "_PRINTABLE"])) {
                 $objDocument[$ar['TYPE_ID'] . "_" . $ar['VALUE_TYPE'] . "_PRINTABLE"] = "";
             }
             $objDocument[$ar['TYPE_ID'] . "_" . $ar['VALUE_TYPE'] . "_PRINTABLE"] .= (strlen($objDocument[$ar['TYPE_ID'] . "_" . $ar['VALUE_TYPE'] . "_PRINTABLE"]) > 0 ? ", " : "") . $ar['VALUE'];
             if (!isset($objDocument[$ar['TYPE_ID'] . "_PRINTABLE"])) {
                 $objDocument[$ar['TYPE_ID'] . "_PRINTABLE"] = "";
             }
             $objDocument[$ar['TYPE_ID'] . "_PRINTABLE"] .= (strlen($objDocument[$ar['TYPE_ID'] . "_PRINTABLE"]) > 0 ? ", " : "") . $ar['VALUE'];
         }
         $multiFieldTypes = CCrmFieldMulti::GetEntityTypeList();
         foreach ($multiFieldTypes as $typeId => $arFields) {
             if (!isset($objDocument[$typeId])) {
                 $objDocument[$typeId] = array();
             }
             $printableFieldName = $typeId . '_PRINTABLE';
             if (!isset($objDocument[$printableFieldName])) {
                 $objDocument[$printableFieldName] = '';
             }
             foreach ($arFields as $valueType => $valueName) {
                 $fieldName = $typeId . '_' . $valueType;
                 if (!isset($objDocument[$fieldName])) {
                     $objDocument[$fieldName] = array('');
                 }
                 $printableFieldName = $fieldName . '_PRINTABLE';
                 if (!isset($objDocument[$printableFieldName])) {
                     $objDocument[$printableFieldName] = '';
                 }
             }
         }
         // Preparation of user names -->
         $nameFormat = CSite::GetNameFormat(false);
         if (isset($objDocument['ASSIGNED_BY_ID'])) {
             $objDocument['ASSIGNED_BY_PRINTABLE'] = CUser::FormatName($nameFormat, array('LOGIN' => isset($objDocument['ASSIGNED_BY_LOGIN']) ? $objDocument['ASSIGNED_BY_LOGIN'] : '', 'NAME' => isset($objDocument['ASSIGNED_BY_NAME']) ? $objDocument['ASSIGNED_BY_NAME'] : '', 'LAST_NAME' => isset($objDocument['ASSIGNED_BY_LAST_NAME']) ? $objDocument['ASSIGNED_BY_LAST_NAME'] : '', 'SECOND_NAME' => isset($objDocument['ASSIGNED_BY_SECOND_NAME']) ? $objDocument['ASSIGNED_BY_SECOND_NAME'] : ''), true, false);
         }
         if (isset($objDocument['CREATED_BY_ID'])) {
             $objDocument['CREATED_BY_PRINTABLE'] = CUser::FormatName($nameFormat, array('LOGIN' => isset($objDocument['CREATED_BY_LOGIN']) ? $objDocument['CREATED_BY_LOGIN'] : '', 'NAME' => isset($objDocument['CREATED_BY_NAME']) ? $objDocument['CREATED_BY_NAME'] : '', 'LAST_NAME' => isset($objDocument['CREATED_BY_LAST_NAME']) ? $objDocument['CREATED_BY_LAST_NAME'] : '', 'SECOND_NAME' => isset($objDocument['CREATED_BY_SECOND_NAME']) ? $objDocument['CREATED_BY_SECOND_NAME'] : ''), true, false);
         }
         // <-- Preparation of user names
         switch ($arDocumentID['TYPE']) {
             case 'DEAL':
                 CCrmDocumentDeal::PrepareDocument($objDocument);
                 break;
             case 'LEAD':
                 CCrmDocumentLead::PrepareDocument($objDocument);
                 break;
             case 'CONTACT':
                 CCrmDocumentContact::PrepareDocument($objDocument);
                 break;
         }
         return $objDocument;
     }
     return null;
 }
 public static function GetDocumentFields($documentType)
 {
     $arDocumentID = self::GetDocumentInfo($documentType . '_0');
     if (empty($arDocumentID)) {
         throw new CBPArgumentNullException('documentId');
     }
     __IncludeLang($_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/components/bitrix/crm.' . strtolower($arDocumentID['TYPE']) . '.edit/lang/' . LANGUAGE_ID . '/component.php');
     $printableFieldNameSuffix = ' (' . GetMessage('CRM_FIELD_BP_TEXT') . ')';
     $emailFieldNameSuffix = ' (' . GetMessage('CRM_FIELD_BP_EMAIL') . ')';
     $arResult = array('ID' => array('Name' => GetMessage('CRM_FIELD_ID'), 'Type' => 'int', 'Filterable' => true, 'Editable' => false, 'Required' => false), 'TITLE' => array('Name' => GetMessage('CRM_FIELD_TITLE'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => true), 'COMPANY_TYPE' => array('Name' => GetMessage('CRM_FIELD_COMPANY_TYPE'), 'Type' => 'select', 'Options' => CCrmStatus::GetStatusListEx('COMPANY_TYPE'), 'Filterable' => true, 'Editable' => true, 'Required' => false), 'INDUSTRY' => array('Name' => GetMessage('CRM_FIELD_INDUSTRY'), 'Type' => 'select', 'Options' => CCrmStatus::GetStatusListEx('INDUSTRY'), 'Filterable' => true, 'Editable' => true, 'Required' => false), 'EMPLOYEES' => array('Name' => GetMessage('CRM_FIELD_EMPLOYEES'), 'Type' => 'select', 'Options' => CCrmStatus::GetStatusListEx('EMPLOYEES'), 'Filterable' => true, 'Editable' => true, 'Required' => false), 'REVENUE' => array('Name' => GetMessage('CRM_FIELD_REVENUE'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'CURRENCY_ID' => array('Name' => GetMessage('CRM_FIELD_CURRENCY_ID'), 'Type' => 'select', 'Options' => CCrmCurrencyHelper::PrepareListItems(), 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ASSIGNED_BY_ID' => array('Name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID'), 'Type' => 'user', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ASSIGNED_BY_PRINTABLE' => array('Name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID') . $printableFieldNameSuffix, 'Type' => 'string', 'Filterable' => false, 'Editable' => false, 'Required' => false), 'ASSIGNED_BY_EMAIL' => array('Name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID') . $emailFieldNameSuffix, 'Type' => 'string', 'Filterable' => false, 'Editable' => false, 'Required' => false), 'COMMENTS' => array('Name' => GetMessage('CRM_FIELD_COMMENTS'), 'Type' => 'text', 'Filterable' => false, 'Editable' => true, 'Required' => false), 'EMAIL' => array('Name' => GetMessage('CRM_FIELD_EMAIL'), 'Type' => 'email', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'PHONE' => array('Name' => GetMessage('CRM_FIELD_PHONE'), 'Type' => 'phone', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'WEB' => array('Name' => GetMessage('CRM_FIELD_WEB'), 'Type' => 'web', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'IM' => array('Name' => GetMessage('CRM_FIELD_MESSENGER'), 'Type' => 'im', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS' => array('Name' => GetMessage('CRM_FIELD_ADDRESS'), 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS_LEGAL' => array('Name' => GetMessage('CRM_FIELD_ADDRESS_LEGAL'), 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'BANKING_DETAILS' => array('Name' => GetMessage('CRM_FIELD_BANKING_DETAILS'), 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), "OPENED" => array("Name" => GetMessage("CRM_FIELD_OPENED"), "Type" => "bool", "Filterable" => true, "Editable" => true, "Required" => false), "LEAD_ID" => array("Name" => GetMessage("CRM_FIELD_LEAD_ID"), "Type" => "int", "Filterable" => true, "Editable" => true, "Required" => false), "ORIGINATOR_ID" => array("Name" => GetMessage("CRM_FIELD_ORIGINATOR_ID"), "Type" => "string", "Filterable" => true, "Editable" => true, "Required" => false), "ORIGIN_ID" => array("Name" => GetMessage("CRM_FIELD_ORIGIN_ID"), "Type" => "string", "Filterable" => true, "Editable" => true, "Required" => false), "CONTACT_ID" => array("Name" => GetMessage("CRM_FIELD_CONTACT_ID"), "Type" => "UF:crm", "Options" => array('CONTACT' => 'Y'), "Filterable" => true, "Editable" => true, "Required" => false, "Multiple" => false), "DATE_CREATE" => array("Name" => GetMessage("CRM_COMPANY_EDIT_FIELD_DATE_CREATE"), "Type" => "datetime", "Filterable" => true, "Editable" => false, "Required" => false), "DATE_MODIFY" => array("Name" => GetMessage("CRM_COMPANY_EDIT_FIELD_DATE_MODIFY"), "Type" => "datetime", "Filterable" => true, "Editable" => false, "Required" => false));
     $ar = CCrmFieldMulti::GetEntityTypeList();
     foreach ($ar as $typeId => $arFields) {
         $arResult[$typeId . '_PRINTABLE'] = array('Name' => GetMessage("CRM_FIELD_MULTI_" . $typeId) . $printableFieldNameSuffix, 'Type' => 'string', "Filterable" => true, "Editable" => false, "Required" => false);
         foreach ($arFields as $valueType => $valueName) {
             $arResult[$typeId . '_' . $valueType] = array('Name' => $valueName, 'Type' => 'string', "Filterable" => true, "Editable" => false, "Required" => false);
             $arResult[$typeId . '_' . $valueType . '_PRINTABLE'] = array('Name' => $valueName . $printableFieldNameSuffix, 'Type' => 'string', "Filterable" => true, "Editable" => false, "Required" => false);
         }
     }
     global $USER_FIELD_MANAGER;
     $CCrmUserType = new CCrmUserType($USER_FIELD_MANAGER, 'CRM_COMPANY');
     $CCrmUserType->AddBPFields($arResult, array('PRINTABLE_SUFFIX' => GetMessage("CRM_FIELD_BP_TEXT")));
     return $arResult;
 }
 public static function GetDocumentFields($documentType)
 {
     $arDocumentID = self::GetDocumentInfo($documentType . '_0');
     if (empty($arDocumentID)) {
         throw new CBPArgumentNullException('documentId');
     }
     __IncludeLang($_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/components/bitrix/crm.' . strtolower($arDocumentID['TYPE']) . '.edit/lang/' . LANGUAGE_ID . '/component.php');
     $addressLabels = Bitrix\Crm\EntityAddress::getShortLabels();
     $printableFieldNameSuffix = ' (' . GetMessage('CRM_FIELD_BP_TEXT') . ')';
     $emailFieldNameSuffix = ' (' . GetMessage('CRM_FIELD_BP_EMAIL') . ')';
     $arResult = array('ID' => array('Name' => GetMessage('CRM_FIELD_ID'), 'Type' => 'int', 'Filterable' => true, 'Editable' => false, 'Required' => false), 'TITLE' => array('Name' => GetMessage('CRM_FIELD_TITLE'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => true), 'STATUS_ID' => array('Name' => GetMessage('CRM_FIELD_STATUS_ID'), 'Type' => 'select', 'Options' => CCrmStatus::GetStatusListEx('STATUS'), 'Filterable' => true, 'Editable' => true, 'Required' => false), 'STATUS_ID_PRINTABLE' => array('Name' => GetMessage('CRM_FIELD_STATUS_ID') . $printableFieldNameSuffix, 'Type' => 'string', 'Filterable' => false, 'Editable' => false, 'Required' => false), 'STATUS_DESCRIPTION' => array('Name' => GetMessage('CRM_FIELD_STATUS_DESCRIPTION'), 'Type' => 'text', 'Filterable' => false, 'Editable' => true, 'Required' => false), 'OPPORTUNITY' => array('Name' => GetMessage('CRM_FIELD_OPPORTUNITY'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'CURRENCY_ID' => array('Name' => GetMessage('CRM_FIELD_CURRENCY_ID'), 'Type' => 'select', 'Options' => CCrmCurrencyHelper::PrepareListItems(), 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ASSIGNED_BY_ID' => array('Name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID'), 'Type' => 'user', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ASSIGNED_BY_PRINTABLE' => array('Name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID') . $printableFieldNameSuffix, 'Type' => 'string', 'Filterable' => false, 'Editable' => false, 'Required' => false), 'ASSIGNED_BY_EMAIL' => array('Name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID') . $emailFieldNameSuffix, 'Type' => 'string', 'Filterable' => false, 'Editable' => false, 'Required' => false), 'CREATED_BY_ID' => array('Name' => GetMessage('CRM_FIELD_CREATED_BY_ID'), 'Type' => 'user', 'Filterable' => true, 'Editable' => false, 'Required' => false), 'CREATED_BY_PRINTABLE' => array('Name' => GetMessage('CRM_FIELD_CREATED_BY_ID') . $printableFieldNameSuffix, 'Type' => 'string', 'Filterable' => false, 'Editable' => false, 'Required' => false), 'COMMENTS' => array('Name' => GetMessage('CRM_FIELD_COMMENTS'), 'Type' => 'text', 'Filterable' => false, 'Editable' => true, 'Required' => false), 'NAME' => array('Name' => GetMessage('CRM_FIELD_NAME'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'LAST_NAME' => array('Name' => GetMessage('CRM_FIELD_LAST_NAME'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'SECOND_NAME' => array('Name' => GetMessage('CRM_FIELD_SECOND_NAME'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'BIRTHDATE' => array('Name' => GetMessage('CRM_LEAD_EDIT_FIELD_BIRTHDATE'), 'Type' => 'datetime', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'EMAIL' => array('Name' => GetMessage('CRM_FIELD_EMAIL'), 'Type' => 'email', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'PHONE' => array('Name' => GetMessage('CRM_FIELD_PHONE'), 'Type' => 'phone', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'WEB' => array('Name' => GetMessage('CRM_FIELD_WEB'), 'Type' => 'web', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'IM' => array('Name' => GetMessage('CRM_FIELD_MESSENGER'), 'Type' => 'im', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'COMPANY_TITLE' => array('Name' => GetMessage('CRM_FIELD_COMPANY_TITLE'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'POST' => array('Name' => GetMessage('CRM_FIELD_POST'), 'Type' => 'string', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'FULL_ADDRESS' => array('Name' => GetMessage('CRM_FIELD_ADDRESS'), 'Type' => 'text', 'Filterable' => false, 'Editable' => false, 'Required' => false), 'ADDRESS' => array('Name' => $addressLabels['ADDRESS'], 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS_2' => array('Name' => $addressLabels['ADDRESS_2'], 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS_CITY' => array('Name' => $addressLabels['CITY'], 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS_POSTAL_CODE' => array('Name' => $addressLabels['POSTAL_CODE'], 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS_REGION' => array('Name' => $addressLabels['REGION'], 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS_PROVINCE' => array('Name' => $addressLabels['PROVINCE'], 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'ADDRESS_COUNTRY' => array('Name' => $addressLabels['COUNTRY'], 'Type' => 'text', 'Filterable' => true, 'Editable' => true, 'Required' => false), 'SOURCE_ID' => array('Name' => GetMessage('CRM_FIELD_SOURCE_ID'), 'Type' => 'select', 'Options' => CCrmStatus::GetStatusListEx('SOURCE'), 'Filterable' => true, 'Editable' => true, 'Required' => false), 'SOURCE_DESCRIPTION' => array('Name' => GetMessage('CRM_FIELD_SOURCE_DESCRIPTION'), 'Type' => 'text', 'Filterable' => false, 'Editable' => true, 'Required' => false), "DATE_CREATE" => array("Name" => GetMessage("CRM_LEAD_EDIT_FIELD_DATE_CREATE"), "Type" => "datetime", "Filterable" => true, "Editable" => false, "Required" => false), "DATE_MODIFY" => array("Name" => GetMessage("CRM_LEAD_EDIT_FIELD_DATE_MODIFY"), "Type" => "datetime", "Filterable" => true, "Editable" => false, "Required" => false));
     $ar = CCrmFieldMulti::GetEntityTypeList();
     foreach ($ar as $typeId => $arFields) {
         $arResult[$typeId . '_PRINTABLE'] = array('Name' => GetMessage('CRM_FIELD_MULTI_' . $typeId) . $printableFieldNameSuffix, 'Type' => 'string', "Filterable" => true, "Editable" => false, "Required" => false);
         foreach ($arFields as $valueType => $valueName) {
             $arResult[$typeId . '_' . $valueType] = array('Name' => $valueName, 'Type' => 'string', "Filterable" => true, "Editable" => false, "Required" => false);
             $arResult[$typeId . '_' . $valueType . '_PRINTABLE'] = array('Name' => $valueName . $printableFieldNameSuffix, 'Type' => 'string', "Filterable" => true, "Editable" => false, "Required" => false);
         }
     }
     global $USER_FIELD_MANAGER;
     $CCrmUserType = new CCrmUserType($USER_FIELD_MANAGER, 'CRM_LEAD');
     $CCrmUserType->AddBPFields($arResult, array('PRINTABLE_SUFFIX' => GetMessage("CRM_FIELD_BP_TEXT")));
     return $arResult;
 }
Exemple #4
0
$arResult['ENTITY_ID'] = isset($arParams['ENTITY_ID']) ? $arParams['ENTITY_ID'] : '';
$arResult['ELEMENT_ID'] = isset($arParams['ELEMENT_ID']) ? intval($arParams['ELEMENT_ID']) : 0;
$arResult['TYPE_ID'] = isset($arParams['TYPE_ID']) ? strval($arParams['TYPE_ID']) : '';
$arResult['FM_MNEMONIC'] = 'FM';
if (isset($arParams['FM_MNEMONIC']) && !empty($arParams['FM_MNEMONIC'])) {
    $arResult['FM_MNEMONIC'] = $arParams['FM_MNEMONIC'];
}
if ($arResult['TYPE_ID'] === '') {
    ShowError(GetMessage('CRM_FIELD_MULTI_EDIT_TYPE_ID_NOT_DEFINED'));
    return;
}
$arResult['SKIP_VALUES'] = array();
if (isset($arParams['SKIP_VALUES']) && !empty($arParams['SKIP_VALUES'])) {
    $arResult['SKIP_VALUES'] = $arParams['SKIP_VALUES'];
}
$ar = CCrmFieldMulti::GetEntityTypeList($arResult['TYPE_ID'], false);
foreach ($ar as $valueType => $value) {
    if (in_array($valueType, $arResult['SKIP_VALUES'])) {
        continue;
    }
    $arResult['TYPE_BOX']['REFERENCE'][] = $value;
    $arResult['TYPE_BOX']['REFERENCE_ID'][] = $valueType;
}
$arResult['VALUES'] = array();
if (isset($arParams['VALUES'][$arParams['TYPE_ID']]) && !empty($arParams['VALUES'][$arParams['TYPE_ID']])) {
    foreach ($arParams['VALUES'][$arParams['TYPE_ID']] as $ID => $arValue) {
        if (substr($ID, 0, 1) == 'n' && $arValue['VALUE'] == '') {
            continue;
        }
        $arResult['VALUES'][$ID]['ID'] = $ID;
        $arResult['VALUES'][$ID]['VALUE'] = $arValue['VALUE'];
 public function ListAddHeaders(&$arHeaders, $skipTypes = array(), $skipValueTypes = array())
 {
     if (!is_array($skipTypes)) {
         $skipTypes = array();
     }
     if (!is_array($skipValueTypes)) {
         $skipValueTypes = array();
     }
     $ar = CCrmFieldMulti::GetEntityTypeList();
     foreach ($ar as $typeId => $arFields) {
         if (in_array($typeId, $skipTypes, true)) {
             continue;
         }
         foreach ($arFields as $valueType => $valueName) {
             if (in_array($valueType, $skipValueTypes, true)) {
                 continue;
             }
             $arHeaders[] = array('id' => $typeId . '_' . $valueType, 'name' => $valueName, 'sort' => false, 'default' => $valueType == 'WORK' && ($typeId == 'PHONE' || $typeId == 'EMAIL'), 'editable' => false, 'type' => 'string');
         }
     }
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $arMap = array("MailUserFrom" => "mail_user_from", "MailCrmEntityToArray" => "mail_crm_entity_to", "MailCrmEntityAddressType" => "mail_crm_entity_address_type", "MailSubject" => "mail_subject", "MailText" => "mail_text", "MailMessageType" => "mail_message_type", "MailCharset" => "mail_charset", "DirrectMail" => "dirrect_mail", "MailSite" => "mail_site");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "MailUserFrom") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k . "Array"], $arWorkflowTemplate, $documentType);
                         if (strlen($arCurrentValues[$arMap[$k]]) > 0 && strlen($arCurrentActivity["Properties"][$k]) > 0) {
                             $arCurrentValues[$arMap[$k]] .= ", ";
                         }
                         if (strlen($arCurrentActivity["Properties"][$k]) > 0) {
                             $arCurrentValues[$arMap[$k]] .= $arCurrentActivity["Properties"][$k];
                         }
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     $arCurrentValues[$arMap[$k]] = "";
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     if ($arCurrentValues['dirrect_mail'] != "Y" && $arCurrentValues['dirrect_mail'] != "N") {
         $arCurrentValues['dirrect_mail'] = "Y";
     }
     global $USER_FIELD_MANAGER;
     $arUserFieldType = $USER_FIELD_MANAGER->GetUserType('crm');
     $mailCrmEntityTo = is_array($arCurrentValues) && isset($arCurrentValues['mail_crm_entity_to']) && is_array($arCurrentValues['mail_crm_entity_to']) ? $arCurrentValues['mail_crm_entity_to'] : array();
     $arCurrentValues['mail_crm_entity_to_text'] = '';
     $entityKeyCount = count($mailCrmEntityTo);
     if ($entityKeyCount > 0 && !CCrmEntityHelper::IsEntityKey($mailCrmEntityTo[$entityKeyCount - 1])) {
         $arCurrentValues['mail_crm_entity_to_text'] = array_pop($mailCrmEntityTo);
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName, 'crmEntityToUserField' => array('ENTITY_ID' => 'CRM_' . $documentType[2], 'FIELD_NAME' => 'mail_crm_entity_to', 'USER_TYPE_ID' => 'crm', 'SORT' => 100, 'MULTIPLE' => 'Y', 'MANDATORY' => 'Y', 'EDIT_IN_LIST' => 'Y', 'EDIT_FORM_LABEL' => $arUserFieldType['DESCRIPTION'], 'VALUE' => $mailCrmEntityTo, 'USER_TYPE' => $arUserFieldType, 'SETTINGS' => array('LEAD' => 'Y', 'CONTACT' => 'Y', 'COMPANY' => 'Y', 'DEAL' => 'N')), 'crmEntityAddressTypes' => CCrmFieldMulti::GetEntityTypeList('EMAIL', false)));
 }