From 05b0956957cffd0851ea38e3f4ba9597f9178d55 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 Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- 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 77ac135c5b..9b65a4a587 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -421,26 +421,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.39.5