@@ -, +, @@ acqui --- C4/Items.pm | 22 ---------------------- acqui/basket.pl | 9 ++------- acqui/parcel.pl | 8 +------- 3 files changed, 3 insertions(+), 36 deletions(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -92,7 +92,6 @@ BEGIN { ShelfToCart GetAnalyticsCount - GetItemHolds SearchItemsByField SearchItems @@ -2556,27 +2555,6 @@ sub GetAnalyticsCount { return ($result); } -=head2 GetItemHolds - - $holds = &GetItemHolds($biblionumber, $itemnumber); - -This function return the count of holds with $biblionumber and $itemnumber - -=cut - -sub GetItemHolds { - my ($biblionumber, $itemnumber) = @_; - my $holds; - my $dbh = C4::Context->dbh; - my $query = "SELECT count(*) - FROM reserves - WHERE biblionumber=? AND itemnumber=?"; - my $sth = $dbh->prepare($query); - $sth->execute($biblionumber, $itemnumber); - $holds = $sth->fetchrow; - return $holds; -} - =head2 SearchItemsByField my $items = SearchItemsByField($field, $value); --- a/acqui/basket.pl +++ a/acqui/basket.pl @@ -465,13 +465,8 @@ sub get_order_infos { my $itemcount = GetItemsCount($biblionumber); my $holds_count = $biblio ? $biblio->holds->count : 0; my @items = GetItemnumbersFromOrder( $ordernumber ); - my $itemholds; - foreach my $item (@items){ - my $nb = GetItemHolds($biblionumber, $item); - if ($nb){ - $itemholds += $nb; - } - } + my $itemholds = $biblio ? $biblio->holds->search({ itemnumber => { -in => \@items } })->count : 0; + # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680 $line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds_count); $line{items} = ($itemcount) - (scalar @items); --- a/acqui/parcel.pl +++ a/acqui/parcel.pl @@ -245,13 +245,7 @@ unless( defined $invoice->{closedate} ) { my $itemcount = GetItemsCount($biblionumber); my $holds_count = $biblio ? $biblio->holds->count : 0; my @items = GetItemnumbersFromOrder( $ordernumber ); - my $itemholds; - foreach my $item (@items){ - my $nb = GetItemHolds($biblionumber, $item); - if ($nb){ - $itemholds += $nb; - } - } + my $itemholds = $biblio ? $biblio->holds->search({ itemnumber => { -in => \@items } })->count : 0; my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); $line{suggestionid} = $suggestion->{suggestionid}; --