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

re #1327

parent c8bcec4b
No related branches found
No related tags found
No related merge requests found
......@@ -49,8 +49,9 @@ class Course_RoomRequestsController extends AuthenticatedController
$pagetitle .= _('Verwalten von Raumanfragen');
PageLayout::setTitle($pagetitle);
$this->available_room_categories = ResourceCategory::findByClass_name('Room');
$this->available_room_categories = ResourceCategory::findByClass_name('Room');
$this->step = 0;
}
/**
......@@ -273,7 +274,7 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->request = null;
$this->request = RoomRequest::find(Request::get('request_id')) ? RoomRequest::find(Request::get('request_id')) : new RoomRequest($this->request_id);
// TODO no idea why we need this and what it does
// time ranges (start date, end date)
$this->request->setRangeFields('course', [Context::getId()]);
$this->request_time_intervals = $this->request->getTimeIntervals();
......@@ -285,25 +286,28 @@ class Course_RoomRequestsController extends AuthenticatedController
public function request_first_step_action($request_id)
{
$this->request_id = $request_id;
$this->step = 1;
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');
$_SESSION[$request_id]['room_name'] = $this->room_name;
$this->search_by_roomname = Request::submitted('search_by_name');
$this->category_id = Request::get('category_id');
$_SESSION[$request_id]['room_category'] = $this->category_id;
$this->search_by_category = Request::submitted('search_by_category');
// TODO do we need to delete one of these after step 0?
// 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]['room_name'] = $this->room_name;
$this->redirect(
'course/room_requests/find_by_roomname/' . $this->request_id
'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]['room_category'] = $this->category_id;
$this->redirect(
'course/room_requests/find_by_category/' . $this->request_id
'course/room_requests/find_by_category/' . $this->request_id . '/' . $this->step
);
} else {
$this->redirect(
......@@ -314,10 +318,12 @@ class Course_RoomRequestsController extends AuthenticatedController
}
public function find_by_roomname_action($request_id)
public function find_by_roomname_action($request_id, $step)
{
$this->request_id = $request_id;
$this->step = $step;
$this->room_name = $_SESSION[$request_id]['room_name'];
$this->available_rooms = RoomManager::findRooms(
$this->room_name,
null,
......@@ -329,14 +335,28 @@ class Course_RoomRequestsController extends AuthenticatedController
// small icons before room name to show whether they are bookable or not
$this->available_room_icons = $this->getRoomBookingIcons($this->available_rooms, $this->request_id);
$this->selected_room = Resource::find($_SESSION[$request_id]['room_id']);
// after selecting a room, go to next step
if ((Request::submitted('request_second_step'))) {
$this->selected_room_id = Request::get('selected_room_id');
$_SESSION[$request_id]['room_id'] = $this->selected_room_id;
$this->redirect(
'course/room_requests/request_second_step/' . $this->request_id
);
}
}
public function find_by_category_action($request_id)
public function find_by_category_action($request_id, $step)
{
$this->request_id = $request_id;
$this->step = $step;
$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);
......@@ -346,6 +366,18 @@ class Course_RoomRequestsController extends AuthenticatedController
}
public function request_second_step_action($request_id)
{
$this->request_id = $request_id;
$this->step = 2;
//$this->selected_room = Resource::find($_SESSION[$request_id]['room_id']);
$this->redirect(
'course/room_requests/find_by_roomname/' . $this->request_id . '/' . $this->step
);
}
private function getRoomBookingIcons($available_rooms, $request_id)
{
$this->request_id = $request_id;
......
......@@ -4,20 +4,13 @@
_('Zurück'),
$controller->link_for('course/room_requests/new_request/' . $request_id),
[
'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'
]
) ?>
<?= \Studip\Button::create(_('Raum auswählen und weiter'), 'request_second_step') ?>
<? endif ?>
<?= \Studip\LinkButton::createCancel(
......
<label><?= _('Ausgewählter Raum') ?></label>
<? if ($selected_room): ?>
<input type="hidden" name="selected_room_id"
value="<?= htmlReady($selected_room->id) ?>">
<?= htmlReady($selected_room->name) ?>
<? endif ?>
<?= var_dump($selected_room); ?>
<form method="post" name="room_request" class="default"
action="<?= $this->controller->link_for('course/room_requests/request_first_step/' . $request_id) ?>"
action="<?= $this->controller->link_for('course/room_requests/request_second_step/' . $request_id . '/' . $this->step) ?>"
<?= Request::isXhr() ? 'data-dialog="size=big"' : ''?>>
<input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>">
<?= CSRFProtection::tokenTag() ?>
......@@ -125,4 +125,4 @@
</section>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => 1]) ?>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => $step]) ?>
<form method="post" name="room_request" class="default"
action="<?= $this->controller->link_for('course/room_requests/request_first_step/' . $request_id) ?>"
action="<?= $this->controller->link_for('course/room_requests/find_by_roomname/' . $request_id . '/' . $this->step) ?>"
<?= Request::isXhr() ? 'data-dialog="size=big"' : ''?>>
<input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>">
<?= CSRFProtection::tokenTag() ?>
......@@ -14,6 +14,10 @@
<fieldset>
<legend><?= _('Wünschbare Eigenschaften') ?></legend>
<? if ($step == 2) : ?>
<?= $this->render_partial('course/room_requests/_room_with_properties') ?>
<? endif ?>
<? if ($available_room_categories): ?>
<label>
<?= _('Raumkategorie') ?>
......@@ -22,7 +26,7 @@
<option value=""><?= _('bitte auswählen') ?></option>
<? foreach ($available_room_categories as $rc): ?>
<option value="<?= htmlReady($rc->id) ?>"
<?= ($category_id == $rc->id)
<?= ($selected_room->category_id == $rc->id)
? 'selected="selected"'
: '' ?>>
<?= htmlReady($rc->name) ?>
......@@ -92,7 +96,10 @@
<?= $available_room_icons[$room->id] ?>
<input type="radio" name="selected_room_id"
data-activates="button[type='submit'][name='select_room']"
value="<?= htmlReady($room->id) ?>">
value="<?= htmlReady($room->id) ?>"
<? if ($_SESSION[$request_id]['room_id'] == $room->id) echo 'checked' ?>>
>
<?= htmlReady(mb_substr($room->name, 0, 50)); ?>
<? if ($room->properties): ?>
<? $property_names = $room->getInfolabelPrperties()
......@@ -112,5 +119,6 @@
</div>
</section>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => 1]) ?>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => $step]) ?>
<? endif ?>
......@@ -8,7 +8,7 @@
<?= $this->render_partial(
'course/room_requests/_new_request_header') ?>
Request ID: <?= $request_id ?>
<?= var_dump($_SESSION[$request_id]) ?>
<br/>
<section class="resources-grid">
<div>
......@@ -23,7 +23,7 @@ Request ID: <?= $request_id ?>
<option value=""><?= _('bitte auswählen') ?></option>
<? foreach ($available_room_categories as $rc): ?>
<option value="<?= htmlReady($rc->id) ?>"
<?= ($category_id == $rc->id)
<?= ($_SESSION[$request_id]['room_category'] == $rc->id)
? 'selected="selected"'
: '' ?>>
<?= htmlReady($rc->name) ?>
......@@ -88,5 +88,5 @@ Request ID: <?= $request_id ?>
</div>
</section>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => 0]) ?>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => $step]) ?>
<? endif ?>
<?php
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