- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/requisite/importhelper.php
- Класс: Bitrix\Crm\Requisite\ImportHelper
- Вызов: ImportHelper::getRequisiteDupControlImportOptions
static function getRequisiteDupControlImportOptions($headers, $activeCountryList,
$optionPrefix = 'IMPORT_DUP_CONTROL_ENABLE_RQ')
{
$result = array();
$optionPrefix = is_string($optionPrefix) ? $optionPrefix : '';
$dupControlFieldMap = array();
foreach (EntityRequisite::getDuplicateCriterionFieldsMap() as $countryId => $fields)
$dupControlFieldMap['requisite'][$countryId] = array_fill_keys($fields, true);
foreach (EntityBankDetail::getDuplicateCriterionFieldsMap() as $countryId => $fields)
$dupControlFieldMap['bankDetail'][$countryId] = array_fill_keys($fields, true);
$dupHeaders = array();
foreach($headers as $header)
{
if (isset($header['group']) && isset($header['field']) && isset($header['countryId']))
{
if (isset($dupControlFieldMap[$header['group']][$header['countryId']][$header['field']]))
{
$dupHeaders[$header['countryId']][$header['group']][$header['field']] = $header;
}
}
}
$fieldTitleMap = array();
$requisite = EntityRequisite::getSingleInstance();
$fieldTitleMap['requisite'] = $requisite->getRqFieldTitleMap();
$bankDetail = EntityBankDetail::getSingleInstance();
$fieldTitleMap['bankDetail'] = $bankDetail->getRqFieldTitleMap();
foreach ($activeCountryList as $countryId => $countryName)
{
if (isset($dupHeaders[$countryId]))
{
foreach ($dupHeaders[$countryId] as $groupName => $headers)
{
switch ($groupName)
{
case 'requisite':
$groupId = 'RQ';
break;
case 'bankDetail':
$groupId = 'BD';
break;
default:
$groupId = '';
}
if ($groupId !== '')
{
foreach ($headers as $fieldName => $header)
{
$optionId = $optionPrefix.'['.$countryId.']['.$groupId.']['.$fieldName.']';
$optionName = isset($fieldTitleMap[$groupName][$fieldName][$countryId]) ?
$fieldTitleMap[$groupName][$fieldName][$countryId] : $fieldName;
$result[] = array(
'id' => $optionId,
'name' => $optionName,
'groupId' => $groupId,
'group' => $groupName,
'field' => $fieldName,
'countryId' => $countryId,
'countryName' => $activeCountryList[$countryId]
);
}
}
}
}
}
return $result;
}