Skip to content
Snippets Groups Projects
Commit 4682fb5d authored by David Siegfried's avatar David Siegfried
Browse files

fixes #3980

Closes #3980

Merge request studip/studip!2830
parent 4693ea0f
No related branches found
No related tags found
No related merge requests found
...@@ -274,7 +274,6 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -274,7 +274,6 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->selected_room_id = Request::get('selected_room_id'); $this->selected_room_id = Request::get('selected_room_id');
$_SESSION[$request_id]['room_id'] = $this->selected_room_id; $_SESSION[$request_id]['room_id'] = $this->selected_room_id;
$_SESSION[$request_id]['select_room'] = true; $_SESSION[$request_id]['select_room'] = true;
$this->redirect( $this->redirect(
'course/room_requests/request_check_properties/' . $this->request_id 'course/room_requests/request_check_properties/' . $this->request_id
); );
...@@ -289,8 +288,6 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -289,8 +288,6 @@ class Course_RoomRequestsController extends AuthenticatedController
); );
return; return;
} }
// or we filter via category
else if (Request::get('category_id') && Request::submitted('select_properties')) { else if (Request::get('category_id') && Request::submitted('select_properties')) {
$_SESSION[$request_id]['search_by'] = 'category'; $_SESSION[$request_id]['search_by'] = 'category';
$_SESSION[$request_id]['room_category_id'] = Request::get('category_id'); $_SESSION[$request_id]['room_category_id'] = Request::get('category_id');
...@@ -310,39 +307,13 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -310,39 +307,13 @@ class Course_RoomRequestsController extends AuthenticatedController
// for step 2: after choosing a specific room OR searching via properties // for step 2: after choosing a specific room OR searching via properties
if ($this->step === 2) { 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 // find rooms fitting to category and properties
if (Request::submitted('search_rooms')) { if (Request::submitted('search_rooms')) {
$this->selected_properties = Request::getArray('selected_properties'); $this->selected_properties = Request::getArray('selected_properties');
$_SESSION[$request_id]['selected_properties'] = $this->selected_properties; $_SESSION[$request_id]['selected_properties'] = $this->selected_properties;
// no min number of seats // no min number of seats
if ( 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' && $_SESSION[$request_id]['search_by'] === 'category'
) { ) {
PageLayout::postError( PageLayout::postError(
...@@ -360,13 +331,42 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -360,13 +331,42 @@ class Course_RoomRequestsController extends AuthenticatedController
} }
} }
// let's find all the properties belonging to the selected category if ($_SESSION[$request_id]['search_by'] === 'roomname') {
$this->room_category_id = $_SESSION[$request_id]['room_category_id']; // find category via room
$this->category = ResourceCategory::find($this->room_category_id); $this->category = ResourceCategory::find($this->selected_room_category_id);
$this->available_properties = $this->category->getRequestableProperties(); 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->preparation_time = $_SESSION[$request_id]['preparation_time'] ?? null;
$this->comment = $_SESSION[$request_id]['comment'] ?? null; $this->comment = $_SESSION[$request_id]['comment'] ?? null;
$this->request->category_id = $_SESSION[$request_id]['room_category_id']; $this->request->category_id = $_SESSION[$request_id]['room_category_id'];
...@@ -376,6 +376,7 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -376,6 +376,7 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->selected_room_id = Request::get('selected_room_id'); $this->selected_room_id = Request::get('selected_room_id');
$_SESSION[$request_id]['room_id'] = $this->selected_room_id; $_SESSION[$request_id]['room_id'] = $this->selected_room_id;
$_SESSION[$request_id]['selected_properties'] = Request::getArray('selected_properties'); $_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 ); $this->redirect('course/room_requests/request_show_summary/' . $this->request_id );
} }
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
] ]
) ?> ) ?>
<? if ($category) : ?> <? if (!empty($category)) : ?>
<?= Icon::create('decline')->asInput( <?= Icon::create('decline')->asInput(
[ [
'title' => _('alle Angaben zurücksetzen'), 'title' => _('alle Angaben zurücksetzen'),
......
...@@ -224,20 +224,24 @@ ...@@ -224,20 +224,24 @@
['data-dialog' => 'size=big']) ?> ['data-dialog' => 'size=big']) ?>
<? endif ?> <? endif ?>
<? if (Request::isXhr() && !$locked && Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS): ?> <? if (Request::isXhr() && !$locked && Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS): ?>
<? ?> <? if (isset($request_id)) : ?>
<?= Studip\LinkButton::create( <?= Studip\LinkButton::create(
(isset($request_id) ? _('Zur Raumanfrage wechseln') : _('Raumanfrage erstellen')), _('Zur Raumanfrage wechseln'),
( $controller->url_for(
isset($request_id)
? $controller->url_for(
'course/room_requests/request_show_summary/' . $request_id 'course/room_requests/request_show_summary/' . $request_id
) ),
: $controller->url_for( ['data-dialog' => 'size=big']
'course/room_requests/new_request/' . $request_id, ) ?>
<? else : ?>
<?= Studip\LinkButton::create(
_('Raumanfrage erstellen'),
$controller->url_for(
'course/room_requests/new_request',
array_merge($params, ['range_str' => 'date', 'range_id' => $date->id]) array_merge($params, ['range_str' => 'date', 'range_id' => $date->id])
) ),
), ['data-dialog' => 'size=big']
['data-dialog' => 'size=big']) ?> ) ?>
<? endif ?>
<? endif ?> <? endif ?>
</footer> </footer>
</form> </form>
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