From b7a5fe392a2e99f78e800df8c840339b60fad24c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 Aug 2022 12:31:43 +0200 Subject: [PATCH] Bug 2894: Fix Routing list holds This is a try to fix a very old bug. Not familiar with the workflow so cannot confirm it will fix everything. The idea is to fix the behaviour of RoutingListAddReserves, and create item-level holds (so only if items have been created). --- serials/routing-preview.pl | 45 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl index e12cd17af0d..1486021d4a5 100755 --- a/serials/routing-preview.pl +++ b/serials/routing-preview.pl @@ -66,41 +66,48 @@ if($ok){ my $biblio = Koha::Biblios->find( $biblionumber ); my $branchcode = $subs->{branchcode}; my $serialitem = Koha::Serial::Items->search( { serialid => $serialid } )->next; - if ( $serialitem ) { + + if ( C4::Context->preference('RoutingListAddReserves') && $serialitem ) { my $item = Koha::Items->find($serialitem->itemnumber); $branchcode = $item->holdingbranch || $branchcode; - } - $library = Koha::Libraries->find($branchcode); - - if (C4::Context->preference('RoutingListAddReserves')){ - my $notes; - my $title = $subs->{'bibliotitle'}; - for my $routing ( @routinglist ) { - my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? LIMIT 1'); - $sth->execute($biblionumber,$routing->{borrowernumber}); + $library = Koha::Libraries->find($branchcode); + + my $notes; + my $title = $subs->{'bibliotitle'}; + for my $routing (@routinglist) { + my $sth = $dbh->prepare( + 'SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? LIMIT 1' + ); + $sth->execute( $biblionumber, $routing->{borrowernumber} ); my $reserve = $sth->fetchrow_hashref; - if($routing->{borrowernumber} == $reserve->{borrowernumber}){ - ModReserve({ - rank => $routing->{ranking}, - biblionumber => $biblionumber, - borrowernumber => $routing->{borrowernumber}, - branchcode => $branchcode, - }); - } else { + if ( $routing->{borrowernumber} == $reserve->{borrowernumber} ) + { + ModReserve( + { + rank => $routing->{ranking}, + biblionumber => $biblionumber, + itemnumber => $serialitem->itemnumber, + borrowernumber => $routing->{borrowernumber}, + branchcode => $branchcode, + } + ); + } + else { AddReserve( { branchcode => $branchcode, borrowernumber => $routing->{borrowernumber}, biblionumber => $biblionumber, + itemnumber => $serialitem->itemnumber, priority => $routing->{ranking}, notes => $notes, title => $title, } ); + } } } - } ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "serials/routing-preview-slip.tt", -- 2.25.1