| Lines 42-49
          To know the supplier this script has to show orders.
      
      
        Link Here | 
        
          | 42 |  | 42 |  | 
        
          | 43 | is the bookseller invoice number. | 43 | is the bookseller invoice number. | 
        
          | 44 |  | 44 |  | 
            
              | 45 | =item freight |  |  | 
            
              | 46 |  | 
        
          | 47 |  | 45 |  | 
        
          | 48 | =item gst | 46 | =item gst | 
        
          | 49 |  | 47 |  | 
  
    | Lines 57-63
          To filter the results list on this given date.
      
      
        Link Here | 
        
          | 57 | =cut | 55 | =cut | 
        
          | 58 |  | 56 |  | 
        
          | 59 | use strict; | 57 | use strict; | 
          
            
              | 60 | #use warnings; FIXME - Bug 2505 | 58 | use warnings; | 
            
              |  |  | 59 |  | 
        
          | 61 | use C4::Auth; | 60 | use C4::Auth; | 
        
          | 62 | use C4::Acquisition; | 61 | use C4::Acquisition; | 
        
          | 63 | use C4::Budgets; | 62 | use C4::Budgets; | 
  
    | Lines 71-86
          use C4::Suggestions;
      
      
        Link Here | 
        
          | 71 | use JSON; | 70 | use JSON; | 
        
          | 72 |  | 71 |  | 
        
          | 73 | my $input=new CGI; | 72 | my $input=new CGI; | 
          
            
              | 74 | my $booksellerid=$input->param('booksellerid'); | 73 |  | 
            
              | 75 | my $bookseller=GetBookSellerFromId($booksellerid); | 74 | my $invoiceid = $input->param('invoiceid'); | 
            
              | 76 |  | 75 | my $invoice = GetInvoiceDetails($invoiceid); | 
            
              | 77 | my $invoice=$input->param('invoice') || ''; | 76 | my $booksellerid = $invoice->{booksellerid}; | 
            
              | 78 | my $freight=$input->param('freight'); | 77 | my $bookseller = GetBookSellerFromId($booksellerid); | 
            
              | 79 | my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst')); | 78 | my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; | 
            
              | 80 | my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0; | 79 | my $datereceived = C4::Dates->new(); | 
            
              | 81 | my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived'))  |  |  | 
            
              | 82 | 					:  C4::Dates->new($input->param('datereceived'), 'iso')   ; | 
            
              | 83 | $datereceived = C4::Dates->new() unless $datereceived; | 
        
          | 84 | my $code            = $input->param('code'); | 80 | my $code            = $input->param('code'); | 
        
          | 85 | my @rcv_err         = $input->param('error'); | 81 | my @rcv_err         = $input->param('error'); | 
        
          | 86 | my @rcv_err_barcode = $input->param('error_bc'); | 82 | my @rcv_err_barcode = $input->param('error_bc'); | 
  
    | Lines 90-105
          my $resultsperpage = $input->param('resultsperpage');
      
      
        Link Here | 
        
          | 90 | $resultsperpage = 20 unless ($resultsperpage); | 86 | $resultsperpage = 20 unless ($resultsperpage); | 
        
          | 91 | $startfrom=0 unless ($startfrom); | 87 | $startfrom=0 unless ($startfrom); | 
        
          | 92 |  | 88 |  | 
          
            
              | 93 | if($input->param('format') eq "json"){ | 89 | my $format = $input->param('format') || ''; | 
            
              |  |  | 90 | if($format eq "json"){ | 
        
          | 94 |     my ($template, $loggedinuser, $cookie) | 91 |     my ($template, $loggedinuser, $cookie) | 
        
          | 95 |         = get_template_and_user({template_name => "acqui/ajax.tmpl", | 92 |         = get_template_and_user({template_name => "acqui/ajax.tmpl", | 
        
          | 96 |                  query => $input, | 93 |                  query => $input, | 
          
            
              | 97 | 				 type => "intranet", | 94 |                  type => "intranet", | 
        
          | 98 |                  authnotrequired => 0, | 95 |                  authnotrequired => 0, | 
        
          | 99 |                  flagsrequired => {acquisition => 'order_receive'}, | 96 |                  flagsrequired => {acquisition => 'order_receive'}, | 
        
          | 100 |                  debug => 1, | 97 |                  debug => 1, | 
        
          | 101 |     }); | 98 |     }); | 
          
            
              | 102 |         | 99 |  | 
        
          | 103 |     my @datas; | 100 |     my @datas; | 
        
          | 104 |     my $search   = $input->param('search') || ''; | 101 |     my $search   = $input->param('search') || ''; | 
        
          | 105 |     my $supplier = $input->param('booksellerid') || ''; | 102 |     my $supplier = $input->param('booksellerid') || ''; | 
  
    | Lines 110-116
          if($input->param('format') eq "json"){
      
      
        Link Here | 
        
          | 110 |     foreach my $order (@$orders){ | 107 |     foreach my $order (@$orders){ | 
        
          | 111 |         if($order->{quantityreceived} < $order->{quantity}){ | 108 |         if($order->{quantityreceived} < $order->{quantity}){ | 
        
          | 112 |             my $data = {}; | 109 |             my $data = {}; | 
          
            
              | 113 |              | 110 |  | 
        
          | 114 |             $data->{basketno} = $order->{basketno}; | 111 |             $data->{basketno} = $order->{basketno}; | 
        
          | 115 |             $data->{ordernumber} = $order->{ordernumber}; | 112 |             $data->{ordernumber} = $order->{ordernumber}; | 
        
          | 116 |             $data->{title} = $order->{title}; | 113 |             $data->{title} = $order->{title}; | 
  
    | Lines 118-131
          if($input->param('format') eq "json"){
      
      
        Link Here | 
        
          | 118 |             $data->{isbn} = $order->{isbn}; | 115 |             $data->{isbn} = $order->{isbn}; | 
        
          | 119 |             $data->{booksellerid} = $order->{booksellerid}; | 116 |             $data->{booksellerid} = $order->{booksellerid}; | 
        
          | 120 |             $data->{biblionumber} = $order->{biblionumber}; | 117 |             $data->{biblionumber} = $order->{biblionumber}; | 
            
              | 121 |             $data->{freight} = $order->{freight}; |  |  | 
        
          | 122 |             $data->{quantity} = $order->{quantity}; | 118 |             $data->{quantity} = $order->{quantity}; | 
        
          | 123 |             $data->{ecost} = $order->{ecost}; | 119 |             $data->{ecost} = $order->{ecost}; | 
        
          | 124 |             $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity}); | 120 |             $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity}); | 
        
          | 125 |             push @datas, $data; | 121 |             push @datas, $data; | 
        
          | 126 |         } | 122 |         } | 
        
          | 127 |     } | 123 |     } | 
          
            
              | 128 |      | 124 |  | 
        
          | 129 |     my $json_text = to_json(\@datas); | 125 |     my $json_text = to_json(\@datas); | 
        
          | 130 |     $template->param(return => $json_text); | 126 |     $template->param(return => $json_text); | 
        
          | 131 |     output_html_with_http_headers $input, $cookie, $template->output; | 127 |     output_html_with_http_headers $input, $cookie, $template->output; | 
  
    | Lines 135-141
          if($input->param('format') eq "json"){
      
      
        Link Here | 
        
          | 135 | my ($template, $loggedinuser, $cookie) | 131 | my ($template, $loggedinuser, $cookie) | 
        
          | 136 |     = get_template_and_user({template_name => "acqui/parcel.tmpl", | 132 |     = get_template_and_user({template_name => "acqui/parcel.tmpl", | 
        
          | 137 |                  query => $input, | 133 |                  query => $input, | 
          
            
              | 138 | 				 type => "intranet", | 134 |                  type => "intranet", | 
        
          | 139 |                  authnotrequired => 0, | 135 |                  authnotrequired => 0, | 
        
          | 140 |                  flagsrequired => {acquisition => 'order_receive'}, | 136 |                  flagsrequired => {acquisition => 'order_receive'}, | 
        
          | 141 |                  debug => 1, | 137 |                  debug => 1, | 
  
    | Lines 155-164
          if( scalar(@rcv_err) ) {
      
      
        Link Here | 
        
          | 155 | } | 151 | } | 
        
          | 156 |  | 152 |  | 
        
          | 157 | my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table. | 153 | my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table. | 
          
            
              | 158 | my @parcelitems   = GetParcel($booksellerid, $invoice, $datereceived->output('iso')); | 154 | my @parcelitems   = @{ $invoice->{orders} }; | 
        
          | 159 | my $countlines    = scalar @parcelitems; | 155 | my $countlines    = scalar @parcelitems; | 
        
          | 160 | my $totalprice    = 0; | 156 | my $totalprice    = 0; | 
            
              | 161 | my $totalfreight  = 0; |  |  | 
        
          | 162 | my $totalquantity = 0; | 157 | my $totalquantity = 0; | 
        
          | 163 | my $total; | 158 | my $total; | 
        
          | 164 | my $tototal; | 159 | my $tototal; | 
  
    | Lines 166-180
          my @loop_received = ();
      
      
        Link Here | 
        
          | 166 |  | 161 |  | 
        
          | 167 | for (my $i = 0 ; $i < $countlines ; $i++) { | 162 | for (my $i = 0 ; $i < $countlines ; $i++) { | 
        
          | 168 |  | 163 |  | 
          
            
              | 169 |     #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre) | 164 |     $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'}; | 
            
              | 170 |     $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre) |  |  | 
        
          | 171 |     $parcelitems[$i]->{'unitprice'} += 0; | 165 |     $parcelitems[$i]->{'unitprice'} += 0; | 
        
          | 172 |     my %line; | 166 |     my %line; | 
        
          | 173 |     %line          = %{ $parcelitems[$i] }; | 167 |     %line          = %{ $parcelitems[$i] }; | 
          
            
              | 174 |     $line{invoice} = $invoice; | 168 |     $line{invoice} = $invoice->{invoicenumber}; | 
        
          | 175 |     $line{gst}     = $gst; | 169 |     $line{gst}     = $gst; | 
        
          | 176 |     $line{total} = sprintf($cfstr, $total); | 170 |     $line{total} = sprintf($cfstr, $total); | 
          
            
              | 177 |     $line{booksellerid} = $booksellerid; | 171 |     $line{booksellerid} = $invoice->{booksellerid}; | 
        
          | 178 |     push @loop_received, \%line; | 172 |     push @loop_received, \%line; | 
        
          | 179 |     $totalprice += $parcelitems[$i]->{'unitprice'}; | 173 |     $totalprice += $parcelitems[$i]->{'unitprice'}; | 
        
          | 180 |     $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); | 174 |     $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); | 
  
    | Lines 184-327
          for (my $i = 0 ; $i < $countlines ; $i++) {
      
      
        Link Here | 
        
          | 184 |     $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby}; | 178 |     $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby}; | 
        
          | 185 |     $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; | 179 |     $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; | 
        
          | 186 |  | 180 |  | 
            
              | 187 |     #double FIXME - totalfreight is redefined later. |  |  | 
            
              | 188 |  | 
            
              | 189 | # FIXME - each order in a  parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget.. | 
            
              | 190 |     if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) { | 
            
              | 191 |         warn "FREIGHT CHARGE MISMATCH!!"; | 
            
              | 192 |     } | 
            
              | 193 |     $totalfreight = $parcelitems[$i]->{'freight'}; | 
        
          | 194 |     $totalquantity += $parcelitems[$i]->{'quantityreceived'}; | 181 |     $totalquantity += $parcelitems[$i]->{'quantityreceived'}; | 
        
          | 195 |     $tototal       += $total; | 182 |     $tototal       += $total; | 
        
          | 196 | } | 183 | } | 
        
          | 197 |  | 184 |  | 
          
            
              | 198 | my $pendingorders = GetPendingOrders($booksellerid); | 185 | if(!defined $invoice->{closedate}) { | 
            
              | 199 | my $countpendings = scalar @$pendingorders; | 186 |     my $pendingorders = GetPendingOrders($booksellerid); | 
            
              | 200 |  | 187 |     my $countpendings = scalar @$pendingorders; | 
            
              | 201 | # pending orders totals | 188 |  | 
            
              | 202 | my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); | 189 |     # pending orders totals | 
            
              | 203 | my $ordergrandtotal; | 190 |     my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); | 
            
              | 204 | my @loop_orders = (); | 191 |     my $ordergrandtotal; | 
            
              | 205 | for (my $i = 0 ; $i < $countpendings ; $i++) { | 192 |     my @loop_orders = (); | 
            
              | 206 |     my %line; | 193 |     for (my $i = 0 ; $i < $countpendings ; $i++) { | 
            
              | 207 |     %line = %{$pendingorders->[$i]}; | 194 |         my %line; | 
            
              | 208 |     | 195 |         %line = %{$pendingorders->[$i]}; | 
            
              | 209 |     $line{quantity}+=0; | 196 |  | 
            
              | 210 |     $line{quantityreceived}+=0; | 197 |         $line{quantity}+=0; | 
            
              | 211 |     $line{unitprice}+=0; | 198 |         $line{quantityreceived}+=0; | 
            
              | 212 |     $totalPunitprice += $line{unitprice}; | 199 |         $line{unitprice}+=0; | 
            
              | 213 |     $totalPquantity +=$line{quantity}; | 200 |         $totalPunitprice += $line{unitprice}; | 
            
              | 214 |     $totalPqtyrcvd +=$line{quantityreceived}; | 201 |         $totalPquantity +=$line{quantity}; | 
            
              | 215 |     $totalPecost += $line{ecost}; | 202 |         $totalPqtyrcvd +=$line{quantityreceived}; | 
            
              | 216 |     $line{ecost} = sprintf("%.2f",$line{ecost}); | 203 |         $totalPecost += $line{ecost}; | 
            
              | 217 |     $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); | 204 |         $line{ecost} = sprintf("%.2f",$line{ecost}); | 
            
              | 218 |     $line{unitprice} = sprintf("%.2f",$line{unitprice}); | 205 |         $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); | 
            
              | 219 |     $line{invoice} = $invoice; | 206 |         $line{unitprice} = sprintf("%.2f",$line{unitprice}); | 
            
              | 220 |     $line{gst} = $gst; | 207 |         $line{invoice} = $invoice; | 
            
              | 221 |     $line{total} = $total; | 208 |         $line{gst} = $gst; | 
            
              | 222 |     $line{booksellerid} = $booksellerid; | 209 |         $line{total} = $total; | 
            
              | 223 |     $ordergrandtotal += $line{ecost} * $line{quantity}; | 210 |         $line{booksellerid} = $booksellerid; | 
            
              | 224 |      | 211 |         $ordergrandtotal += $line{ecost} * $line{quantity}; | 
            
              | 225 |     my $biblionumber = $line{'biblionumber'}; | 212 |  | 
            
              | 226 |     my $countbiblio = CountBiblioInOrders($biblionumber); | 213 |         my $biblionumber = $line{'biblionumber'}; | 
            
              | 227 |     my $ordernumber = $line{'ordernumber'}; | 214 |         my $countbiblio = CountBiblioInOrders($biblionumber); | 
            
              | 228 |     my @subscriptions = GetSubscriptionsId ($biblionumber); | 215 |         my $ordernumber = $line{'ordernumber'}; | 
            
              | 229 |     my $itemcount = GetItemsCount($biblionumber); | 216 |         my @subscriptions = GetSubscriptionsId ($biblionumber); | 
            
              | 230 |     my $holds  = GetHolds ($biblionumber); | 217 |         my $itemcount = GetItemsCount($biblionumber); | 
            
              | 231 |     my @items = GetItemnumbersFromOrder( $ordernumber ); | 218 |         my $holds  = GetHolds ($biblionumber); | 
            
              | 232 |     my $itemholds; | 219 |         my @items = GetItemnumbersFromOrder( $ordernumber ); | 
            
              | 233 |     foreach my $item (@items){ | 220 |         my $itemholds; | 
            
              | 234 |         my $nb = GetItemHolds($biblionumber, $item); | 221 |         foreach my $item (@items){ | 
            
              | 235 |         if ($nb){ | 222 |             my $nb = GetItemHolds($biblionumber, $item); | 
            
              | 236 |             $itemholds += $nb; | 223 |             if ($nb){ | 
            
              |  |  | 224 |                 $itemholds += $nb; | 
            
              | 225 |             } | 
        
          | 237 |         } | 226 |         } | 
            
              | 238 |     } |  |  | 
        
          | 239 |  | 227 |  | 
          
            
              | 240 |     my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber}); | 228 |         my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber}); | 
            
              | 241 |     $line{suggestionid}         = $suggestion->{suggestionid}; | 229 |         $line{suggestionid}         = $suggestion->{suggestionid}; | 
            
              | 242 |     $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby}; | 230 |         $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby}; | 
            
              | 243 |     $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; | 231 |         $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; | 
            
              |  |  | 232 |  | 
            
              | 233 |         # 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 | 
            
              | 234 |         $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); | 
            
              | 235 |         $line{items}                = ($itemcount) - (scalar @items); | 
            
              | 236 |         $line{left_item}            = 1 if $line{items} >= 1; | 
            
              | 237 |         $line{left_biblio}          = 1 if $countbiblio > 1; | 
            
              | 238 |         $line{biblios}              = $countbiblio - 1; | 
            
              | 239 |         $line{left_subscription}    = 1 if scalar @subscriptions >= 1; | 
            
              | 240 |         $line{subscriptions}        = scalar @subscriptions; | 
            
              | 241 |         $line{left_holds}           = ($holds >= 1) ? 1 : 0; | 
            
              | 242 |         $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); | 
            
              | 243 |         $line{holds}                = $holds; | 
            
              | 244 |         $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; | 
            
              | 245 |          | 
            
              | 246 |          | 
            
              | 247 |         push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); | 
            
              | 248 |     } | 
        
          | 244 |  | 249 |  | 
          
            
              | 245 |     # 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 | 250 |     my $count = $countpendings; | 
            
              | 246 |     $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); |  |  | 
            
              | 247 |     $line{items}                = ($itemcount) - (scalar @items); | 
            
              | 248 |     $line{left_item}            = 1 if $line{items} >= 1; | 
            
              | 249 |     $line{left_biblio}          = 1 if $countbiblio > 1; | 
            
              | 250 |     $line{biblios}              = $countbiblio - 1; | 
            
              | 251 |     $line{left_subscription}    = 1 if scalar @subscriptions >= 1; | 
            
              | 252 |     $line{subscriptions}        = scalar @subscriptions; | 
            
              | 253 |     $line{left_holds}           = 1 if $holds >= 1; | 
            
              | 254 |     $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); | 
            
              | 255 |     $line{holds}                = $holds; | 
            
              | 256 |     $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; | 
            
              | 257 |      | 
            
              | 258 |      | 
            
              | 259 |     push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); | 
            
              | 260 | } | 
            
              | 261 | $freight = $totalfreight unless $freight; | 
        
          | 262 |  | 251 |  | 
          
            
              | 263 | my $count = $countpendings; | 252 |     if ($count>$resultsperpage){ | 
            
              |  |  | 253 |         my $displaynext=0; | 
            
              | 254 |         my $displayprev=$startfrom; | 
            
              | 255 |         if(($count - ($startfrom+$resultsperpage)) > 0 ) { | 
            
              | 256 |             $displaynext = 1; | 
            
              | 257 |         } | 
        
          | 264 |  | 258 |  | 
          
            
              | 265 | if ($count>$resultsperpage){ | 259 |         my @numbers = (); | 
            
              | 266 |     my $displaynext=0; | 260 |         for (my $i=1; $i<$count/$resultsperpage+1; $i++) { | 
            
              | 267 |     my $displayprev=$startfrom; | 261 |                 my $highlight=0; | 
            
              | 268 |     if(($count - ($startfrom+$resultsperpage)) > 0 ) { | 262 |                 ($startfrom/$resultsperpage==($i-1)) && ($highlight=1); | 
            
              | 269 |         $displaynext = 1; | 263 |                 push @numbers, { number => $i, | 
            
              | 270 |     } | 264 |                     highlight => $highlight , | 
            
              |  |  | 265 |                     startfrom => ($i-1)*$resultsperpage}; | 
            
              | 266 |         } | 
        
          | 271 |  | 267 |  | 
          
            
              | 272 |     my @numbers = (); | 268 |         my $from = $startfrom*$resultsperpage+1; | 
            
              | 273 |     for (my $i=1; $i<$count/$resultsperpage+1; $i++) { | 269 |         my $to; | 
            
              | 274 |             my $highlight=0; | 270 |         if($count < (($startfrom+1)*$resultsperpage)){ | 
            
              | 275 |             ($startfrom/$resultsperpage==($i-1)) && ($highlight=1); | 271 |             $to = $count; | 
            
              | 276 |             push @numbers, { number => $i, | 272 |         } else { | 
            
              | 277 |                 highlight => $highlight , | 273 |             $to = (($startfrom+1)*$resultsperpage); | 
            
              | 278 |                 startfrom => ($i-1)*$resultsperpage}; | 274 |         } | 
            
              |  |  | 275 |         $template->param(numbers=>\@numbers, | 
            
              | 276 |                          displaynext=>$displaynext, | 
            
              | 277 |                          displayprev=>$displayprev, | 
            
              | 278 |                          nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), | 
            
              | 279 |                          prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) | 
            
              | 280 |                         ); | 
        
          | 279 |     } | 281 |     } | 
        
          | 280 |  | 282 |  | 
          
            
              | 281 |     my $from = $startfrom*$resultsperpage+1; | 283 |     $template->param( | 
            
              | 282 |     my $to; | 284 |         countpending => $countpendings, | 
            
              | 283 |     if($count < (($startfrom+1)*$resultsperpage)){ | 285 |         loop_orders  => \@loop_orders, | 
            
              | 284 |         $to = $count; | 286 |         ordergrandtotal => sprintf($cfstr, $ordergrandtotal), | 
            
              | 285 |     } else { | 287 |         totalPunitprice => sprintf("%.2f", $totalPunitprice), | 
            
              | 286 |         $to = (($startfrom+1)*$resultsperpage); | 288 |         totalPquantity  => $totalPquantity, | 
            
              | 287 |     } | 289 |         totalPqtyrcvd   => $totalPqtyrcvd, | 
            
              | 288 |     $template->param(numbers=>\@numbers, | 290 |         totalPecost     => sprintf("%.2f", $totalPecost), | 
            
              | 289 |                      displaynext=>$displaynext, | 291 |     ); | 
            
              | 290 |                      displayprev=>$displayprev, |  |  | 
            
              | 291 |                      nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), | 
            
              | 292 |                      prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) | 
            
              | 293 |                     ); | 
        
          | 294 | } | 292 | } | 
        
          | 295 |  | 293 |  | 
            
              | 296 | #$totalfreight=$freight; |  |  | 
            
              | 297 | $tototal = $tototal + $freight; | 
        
          | 298 |  | 294 |  | 
        
          | 299 | $template->param( | 295 | $template->param( | 
          
            
              | 300 |     invoice               => $invoice, | 296 |     invoiceid             => $invoice->{invoiceid}, | 
            
              |  |  | 297 |     invoice               => $invoice->{invoicenumber}, | 
            
              | 298 |     invoiceclosedate      => $invoice->{closedate}, | 
        
          | 301 |     datereceived          => $datereceived->output('iso'), | 299 |     datereceived          => $datereceived->output('iso'), | 
        
          | 302 |     invoicedatereceived   => $datereceived->output('iso'), | 300 |     invoicedatereceived   => $datereceived->output('iso'), | 
        
          | 303 |     formatteddatereceived => $datereceived->output(), | 301 |     formatteddatereceived => $datereceived->output(), | 
        
          | 304 |     name                  => $bookseller->{'name'}, | 302 |     name                  => $bookseller->{'name'}, | 
          
            
              | 305 |     booksellerid            => $booksellerid, | 303 |     booksellerid          => $bookseller->{id}, | 
        
          | 306 |     gst                   => $gst, | 304 |     gst                   => $gst, | 
            
              | 307 |     freight               => $freight, |  |  | 
            
              | 308 |     invoice               => $invoice, | 
        
          | 309 |     countreceived         => $countlines, | 305 |     countreceived         => $countlines, | 
        
          | 310 |     loop_received         => \@loop_received, | 306 |     loop_received         => \@loop_received, | 
            
              | 311 |     countpending          => $countpendings, |  |  | 
            
              | 312 |     loop_orders           => \@loop_orders, | 
        
          | 313 |     totalprice            => sprintf($cfstr, $totalprice), | 307 |     totalprice            => sprintf($cfstr, $totalprice), | 
            
              | 314 |     totalfreight          => $totalfreight, |  |  | 
        
          | 315 |     totalquantity         => $totalquantity, | 308 |     totalquantity         => $totalquantity, | 
        
          | 316 |     tototal               => sprintf($cfstr, $tototal), | 309 |     tototal               => sprintf($cfstr, $tototal), | 
            
              | 317 |     ordergrandtotal       => sprintf($cfstr, $ordergrandtotal), |  |  | 
        
          | 318 |     gst                   => $gst, | 310 |     gst                   => $gst, | 
        
          | 319 |     grandtot              => sprintf($cfstr, $tototal + $gst), | 311 |     grandtot              => sprintf($cfstr, $tototal + $gst), | 
            
              | 320 |     totalPunitprice       => sprintf("%.2f", $totalPunitprice), |  |  | 
            
              | 321 |     totalPquantity        => $totalPquantity, | 
            
              | 322 |     totalPqtyrcvd         => $totalPqtyrcvd, | 
            
              | 323 |     totalPecost           => sprintf("%.2f", $totalPecost), | 
        
          | 324 |     resultsperpage        => $resultsperpage, | 312 |     resultsperpage        => $resultsperpage, | 
        
          | 325 | ); | 313 | ); | 
        
          | 326 | output_html_with_http_headers $input, $cookie, $template->output; | 314 | output_html_with_http_headers $input, $cookie, $template->output; | 
            
              | 327 |   |  |  |