• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/activity/fillactlightcounter.php
  • Класс: Bitrix\Crm\Activity\FillActLightCounter
  • Вызов: FillActLightCounter::updateOrCreate
private function updateOrCreate(int $actId, DateTime $lightTime): void
{
	$rec = ActCounterLightTimeTable::getById($actId)->fetch();

	if (
		$rec
		&& !$this->isDatesEqual($rec['LIGHT_COUNTER_AT'], $lightTime)
	)
	{
		ActCounterLightTimeTable::update($actId, [
			'LIGHT_COUNTER_AT' => $lightTime,
			'IS_LIGHT_COUNTER_NOTIFIED' => $this->isDateLessThenNow($lightTime) ? 'Y' : 'N'
		]);
		return;
	}

	if (!$rec)
	{
		ActCounterLightTimeTable::add([
			'ACTIVITY_ID' => $actId,
			'LIGHT_COUNTER_AT' => $lightTime,
			'IS_LIGHT_COUNTER_NOTIFIED' => $this->isDateLessThenNow($lightTime) ? 'Y' : 'N'
		]);
	}
}