From 8cd346a5207fd8769718c2bbea5d01c9b72240c7 Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Fri, 13 Sep 2024 15:48:34 +0000 Subject: [PATCH] Bug 37587: (QA follow-up) Tidy reserve/placerequest.pl Signed-off-by: Katrin Fischer (cherry picked from commit 6bcc82815d727ee0d6faa94aa42a86909e5d9a57) Signed-off-by: Lucas Gass --- reserve/placerequest.pl | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl index 72b604565d..11aa387672 100755 --- a/reserve/placerequest.pl +++ b/reserve/placerequest.pl @@ -3,7 +3,6 @@ #script to place reserves/requests #written 2/1/00 by chris@katipo.oc.nz - # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. @@ -26,17 +25,17 @@ use Modern::Perl; use CGI qw ( -utf8 ); use URI; use C4::Reserves qw( CanItemBeReserved AddReserve CanBookBeReserved ); -use C4::Auth qw( checkauth ); +use C4::Auth qw( checkauth ); use Koha::Items; use Koha::Patrons; my $input = CGI->new(); -checkauth($input, 0, { reserveforothers => 'place_holds' }, 'intranet'); +checkauth( $input, 0, { reserveforothers => 'place_holds' }, 'intranet' ); my @reqbib = $input->multi_param('reqbib'); -my @biblionumbers = $input->multi_param('biblionumber'); +my @biblionumbers = $input->multi_param('biblionumber'); my @holdable_bibs = $input->multi_param('holdable_bibs'); my $borrowernumber = $input->param('borrowernumber'); my $notes = $input->param('notes'); @@ -44,7 +43,7 @@ my $branch = $input->param('pickup'); my $startdate = $input->param('reserve_date') || ''; my @rank = $input->multi_param('rank-request'); my $title = $input->param('title'); -my @checkitems = $input->multi_param('checkitem'); +my @checkitems = $input->multi_param('checkitem'); my $item_group_id = $input->param('item_group_id'); my $expirationdate = $input->param('expiration_date'); my $itemtype = $input->param('itemtype') || undef; @@ -52,27 +51,25 @@ my $non_priority = $input->param('non_priority'); my $op = $input->param('op') || q{}; my $multi_holds = $input->param('multi_holds'); -my $patron = Koha::Patrons->find( $borrowernumber ); +my $patron = Koha::Patrons->find($borrowernumber); my $holds_to_place_count = $input->param('holds_to_place_count') || 1; my %bibinfos = (); -foreach my $bibnum ( @holdable_bibs ) { +foreach my $bibnum (@holdable_bibs) { my %bibinfo = (); - $bibinfo{title} = $input->param("title_$bibnum"); - $bibinfo{rank} = $input->param("rank_$bibnum"); - $bibinfo{pickup} = $input->param("pickup_$bibnum"); + $bibinfo{title} = $input->param("title_$bibnum"); + $bibinfo{rank} = $input->param("rank_$bibnum"); + $bibinfo{pickup} = $input->param("pickup_$bibnum"); $bibinfos{$bibnum} = \%bibinfo; } - - if ( $op eq 'cud-placerequest' && $patron ) { my %failed_holds; foreach my $biblionumber ( keys %bibinfos ) { my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); - if ( @checkitems ) { + if (@checkitems) { my $hold_priority = $rank[0]; @@ -116,9 +113,9 @@ if ( $op eq 'cud-placerequest' && $patron ) { } } - } elsif (@biblionumbers > 1 || $multi_holds) { + } elsif ( @biblionumbers > 1 || $multi_holds ) { my $bibinfo = $bibinfos{$biblionumber}; - if ( $can_override || CanBookBeReserved($patron->borrowernumber, $biblionumber)->{status} eq 'OK' ) { + if ( $can_override || CanBookBeReserved( $patron->borrowernumber, $biblionumber )->{status} eq 'OK' ) { AddReserve( { branchcode => $bibinfo->{pickup}, @@ -137,9 +134,10 @@ if ( $op eq 'cud-placerequest' && $patron ) { ); } } else { + # place a request on 1st available for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) { - if ( $can_override || CanBookBeReserved($patron->borrowernumber, $biblionumber)->{status} eq 'OK' ) { + if ( $can_override || CanBookBeReserved( $patron->borrowernumber, $biblionumber )->{status} eq 'OK' ) { AddReserve( { branchcode => $branch, @@ -162,7 +160,7 @@ if ( $op eq 'cud-placerequest' && $patron ) { } } - my $redirect_url = URI->new("request.pl"); + my $redirect_url = URI->new("request.pl"); my @failed_hold_msgs = (); #NOTE: Deduplicate failed hold reason statuses/codes @@ -171,8 +169,7 @@ if ( $op eq 'cud-placerequest' && $patron ) { } $redirect_url->query_form( biblionumber => [@biblionumbers], failed_holds => \@failed_hold_msgs ); print $input->redirect($redirect_url); -} -elsif ( $borrowernumber eq '' ) { +} elsif ( $borrowernumber eq '' ) { print $input->header(); print "Invalid borrower number please try again"; -- 2.39.5