- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/requisite/importhelper.php
- Класс: Bitrix\Crm\Requisite\ImportHelper
- Вызов: ImportHelper::__construct
public function __construct($entityTypeId, $headerIndex, $headerInfo, $options)
{
if ($entityTypeId !== \CCrmOwnerType::Company && $entityTypeId !== \CCrmOwnerType::Contact)
throw new Main\ArgumentException('Incorrect entity type.', 'entityTypeId');
if (!is_array($headerIndex) || empty($headerIndex))
$headerIndex = [];
if (!is_array($headerInfo) || empty($headerInfo))
$headerInfo = [];
$this->entityTypeId = $entityTypeId;
switch ($this->entityTypeId)
{
case \CCrmOwnerType::Company:
$this->entityKeyFields = array('ID', 'TITLE');
break;
case \CCrmOwnerType::Contact:
$this->entityKeyFields = array('ID', 'NAME', 'LAST_NAME');
break;
}
$this->requisiteKeyFields = array('ID', 'NAME');
$this->bankDetailKeyFields = array('ID', 'NAME');
$this->rqFieldPrefix = 'RQ_';
$this->bdFieldPrefix = 'BD_';
$this->rqListFieldMap = [];
$this->entityKeyValue = '';
$this->searchNextEntityMode = false;
$this->ready = false;
$this->headerIndex = $headerIndex;
$this->headerGroupCountryIdMap = array();
$this->headerById = array();
foreach ($headerInfo as $header)
{
if (is_array($header) && isset($header['id']) && is_string($header['id']) && $header['id'] <> ''
&& isset($header['group']) && is_string($header['group']) && $header['group'] <> ''
&& isset($header['countryId']) && $header['countryId'] >= 0 && isset($headerIndex[$header['id']]))
{
$this->headerById[$header['id']] = $header;
$countryId = (int)$header['countryId'];
$this->headerGroupCountryIdMap[$header['group']][$countryId][$header['id']] = true;
}
}
$this->rows = array();
$this->rowNumber = 0;
$this->requisiteList = array();
// region Options
$rowLimit = (is_array($options) && isset($options['ROW_LIMIT'])) ? (int)$options['ROW_LIMIT'] : 50;
if ($rowLimit <= 0)
throw new Main\ArgumentException('Invalid number limit option for rows.', 'ROW_LIMIT');
$this->rowLimit = $rowLimit;
$this->assocPreset = (is_array($options) && isset($options['ASSOC_PRESET']) && $options['ASSOC_PRESET']);
$this->assocPresetById = (is_array($options) && isset($options['ASSOC_PRESET_BY_ID'])
&& $options['ASSOC_PRESET_BY_ID']);
$this->useDefPreset = (is_array($options) && isset($options['USE_DEF_PRESET']) && $options['USE_DEF_PRESET']);
$defPresetId = (is_array($options) && isset($options['DEF_PRESET_ID'])) ? (int)$options['DEF_PRESET_ID'] : 0;
$this->defPresetId = $defPresetId > 0 ? $defPresetId : 0;
// endregion Options
}