From b3bdb1c6d2927b4bb3a7160c028855ca574c96ba 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 --- 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 681e8cc401..a5962de026 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.34.1