diff --git a/app/controllers/resources/admin.php b/app/controllers/resources/admin.php index 4f413be98f415cfd72aa6ea16ba337d5650e5b7d..0ce8d41fc2072913ddc1e4e2273b8361401f4455 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 f5220084e283004a3ae0f8336497954f48cf4e22..87d6d8a0df0f29f20a773d3d531a3995f15710a4 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 63da03f89812754153bb61f12388b2a7d8cc2008..a21db5e847ff5700a9585fefda93f2ce5807dbec 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 652cb8b48829c7c228f18d635395951649e61347..84b91105b388e45ed9b5eb42aa8cc63878bba183 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 3b72cc96041d9dca97a9db9aad177f4cc0a140f2..62c1d886bbc089373ff14974e5c08e41349c624c 100644 --- a/app/views/resources/admin/configuration.php +++ b/app/views/resources/admin/configuration.php @@ -114,5 +114,20 @@ value="<?= htmlReady($config->RESOURCES_MIN_BOOKING_TIME) ?>"> </label> </fieldset> + <fieldset> + <legend><?= _('Export') ?></legend> + <label> + <?= _('Voreinstellung zu exportierender Buchungstypen') ?> + <select name="export_booking_types[]" class="nested-select" multiple> + <option value="">-- <?= _('Bitte auswählen') ?> --</option> + <? foreach ($bookingtypes as $index => $name) : ?> + <option value="<?= $index ?>"<?= in_array($index, $export_bookingtypes_default) ? + ' selected' : '' ?>> + <?= htmlReady($name) ?> + </option> + <? endforeach ?> + </select> + </label> + </fieldset> <?= \Studip\Button::create(_('Speichern'), 'save') ?> </form> diff --git a/app/views/resources/export/resource_bookings.php b/app/views/resources/export/resource_bookings.php index 39933ded51140409a272b9bed7cfed2fcb263c0b..144159067a649cdbe723e7514172c2116d128d8f 100644 --- a/app/views/resources/export/resource_bookings.php +++ b/app/views/resources/export/resource_bookings.php @@ -9,8 +9,8 @@ <input type="hidden" name="selected_resources[]" value="<?= htmlReady($resource->id)?>"> <? endif ?> - <article class="widget"> - <header><?= _('Zeitbereich auswählen') ?></header> + <fieldset> + <legend><?= _('Zeitbereich auswählen') ?></legend> <section> <label> <?= _('Startzeitpunkt') ?> @@ -27,7 +27,22 @@ value="<?= $end->format('H:i')?>"> </label> </section> - </article> + </fieldset> + <fieldset> + <legend><?= _('Belegungstypen auswählen') ?></legend> + <section> + <label> + <?= _('Zu exportierende Belegungstypen') ?> + <select name="bookingtypes[]" multiple class="nested-select"> + <? foreach ($booking_types as $index => $name) : ?> + <option value="<?= $index ?>" + <?= in_array($index, $selected_booking_types) ? ' selected' : '' ?>> + <?= htmlReady($name) ?></option> + <? endforeach ?> + </select> + </label> + </section> + </fieldset> <div data-dialog-button> <?= \Studip\Button::create( _('Exportieren'), diff --git a/app/views/resources/export/select_booking_sources.php b/app/views/resources/export/select_booking_sources.php index 527de27190e27f51f0a605d76aa8e6c404fff96c..f24b064cb0c14fe817302a9763dc5095824143a4 100644 --- a/app/views/resources/export/select_booking_sources.php +++ b/app/views/resources/export/select_booking_sources.php @@ -99,6 +99,19 @@ </tbody> </table> <? endif ?> + <fieldset> + <legend><?= _('Belegungstypen auswählen') ?></legend> + <label> + <?= _('Zu exportierende Belegungstypen') ?> + <select name="bookingtypes[]" multiple class="nested-select"> + <? foreach ($booking_types as $index => $name) : ?> + <option value="<?= $index ?>" + <?= in_array($index, $selected_booking_types) ? ' selected' : '' ?>> + <?= htmlReady($name) ?></option> + <? endforeach ?> + </select> + </label> + </fieldset> <div data-dialog-button> <?= \Studip\Button::create(_('Liste mit Buchungen exportieren')) ?> </div> diff --git a/app/views/resources/print/clipboard_rooms.php b/app/views/resources/print/clipboard_rooms.php index b5b4a0d249795bad154715264e2212107d62c4c5..0cba520d95d5913edec34a8124edcd352de4f33c 100644 --- a/app/views/resources/print/clipboard_rooms.php +++ b/app/views/resources/print/clipboard_rooms.php @@ -6,6 +6,9 @@ <input type="hidden" name="clipboard_id" value="<?= htmlReady($selected_clipboard_id) ?>"> <input type="hidden" name="schedule_type" value="<?= htmlReady($schedule_type) ?>"> <input type="hidden" name="date" value="<?= htmlReady($selected_date_string) ?>"> + <? foreach ($selected_booking_types as $type) : ?> + <input type="hidden" name="bookingtypes[]" value="<?= $type ?>"> + <? endforeach ?> <fieldset> <? if (!$available_rooms): ?> <?= MessageBox::info( @@ -91,6 +94,16 @@ value="<?= date('d.m.Y') ?>" class="has-date-picker"> </label> + <label> + <?= _('Zu exportierende Belegungstypen') ?> + <select name="bookingtypes[]" multiple class="nested-select"> + <? foreach ($booking_types as $index => $name) : ?> + <option value="<?= $index ?>" + <?= in_array($index, $selected_booking_types) ? ' selected' : '' ?>> + <?= htmlReady($name) ?></option> + <? endforeach ?> + </select> + </label> </fieldset> <div data-dialog-button> <?= \Studip\Button::create( @@ -156,7 +169,7 @@ ), 'method' => '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 0000000000000000000000000000000000000000..5722f1ef1c538506d7d583f6a814cb5442e54670 --- /dev/null +++ b/db/migrations/20210420_export_bookingtypes.php @@ -0,0 +1,31 @@ +<?php + +class ExportBookingTypes extends Migration +{ + + public function description() + { + return 'Adds a config entry for specifying which booking types shall be exported per default'; + } + + protected function up() + { + $query = "INSERT IGNORE INTO `config` ( + `field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description` + ) VALUES ( + 'RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT', '[0,1,2]', 'array', 'global', 'resources', + UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'Standardmäßig zu exportierende Belegungstypen' + )"; + DBManager::get()->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); + } +}