- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/integration/crm/eventhandler.php
- Класс: Bitrix\Sender\Integration\Crm\EventHandler
- Вызов: EventHandler::onAfterPostingSendRecipient
static function onAfterPostingSendRecipient(array $eventData, Entity\Letter $letter)
{
if (!$eventData['SEND_RESULT'])
{
return;
}
static $isModuleIncluded = null;
if ($isModuleIncluded === null)
{
$isModuleIncluded = Loader::includeModule('crm');
}
if (!$isModuleIncluded)
{
return;
}
if ($letter->getMessage()->isReturnCustomer())
{
return;
}
$recipient = $eventData['RECIPIENT'];
$fields = $eventData['RECIPIENT']['FIELDS'];
$entityId = $fields['CRM_ENTITY_ID'] ?? $recipient['CONTACT_ID'];
if (!$entityId)
{
return;
}
TimeLineQueueTable::add([
'RECIPIENT_ID' => $recipient['ID'],
'POSTING_ID' => $letter->getId(),
'FIELDS' => Json::encode($fields),
'ENTITY_ID' => $entityId,
'CONTACT_TYPE_ID' => $recipient['CONTACT_TYPE_ID'],
'CONTACT_CODE' => $recipient['CONTACT_CODE'],
]);
}