BasePersonalize::getCommunicationFieldsValues

  1. Bitrix24 API (v. 23.675.0)
  2. sender
  3. BasePersonalize
  4. getCommunicationFieldsValues
  • Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/integration/crm/connectors/personalize/basepersonalize.php
  • Класс: Bitrix\Sender\Integration\Crm\Connectors\Personalize\BasePersonalize
  • Вызов: BasePersonalize::getCommunicationFieldsValues
static function getCommunicationFieldsValues($typeId, $ids)
{
	$callId = Bitrix\Crm\Activity\Provider\Call::getId();
	$emailId = Bitrix\Crm\Activity\Provider\Email::getId();
	$olId = Bitrix\Crm\Activity\Provider\OpenLine::getId();
	$webFormId = Bitrix\Crm\Activity\Provider\WebForm::getId();

	$callDate = $emailDate = $olDate = $webFormDate = null;

	$ormRes = \Bitrix\Crm\ActivityTable::getList(
		[
			'select' => ['END_TIME', 'PROVIDER_ID'],
			'filter' => [
				'=COMPLETED'              => 'Y',
				'@PROVIDER_ID'            => [$callId, $emailId, $olId, $webFormId],
				'=BINDINGS.OWNER_TYPE_ID' => $typeId,
				'@BINDINGS.OWNER_ID'      => $ids,
			],
			'order'  => ['END_TIME' => 'DESC']
		]
	);

	while ($row = $ormRes->fetch())
	{
		if ($callDate === null)
		{
			if ($row['PROVIDER_ID'] === $callId)
			{
				$callDate = $row['END_TIME'];
			}
		}
		if ($emailDate === null)
		{
			if ($row['PROVIDER_ID'] === $emailId)
			{
				$emailDate = $row['END_TIME'];
			}
		}
		if ($olDate === null)
		{
			if ($row['PROVIDER_ID'] === $olId)
			{
				$olDate = $row['END_TIME'];
			}
		}
		if ($webFormDate === null)
		{
			if ($row['PROVIDER_ID'] === $webFormId)
			{
				$webFormDate = $row['END_TIME'];
			}
		}

		if ($callDate !== null && $emailDate !== null && $olDate !== null && $webFormDate !== null)
		{
			break;
		}
	}

	return [
		'COMMUNICATIONS.LAST_CALL_DATE'  => (string)$callDate,
		'COMMUNICATIONS.LAST_EMAIL_DATE' => (string)$emailDate,
		'COMMUNICATIONS.LAST_OL_DATE'    => (string)$olDate,
		'COMMUNICATIONS.LAST_FORM_DATE'  => (string)$webFormDate,
	];
}

Добавить комментарий