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 ...@@ -49,8 +49,9 @@ class Course_RoomRequestsController extends AuthenticatedController
$pagetitle .= _('Verwalten von Raumanfragen'); $pagetitle .= _('Verwalten von Raumanfragen');
PageLayout::setTitle($pagetitle); 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 ...@@ -273,7 +274,7 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->request = null; $this->request = null;
$this->request = RoomRequest::find(Request::get('request_id')) ? RoomRequest::find(Request::get('request_id')) : new RoomRequest($this->request_id); $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->setRangeFields('course', [Context::getId()]);
$this->request_time_intervals = $this->request->getTimeIntervals(); $this->request_time_intervals = $this->request->getTimeIntervals();
...@@ -285,25 +286,28 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -285,25 +286,28 @@ class Course_RoomRequestsController extends AuthenticatedController
public function request_first_step_action($request_id) public function request_first_step_action($request_id)
{ {
$this->request_id = $request_id; $this->request_id = $request_id;
$this->step = 1;
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;
$this->search_by_roomname = Request::submitted('search_by_name'); $this->search_by_roomname = Request::submitted('search_by_name');
$this->category_id = Request::get('category_id'); $this->category_id = Request::get('category_id');
$_SESSION[$request_id]['room_category'] = $this->category_id;
$this->search_by_category = Request::submitted('search_by_category'); $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 // 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]['room_name'] = $this->room_name;
$this->redirect( $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 ) { } else if ($this->category_id != null && $this->search_by_category != null ) {
$_SESSION[$request_id]['room_category'] = $this->category_id;
$this->redirect( $this->redirect(
'course/room_requests/find_by_category/' . $this->request_id 'course/room_requests/find_by_category/' . $this->request_id . '/' . $this->step
); );
} else { } else {
$this->redirect( $this->redirect(
...@@ -314,10 +318,12 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -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->request_id = $request_id;
$this->step = $step;
$this->room_name = $_SESSION[$request_id]['room_name']; $this->room_name = $_SESSION[$request_id]['room_name'];
$this->available_rooms = RoomManager::findRooms( $this->available_rooms = RoomManager::findRooms(
$this->room_name, $this->room_name,
null, null,
...@@ -329,14 +335,28 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -329,14 +335,28 @@ class Course_RoomRequestsController extends AuthenticatedController
// small icons before room name to show whether they are bookable or not // 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->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->request_id = $request_id;
$this->step = $step;
$this->room_category_id = $_SESSION[$request_id]['room_category']; $this->room_category_id = $_SESSION[$request_id]['room_category'];
$this->category = ResourceCategory::find($this->room_category_id); $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); $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 ...@@ -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) private function getRoomBookingIcons($available_rooms, $request_id)
{ {
$this->request_id = $request_id; $this->request_id = $request_id;
......
...@@ -4,20 +4,13 @@ ...@@ -4,20 +4,13 @@
_('Zurück'), _('Zurück'),
$controller->link_for('course/room_requests/new_request/' . $request_id), $controller->link_for('course/room_requests/new_request/' . $request_id),
[ [
'step' => $step,
'data-dialog' => 'size=big' '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 ?> <? endif ?>
<?= \Studip\LinkButton::createCancel( <?= \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" <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"' : ''?>> <?= Request::isXhr() ? 'data-dialog="size=big"' : ''?>>
<input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>"> <input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
...@@ -125,4 +125,4 @@ ...@@ -125,4 +125,4 @@
</section> </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" <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"' : ''?>> <?= Request::isXhr() ? 'data-dialog="size=big"' : ''?>>
<input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>"> <input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
<fieldset> <fieldset>
<legend><?= _('Wünschbare Eigenschaften') ?></legend> <legend><?= _('Wünschbare Eigenschaften') ?></legend>
<? if ($step == 2) : ?>
<?= $this->render_partial('course/room_requests/_room_with_properties') ?>
<? endif ?>
<? if ($available_room_categories): ?> <? if ($available_room_categories): ?>
<label> <label>
<?= _('Raumkategorie') ?> <?= _('Raumkategorie') ?>
...@@ -22,7 +26,7 @@ ...@@ -22,7 +26,7 @@
<option value=""><?= _('bitte auswählen') ?></option> <option value=""><?= _('bitte auswählen') ?></option>
<? foreach ($available_room_categories as $rc): ?> <? foreach ($available_room_categories as $rc): ?>
<option value="<?= htmlReady($rc->id) ?>" <option value="<?= htmlReady($rc->id) ?>"
<?= ($category_id == $rc->id) <?= ($selected_room->category_id == $rc->id)
? 'selected="selected"' ? 'selected="selected"'
: '' ?>> : '' ?>>
<?= htmlReady($rc->name) ?> <?= htmlReady($rc->name) ?>
...@@ -92,7 +96,10 @@ ...@@ -92,7 +96,10 @@
<?= $available_room_icons[$room->id] ?> <?= $available_room_icons[$room->id] ?>
<input type="radio" name="selected_room_id" <input type="radio" name="selected_room_id"
data-activates="button[type='submit'][name='select_room']" 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)); ?> <?= htmlReady(mb_substr($room->name, 0, 50)); ?>
<? if ($room->properties): ?> <? if ($room->properties): ?>
<? $property_names = $room->getInfolabelPrperties() <? $property_names = $room->getInfolabelPrperties()
...@@ -112,5 +119,6 @@ ...@@ -112,5 +119,6 @@
</div> </div>
</section> </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 ?> <? endif ?>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<?= $this->render_partial( <?= $this->render_partial(
'course/room_requests/_new_request_header') ?> 'course/room_requests/_new_request_header') ?>
Request ID: <?= $request_id ?> <?= var_dump($_SESSION[$request_id]) ?>
<br/> <br/>
<section class="resources-grid"> <section class="resources-grid">
<div> <div>
...@@ -23,7 +23,7 @@ Request ID: <?= $request_id ?> ...@@ -23,7 +23,7 @@ Request ID: <?= $request_id ?>
<option value=""><?= _('bitte auswählen') ?></option> <option value=""><?= _('bitte auswählen') ?></option>
<? foreach ($available_room_categories as $rc): ?> <? foreach ($available_room_categories as $rc): ?>
<option value="<?= htmlReady($rc->id) ?>" <option value="<?= htmlReady($rc->id) ?>"
<?= ($category_id == $rc->id) <?= ($_SESSION[$request_id]['room_category'] == $rc->id)
? 'selected="selected"' ? 'selected="selected"'
: '' ?>> : '' ?>>
<?= htmlReady($rc->name) ?> <?= htmlReady($rc->name) ?>
...@@ -88,5 +88,5 @@ Request ID: <?= $request_id ?> ...@@ -88,5 +88,5 @@ Request ID: <?= $request_id ?>
</div> </div>
</section> </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 ?> <? 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