aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/resources
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2024-09-09 15:33:40 +0000
committerMoritz Strohm <strohm@data-quest.de>2024-09-09 15:33:40 +0000
commite034e414e80feb25b497172d07eeaa7b6486467d (patch)
tree5b5ad9c56fe81e68edbb1f908ccded46068391e4 /app/controllers/resources
parent48c69ed3ad2ddcb567dfaef4ab43b5c934611c55 (diff)
add repetition from monday until friday for resource bookings, re #2013
Merge request studip/studip!2539
Diffstat (limited to 'app/controllers/resources')
-rw-r--r--app/controllers/resources/booking.php40
1 files changed, 27 insertions, 13 deletions
diff --git a/app/controllers/resources/booking.php b/app/controllers/resources/booking.php
index a4722ed..5373519 100644
--- a/app/controllers/resources/booking.php
+++ b/app/controllers/resources/booking.php
@@ -309,7 +309,8 @@ class Resources_BookingController extends AuthenticatedController
$repetition_interval = null,
$notification_enabled = false,
$included_room_parts = [],
- $overwrite_bookings = false
+ $overwrite_bookings = false,
+ $weekdays = ''
)
{
$result = [
@@ -352,7 +353,8 @@ class Resources_BookingController extends AuthenticatedController
$booking_type == ResourceBooking::TYPE_LOCK
? $overwrite_bookings
: false
- )
+ ),
+ $weekdays
);
} else {
$matching_bookings = ResourceBooking::findByResourceAndTimeRanges(
@@ -397,7 +399,8 @@ class Resources_BookingController extends AuthenticatedController
$booking_type == ResourceBooking::TYPE_LOCK
? $overwrite_bookings
: false
- )
+ ),
+ $weekdays
);
}
}
@@ -423,6 +426,7 @@ class Resources_BookingController extends AuthenticatedController
}
$a->repetition_interval = $repetition_interval->format('P%YY%MM%DD');
$a->repeat_end = $repetition_end->getTimestamp();
+ $a->weekdays = $weekdays;
}
try {
@@ -466,7 +470,8 @@ class Resources_BookingController extends AuthenticatedController
$booking_type == ResourceBooking::TYPE_LOCK
? $overwrite_bookings
: false
- )
+ ),
+ $weekdays
);
$result['bookings'] = [$booking];
} catch (Exception $e) {
@@ -1033,8 +1038,12 @@ class Resources_BookingController extends AuthenticatedController
$this->repetition_style = 'monthly';
$this->repetition_interval = $interval->m;
} else if (($interval->d % 7) == 0) {
- $this->repetition_style = 'weekly';
- $this->repetition_interval = $interval->d / 7;
+ $this->repetition_style = 'daily';
+ if ($this->booking->weekdays === '12345') {
+ $this->repetition_interval = 'workdays';
+ } else {
+ $this->repetition_interval = $interval->d / 7;
+ }
} else {
$this->repetition_style = 'daily';
$this->repetition_interval = $interval->d;
@@ -1125,17 +1134,21 @@ class Resources_BookingController extends AuthenticatedController
intval($this->end->format('s'))
);
if ($this->repetition_style) {
- if ($this->repetition_style == 'daily' && $this->repetition_interval) {
- $this->repetition_date_interval = new DateInterval(
- 'P' . intval($this->repetition_interval) . 'D'
- );
+ if ($this->repetition_style === 'daily' && $this->repetition_interval) {
+ if ($this->repetition_interval === 'workdays') {
+ $this->repetition_date_interval = new DateInterval('P7D');
+ } else {
+ $this->repetition_date_interval = new DateInterval(
+ 'P' . intval($this->repetition_interval) . 'D'
+ );
+ }
}
- if ($this->repetition_style == 'weekly' && $this->repetition_interval) {
+ if ($this->repetition_style === 'weekly' && $this->repetition_interval) {
$this->repetition_date_interval = new DateInterval(
'P' . intval($this->repetition_interval) . 'W'
);
}
- if ($this->repetition_style == 'monthly') {
+ if ($this->repetition_style === 'monthly') {
$this->repetition_date_interval = new DateInterval(
'P1M'
);
@@ -1413,7 +1426,8 @@ class Resources_BookingController extends AuthenticatedController
? $this->other_room_parts[$resource->id]
: []
),
- $this->overwrite_bookings
+ $this->overwrite_bookings,
+ $this->repetition_interval === 'workdays' ? '12345' : ''
);
$errors = array_merge($errors, $results['errors']);
$room_part_errors = array_merge(