From f31993d126ed97fdc80605931f41ed29b1dac5d1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 15 Jan 2020 16:28:00 -0300 Subject: [PATCH] Bug 24430: Remove CountBiblioInOrders and its traces This patch replaces the only uses of CountBiblioInOrders and makes that code use $biblio->orders->count instead. Test nothing breaks in basket.pl and parcel.pl Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- C4/Biblio.pm | 21 --------------------- acqui/basket.pl | 5 +++-- acqui/parcel.pl | 2 +- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index ce0d4fbdb6..c07313ab33 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -54,7 +54,6 @@ BEGIN { TransformKohaToMarc PrepHostMarcField CountItemsIssued - CountBiblioInOrders ModBiblio ModZebra UpdateTotalIssues @@ -3180,26 +3179,6 @@ sub ModBiblioMarc { return $biblionumber; } -=head2 CountBiblioInOrders - - $count = &CountBiblioInOrders( $biblionumber); - -This function return count of biblios in orders with $biblionumber - -=cut - -sub CountBiblioInOrders { - my ($biblionumber) = @_; - my $dbh = C4::Context->dbh; - my $query = "SELECT count(*) - FROM aqorders - WHERE biblionumber=? AND datecancellationprinted IS NULL"; - my $sth = $dbh->prepare($query); - $sth->execute($biblionumber); - my $count = $sth->fetchrow; - return ($count); -} - =head2 prepare_host_field $marcfield = prepare_host_field( $hostbiblioitem, $marcflavour ); diff --git a/acqui/basket.pl b/acqui/basket.pl index 0c8b5eac6c..65ed547452 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -136,7 +136,7 @@ if ( $op eq 'delete_confirm' ) { foreach my $myorder (@orders){ my $biblionumber = $myorder->{'biblionumber'}; my $biblio = Koha::Biblios->find( $biblionumber ); - my $countbiblio = CountBiblioInOrders($biblionumber); + my $countbiblio = $biblio->active_orders_count; my $ordernumber = $myorder->{'ordernumber'}; my $cnt_subscriptions = $biblio->subscriptions->count; my $itemcount = $biblio->items->count; @@ -477,7 +477,8 @@ sub get_order_infos { my $biblionumber = $order->{'biblionumber'}; if ( $biblionumber ) { # The biblio still exists my $biblio = Koha::Biblios->find( $biblionumber ); - my $countbiblio = CountBiblioInOrders($biblionumber); + my $countbiblio = $biblio->active_orders_count; + my $ordernumber = $order->{'ordernumber'}; my $cnt_subscriptions = $biblio->subscriptions->count; my $itemcount = $biblio->items->count; diff --git a/acqui/parcel.pl b/acqui/parcel.pl index 9c16c9ccfe..8139cabfb9 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -241,7 +241,7 @@ unless( defined $invoice->{closedate} ) { my $biblionumber = $line{'biblionumber'}; my $biblio = Koha::Biblios->find( $biblionumber ); - my $countbiblio = CountBiblioInOrders($biblionumber); + my $countbiblio = $biblio->active_orders_count; my $ordernumber = $line{'ordernumber'}; my $order_object = Koha::Acquisition::Orders->find($ordernumber); my $cnt_subscriptions = $biblio ? $biblio->subscriptions->count: 0; -- 2.39.5