Browse Source

Bug 18255: Koha::Biblio - Replace GetBiblioItemByBiblioNumber with Koha::Biblio->biblioitem

The subroutine GetBiblioItemByBiblioNumber considers that we have a 1-N
relation between biblio and biblioitems, which is wrong (it's 1-1).
So the calls can be replaced with Koha::biblio->biblioitem, it will ease
the read of the code.

Test plan:
1. Use the ILSDI service to display info of a bibliographic record,
biblioitems fields must be displayed
2. Search for items, biblioitems info must be displayed as well in the
result table

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
18.05.x
Jonathan Druart 7 years ago
parent
commit
cb336e633b
  1. 24
      C4/Biblio.pm
  2. 9
      C4/ILSDI/Services.pm
  3. 5
      catalogue/itemsearch.pl
  4. 2
      cataloguing/merge.pl
  5. 3
      serials/routing-preview.pl

24
C4/Biblio.pm

@ -69,7 +69,6 @@ BEGIN {
GetMarcBiblio
GetBiblioItemData
GetBiblioItemInfosOf
GetBiblioItemByBiblioNumber
&GetRecordValue
@ -750,29 +749,6 @@ sub GetBiblioItemData {
return ($data);
} # sub &GetBiblioItemData
=head2 GetBiblioItemByBiblioNumber
NOTE : This function has been copy/paste from C4/Biblio.pm from head before zebra integration.
=cut
sub GetBiblioItemByBiblioNumber {
my ($biblionumber) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("Select * FROM biblioitems WHERE biblionumber = ?");
my $count = 0;
my @results;
$sth->execute($biblionumber);
while ( my $data = $sth->fetchrow_hashref ) {
push @results, $data;
}
$sth->finish;
return @results;
}
=head2 GetISBDView
$isbd = &GetISBDView({

9
C4/ILSDI/Services.pm

@ -208,9 +208,13 @@ sub GetRecords {
foreach my $biblionumber ( split( / /, $cgi->param('id') ) ) {
# Get the biblioitem from the biblionumber
my $biblioitem = ( GetBiblioItemByBiblioNumber( $biblionumber, undef ) )[0];
if ( not $biblioitem->{'biblionumber'} ) {
my $biblio = Koha::Biblios->find( $biblionumber );
my $biblioitem = $biblio->biblioitem;
if ( $biblioitem ) {
$biblioitem = $biblioitem->unblessed;
} else {
$biblioitem->{code} = "RecordNotFound";
# FIXME We should not need to process something else; next?
}
my $embed_items = 1;
@ -223,7 +227,6 @@ sub GetRecords {
# Get most of the needed data
my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
my $biblio = Koha::Biblios->find( $biblionumber );
my $holds = $biblio->current_holds->unblessed;
my $issues = GetBiblioIssues($biblionumber);
my $items = GetItemsByBiblioitemnumber($biblioitemnumber);

5
catalogue/itemsearch.pl

@ -233,8 +233,9 @@ if (scalar keys %params > 0) {
}
foreach my $item (@$results) {
$item->{biblio} = Koha::Biblios->find( $item->{biblionumber} );
($item->{biblioitem}) = GetBiblioItemByBiblioNumber($item->{biblionumber});
my $biblio = Koha::Biblios->find( $item->{biblionumber} );
$item->{biblio} = $biblio;
$item->{biblioitem} = $biblio->biblioitem->unblessed;
$item->{status} = $notforloan_map->{$item->{notforloan}};
if (defined $item->{location}) {
$item->{location} = $location_map->{$item->{location}};

2
cataloguing/merge.pl

@ -159,8 +159,6 @@ if ($merge) {
# Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio)
my @allorders = GetOrdersByBiblionumber($biblionumber);
my @tobiblioitem = GetBiblioItemByBiblioNumber ($ref_biblionumber);
my $tobiblioitem_biblioitemnumber = $tobiblioitem [0]-> {biblioitemnumber };
foreach my $myorder (@allorders) {
$myorder->{'biblionumber'} = $ref_biblionumber;
ModOrder ($myorder);

3
serials/routing-preview.pl

@ -66,7 +66,6 @@ my $library;
if($ok){
# get biblio information....
my $biblionumber = $subs->{'bibnum'};
my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblionumber);
my @itemresults = GetItemsInfo( $biblionumber );
my $branch = @itemresults ? $itemresults[0]->{'holdingbranch'} : $subs->{branchcode};
$library = Koha::Libraries->find($branch);
@ -95,7 +94,7 @@ if($ok){
branchcode => $branch
});
} else {
AddReserve($branch,$routing->{borrowernumber},$biblionumber,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title);
AddReserve($branch,$routing->{borrowernumber},$biblionumber,undef,$routing->{ranking}, undef, undef, $notes,$title);
}
}
}

Loading…
Cancel
Save