Example #1
0
 public static function CompareFields($arFieldsOrig, $arFieldsModif, $bCheckPerms = true)
 {
     $arMsg = array();
     if (array_key_exists('QUOTE_NUMBER', $arFieldsModif)) {
         $origQuoteNumber = isset($arFieldsOrig['QUOTE_NUMBER']) ? $arFieldsOrig['QUOTE_NUMBER'] : '';
         $modifQuoteNumber = isset($arFieldsModif['QUOTE_NUMBER']) ? $arFieldsModif['QUOTE_NUMBER'] : '';
         if ($origQuoteNumber != $modifQuoteNumber) {
             $arMsg[] = array('ENTITY_FIELD' => 'QUOTE_NUMBER', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_QUOTE_NUMBER'), 'EVENT_TEXT_1' => !empty($origQuoteNumber) ? $origQuoteNumber : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifQuoteNumber) ? $modifQuoteNumber : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origQuoteNumber, $modifQuoteNumber);
     }
     if (array_key_exists('TITLE', $arFieldsModif)) {
         $origTitle = isset($arFieldsOrig['TITLE']) ? $arFieldsOrig['TITLE'] : '';
         $modifTitle = isset($arFieldsModif['TITLE']) ? $arFieldsModif['TITLE'] : '';
         if ($origTitle != $modifTitle) {
             $arMsg[] = array('ENTITY_FIELD' => 'TITLE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_TITLE'), 'EVENT_TEXT_1' => !empty($origTitle) ? $origTitle : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifTitle) ? $modifTitle : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origTitle, $modifTitle);
     }
     if (array_key_exists('LEAD_ID', $arFieldsModif)) {
         $origLeadId = isset($arFieldsOrig['LEAD_ID']) ? intval($arFieldsOrig['LEAD_ID']) : 0;
         $modifLeadId = isset($arFieldsModif['LEAD_ID']) ? intval($arFieldsModif['LEAD_ID']) : 0;
         if ($origLeadId != $modifLeadId) {
             $arLead = array();
             $arFilterTmp = array('@ID' => array($origLeadId, $modifLeadId));
             if (!$bCheckPerms) {
                 $arFilterTmp["CHECK_PERMISSIONS"] = "N";
             }
             $dbRes = CCrmLead::GetListEx(array('TITLE' => 'ASC'), $arFilterTmp);
             while ($arRes = $dbRes->Fetch()) {
                 $arLead[$arRes['ID']] = $arRes['TITLE'];
             }
             $arMsg[] = array('ENTITY_FIELD' => 'LEAD_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_LEAD_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arLead, $origLeadId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arLead, $modifLeadId));
         }
         unset($origLeadId, $modifLeadId);
     }
     if (array_key_exists('DEAL_ID', $arFieldsModif)) {
         $origDealId = isset($arFieldsOrig['DEAL_ID']) ? intval($arFieldsOrig['DEAL_ID']) : 0;
         $modifDealId = isset($arFieldsModif['DEAL_ID']) ? intval($arFieldsModif['DEAL_ID']) : 0;
         if ($origDealId != $modifDealId) {
             $arDeal = array();
             $arFilterTmp = array('ID' => array($origDealId, $modifDealId));
             if (!$bCheckPerms) {
                 $arFilterTmp["CHECK_PERMISSIONS"] = "N";
             }
             $dbRes = CCrmDeal::GetList(array('TITLE' => 'ASC'), $arFilterTmp);
             while ($arRes = $dbRes->Fetch()) {
                 $arDeal[$arRes['ID']] = $arRes['TITLE'];
             }
             $arMsg[] = array('ENTITY_FIELD' => 'DEAL_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_DEAL_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arDeal, $origDealId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arDeal, $modifDealId));
         }
         unset($origDealId, $modifDealId);
     }
     if (array_key_exists('COMPANY_ID', $arFieldsModif)) {
         $origCompanyId = isset($arFieldsOrig['COMPANY_ID']) ? intval($arFieldsOrig['COMPANY_ID']) : 0;
         $modifCompanyId = isset($arFieldsModif['COMPANY_ID']) ? intval($arFieldsModif['COMPANY_ID']) : 0;
         if ($origCompanyId != $modifCompanyId) {
             $arCompany = array();
             $arFilterTmp = array('ID' => array($origCompanyId, $modifCompanyId));
             if (!$bCheckPerms) {
                 $arFilterTmp["CHECK_PERMISSIONS"] = "N";
             }
             $dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), $arFilterTmp);
             while ($arRes = $dbRes->Fetch()) {
                 $arCompany[$arRes['ID']] = $arRes['TITLE'];
             }
             $arMsg[] = array('ENTITY_FIELD' => 'COMPANY_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_COMPANY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arCompany, $origCompanyId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arCompany, $modifCompanyId));
         }
         unset($origCompanyId, $modifCompanyId);
     }
     if (array_key_exists('CONTACT_ID', $arFieldsModif)) {
         $origContactId = isset($arFieldsOrig['CONTACT_ID']) ? intval($arFieldsOrig['CONTACT_ID']) : 0;
         $modifContactId = isset($arFieldsModif['CONTACT_ID']) ? intval($arFieldsModif['CONTACT_ID']) : 0;
         if ($origContactId != $modifContactId) {
             $arContact = array();
             $arFilterTmp = array('@ID' => array($origContactId, $modifContactId));
             if (!$bCheckPerms) {
                 $arFilterTmp["CHECK_PERMISSIONS"] = "N";
             }
             $dbRes = CCrmContact::GetListEx(array(), $arFilterTmp);
             while ($arRes = $dbRes->Fetch()) {
                 $arContact[$arRes['ID']] = CCrmContact::PrepareFormattedName($arRes);
             }
             $arMsg[] = array('ENTITY_FIELD' => 'CONTACT_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CONTACT_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arContact, $origContactId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arContact, $modifContactId));
         }
         unset($origContactId, $modifContactId);
     }
     if (array_key_exists('ASSIGNED_BY_ID', $arFieldsModif)) {
         $origAssignedById = isset($arFieldsOrig['ASSIGNED_BY_ID']) ? intval($arFieldsOrig['ASSIGNED_BY_ID']) : 0;
         $modifAssignedById = isset($arFieldsModif['ASSIGNED_BY_ID']) ? intval($arFieldsModif['ASSIGNED_BY_ID']) : 0;
         if ($origAssignedById != $modifAssignedById) {
             $arUser = array();
             $dbUsers = CUser::GetList($sort_by = 'last_name', $sort_dir = 'asc', array('ID' => implode('|', array(intval($origAssignedById), intval($modifAssignedById)))), 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_QUOTE_FIELD_COMPARE_ASSIGNED_BY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arUser, $origAssignedById), 'EVENT_TEXT_2' => CrmCompareFieldsList($arUser, $modifAssignedById));
         }
         unset($origAssignedById, $modifAssignedById);
     }
     if (array_key_exists('STATUS_ID', $arFieldsModif)) {
         $origStatusId = isset($arFieldsOrig['STATUS_ID']) ? $arFieldsOrig['STATUS_ID'] : '';
         $modifStatusId = isset($arFieldsModif['STATUS_ID']) ? $arFieldsModif['STATUS_ID'] : '';
         if ($origStatusId != $modifStatusId) {
             $arStatus = CCrmStatus::GetStatusList('QUOTE_STATUS');
             $arMsg[] = array('ENTITY_FIELD' => 'STATUS_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_STATUS_ID'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $origStatusId)), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $modifStatusId)));
         }
         unset($origStatusId, $modifStatusId);
     }
     if (array_key_exists('COMMENTS', $arFieldsModif)) {
         $origComments = isset($arFieldsOrig['COMMENTS']) ? $arFieldsOrig['COMMENTS'] : '';
         $modifComments = isset($arFieldsModif['COMMENTS']) ? $arFieldsModif['COMMENTS'] : '';
         if ($origComments != $modifComments) {
             $arMsg[] = array('ENTITY_FIELD' => 'COMMENTS', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_COMMENTS'), 'EVENT_TEXT_1' => !empty($origComments) ? $origComments : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifComments) ? $modifComments : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origComments, $modifComments);
     }
     if (array_key_exists('CONTENT', $arFieldsModif)) {
         $origContent = isset($arFieldsOrig['CONTENT']) ? $arFieldsOrig['CONTENT'] : '';
         $modifContent = isset($arFieldsModif['CONTENT']) ? $arFieldsModif['CONTENT'] : '';
         if ($origContent != $modifContent) {
             $arMsg[] = array('ENTITY_FIELD' => 'CONTENT', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CONTENT'), 'EVENT_TEXT_1' => !empty($origContent) ? $origContent : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifContent) ? $modifContent : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origContent, $modifContent);
     }
     if (array_key_exists('TERMS', $arFieldsModif)) {
         $origTerms = isset($arFieldsOrig['TERMS']) ? $arFieldsOrig['TERMS'] : '';
         $modifTerms = isset($arFieldsModif['TERMS']) ? $arFieldsModif['TERMS'] : '';
         if ($origTerms != $modifTerms) {
             $arMsg[] = array('ENTITY_FIELD' => 'TERMS', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_TERMS'), 'EVENT_TEXT_1' => !empty($origTerms) ? $origTerms : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifTerms) ? $modifTerms : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origTerms, $modifTerms);
     }
     if (array_key_exists('OPPORTUNITY', $arFieldsModif) || array_key_exists('CURRENCY_ID', $arFieldsModif)) {
         $origOpportunity = isset($arFieldsOrig['OPPORTUNITY']) ? round(doubleval($arFieldsOrig['OPPORTUNITY']), 2) : 0.0;
         $modifOpportunity = isset($arFieldsModif['OPPORTUNITY']) ? round(doubleval($arFieldsModif['OPPORTUNITY']), 2) : $origOpportunity;
         $origCurrencyId = isset($arFieldsOrig['CURRENCY_ID']) ? $arFieldsOrig['CURRENCY_ID'] : '';
         $modifCurrencyId = isset($arFieldsModif['CURRENCY_ID']) ? $arFieldsModif['CURRENCY_ID'] : $origCurrencyId;
         if ($origOpportunity != $modifOpportunity || $origCurrencyId != $modifCurrencyId) {
             $arStatus = CCrmCurrencyHelper::PrepareListItems();
             $arMsg[] = array('ENTITY_FIELD' => 'OPPORTUNITY', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_OPPORTUNITY'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $origCurrencyId, '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $modifCurrencyId, '')) != '' ? ' (' . $val . ')' : ''));
         }
         unset($origOpportunity, $modifOpportunity, $origCurrencyId, $modifCurrencyId);
     }
     if (array_key_exists('TAX_VALUE', $arFieldsModif) || array_key_exists('CURRENCY_ID', $arFieldsModif)) {
         if (isset($arFieldsOrig['TAX_VALUE']) && isset($arFieldsModif['TAX_VALUE']) && $arFieldsOrig['TAX_VALUE'] != $arFieldsModif['TAX_VALUE'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) {
             $arStatus = CCrmCurrencyHelper::PrepareListItems();
             $arMsg[] = array('ENTITY_FIELD' => 'TAX_VALUE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_TAX_VALUE'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''));
         }
     }
     if (array_key_exists('BEGINDATE', $arFieldsOrig) && array_key_exists('BEGINDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) != $arFieldsModif['BEGINDATE'] && $arFieldsOrig['BEGINDATE'] != $arFieldsModif['BEGINDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'BEGINDATE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_BEGINDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['BEGINDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['BEGINDATE']) ? $arFieldsModif['BEGINDATE'] : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('CLOSEDATE', $arFieldsOrig) && array_key_exists('CLOSEDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) != $arFieldsModif['CLOSEDATE'] && $arFieldsOrig['CLOSEDATE'] != $arFieldsModif['CLOSEDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'CLOSEDATE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CLOSEDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['CLOSEDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['CLOSEDATE']) ? $arFieldsModif['CLOSEDATE'] : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('OPENED', $arFieldsModif)) {
         if (isset($arFieldsOrig['OPENED']) && isset($arFieldsModif['OPENED']) && $arFieldsOrig['OPENED'] != $arFieldsModif['OPENED']) {
             $arMsg[] = array('ENTITY_FIELD' => 'OPENED', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_OPENED'), 'EVENT_TEXT_1' => $arFieldsOrig['OPENED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'EVENT_TEXT_2' => $arFieldsModif['OPENED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'));
         }
     }
     if (array_key_exists('CLOSED', $arFieldsModif)) {
         if (isset($arFieldsOrig['CLOSED']) && isset($arFieldsModif['CLOSED']) && $arFieldsOrig['CLOSED'] != $arFieldsModif['CLOSED']) {
             $arMsg[] = array('ENTITY_FIELD' => 'CLOSED', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CLOSED'), 'EVENT_TEXT_1' => $arFieldsOrig['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'EVENT_TEXT_2' => $arFieldsModif['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'));
         }
     }
     // person type
     if (array_key_exists('PERSON_TYPE_ID', $arFieldsModif)) {
         $bPersonTypeChanged = isset($arFieldsOrig['PERSON_TYPE_ID']) && isset($arFieldsModif['PERSON_TYPE_ID']) && intval($arFieldsOrig['PERSON_TYPE_ID']) !== intval($arFieldsModif['PERSON_TYPE_ID']);
         if ($bPersonTypeChanged) {
             $arPersonTypes = CCrmPaySystem::getPersonTypesList();
             if ($bPersonTypeChanged) {
                 $arMsg[] = array('ENTITY_FIELD' => 'PERSON_TYPE_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_PERSON_TYPE_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arPersonTypes, $arFieldsOrig['PERSON_TYPE_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arPersonTypes, $arFieldsModif['PERSON_TYPE_ID']));
             }
         }
     }
     if (array_key_exists('LOCATION_ID', $arFieldsModif)) {
         $origLocationId = isset($arFieldsOrig['LOCATION_ID']) ? $arFieldsOrig['LOCATION_ID'] : '';
         $modifLocationId = isset($arFieldsModif['LOCATION_ID']) ? $arFieldsModif['LOCATION_ID'] : '';
         if ($origLocationId != $modifLocationId) {
             $origLocationString = $modifLocationString = '';
             if (IsModuleInstalled('sale') && CModule::IncludeModule('sale')) {
                 $location = new CSaleLocation();
                 $origLocationString = $origLocationId > 0 ? $location->GetLocationString($origLocationId) : '';
                 $modifLocationString = $modifLocationId > 0 ? $location->GetLocationString($modifLocationId) : '';
             }
             if (empty($origLocationString) && intval($origLocationId) > 0) {
                 $origLocationString = '[' . $origLocationId . ']';
             }
             if (empty($modifLocationString) && intval($modifLocationId) > 0) {
                 $modifLocationString = '[' . $modifLocationId . ']';
             }
             $arMsg[] = array('ENTITY_FIELD' => 'LOCATION_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_LOCATION_ID'), 'EVENT_TEXT_1' => $origLocationString, 'EVENT_TEXT_2' => $modifLocationString);
             unset($origLocationString, $modifLocationString);
         }
         unset($origLocationId, $modifLocationId);
     }
     $origClientFieldValue = $modifClientFieldValue = '';
     foreach (self::$clientFields as $fieldName) {
         if (array_key_exists($fieldName, $arFieldsModif)) {
             $origClientFieldValue = isset($arFieldsOrig[$fieldName]) ? $arFieldsOrig[$fieldName] : '';
             $modifClientFieldValue = isset($arFieldsModif[$fieldName]) ? $arFieldsModif[$fieldName] : '';
             if ($origClientFieldValue != $modifClientFieldValue) {
                 $arMsg[] = array('ENTITY_FIELD' => $fieldName, 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_' . $fieldName), 'EVENT_TEXT_1' => !empty($origClientFieldValue) ? $origClientFieldValue : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifClientFieldValue) ? $modifClientFieldValue : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
             }
         }
     }
     unset($fieldName, $origClientFieldValue, $modifClientFieldValue);
     // Processing of the files
     if (array_key_exists('STORAGE_TYPE_ID', $arFieldsModif) && array_key_exists('STORAGE_ELEMENT_IDS', $arFieldsModif) && strlen($arFieldsModif['STORAGE_ELEMENT_IDS']) > 0) {
         $newStorageTypeID = isset($arFieldsModif['STORAGE_TYPE_ID']) ? intval($arFieldsModif['STORAGE_TYPE_ID']) : CCrmQuoteStorageType::Undefined;
         $oldStorageTypeID = isset($arFieldsOrig['STORAGE_TYPE_ID']) ? intval($arFieldsOrig['STORAGE_TYPE_ID']) : CCrmQuoteStorageType::Undefined;
         self::PrepareStorageElementIDs($arFieldsModif);
         $newElementIDs = $arFieldsModif['STORAGE_ELEMENT_IDS'];
         self::PrepareStorageElementIDs($arFieldsOrig);
         $oldElementIDs = $arFieldsOrig['STORAGE_ELEMENT_IDS'];
         if ($newStorageTypeID === $oldStorageTypeID && is_array($newElementIDs) && is_array($oldElementIDs)) {
             $arRemovedElementIDs = array_values(array_diff($oldElementIDs, $newElementIDs));
             if (!empty($arRemovedElementIDs)) {
                 foreach ($arRemovedElementIDs as $elementID) {
                     self::PrepareFileEvent($oldStorageTypeID, $elementID, 'REMOVE', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
             }
             unset($arRemovedElementIDs);
             $arAddedElementIDs = array_values(array_diff($newElementIDs, $oldElementIDs));
             if (!empty($arAddedElementIDs)) {
                 foreach ($arAddedElementIDs as $elementID) {
                     self::PrepareFileEvent($newStorageTypeID, $elementID, 'ADD', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
             }
             unset($arAddedElementIDs);
         } else {
             if ($newStorageTypeID !== $oldStorageTypeID && is_array($newElementIDs) && is_array($oldElementIDs)) {
                 foreach ($oldElementIDs as $elementID) {
                     self::PrepareFileEvent($oldStorageTypeID, $elementID, 'REMOVE', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
                 foreach ($newElementIDs as $elementID) {
                     self::PrepareFileEvent($newStorageTypeID, $elementID, 'ADD', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
             }
         }
         unset($newStorageTypeID, $oldStorageTypeID, $newElementIDs, $oldElementIDs);
     }
     return $arMsg;
 }
Example #2
0
 public static function CompareFields($arFieldsOrig, $arFieldsModif, $bCheckPerms = true)
 {
     $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['COMPANY_ID']) && isset($arFieldsModif['COMPANY_ID']) && (int) $arFieldsOrig['COMPANY_ID'] != (int) $arFieldsModif['COMPANY_ID']) {
         $arCompany = array();
         $arFilterTmp = array('ID' => array($arFieldsOrig['COMPANY_ID'], $arFieldsModif['COMPANY_ID']));
         if (!$bCheckPerms) {
             $arFilterTmp["CHECK_PERMISSIONS"] = "N";
         }
         $dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), $arFilterTmp);
         while ($arRes = $dbRes->Fetch()) {
             $arCompany[$arRes['ID']] = $arRes['TITLE'];
         }
         $arMsg[] = array('ENTITY_FIELD' => 'COMPANY_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_COMPANY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arCompany, $arFieldsOrig['COMPANY_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arCompany, $arFieldsModif['COMPANY_ID']));
     }
     if (isset($arFieldsOrig['CONTACT_ID']) && isset($arFieldsModif['CONTACT_ID']) && (int) $arFieldsOrig['CONTACT_ID'] != (int) $arFieldsModif['CONTACT_ID']) {
         $arContact = array();
         $arFilterTmp = array('ID' => array($arFieldsOrig['CONTACT_ID'], $arFieldsModif['CONTACT_ID']));
         if (!$bCheckPerms) {
             $arFilterTmp["CHECK_PERMISSIONS"] = "N";
         }
         $dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), $arFilterTmp);
         while ($arRes = $dbRes->Fetch()) {
             $arContact[$arRes['ID']] = $arRes['LAST_NAME'] . ' ' . $arRes['NAME'];
         }
         $arMsg[] = array('ENTITY_FIELD' => 'CONTACT_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_CONTACT_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arContact, $arFieldsOrig['CONTACT_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arContact, $arFieldsModif['CONTACT_ID']));
     }
     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('SELECT' => array('NAME', 'SECOND_NAME', 'LAST_NAME', 'LOGIN', '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']));
     }
     if (isset($arFieldsOrig['STAGE_ID']) && isset($arFieldsModif['STAGE_ID']) && $arFieldsOrig['STAGE_ID'] != $arFieldsModif['STAGE_ID']) {
         $arStatus = CCrmStatus::GetStatusList('DEAL_STAGE');
         $arMsg[] = array('ENTITY_FIELD' => 'STAGE_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_DEAL_STAGE'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['STAGE_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['STAGE_ID'])));
     }
     /*
     if (isset($arFieldsOrig['STATE_ID']) && isset($arFieldsModif['STATE_ID'])
     	&& $arFieldsOrig['STATE_ID'] != $arFieldsModif['STATE_ID'])
     {
     	$CCrmStatus = new CCrmStatus('DEAL_STATE');
     	$arStatusOrig = $CCrmStatus->GetStatusByStatusId($arFieldsOrig['STATE_ID']);
     	$arStatusModif = $CCrmStatus->GetStatusByStatusId($arFieldsModif['STATE_ID']);
     
     	$arMsg[] = Array(
     		'ENTITY_FIELD' => 'STATE_ID',
     		'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_DEAL_STATE'),
     		'EVENT_TEXT_1' => isset($arStatusOrig['NAME'])? $arStatusOrig['NAME']: GetMessage('CRM_FIELD_COMPARE_EMPTY'),
     		'EVENT_TEXT_2' => isset($arStatusModif['NAME'])? $arStatusModif['NAME']: GetMessage('CRM_FIELD_COMPARE_EMPTY'),
     	);
     }
     */
     if (isset($arFieldsOrig['TYPE_ID']) && isset($arFieldsModif['TYPE_ID']) && $arFieldsOrig['TYPE_ID'] != $arFieldsModif['TYPE_ID']) {
         $arStatus = CCrmStatus::GetStatusList('DEAL_TYPE');
         $arMsg[] = array('ENTITY_FIELD' => 'TYPE_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_DEAL_TYPE'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['TYPE_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['TYPE_ID'])));
     }
     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['PRODUCT_ID']) && isset($arFieldsModif['PRODUCT_ID'])
     //			&& $arFieldsOrig['PRODUCT_ID'] != $arFieldsModif['PRODUCT_ID'])
     //		{
     //			$arStatus = CCrmStatus::GetStatusList('PRODUCT');
     //			$arMsg[] = Array(
     //				'ENTITY_FIELD' => 'PRODUCT_ID',
     //				'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_PRODUCT'),
     //				'EVENT_TEXT_1' => CrmCompareFieldsList($arStatus, $arFieldsOrig['PRODUCT_ID']),
     //				'EVENT_TEXT_2' => CrmCompareFieldsList($arStatus, $arFieldsModif['PRODUCT_ID'])
     //			);
     //		}
     if (isset($arFieldsOrig['OPPORTUNITY']) && isset($arFieldsModif['OPPORTUNITY']) && $arFieldsOrig['OPPORTUNITY'] != $arFieldsModif['OPPORTUNITY'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) {
         $arStatus = CCrmCurrencyHelper::PrepareListItems();
         $arMsg[] = array('ENTITY_FIELD' => 'OPPORTUNITY', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_OPPORTUNITY'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''));
     }
     if (isset($arFieldsOrig['TAX_VALUE']) && isset($arFieldsModif['TAX_VALUE']) && $arFieldsOrig['TAX_VALUE'] != $arFieldsModif['TAX_VALUE'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) {
         $arStatus = CCrmCurrencyHelper::PrepareListItems();
         $arMsg[] = array('ENTITY_FIELD' => 'TAX_VALUE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_TAX_VALUE'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''));
     }
     if (isset($arFieldsOrig['PROBABILITY']) && isset($arFieldsModif['PROBABILITY']) && $arFieldsOrig['PROBABILITY'] != $arFieldsModif['PROBABILITY']) {
         $arMsg[] = array('ENTITY_FIELD' => 'PROBABILITY', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_PROBABILITY'), 'EVENT_TEXT_1' => intval($arFieldsOrig['PROBABILITY']) . '%', 'EVENT_TEXT_2' => intval($arFieldsModif['PROBABILITY']) . '%');
     }
     if (array_key_exists('BEGINDATE', $arFieldsOrig) && array_key_exists('BEGINDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) != $arFieldsModif['BEGINDATE'] && $arFieldsOrig['BEGINDATE'] != $arFieldsModif['BEGINDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'BEGINDATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_BEGINDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['BEGINDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['BEGINDATE']) ? $arFieldsModif['BEGINDATE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('CLOSEDATE', $arFieldsOrig) && array_key_exists('CLOSEDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) != $arFieldsModif['CLOSEDATE'] && $arFieldsOrig['CLOSEDATE'] != $arFieldsModif['CLOSEDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'CLOSEDATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_CLOSEDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['CLOSEDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['CLOSEDATE']) ? $arFieldsModif['CLOSEDATE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('EVENT_DATE', $arFieldsOrig) && array_key_exists('EVENT_DATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['EVENT_DATE'])) != $arFieldsModif['EVENT_DATE'] && $arFieldsOrig['EVENT_DATE'] != $arFieldsModif['EVENT_DATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'EVENT_DATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_EVENT_DATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['EVENT_DATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['EVENT_DATE'])) : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['EVENT_DATE']) ? $arFieldsModif['EVENT_DATE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['EVENT_ID']) && isset($arFieldsModif['EVENT_ID']) && $arFieldsOrig['EVENT_ID'] != $arFieldsModif['EVENT_ID']) {
         $arStatus = CCrmStatus::GetStatusList('EVENT_TYPE');
         $arMsg[] = array('ENTITY_FIELD' => 'EVENT_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_EVENT_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arStatus, $arFieldsOrig['EVENT_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arStatus, $arFieldsModif['EVENT_ID']));
     }
     if (isset($arFieldsOrig['EVENT_DESCRIPTION']) && isset($arFieldsModif['EVENT_DESCRIPTION']) && $arFieldsOrig['EVENT_DESCRIPTION'] != $arFieldsModif['EVENT_DESCRIPTION']) {
         $arMsg[] = array('ENTITY_FIELD' => 'EVENT_DESCRIPTION', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_EVENT_DESCRIPTION'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['EVENT_DESCRIPTION']) ? $arFieldsOrig['EVENT_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['EVENT_DESCRIPTION']) ? $arFieldsModif['EVENT_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['CLOSED']) && isset($arFieldsModif['CLOSED']) && $arFieldsOrig['CLOSED'] != $arFieldsModif['CLOSED']) {
         $arMsg[] = array('ENTITY_FIELD' => 'CLOSED', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_CLOSED'), 'EVENT_TEXT_1' => $arFieldsOrig['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'EVENT_TEXT_2' => $arFieldsModif['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'));
     }
     $origLocationId = isset($arFieldsOrig['LOCATION_ID']) ? $arFieldsOrig['LOCATION_ID'] : '';
     $modifLocationId = isset($arFieldsModif['LOCATION_ID']) ? $arFieldsModif['LOCATION_ID'] : '';
     if ($origLocationId != $modifLocationId) {
         $origLocationString = $modifLocationString = '';
         if (IsModuleInstalled('sale') && CModule::IncludeModule('sale')) {
             $location = new CSaleLocation();
             $origLocationString = $origLocationId > 0 ? $location->GetLocationString($origLocationId) : '';
             $modifLocationString = $modifLocationId > 0 ? $location->GetLocationString($modifLocationId) : '';
         }
         if (empty($origLocationString) && intval($origLocationId) > 0) {
             $origLocationString = '[' . $origLocationId . ']';
         }
         if (empty($modifLocationString) && intval($modifLocationId) > 0) {
             $modifLocationString = '[' . $modifLocationId . ']';
         }
         $arMsg[] = array('ENTITY_FIELD' => 'LOCATION_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_LOCATION_ID'), 'EVENT_TEXT_1' => $origLocationString, 'EVENT_TEXT_2' => $modifLocationString);
         unset($origLocationString, $modifLocationString);
     }
     unset($origLocationId, $modifLocationId);
     return $arMsg;
 }
Example #3
0
 public static function CompareFields($arFieldsOrig, $arFieldsModif)
 {
     $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']));
     }
     if (isset($arFieldsOrig['ADDRESS']) && isset($arFieldsModif['ADDRESS']) && $arFieldsOrig['ADDRESS'] != $arFieldsModif['ADDRESS']) {
         $arMsg[] = array('ENTITY_FIELD' => 'ADDRESS', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_ADDRESS'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['ADDRESS']) ? $arFieldsOrig['ADDRESS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['ADDRESS']) ? $arFieldsModif['ADDRESS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['ADDRESS_LEGAL']) && isset($arFieldsModif['ADDRESS_LEGAL']) && $arFieldsOrig['ADDRESS_LEGAL'] != $arFieldsModif['ADDRESS_LEGAL']) {
         $arMsg[] = array('ENTITY_FIELD' => 'ADDRESS_LEGAL', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_ADDRESS_LEGAL'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['ADDRESS_LEGAL']) ? $arFieldsOrig['ADDRESS_LEGAL'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['ADDRESS_LEGAL']) ? $arFieldsModif['ADDRESS_LEGAL'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     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('SELECT' => array('NAME', 'SECOND_NAME', 'LAST_NAME', 'LOGIN', '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;
 }
Example #4
0
 public static function CompareFields($arFieldsOrig, $arFieldsModif)
 {
     $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' => !empty($arFieldsOrig['TITLE']) ? $arFieldsOrig['TITLE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['TITLE']) ? $arFieldsModif['TITLE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['NAME']) && isset($arFieldsModif['NAME']) && $arFieldsOrig['NAME'] != $arFieldsModif['NAME']) {
         $arMsg[] = array('ENTITY_FIELD' => 'NAME', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_NAME'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['NAME']) ? $arFieldsOrig['NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['NAME']) ? $arFieldsModif['NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['LAST_NAME']) && isset($arFieldsModif['LAST_NAME']) && $arFieldsOrig['LAST_NAME'] != $arFieldsModif['LAST_NAME']) {
         $arMsg[] = array('ENTITY_FIELD' => 'LAST_NAME', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_LAST_NAME'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['LAST_NAME']) ? $arFieldsOrig['LAST_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['LAST_NAME']) ? $arFieldsModif['LAST_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['SECOND_NAME']) && isset($arFieldsModif['SECOND_NAME']) && $arFieldsOrig['SECOND_NAME'] != $arFieldsModif['SECOND_NAME']) {
         $arMsg[] = array('ENTITY_FIELD' => 'SECOND_NAME', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_SECOND_NAME'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['SECOND_NAME']) ? $arFieldsOrig['SECOND_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['SECOND_NAME']) ? $arFieldsModif['SECOND_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['FM']) && isset($arFieldsModif['FM'])) {
         $arMsg = array_merge($arMsg, CCrmFieldMulti::CompareFields($arFieldsOrig['FM'], $arFieldsModif['FM']));
     }
     if (isset($arFieldsOrig['POST']) && isset($arFieldsModif['POST']) && $arFieldsOrig['POST'] != $arFieldsModif['POST']) {
         $arMsg[] = array('ENTITY_FIELD' => 'POST', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_POST'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['POST']) ? $arFieldsOrig['POST'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['POST']) ? $arFieldsModif['POST'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     $arMsg = array_merge($arMsg, \Bitrix\Crm\LeadAddress::prepareChangeEvents($arFieldsOrig, $arFieldsModif));
     if (isset($arFieldsOrig['STATUS_ID']) && isset($arFieldsModif['STATUS_ID']) && $arFieldsOrig['STATUS_ID'] != $arFieldsModif['STATUS_ID']) {
         $arStatus = CCrmStatus::GetStatusList('STATUS');
         $arMsg[] = array('ENTITY_FIELD' => 'STATUS_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_STATUS_ID'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['STATUS_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['STATUS_ID'])));
     }
     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['STATUS_DESCRIPTION']) && isset($arFieldsModif['STATUS_DESCRIPTION']) && $arFieldsOrig['STATUS_DESCRIPTION'] != $arFieldsModif['STATUS_DESCRIPTION']) {
         $arMsg[] = array('ENTITY_FIELD' => 'STATUS_DESCRIPTION', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_STATUS_DESCRIPTION'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['STATUS_DESCRIPTION']) ? $arFieldsOrig['STATUS_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['STATUS_DESCRIPTION']) ? $arFieldsModif['STATUS_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['OPPORTUNITY']) && isset($arFieldsModif['OPPORTUNITY']) && $arFieldsOrig['OPPORTUNITY'] != $arFieldsModif['OPPORTUNITY'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) {
         $arStatus = CCrmCurrencyHelper::PrepareListItems();
         $arMsg[] = array('ENTITY_FIELD' => 'OPPORTUNITY', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_OPPORTUNITY'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''));
     }
     if (isset($arFieldsOrig['SOURCE_ID']) && isset($arFieldsModif['SOURCE_ID']) && $arFieldsOrig['SOURCE_ID'] != $arFieldsModif['SOURCE_ID']) {
         $arStatus = CCrmStatus::GetStatusList('SOURCE');
         $arMsg[] = array('ENTITY_FIELD' => 'SOURCE_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_SOURCE_ID'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['SOURCE_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['SOURCE_ID'])));
     }
     //		if (isset($arFieldsOrig['PRODUCT_ID']) && isset($arFieldsModif['PRODUCT_ID'])
     //			&& $arFieldsOrig['PRODUCT_ID'] != $arFieldsModif['PRODUCT_ID'])
     //		{
     //			$arStatus = CCrmStatus::GetStatusList('PRODUCT');
     //			$arMsg[] = Array(
     //				'ENTITY_FIELD' => 'PRODUCT_ID',
     //				'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_PRODUCT'),
     //				'EVENT_TEXT_1' => CrmCompareFieldsList($arStatus, $arFieldsOrig['PRODUCT_ID']),
     //				'EVENT_TEXT_2' => CrmCompareFieldsList($arStatus, $arFieldsModif['PRODUCT_ID'])
     //			);
     //		}
     if (isset($arFieldsOrig['COMPANY_TITLE']) && isset($arFieldsModif['COMPANY_TITLE']) && $arFieldsOrig['COMPANY_TITLE'] != $arFieldsModif['COMPANY_TITLE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'COMPANY_TITLE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_COMPANY_TITLE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['COMPANY_TITLE']) ? $arFieldsOrig['COMPANY_TITLE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['COMPANY_TITLE']) ? $arFieldsModif['COMPANY_TITLE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['SOURCE_DESCRIPTION']) && isset($arFieldsModif['SOURCE_DESCRIPTION']) && $arFieldsOrig['SOURCE_DESCRIPTION'] != $arFieldsModif['SOURCE_DESCRIPTION']) {
         $arMsg[] = array('ENTITY_FIELD' => 'SOURCE_DESCRIPTION', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_SOURCE_DESCRIPTION'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['SOURCE_DESCRIPTION']) ? $arFieldsOrig['SOURCE_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['SOURCE_DESCRIPTION']) ? $arFieldsModif['SOURCE_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['ASSIGNED_BY_ID']) && isset($arFieldsModif['ASSIGNED_BY_ID']) && $arFieldsOrig['ASSIGNED_BY_ID'] != $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('SELECT' => array('NAME', 'SECOND_NAME', 'LAST_NAME', 'LOGIN', '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']));
     }
     if (isset($arFieldsOrig['BIRTHDATE']) || isset($arFieldsModif['BIRTHDATE'])) {
         $origBirthdate = isset($arFieldsOrig['BIRTHDATE']) ? $arFieldsOrig['BIRTHDATE'] : '';
         $modifBirthdate = isset($arFieldsModif['BIRTHDATE']) ? $arFieldsModif['BIRTHDATE'] : '';
         if ($origBirthdate !== $modifBirthdate) {
             $arMsg[] = array('ENTITY_FIELD' => 'BIRTHDATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_BIRTHDATE'), 'EVENT_TEXT_1' => $origBirthdate !== '' ? $origBirthdate : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => $modifBirthdate !== '' ? $modifBirthdate : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
         }
     }
     return $arMsg;
 }
Example #5
0
 public static function CompareFields(array $arFieldsOrig, array $arFieldsModif, array $arOptions = null)
 {
     if (!is_array($arOptions)) {
         $arOptions = array();
     }
     $arMsg = array();
     if (isset($arFieldsOrig['HONORIFIC']) || isset($arFieldsModif['HONORIFIC'])) {
         $origHonorific = isset($arFieldsOrig['HONORIFIC']) ? $arFieldsOrig['HONORIFIC'] : '';
         $modifHonrific = isset($arFieldsModif['HONORIFIC']) ? $arFieldsModif['HONORIFIC'] : '';
         if ($origHonorific !== $modifHonrific) {
             $arMsg[] = array('ENTITY_FIELD' => 'HONORIFIC', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_HONORIFIC'), 'EVENT_TEXT_1' => $origHonorific !== '' ? $origHonorific : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => $modifHonrific !== '' ? $modifHonrific : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
         }
     }
     if (isset($arFieldsOrig['NAME']) && isset($arFieldsModif['NAME']) && $arFieldsOrig['NAME'] != $arFieldsModif['NAME']) {
         $arMsg[] = array('ENTITY_FIELD' => 'NAME', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_NAME'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['NAME']) ? $arFieldsOrig['NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['NAME']) ? $arFieldsModif['NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['LAST_NAME']) && isset($arFieldsModif['LAST_NAME']) && $arFieldsOrig['LAST_NAME'] != $arFieldsModif['LAST_NAME']) {
         $arMsg[] = array('ENTITY_FIELD' => 'LAST_NAME', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_LAST_NAME'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['LAST_NAME']) ? $arFieldsOrig['LAST_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['LAST_NAME']) ? $arFieldsModif['LAST_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['SECOND_NAME']) && isset($arFieldsModif['SECOND_NAME']) && $arFieldsOrig['SECOND_NAME'] != $arFieldsModif['SECOND_NAME']) {
         $arMsg[] = array('ENTITY_FIELD' => 'SECOND_NAME', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_SECOND_NAME'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['SECOND_NAME']) ? $arFieldsOrig['SECOND_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['SECOND_NAME']) ? $arFieldsModif['SECOND_NAME'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['FM']) && isset($arFieldsModif['FM'])) {
         $arMsg = array_merge($arMsg, CCrmFieldMulti::CompareFields($arFieldsOrig['FM'], $arFieldsModif['FM']));
     }
     if (isset($arFieldsOrig['POST']) && isset($arFieldsModif['POST']) && $arFieldsOrig['POST'] != $arFieldsModif['POST']) {
         $arMsg[] = array('ENTITY_FIELD' => 'POST', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_POST'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['POST']) ? $arFieldsOrig['POST'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['POST']) ? $arFieldsModif['POST'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     $addressOptions = array();
     if (isset($arOptions['ADDRESS_FIELDS'])) {
         $addressOptions['FIELDS'] = $arOptions['ADDRESS_FIELDS'];
     }
     $arMsg = array_merge($arMsg, \Bitrix\Crm\ContactAddress::prepareChangeEvents($arFieldsOrig, $arFieldsModif, \Bitrix\Crm\ContactAddress::Primary, $addressOptions));
     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['COMPANY_ID']) && isset($arFieldsModif['COMPANY_ID']) && (int) $arFieldsOrig['COMPANY_ID'] != (int) $arFieldsModif['COMPANY_ID']) {
         $arCompany = array();
         $dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), array('ID' => array($arFieldsOrig['COMPANY_ID'], $arFieldsModif['COMPANY_ID'])));
         while ($arRes = $dbRes->Fetch()) {
             $arCompany[$arRes['ID']] = $arRes['TITLE'];
         }
         $arMsg[] = array('ENTITY_FIELD' => 'COMPANY_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_COMPANY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arCompany, $arFieldsOrig['COMPANY_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arCompany, $arFieldsModif['COMPANY_ID']));
     }
     if (isset($arFieldsOrig['SOURCE_ID']) && isset($arFieldsModif['SOURCE_ID']) && $arFieldsOrig['SOURCE_ID'] != $arFieldsModif['SOURCE_ID']) {
         $arStatus = CCrmStatus::GetStatusList('SOURCE');
         $arMsg[] = array('ENTITY_FIELD' => 'SOURCE_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_SOURCE_ID'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['SOURCE_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['SOURCE_ID'])));
     }
     if (isset($arFieldsOrig['SOURCE_DESCRIPTION']) && isset($arFieldsModif['SOURCE_DESCRIPTION']) && $arFieldsOrig['SOURCE_DESCRIPTION'] != $arFieldsModif['SOURCE_DESCRIPTION']) {
         $arMsg[] = array('ENTITY_FIELD' => 'SOURCE_DESCRIPTION', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_SOURCE_DESCRIPTION'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['SOURCE_DESCRIPTION']) ? $arFieldsOrig['SOURCE_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['SOURCE_DESCRIPTION']) ? $arFieldsModif['SOURCE_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['TYPE_ID']) && isset($arFieldsModif['TYPE_ID']) && $arFieldsOrig['TYPE_ID'] != $arFieldsModif['TYPE_ID']) {
         $arStatus = CCrmStatus::GetStatusList('CONTACT_TYPE');
         $arMsg[] = array('ENTITY_FIELD' => 'TYPE_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_TYPE_ID'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['TYPE_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['TYPE_ID'])));
     }
     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']));
     }
     if (isset($arFieldsOrig['BIRTHDATE']) || isset($arFieldsModif['BIRTHDATE'])) {
         $origBirthdate = isset($arFieldsOrig['BIRTHDATE']) ? $arFieldsOrig['BIRTHDATE'] : '';
         $modifBirthdate = isset($arFieldsModif['BIRTHDATE']) ? $arFieldsModif['BIRTHDATE'] : '';
         if ($origBirthdate !== $modifBirthdate) {
             $arMsg[] = array('ENTITY_FIELD' => 'BIRTHDATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_BIRTHDATE'), 'EVENT_TEXT_1' => $origBirthdate !== '' ? $origBirthdate : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => $modifBirthdate !== '' ? $modifBirthdate : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
         }
     }
     return $arMsg;
 }