Skip to content
Snippets Groups Projects
Commit aad38b53 authored by Michaela Brückner's avatar Michaela Brückner :unicorn:
Browse files

check for seats, re #1327

parent e7f0e311
No related branches found
No related tags found
No related merge requests found
......@@ -292,11 +292,12 @@ class Course_RoomRequestsController extends AuthenticatedController
{
$this->request_id = $request_id;
$this->step = 1;
$_SESSION[$request_id]['search_by'] = '';
if (Request::isPost()) {
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');
$_SESSION[$request_id]['room_name'] = $this->room_name;
$this->search_by_roomname = Request::submitted('search_by_name');
......@@ -306,10 +307,13 @@ class Course_RoomRequestsController extends AuthenticatedController
// user looks for a special room OR for room within a selected category
if ($this->room_name != null && $this->search_by_roomname != null) {
$_SESSION[$request_id]['search_by'] = 'roomname';
$this->redirect(
'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step
);
} else if ($this->category_id != null && $this->search_by_category != null ) {
$_SESSION[$request_id]['search_by'] = 'category';
$this->redirect(
'course/room_requests/find_by_category/' . $this->request_id . '/' . $this->step
);
......@@ -345,7 +349,6 @@ class Course_RoomRequestsController extends AuthenticatedController
// for step 2 after choosing a room
if ($step == 2) {
echo"Hallo";
$this->category = ResourceCategory::find($this->selected_room_category_id);
$this->available_properties = $this->category->getRequestableProperties();
}
......@@ -369,6 +372,25 @@ class Course_RoomRequestsController extends AuthenticatedController
'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
'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)
......
<footer data-dialog-button>
<? if ($step >= 1) : ?>
<?= \Studip\LinkButton::create(
_('Zurück'),
$controller->link_for('course/room_requests/new_request/' . $request_id),
[
'data-dialog' => 'size=big'
]
<footer data-dialog-button>
<? if ($step >= 1) : ?>
<?= \Studip\LinkButton::create(
_('Zurück'),
$controller->link_for('course/room_requests/new_request/' . $request_id),
['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(
_('Abbrechen'),
$controller->link_for('course/room_requests/index/' . $course_id),
[
'title' => _('Abbrechen')
]
) ?>
</footer>
<?= \Studip\LinkButton::createCancel(
_('Abbrechen'),
$controller->link_for('course/room_requests/index/' . $course_id),
[
'title' => _('Abbrechen')
]
) ?>
</footer>
</form>
Step: <?= $step ?>
......@@ -56,6 +56,7 @@
<!-- ROOM CATEGORY PROPERTIES -->
<? if ($available_properties) : ?>
<? foreach ($available_properties as $property) : ?>
<?= var_dump($property) ?>
<?= $property->toHtmlInput(
$selected_properties[$property->name],
'selected_properties[' . htmlReady($property->name) . ']',
......
......@@ -56,32 +56,54 @@
</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 ?>
<? if ($step == 2) : ?>
<!-- After choosing a category or room -->
<? 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>
<? endif ?>
<? if (!$embedded) : ?>
</fieldset>
</div>
<div>
<fieldset>
<legend><?= _('Raumsuche') ?></legend>
<label>
<?= _('Raumname') ?>
<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(
[
'name' => 'search_by_name',
......@@ -89,7 +111,7 @@
'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(
[
'type' => 'image',
......
......@@ -63,7 +63,7 @@
<label>
<?= _('Raumname') ?>
<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(
[
'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