From 10ee030adf9128a102127d684d6d997515b10419 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 29 Aug 2023 12:48:11 -0400 Subject: [PATCH] Bug 34643: Split CircConfirmItemParts for self-checkout and self-checkin Many libraries wish to be able to allow self-check for multi-part items while requesting librarians to verify the parts when checking out/in at the desk. It makes sense to split CircConfirmItemParts into three prefs such that the feature can be enabled/disabled for SCO and SCI independently. Test Plan: 1) Apply this patch 2) Enable SCO and SCI 3) Set CircConfirmItemPartsSCO to "Don't allow" 4) Attempt to checkout out an item with materials via SCO, it should fail 5) Set CircConfirmItemPartsSCO to "Allow" 6) Repeat step 4, it should succeed 7) Set CircConfirmItemPartsSCI to "Don't allow" 8) Attempt to check in the item via SCI, it should fail 9) Attempt to check in the item via SCO, it should fail 9) Set CircConfirmItemPartsSCI to "Allow" 10) Attempt to check in the item via SCO and SCI, it should succeed! Signed-off-by: AFHDubCoLib --- .../data/mysql/atomicupdate/bug_34643.pl | 22 +++++++++++++++++++ .../admin/preferences/circulation.pref | 12 ++++++++++ opac/sci/sci-main.pl | 2 +- opac/sco/sco-main.pl | 5 ++++- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_34643.pl diff --git a/installer/data/mysql/atomicupdate/bug_34643.pl b/installer/data/mysql/atomicupdate/bug_34643.pl new file mode 100755 index 0000000000..a23965c2b0 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_34643.pl @@ -0,0 +1,22 @@ +use Modern::Perl; + +return { + bug_number => "34643", + description => "Split CircConfirmItemParts for self-checkout and self-checkin", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my $val = C4::Context->preference('CircConfirmItemParts'); + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences VALUES + ("CircConfirmItemPartsSCO", ?, NULL, "Deny checkout of multipart items for self-checkout", "Yes/No" ), + ("CircConfirmItemPartsSCI", ?, NULL, "Deny checkout of multipart items for self-checkin", "Yes/No"); + }, undef, $val, $val + ); + + say $out "Added new system preference 'CircConfirmItemPartsSCO'"; + say $out "Added new system preference 'CircConfirmItemPartsSCI'"; + }, +}; 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 bae185a1f5..2f1753b9d3 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 @@ -12,6 +12,18 @@ Circulation: 1: "Require" 0: "Don't require" - staff to confirm that all parts of an item are present at checkin/checkout. + - + - pref: CircConfirmItemPartsSCO + choices: + 1: "Don't allow" + 0: "Allow" + - multi-part items to be checked out via the web-based self checkout module. + - + - pref: CircConfirmItemPartsSCI + choices: + 1: "Don't allow" + 0: "Allow" + - multi-part items to be checked in via the web-based self check-in or self checkout modules. - - pref: AutoSwitchPatron choices: diff --git a/opac/sci/sci-main.pl b/opac/sci/sci-main.pl index d2fdca9e10..38d698b23f 100755 --- a/opac/sci/sci-main.pl +++ b/opac/sci/sci-main.pl @@ -68,7 +68,7 @@ if ( $op eq 'cud-check_in' ) { my ( $success, $messages, $checkout, $patron ); my $item = Koha::Items->find( { barcode => $barcode } ); my $human_required = 0; - if ( C4::Context->preference("CircConfirmItemParts") + if ( C4::Context->preference("CircConfirmItemPartsSCI") && defined($item) && $item->materials ) { diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index a4a05f793e..d2325b396f 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -147,7 +147,7 @@ if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { my $item = Koha::Items->find( { barcode => $barcode } ); - if ( $success && C4::Context->preference("CircConfirmItemParts") ) { + if ( $success && C4::Context->preference("CircConfirmItemPartsSCI") ) { if ( defined($item) && $item->materials ) { @@ -179,6 +179,9 @@ elsif ( $patron && ( $op eq 'cud-checkout' ) ) { 0, C4::Context->preference("AllowItemsOnHoldCheckoutSCO") ); + + delete $needconfirm->{ADDITIONAL_MATERIALS} unless C4::Context->preference("CircConfirmItemPartsSCO"); + my $issue_error; if ( $confirm_required = scalar keys %$needconfirm ) { for my $error ( qw( UNKNOWN_BARCODE max_loans_allowed ISSUED_TO_ANOTHER NO_MORE_RENEWALS NOT_FOR_LOAN DEBT WTHDRAWN RESTRICTED RESERVED ITEMNOTSAMEBRANCH EXPIRED DEBARRED CARD_LOST GNA INVALID_DATE UNKNOWN_BARCODE TOO_MANY DEBT_GUARANTEES DEBT_GUARANTORS USERBLOCKEDOVERDUE PATRON_CANT PREVISSUE NOT_FOR_LOAN_FORCING ITEM_LOST ADDITIONAL_MATERIALS ) ) { -- 2.44.0