From d6b4ad3dbb3c10ee3d4ba766d2f18dfacfe7ab0a Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Wed, 26 Jun 2024 17:07:00 +0200 Subject: [PATCH] Bug 37201: Allow or not a checkout if a expired booking exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test plan: 1) Apply this patch and run updatedatabase 2) Set a booking on a specific item 3) In database you can update the value to set a past date for booking end for example. 4) Go system preferences and search 'AllowExpiredBookingTransformation' 5) When you "Don\'t allow" normally you will find a pop up to confirm the checkout when you choose to 'Transform to checkout' from bookings list view. Sponsored by: Association de Gestion des Ĺ’uvres Sociales d'Inria (AGOS) --- C4/Circulation.pm | 9 +++++++++ circ/circulation.pl | 1 + ...ug_37201_allow-expired-booking-to-checkout.pl | 16 ++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/circulation.pref | 6 ++++++ .../prog/en/modules/circ/circulation.tt | 5 +++++ 6 files changed, 38 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/Bug_37201_allow-expired-booking-to-checkout.pl diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ebdc4334d70..607864a3ee5 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -781,6 +781,7 @@ sub CanBookBeIssued { my $onsite_checkout = $params->{onsite_checkout} || 0; my $override_high_holds = $params->{override_high_holds} || 0; + my $booking_id = $params->{booking_id}; my $item_object = $params->{item} // Koha::Items->find( { barcode => $barcode } ); @@ -1265,6 +1266,14 @@ sub CanBookBeIssued { } } + if ( $booking_id && !(C4::Context->preference('AllowExpiredBookingTransformation')) ) { + my $booking = Koha::Bookings->find( { booking_id => $booking_id } ); + my $booking_end = dt_from_string( $booking->end_date ); + if ( $booking->patron_id == $patron->borrowernumber && $now > $booking_end ) { + $needsconfirmation{'BOOKED_TOO_LATE'} = $booking; + } + } + ## CHECK AGE RESTRICTION my $agerestriction = $biblioitem->agerestriction; my ( $restriction_age, $daysToAgeRestriction ) = diff --git a/circ/circulation.pl b/circ/circulation.pl index c67569f647d..1ba9b45716b 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -341,6 +341,7 @@ if (@$barcodes && $op eq 'cud-checkout') { { onsite_checkout => $onsite_checkout, override_high_holds => $override_high_holds || $override_high_holds_tmp || 0, + booking_id => $booking_id, } ); } catch { diff --git a/installer/data/mysql/atomicupdate/Bug_37201_allow-expired-booking-to-checkout.pl b/installer/data/mysql/atomicupdate/Bug_37201_allow-expired-booking-to-checkout.pl new file mode 100755 index 00000000000..ca287a79d03 --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug_37201_allow-expired-booking-to-checkout.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "37201", + description => "Add syspref AllowExpiredBookingTransformation", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('AllowExpiredBookingTransformation', 1, '', 'Prevent transform into checkout a past booking', 'YesNo'); + }); + + say $out "Added new system preference 'AllowExpiredBookingTransformation'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index dffaaadd49a..58f30785571 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -28,6 +28,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AllFinesNeedOverride','1','0','If on, staff will be asked to override every fine, even if it is below noissuescharge.','YesNo'), ('AllowAllMessageDeletion','0','','Allow any Library to delete any message','YesNo'), ('AllowCheckoutNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo'), +('AllowExpiredBookingTransformation','1','','Prevent transform into checkout a past booking','YesNo'), ('AllowFineOverride','0','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','YesNo'), ('AllowHoldDateInFuture','0','','If set a date field is displayed on the Hold screen of the Staff Interface, allowing the hold date to be set in the future.','YesNo'), ('AllowHoldItemTypeSelection','0','','If enabled, patrons and staff will be able to select the itemtype when placing a hold','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index e0e0ead4892..143d9a20ae6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -615,6 +615,12 @@ Circulation: open: "extend the loan period and set the checkout to be due at the library's open time." close: "shorten the loan period and set the checkout to be due at the library's close time." ignore: "do not consider the library's opening hours." + - + - pref: AllowExpiredBookingTransformation + choices: + 1: Allow + 0: "Don't allow" + - patrons to transform a past booking into checkout. Checkin policy: - - pref: TrapHoldsOnOrder 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 4689f6cdd1a..b1d92959ced 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -275,6 +275,11 @@ Patron has this item booked for checkout on [% BOOKED_EARLY.start_date | $KohaDates %] [% END %] + [% IF ( BOOKED_TOO_LATE ) %] +
  • + Booking ended on [% BOOKED_TOO_LATE.end_date | $KohaDates %] would you force the checkout ? +
  • + [% END %] [% IF CAN_user_circulate_force_checkout or HIGHHOLDS %] -- 2.30.2