From aef002106a76b9686cf095bc65091a1dbaf7d456 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 5 May 2017 10:11:02 -0300 Subject: [PATCH] Bug 18276: (follow-up) Remove GetBiblioFromItemNumber - ILSDI Take into account biblio level holds Signed-off-by: Josef Moravec --- C4/ILSDI/Services.pm | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index a514f50547..1db96e9f4d 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -419,26 +419,30 @@ sub GetPatronInfo { my $holds = $patron->holds; while ( my $hold = $holds->next ) { - my $unblessed_hold = $hold->unblessed; + my ( $item, $biblio, $biblioitem ) = ( {}, {}, {} ); # Get additional informations - my $item = Koha::Items->find( $hold->itemnumber ); - my $biblio = $item->biblio; - my $biblioitem = $biblio->biblioitem; - my $library = Koha::Libraries->find( $hold->branchcode ); # Should $hold->get_library - my $branchname = $library ? $library->branchname : ''; - - # Remove unwanted fields - $item = $item->unblessed; - delete $item->{'more_subfields_xml'}; - $biblio = $biblio->unblessed; - $biblioitem = $biblioitem->unblessed; + if ( $hold->itemnumber ) { # item level holds + $item = Koha::Items->find( $hold->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 + my $unblessed_hold = $hold->unblessed; $unblessed_hold->{item} = { %$item, %$biblio, %$biblioitem }; + my $library = Koha::Libraries->find( $hold->branchcode ); + my $branchname = $library ? $library->branchname : ''; $unblessed_hold->{branchname} = $branchname; $unblessed_hold->{title} = GetBiblio( $hold->biblionumber )->{'title'}; # Should be $hold->get_biblio push @{ $borrower->{holds}{hold} }, $unblessed_hold; + } } -- 2.11.0