87 $location = Util::parseLocation($locationId);
90 if ($location[
'room_id'] || $location[
'mrid'])
93 ->setTimeZone(
new \DateTimeZone(
'UTC'));
95 ->setTimeZone(
new \DateTimeZone(
'UTC'));
97 $fromTs = \Bitrix\Calendar\Util::getDateTimestampUtc($dateFrom, $params[
'fields'][
'TZ_FROM']);
98 $toTs = \Bitrix\Calendar\Util::getDateTimestampUtc($dateTo, $params[
'fields'][
'TZ_FROM']);
99 if ($params[
'fields'][
'SKIP_TIME'])
101 $toTs += \CCalendar::GetDayLen();
104 $eventId = (int)$params[
'fields'][
'ID'];
106 $from = \Bitrix\Calendar\Util::formatDateTimestampUTC($fromTs);
107 $to = \Bitrix\Calendar\Util::formatDateTimestampUTC($toTs);
109 if ($location[
'mrid'])
112 'allowReserveMeeting' =>
true,
113 'id' => $location[
'mrid'],
114 'from' => \CCalendar::Date(
115 $fromTs - \CCalendar::DAY_LENGTH,
118 'to' => \CCalendar::Date(
119 $toTs + \CCalendar::DAY_LENGTH,
122 'curEventId' => $location[
'mrevid'],
125 foreach ($meetingRoomRes as $entry)
127 if ((
int)$entry[
'ID'] !== (
int)$location[
'mrevid'])
129 $entryFromTs = \CCalendar::Timestamp($entry[
'DT_FROM']);
130 $entryToTs = \CCalendar::Timestamp($entry[
'DT_TO']);
132 if ($entryFromTs < $toTs && $entryToTs > $fromTs)
140 elseif ($location[
'room_id'])
143 foreach ($entries as $entry)
145 if ((
int)$entry[
'ID'] !== (
int)$location[
'room_event_id']
146 && (
int)$entry[
'PARENT_ID'] !== $eventId)
148 $entryFromTs = \Bitrix\Calendar\Util::getDateTimestampUtc(
new DateTime($entry[
'DATE_FROM']), $entry[
'TZ_FROM']);
149 $entryToTs = \Bitrix\Calendar\Util::getDateTimestampUtc(
new DateTime($entry[
'DATE_TO']), $entry[
'TZ_FROM']);
150 if ($entry[
'DT_SKIP_TIME'] ===
'Y')
152 $entryToTs += \CCalendar::GetDayLen();
155 if ($entryFromTs < $toTs && $entryToTs > $fromTs)
197 if (!is_array($this->datesRange) || !is_array($this->locationList) || empty($this->datesRange))
202 $roomIds = array_map(
static fn($room) => (
int)$room[
'ID'], $this->locationList);
203 $from = $this->datesRange[0];
204 $to = $this->datesRange[count($this->datesRange) - 1];
210 foreach ($this->datesRange as $date)
215 foreach ($entries as $entry)
217 $roomId = (int)$entry[
'SECTION_ID'];
219 $dateStart =
new DateTime($entry[
'DATE_FROM']);
220 $dateEnd =
new DateTime($entry[
'DATE_TO']);
221 while ($dateStart->getTimestamp() <= $dateEnd->getTimestamp())
223 $date = $dateStart->format(
'd.m.Y');
224 $dateStart->add(
'1 day');
225 if (!isset($result[$date]))
230 $result[$date][$roomId] ??= [];
231 $result[$date][$roomId][] = $entry;