Skip to content
Snippets Groups Projects
Commit f75b6765 authored by Michaela Brückner's avatar Michaela Brückner :unicorn: Committed by Jan-Hendrik Willms
Browse files

check for seats, re #1327

parent 04f21c3b
No related branches found
No related tags found
No related merge requests found
...@@ -292,11 +292,12 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -292,11 +292,12 @@ class Course_RoomRequestsController extends AuthenticatedController
{ {
$this->request_id = $request_id; $this->request_id = $request_id;
$this->step = 1; $this->step = 1;
$_SESSION[$request_id]['search_by'] = '';
if (Request::isPost()) { if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest(); CSRFProtection::verifyUnsafeRequest();
// either search by room (name) or room category, then go to next step // either search by room name or room category, then go to next step
$this->room_name = Request::get('room_name'); $this->room_name = Request::get('room_name');
$_SESSION[$request_id]['room_name'] = $this->room_name; $_SESSION[$request_id]['room_name'] = $this->room_name;
$this->search_by_roomname = Request::submitted('search_by_name'); $this->search_by_roomname = Request::submitted('search_by_name');
...@@ -306,10 +307,13 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -306,10 +307,13 @@ class Course_RoomRequestsController extends AuthenticatedController
// user looks for a special room OR for room within a selected category // user looks for a special room OR for room within a selected category
if ($this->room_name != null && $this->search_by_roomname != null) { if ($this->room_name != null && $this->search_by_roomname != null) {
$_SESSION[$request_id]['search_by'] = 'roomname';
$this->redirect( $this->redirect(
'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step 'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step
); );
} else if ($this->category_id != null && $this->search_by_category != null ) { } else if ($this->category_id != null && $this->search_by_category != null ) {
$_SESSION[$request_id]['search_by'] = 'category';
$this->redirect( $this->redirect(
'course/room_requests/find_by_category/' . $this->request_id . '/' . $this->step 'course/room_requests/find_by_category/' . $this->request_id . '/' . $this->step
); );
...@@ -345,7 +349,6 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -345,7 +349,6 @@ class Course_RoomRequestsController extends AuthenticatedController
// for step 2 after choosing a room // for step 2 after choosing a room
if ($step == 2) { if ($step == 2) {
echo"Hallo";
$this->category = ResourceCategory::find($this->selected_room_category_id); $this->category = ResourceCategory::find($this->selected_room_category_id);
$this->available_properties = $this->category->getRequestableProperties(); $this->available_properties = $this->category->getRequestableProperties();
} }
...@@ -369,6 +372,25 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -369,6 +372,25 @@ class Course_RoomRequestsController extends AuthenticatedController
'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step 'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step
); );
} }
$this->selected_properties = Request::getArray('selected_properties');
$_SESSION[$request_id]['seats'] = $this->selected_properties['seats'];
if (Request::submitted('save_request')) {
// we need the seats property with at least one seat, else we get an error
if ($_SESSION[$request_id]['seats'] < 1) {
PageLayout::postError(
_('Es wurde keine Anzahl an gewünschten Sitzplätzen angegeben!')
);
$this->redirect(
'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step
);
} else {
// TODO actually save the request
PageLayout::postSuccess(_('Die Anfrage wurde gespeichert!'));
$this->relocate('course/timesrooms/');
}
}
} }
...@@ -399,6 +421,13 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -399,6 +421,13 @@ class Course_RoomRequestsController extends AuthenticatedController
'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step 'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step
); );
}
public function save_request_action($request_id) {
$this->request_id = $request_id;
} }
private function getRoomBookingIcons($available_rooms, $request_id) private function getRoomBookingIcons($available_rooms, $request_id)
......
...@@ -3,16 +3,18 @@ ...@@ -3,16 +3,18 @@
<?= \Studip\LinkButton::create( <?= \Studip\LinkButton::create(
_('Zurück'), _('Zurück'),
$controller->link_for('course/room_requests/new_request/' . $request_id), $controller->link_for('course/room_requests/new_request/' . $request_id),
[ ['data-dialog' => 'size=big']
'data-dialog' => 'size=big'
]
) ?> ) ?>
<?= \Studip\Button::create(_('Weiter'), 'request_second_step') ?>
<? endif ?> <? endif ?>
<? if ($step == 1 && $_SESSION[$request_id]['search_by'] == 'roomname') : ?>
<?= \Studip\Button::create(_('Weiter'), 'request_second_step') ?>
<? elseif (($step == 1 && $_SESSION[$request_id]['search_by'] == 'category') || ($step == 2 && $_SESSION[$request_id]['search_by'] == 'roomname')) : ?>
<?= \Studip\Button::create(_('Speichern'), 'save_request') ?>
<? endif ?>
<?= \Studip\LinkButton::createCancel( <?= \Studip\LinkButton::createCancel(
_('Abbrechen'), _('Abbrechen'),
$controller->link_for('course/room_requests/index/' . $course_id), $controller->link_for('course/room_requests/index/' . $course_id),
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
<!-- ROOM CATEGORY PROPERTIES --> <!-- ROOM CATEGORY PROPERTIES -->
<? if ($available_properties) : ?> <? if ($available_properties) : ?>
<? foreach ($available_properties as $property) : ?> <? foreach ($available_properties as $property) : ?>
<?= var_dump($property) ?>
<?= $property->toHtmlInput( <?= $property->toHtmlInput(
$selected_properties[$property->name], $selected_properties[$property->name],
'selected_properties[' . htmlReady($property->name) . ']', 'selected_properties[' . htmlReady($property->name) . ']',
......
...@@ -56,7 +56,9 @@ ...@@ -56,7 +56,9 @@
</span> </span>
</label> </label>
<? endif ?> <? endif ?>
<!-- ROOM CATEGORY PROPERTIES -->
<? if ($step == 2) : ?>
<!-- After choosing a category or room -->
<? if ($available_properties) : ?> <? if ($available_properties) : ?>
<? foreach ($available_properties as $property) : ?> <? foreach ($available_properties as $property) : ?>
<?= $property->toHtmlInput( <?= $property->toHtmlInput(
...@@ -67,21 +69,41 @@ ...@@ -67,21 +69,41 @@
) ?> ) ?>
<? endforeach ?> <? endforeach ?>
<? endif ?> <? 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>
<? endif ?>
<? if (!$embedded) : ?> <? if (!$embedded) : ?>
</fieldset> </fieldset>
</div> </div>
<div> <div>
<fieldset> <fieldset>
<legend><?= _('Raumsuche') ?></legend> <legend><?= _('Raumsuche') ?></legend>
<label> <label>
<?= _('Raumname') ?> <?= _('Raumname') ?>
<span class="flex-row"> <span class="flex-row">
<input type="text" name="room_name" value="<?= htmlReady($room_name) ?>"> <input type="text" name="room_name" value="<?= htmlReady($_SESSION[$request_id]['room_name']) ?>">
<?= Icon::create('search', Icon::ROLE_CLICKABLE)->asInput( <?= Icon::create('search', Icon::ROLE_CLICKABLE)->asInput(
[ [
'name' => 'search_by_name', 'name' => 'search_by_name',
...@@ -89,7 +111,7 @@ ...@@ -89,7 +111,7 @@
'style' => 'margin-left: 0.2em; margin-top: 0.6em;' 'style' => 'margin-left: 0.2em; margin-top: 0.6em;'
] ]
) ?> ) ?>
<? if ($room_name) : ?> <? if ($_SESSION[$request_id]['room_name']) : ?>
<?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput( <?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput(
[ [
'type' => 'image', 'type' => 'image',
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<label> <label>
<?= _('Raumname') ?> <?= _('Raumname') ?>
<span class="flex-row"> <span class="flex-row">
<input type="text" name="room_name" value="<?= htmlReady($room_name) ?>"> <input type="text" name="room_name" value="<?= htmlReady($_SESSION[$request_id]['room_name']) ?>">
<?= Icon::create('search', Icon::ROLE_CLICKABLE)->asInput( <?= Icon::create('search', Icon::ROLE_CLICKABLE)->asInput(
[ [
'name' => 'search_by_name', 'name' => 'search_by_name',
......
<?php
<?php
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment