From 302542f7ec5cee52e995e543382a9f511a4e3ee3 Mon Sep 17 00:00:00 2001 From: Barry Cannon Date: Mon, 4 Nov 2019 16:39:51 +0000 Subject: [PATCH] Bug 15729 - SIP server allows checkin of reserved item This patch allows the library to allow or dissallow items that are reserved to be checked in via a selfcheck machine. Some libraries perfer to deny the checkin transaction to force the borrower to return via the circ desk. Adds a new systempreference called AllowSIPCheckInOnHolds. To Test, apply the patch and run database update - Check Administration > System preferences > Circulation > AllowSIPCheckInOnHolds and set to "Don't Allow" - Find, or create, a biblio in the catalogue with more that one item and place a bib level hold. - Restart SIP instance on the server - Issue a checkin transaction call from a selfcheck machine or via the sip_cli emulator - Observe the checkin has been denied with screen message explaining why. - Delete the hold on the biblio record. - Create a new hold item-level hold on the same biblio record - Try the transaction again with the item that has an item-level hold. - Observe the checing has been denied. - Try the transaction again with an item attached to the biblio that does not have an item-level hold - Observer the checkin is allowed. - Change the System preference AllowSIPCheckInOnHolds to "Allow" - Restart the SIP instance on the server - Preform the checkin transaction above again and notice they are now permitted --- C4/SIP/ILS.pm | 3 +++ C4/SIP/ILS/Transaction/Checkin.pm | 28 +++++++++++++++++++++- installer/data/mysql/atomicupdate/bug_15729.perl | 6 +++++ installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/circulation.pref | 6 +++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_15729.perl diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index b543539dd0..47b22b1516 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -226,6 +226,9 @@ sub checkin { } elsif ( $data->{messages}->{WasLost} && !$circ->ok ) { $circ->screen_msg("Item lost, return not allowed"); syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - item lost"); + } elsif ($data->{messages}->{ResFound}->{AllowSIPCheckinOnHolds} && !$circ->ok) { + $circ->screen_msg("Checkin failed, item reserved. Please bring to issue desk."); + syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - item reserved"); } elsif ( !$item->{patron} ) { if ( $checked_in_ok ) { # Mark checkin ok although book not checked out $circ->ok( 1 ); diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index f0e8bbdf49..71dd21b768 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -68,8 +68,34 @@ sub do_checkin { . ':' . substr( $return_date, 16, 2 ); + my ($return, $messages, $issue, $borrower); + + if ( !C4::Context->preference("AllowSIPCheckinOnHolds") ) { + if ( scalar @{ $self->{item}->{hold_queue} } ) { # there's an item-level hold, is it for this item? + foreach my $hq ( @{ $self->{item}->{hold_queue} } ) { + if ( $self->{item}->{itemnumber} == $hq->{itemnumber} ) { + $messages = { "ResFound" => { "AllowSIPCheckinOnHolds" => 1 } }; + $self->alert_type('01'); + $self->ok(0); + return { messages => $messages }; + } + + } + } + if ( scalar @{ $self->{item}->{pending_queue} } ) { + foreach my $pq ( @{ $self->{item}->{pending_queue} } ) { + if ( $pq->{item_level_hold} == 0 ) { # bib level hold? + $messages = { "ResFound" => { "AllowSIPCheckinOnHolds" => 1 } }; + $self->alert_type('01'); + $self->ok(0); + return { messages => $messages }; + } + } + } + } + $debug and warn "do_checkin() calling AddReturn($barcode, $branch)"; - my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, dt_from_string($return_date)); + ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, dt_from_string($return_date)); if ( $checked_in_ok ) { delete $messages->{NotIssued}; diff --git a/installer/data/mysql/atomicupdate/bug_15729.perl b/installer/data/mysql/atomicupdate/bug_15729.perl new file mode 100644 index 0000000000..90ec045a53 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_15729.perl @@ -0,0 +1,6 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('AllowSIPCheckInOnHolds','0','','SIP checkin transaction to proceed if the item being checked in has an existing hold on it.','YesNo'); + + +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 86514d94f9..c9ac5446a2 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -42,6 +42,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AllowRenewalOnHoldOverride','0',NULL,'If ON, allow items on hold to be renewed with a specified due date','YesNo'), ('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'), ('AllowSelfCheckReturns','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'), +('AllowSIPCheckInOnHolds','0','','SIP checkin transaction to proceed if the item being checked in has an existing hold on it.','YesNo'), ('AllowStaffToSetCheckoutsVisibilityForGuarantor','0',NULL,'If enabled, library staff can set a patron''s checkouts to be visible to linked patrons from the opac.', 'YesNo'), ('AllowStaffToSetFinesVisibilityForGuarantor','0',NULL,'If enabled, library staff can set a patron''s fines to be visible to linked patrons from the opac.', 'YesNo'), ('AllowTooManyOverride','1','','If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts','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 52fdc24bba..ccc2e3a1ca 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 @@ -505,6 +505,12 @@ Circulation: no: "Don't" - automatically fill holds instead of asking the librarian. - + - pref: AllowSIPCheckInOnHolds + choices: + yes: Allow + no: "Don't Allow" + - SIP checkin transaction to proceed if the item being checked in has an existing hold on it. + - - pref: HoldsAutoFillPrintSlip choices: yes: Do -- 2.11.0