From a790d2e3778d37eec37683336e475b707feee822 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Thu, 7 Oct 2021 16:11:28 +0000 Subject: [PATCH] TIC #88 --- app/controllers/resources/room_request.php | 28 ++++ app/views/resources/room_request/resolve.php | 32 ++++- .../assets/stylesheets/scss/resources.scss | 132 +++++++++--------- 3 files changed, 126 insertions(+), 66 deletions(-) diff --git a/app/controllers/resources/room_request.php b/app/controllers/resources/room_request.php index c54b6683dc8..909f1d639fb 100644 --- a/app/controllers/resources/room_request.php +++ b/app/controllers/resources/room_request.php @@ -1523,6 +1523,8 @@ class Resources_RoomRequestController extends AuthenticatedController $resolve = Request::submitted('resolve') || $force_resolve; $this->show_force_resolve_button = false; + $this->booked_room_infos = []; + if ($resolve) { CSRFProtection::verifyUnsafeRequest(); $this->selected_rooms = array_filter(Request::getArray('selected_rooms')); @@ -1616,6 +1618,16 @@ class Resources_RoomRequestController extends AuthenticatedController ); if ($booking instanceof ResourceBooking) { $bookings[] = $booking; + if ($this->booked_room_infos[$room->id]) { + if ($this->booked_room_infos[$room->id]['first_booking_date'] > $booking->begin) { + $this->booked_room_infos[$room->id]['first_booking_date'] = $booking->begin; + } + } else { + $this->booked_room_infos[$room->id] = [ + 'room' => $room, + 'first_booking_date' => $booking->begin + ]; + } } } catch (Exception $e) { $errors[] = $e->getMessage(); @@ -1731,6 +1743,22 @@ class Resources_RoomRequestController extends AuthenticatedController ); } } + + if ($this->booked_room_infos) { + //Sort the array: + uasort( + $this->booked_room_infos, + function ($a, $b) { + if ($a['room']->name > $b['room']->name) { + return 1; + } elseif ($a['room']->name < $b['room']->name) { + return -1; + } else { + return 0; + } + } + ); + } } } diff --git a/app/views/resources/room_request/resolve.php b/app/views/resources/room_request/resolve.php index 1d5e2e4128e..ef8bc2cca59 100644 --- a/app/views/resources/room_request/resolve.php +++ b/app/views/resources/room_request/resolve.php @@ -2,6 +2,35 @@ data-dialog="size=big;<?= Request::submitted('reload-on-close') ? 'reload-on-close' : ''; ?>" action="<?= $controller->link_for('resources/room_request/resolve/' . $request->id) ?>"> <?= CSRFProtection::tokenTag() ?> + <? if ($booked_room_infos): ?> + <article class="studip"> + <header> + <h1><?= _('Gebuchte Räume') ?></h1> + </header> + <section> + <ul class="list-csv"> + <? foreach ($booked_room_infos as $room_info) : ?> + <li> + <a href="<?= $room_info['room']->getActionLink( + 'booking_plan', + ['defaultDate' => date('Y-m-d', $room_info['first_booking_date'])] + ) ?>" target="_blank" + title="<?= _('Belegungsplan anzeigen') ?>"> + <?= htmlReady($room_info['room']->getFullName()) ?> + <?= Icon::create('link-intern')->asImg( + [ + 'class' => 'text-bottom', + 'title' => '' + ] + ) ?> + </a> + </li> + <? endforeach ?> + </ul> + </section> + </article> + <? endif ?> + <section class="splitted-layout"> <? if ($show_info) : ?> <article class="studip left-part"> <header> @@ -328,6 +357,7 @@ </article> <? endif ?> <? endif ?> + </section> <footer data-dialog-button> <? if ($prev_request) : ?> <?= \Studip\LinkButton::create( @@ -386,4 +416,4 @@ ) ?> <? endif ?> </footer> -</form> \ No newline at end of file +</form> diff --git a/resources/assets/stylesheets/scss/resources.scss b/resources/assets/stylesheets/scss/resources.scss index 41d87ba0a09..1f57dbf4df8 100644 --- a/resources/assets/stylesheets/scss/resources.scss +++ b/resources/assets/stylesheets/scss/resources.scss @@ -452,87 +452,89 @@ form#resolve-request, form#decline-request { @media all and (min-width: 1600px) { form#resolve-request { - display: flex; - flex-direction: row; - flex-wrap: wrap; - - article.assign-dates { - div { - overflow-x: auto; - max-height: 250px; - } - } - article.assign-dates, div[data-dialog-button] { - header { - margin: 0; + section.splitted-layout { + display: flex; + flex-direction: row; + flex-wrap: wrap; + + article.assign-dates { + div { + overflow-x: auto; + max-height: 250px; + } } - - table { - > tbody:last-of-type { - > tr:last-child { - > td { - border-bottom: none; - } - } + article.assign-dates, div[data-dialog-button] { + header { + margin: 0; } - &.default { - > thead { - > tr { - > th { - &:first-child { - z-index: 2; - background-color: $content-color-20; - min-width: 180px; - left: 0; - } - position: sticky; - top: 0; - z-index: 1; - border-top: none; - border-bottom: none !important; - box-shadow: inset 0 1px 0 $brand-color-darker; + + table { + > tbody:last-of-type { + > tr:last-child { + > td { + border-bottom: none; } } } - > tbody { - > tr { - > td { - &:first-child { + &.default { + > thead { + > tr { + > th { + &:first-child { + z-index: 2; + background-color: $content-color-20; + min-width: 180px; + left: 0; + } position: sticky; - left: 0; + top: 0; z-index: 1; - background: $white; + border-top: none; + border-bottom: none !important; + box-shadow: inset 0 1px 0 $brand-color-darker; + } + } + } + > tbody { + > tr { + > td { + &:first-child { + position: sticky; + left: 0; + z-index: 1; + background: $white; + } } } } } } - } - margin: 0; - height: 100%; - overflow-y: auto; - width: 100%; - padding: 0; - } + margin: 0; + height: 100%; + overflow-y: auto; + width: 100%; + padding: 0; + } - article { - &.left-part, &.right-part { + article { + &.left-part, &.right-part { - flex-grow: 1; - margin-bottom: 10px; - } + flex-grow: 1; + margin-bottom: 10px; + } - &.left-part { - width: 50%; - } - &.right-part { - width: 40%; - padding-left: 1em; - } + &.left-part { + width: 50%; + } + &.right-part { + width: 40%; + padding-left: 1em; + } - section { - padding-top: 0; + section { + padding-top: 0; + } } } } @@ -543,4 +545,4 @@ form#resolve-request, form#decline-request { form#resolve-request article.right-part { padding-bottom: 10px; } -} \ No newline at end of file +} -- GitLab