From e3edb4ed7fd9f2222455bfa18d5da64e0ef29f95 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 18 Jul 2025 15:14:12 +0200 Subject: [PATCH] Bug 36136: Make sure 'to' dates are instantiated with the 'from' dates as minimum To test you should check the behavior of forms which have sets of "from" and "to" dates. It shouldn't be possible to select a "to" date which is before the "from" date. For example: - Overdues report - Invoice search In some cases we need to check that the fields work correctly when the "from" date is already filled: - Editing vendor issues - Editing a budget - Duplicating a subscription Signed-off-by: Owen Leonard --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 681e8cc4013..a5962de0265 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -114,6 +114,17 @@ } } new Maskito( instance.altInput, maskitoOptions ); + + /* If there is a node with data-date_to with the id of this node it means we are instantiating a 'from' for a date range */ + const toInput = instance.input; + const fromInput = document.querySelector(`[data-date_to='${toInput.id}']`); + if (fromInput && fromInput._flatpickr) { + const fromDate = fromInput._flatpickr.selectedDates[0]; + if (fromDate) { + instance.set('minDate', fromDate); + } + } + }, onChange: function( selectedDates, dateText, instance) { if (selectedDates.length === 0) { -- 2.39.5