• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/import/outlookcsvfileimport.php
  • Класс: Bitrix\Crm\Import\OutlookCsvFileImport
  • Вызов: OutlookCsvFileImport::checkHeaders
public function checkHeaders(array &$messages)
{
	IncludeModuleLangFile(__FILE__);

	$map = $this->headerMap;
	if($map === null)
	{
		throw new Main\SystemException("Invalid operation. HeaderMap is not assigned.");
	}

	$hasName = isset($map[$this->getFiledAlias('FIRST_NAME')])
		|| isset($map[$this->getFiledAlias('LAST_NAME')]);

	if(!$hasName)
	{
		$messages[] = GetMessage(
			'CRM_IMPORT_OUTLOOK_ERROR_FIELDS_NOT_FOUND',
			array(
				'#FIELD_LIST#' => implode(', ',
					array(
						'\''.$this->getFiledAlias('FIRST_NAME').'\'',
						'\''.$this->getFiledAlias('LAST_NAME').'\''
					)
				)
			)
		);
	}

	$hasEmail = isset($map[$this->getFiledAlias('E_MAIL_ADDRESS')])
		|| isset($map[$this->getFiledAlias('E_MAIL_2_ADDRESS')]);

	$hasPhone = isset($map[$this->getFiledAlias('PRIMARY_PHONE')])
		|| isset($map[$this->getFiledAlias('COMPANY_MAIN_PHONE')])
		|| isset($map[$this->getFiledAlias('MOBILE_PHONE')])
		|| isset($map[$this->getFiledAlias('BUSINESS_PHONE')])
		|| isset($map[$this->getFiledAlias('BUSINESS_PHONE_2')])
		|| isset($map[$this->getFiledAlias('HOME_PHONE')])
		|| isset($map[$this->getFiledAlias('HOME_PHONE_2')])
		|| isset($map[$this->getFiledAlias('CAR_PHONE')])
		|| isset($map[$this->getFiledAlias('RADIO_PHONE')])
		|| isset($map[$this->getFiledAlias('OTHER_PHONE')]);

	if(!$hasName && !$hasEmail && !$hasPhone)
	{
		$messages[] = GetMessage('CRM_IMPORT_OUTLOOK_REQUIREMENTS_NEW', ['#FILE_LANG#' => $this->headerLanguage]);
	}

	return $hasName || $hasEmail || $hasPhone;
}