From 7ba5e5811eeb701fbc7d41aa48b9c16a77864d6e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 13 Mar 2017 13:04:01 -0300 Subject: [PATCH] Bug 18255: WIP --- C4/Biblio.pm | 24 ------------------------ C4/ILSDI/Services.pm | 8 ++++++-- C4/SIP/ILS/Transaction/Hold.pm | 4 ++-- catalogue/itemsearch.pl | 2 +- cataloguing/merge.pl | 2 -- 5 files changed, 9 insertions(+), 31 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index ef2e432..82205fa 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -67,7 +67,6 @@ BEGIN { GetMarcBiblio GetBiblioItemData GetBiblioItemInfosOf - GetBiblioItemByBiblioNumber GetBiblioFromItemNumber GetBiblionumberFromItemnumber @@ -809,29 +808,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 GetBiblionumberFromItemnumber diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index b735d38..0271da9 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -35,6 +35,7 @@ use DateTime; use C4::Auth; use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::Biblioitems; use Koha::Libraries; =head1 NAME @@ -204,9 +205,12 @@ 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 $biblioitem = Koha::Biblioitems->search( { biblionumber => $biblionumber } )->next; + if ( $biblioitem ) { + $biblioitem = $biblioitem->unblessed; + } else { $biblioitem->{code} = "RecordNotFound"; + # FIXME We should not need to process something else; next? } my $embed_items = 1; diff --git a/C4/SIP/ILS/Transaction/Hold.pm b/C4/SIP/ILS/Transaction/Hold.pm index da3ad83..926d42d 100644 --- a/C4/SIP/ILS/Transaction/Hold.pm +++ b/C4/SIP/ILS/Transaction/Hold.pm @@ -10,7 +10,7 @@ use C4::SIP::ILS::Transaction; use C4::Reserves; # AddReserve use C4::Members; # GetMember -use C4::Biblio; # GetBiblioFromItemNumber GetBiblioItemByBiblioNumber +use C4::Biblio; # GetBiblioFromItemNumber use parent qw(C4::SIP::ILS::Transaction); @@ -62,7 +62,7 @@ sub do_hold { return $self; } my $bibno = $bib->{biblionumber}; - AddReserve( $branch, $borrower->{borrowernumber}, $bibno, GetBiblioItemByBiblioNumber($bibno) ); + AddReserve( $branch, $borrower->{borrowernumber}, $bibno ); # unfortunately no meaningful return value $self->ok(1); diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index fa6b357..7547fc7 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -213,7 +213,7 @@ if (scalar keys %params > 0) { foreach my $item (@$results) { $item->{biblio} = GetBiblio($item->{biblionumber}); - ($item->{biblioitem}) = GetBiblioItemByBiblioNumber($item->{biblionumber}); + $item->{biblioitem} = Koha::Biblioitems->find( $item->{biblioitemnumber} )->unblessed; $item->{status} = $notforloan_map->{$item->{notforloan}}; if (defined $item->{location}) { $item->{location} = $location_map->{$item->{location}}; diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl index ee9f1fa..89403ba 100755 --- a/cataloguing/merge.pl +++ b/cataloguing/merge.pl @@ -158,8 +158,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); -- 2.9.3