From 7580842a16382cbf2ba50f227eacafd4869c1eba Mon Sep 17 00:00:00 2001 From: Thomas Hackl Date: Thu, 7 Oct 2021 09:10:38 +0000 Subject: TIC 11438 Export-Buchungstypen --- app/controllers/resources/admin.php | 14 ++++++++++ app/controllers/resources/export.php | 25 ++++++++++++++++- app/controllers/resources/print.php | 12 ++++++++- app/routes/Resources.php | 2 +- app/views/resources/admin/configuration.php | 15 +++++++++++ app/views/resources/export/resource_bookings.php | 21 ++++++++++++--- .../resources/export/select_booking_sources.php | 13 +++++++++ app/views/resources/print/clipboard_rooms.php | 15 ++++++++++- db/migrations/20210420_export_bookingtypes.php | 31 ++++++++++++++++++++++ 9 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 db/migrations/20210420_export_bookingtypes.php diff --git a/app/controllers/resources/admin.php b/app/controllers/resources/admin.php index 4f413be..0ce8d41 100644 --- a/app/controllers/resources/admin.php +++ b/app/controllers/resources/admin.php @@ -1056,6 +1056,13 @@ class Resources_AdminController extends AuthenticatedController $this->resources_booking_plan_end_hour = $this->config->RESOURCES_BOOKING_PLAN_END_HOUR; + $this->bookingtypes = [ + 0 => _('Buchung'), + 1 => _('Reservierung'), + 2 => _('Sperrbuchung'), + 3 => _('Planungsbuchung') + ]; + if (Request::submitted('save')) { //Get colors: @@ -1203,6 +1210,11 @@ class Resources_AdminController extends AuthenticatedController $this->resources_booking_plan_end_hour ); + $this->config->store( + 'RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT', + Request::intArray('export_booking_types') + ); + PageLayout::postSuccess( _('Die Konfigurationsoptionen wurden gespeichert!') ); @@ -1212,5 +1224,7 @@ class Resources_AdminController extends AuthenticatedController "colour_id LIKE 'Resources%' ORDER BY colour_id ASC" ); + + $this->export_bookingtypes_default = $this->config->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT; } } diff --git a/app/controllers/resources/export.php b/app/controllers/resources/export.php index f522008..87d6d8a 100644 --- a/app/controllers/resources/export.php +++ b/app/controllers/resources/export.php @@ -119,6 +119,16 @@ class Resources_ExportController extends AuthenticatedController $this->range_id = Request::get('range_id'); } + // All available booking types. + $this->booking_types = [ + 0 => _('Buchung'), + 1 => _('Reservierung'), + 2 => _('Sperrbuchung'), + 3 => _('Planungsbuchung') + ]; + $this->selected_booking_types = Request::intArray('bookingtypes') ?: + Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT; + //Build sidebar $sidebar = Sidebar::get(); @@ -214,6 +224,16 @@ class Resources_ExportController extends AuthenticatedController ); $this->end->setTime(23, 59, 59); } + + + // All available booking types. + $this->booking_types = [ + 0 => _('Buchung'), + 1 => _('Reservierung'), + 2 => _('Sperrbuchung'), + 3 => _('Planungsbuchung') + ]; + $this->selected_booking_types = Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT; } @@ -317,11 +337,14 @@ class Resources_ExportController extends AuthenticatedController ] ); + $types = Request::intArray('bookingtypes') ?: + Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT; + //Prepare data for export: foreach ($intervals as $interval) { $booking = $interval->booking; - if (!$booking instanceof ResourceBooking) { + if (!$booking instanceof ResourceBooking || !in_array($booking->booking_type, $types)) { continue; } $description = $booking->description; diff --git a/app/controllers/resources/print.php b/app/controllers/resources/print.php index 63da03f..a21db5e 100644 --- a/app/controllers/resources/print.php +++ b/app/controllers/resources/print.php @@ -128,10 +128,20 @@ class Resources_PrintController extends AuthenticatedController //and In both cases we must collect the selected //clipboard, the selected date and the selected schedule type. //Furthermore a date and the type of schedule has been selected. + // Also check for booking types to export. $this->selected_clipboard_id = Request::get('clipboard_id'); $this->schedule_type = Request::get('schedule_type'); $this->selected_date_string = Request::get('date'); - + $this->selected_booking_types = Request::intArray('bookingtypes') ?: + Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT; + + // All available booking types. + $this->booking_types = [ + 0 => _('Buchung'), + 1 => _('Reservierung'), + 2 => _('Sperrbuchung'), + 3 => _('Planungsbuchung') + ]; if (!$this->clipboard_selected && !$this->print_schedules) { //We have to load all selectable clipboards of the current user: $this->available_clipboards = Clipboard::getClipboardsForUser( diff --git a/app/routes/Resources.php b/app/routes/Resources.php index 652cb8b..84b9110 100644 --- a/app/routes/Resources.php +++ b/app/routes/Resources.php @@ -378,7 +378,7 @@ class Resources extends \RESTAPI\RouteMap //Get parameters: $booking_types = []; if (!$nobody_access) { - $booking_types = \Request::getArray('booking_types'); + $booking_types = explode(',', \Request::get('booking_types')); } $begin_timestamp = $begin->getTimestamp(); diff --git a/app/views/resources/admin/configuration.php b/app/views/resources/admin/configuration.php index 3b72cc9..62c1d88 100644 --- a/app/views/resources/admin/configuration.php +++ b/app/views/resources/admin/configuration.php @@ -114,5 +114,20 @@ value="RESOURCES_MIN_BOOKING_TIME) ?>"> +
+ + +
diff --git a/app/views/resources/export/resource_bookings.php b/app/views/resources/export/resource_bookings.php index 39933de..1441590 100644 --- a/app/views/resources/export/resource_bookings.php +++ b/app/views/resources/export/resource_bookings.php @@ -9,8 +9,8 @@ -
-
+
+
-
+ +
+ +
+ +
+
+
+ + +
diff --git a/app/views/resources/print/clipboard_rooms.php b/app/views/resources/print/clipboard_rooms.php index b5b4a0d..0cba520 100644 --- a/app/views/resources/print/clipboard_rooms.php +++ b/app/views/resources/print/clipboard_rooms.php @@ -6,6 +6,9 @@ + + +
" class="has-date-picker"> +
'GET', 'extraParams' => [ - 'booking_types' => [0,1,2], + 'booking_types' => $selected_booking_types, 'display_requests' => 1 ] ] diff --git a/db/migrations/20210420_export_bookingtypes.php b/db/migrations/20210420_export_bookingtypes.php new file mode 100644 index 0000000..5722f1e --- /dev/null +++ b/db/migrations/20210420_export_bookingtypes.php @@ -0,0 +1,31 @@ +exec($query); + } + + protected function down() + { + $query = "DELETE FROM `config` + WHERE `field` = 'RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT'"; + DBManager::get()->exec($query); + $query = "DELETE FROM `config_values` + WHERE `field` = 'RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT'"; + DBManager::get()->exec($query); + } +} -- cgit v1.0