From 65a56b9de78225f88f4b5aba5de5c8124aa81a8f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 2 Jan 2026 11:17:02 +0000 Subject: [PATCH] Bug 39584: Fix trail period incorrectly limiting max booking date This commit fixes a bug where the trail period was preventing selection of the maximum end date allowed by circulation rules, even when there were no booking conflicts in the trail period. The Problem: ============ The hover logic in place_booking.js checked if ANY disabled date fell within the trail period and would prevent selection. However, dates can be disabled for multiple reasons: 1. They conflict with an existing booking (correct reason to disable) 2. They are beyond the maxDate set by circulation rules (incorrect!) 3. They are in the past When hovering over the max selectable end date, the trail period would extend beyond the maxDate. Those dates were disabled by flatpickr automatically, and the code incorrectly interpreted this as a booking conflict, preventing selection of the otherwise valid max date. The Fix: ======== Modified the trail period conflict check (lines 995-1005) to only consider dates that are within the max date range. Disabled dates beyond the maxDate are now ignored when checking for trail conflicts. Before: if (elemDate.isAfter(trailStart) && elemDate.isSameOrBefore(trailEnd)) { trailDisable = true; } After: if (elemDate.isAfter(trailStart) && elemDate.isSameOrBefore(trailEnd)) { const maxDate = periodPicker.config.maxDate ? dayjs(periodPicker.config.maxDate) : null; if (!maxDate || elemDate.isSameOrBefore(maxDate)) { trailDisable = true; } } This ensures trail periods only prevent selection when they conflict with actual bookings, not when they extend beyond the circulation rules' maximum date. Signed-off-by: Kristi Krueger Signed-off-by: Andrew Fuerste Henry Signed-off-by: Paul Derscheid Signed-off-by: Lucas Gass (cherry picked from commit 22c8829738c354ed83dc8e41d30bc8c791bd101b) Signed-off-by: Jacob O'Mara --- .../prog/js/modals/place_booking.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js index 23338218e7..4ba967f1d8 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js @@ -1018,7 +1018,21 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { elemDate.isAfter(trailStart) && elemDate.isSameOrBefore(trailEnd) ) { - trailDisable = true; + // Only consider this a conflict if the disabled date is within the max date range + // (i.e., disabled due to booking conflict, not because it's beyond max date) + const maxDate = periodPicker.config + .maxDate + ? dayjs( + periodPicker.config + .maxDate + ) + : null; + if ( + !maxDate || + elemDate.isSameOrBefore(maxDate) + ) { + trailDisable = true; + } } } dayElem.classList.remove("leadDisable");