From a40207c7d8a67e09e52a0b1582c08fd13d9429a9 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. --- .../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 8bd0a6aed88..a97348b6bbd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js @@ -996,7 +996,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"); -- 2.52.0