Skip to content
Snippets Groups Projects
Commit 7580842a authored by Thomas Hackl's avatar Thomas Hackl
Browse files

TIC 11438 Export-Buchungstypen

parent 754d05d1
No related branches found
No related tags found
No related merge requests found
...@@ -1056,6 +1056,13 @@ class Resources_AdminController extends AuthenticatedController ...@@ -1056,6 +1056,13 @@ class Resources_AdminController extends AuthenticatedController
$this->resources_booking_plan_end_hour = $this->resources_booking_plan_end_hour =
$this->config->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')) { if (Request::submitted('save')) {
//Get colors: //Get colors:
...@@ -1203,6 +1210,11 @@ class Resources_AdminController extends AuthenticatedController ...@@ -1203,6 +1210,11 @@ class Resources_AdminController extends AuthenticatedController
$this->resources_booking_plan_end_hour $this->resources_booking_plan_end_hour
); );
$this->config->store(
'RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT',
Request::intArray('export_booking_types')
);
PageLayout::postSuccess( PageLayout::postSuccess(
_('Die Konfigurationsoptionen wurden gespeichert!') _('Die Konfigurationsoptionen wurden gespeichert!')
); );
...@@ -1212,5 +1224,7 @@ class Resources_AdminController extends AuthenticatedController ...@@ -1212,5 +1224,7 @@ class Resources_AdminController extends AuthenticatedController
"colour_id LIKE 'Resources%' "colour_id LIKE 'Resources%'
ORDER BY colour_id ASC" ORDER BY colour_id ASC"
); );
$this->export_bookingtypes_default = $this->config->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT;
} }
} }
...@@ -119,6 +119,16 @@ class Resources_ExportController extends AuthenticatedController ...@@ -119,6 +119,16 @@ class Resources_ExportController extends AuthenticatedController
$this->range_id = Request::get('range_id'); $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 //Build sidebar
$sidebar = Sidebar::get(); $sidebar = Sidebar::get();
...@@ -214,6 +224,16 @@ class Resources_ExportController extends AuthenticatedController ...@@ -214,6 +224,16 @@ class Resources_ExportController extends AuthenticatedController
); );
$this->end->setTime(23, 59, 59); $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 ...@@ -317,11 +337,14 @@ class Resources_ExportController extends AuthenticatedController
] ]
); );
$types = Request::intArray('bookingtypes') ?:
Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT;
//Prepare data for export: //Prepare data for export:
foreach ($intervals as $interval) { foreach ($intervals as $interval) {
$booking = $interval->booking; $booking = $interval->booking;
if (!$booking instanceof ResourceBooking) { if (!$booking instanceof ResourceBooking || !in_array($booking->booking_type, $types)) {
continue; continue;
} }
$description = $booking->description; $description = $booking->description;
......
...@@ -128,10 +128,20 @@ class Resources_PrintController extends AuthenticatedController ...@@ -128,10 +128,20 @@ class Resources_PrintController extends AuthenticatedController
//and In both cases we must collect the selected //and In both cases we must collect the selected
//clipboard, the selected date and the selected schedule type. //clipboard, the selected date and the selected schedule type.
//Furthermore a date and the type of schedule has been selected. //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->selected_clipboard_id = Request::get('clipboard_id');
$this->schedule_type = Request::get('schedule_type'); $this->schedule_type = Request::get('schedule_type');
$this->selected_date_string = Request::get('date'); $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) { if (!$this->clipboard_selected && !$this->print_schedules) {
//We have to load all selectable clipboards of the current user: //We have to load all selectable clipboards of the current user:
$this->available_clipboards = Clipboard::getClipboardsForUser( $this->available_clipboards = Clipboard::getClipboardsForUser(
......
...@@ -378,7 +378,7 @@ class Resources extends \RESTAPI\RouteMap ...@@ -378,7 +378,7 @@ class Resources extends \RESTAPI\RouteMap
//Get parameters: //Get parameters:
$booking_types = []; $booking_types = [];
if (!$nobody_access) { if (!$nobody_access) {
$booking_types = \Request::getArray('booking_types'); $booking_types = explode(',', \Request::get('booking_types'));
} }
$begin_timestamp = $begin->getTimestamp(); $begin_timestamp = $begin->getTimestamp();
......
...@@ -114,5 +114,20 @@ ...@@ -114,5 +114,20 @@
value="<?= htmlReady($config->RESOURCES_MIN_BOOKING_TIME) ?>"> value="<?= htmlReady($config->RESOURCES_MIN_BOOKING_TIME) ?>">
</label> </label>
</fieldset> </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') ?> <?= \Studip\Button::create(_('Speichern'), 'save') ?>
</form> </form>
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
<input type="hidden" name="selected_resources[]" <input type="hidden" name="selected_resources[]"
value="<?= htmlReady($resource->id)?>"> value="<?= htmlReady($resource->id)?>">
<? endif ?> <? endif ?>
<article class="widget"> <fieldset>
<header><?= _('Zeitbereich auswählen') ?></header> <legend><?= _('Zeitbereich auswählen') ?></legend>
<section> <section>
<label> <label>
<?= _('Startzeitpunkt') ?> <?= _('Startzeitpunkt') ?>
...@@ -27,7 +27,22 @@ ...@@ -27,7 +27,22 @@
value="<?= $end->format('H:i')?>"> value="<?= $end->format('H:i')?>">
</label> </label>
</section> </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> <div data-dialog-button>
<?= \Studip\Button::create( <?= \Studip\Button::create(
_('Exportieren'), _('Exportieren'),
......
...@@ -99,6 +99,19 @@ ...@@ -99,6 +99,19 @@
</tbody> </tbody>
</table> </table>
<? endif ?> <? 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> <div data-dialog-button>
<?= \Studip\Button::create(_('Liste mit Buchungen exportieren')) ?> <?= \Studip\Button::create(_('Liste mit Buchungen exportieren')) ?>
</div> </div>
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
<input type="hidden" name="clipboard_id" value="<?= htmlReady($selected_clipboard_id) ?>"> <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="schedule_type" value="<?= htmlReady($schedule_type) ?>">
<input type="hidden" name="date" value="<?= htmlReady($selected_date_string) ?>"> <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> <fieldset>
<? if (!$available_rooms): ?> <? if (!$available_rooms): ?>
<?= MessageBox::info( <?= MessageBox::info(
...@@ -91,6 +94,16 @@ ...@@ -91,6 +94,16 @@
value="<?= date('d.m.Y') ?>" value="<?= date('d.m.Y') ?>"
class="has-date-picker"> class="has-date-picker">
</label> </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> </fieldset>
<div data-dialog-button> <div data-dialog-button>
<?= \Studip\Button::create( <?= \Studip\Button::create(
...@@ -156,7 +169,7 @@ ...@@ -156,7 +169,7 @@
), ),
'method' => 'GET', 'method' => 'GET',
'extraParams' => [ 'extraParams' => [
'booking_types' => [0,1,2], 'booking_types' => $selected_booking_types,
'display_requests' => 1 'display_requests' => 1
] ]
] ]
......
<?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);
}
}
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