From bb059abe90c4be84d3354ba0c716566227b39c64 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 29 Apr 2024 04:37:50 +0000 Subject: [PATCH] Bug 32256: Handle batch error messages better This enhancement modifies the self-checkout script to better handle 'impossible' and 'needs confirmation' checkout messages. Test with a combination of barcodes that would invoke these messages, for example: - impossible: barcode doesn't exist - impossible: barcode is for a 'notforloan' item type - impossible: debt - needs confirmation: barcode already checked out, i.e. confirm renewal Include barcodes that should have successful checkouts too. Also, test with the following sysprefs: - BatchCheckouts: enabled - BatchCheckoutsValidCategories: none selected Confirm SCO does not have a multi-line text area for more than one barcode, and doesn't accept more than one barcode. Signed-off-by: Andrew Fuerste Henry Signed-off-by: Martin Renvoize Signed-off-by: Andrew Fuerste Henry Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../bootstrap/en/modules/sco/sco-main.tt | 80 ++++++++--------- opac/sco/sco-main.pl | 87 +++++++++---------- 2 files changed, 73 insertions(+), 94 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 13e510ce7b..cd369b559d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -56,59 +56,59 @@

[% LibraryName | html %] Self checkout system

- [% IF ( impossible ) %] + [% FOREACH item IN impossible %]

Item cannot be checked out.

Sorry, this item cannot be checked out at this station.

- [% IF ( title ) %] -

Title: [% title | html %]

+ [% IF ( item.title ) %] +

Title: [% item.title | html %]

[% END %]

- [% IF ( circ_error_UNKNOWN_BARCODE ) %] + [% IF ( item.circ_error_UNKNOWN_BARCODE ) %] The system does not recognize this barcode. - [% ELSIF ( circ_error_max_loans_allowed ) %] + [% ELSIF ( item.circ_error_max_loans_allowed ) %] You have reached the maximum limit of items checked out. - [% ELSIF ( circ_error_ISSUED_TO_ANOTHER ) %] + [% ELSIF ( item.circ_error_ISSUED_TO_ANOTHER ) %] This item is checked out to someone else. - [% ELSIF ( circ_error_NO_MORE_RENEWALS ) %] + [% ELSIF ( item.circ_error_NO_MORE_RENEWALS ) %] You cannot renew this item again. - [% ELSIF ( circ_error_NOT_FOR_LOAN ) %] + [% ELSIF ( item.circ_error_NOT_FOR_LOAN ) %] This item is not for loan. - [% ELSIF ( circ_error_DEBT ) %] - You owe the library [% DEBT | $Price with_symbol => 1%] and cannot check out. - [% ELSIF ( circ_error_WTHDRAWN ) %] + [% ELSIF ( item.circ_error_DEBT ) %] + You owe the library [% item.DEBT | $Price with_symbol => 1%] and cannot check out. + [% ELSIF ( item.circ_error_WTHDRAWN ) %] This item has been withdrawn from the collection. - [% ELSIF ( circ_error_RESTRICTED ) %] + [% ELSIF ( item.circ_error_RESTRICTED ) %] This item is restricted. - [% ELSIF ( circ_error_RESERVED ) %] + [% ELSIF ( item.circ_error_RESERVED ) %] This item is on hold for another patron. - [% ELSIF ( circ_error_ITEMNOTSAMEBRANCH ) %] + [% ELSIF ( item.circ_error_ITEMNOTSAMEBRANCH ) %] This item belongs to another library. - [% ELSIF ( circ_error_EXPIRED ) %] + [% ELSIF ( item.circ_error_EXPIRED ) %] Your account has expired. - [% ELSIF ( circ_error_DEBARRED ) %] + [% ELSIF ( item.circ_error_DEBARRED ) %] Your account has been suspended. - [% ELSIF ( circ_error_CARD_LOST ) %] + [% ELSIF ( item.circ_error_CARD_LOST ) %] This library card has been declared lost. - [% ELSIF ( circ_error_GNA ) %] + [% ELSIF ( item.circ_error_GNA ) %] Your contact information seems to be incomplete. - [% ELSIF ( circ_error_INVALID_DATE ) %] + [% ELSIF ( item.circ_error_INVALID_DATE ) %] Due date is not valid. - [% ELSIF ( circ_error_ADDITIONAL_MATERIALS ) %] + [% ELSIF ( item.circ_error_ADDITIONAL_MATERIALS ) %] Item must be checked out at a circulation desk. [% END %] Please see a member of the library staff.

- [% IF ( returnitem && Koha.Preference('SCOAllowCheckin') ) %] + [% IF ( item.returnitem && Koha.Preference('SCOAllowCheckin') ) %]
[% INCLUDE 'csrf-token.inc' %] Return - + @@ -119,19 +119,19 @@ Error - +
- [% END # / IF ( impossible %] + [% END # / FOREACH impossible %] - [% IF ( confirm ) %] + [% FOREACH c IN confirm %]

Please confirm the checkout:

- [% IF ( confirm_renew_issue ) %] -

This item is already checked out to you: [% confirm | html %] ([% barcode | html %])

+ [% IF ( c.confirm_renew_issue ) %] +

This item is already checked out to you: [% c.confirm | html %] ([% c.barcode | html %])

[% END %] [% IF ( renew && Koha.Preference('SCOAllowCheckin') ) %] @@ -140,7 +140,7 @@ Return - + @@ -148,13 +148,13 @@ [% END %] - [% UNLESS ( renew ) %] + [% UNLESS ( c.renew ) %]
[% INCLUDE 'csrf-token.inc' %] Renew - + @@ -166,7 +166,7 @@ Renew - + @@ -183,7 +183,7 @@
- [% END # / IF confirm %] + [% END # / FOREACH confirm %] [% IF ( nopermission ) %] @@ -241,18 +241,6 @@ [% END %] - [% IF ( circ_error_BATCH_CHECKOUT ) %] -
-

Item cannot be checked out in a batch

-

Check out the following item(s) individually:

-
    - [% FOREACH barcode IN circ_error_BATCH_CHECKOUT %] -
  • [% barcode | html %]
  • - [% END %] -
-
- [% END %] - [% UNLESS ( hide_main ) %] [% IF ( patronid ) %] @@ -285,10 +273,10 @@
- +
- [% IF Koha.Preference('BatchCheckouts') %] + [% IF batch_checkouts_allowed %] [% ELSE %] diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index c049f2bb01..26c76c2f76 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -138,34 +138,13 @@ my $branch = $issuer->{branchcode}; my $confirm_required = 0; my $return_only = 0; +my $batch_checkouts_allowed; if ( C4::Context->preference('BatchCheckouts') and $patron ) { my @batch_category_codes = split ',', C4::Context->preference('BatchCheckoutsValidCategories'); my $categorycode = $patron->categorycode; if ( $categorycode && grep { $_ eq $categorycode } @batch_category_codes ) { - # do nothing - logged in patron is allowed to do batch checkouts - } else { - # patron category not allowed to do batch checkouts, only allow first barcode - my @error_barcodes; - while ( scalar @$barcodes > 1 ) { - my $error_barcode = pop @$barcodes; - push @error_barcodes, $error_barcode; - } - - $template->param( - "circ_error_BATCH_CHECKOUT" => \@error_barcodes, - ) if @$barcodes; - } -} else { - # batch checkouts not enabled, only allow first barcode - my @error_barcodes; - while ( scalar @$barcodes > 1 ) { - my $error_barcode = pop @$barcodes; - push @error_barcodes, $error_barcode; + $batch_checkouts_allowed = 1; } - - $template->param( - "circ_error_BATCH_CHECKOUT" => \@error_barcodes, - ) if @$barcodes; } if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { @@ -199,6 +178,8 @@ if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { } elsif ( $patron && ( $op eq 'cud-checkout' ) ) { + my @failed_checkouts; + my @confirm_checkouts; foreach my $barcode ( @$barcodes ) { my $item = Koha::Items->find( { barcode => $barcode } ); my $impossible = {}; @@ -222,46 +203,47 @@ elsif ( $patron && ( $op eq 'cud-checkout' ) ) { } if (scalar keys %$impossible) { - my $issue_error = (keys %$impossible)[0]; # FIXME This is wrong, we assume only one error and keys are not ordered my $title = ( $item ) ? $item->biblio->title : ''; - $template->param( - impossible => $issue_error, + my $failed_checkout = { "circ_error_$issue_error" => 1, title => $title, - hide_main => 1, - ); + }; + if ($issue_error eq 'DEBT') { - $template->param(DEBT => $impossible->{DEBT}); + $failed_checkout->{DEBT} = $impossible->{DEBT}; } if ( $issue_error eq "NO_MORE_RENEWALS" ) { $return_only = 1; - $template->param( - returnitem => 1, - barcode => $barcode, - ); + $failed_checkout->{barcode} = $barcode; + $failed_checkout->{returnitem} = 1; } - last; - } elsif ( $needconfirm->{RENEW_ISSUE} ){ + + push @failed_checkouts, $failed_checkout; + $template->param( - renew => 1, - barcode => $barcode, - confirm => $item->biblio->title, - confirm_renew_issue => 1, - hide_main => 1, + hide_main => 1, ); - last; - } elsif ( $confirm_required && !$confirmed ) { + } elsif ( $needconfirm->{RENEW_ISSUE} ) { + my $confirm_checkout = { + renew => 1, + barcode => $barcode, + confirm => $item->biblio->title, + confirm_renew_issue => 1, + }; + push @confirm_checkouts, $confirm_checkout; $template->param( - impossible => 1, - "circ_error_$issue_error" => 1, - hide_main => 1, + hide_main => 1, ); + } elsif ( $confirm_required && !$confirmed ) { + my $failed_checkout = { + "circ_error_$issue_error" => 1, + }; if ($issue_error eq 'DEBT') { - $template->param(DEBT => $needconfirm->{DEBT}); + $failed_checkout->{DEBT} = $needconfirm->{DEBT}; } - last; + push @failed_checkouts, $failed_checkout; } else { if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues. my ( $hold_existed, $item ); @@ -303,14 +285,22 @@ elsif ( $patron && ( $op eq 'cud-checkout' ) ) { } } else { $confirm_required = 1; - $template->param( + my $confirm_checkout = { confirm => "Issuing title: " . $item->biblio->title, barcode => $barcode, + }; + push @confirm_checkouts, $confirm_checkout; + $template->param( hide_main => 1, ); } } } # foreach barcode in barcodes + + $template->param( + impossible => \@failed_checkouts, + confirm => \@confirm_checkouts, + ); } # $op if ( $patron && ( $op eq 'cud-renew' ) ) { @@ -388,6 +378,7 @@ if ( $patron) { howpriority => $show_priority, ACCOUNT_LINES => $accountlines, total => $total, + batch_checkouts_allowed => $batch_checkouts_allowed, ); my $patron_messages = Koha::Patron::Messages->search( -- 2.39.5