コード例 #1
0
ファイル: crm_quote.php プロジェクト: DarneoStudio/bitrix
 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;
 }
コード例 #2
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
        $psID = isset($arParams['PS_ID']) ? intval($arParams['PS_ID']) : 0;
        if (!CSalePaySystem::Delete($psID)) {
            ShowError(GetMessage('CRM_PS_DELETE_UNKNOWN_ERROR'));
        }
        LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_PS_LIST'], array()));
    }
}
$arResult['FIELDS'] = array();
if (strlen($arParams['PS_ID']) > 0) {
    $arResult['FIELDS']['tab_props'][] = array('id' => 'ID', 'name' => 'ID', 'value' => $psID, 'type' => 'label');
}
$arResult['FIELDS']['tab_props'][] = array('id' => 'NAME', 'name' => GetMessage('CRM_PS_FIELD_NAME'), 'value' => htmlspecialcharsbx($arPaySys['NAME']), 'type' => 'text');
$arResult['FIELDS']['tab_props'][] = array('id' => 'ACTIVE', 'name' => GetMessage('CRM_PS_FIELD_ACTIVE'), 'value' => $arPaySys['ACTIVE'], 'type' => 'checkbox');
$arResult['FIELDS']['tab_props'][] = array('id' => 'SORT', 'name' => GetMessage('CRM_PS_FIELD_SORT'), 'value' => $arPaySys['SORT'], 'type' => 'text');
$arResult['FIELDS']['tab_props'][] = array('id' => 'DESCRIPTION', 'name' => GetMessage('CRM_PS_FIELD_DESCRIPTION'), 'value' => $arPaySys['DESCRIPTION'], 'type' => 'textarea');
$ptList = CCrmPaySystem::getPersonTypesList();
$ptID = $arPaySys['ACTION']['PERSON_TYPE_ID'] ? $arPaySys['ACTION']['PERSON_TYPE_ID'] : key($ptList);
$arResult['FIELDS']['tab_props'][] = array('id' => 'PERSON_TYPE_ID', 'name' => GetMessage('CRM_PS_FIELD_PERSON_TYPE_ID'), 'type' => 'list', 'items' => $ptList, 'value' => $ptID);
/*
$arResult['FIELDS']['tab_props'][] = array(
	'id' => 'NEW_WINDOW',
	'name' =>  GetMessage('CRM_PS_FIELD_NEW_WINDOW'),
	'value' => $arPaySys['ACTION']['NEW_WINDOW'],
	'type' =>  'checkbox'
);

$arResult['FIELDS']['tab_props'][] = array(
	'id' => 'ENCODING',
	'name' => GetMessage('CRM_PS_FIELD_ENCODING'),
	'type' => 'list',
	'items' => array(
コード例 #3
0
ファイル: csv.php プロジェクト: mrdeadmouse/u136006
     $arHead = isset($arHeaders[$headerID]) ? $arHeaders[$headerID] : null;
     if (!$arHead) {
         continue;
     }
     // Special logic for ENTITIES_LINKS headers: expand in 3 columns
     if ($headerID === 'ENTITIES_LINKS') {
         $showProductRows = true;
         echo '"' . GetMessage('CRM_COLUMN_DEAL') . '";';
         echo '"' . GetMessage('CRM_COLUMN_COMPANY') . '";';
         echo '"' . GetMessage('CRM_COLUMN_CONTACT') . '";';
     } else {
         echo '"' . $arHead['name'] . '";';
     }
 }
 echo "\n";
 $arPersonTypes = CCrmPaySystem::getPersonTypesList();
 $arPaySystems = array();
 foreach (array_keys($arPersonTypes) as $personTypeId) {
     $arPaySystems[$personTypeId] = CCrmPaySystem::GetPaySystemsListItems($personTypeId);
 }
 unset($personTypeId);
 foreach ($arResult['INVOICE'] as $i => &$arInvoice) {
     // Serialize each product row as invoice with single product
     $productRows = $showProductRows && isset($arInvoice['PRODUCT_ROWS']) ? $arInvoice['PRODUCT_ROWS'] : array();
     if (count($productRows) == 0) {
         // Invoice has no product rows (or they are not displayed) - we have to create dummy for next loop by product rows only
         $productRows[] = array();
     }
     $invoiceData = array();
     $personTypeId = $arInvoice['PERSON_TYPE_ID'];
     foreach ($productRows as $productRow) {
コード例 #4
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
    $arLOCATION2 = array();
    
    $db_location = CSaleTaxRate::GetLocationList(array("TAXRATE_ID" => $arResult['ID'], "LOCATION_TYPE" => "G"));
    
    while ($arLocation = $db_location->Fetch())
    {
    	$arLOCATION2[] = $arLocation["LOCATION_ID"];
    }
    
    if(!is_array($arLOCATION2))
    	$arLOCATION2 = array();
    
    $arResult['LOCATION2'] = $arLOCATION2;
    
    $dbLocGrList = CSaleLocationGroup::GetList(array("NAME"=>"ASC"), array(), LANGUAGE_ID);
    
    while ($arLocGr = $dbLocGrList->Fetch())
    {
    	$arLocGrList[$arLocGr['ID']] = $arLocGr;
    
    	if(in_array(intval($arLocGr['ID']), $arResult['LOCATION2']))
    		$arLocGrList[$arLocGr['ID']]['SELECTED'] = true;
    	else
    		$arLocGrList[$arLocGr['ID']]['SELECTED'] = false;
    }
    
    $arResult['LOCATION2_LIST'] = $arLocGrList;
    */
    $arResult['PERSON_TYPES_LIST'] = CCrmPaySystem::getPersonTypesList(true);
}
$this->IncludeComponentTemplate();
コード例 #5
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
$sExportType = '';
if (!empty($_REQUEST['type'])) {
    $sExportType = strtolower(trim($_REQUEST['type']));
    if (!in_array($sExportType, array('csv', 'excel'))) {
        $sExportType = '';
    }
}
if (!empty($sExportType) && $CCrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'EXPORT')) {
    ShowError(GetMessage('CRM_PERMISSION_DENIED'));
    return;
}
$CCrmUserType = new CCrmUserType($USER_FIELD_MANAGER, CCrmInvoice::$sUFEntityID);
$arResult['GRID_ID'] = 'CRM_INVOICE_LIST_V12' . ($bInternal && !empty($arParams['GRID_ID_SUFFIX']) ? '_' . $arParams['GRID_ID_SUFFIX'] : '');
$arResult['STATUS_LIST'] = CCrmStatus::GetStatusListEx('INVOICE_STATUS');
$arResult['CURRENCY_LIST'] = CCrmCurrencyHelper::PrepareListItems();
$arResult['PERSON_TYPES'] = CCrmPaySystem::getPersonTypesList();
$arPaySystems = array();
foreach (array_keys($arResult['PERSON_TYPES']) as $personTypeId) {
    $arPaySystems[$personTypeId] = CCrmPaySystem::GetPaySystemsListItems($personTypeId);
}
$arResult['PAY_SYSTEMS_LIST'] = $arPaySystems;
unset($personTypeId, $arPaySystems);
$arResult['EVENT_LIST'] = CCrmStatus::GetStatusListEx('EVENT_TYPE');
$arResult['CLOSED_LIST'] = array('Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'));
$arResult['FILTER'] = array();
$arResult['FILTER2LOGIC'] = array();
$arResult['FILTER_PRESETS'] = array();
$arResult['PERMS']['ADD'] = !$CCrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'ADD');
$arResult['PERMS']['WRITE'] = !$CCrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'WRITE');
$arResult['PERMS']['DELETE'] = !$CCrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'DELETE');
$arResult['AJAX_MODE'] = isset($arParams['AJAX_MODE']) ? $arParams['AJAX_MODE'] : ($arResult['INTERNAL'] ? 'N' : 'Y');