Added a couple of FIXME comments.
[koha.git] / acqui / receive.pl
1 #!/usr/bin/perl
2
3 #script to recieve orders
4 #written by chris@katipo.co.nz 24/2/2000
5
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 use C4::Catalogue;
25 use C4::Biblio;
26 use C4::Output;
27 use CGI;
28 use strict;
29
30 my $input=new CGI;
31 print $input->header();
32 my $id=$input->param('id');
33 my ($count,@booksellers)=bookseller($id);
34 my $invoice=$input->param('invoice');
35 my $freight=$input->param('freight');
36 my $gst=$input->param('gst');
37 my $user=$input->remote_user;
38 my $date=localtime(time);
39 print startpage;
40
41 print startmenu('acquisitions');
42
43 print <<EOP
44
45 <div align=right>
46 Invoice: $invoice<br>
47 Received By: $user<br>
48 $date
49 </div>
50 <FONT SIZE=6><em>Receipt Summary For : <a href=whitcoulls.html>$booksellers[0]->{'name'}</a> </em></FONT>
51 <CENTER>
52
53 <FORM ACTION="/cgi-bin/koha/acqui/acquire.pl">
54 <input type=hidden name=gst value=$gst>
55 <input type=hidden name=freight value=$freight>
56 <input type=hidden name=invoice value=$invoice>
57
58 <b>Search ISBN or Title:</b> <INPUT TYPE="text"  SIZE="25"   NAME="recieve">
59 </form>
60 <p>
61 <FORM ACTION="" method=post name=orderform>
62
63 <table border=0 cellspacing=0 cellpadding=5>
64 <tr valign=top bgcolor=#99cc33>
65 <td background="/images/background-mem.gif"><b>BASKET</b></td>
66 <td background="/images/background-mem.gif"><b>ISBN</b></td>
67 <td background="/images/background-mem.gif"><b>TITLE</b></td>
68 <td background="/images/background-mem.gif"><b>AUTHOR</b></td>
69 <td background="/images/background-mem.gif"><b>ACTUAL</b></td>
70 <td background="/images/background-mem.gif"><b>P&P</b></td>
71 <td background="/images/background-mem.gif"><b>QTY</b></td>
72 <td background="/images/background-mem.gif"><b>TOTAL</b></td></tr>
73
74 EOP
75 ;
76 my @results;
77 ($count,@results)=invoice($invoice);
78 if ($invoice eq ''){
79   ($count,@results)=getallorders($id);
80 }
81 print $count;
82 my $totalprice=0;
83 my $totalfreight=0;
84 my $totalquantity=0;
85 my $total;
86 my $tototal;
87 for (my$i=0;$i<$count;$i++){
88  $total=($results[$i]->{'unitprice'} + $results[$i]->{'freight'}) * $results[$i]->{'quantityreceived'};
89 $results[$i]->{'unitprice'}+=0;
90 print <<EOP
91 <tr valign=top bgcolor=#ffffcc>
92 <td>$results[$i]->{'basketno'}</td>
93 <td>$results[$i]->{'isbn'}</td>
94 <td><a href="acquire.pl?recieve=$results[$i]->{'ordernumber'}&biblio=$results[$i]->{'biblionumber'}&invoice=$invoice&gst=$gst&freight=$freight">$results[$i]->{'title'}</a></td>
95 <td>$results[$i]->{'author'}</td>
96 <td>\$$results[$i]->{'unitprice'}</td>
97 <td></td>
98 <td>$results[$i]->{'quantityreceived'}</td>
99 <td>\$ $total</td>
100 </tr>
101 EOP
102 ;
103 $totalprice+=$results[$i]->{'unitprice'};
104 $totalfreight+=$results[$i]->{'freight'};
105 $totalquantity+=$results[$i]->{'quantityreceived'};
106 $tototal+=$total;
107 }
108 $totalfreight=$freight;
109 $tototal=$tototal+$freight;
110
111 my $grandtot=$tototal+$gst;
112 print <<EOP
113 <tr valign=top bgcolor=white>
114 <td colspan=8><hr>
115 </td></tr>
116
117
118
119 <tr valign=top bgcolor=white>
120 <td></td>
121 <td></td>
122 <td></td>
123 <td><b>SUBTOTALS</b></td>
124 <td>\$$totalprice</td>
125 <td>$totalfreight</td>
126 <td>$totalquantity</td>
127 <td>\$$tototal</td>
128 </tr>
129 <tr valign=top bgcolor=white>
130 <td colspan=5 rowspan=2  bgcolor=#99cc33 background="/images/background-mem.gif">
131 <b>HELP</b>
132 <br>
133 The total at the bottom of the page should be within a few cents of the total for the invoice.<p>
134 When you have finished this invoice save the changes.
135 </td>                                                                                                                                                                                                                                           
136 <td colspan=2 align=right><b>GST</b></td>
137 <td>\$$gst</td>
138 </tr>
139 <tr valign=top bgcolor=white>
140 <td colspan=2 align=right ><b>TOTAL</b></td>
141 <td>\$$grandtot</td>
142 </tr>
143 <tr valign=top bgcolor=white>
144 <td></td>
145 <td></td>
146 <td></td>
147 <td></td>
148 <td></td>
149 <td></td>
150 <td colspan=3><input type=image  name=submit src=/images/save-changes.gif border=0 width=187 height=42 align=right></td>
151 </tr>
152 </table>
153 </CENTER>
154 EOP
155 ;
156
157
158 print endmenu('acquisitions');
159
160 print endpage;