From 6e56e4a0d1b74df33b64cc70bd38c0405597e108 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 29 Feb 2024 11:28:24 +0000 Subject: [PATCH] Bug 36175: Corrections to reduced due for booked items This patch fixes a mistake in the circulation controller such that the proper reduceddue date is passed to the template when a checkout would overlap with a booking. I also take the oportunity to enhance the functionality to allow librarians to set their own reduceddue date between now and the hard reduceddue as required for the existing booking. Test plan 1) Set an item to 'bookable' 2) Add a booking to that item for user A for a few days time. 3) Attempt to checkout the item to user B and note the warning that the item is booked for another user. 4) With the patch applied, a reduced due date of 1 day prior to the booking should be defaulted to in the displayed date picker. 5) You should be able to select any date between today and the day before the booking starts 6) Confirm you can checkout with the reduceddue date set. 7) Bonus point, confirm the field is required, so if you try to wipe it and then checkout, you will be blocked. Signed-off-by: Kelly Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- circ/circulation.pl | 2 +- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 4 ++++ koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index a6a30ce288..0ba9c2d46c 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -426,7 +426,7 @@ if (@$barcodes && $op eq 'cud-checkout') { $template_params->{getBarcodeMessageIteminfo} = $item->barcode; $template_params->{NEEDSCONFIRMATION} = 1; $confirm_required = 1; - if ( $needsconfirmation eq 'BOOKED_TO_ANOTHER' ) { + if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { my $reduceddue = dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )->subtract( days => 1 ); $template_params->{reduceddue} = $reduceddue; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 9889985181..a3d213675c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -184,6 +184,10 @@ if ( $(input).data('flatpickr-disable-shortcuts') === true ) { options['plugins'] = []; } + let maxDate = $(input).data("flatpickr-maxdate"); + if( typeof maxDate !== 'undefined' ) { + options['maxDate'] = new Date(maxDate); + } let fp = $(input).flatpickr(options); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 3eb1a55434..54c4da8d89 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -347,7 +347,7 @@ [% IF ( INVALID_DATE ) %]

- +

[% ELSE %] @@ -356,7 +356,7 @@ [% IF ( BOOKED_TO_ANOTHER ) %]

[% END %] -- 2.39.5