Skip to content
Snippets Groups Projects
Commit fefcc5e6 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

course/room_requests/request_select_room: show partially available rooms with a yellow icon

parent 17080324
No related branches found
No related tags found
No related merge requests found
......@@ -600,27 +600,69 @@ class Course_RoomRequestsController extends AuthenticatedController
null
];
}
$this->matching_rooms = [];
if (!$this->room_name && !$this->selected_properties) {
//Load all requestable rooms:
$this->available_rooms = RoomManager::findRooms(
$this->matching_rooms = RoomManager::findRooms(
'',
null,
null,
[],
$this->request->getTimeIntervals(),
[],
'name ASC, mkdate ASC'
);
} else {
//Search rooms by the selected properties:
$this->available_rooms = RoomManager::findRooms(
$this->matching_rooms = RoomManager::findRooms(
$this->room_name,
null,
null,
$search_properties,
$this->request->getTimeIntervals(),
[],
'name ASC, mkdate ASC'
);
}
$this->available_room_icons = [];
$request_time_intervals = $this->request->getTimeIntervals();
$request_date_amount = count($request_time_intervals);
foreach ($this->matching_rooms as $room) {
$request_dates_booked = 0;
foreach ($request_time_intervals as $interval) {
$booked = ResourceBookingInterval::countBySql(
'resource_id = :room_id
AND
(begin BETWEEN :begin AND :end
OR end BETWEEN :begin AND :end)',
[
'room_id' => $room->id,
'begin' => $interval['begin'],
'end' => $interval['end']
]
) > 0;
if ($booked) {
$request_dates_booked++;
}
}
if ($request_dates_booked == 0) {
$this->available_room_icons[$room->id] =
Icon::create('check-circle', Icon::ROLE_STATUS_GREEN)->asImg(
[
'class' => 'text-bottom',
'title' => _('freier Raum')
]
);
$this->available_rooms[] = $room;
} elseif ($request_dates_booked < $request_time_intervals) {
$this->available_room_icons[$room->id] =
Icon::create('exclaim-circle', Icon::ROLE_STATUS_YELLOW)->asImg(
[
'class' => 'text-bottom',
'title' => _('teilweise belegter Raum')
]
);
$this->available_rooms[] = $room;
}
}
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
......@@ -971,4 +1013,4 @@ class Course_RoomRequestsController extends AuthenticatedController
}
$this->redirect('course/room_requests/index');
}
}
\ No newline at end of file
}
......@@ -32,19 +32,7 @@
<? foreach ($available_rooms as $room): ?>
<div class="flex-row">
<label class="horizontal">
<? if ($overlaps[$room->id] <= 0.0): ?>
<?= Icon::create('check-circle', Icon::ROLE_STATUS_GREEN)->asImg(
['class' => 'text-bottom']
) ?>
<? elseif ($overlaps[$room->id] >= 1.0): ?>
<?= Icon::create('decline-circle', Icon::ROLE_STATUS_RED)->asImg(
['class' => 'text-bottom']
) ?>
<? else: ?>
<?= Icon::create('exclaim-circle', Icon::ROLE_STATUS_YELLOW)->asImg(
['class' => 'text-bottom']
) ?>
<? endif ?>
<?= $available_room_icons[$room->id] ?>
<input type="radio" name="selected_room_id"
data-activates="button[type='submit'][name='select_room']"
value="<?= htmlReady($room->id) ?>">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment