Glens updates to automatically increment barcode, and to remove hardcoded itemtypes...
[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 ($count,@results)=invoice($invoice);
58 if ($invoice eq ''){
59   ($count,@results)=getallorders($id);
60 }
61 print $count;
62 my $totalprice=0;
63 my $totalfreight=0;
64 my $totalquantity=0;
65 my $total;
66 my $tototal;
67 for (my$i=0;$i<$count;$i++){
68  $total=($results[$i]->{'unitprice'} + $results[$i]->{'freight'}) * $results[$i]->{'quantityreceived'};
69 $results[$i]->{'unitprice'}+=0;
70 print <<EOP
71 <tr valign=top bgcolor=#ffffcc>
72 <td>$results[$i]->{'basketno'}</td>
73 <td>$results[$i]->{'isbn'}</td>
74 <td><a href="acquire.pl?recieve=$results[$i]->{'ordernumber'}&biblio=$results[$i]->{'biblionumber'}&invoice=$invoice&gst=$gst&freight=$freight">$results[$i]->{'title'}</a></td>
75 <td>$results[$i]->{'author'}</td>
76 <td>\$$results[$i]->{'unitprice'}</td>
77 <td></td>
78 <td>$results[$i]->{'quantityreceived'}</td>
79 <td>\$ $total</td>
80 </tr>
81 EOP
82 ;
83 $totalprice+=$results[$i]->{'unitprice'};
84 $totalfreight+=$results[$i]->{'freight'};
85 $totalquantity+=$results[$i]->{'quantityreceived'};
86 $tototal+=$total;
87 }
88 $totalfreight=$freight;
89 $tototal=$tototal+$freight;
90
91 my $grandtot=$tototal+$gst;
92 print <<EOP
93 <tr valign=top bgcolor=white>
94 <td colspan=8><hr>
95 </td></tr>
96
97
98
99 <tr valign=top bgcolor=white>
100 <td></td>
101 <td></td>
102 <td></td>
103 <td><b>SUBTOTALS</b></td>
104 <td>\$$totalprice</td>
105 <td>$totalfreight</td>
106 <td>$totalquantity</td>
107 <td>\$$tototal</td>
108 </tr>
109 <tr valign=top bgcolor=white>
110 <td colspan=5 rowspan=2  bgcolor=#99cc33 background="/images/background-mem.gif">
111 <b>HELP</b>
112 <br>
113 The total at the bottom of the page should be within a few cents of the total for the invoice.<p>
114 When you have finished this invoice save the changes.
115 </td>                                                                                                                                                                                                                                           
116 <td colspan=2 align=right><b>GST</b></td>
117 <td>\$$gst</td>
118 </tr>
119 <tr valign=top bgcolor=white>
120 <td colspan=2 align=right ><b>TOTAL</b></td>
121 <td>\$$grandtot</td>
122 </tr>
123 <tr valign=top bgcolor=white>
124 <td></td>
125 <td></td>
126 <td></td>
127 <td></td>
128 <td></td>
129 <td></td>
130 <td colspan=3><input type=image  name=submit src=/images/save-changes.gif border=0 width=187 height=42 align=right></td>
131 </tr>
132 </table>
133 </CENTER>
134 EOP
135 ;
136
137
138 print endmenu('acquisitions');
139
140 print endpage;