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.
64 use C4::Interface::CGI::Output;
70 my $supplierid=$input->param('supplierid');
71 my @booksellers=GetBookSeller($supplierid);
72 my $count = scalar @booksellers;
74 my $invoice=$input->param('invoice') || '';
75 my $freight=$input->param('freight');
76 my $gst=$input->param('gst');
77 my $datereceived=$input->param('datereceived') || format_date(join "-",Date::Calc::Today());
78 my $code=$input->param('code');
80 my ($template, $loggedinuser, $cookie)
81 = get_template_and_user({template_name => "acqui/parcel.tmpl",
85 flagsrequired => {acquisition => 1},
88 my @parcelitems=GetParcel($supplierid,$invoice,$datereceived);
89 my $countlines = scalar @parcelitems;
97 my @loop_received = ();
98 for (my $i=0;$i<$countlines;$i++){
99 $total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre)
100 $parcelitems[$i]->{'unitprice'}+=0;
103 $line{color}='#EEEEEE';
106 $line{color}='white';
109 %line = %{$parcelitems[$i]};
110 $line{invoice} = $invoice;
112 $line{total} = $total;
113 $line{supplierid} = $supplierid;
114 push @loop_received, \%line;
115 $totalprice+=$parcelitems[$i]->{'unitprice'};
116 $totalfreight+=$parcelitems[$i]->{'freight'};
117 $totalquantity+=$parcelitems[$i]->{'quantityreceived'};
120 my $pendingorders = GetPendingOrders($supplierid);
121 my $countpendings = scalar @$pendingorders;
123 my @loop_orders = ();
124 for (my $i=0;$i<$countpendings;$i++){
127 $line{color}='#EEEEEE';
130 $line{color}='white';
133 %line = %{$pendingorders->[$i]};
134 $line{ecost} = sprintf("%.2f",$line{ecost});
135 $line{unitprice} = sprintf("%.2f",$line{unitprice});
136 $line{invoice} = $invoice;
138 $line{total} = $total;
139 $line{supplierid} = $supplierid;
140 push @loop_orders, \%line;
143 $totalfreight=$freight;
144 $tototal=$tototal+$freight;
146 $template->param(invoice => $invoice,
147 datereceived => $datereceived,
148 formatteddatereceived => format_date($datereceived),
149 name => $booksellers[0]->{'name'},
150 supplierid => $supplierid,
154 countreceived => $countlines,
155 loop_received => \@loop_received,
156 countpending => $countpendings,
157 loop_orders => \@loop_orders,
158 totalprice => $totalprice,
159 totalfreight => $totalfreight,
160 totalquantity => $totalquantity,
163 grandtot => $tototal+$gst,
164 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
165 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
166 IntranetNav => C4::Context->preference("IntranetNav"),
168 output_html_with_http_headers $input, $cookie, $template->output;