From 57b1cadc4e490984f46563bf21374a1cf92e9026 Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Mon, 12 Jun 2023 17:58:15 +0000 Subject: [PATCH] Bug 33887: Add the ability to optionally fill the next hold when an item is automatically checked in. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When an item is automatically checked in, Koha should be able to trap that item for the next patron and send a notification to that patron that a hold is waiting for them. To test: 1. Apply patches 2. restart_all and updatedatabase 3. Go to administration -> item types and edit an item type 4. Make sure the checkbox that is labeled ‘Automatic checkin:’ is checked. At the bottom of the page click save changes. 5. In Administration -> system preferences, search for ‘AutomaticCheckinAutoFill’ and set it to ‘Do’. 6. Check out an item to a patron and make it overdue (.ie set due date to yesterday). Also make sure that the item type you are checking out matches the item type edited in step 4. 7. Place a hold on the item. Make the pickup location the same as the library it is checked out from. 8. Run cronjob at misc/cronjobs/automatic_checkin.pl 9. On the item details page, notice that the item was checked in and now the hold is waiting for pickup. 10. Visit the patron’s page who placed the hold. 11. Click on the notices tab and see that there is a ‘Hold available for pickup’ notice. 12. Repeat steps 6-8, but this time make the hold pickup location different than the library the item is currently checked out to. 13. Notice that this time, the item was checked in, the hold is waiting, and the item is in transit to the other library. 14. If you visit the patron’s page, this time there should be no new notice because the item is still in transit. 15. Sign-Off :) Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- Koha/Checkouts.pm | 17 ++++++++++++++--- installer/data/mysql/atomicupdate/bug_33887.pl | 16 ++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/circulation.pref | 7 +++++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_33887.pl diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm index 76a3b9e686..65cb7f0581 100644 --- a/Koha/Checkouts.pm +++ b/Koha/Checkouts.pm @@ -28,6 +28,7 @@ use Koha::DateUtils qw( dt_from_string ); use base qw(Koha::Objects); + =head1 NAME Koha::Checkouts - Koha Checkout object set class @@ -66,7 +67,7 @@ sub calculate_dropbox_date { my $automatic_checkins = Koha::Checkouts->automatic_checkin() -Checks in every due issue which itemtype has automatic_checkin enabled +Checks in every due issue which itemtype has automatic_checkin enabled. Also if the AutoCheckinAutoFill sys. pref. is enabled, the item is trapped for the next patron. =cut @@ -81,10 +82,20 @@ sub automatic_checkin { { prefetch => 'item'} ); + my $autofill_next = C4::Context->preference('AutomaticCheckinAutoFill'); + while ( my $checkout = $due_checkouts->next ) { if ( $checkout->item->itemtype->automatic_checkin ) { - C4::Circulation::AddReturn( $checkout->item->barcode, - $checkout->branchcode, undef, dt_from_string($checkout->date_due) ); + my ( undef, $messages) = C4::Circulation::AddReturn($checkout->item->barcode, $checkout->branchcode, undef, dt_from_string($checkout->date_due) ); + if ( $autofill_next ){ + if ( $messages->{ResFound} ){ + my $is_transfer = $checkout->branchcode ne $messages->{ResFound}->{branchcode}; + C4::Reserves::ModReserveAffect($checkout->item->itemnumber, $checkout->borrowernumber, $is_transfer, $messages->{ResFound}->{reserve_id}, $checkout->{desk_id}, 0); + if( $is_transfer ){ + C4::Items::ModItemTransfer($checkout->item->itemnumber,$checkout->branchcode, $messages->{ResFound}->{branchcode},"Reserve"); + } + } + } } } } diff --git a/installer/data/mysql/atomicupdate/bug_33887.pl b/installer/data/mysql/atomicupdate/bug_33887.pl new file mode 100755 index 0000000000..3ffd66537d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_33887.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "33887", + description => "Automatically fill the next hold with a automatic check in.", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + # Do you stuffs here + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('AutomaticCheckinAutoFill', '0', NULL,'Automatically fill the next hold with an automatic checkin cronjob.', 'YesNo') }); + # Print useful stuff here + # sysprefs + say $out "Added new system preference 'AutomaticCheckinAutoFill'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 078b27eb11..314efd51a8 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -83,6 +83,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AutoEmailNewUser','0',NULL,'Send an email to newly created patrons.','YesNo'), ('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple'), ('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff interface from unauthorized IP addresses','YesNo'), +('AutomaticCheckinAutoFill','0',NULL,'Automatically fill the next hold with an automatic check in.','YesNo'), ('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'), ('AutoLinkBiblios','0',NULL,'If enabled, link biblio to authorities on creation and edit','YesNo'), ('AutomaticConfirmTransfer','0',NULL,'Defines whether transfers should be automatically confirmed at checkin if modal dismissed','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 cc11c87a14..4d39922e8e 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 @@ -977,6 +977,13 @@ Circulation: homebranch: "item's home library" holdingbranch: "item's holding library" - "." + - + - pref: AutomaticCheckinAutoFill + choices: + 1: "Allow" + 0: "Don't allow" + - allow holds to be automatically filled after being automatically checked in. + - '
NOTE: These system preferences require the misc/cronjobs/automatic_checkin.pl cronjob. Ask your system administrator to schedule it.
' Patron restrictions: - - pref: PatronRestrictionTypes -- 2.39.5