- Модуль: catalogmobile
- Путь к файлу: ~/bitrix/modules/catalogmobile/lib/EntityEditor/RealizationDocumentProvider.php
- Класс: BitrixCatalogMobileEntityEditorRealizationDocumentProvider
- Вызов: RealizationDocumentProvider::getClientInfo
protected function getClientInfo(): array
{
$companyId = 0;
$contactIds = [];
if (!$this->order)
{
return [];
}
if (!$this->shipment->getId())
{
$bindingEntity = $this->getOwnerEntity();
if ($bindingEntity)
{
$companyId = $bindingEntity->getCompanyId();
$contacts = $bindingEntity->getContacts();
foreach ($contacts as $contact)
{
$contactIds[] = $contact->getId();
}
}
}
else
{
$clientCollection = $this->order->getContactCompanyCollection();
if ($clientCollection && !$clientCollection->isEmpty())
{
/** @var BitrixCrmOrderCompany $company */
if ($company = $clientCollection->getPrimaryCompany())
{
$companyId = $company->getField('ENTITY_ID');
}
$contacts = $clientCollection->getContacts();
/** @var BitrixCrmOrderContact $contact */
foreach ($contacts as $contact)
{
$contactIds[] = $contact->getField('ENTITY_ID');
}
}
}
$clientInfo = [
'COMPANY_DATA' => [],
'CONTACT_DATA' => [],
];
if ($companyId > 0)
{
$isEntityReadPermitted = CCrmCompany::CheckReadPermission($companyId, CCrmPerms::GetCurrentUserPermissions());
$companyInfo = CCrmEntitySelectorHelper::PrepareEntityInfo(
CCrmOwnerType::CompanyName,
$companyId,
[
'ENTITY_EDITOR_FORMAT' => true,
'IS_HIDDEN' => !$isEntityReadPermitted,
'REQUIRE_REQUISITE_DATA' => true,
'REQUIRE_MULTIFIELDS' => true,
'NAME_TEMPLATE' => BitrixCrmFormatPersonNameFormatter::getFormat(),
]
);
$clientInfo['COMPANY_DATA'] = [$companyInfo];
}
$iteration = 0;
foreach ($contactIds as $contactID)
{
$isEntityReadPermitted = CCrmContact::CheckReadPermission($contactID, CCrmPerms::GetCurrentUserPermissions());
$clientInfo['CONTACT_DATA'][] = CCrmEntitySelectorHelper::PrepareEntityInfo(
CCrmOwnerType::ContactName,
$contactID,
[
'ENTITY_EDITOR_FORMAT' => true,
'IS_HIDDEN' => !$isEntityReadPermitted,
'REQUIRE_REQUISITE_DATA' => true,
'REQUIRE_EDIT_REQUISITE_DATA' => ($iteration === 0), // load full requisite data for first item only (due to performance optimisation)
'REQUIRE_MULTIFIELDS' => true,
'REQUIRE_BINDINGS' => true,
'NAME_TEMPLATE' => BitrixCrmFormatPersonNameFormatter::getFormat(),
'NORMALIZE_MULTIFIELDS' => true,
]
);
$iteration++;
}
return $clientInfo;
}