ResourceBooking::fetchFieldValue

  1. Bitrix24 API (v. 23.675.0)
  2. calendar
  3. ResourceBooking
  4. fetchFieldValue
  • Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/userfield/resourcebooking.php
  • Класс: BitrixCalendarUserFieldResourceBooking
  • Вызов: ResourceBooking::fetchFieldValue
static function fetchFieldValue($value)
{
	$resourseList = InternalsResourceTable::getList(
		array(
			"filter" => array(
				"=ID" => $value
			)
		)
	);

	$result = array(
		'ENTRIES' => []
	);

	while ($resourse = $resourseList->fetch())
	{
		if (!isset($result['DATE_FROM']))
		{
			CTimeZone::Disable();
			$result['DATE_FROM'] = $resourse['DATE_FROM']->toString();
			$result['DATE_TO'] = $resourse['DATE_TO']->toString();
			$result['SERVICE_NAME'] = $resourse['SERVICE_NAME'];
			CTimeZone::Enable();

			$fromTs = CCalendar::timestamp($result['DATE_FROM']);
			$toTs = CCalendar::timestamp($result['DATE_TO']);

			if (!$resourse['SKIP_TIME'])
			{
				$currentUserID = CCalendar::getCurUserId();

				$userOffsetFrom = CCalendar::getTimezoneOffset($resourse['TZ_FROM'], $fromTs) - CCalendar::getCurrentOffsetUTC($currentUserID);
				$userOffsetTo = CCalendar::getTimezoneOffset($resourse['TZ_TO'], $toTs) - CCalendar::getCurrentOffsetUTC($currentUserID);

				$result['DATE_FROM'] = CCalendar::date($fromTs - $userOffsetFrom);
				$result['DATE_TO'] = CCalendar::date($toTs - $userOffsetTo);
			}
			else
			{
				$result['DATE_TO'] = CCalendar::date($toTs + CCalendar::DAY_LENGTH);
			}
		}

		$result['ENTRIES'][] = array(
			'ID' => $resourse['ID'],
			'EVENT_ID' => $resourse['EVENT_ID'],
			'TYPE' => $resourse['CAL_TYPE'],
			'RESOURCE_ID' => $resourse['RESOURCE_ID']
		);
	}

	return $result;
}

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