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