From 3d66d8985c69bb9f218f373d9bc64e033edb56ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Gl=C3=B6ggler?= <till@gundk.it> Date: Mon, 11 Oct 2021 12:16:31 +0200 Subject: [PATCH] add booked rooms to list --- app/controllers/resources/room_request.php | 29 +++++++++++++++++++ .../resources/ResourceRequest.class.php | 1 - templates/dates/seminar_html_roomplanning.php | 3 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/controllers/resources/room_request.php b/app/controllers/resources/room_request.php index 26a0a8a17e2..2b25b7f9d6e 100644 --- a/app/controllers/resources/room_request.php +++ b/app/controllers/resources/room_request.php @@ -1478,6 +1478,35 @@ class Resources_RoomRequestController extends AuthenticatedController $this->alternative_rooms = array_merge($this->alternative_rooms, $request_rooms); } } + + // add all booked rooms as well + $booked_rooms = []; + foreach($this->request_time_intervals as $key => $data) { + foreach ($data['intervals'] as $timeslot) { + if (!isset($booked_rooms[$timeslot['booked_room']])) { + $room = Room::find($timeslot['booked_room']); + if ($room) { + $booked_rooms[$timeslot['booked_room']] = $room; + } + } + } + } + + if (!empty($booked_rooms)) { + $this->alternative_rooms = array_merge($booked_rooms, $this->alternative_rooms); + } + + // deduplicate array + $deduplicated = []; + + foreach ($this->alternative_rooms as $room) { + if (!isset($deduplicated[$room->id])) { + $deduplicated[$room->id] = $room; + } + } + + $this->alternative_rooms = $deduplicated; + foreach ($this->alternative_rooms as $room) { $this->metadate_available[$room->id] = []; $this->room_availability[$room->id] = []; diff --git a/lib/models/resources/ResourceRequest.class.php b/lib/models/resources/ResourceRequest.class.php index 67b3b982176..d7435c8cde8 100644 --- a/lib/models/resources/ResourceRequest.class.php +++ b/lib/models/resources/ResourceRequest.class.php @@ -1356,7 +1356,6 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen } elseif ($this->course_id) { $course = new Seminar($this->course_id); if ($course) { - $strings[] = 'ct'; $strings[] = $course->getDatesTemplate('dates/seminar_html_roomplanning', [ 'shrink' => false, diff --git a/templates/dates/seminar_html_roomplanning.php b/templates/dates/seminar_html_roomplanning.php index 97133e49584..f3311494aef 100644 --- a/templates/dates/seminar_html_roomplanning.php +++ b/templates/dates/seminar_html_roomplanning.php @@ -27,7 +27,8 @@ if (!empty($dates['regular']['turnus_data']) || !empty($dates['irregular'])) : [ 'assigned' => $cycle['assigned_rooms'], 'freetext' => $cycle['freetext_rooms'], - 'plain' => true] + 'link' => true + ] ); endif; -- GitLab