Bug 33345

Summary: On-site checkout checkbox does not work since issue date using flatpickr
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: TemplatesAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: normal    
Priority: P5 - low CC: david, lucas
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30717
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.05
Circulation function:
Bug Depends on: 30718    
Bug Blocks:    
Attachments: Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr
Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr
Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr
Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr

Description Fridolin Somers 2023-03-27 21:03:01 UTC
Since Bug 30718, date due uses flatpickr.
The JavaScript code setting due date via on-site checkout checkbox needs to be adapted.
Sort of like Bug 30717.
Comment 1 Fridolin Somers 2023-03-27 21:30:02 UTC
Created attachment 148786 [details] [review]
Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr

WIP
Comment 2 Fridolin Somers 2023-03-27 21:34:19 UTC
There are other places setting 'duedatespec' input, but they are hidden so not with flatpickr :

koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt:                    $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate | html %]');
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt:                        $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt:                        $("input[name=restoreduedatespec]:hidden").val('[% duedatespec | html %]');
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt:                        $("input[name=duedatespec]:hidden").val('');
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt:                              $("input[name=duedatespec]:hidden").val('[% checkout_info.HIGHHOLDS.returndate | html %]');
koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt:            if ($('#duedatespec').val().length === 0) {
koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt:            var date_due = flatpickr.parseDate( $('#duedatespec').val(), flatpickr_datetime_string );
Comment 3 Fridolin Somers 2023-03-27 21:48:37 UTC
Created attachment 148787 [details] [review]
Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr

Since Bug 30718, date due uses flatpickr.
The JavaScript code setting due date via on-site checkout checkbox needs to be adapted.
Sort of like Bug 30717.

This patch renames the variable sent to template
'today_due_date_and_time' to avoid confusion with variable 'todaysdate'
used in other templates.

Test plan :
1) Enable system preference 'OnSiteCheckouts'
2) Go to a patron circulation page /cgi-bin/koha/circ/circulation.pl
3) Click on settings icon inside barcode input
=> Check due date input is empty
4) Click on 'On-site checkout'
=> Check due date input is filled with today date at 23:59
5) Fill barcode input and do check-out
6) Check due date is correct
Comment 4 David Nind 2023-04-08 19:03:40 UTC
Created attachment 149298 [details] [review]
Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr

Since Bug 30718, date due uses flatpickr.
The JavaScript code setting due date via on-site checkout checkbox needs to be adapted.
Sort of like Bug 30717.

This patch renames the variable sent to template
'today_due_date_and_time' to avoid confusion with variable 'todaysdate'
used in other templates.

Test plan :
1) Enable system preference 'OnSiteCheckouts'
2) Go to a patron circulation page /cgi-bin/koha/circ/circulation.pl
3) Click on settings icon inside barcode input
=> Check due date input is empty
4) Click on 'On-site checkout'
=> Check due date input is filled with today date at 23:59
5) Fill barcode input and do check-out
6) Check due date is correct

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2023-04-08 19:10:08 UTC
Testing notes (using KTD):

1. If I understand this correctly, if OnSiteCheckouts is enabled:
   1.1 Go to check out an item for a patron
   1.2 Click on the settings icon in the barcode input field
   1.3 Click the tick box next to 'On-site checkouts'
   1.4 It should automatically fill in the 'Specify due date' field with today's date and 23:59 as the time
   1.5 Before the patch is applied, it doesn't (when it should)
   1.6 After the patch is applied, it does (which is what is expected)
Comment 6 Katrin Fischer 2023-04-09 12:19:18 UTC
Verified that this restores the previous behavior (tested in 20.11).
Comment 7 Katrin Fischer 2023-04-09 12:19:46 UTC
Created attachment 149363 [details] [review]
Bug 33345: On-site checkout checkbox does not work since issue date using flatpickr

Since Bug 30718, date due uses flatpickr.
The JavaScript code setting due date via on-site checkout checkbox needs to be adapted.
Sort of like Bug 30717.

This patch renames the variable sent to template
'today_due_date_and_time' to avoid confusion with variable 'todaysdate'
used in other templates.

Test plan :
1) Enable system preference 'OnSiteCheckouts'
2) Go to a patron circulation page /cgi-bin/koha/circ/circulation.pl
3) Click on settings icon inside barcode input
=> Check due date input is empty
4) Click on 'On-site checkout'
=> Check due date input is filled with today date at 23:59
5) Fill barcode input and do check-out
6) Check due date is correct

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Tomás Cohen Arazi (tcohen) 2023-04-14 14:20:11 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 9 Matt Blenkinsop 2023-04-18 12:06:16 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 10 Lucas Gass (lukeg) 2023-05-05 22:13:48 UTC
Missing 22.05.x dependencies, no backport.