Base::loadCommunicationValues

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Base
  4. loadCommunicationValues
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/bizproc/document/valuecollection/base.php
  • Класс: Bitrix\Crm\Integration\BizProc\Document\ValueCollection\Base
  • Вызов: Base::loadCommunicationValues
protected function loadCommunicationValues(): void
{
	$callId = Crm\Activity\Provider\Call::getId();
	$emailId = Crm\Activity\Provider\Email::getId();
	$olId = Crm\Activity\Provider\OpenLine::getId();
	$webFormId = Crm\Activity\Provider\WebForm::getId();

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

	$ormRes = Crm\ActivityTable::getList([
		'select' => ['END_TIME', 'PROVIDER_ID'],
		'filter' => [
			'=COMPLETED' => 'Y',
			'@PROVIDER_ID' => [$callId, $emailId, $olId, $webFormId],
			'=BINDINGS.OWNER_TYPE_ID' => $this->typeId,
			'=BINDINGS.OWNER_ID' => $this->id,
		],
		'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;
		}
	}

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

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