Bug 5549 : Daily loans should be due at 23:59
[koha.git] / acqui / parcel.pl
index c256c60..5d0d164 100755 (executable)
@@ -34,7 +34,7 @@ It allows to write an order as 'received' when he arrives.
 
 =over 4
 
-=item supplierid
+=item booksellerid
 
 To know the supplier this script has to show orders.
 
@@ -67,11 +67,12 @@ use C4::Items;
 use CGI;
 use C4::Output;
 use C4::Dates qw/format_date format_date_in_iso/;
+use C4::Suggestions;
 use JSON;
 
 my $input=new CGI;
-my $supplierid=$input->param('supplierid');
-my $bookseller=GetBookSellerFromId($supplierid);
+my $booksellerid=$input->param('booksellerid');
+my $bookseller=GetBookSellerFromId($booksellerid);
 
 my $invoice=$input->param('invoice') || '';
 my $freight=$input->param('freight');
@@ -101,7 +102,7 @@ if($input->param('format') eq "json"){
        
     my @datas;
     my $search   = $input->param('search') || '';
-    my $supplier = $input->param('supplierid') || '';
+    my $supplier = $input->param('booksellerid') || '';
     my $basketno = $input->param('basketno') || '';
     my $orderno  = $input->param('orderno') || '';
 
@@ -154,7 +155,7 @@ if( scalar(@rcv_err) ) {
 }
 
 my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
-my @parcelitems   = GetParcel($supplierid, $invoice, $datereceived->output('iso'));
+my @parcelitems   = GetParcel($booksellerid, $invoice, $datereceived->output('iso'));
 my $countlines    = scalar @parcelitems;
 my $totalprice    = 0;
 my $totalfreight  = 0;
@@ -173,11 +174,16 @@ for (my $i = 0 ; $i < $countlines ; $i++) {
     $line{invoice} = $invoice;
     $line{gst}     = $gst;
     $line{total} = sprintf($cfstr, $total);
-    $line{supplierid} = $supplierid;
+    $line{booksellerid} = $booksellerid;
     push @loop_received, \%line;
     $totalprice += $parcelitems[$i]->{'unitprice'};
     $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
 
+    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
+    $line{suggestionid}         = $suggestion->{suggestionid};
+    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
+    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
+
     #double FIXME - totalfreight is redefined later.
 
 # 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..
@@ -189,7 +195,7 @@ for (my $i = 0 ; $i < $countlines ; $i++) {
     $tototal       += $total;
 }
 
-my $pendingorders = GetPendingOrders($supplierid);
+my $pendingorders = GetPendingOrders($booksellerid);
 my $countpendings = scalar @$pendingorders;
 
 # pending orders totals
@@ -213,7 +219,7 @@ for (my $i = 0 ; $i < $countpendings ; $i++) {
     $line{invoice} = $invoice;
     $line{gst} = $gst;
     $line{total} = $total;
-    $line{supplierid} = $supplierid;
+    $line{booksellerid} = $booksellerid;
     $ordergrandtotal += $line{ecost} * $line{quantity};
     
     my $biblionumber = $line{'biblionumber'};
@@ -230,7 +236,12 @@ for (my $i = 0 ; $i < $countpendings ; $i++) {
             $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);
@@ -291,7 +302,7 @@ $template->param(
     invoicedatereceived   => $datereceived->output('iso'),
     formatteddatereceived => $datereceived->output(),
     name                  => $bookseller->{'name'},
-    supplierid            => $supplierid,
+    booksellerid            => $booksellerid,
     gst                   => $gst,
     freight               => $freight,
     invoice               => $invoice,