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 my @loop_orders = ();
123 for (my $i=0;$i<$countpendings;$i++){
126 $line{color}='#EEEEEE';
129 $line{color}='white';
132 %line = %{$pendingorders->[$i]};
133 $line{ecost} = sprintf("%.2f",$line{ecost});
134 $line{unitprice} = sprintf("%.2f",$line{unitprice});
135 $line{invoice} = $invoice;
137 $line{total} = $total;
138 $line{supplierid} = $supplierid;
139 push @loop_orders, \%line;
142 $totalfreight=$freight;
143 $tototal=$tototal+$freight;
145 $template->param(invoice => $invoice,
146 datereceived => $datereceived,
147 formatteddatereceived => format_date($datereceived),
148 name => $booksellers[0]->{'name'},
149 supplierid => $supplierid,
153 countreceived => $countlines,
154 loop_received => \@loop_received,
155 countpending => $countpendings,
156 loop_orders => \@loop_orders,
157 totalprice => $totalprice,
158 totalfreight => $totalfreight,
159 totalquantity => $totalquantity,
162 grandtot => $tototal+$gst,
163 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
164 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
165 IntranetNav => C4::Context->preference("IntranetNav"),
167 output_html_with_http_headers $input, $cookie, $template->output;