From de7d3394a6a69eae56ac0927ec55bb7ada7e193e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 5 May 2017 10:11:02 -0300 Subject: [PATCH] [SIGNED-OFF] Bug 18276: (follow-up) Remove GetBiblioFromItemNumber - ILSDI Take into account biblio level holds Signed-off-by: Josef Moravec --- C4/ILSDI/Services.pm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 0e8663c..5076110 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -417,21 +417,24 @@ sub GetPatronInfo { my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); foreach my $reserve (@reserves) { + my ( $item, $biblio, $biblioitem ) = ( {}, {}, {} ); # Get additional informations - my $item = Koha::Items->find( $reserve->{itemnumber} ); - my $biblio = $item->biblio; - my $biblioitem = $biblio->biblioitem; - my $library = Koha::Libraries->find( $reserve->{branchcode} ); - my $branchname = $library ? $library->branchname : ''; - - # Remove unwanted fields - $item = $item->unblessed; - delete $item->{'more_subfields_xml'}; - $biblio = $biblio->unblessed; - $biblioitem = $biblioitem->unblessed; + if ( $reserve->{itemnumber} ) { # item level holds + $item = Koha::Items->find( $reserve->{itemnumber} ); + $biblio = $item->biblio; + $biblioitem = $biblio->biblioitem; + + # Remove unwanted fields + $item = $item->unblessed; + delete $item->{more_subfields_xml}; + $biblio = $biblio->unblessed; + $biblioitem = $biblioitem->unblessed; + } # Add additional fields $reserve->{'item'} = { %$item, %$biblio, %$biblioitem }; + my $library = Koha::Libraries->find( $reserve->{branchcode} ); + my $branchname = $library ? $library->branchname : ''; $reserve->{'branchname'} = $branchname; $reserve->{'title'} = GetBiblio( $reserve->{'biblionumber'} )->{'title'}; } -- 2.1.4