public static function CompareFields(array $arFieldsOrig, array $arFieldsModif, array $arOptions = null) { if (!is_array($arOptions)) { $arOptions = array(); } $arMsg = array(); if (isset($arFieldsOrig['TITLE']) && isset($arFieldsModif['TITLE']) && $arFieldsOrig['TITLE'] != $arFieldsModif['TITLE']) { $arMsg[] = array('ENTITY_FIELD' => 'TITLE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_TITLE'), 'EVENT_TEXT_1' => $arFieldsOrig['TITLE'], 'EVENT_TEXT_2' => $arFieldsModif['TITLE']); } if (isset($arFieldsOrig['FM']) && isset($arFieldsModif['FM'])) { $arMsg = array_merge($arMsg, CCrmFieldMulti::CompareFields($arFieldsOrig['FM'], $arFieldsModif['FM'])); } $addressOptions = array(); if (isset($arOptions['ADDRESS_FIELDS'])) { $addressOptions['FIELDS'] = $arOptions['ADDRESS_FIELDS']; } $arMsg = array_merge($arMsg, \Bitrix\Crm\CompanyAddress::prepareChangeEvents($arFieldsOrig, $arFieldsModif, \Bitrix\Crm\EntityAddress::Primary, $addressOptions)); $arMsg = array_merge($arMsg, \Bitrix\Crm\CompanyAddress::prepareChangeEvents($arFieldsOrig, $arFieldsModif, \Bitrix\Crm\EntityAddress::Registered, $addressOptions)); if (isset($arFieldsOrig['BANKING_DETAILS']) && isset($arFieldsModif['BANKING_DETAILS']) && $arFieldsOrig['BANKING_DETAILS'] != $arFieldsModif['BANKING_DETAILS']) { $arMsg[] = array('ENTITY_FIELD' => 'BANKING_DETAILS', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_BANKING_DETAILS'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['BANKING_DETAILS']) ? $arFieldsOrig['BANKING_DETAILS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['BANKING_DETAILS']) ? $arFieldsModif['BANKING_DETAILS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY')); } if (isset($arFieldsOrig['COMPANY_TYPE']) && isset($arFieldsModif['COMPANY_TYPE']) && $arFieldsOrig['COMPANY_TYPE'] != $arFieldsModif['COMPANY_TYPE']) { $arStatus = CCrmStatus::GetStatusList('COMPANY_TYPE'); $arMsg[] = array('ENTITY_FIELD' => 'COMPANY_TYPE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_COMPANY_TYPE'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['COMPANY_TYPE'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['COMPANY_TYPE']))); } if (isset($arFieldsOrig['INDUSTRY']) && isset($arFieldsModif['INDUSTRY']) && $arFieldsOrig['INDUSTRY'] != $arFieldsModif['INDUSTRY']) { $arStatus = CCrmStatus::GetStatusList('INDUSTRY'); $arMsg[] = array('ENTITY_FIELD' => 'INDUSTRY', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_INDUSTRY'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['INDUSTRY'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['INDUSTRY']))); } if (isset($arFieldsOrig['REVENUE']) && isset($arFieldsModif['REVENUE']) && $arFieldsOrig['REVENUE'] != $arFieldsModif['REVENUE'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) { $arStatus = CCrmCurrencyHelper::PrepareListItems(); $arMsg[] = array('ENTITY_FIELD' => 'REVENUE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_REVENUE'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['REVENUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['REVENUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : '')); } if (isset($arFieldsOrig['EMPLOYEES']) && isset($arFieldsModif['EMPLOYEES']) && $arFieldsOrig['EMPLOYEES'] != $arFieldsModif['EMPLOYEES']) { $arStatus = CCrmStatus::GetStatusList('EMPLOYEES'); $arMsg[] = array('ENTITY_FIELD' => 'EMPLOYEES', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_EMPLOYEES'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['EMPLOYEES'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['EMPLOYEES']))); } if (isset($arFieldsOrig['COMMENTS']) && isset($arFieldsModif['COMMENTS']) && $arFieldsOrig['COMMENTS'] != $arFieldsModif['COMMENTS']) { $arMsg[] = array('ENTITY_FIELD' => 'COMMENTS', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_COMMENTS'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['COMMENTS']) ? $arFieldsOrig['COMMENTS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['COMMENTS']) ? $arFieldsModif['COMMENTS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY')); } if (isset($arFieldsOrig['ASSIGNED_BY_ID']) && isset($arFieldsModif['ASSIGNED_BY_ID']) && (int) $arFieldsOrig['ASSIGNED_BY_ID'] != (int) $arFieldsModif['ASSIGNED_BY_ID']) { $arUser = array(); $dbUsers = CUser::GetList($sort_by = 'last_name', $sort_dir = 'asc', array('ID' => implode('|', array(intval($arFieldsOrig['ASSIGNED_BY_ID']), intval($arFieldsModif['ASSIGNED_BY_ID'])))), array('FIELDS' => array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'LOGIN', 'TITLE', 'EMAIL'))); while ($arRes = $dbUsers->Fetch()) { $arUser[$arRes['ID']] = CUser::FormatName(CSite::GetNameFormat(false), $arRes); } $arMsg[] = array('ENTITY_FIELD' => 'ASSIGNED_BY_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_ASSIGNED_BY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arUser, $arFieldsOrig['ASSIGNED_BY_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arUser, $arFieldsModif['ASSIGNED_BY_ID'])); } return $arMsg; }