• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/agent/activity/lightcounter/filllightcounterpart1.php
  • Класс: Bitrix\Crm\Agent\Activity\LightCounter\FillLightCounterPart1
  • Вызов: FillLightCounterPart1::execute
public function execute(): bool
{
	if (Option::get('crm', self::PART_IS_DONE_NAME, 'N') === 'Y')
	{
		return self::PART_IS_DONE;
	}

	$lastId = $this->getLastId();
	$activities = $this->queryUncompletedActivitiesToProcess($lastId);

	if (empty($activities))
	{
		Option::set('crm', self::PART_IS_DONE_NAME, 'Y');
		return self::PART_IS_DONE;
	}

	foreach ($activities as $row)
	{
		$offsets = $row['MAX_OFFSET'] ? [$row['MAX_OFFSET']] : null;
		$lightTime = (new CounterLightTime)->calculate(
			CalculateParams::createFromArrays($row, $offsets)
		);

		$this->insertIntoToLightTimeTable($row['ID'], $lightTime);
		$this->updateCountableActTable($row['ID'], $lightTime, $row['DEADLINE']);
	}

	$this->setLastId(end($activities)['ID']);

	return self::PART_HAS_MORE_ITERATIONS;
}