From 01b331d024229e8d43a37e93b956673bc12cf250 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 21 Jan 2026 09:28:21 +0000 Subject: [PATCH] Bug 39584: Fix end date disable to check selected item, not all items When a specific item is selected in the booking modal, the end date disable logic was incorrectly checking if ALL bookable items were unavailable before disabling a date. This meant dates with existing bookings for the selected item remained selectable if other items were available. Now when a specific item is selected (booking_item_id != 0), the logic checks if that specific item is in the unavailable_items list. The "all items unavailable" check is only used when "Any item" is selected. This aligns the end date selection behavior with the start date selection behavior, which already correctly checks only the selected item. Signed-off-by: Kristi Krueger Signed-off-by: Andrew Fuerste Henry Signed-off-by: Paul Derscheid --- .../prog/js/modals/place_booking.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) 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 a97348b6bbd..5b7bb772c31 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js @@ -566,14 +566,28 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { continue; } - // check that there are available items - // available = all bookable items - booked items - booked biblios - let total_available = - bookable_items.length - - unavailable_items.length - - biblio_bookings.length; - if (total_available === 0) { - return true; + // check availability based on selection type + if ( + booking_item_id && + booking_item_id != 0 + ) { + // Specific item selected - check if that item is unavailable + if ( + unavailable_items.indexOf( + parseInt(booking_item_id) + ) !== -1 + ) { + return true; + } + } else { + // "Any item" selected - check if all items are unavailable + let total_available = + bookable_items.length - + unavailable_items.length - + biblio_bookings.length; + if (total_available === 0) { + return true; + } } } -- 2.52.0