5 #script to recieve orders
6 #written by chris@katipo.co.nz 24/2/2000
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
32 This script shows all orders receipt or pending for a given supplier.
33 It allows to write an order as 'received' when he arrives.
40 To know the supplier this script has to show orders.
43 is the bookseller invoice number.
52 To filter the results list on this given date.
69 my $supplierid=$input->param('supplierid');
70 my @booksellers=GetBookSeller($supplierid);
71 my $count = scalar @booksellers;
73 my $invoice=$input->param('invoice') || '';
74 my $freight=$input->param('freight');
75 my $gst=$input->param('gst');
76 my $datereceived=format_date_in_iso($input->param('datereceived')) || format_date(join "-",Date::Calc::Today());
77 my $code=$input->param('code');
79 my ($template, $loggedinuser, $cookie)
80 = get_template_and_user({template_name => "acqui/parcel.tmpl",
84 flagsrequired => {acquisition => 1},
87 my @parcelitems=GetParcel($supplierid,$invoice,$datereceived);
88 my $countlines = scalar @parcelitems;
96 my @loop_received = ();
97 for (my $i=0;$i<$countlines;$i++){
98 $total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre)
99 $parcelitems[$i]->{'unitprice'}+=0;
102 $line{color}='#EEEEEE';
105 $line{color}='white';
108 %line = %{$parcelitems[$i]};
109 $line{invoice} = $invoice;
111 $line{total} = $total;
112 $line{supplierid} = $supplierid;
113 push @loop_received, \%line;
114 $totalprice+=$parcelitems[$i]->{'unitprice'};
115 $totalfreight+=$parcelitems[$i]->{'freight'};
116 $totalquantity+=$parcelitems[$i]->{'quantityreceived'};
119 my $pendingorders = GetPendingOrders($supplierid);
120 my $countpendings = scalar @$pendingorders;
122 # pending orders totals
123 my ($totalPunitprice,$totalPquantity,$totalPecost);
125 my @loop_orders = ();
126 for (my $i=0;$i<$countpendings;$i++){
129 $line{color}='#EEEEEE';
132 $line{color}='white';
135 %line = %{$pendingorders->[$i]};
136 $totalPunitprice += $line{unitprice};
137 $totalPquantity +=$line{quantity};
138 $totalPecost += $line{ecost};
139 $line{ecost} = sprintf("%.2f",$line{ecost});
140 $line{unitprice} = sprintf("%.2f",$line{unitprice});
141 $line{invoice} = $invoice;
143 $line{total} = $total;
144 $line{supplierid} = $supplierid;
145 push @loop_orders, \%line;
148 $totalfreight=$freight;
149 $tototal=$tototal+$freight;
151 $template->param(invoice => $invoice,
152 datereceived => $datereceived,
153 formatteddatereceived => format_date($datereceived),
154 name => $booksellers[0]->{'name'},
155 supplierid => $supplierid,
159 countreceived => $countlines,
160 loop_received => \@loop_received,
161 countpending => $countpendings,
162 loop_orders => \@loop_orders,
163 totalprice => $totalprice,
164 totalfreight => $totalfreight,
165 totalquantity => $totalquantity,
168 grandtot => $tototal+$gst,
169 totalPunitprice => sprintf("%.2f",$totalPunitprice),
170 totalPquantity => $totalPquantity,
171 totalPecost => sprintf("%.2f",$totalPecost),
173 output_html_with_http_headers $input, $cookie, $template->output;