diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index f37929ca6ba1061b5ae3ee533d141dbcc0cea3eb..11647ac8b4c2b7de7e10ae7611fb9ddab9af7197 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -180,7 +180,23 @@ class Course_TimesroomsController extends AuthenticatedController $dates = $this->course->getDatesWithExdates(); + $this->current_user = User::findCurrent(); + $this->user_has_permissions = ResourceManager::userHasGlobalPermission($this->current_user, 'admin'); + $check_room_requests = Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS; + $this->room_requests = RoomRequest::findBySQL( + 'course_id = :course_id + ORDER BY course_id, metadate_id, termin_id', + [ + 'course_id' => $this->course->id + ] + ); + + $this->global_requests = $this->course->room_requests->filter(function (RoomRequest $request) { + return $request->closed < 2 && !$request->termin_id; + }); + + $single_dates = []; $this->single_date_room_request_c = 0; foreach ($dates as $val) { diff --git a/app/views/course/timesrooms/_roomRequest.php b/app/views/course/timesrooms/_roomRequest.php index 3eecb3c46b193cbf32eee23baa9c049a1d3b2fee..e8ee82984c97f5bf4b15395c4bc91aa4c9979ece 100644 --- a/app/views/course/timesrooms/_roomRequest.php +++ b/app/views/course/timesrooms/_roomRequest.php @@ -1,8 +1,3 @@ -<?php -$global_requests = $course->room_requests->filter(function (RoomRequest $request) { - return $request->closed < 2 && !$request->termin_id; -}); -?> <section class="contentbox"> <header> <h1> @@ -29,13 +24,133 @@ $global_requests = $course->room_requests->filter(function (RoomRequest $request </nav> </header> + <?php + echo $flash['message']; + ?> + + <? if (count($room_requests)) : ?> <section> - <? if (count($global_requests) > 0): ?> - <p><?= _('Für diese Veranstaltung liegt eine offene Raumanfrage vor') ?></p> - <?= Studip\LinkButton::create(_('Raumanfragen anzeigen'), - URLHelper::getURL('dispatch.php/course/room_requests/index/' . $course->getId())) ?> - <? else: ?> - <p><?= _('Keine Raumanfrage vorhanden') ?></p> - <? endif ?> + <table class="default"> + <colgroup> + <col style="width: 40%"> + <col style="width: 20%"> + <col> + <col style="width: 50px"> + </colgroup> + <thead> + <tr> + <th><?= _('Art der Anfrage') ?></th> + <th><?= _('Anfragender') ?></th> + <th><?= _('Bearbeitungsstatus') ?></th> + <th></th> + </tr> + </thead> + <tbody> + <? foreach ($room_requests as $rr): ?> + <tr> + <td> + <?= htmlReady($rr->getTypeString(), 1, 1) ?> + </td> + <td> + <?= htmlReady($rr->user ? $rr->user->getFullName() : '') ?> + </td> + <td> + <?= htmlReady($rr->getStatusText()) ?> + </td> + <td class="actions"> + <a class="load-in-new-row" + href="<?= $controller->link_for('course/room_requests/info/' . $rr->id) ?>"> + <?= Icon::create( + 'info', + Icon::ROLE_CLICKABLE, + [ + 'title' => _('Weitere Informationen einblenden') + ] + ) ?> + </a> + <? $params = [] ?> + <? $dialog = []; ?> + <? if (Request::isXhr()) : ?> + <? $params['asDialog'] = true; ?> + <? $dialog['data-dialog'] = 'size=big' ?> + <? endif ?> + + <? $actionMenu = ActionMenu::get()->setContext($rr->getTypeString()) ?> + <? $actionMenu->addLink( + $controller->url_for('course/room_requests/request_summary/' . $rr->id, ['clear_cache' => 1]), + _('Diese Anfrage bearbeiten'), + Icon::create( + 'edit', + Icon::ROLE_CLICKABLE, + [ + 'title' => _('Diese Anfrage bearbeiten') + ] + ), + $dialog + ) ?> + + <?php + if ($rr->room && !$user_has_permissions) { + $user_has_permissions = $rr->room->userHasPermission($current_user, 'admin'); + } + ?> + + <? if ($user_has_permissions && (int)$rr->closed === 0): ?> + <? $actionMenu->addLink( + URLHelper::getURL( + 'dispatch.php/resources/room_request/resolve/' . $rr->id, + [ + 'reload-on-close' => 1, + 'single-request' => 1 + ] + ), + _('Diese Anfrage selbst auflösen'), + Icon::create( + 'admin', + Icon::ROLE_CLICKABLE, + [ + 'title' => _('Diese Anfrage selbst auflösen') + ] + ), + ['data-dialog' => '1'] + ) ?> + <? endif ?> + <? $actionMenu->addLink( + $controller->url_for('course/room_requests/delete/' . $rr->id), + _('Diese Anfrage löschen'), + Icon::create( + 'trash', + Icon::ROLE_CLICKABLE, + [ + 'title' => _('Diese Anfrage löschen') + ] + ) + ) ?> + <?= $actionMenu->render() ?> + </td> + </tr> + <? endforeach ?> + <? if ($request_id == $rr->id) : ?> + <tr> + <td colspan="4"> + <?= $this->render_partial('course/room_requests/_request.php', ['request' => $rr]); ?> + </td> + </tr> + <? endif ?> + </tbody> + </table> </section> + <? else : ?> + <?= MessageBox::info(_('Zu dieser Veranstaltung sind noch keine Raumanfragen vorhanden.')) ?> + <? endif ?> + + <? if (Request::isXhr()) : ?> + <div data-dialog-button> + <?= \Studip\LinkButton::createEdit( + _('Neue Raumanfrage erstellen'), + $controller->url_for('course/room_requests/new/' . $course_id, $url_params), + ['data-dialog' => 'size=big'] + ) ?> + </div> +<? endif ?> </section>