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