From 6531b2db41cfd42960cbcebe1e7d6104c6845041 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Mon, 6 Sep 2021 08:45:21 +0000 Subject: [PATCH] fixes BIESt #123 and #126 --- app/controllers/resources/export.php | 37 +++++++++++++++++++--------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/app/controllers/resources/export.php b/app/controllers/resources/export.php index c0afb61a3ce..f5220084e28 100644 --- a/app/controllers/resources/export.php +++ b/app/controllers/resources/export.php @@ -304,23 +304,36 @@ class Resources_ExportController extends AuthenticatedController foreach ($resources as $resource) { //Retrieve the bookings in the specified time range: - $bookings = ResourceBooking::findByResourceAndTimeRanges( - $resource, + $intervals = ResourceBookingInterval::findBySql( + '`resource_id` = :resource_id + AND + (`begin` BETWEEN :begin AND :end + OR `end` BETWEEN :begin AND :end) + ORDER BY `begin` ASC, `end` ASC', [ - [ - 'begin' => $this->begin->getTimestamp(), - 'end' => $this->end->getTimestamp() - ] - ], - [0, 1, 2, 3] + 'resource_id' => $resource->id, + 'begin' => $this->begin->getTimestamp(), + 'end' => $this->end->getTimestamp() + ] ); //Prepare data for export: - foreach ($bookings as $booking) { + foreach ($intervals as $interval) { + $booking = $interval->booking; + if (!$booking instanceof ResourceBooking) { + continue; + } + $description = $booking->description; + if (!$booking->isSimpleBooking()) { + $course = $booking->assigned_course_date->course; + if ($course instanceof Course) { + $description = $course->getFullName(); + } + } $booking_data[] = [ - date('d.m.Y H:i', $booking->begin), - date('d.m.Y H:i', $booking->end), + date('d.m.Y H:i', ($interval->begin + $booking->preparation_time)), + date('d.m.Y H:i', $interval->end), sprintf( _('%u min.'), intval($booking->preparation_time / 60) @@ -339,7 +352,7 @@ class Resources_ExportController extends AuthenticatedController ) ) ), - $booking->description, + $description, $booking->booking_user ? $booking->booking_user->getFullName() : '', implode(', ', $booking->getAssignedUsers()), $booking->internal_comment -- GitLab