Skip to content
Snippets Groups Projects
Commit d0353afb authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #3611

Closes #3611

Merge request studip/studip!2504
parent af54012b
No related branches found
No related tags found
No related merge requests found
......@@ -265,9 +265,9 @@ class Course_RoomRequestsController extends AuthenticatedController
// selected room and its category
$this->selected_room = Resource::find($_SESSION[$request_id]['room_id'] ?: $this->request->resource_id);
$this->selected_room_category_id = $this->selected_room->category_id ?: $_SESSION[$request_id]['room_category_id'];
$this->selected_room_category_id = $this->selected_room->category_id ?? $_SESSION[$request_id]['room_category_id'] ?? null;
$_SESSION[$request_id]['room_category_id'] = $_SESSION[$request_id]['room_category_id'] ?: $this->selected_room->category_id;
$_SESSION[$request_id]['room_category_id'] = $_SESSION[$request_id]['room_category_id'] ?? $this->selected_room->category_id ?? null;
// after selecting a room, go to next step or stay here if no room was selected at all
if (Request::submitted('select_room')) {
......@@ -367,9 +367,9 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->available_properties = $this->category->getRequestableProperties();
// properties, like 'Sitzplätze', 'behindertengerecht' etc
$this->selected_properties = $_SESSION[$request_id]['selected_properties'];
$this->preparation_time = $_SESSION[$request_id]['preparation_time'];
$this->comment = $_SESSION[$request_id]['comment'];
$this->selected_properties = $_SESSION[$request_id]['selected_properties'] ?? null;
$this->preparation_time = $_SESSION[$request_id]['preparation_time'] ?? null;
$this->comment = $_SESSION[$request_id]['comment'] ?? null;
$this->request->category_id = $_SESSION[$request_id]['room_category_id'];
// finally we want to show a summary
......@@ -412,11 +412,11 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->course = Course::find($this->course_id);
$this->selected_properties['seats'] = $_SESSION[$request_id]['selected_properties']['seats']
?: $this->course->admission_turnout
?? $this->course->admission_turnout
?: Config::get()->RESOURCES_ROOM_REQUEST_DEFAULT_SEATS;
$this->preparation_time = $_SESSION[$request_id]['preparation_time'];
$this->comment = $_SESSION[$request_id]['comment'];
$this->preparation_time = $_SESSION[$request_id]['preparation_time'] ?? null;
$this->comment = $_SESSION[$request_id]['comment'] ?? null;
// when searching for a room name, list found room
if ($_SESSION[$request_id]['room_name'] !== '') {
......@@ -562,20 +562,23 @@ class Course_RoomRequestsController extends AuthenticatedController
}
$this->request = new RoomRequest($this->request_id);
$this->request->setRangeFields($_SESSION[$this->request_id]['range'], $_SESSION[$this->request_id]['range_ids']);
$this->request->setRangeFields(
$_SESSION[$this->request_id]['range'] ?? '',
$_SESSION[$this->request_id]['range_ids'] ?? []
);
$this->selected_room_category = ResourceCategory::find($_SESSION[$request_id]['room_category_id'] ?: $this->request->category_id);
$this->selected_room_category = ResourceCategory::find($_SESSION[$request_id]['room_category_id'] ?? $this->request->category_id);
$this->selected_room = Resource::find($_SESSION[$request_id]['room_id'] ?: $this->request->resource_id);
$this->selected_room = Resource::find($_SESSION[$request_id]['room_id'] ?? $this->request->resource_id);
$this->room_id = $_SESSION[$request_id]['room_id'] ?: $this->request->resource_id;
$this->room_id = $_SESSION[$request_id]['room_id'] ?? $this->request->resource_id;
$this->available_properties = $this->selected_room_category->getRequestableProperties();
$this->selected_properties = $_SESSION[$request_id]['selected_properties'] ?: [];
$this->selected_properties = $_SESSION[$request_id]['selected_properties'] ?? [];
$this->request_properties = $this->request->properties;
// either properties from stored request or those from session
if ($this->request_properties && !$_SESSION[$request_id]['selected_properties']) {
if ($this->request_properties && empty($_SESSION[$request_id]['selected_properties'])) {
foreach ($this->request_properties as $property) {
$this->selected_properties[$property->name] = $property->state;
}
......
......@@ -15,18 +15,17 @@
<label>
<?= _('Raumkategorie') ?>
<span class="flex-row">
<select name="category_id" <?= $category ? 'disabled' : '' ?>>
<select name="category_id" <?= !empty($category) ? 'disabled' : '' ?>>
<option value=""><?= _('bitte auswählen') ?></option>
<? foreach ($available_room_categories as $rc): ?>
<option value="<?= htmlReady($rc->id) ?>"
<?= $_SESSION[$request_id]['room_category'] === $rc->id
? 'selected'
: '' ?>>
<? if (isset($_SESSION[$request_id]['room_category']) && $_SESSION[$request_id]['room_category'] === $rc->id) echo 'selected'; ?>
>
<?= htmlReady($rc->name) ?>
</option>
<? endforeach ?>
</select>
<? if ($category) : ?>
<? if (!empty($category)) : ?>
<?= Icon::create('decline')->asInput(
[
'title' => _('alle Angaben zurücksetzen'),
......@@ -51,42 +50,40 @@
</span>
</label>
<? endif ?>
<? if (!$embedded) : ?>
</fieldset>
</div>
</fieldset>
</div>
<div>
<fieldset>
<legend><?= _('Raumsuche') ?></legend>
<label>
<?= _('Raumname') ?>
<span class="flex-row">
<input type="text" name="room_name" value="<?= htmlReady($_SESSION[$request_id]['room_name']) ?>">
<?= Icon::create('search')->asInput(
[
<? if (empty($embedded)) : ?>
<div>
<fieldset>
<legend><?= _('Raumsuche') ?></legend>
<label>
<?= _('Raumname') ?>
<span class="flex-row">
<input type="text" name="room_name" value="<?= htmlReady($_SESSION[$request_id]['room_name'] ?? '') ?>">
<?= Icon::create('search')->asInput([
'title' => _('Räume suchen'),
'name' => 'search_by_name',
'class' => 'text-bottom',
'style' => 'margin-left: 0.2em; margin-top: 0.6em;'
]
) ?>
<? if ($room_name) : ?>
<?= Icon::create('decline')->asInput(
[
'style' => 'margin-left: 0.2em; margin-top: 0.6em;',
]) ?>
<? if (!empty($room_name)) : ?>
<?= Icon::create('decline')->asInput([
'title' => _('alle Angaben zurücksetzen'),
'type' => 'image',
'class' => 'text-bottom',
'name' => 'reset_name',
'style' => 'margin-left: 0.2em; margin-top: 0.6em;'
]
) ?>
<? endif?>
</span>
</label>
'style' => 'margin-left: 0.2em; margin-top: 0.6em;',
]) ?>
<? endif?>
</span>
</label>
</fieldset>
</fieldset>
</div>
<? endif; ?>
</section>
</div>
</section>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => $step]) ?>
<? if (empty($embedded)) : ?>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => $step]) ?>
<? endif ?>
......@@ -59,7 +59,7 @@
<? if ($available_properties) : ?>
<? foreach ($available_properties as $property) : ?>
<?= $property->toHtmlInput(
$selected_properties[$property->name],
$selected_properties[$property->name] ?? '',
'selected_properties[' . htmlReady($property->name) . ']',
true,
false
......@@ -80,42 +80,40 @@
<label>
<?= _('Raumname') ?>
<span class="flex-row">
<input type="text" name="room_name" value="<?= htmlReady($room_name) ?>" >
<?= Icon::create('search')->asInput(
[
<input type="text" name="room_name" value="<?= htmlReady($room_name) ?>" >
<?= Icon::create('search')->asInput([
'title' => _('Räume suchen'),
'name' => 'search_by_name',
'class' => 'text-bottom',
'style' => 'margin-left: 0.2em; margin-top: 0.6em;'
]
) ?>
</span>
'style' => 'margin-left: 0.2em; margin-top: 0.6em;',
]) ?>
</span>
</label>
<? if ($available_rooms) : ?>
<label><strong><?= _('Passende Räume') ?></strong>
<section class="selectbox" id="room_select">
<? foreach ($available_rooms as $room): ?>
<div class="flex-row">
<label class="horizontal">
<?= $available_room_icons[$room->id] ?>
<input type="radio" name="selected_room_id"
data-activates="button[type='submit'][name='select_room']"
value="<?= htmlReady($room->id) ?>"
<? if ($_SESSION[$request_id]['room_id'] === $room->id) echo 'checked' ?>>
<?= htmlReady(mila($room->name, 50)) . ' (' . $room['category']->name . ')'?>
<? if ($room->properties): ?>
<? $property_names = $room->getInfolabelProperties()
->pluck('fullname') ?>
<?= tooltipIcon(implode("\n", $property_names)) ?>
<? endif ?>
</label>
</div>
<? endforeach ?>
</section>
</label>
<?= \Studip\Button::create(_('Raum auswählen'), 'select_room') ?>
<? else : ?>
<? endif ?>
<? if (!empty($available_rooms)) : ?>
<label>
<strong><?= _('Passende Räume') ?></strong>
<section class="selectbox" id="room_select">
<? foreach ($available_rooms as $room): ?>
<div class="flex-row">
<label class="horizontal">
<?= $available_room_icons[$room->id] ?>
<input type="radio" name="selected_room_id"
data-activates="button[type='submit'][name='select_room']"
value="<?= htmlReady($room->id) ?>"
<? if ($_SESSION[$request_id]['room_id'] === $room->id) echo 'checked' ?>>
<?= htmlReady(mila($room->name, 50)) . ' (' . $room['category']->name . ')'?>
<? if ($room->properties): ?>
<? $property_names = $room->getInfolabelProperties()
->pluck('fullname') ?>
<?= tooltipIcon(implode("\n", $property_names)) ?>
<? endif ?>
</label>
</div>
<? endforeach ?>
</section>
</label>
<?= \Studip\Button::create(_('Raum auswählen'), 'select_room') ?>
<? endif ?>
</fieldset>
</div>
......
......@@ -61,7 +61,7 @@
<? if ($available_properties) : ?>
<? foreach ($available_properties as $property) : ?>
<?= $property->toHtmlInput(
$selected_properties[$property->name],
$selected_properties[$property->name] ?? '',
'selected_properties[' . htmlReady($property->name) . ']',
true,
false,
......@@ -74,11 +74,11 @@
<? endif ?>
<? if (!$embedded) : ?>
</fieldset>
</div>
<? if (empty($embedded)) : ?>
<div>
<fieldset class="request-fieldset">
<legend><?= _('Raumsuche') ?></legend>
......@@ -124,11 +124,11 @@
<? else : ?>
<?= MessageBox::info(_('Es wurden keine passenden Räume gefunden!')) ?>
<? endif ?>
</fieldset>
</div>
<? endif; ?>
</section>
<? if (empty($embedded)) : ?>
<?= $this->render_partial('course/room_requests/_new_request_form_footer', ['step' => $step, 'search_by' => 'roomname']) ?>
<? endif ?>
......@@ -107,7 +107,7 @@
</td>
</tr>
<? endforeach ?>
<? if ($request_id === $rr->id) : ?>
<? if (isset($request_id) && $request_id === $rr->id) : ?>
<tr>
<td colspan="4">
<?= $this->render_partial('course/room_requests/_request.php', ['request' => $rr]); ?>
......
......@@ -222,11 +222,13 @@ class Folder extends SimpleORMap implements FeedbackRange
[$course_topic->seminar_id]
);
foreach ($topic_folders as $folder) {
if ($folder['data_content']['topic_id'] === $topic_id) {
$ret[] = $folder;
$ret = array_filter(
$topic_folders,
function (Folder $folder) use ($topic_id): bool {
return isset($folder->data_content)
&& $folder->data_content['topic_id'] === $topic_id;
}
}
);
}
return $ret;
}
......@@ -241,7 +243,7 @@ class Folder extends SimpleORMap implements FeedbackRange
*/
public static function findByTermin_id($termin_id)
{
$course_date = CourseDate::find($termin_id);
$course_date = CourseDate::find($termin_id);
$ret = [];
if ($course_date) {
$date_folders = self::findBySQL(
......@@ -249,11 +251,13 @@ class Folder extends SimpleORMap implements FeedbackRange
[$course_date->range_id]
);
foreach ($date_folders as $folder) {
if ($folder['data_content']['termin_id'] === $termin_id) {
$ret[] = $folder;
$ret = array_filter(
$date_folders,
function (Folder $folder) use ($termin_id): bool {
return isset($folder->data_content['termin_id'])
&& $folder->data_content['termin_id'] === $termin_id;
}
}
);
}
return $ret;
}
......
......@@ -1189,8 +1189,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
$interval['range'] = ResourceRequestAppointment::class;
$interval['range_id'] = $appointment->appointment_id;
$interval['booked_room'] = $date->room_booking ? $date->room_booking->resource_id : null;
$interval['booking_id'] = $date->room_booking ? $date->room_booking->id : null;
$interval['booked_room'] = $date->room_booking->resource_id ?? null;
$interval['booking_id'] = $date->room_booking->id ?? null;
}
$time_intervals[] = $interval;
......@@ -1214,8 +1214,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
if ($with_range) {
$interval['range'] = CourseDate::class;
$interval['range_id'] = $this->termin_id;
$interval['booked_room'] = $this->date->room_booking ? $this->date->room_booking->resource_id: null;
$interval['booking_id'] = $this->date->room_booking ? $this->date->room_booking->id : null;
$interval['booked_room'] = $this->date->room_booking->resource_id ?? null;
$interval['booking_id'] = $this->date->room_booking->id ?? null;
}
return [$interval];
} elseif ($this->metadate_id) {
......@@ -1238,8 +1238,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
if ($with_range) {
$interval['range'] = CourseDate::class;
$interval['range_id'] = $date->id;
$interval['booked_room'] = $date->room_booking->resource_id;
$interval['booking_id'] = $date->room_booking->id;
$interval['booked_room'] = $date->room_booking->resource_id ?? null;
$interval['booking_id'] = $date->room_booking->id ?? null;
}
$time_intervals[] = $interval;
}
......@@ -1265,8 +1265,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
if ($with_range) {
$interval['range'] = CourseDate::class;
$interval['range_id'] = $date->id;
$interval['booked_room'] = $date->room_booking ? $date->room_booking->resource_id: null;
$interval['booking_id'] = $date->room_booking ? $date->room_booking->id : null;
$interval['booked_room'] = $date->room_booking->resource_id ?? null;
$interval['booking_id'] = $date->room_booking->id ?? null;
}
$time_intervals[] = $interval;
}
......
......@@ -13,7 +13,7 @@
}
// Remove required attribute if no text has been set
if (isset($attr['required']) && !$attr['value']) {
if (isset($attr['required']) && empty($attr['value'])) {
unset($attr['required']);
}
}
......
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