Bug 30726

Summary: Flatpickr's "yesterday" shortcut doesn't work if entry is limited to past dates
Product: Koha Reporter: Owen Leonard <oleonard>
Component: TemplatesAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: minor    
Priority: P5 - low CC: arthur.suzuki, jonathan.druart, lucas, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.01, 21.11.07
Bug Depends on: 29478    
Bug Blocks:    
Attachments: Bug 30726: Fix "yesterday" when limited to past dates
Bug 30726: Fix "yesterday" when limited to past dates
Bug 30726: Fix "yesterday" when limited to past dates

Description Owen Leonard 2022-05-10 14:57:44 UTC
If you configure a Flatpickr instance with the "pastdate" option (See the "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl), the "Yesterday" shortcut doesn't work. It should automatically select the previous day's date and populate the form field.
Comment 1 Jonathan Druart 2022-05-12 09:50:18 UTC
I think this is the correct fix:

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
index 1e17eccd573..5b433881377 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
@@ -152,7 +152,7 @@
                 disable_buttons.push(2); /* Tomorrow */
             }
             if( $(this).data("flatpickr-pastdate") === true ) {
-                options['maxDate'] = new Date().fp_incr(-1);
+                options['maxDate'] = new Date().fp_incr(-1).setHours(23, 59, 00, 00);
                 disable_buttons.push(1); /* Today */
                 disable_buttons.push(2); /* Tomorrow */
             }
Comment 2 Jonathan Druart 2022-06-01 12:38:23 UTC
Created attachment 135540 [details] [review]
Bug 30726: Fix "yesterday" when limited to past dates

Test plan:
Go to "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl
Select "Yesterday"
=> it automatically selects the previous day's date and populates the form field
Comment 3 Lucas Gass 2022-06-01 14:53:08 UTC
Created attachment 135552 [details] [review]
Bug 30726: Fix "yesterday" when limited to past dates

Test plan:
Go to "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl
Select "Yesterday"
=> it automatically selects the previous day's date and populates the form field

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Katrin Fischer 2022-06-06 11:29:45 UTC
Created attachment 135723 [details] [review]
Bug 30726: Fix "yesterday" when limited to past dates

Test plan:
Go to "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl
Select "Yesterday"
=> it automatically selects the previous day's date and populates the form field

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Tomás Cohen Arazi 2022-06-06 14:57:22 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 6 Lucas Gass 2022-06-17 20:15:19 UTC
Pushed to 22.05.x for 22.05.01
Comment 7 Arthur Suzuki 2022-06-21 14:03:49 UTC
thx! pushed to 21.11.x for 21.11.07
Comment 8 Victor Grousset/tuxayo 2022-06-26 00:14:47 UTC
Missing dependencies for 21.05.x, it shouldn't be affected, no backport.
Nothing to document, marking resolved.