• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/kpimanager.php
  • Класс: BitrixImOpenLinesKpiManager
  • Вызов: KpiManager::startTimer
public function startTimer()
{
	$currentMessage = $this->getNotAnsweredMessage();
	if (!is_null($currentMessage['TIME_STOP']))
	{
		$updateFields = array(
			'TIME_STOP' => null
		);

		if (!is_null($currentMessage['TIME_EXPIRED']) && $currentMessage['IS_SENT_EXPIRED_NOTIFICATION'] == 'N')
		{
			$timeExpiredTimestamp = DateTime::createFromUserTime($currentMessage['TIME_EXPIRED'])->getTimestamp();
			$timeStopTimestamp = DateTime::createFromUserTime($currentMessage['TIME_STOP'])->getTimestamp();
			$timeExpired = DateTime::createFromTimestamp($timeExpiredTimestamp + time() - $timeStopTimestamp);
			if ($timeExpired->getTimestamp() >= time())
			{
				$updateFields['TIME_EXPIRED'] = DateTime::createFromTimestamp($timeExpiredTimestamp + time() - $timeStopTimestamp);
			}
		}

		if (!empty($currentMessage['TIME_STOP_HISTORY']) && is_array($currentMessage['TIME_STOP_HISTORY']))
		{
			$currentTimeHistory = array_pop($currentMessage['TIME_STOP_HISTORY']);
			if (is_null($currentTimeHistory['TIME_CONTINUE']))
			{
				$currentTimeHistory['TIME_CONTINUE'] = DateTime::createFromTimestamp(time());
				$currentMessage['TIME_STOP_HISTORY'][] = $currentTimeHistory;
				$updateFields['TIME_STOP_HISTORY'] = $currentMessage['TIME_STOP_HISTORY'];
			}
		}

		$this->updateMessage($currentMessage['ID'], $updateFields);
	}
}