diff --git a/app/controllers/course/room_requests.php b/app/controllers/course/room_requests.php index 14c0179b08f257dc7414e49661b083c8ebec385d..b1db6328296f3dc136527012edadd793b4e1244c 100644 --- a/app/controllers/course/room_requests.php +++ b/app/controllers/course/room_requests.php @@ -274,7 +274,6 @@ class Course_RoomRequestsController extends AuthenticatedController $this->selected_room_id = Request::get('selected_room_id'); $_SESSION[$request_id]['room_id'] = $this->selected_room_id; $_SESSION[$request_id]['select_room'] = true; - $this->redirect( 'course/room_requests/request_check_properties/' . $this->request_id ); @@ -289,8 +288,6 @@ class Course_RoomRequestsController extends AuthenticatedController ); return; } - - // or we filter via category else if (Request::get('category_id') && Request::submitted('select_properties')) { $_SESSION[$request_id]['search_by'] = 'category'; $_SESSION[$request_id]['room_category_id'] = Request::get('category_id'); @@ -310,39 +307,13 @@ class Course_RoomRequestsController extends AuthenticatedController // for step 2: after choosing a specific room OR searching via properties if ($this->step === 2) { - if ($_SESSION[$request_id]['search_by'] == 'roomname') { - // find category via room - $this->category = ResourceCategory::find($this->selected_room_category_id); - if ($this->category) { - $this->available_properties = $this->category->getRequestableProperties(); - } - - $this->selected_properties = $_SESSION[$request_id]['selected_properties']; - $this->room = Room::find($_SESSION[$request_id]['room_id']); - $this->selected_properties['seats'] = $_SESSION[$request_id]['selected_properties']['seats'] - ?: $this->course->admission_turnout - ?: Config::get()->RESOURCES_ROOM_REQUEST_DEFAULT_SEATS; - $_SESSION[$request_id]['selected_properties']['seats'] = $this->selected_properties['seats']; - } else if ($_SESSION[$request_id]['search_by'] === 'category') { - $this->room = Room::find($_SESSION[$request_id]['room_id']); - if ($this->room) { - $this->grouped_properties = $this->room->getGroupedProperties(); - foreach ($this->grouped_properties as $properties) { - foreach ($properties as $property) { - $this->selected_properties[$property->name] = $property->state; - } - } - } - - } - // find rooms fitting to category and properties if (Request::submitted('search_rooms')) { $this->selected_properties = Request::getArray('selected_properties'); $_SESSION[$request_id]['selected_properties'] = $this->selected_properties; // no min number of seats if ( - (!$_SESSION[$request_id]['selected_properties']['seats'] || $_SESSION[$request_id]['selected_properties']['seats'] < 1) + (!isset($_SESSION[$request_id]['selected_properties']['seats']) || $_SESSION[$request_id]['selected_properties']['seats'] < 1) && $_SESSION[$request_id]['search_by'] === 'category' ) { PageLayout::postError( @@ -360,13 +331,42 @@ class Course_RoomRequestsController extends AuthenticatedController } } - // let's find all the properties belonging to the selected category - $this->room_category_id = $_SESSION[$request_id]['room_category_id']; - $this->category = ResourceCategory::find($this->room_category_id); - $this->available_properties = $this->category->getRequestableProperties(); + if ($_SESSION[$request_id]['search_by'] === 'roomname') { + // find category via room + $this->category = ResourceCategory::find($this->selected_room_category_id); + if ($this->category) { + $this->available_properties = $this->category->getRequestableProperties(); + } + + $this->selected_properties = $_SESSION[$request_id]['selected_properties'] ?? null; + $this->room = Room::find($_SESSION[$request_id]['room_id']); + if (!isset($_SESSION[$request_id]['selected_properties']['seats'])) { + $this->selected_properties['seats'] = $this->course->admission_turnout ?? Config::get()->RESOURCES_ROOM_REQUEST_DEFAULT_SEATS; + } + $_SESSION[$request_id]['selected_properties']['seats'] = $this->selected_properties['seats']; + $_SESSION[$request_id]['room_category_id'] = $this->selected_room_category_id; + } else if ($_SESSION[$request_id]['search_by'] === 'category') { + $this->room = Room::find($_SESSION[$request_id]['room_id']); + if ($this->room) { + $this->grouped_properties = $this->room->getGroupedProperties(); + $this->selected_properties = []; + foreach ($this->grouped_properties as $properties) { + foreach ($properties as $property) { + $this->selected_properties[$property->name] = $property->state; + } + } + } + } else { + // let's find all the properties belonging to the selected category + $this->room_category_id = $_SESSION[$request_id]['room_category_id']; + $this->category = ResourceCategory::find($this->room_category_id); + if ($this->category) { + $this->available_properties = $this->category->getRequestableProperties(); + } + // properties, like 'Sitzplätze', 'behindertengerecht' etc + $this->selected_properties = $_SESSION[$request_id]['selected_properties'] ?? null; + } - // properties, like 'Sitzplätze', 'behindertengerecht' etc - $this->selected_properties = $_SESSION[$request_id]['selected_properties'] ?? null; $this->preparation_time = $_SESSION[$request_id]['preparation_time'] ?? null; $this->comment = $_SESSION[$request_id]['comment'] ?? null; $this->request->category_id = $_SESSION[$request_id]['room_category_id']; @@ -376,6 +376,7 @@ class Course_RoomRequestsController extends AuthenticatedController $this->selected_room_id = Request::get('selected_room_id'); $_SESSION[$request_id]['room_id'] = $this->selected_room_id; $_SESSION[$request_id]['selected_properties'] = Request::getArray('selected_properties'); + $_SESSION[$request_id]['room_category_id'] = $this->room_category_id; $this->redirect('course/room_requests/request_show_summary/' . $this->request_id ); } } diff --git a/app/views/course/room_requests/request_find_matching_rooms.php b/app/views/course/room_requests/request_find_matching_rooms.php index 01f42a410718477a1079d6c7e45e86d6bb9bf2ee..0a11aeb45976aeea3d121c07f98830f36539c931 100644 --- a/app/views/course/room_requests/request_find_matching_rooms.php +++ b/app/views/course/room_requests/request_find_matching_rooms.php @@ -41,7 +41,7 @@ ] ) ?> - <? if ($category) : ?> + <? if (!empty($category)) : ?> <?= Icon::create('decline')->asInput( [ 'title' => _('alle Angaben zurücksetzen'), diff --git a/app/views/course/timesrooms/editDate.php b/app/views/course/timesrooms/editDate.php index c4bd405ea1f6f5e91c9da128b94eff203b54ec31..e3bde2c2bcc59af7b70c7ce4c8d0604bcdfcf3d9 100644 --- a/app/views/course/timesrooms/editDate.php +++ b/app/views/course/timesrooms/editDate.php @@ -224,20 +224,24 @@ ['data-dialog' => 'size=big']) ?> <? endif ?> <? if (Request::isXhr() && !$locked && Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS): ?> - <? ?> - <?= Studip\LinkButton::create( - (isset($request_id) ? _('Zur Raumanfrage wechseln') : _('Raumanfrage erstellen')), - ( - isset($request_id) - ? $controller->url_for( + <? if (isset($request_id)) : ?> + <?= Studip\LinkButton::create( + _('Zur Raumanfrage wechseln'), + $controller->url_for( 'course/room_requests/request_show_summary/' . $request_id - ) - : $controller->url_for( - 'course/room_requests/new_request/' . $request_id, + ), + ['data-dialog' => 'size=big'] + ) ?> + <? else : ?> + <?= Studip\LinkButton::create( + _('Raumanfrage erstellen'), + $controller->url_for( + 'course/room_requests/new_request', array_merge($params, ['range_str' => 'date', 'range_id' => $date->id]) - ) - ), - ['data-dialog' => 'size=big']) ?> + ), + ['data-dialog' => 'size=big'] + ) ?> + <? endif ?> <? endif ?> </footer> </form>