diff --git a/lib/classes/sidebar/RoomSearchWidget.class.php b/lib/classes/sidebar/RoomSearchWidget.class.php index 008065816115b02c75e6357b044f0dc24f659bb5..da2238e5fddf4a3e10421e0068dfd9e3383399be 100644 --- a/lib/classes/sidebar/RoomSearchWidget.class.php +++ b/lib/classes/sidebar/RoomSearchWidget.class.php @@ -33,7 +33,7 @@ class RoomSearchWidget extends SidebarWidget } $room_types = Room::getAllRoomTypes(); - if ($room_types) { + if (!empty($room_types)) { $filtered_room_types = []; foreach ($room_types as $type) { $filtered_room_types[$type] = $type; @@ -42,10 +42,6 @@ class RoomSearchWidget extends SidebarWidget ['' => _('Alle Raumtypen')], $filtered_room_types ); - } else { - $room_types = [ - '' => _('Alle Raumtypen') - ]; } $this->criteria = []; @@ -89,16 +85,18 @@ class RoomSearchWidget extends SidebarWidget 'value' => '', 'optional' => false ]; - $this->criteria['room_type'] = [ - 'name' => 'room_type', - 'title' => _('Raumtyp'), - 'type' => 'select', - 'range_search' => false, - 'options' => $room_types, - 'switch' => false, - 'value' => '', - 'optional' => false - ]; + if (!empty($room_types)) { + $this->criteria['room_type'] = [ + 'name' => 'room_type', + 'title' => _('Raumtyp'), + 'type' => 'select', + 'range_search' => false, + 'options' => $room_types, + 'switch' => false, + 'value' => '', + 'optional' => false + ]; + } $this->criteria['special__building_location'] = [ 'name' => 'special__building_location', 'title' => _('Standort / Gebäude'), @@ -167,6 +165,7 @@ class RoomSearchWidget extends SidebarWidget 'value' => [10, 100], 'optional' => false ]; + } diff --git a/templates/sidebar/room-search-widget.php b/templates/sidebar/room-search-widget.php index 6a0fb919ba290288008147b7013b6ff27da113cc..5663c11aefe739730057f372d318b57f9ed630be 100644 --- a/templates/sidebar/room-search-widget.php +++ b/templates/sidebar/room-search-widget.php @@ -6,31 +6,30 @@ 'sidebar/room-search-criteria.php', [ 'criteria' => ( - $selected_criteria['special__room_name'] - ? $selected_criteria['special__room_name'] - : $criteria['special__room_name'] - ), - 'removable' => false - ] - ) ?> - <?= $this->render_partial( - 'sidebar/room-search-criteria.php', - [ - 'criteria' => ( - $selected_criteria['room_type'] - ? $selected_criteria['room_type'] - : $criteria['room_type'] - ), + $selected_criteria['special__room_name'] + ?: $criteria['special__room_name'] + ), 'removable' => false ] ) ?> + <? if (isset($criteria['room_type'])): ?> + <?= $this->render_partial( + 'sidebar/room-search-criteria.php', + [ + 'criteria' => ( + $selected_criteria['room_type'] + ?: $criteria['room_type'] + ), + 'removable' => false + ] + ) ?> + <? endif ?> <?= $this->render_partial( 'sidebar/room-search-criteria.php', [ 'criteria' => ( $selected_criteria['room_category_id'] - ? $selected_criteria['room_category_id'] - : $criteria['room_category_id'] + ?: $criteria['room_category_id'] ), 'removable' => false ] @@ -40,8 +39,7 @@ [ 'criteria' => ( $selected_criteria['special__building_location'] - ? $selected_criteria['special__building_location'] - : $criteria['special__building_location'] + ?: $criteria['special__building_location'] ), 'removable' => false ] @@ -52,8 +50,7 @@ [ 'criteria' => ( $selected_criteria['special__building_location_label'] - ? $selected_criteria['special__building_location_label'] - : $criteria['special__building_location_label'] + ?: $criteria['special__building_location_label'] ), 'removable' => false ] @@ -64,16 +61,14 @@ [ 'criteria' => $selected_criteria['special__seats'] - ? $selected_criteria['special__seats'] - : $criteria['special__seats'] + ?: $criteria['special__seats'] ] ) ?> <?= $this->render_partial( 'sidebar/room-search-criteria-available-range.php', [ 'criteria' => $selected_criteria['special__time_range'] - ? $selected_criteria['special__time_range'] - : $criteria['special__time_range'] + ?: $criteria['special__time_range'] ] ) ?>