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