-
-}else{
-## one basket
-$countpendings=1;
-
-my @orders=GetOrders($basketno);
- foreach my $order(@orders){
-$invoice=$order->{booksellerinvoicenumber} unless $invoice;
- $order->{toreceive}=$order->{quantity} - $order->{quantityreceived};
- $totalquantity+=$order->{quantity};
- $totaltoreceive+=$order->{toreceive};
- $totalprice+=$order->{rrp}*$order->{quantity};
- $totaltoprice+=$order->{rrp}*$order->{toreceive};
- $totalgst+=(($order->{rrp}*$order->{quantity}) -($order->{rrp}*$order->{quantity}*$order->{discount}/100))* $order->{gst}/100;
- $totaltogst+=(($order->{rrp}*$order->{toreceive}) -($order->{rrp}*$order->{toreceive}*$order->{discount}/100))* $order->{gst}/100;
- $totaldiscount +=$order->{rrp}*$order->{quantity}*$order->{discount}/100;
- $totaltodiscount +=$order->{rrp}*$order->{toreceive}*$order->{discount}/100;
- $order->{actualrrp}=sprintf( "%.2f",$order->{rrp}/$currencyrate);
- push @loop_orders, $order;
- }
+push @book_foot_loop, map { $_ } values %foot;
+
+my @loop_orders = ();
+if(!defined $invoice->{closedate}) {
+ my $pendingorders;
+ if($input->param('op') eq "search"){
+ my $search = $input->param('summaryfilter') || '';
+ my $ean = $input->param('eanfilter') || '';
+ my $basketno = $input->param('basketfilter') || '';
+ my $orderno = $input->param('orderfilter') || '';
+ my $grouped;
+ my $owner;
+ $pendingorders = GetPendingOrders($booksellerid,$grouped,$owner,$basketno,$orderno,$search,$ean);
+ }else{
+ $pendingorders = GetPendingOrders($booksellerid);
+ }
+ my $countpendings = scalar @$pendingorders;
+
+ for (my $i = 0 ; $i < $countpendings ; $i++) {
+ my %line;
+ %line = %{$pendingorders->[$i]};
+
+ my $ecost = get_value_with_gst_params( $line{ecost}, $line{gstrate}, $bookseller );
+ $line{unitprice} = get_value_with_gst_params( $line{unitprice}, $line{gstrate}, $bookseller );
+ $line{quantity} += 0;
+ $line{quantityreceived} += 0;
+ $line{unitprice}+=0;
+ $line{ecost} = sprintf( "%.2f", $ecost );
+ $line{ordertotal} = sprintf( "%.2f", $ecost * $line{quantity} );
+ $line{unitprice} = sprintf("%.2f",$line{unitprice});
+ $line{invoice} = $invoice;
+ $line{booksellerid} = $booksellerid;
+
+
+
+ my $biblionumber = $line{'biblionumber'};
+ my $countbiblio = CountBiblioInOrders($biblionumber);
+ my $ordernumber = $line{'ordernumber'};
+ my @subscriptions = GetSubscriptionsId ($biblionumber);
+ my $itemcount = GetItemsCount($biblionumber);
+ my $holds = GetHolds ($biblionumber);
+ my @items = GetItemnumbersFromOrder( $ordernumber );
+ my $itemholds;
+ foreach my $item (@items){
+ my $nb = GetItemHolds($biblionumber, $item);
+ if ($nb){
+ $itemholds += $nb;
+ }
+ }
+
+ my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber});
+ $line{suggestionid} = $suggestion->{suggestionid};
+ $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby};
+ $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
+
+ # 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);
+ $line{items} = ($itemcount) - (scalar @items);
+ $line{left_item} = 1 if $line{items} >= 1;
+ $line{left_biblio} = 1 if $countbiblio > 1;
+ $line{biblios} = $countbiblio - 1;
+ $line{left_subscription} = 1 if scalar @subscriptions >= 1;
+ $line{subscriptions} = scalar @subscriptions;
+ $line{left_holds} = ($holds >= 1) ? 1 : 0;
+ $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
+ $line{holds} = $holds;
+ $line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
+
+ my $budget = GetBudget( $line{budget_id} );
+ $line{budget_name} = $budget->{'budget_name'};
+
+ push @loop_orders, \%line;
+ }
+
+ $template->param(
+ loop_orders => \@loop_orders,
+ );