• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/requisite/importhelper.php
  • Класс: Bitrix\Crm\Requisite\ImportHelper
  • Вызов: ImportHelper::parseBankDetailFields
protected function parseBankDetailFields($row, $presetInfo)
{
	$result = new Main\Result();

	$bankDetailFields = array();
	$countryId = $presetInfo['COUNTRY_ID'];
	$skipFieldsMap = array(
		$this->bdFieldPrefix.'ID' => true
	);
	$headerIds = array();
	if (is_array($this->headerGroupCountryIdMap['bankDetail'][0]))
		$headerIds = array_keys($this->headerGroupCountryIdMap['bankDetail'][0]);
	if (is_array($this->headerGroupCountryIdMap['bankDetail'][$countryId]))
		$headerIds = array_merge($headerIds, array_keys($this->headerGroupCountryIdMap['bankDetail'][$countryId]));
	foreach ($headerIds as $headerId)
	{
		if (isset($skipFieldsMap[$headerId]))
			continue;

		$fieldName = '';
		$fieldType = 'string';
		if (is_array($this->headerById[$headerId])
			&& isset($this->headerById[$headerId]['field'])
			&& isset($this->headerById[$headerId]['countryId'])
			&& $this->headerById[$headerId]['fieldType'])
		{
			$fieldName = $this->headerById[$headerId]['field'];
			$fieldType = $this->headerById[$headerId]['fieldType'];
		}
		if (!is_string($fieldName) || $fieldName == '')
		{
			continue;
		}

		if (isset($row[$this->headerIndex[$headerId]]))
		{
			$value = $row[$this->headerIndex[$headerId]];

			if ($fieldType === 'integer')
			{
				$value = (int)$value;
			}
			else if ($fieldType === 'boolean')
			{
				$value = ToUpper($value);
				$yesStr = ToUpper(Loc::getMessage('MAIN_YES'));
				$value = ($value === 'Y' || $value === $yesStr || $value == 1) ? 'Y' : 'N';
			}

			$bankDetailFields[$fieldName] = $value;
		}
	}

	if (!empty($bankDetailFields))
		$bankDetailFields['COUNTRY_ID'] = $countryId;

	$result->setData($bankDetailFields);

	return $result;
}