Take into account biblio level holds
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
my $holds = $patron->holds;
while ( my $hold = $holds->next ) {
my $holds = $patron->holds;
while ( my $hold = $holds->next ) {
- my $unblessed_hold = $hold->unblessed;
+ my ( $item, $biblio, $biblioitem ) = ( {}, {}, {} );
# Get additional informations
# 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;
+ }
+ my $unblessed_hold = $hold->unblessed;
$unblessed_hold->{item} = { %$item, %$biblio, %$biblioitem };
$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;
$unblessed_hold->{branchname} = $branchname;
$unblessed_hold->{title} = GetBiblio( $hold->biblionumber )->{'title'}; # Should be $hold->get_biblio
push @{ $borrower->{holds}{hold} }, $unblessed_hold;