@@ -, +, @@ --- C4/Acquisition.pm | 19 +++---------------- acqui/histsearch.pl | 7 ++----- catalogue/detail.pl | 2 +- t/db_dependent/Acquisition.t | 4 ++-- 4 files changed, 8 insertions(+), 24 deletions(-) --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -2246,7 +2246,7 @@ sub GetLateOrders { =head3 GetHistory - (\@order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( %params ); + \@order_loop = GetHistory( %params ); Retreives some acquisition history information @@ -2286,9 +2286,6 @@ returns: 'quantityreceived' => undef, 'title' => 'The Adventures of Huckleberry Finn' } - $total_qty is the sum of all of the quantities in $order_loop - $total_price is the cost of each in $order_loop times the quantity - $total_qtyreceived is the sum of all of the quantityreceived entries in $order_loop =cut @@ -2457,18 +2454,8 @@ sub GetHistory { } } $query .= " ORDER BY id"; - my $sth = $dbh->prepare($query); - $sth->execute( @query_params ); - my $cnt = 1; - while ( my $line = $sth->fetchrow_hashref ) { - $line->{count} = $cnt++; - $line->{toggle} = 1 if $cnt % 2; - push @order_loop, $line; - $total_qty += ( $line->{quantity} ) ? $line->{quantity} : 0; - $total_qtyreceived += ( $line->{quantityreceived} ) ? $line->{quantityreceived} : 0; - $total_price += ( $line->{quantity} and $line->{ecost} ) ? $line->{quantity} * $line->{ecost} : 0; - } - return \@order_loop, $total_qty, $total_price, $total_qtyreceived; + + return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params ); } =head2 GetRecentAcqui --- a/acqui/histsearch.pl +++ a/acqui/histsearch.pl @@ -103,10 +103,10 @@ if ( $d = $input->param('iso') ) { $to_iso = C4::Dates->new($d)->output('iso'); } -my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ); +my $order_loop; # If we're supplied any value then we do a search. Otherwise we don't. if ($do_search) { - ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = GetHistory( + $order_loop = GetHistory( title => $title, author => $author, isbn => $isbn, @@ -139,9 +139,6 @@ for my $bp ( @{$budgetperiods} ) { $template->param( order_loop => $order_loop, - total_qty => $total_qty, - total_qtyreceived => $total_qtyreceived, - total_price => sprintf( "%.2f", $total_price ), numresults => $order_loop ? scalar(@$order_loop) : undef, title => $title, author => $author, --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -168,7 +168,7 @@ foreach my $subscription (@subscriptions) { # Get acquisition details if ( C4::Context->preference('AcquisitionDetails') ) { - my ( $orders, $qty, $price, $received ) = C4::Acquisition::GetHistory( biblionumber => $biblionumber, get_canceled_order => 1 ); + my $orders = C4::Acquisition::GetHistory( biblionumber => $biblionumber, get_canceled_order => 1 ); $template->param( orders => $orders, ); --- a/t/db_dependent/Acquisition.t +++ a/t/db_dependent/Acquisition.t @@ -820,9 +820,9 @@ is( $neworder->{'budget_id'}, $budgetid, 'Budget on new order is unchanged' ); is( $neworder->{ordernumber}, $new_ordernumber, 'Split: test ordernumber' ); is( $neworder->{parent_ordernumber}, $ordernumbers[1], 'Split: test parent_ordernumber' ); -my ( $orders ) = GetHistory( ordernumber => $ordernumbers[1] ); +my $orders = GetHistory( ordernumber => $ordernumbers[1] ); is( scalar( @$orders ), 1, 'GetHistory with a given ordernumber returns 1 order' ); -( $orders ) = GetHistory( ordernumber => $ordernumbers[1], search_children_too => 1 ); +$orders = GetHistory( ordernumber => $ordernumbers[1], search_children_too => 1 ); is( scalar( @$orders ), 2, 'GetHistory with a given ordernumber and search_children_too set returns 2 orders' ); my $budgetid2 = C4::Budgets::AddBudget( --