From 54d884819121ecb18930bbf250dfbb21fc7ecb93 Mon Sep 17 00:00:00 2001 From: Emily Lamancusa Date: Sun, 24 Mar 2024 16:07:16 -0400 Subject: [PATCH] Bug 35559: Correctly parse previous flatpickr date The Flatpickr configuration for futuredate and futuredateinclusive is meant to allow the preexisting date, even if it is in the past, to avoid data loss. As of Bug 30718 - Use flatpickr's alt option everywhere, that incoming date is in yyyy-mm-dd format, not the configured human-readable format, and needs to be parsed accordingly. To test: 1. Place 2 holds on the same bib, both with an expiration date set 2. Set the expiration date for one of the holds to a date in the past (e.g., in Koha Testing Docker, use the commands: ktd --shell koha-mysql kohadev to access the database directly) 3. Reload the holds tab for that bib --> Note that the future expiration date will be editable, and the past expiration date will not be editable 4. In a new tab, go to Administration > Patron Categories 5. Edit one patron category to have an enrolment period date in the future 6. Edit another patron category to have an enrolment period date in the past (e.g. by accessing the database directly, as above) 7. Reload the Edit pages for each of the above categories (in new tabs) --> Note that the future enrolment period date will be retained in the date field, but the past enrolment period date will be blanked out 8. Apply this patchset 9. Refresh the holds tab from step 3 --> Note that both expiration dates are now editable 10. Refresh the 2 patron category tabs from step 7 --> Note that both enrolment dates are now retained correctly 11. Open the date picker on one of the date fields that has a past date --> Note that other past dates, besides the existing date, are prevented Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index b8e2dd96db..62a7059b09 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -179,7 +179,7 @@ || $(input).data("flatpickr-futuredate") === true ) { let original_date = $(input).val(); if ( original_date ) { - original_date = Date_from_syspref( original_date ).getTime(); + original_date = flatpickr.parseDate(original_date, 'Y-m-d').getTime(); let tomorrow = new Date().fp_incr(1).getTime(); options['enable'] = [function(date){ -- 2.39.5