• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/queue/event.php
  • Класс: BitrixImOpenLinesQueueEvent
  • Вызов: Event::OnStartAbsence
static function OnStartAbsence(BitrixMainEvent $event)
{
	$eventData = $event->getParameters();

	$userId = $eventData['USER_ID'];

	if(
		!empty($userId) &&
		is_numeric($userId) &&
		ImOpenLinesQueue::isRealOperator($userId) &&
		!empty($eventData['ABSENCE_TYPE']) &&
		!empty($eventData['DURATION'])
	)
	{
		$durationAbsenceDay = floor($eventData['DURATION']/86400);
		$isVacation = true;
		$listLine = [];

		if(Loader::includeModule('intranet') && !UserAbsence::isVacation($eventData['ABSENCE_TYPE']))
		{
			$isVacation = false;
		}

		if ($isVacation === true && $durationAbsenceDay > 0)
		{
			$listLine = self::getLineIsSessionOperator($userId);

			if (!empty($listLine))
			{
				foreach ($listLine as $lineId)
				{
					if (!BitrixImOpenLinesQueue::isOperatorSingleInLine($lineId, $userId))
					{
						$configManager = self::initialization($lineId);
						if(!empty($configManager))
						{
							$configManager->returnSessionsUsersToQueueIsStartAbsence(
								[$userId],
								$durationAbsenceDay,
								ImOpenLinesQueue::REASON_OPERATOR_ABSENT
							);
						}
					}
				}
			}
		}

		ImOpenLinesDebug::addQueueEvent(
			__METHOD__,
			0,
			0,
			[
				'eventData' => $eventData,
				'durationAbsenceDay' => $durationAbsenceDay,
				'isVacation' => $isVacation,
				'listLine' => $listLine
			]
		);
	}
}