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