From e1ccec16b47fd693d913e1c82b9815b63d26f6c5 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 Signed-off-by: Olli Kautonen Signed-off-by: Kyle M Hall --- 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 1437f2e157f..607d72d929b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -115,6 +115,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.50.1 (Apple Git-155)