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 <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-11-02 19:05:16 +00:00 committed by Tomas Cohen Arazi
parent 0677a53e14
commit 3ec73d80e2
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
4 changed files with 67 additions and 8 deletions

View file

@ -2179,6 +2179,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;
@ -2197,7 +2198,7 @@ sub ReserveSlip {
'borrowers' => $reserve->{borrowernumber},
'biblio' => $reserve->{biblionumber},
'biblioitems' => $reserve->{biblionumber},
'items' => $reserve->{itemnumber},
'items' => $reserve->{itemnumber} || $itemnumber,
},
);
}

View file

@ -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;
}

View file

@ -391,12 +391,16 @@
[% END # /IF ADDITIONAL_MATERIALS %]
[% IF ( RESERVED or RESERVE_WAITING or TRANSFERRED or PROCESSING ) %]
<form method="get" action="/cgi-bin/koha/circ/circulation.pl">
<form method="post" action="/cgi-bin/koha/circ/circulation.pl">
<input type="hidden" name="restoreduedatespec" />
<input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
<input type="hidden" name="confirm_hold" value="[% reserve_id | html %]" />
<input type="hidden" name="hold_branch" value="[% resbranchcode | html %]" />
<input type="hidden" name="hold_borrower" value="[% resborrowernumber | html %]" />
<input type="hidden" name="hold_itemnumber" value="[% item.itemnumber | html %]" />
<input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
<button class="print" type="submit" onclick="Dopop('hold-transfer-slip.pl?reserve_id=[% reserve_id | uri %]');this.form.submit();"><i class="fa fa-print"></i> Don't check out and print slip (P)</button>
<button class="print" type="submit" onclick="Dopop('hold-transfer-slip.pl?reserve_id=[% reserve_id | uri %]&itemnumber=[% item.id | html %]');this.form.submit();"><i class="fa fa-print"></i> Don't check out, confirm hold, and print slip (P)</button>
</form>
[% END %]

View file

@ -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;