diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2026-03-02 12:12:22 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2026-03-02 12:12:22 +0000 |
| commit | f7198ce453deae678c921b8e45c5ee7e00d6e8ee (patch) | |
| tree | 01b40ea740fdf48e024e9e4366c7d0a809494efd /app | |
| parent | a5b30bccc670b5139def13ec0141eedac13bafc8 (diff) | |
resources/export/bookings: show each day of a booking in the exported data, fixes #6281issue-6311
Closes #6281
Merge request studip/studip!4758
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/resources/export.php | 94 |
1 files changed, 61 insertions, 33 deletions
diff --git a/app/controllers/resources/export.php b/app/controllers/resources/export.php index c9ccdf9..f1420db 100644 --- a/app/controllers/resources/export.php +++ b/app/controllers/resources/export.php @@ -408,41 +408,69 @@ class Resources_ExportController extends AuthenticatedController } } } - $row = [ - date('d.m.Y', $interval->begin), - date('H:i', $interval->begin + $booking->preparation_time), - date('H:i', $interval->end), - strftime('%a', $interval->begin), - sprintf( - _('%u min.'), - intval($booking->preparation_time / 60) - ), - $booking->resource->name, - ( - $booking->booking_type == ResourceBooking::TYPE_NORMAL - ? _('Buchung') - : ( - $booking->booking_type == ResourceBooking::TYPE_RESERVATION - ? _('Reservierung') - : ( - $booking->booking_type == ResourceBooking::TYPE_LOCK - ? _('Sperrbuchung') - : _('sonstiges') - ) - ) - ), - $description, - $turnout, - $booking->booking_user ? $booking->booking_user->getFullName() : '', - implode(', ', $booking->getAssignedUsers()), - $booking->internal_comment - ]; + //In case the booking spans over several days, several rows must be created: + $interval_start = new DateTime(); + $interval_start->setTimestamp($interval->begin); + $interval_end = new DateTime(); + $interval_end->setTimestamp($interval->end); + $current_day = clone $interval_start; + while ($current_day < $interval_end) { + $interval_is_on_weekday = in_array($current_day->format('N'), $this->weekdays); + if (!$interval_is_on_weekday) { + //Go directly to the next day: + $current_day = $current_day->add(new DateInterval('P1D')); + continue; + } + $start_time_str = date('H:i', $interval->begin + $booking->preparation_time); + $end_time_str = date('H:i', $interval->end); + if ($current_day->format('Ymd') !== $interval_start->format('Ymd')) { + //This is not the first day. + $start_time_str = '00:00'; + } + if ($current_day->format('Ymd') !== $interval_end->format('Ymd')) { + //This is not the last day. + $end_time_str = '23:59'; + } - if (Config::get()->ENABLE_NUMBER_OF_PARTICIPANTS) { - $row[] = $number_of_participants; - } + $row = [ + $current_day->format('d.m.Y'), + $start_time_str, + $end_time_str, + getWeekday((int)$current_day->format('w')), + sprintf( + _('%u min.'), + intval($booking->preparation_time / 60) + ), + $booking->resource->name, + ( + $booking->booking_type == ResourceBooking::TYPE_NORMAL + ? _('Buchung') + : ( + $booking->booking_type == ResourceBooking::TYPE_RESERVATION + ? _('Reservierung') + : ( + $booking->booking_type == ResourceBooking::TYPE_LOCK + ? _('Sperrbuchung') + : _('sonstiges') + ) + ) + ), + $description, + $turnout, + $booking->booking_user ? $booking->booking_user->getFullName() : '', + implode(', ', $booking->getAssignedUsers()), + $booking->internal_comment + ]; + + if (Config::get()->ENABLE_NUMBER_OF_PARTICIPANTS) { + $row[] = $number_of_participants; + } + //Add the row: + $booking_data[] = $row; - $booking_data[] = $row; + //Go to the next day: + $current_day = $current_day->add(new DateInterval('P1D')); + } } } |
