From c8bcec4bbefd29145bd963809f16397d3af28301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michaela=20Br=C3=BCckner?= <brueckner@data-quest.de> Date: Wed, 17 Aug 2022 11:32:50 +0200 Subject: [PATCH] selection of properties, re #1327 --- app/controllers/course/room_requests.php | 26 +++- .../_new_request_form_footer.php | 33 +++-- .../course/room_requests/find_by_category.php | 129 +++++++++++++++++- .../course/room_requests/new_request.php | 4 +- 4 files changed, 166 insertions(+), 26 deletions(-) diff --git a/app/controllers/course/room_requests.php b/app/controllers/course/room_requests.php index e92011b5f8e..c9c7a731fa5 100644 --- a/app/controllers/course/room_requests.php +++ b/app/controllers/course/room_requests.php @@ -48,6 +48,9 @@ class Course_RoomRequestsController extends AuthenticatedController $pagetitle .= Course::find($this->course_id)->getFullname() . ' - '; $pagetitle .= _('Verwalten von Raumanfragen'); PageLayout::setTitle($pagetitle); + + $this->available_room_categories = ResourceCategory::findByClass_name('Room'); + } /** @@ -276,7 +279,6 @@ class Course_RoomRequestsController extends AuthenticatedController - $this->available_room_categories = ResourceCategory::findByClass_name('Room'); } @@ -286,10 +288,11 @@ class Course_RoomRequestsController extends AuthenticatedController if (Request::isPost()) { CSRFProtection::verifyUnsafeRequest(); + // either search by room (name) or room category, then go to next step $this->room_name = Request::get('room_name'); $this->search_by_roomname = Request::submitted('search_by_name'); $this->category_id = Request::get('category_id'); - $this->search_by_category = Request::submitted('select_properties'); + $this->search_by_category = Request::submitted('search_by_category'); // user looks for a special room OR for room within a selected category if ($this->room_name != null && $this->search_by_roomname != null) { @@ -298,7 +301,7 @@ class Course_RoomRequestsController extends AuthenticatedController 'course/room_requests/find_by_roomname/' . $this->request_id ); } else if ($this->category_id != null && $this->search_by_category != null ) { - $_SESSION[$request_id]['room_category'] = $this->catgeory_id; + $_SESSION[$request_id]['room_category'] = $this->category_id; $this->redirect( 'course/room_requests/find_by_category/' . $this->request_id ); @@ -330,6 +333,19 @@ class Course_RoomRequestsController extends AuthenticatedController } + public function find_by_category_action($request_id) + { + $this->request_id = $request_id; + $this->room_category_id = $_SESSION[$request_id]['room_category']; + $this->category = ResourceCategory::find($this->room_category_id); + + $this->request = RoomRequest::find($this->request_id) ? RoomRequest::find($this->request_id) : new RoomRequest($this->request_id); + + RoomManager::findRoomsByRequest($this->request); + $this->available_properties = $this->category->getRequestableProperties(); + + } + private function getRoomBookingIcons($available_rooms, $request_id) { $this->request_id = $request_id; @@ -382,12 +398,8 @@ class Course_RoomRequestsController extends AuthenticatedController - public function find_by_category_action($request_id) - { - } - /************ OLD STUFF *******/ /** diff --git a/app/views/course/room_requests/_new_request_form_footer.php b/app/views/course/room_requests/_new_request_form_footer.php index 31f72e42139..202350097da 100644 --- a/app/views/course/room_requests/_new_request_form_footer.php +++ b/app/views/course/room_requests/_new_request_form_footer.php @@ -1,22 +1,25 @@ <footer data-dialog-button> - <? if ($room_search_button) : ?> - <?= \Studip\Button::create( - _('Räume suchen'), - 'search_rooms', + <? if ($step >= 1) : ?> + <?= \Studip\LinkButton::create( + _('Zurück'), + $controller->link_for('course/room_requests/new_request/' . $request_id), [ - 'title' => _('Startet die Suche von Räumen anhand der gewählten Eigenschaften.') + 'step' => $step, + 'data-dialog' => 'size=big' ] + + ) ?> + <?= \Studip\LinkButton::create( + _('Raum auswählen und weiter'), + $controller->link_for('course/room_requests/new_request/' . $request_id), + [ + 'step' => $step +1, + 'data-dialog' => 'size=auto' + ] + ) ?> <? endif ?> - <? if ($room_select_button) : ?> - <?= \Studip\Button::create(_('Raum auswählen'), 'select_room') ?> - <? endif ?> - <? if ($save_buttons) : ?> - <?= \Studip\Button::create(_('Speichern'), 'save_and_close') ?> - <? endif ?> - <? if ($select_properties_button) : ?> - <?= \Studip\Button::create(_('Eigenschaften wählen'), 'select_properties') ?> - <? endif ?> + <?= \Studip\LinkButton::createCancel( _('Abbrechen'), $controller->link_for('course/room_requests/index/' . $course_id), @@ -26,4 +29,4 @@ ) ?> </footer> </form> -<?= $step ?> +Step: <?= $step ?> diff --git a/app/views/course/room_requests/find_by_category.php b/app/views/course/room_requests/find_by_category.php index b3d9bbc7f37..f12239749a8 100644 --- a/app/views/course/room_requests/find_by_category.php +++ b/app/views/course/room_requests/find_by_category.php @@ -1 +1,128 @@ -<?php +<form method="post" name="room_request" class="default" + action="<?= $this->controller->link_for('course/room_requests/request_first_step/' . $request_id) ?>" + <?= Request::isXhr() ? 'data-dialog="size=big"' : ''?>> + <input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>"> + <?= CSRFProtection::tokenTag() ?> + + + <?= $this->render_partial( + 'course/room_requests/_new_request_header') ?> + + <?= var_dump($_SESSION[$request_id]) ?> + <section class="resources-grid"> + <div> + <fieldset> + <legend><?= _('Wünschbare Eigenschaften') ?></legend> + + <? if ($available_room_categories): ?> + <label> + <?= _('Raumkategorie') ?> + <span class="flex-row"> + <select name="category_id" <?= $category ? 'disabled' : '' ?>> + <option value=""><?= _('bitte auswählen') ?></option> + <? foreach ($available_room_categories as $rc): ?> + <option value="<?= htmlReady($rc->id) ?>" + <?= ($_SESSION[$request_id]['room_category'] == $rc->id) + ? 'selected="selected"' + : '' ?>> + <?= htmlReady($rc->name) ?> + </option> + <? endforeach ?> + </select> + <? if ($category) : ?> + <?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'reset_category', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? else : ?> + <?= Icon::create('accept', Icon::ROLE_CLICKABLE, ['title' => _('Raumtyp auswählen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'select_properties', + 'value' => _('Raumtyp auswählen'), + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? endif ?> + </span> + </label> + <? endif ?> + + <!-- ROOM CATEGORY PROPERTIES --> + <? if ($available_properties) : ?> + <? foreach ($available_properties as $property) : ?> + <?= $property->toHtmlInput( + $selected_properties[$property->name], + 'selected_properties[' . htmlReady($property->name) . ']', + true, + false + ) ?> + <? endforeach ?> + <? endif ?> + + <label> + <?= _('Rüstzeit (in Minuten)') ?> + <input type="number" name="preparation_time" + value="<?= htmlReady($preparation_time) ?>" + min="0" max="<?= htmlReady($max_preparation_time) ?>"> + </label> + + <? if ($user_is_global_resource_admin) : ?> + <label> + <input type="checkbox" name="reply_lecturers" value="1" + <?= $reply_lecturers + ? 'checked="checked"' + : '' + ?>> + <?= _('Benachrichtigung bei Ablehnung der Raumanfrage auch an alle Lehrenden der Veranstaltung senden') ?> + </label> + <? endif ?> + + <label> + <?= _('Nachricht an die Raumvergabe') ?> + <textarea name="comment" cols="58" rows="4" + placeholder="<?= _('Weitere Wünsche oder Bemerkungen zur angefragten Raumbelegung') ?>"><?= htmlReady($comment) ?></textarea> + </label> + + </fieldset> + </div> + + <div> + <fieldset> + <legend><?= _('Raumsuche') ?></legend> + <label> + <?= _('Raumname') ?> + <span class="flex-row"> + <input type="text" name="room_name" value="<?= htmlReady($room_name) ?>"> + <?= Icon::create('search', Icon::ROLE_CLICKABLE)->asInput( + [ + 'name' => 'search_by_name', + 'class' => 'text-bottom', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? if ($room_name) : ?> + <?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'reset_category', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? endif?> + </span> + </label> + + </fieldset> + + </div> + </section> + + +<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => 1]) ?> diff --git a/app/views/course/room_requests/new_request.php b/app/views/course/room_requests/new_request.php index 3b5dcef3bdc..4a6fdbbccb3 100644 --- a/app/views/course/room_requests/new_request.php +++ b/app/views/course/room_requests/new_request.php @@ -8,10 +8,8 @@ <?= $this->render_partial( 'course/room_requests/_new_request_header') ?> -<?= $request_id ?> +Request ID: <?= $request_id ?> <br/> - <?= var_dump($request_time_intervals) ?> - <section class="resources-grid"> <div> <fieldset> -- GitLab