From 96442d7ac738c3baf3a0e6914362e908bdc7adc3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 2 Nov 2023 19:05:16 +0000 Subject: [PATCH] Bug 17798: Confirm hold when printing slip from another patron's account This patch adds a few pieces of information to the print slip button and makes the code confirm the hold As we are printing before the confirm, we also add the ability to pass in the itemnumber to 'ReserveSlip' This is slightly hacky, however, I don't see another way to allow printing without an additional page reload. To test: 1 - Place a title level hold for patron A, for delivery to library B 2 - Attempt to checkout an item from the record above to Patron B from library A 3 - You receive an alert about the hold 4 - Click "Don't check out, confirm hold, and print slip" 5 - Confirm the slip looks correct and has item info 6 - Confirm that item is in transit to fill hold 7 - Revert transit status 8 - Attempt to checkout the item to Patron B from Library B 9 - Click "Don't check out, confirm hold, and print slip" 10 - Confirm slip is correct 11 - Confirm item is marked waiting Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 3ec73d80e2a88e3a87eefc886865ccfb91f9be09) Signed-off-by: Fridolin Somers --- C4/Reserves.pm | 3 +- circ/circulation.pl | 22 ++++++++-- .../prog/en/modules/circ/circulation.tt | 8 +++- t/db_dependent/Reserves/ReserveSlip.t | 42 ++++++++++++++++++- 4 files changed, 67 insertions(+), 8 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index b771a37083..0295bd3c66 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -2162,6 +2162,7 @@ sub ReserveSlip { my ($args) = @_; my $branchcode = $args->{branchcode}; my $reserve_id = $args->{reserve_id}; + my $itemnumber = $args->{itemnumber}; my $hold = Koha::Holds->find($reserve_id); return unless $hold; @@ -2180,7 +2181,7 @@ sub ReserveSlip { 'borrowers' => $reserve->{borrowernumber}, 'biblio' => $reserve->{biblionumber}, 'biblioitems' => $reserve->{biblionumber}, - 'items' => $reserve->{itemnumber}, + 'items' => $reserve->{itemnumber} || $itemnumber, }, ); } diff --git a/circ/circulation.pl b/circ/circulation.pl index 0e666893af..3311308acf 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -38,7 +38,7 @@ use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue ); use C4::Members; use C4::Biblio qw( TransformMarcToKoha ); use C4::Search qw( new_record_from_zebra ); -use C4::Reserves; +use C4::Reserves qw( ModReserveAffect ); use Koha::Holds; use C4::Context; use CGI::Session; @@ -69,6 +69,10 @@ my $override_high_holds_tmp = $query->param('override_high_holds_tmp'); my $sessionID = $query->cookie("CGISESSID") ; my $session = get_session($sessionID); +my $userenv = C4::Context->userenv; +my $branch = $userenv->{'branch'} // ''; +my $desk_id = $userenv->{"desk_id"} || ''; + my $barcodes = []; my $barcode = $query->param('barcode'); my $findborrower; @@ -88,6 +92,18 @@ if (C4::Context->preference("AutoSwitchPatron") && $barcode) { $findborrower ||= $query->param('findborrower') || q{}; $findborrower =~ s|,| |g; +if ( $query->param('confirm_hold') ) { + my $reserve_id = $query->param('confirm_hold'); + my $hold_branch = $query->param('hold_branch'); + my $hold_itemnumber = $query->param('hold_itemnumber'); + my $hold_borrowernumber = $query->param('hold_borrowernumber'); + my $diffBranchSend = ( $branch ne $hold_branch ); + + # diffBranchSend tells ModReserveAffect whether document is expected in this library or not, + # i.e., whether to apply waiting status + ModReserveAffect( $hold_itemnumber, $hold_borrowernumber, $diffBranchSend, $reserve_id, $desk_id ); +} + # Barcode given by user could be '0' if ( $barcode || ( defined($barcode) && $barcode eq '0' ) ) { $barcodes = [ $barcode ]; @@ -134,7 +150,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( my $logged_in_user = Koha::Patrons->find( $loggedinuser ); my $force_allow_issue = $query->param('forceallow') || 0; -if (!C4::Auth::haspermission( C4::Context->userenv->{id} , { circulate => 'force_checkout' } )) { +if (!C4::Auth::haspermission( $userenv->{id} , { circulate => 'force_checkout' } )) { $force_allow_issue = 0; } my $onsite_checkout = $query->param('onsite_checkout'); @@ -151,8 +167,6 @@ my @failedreturns = $query->multi_param('failedreturn'); our %return_failed = (); for (@failedreturns) { $return_failed{$_} = 1; } -my $branch = C4::Context->userenv->{'branch'}; - for my $barcode ( @$barcodes ) { $barcode = barcodedecode( $barcode ) if $barcode; } 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 41d7553b52..99f2c454ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -361,12 +361,16 @@ [% END # /IF ADDITIONAL_MATERIALS %] [% IF ( RESERVED or RESERVE_WAITING or TRANSFERRED or PROCESSING ) %] -
+ + + + + - +
[% END %] diff --git a/t/db_dependent/Reserves/ReserveSlip.t b/t/db_dependent/Reserves/ReserveSlip.t index 03b5731644..664f9a1b0c 100755 --- a/t/db_dependent/Reserves/ReserveSlip.t +++ b/t/db_dependent/Reserves/ReserveSlip.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 4; use t::lib::TestBuilder; use C4::Reserves qw( ReserveSlip ); @@ -111,6 +111,46 @@ is (ReserveSlip({ })->{content}, sprintf( "Hold found for %s: Please pick up %s with barcode %s at %s.", $patron->{firstname}, $biblio->title, $item1->barcode, $library->{branchcode}),"Hold slip contains correctly parsed content"); +subtest 'title level hold' => sub { + plan tests => 2; + + my $biblio = $builder->build_sample_biblio; + my $item = $builder->build_sample_item( + { + biblionumber => $biblio->biblionumber, + library => $library->{branchcode}, + } + ); + my $hold = $builder->build_object( + { + class => 'Koha::Holds', + value => { + branchcode => $library->{branchcode}, + borrowernumber => $patron->{borrowernumber}, + biblionumber => $biblio->id, + itemnumber => undef, + } + } + ); + + my $slip = ReserveSlip( + { + branchcode => $hold->branchcode, + reserve_id => $hold->id, + itemnumber => $item->id + } + ); + is( $slip->{code}, 'HOLD_SLIP', "We get expected letter" ); + is( + $slip->{content}, + sprintf( + "Hold found for %s: Please pick up %s with barcode %s at %s.", $patron->{firstname}, $biblio->title, + $item->barcode, $library->{branchcode} + ), + "Hold slip contents correctly use the passed item" + ); +}; + $schema->storage->txn_rollback; 1; -- 2.39.5