- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/integration/sale/cashbox/eventhandlers/check.php
- Класс: BitrixCatalogIntegrationSaleCashboxEventHandlersCheck
- Вызов: Check::getCatalogContractorDataByContractIds
static function getCatalogContractorDataByContractIds(array $contractIds): array
{
$result = [
'contracts' => [],
'individual' => [],
'company' => [],
];
$contractorIterator = CatalogAgentContractTable::getList([
'select' => [
'ID',
'CONTRACTOR_ID',
'CONTRACTOR_PERSON_TYPE' => 'CONTRACTOR.PERSON_TYPE',
'CONTRACTOR_PERSON_NAME' => 'CONTRACTOR.PERSON_NAME',
'CONTRACTOR_PERSON_LASTNAME' => 'CONTRACTOR.PERSON_LASTNAME',
'CONTRACTOR_COMPANY' => 'CONTRACTOR.COMPANY',
'CONTRACTOR_PHONE' => 'CONTRACTOR.PHONE',
'CONTRACTOR_ADDRESS' => 'CONTRACTOR.ADDRESS',
'CONTRACTOR_INN' => 'CONTRACTOR.INN',
],
'filter' => [
'=ID' => $contractIds,
],
]);
while ($contractor = $contractorIterator->fetch())
{
$personName = '';
if (!empty($contractor['CONTRACTOR_PERSON_TYPE']))
{
$personName = $contractor['CONTRACTOR_PERSON_TYPE'];
}
if (!empty($contractor['CONTRACTOR_PERSON_LASTNAME']))
{
$personName = $personName
? $personName . ' ' . $contractor['CONTRACTOR_PERSON_LASTNAME']
: $contractor['CONTRACTOR_PERSON_LASTNAME']
;
}
$type = self::TYPE_INDIVIDUAL;
if ($contractor['CONTRACTOR_PERSON_TYPE'] === CatalogContractorTable::TYPE_COMPANY)
{
$type = self::TYPE_COMPANY;
}
$phone = $contractor['CONTRACTOR_PHONE'];
if ($phone)
{
$phone = preg_split('/[.,;]+/', $phone);
$phone = array_filter(array_map('trim', $phone));
}
else
{
$phone = [];
}
$result['contracts'][$contractor['ID']][$type] = $contractor['CONTRACTOR_ID'];
$result[$type][$contractor['CONTRACTOR_ID']] = [
'TYPE' => $type,
'PERSON_NAME' => $personName,
'COMPANY_NAME' => $contractor['CONTRACTOR_COMPANY'],
'PHONES' => $phone,
'INN' => $contractor['CONTRACTOR_INN'],
];
}
return $result;
}