commiting forgotten changes before releasing 1.3.2
[koha.git] / acqui / acquire.pl
blob969f49719f46354e67359fa618abed5d43713721
1 #!/usr/bin/perl
3 # $Id$
5 #script to recieve orders
6 #written by chris@katipo.co.nz 24/2/2000
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
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.
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.
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
26 use strict;
27 use CGI;
28 use C4::Context;
29 use C4::Catalogue;
30 use C4::Biblio;
31 use C4::Output;
32 use C4::Search;
34 my $input=new CGI;
35 print $input->header();
36 my $id=$input->param('id');
38 print startpage;
40 print startmenu('acquisitions');
42 my $search=$input->param('recieve');
43 my $invoice=$input->param('invoice');
44 my $freight=$input->param('freight');
45 my $biblio=$input->param('biblio');
46 my $catview=$input->param('catview');
47 my $gst=$input->param('gst');
48 my ($count,@results)=ordersearch($search,$biblio,$catview);
49 my ($count2,@booksellers)=bookseller($results[0]->{'booksellerid'});
50 #print $count;
51 my @date=split('-',$results[0]->{'entrydate'});
52 my $date="$date[2]/$date[1]/$date[0]";
54 if ($count == 1){
57 print <<EOP
59 <script language="javascript" type="text/javascript">
60 <!--
61 function messenger(X,Y,etc){
62 win=window.open("","mess","height="+X+",width="+Y+",screenX=150,screenY=0");
63 win.focus();
64 win.document.close();
65 win.document.write("<body link='#333333' bgcolor='#ffffff' text='#000000'><font size=2><p><br>");
66 win.document.write(etc);
67 win.document.write("<center><form><input type=button onclick='self.close()' value=Close></form></center>");
68 win.document.write("</font></body></html>");
70 //-->
71 </script>
72 <form action="/cgi-bin/koha/acqui/finishreceive.pl" method=post>
73 <input type=hidden name=biblio value=$results[0]->{'biblionumber'}>
74 <input type=hidden name=ordnum value=$results[0]->{'ordernumber'}>
75 <input type=hidden name=biblioitemnum value=$results[0]->{'biblioitemnumber'}>
76 <input type=hidden name=bookseller value=$results[0]->{'booksellerid'}>
77 <input type=hidden name=freight value=$freight>
78 <input type=hidden name=gst value=$gst>
79 EOP
81 if ($catview ne 'yes'){
82 print "<input type=image name=submit src=/images/save-changes.gif border=0 width=187 height=42 align=right>";
83 } else {
84 print "<a href=/cgi-bin/koha/acqui/newbiblio.pl?ordnum=$results[0]->{'ordernumber'}&id=$results[0]->{'booksellerid'}><img src=/images/modify-mem.gif align=right border=0></a>";
86 print <<EOP
87 <FONT SIZE=6><em>$results[0]->{'ordernumber'} - Receive Order</em></FONT><br>
88 Shopping Basket For: $booksellers[0]->{'name'}
89 <br> Order placed: $date
90 <P>
91 <CENTER>
92 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 align=left width="40%">
93 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>CATALOGUE DETAILS</B></td></tr>
95 <TR VALIGN=TOP>
96 <TD><b>Title *</b></td>
97 <td><input type=text size=20 name=title value="$results[0]->{'title'}" >
98 </td>
99 </tr>
100 <TR VALIGN=TOP>
101 <TD>Author</td>
102 <td><input type=text size=20 name=author value="$results[0]->{'author'}" >
103 </td>
104 </tr>
105 <TR VALIGN=TOP>
106 <TD>Copyright Date</td>
107 <td><input type=text size=20 name=copyright value="$results[0]->{'copyrightdate'}" >
108 </td>
109 </tr>
110 <TR VALIGN=TOP>
112 <TD>Format</td>
113 <td>
114 <select name=format size=1>
118 my $dbh = C4::Context->dbh;
119 my $query="Select itemtype,description from itemtypes order by description";
120 my $sth=$dbh->prepare($query);
121 $sth->execute;
122 while (my $data=$sth->fetchrow_hashref){
123 if ($data->{'itemtype'} eq $results[0]->{'itemtype'}) {
124 print "<option SELECTED value=\"" . $data->{'itemtype'} . "\">" . $data->{'description'} . "\n";
125 } else {
126 print "<option value=\"" . $data->{'itemtype'} . "\">" . $data->{'description'} . "\n";
129 $sth->finish;
131 print <<EOP
132 </select>
134 </td>
135 </tr>
137 <TR VALIGN=TOP>
139 <TD>ISBN</td>
140 <td><input type=text size=20 name=ISBN value="$results[0]->{'isbn'}">
141 </td>
142 </tr>
144 <TR VALIGN=TOP>
146 <TD>Series</td>
147 <td><input type=text size=20 name=Series value="$results[0]->{'seriestitle'}">
148 </td>
149 </tr>
151 <TR VALIGN=TOP>
152 <TD>Branch</td>
153 <td><select name=branch size=1>
156 my ($count2,@branches)=branches();
157 for (my $i=0;$i<$count2;$i++){
158 print "<option value=$branches[$i]->{'branchcode'}";
159 if ($results[0]->{'branchcode'} == $branches[$i]->{'branchcode'}){
160 print " Selected";
162 print ">$branches[$i]->{'branchname'}";
164 print <<EOP
165 </select>
166 </td>
167 </tr>
169 <TR VALIGN=TOP bgcolor=#ffffcc >
170 <TD><B>Item Barcode *</B></td>
172 <td><input type=text size=20 name=barcode value=
176 my $auto_barcode = C4::Context->preference("autoBarcode") || 0;
177 # See whether barcodes should be automatically allocated.
178 # Defaults to 0, meaning "no".
179 if ($auto_barcode eq '1') {
180 my $dbh = C4::Context->dbh;
181 my $query="Select barcode from items order by barcode desc";
182 my $sth=$dbh->prepare($query);
183 $sth->execute;
184 my $data=$sth->fetchrow_hashref;
185 print $data->{'barcode'}+1;
186 $sth->finish;
189 print <<EOP
191 </td>
192 </tr>
194 <TR VALIGN=TOP bgcolor=#ffffcc >
195 <TD><B>Volume Info (for serials) *</B></td>
197 <td><input type=text size=20 name=volinf>
198 </td>
199 </tr>
200 </table>
204 <img src="/images/holder.gif" width=32 height=250 align=left>
206 <table border=1 cellspacing=0 cellpadding=5 width="40%">
208 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>ACCOUNTING DETAILS</B></td></tr>
209 <TR VALIGN=TOP>
210 <TD><B>Bookfund *</B></td>
211 <td><select name=bookfund size=1>
214 my @bookfund;
215 ($count2,@bookfund)=bookfunds();
216 for (my $i=0;$i<$count2;$i++){
217 print "<option value=$bookfund[$i]->{'bookfundid'}";
218 if ($bookfund[$i]->{'bookfundid'}==$results[0]->{'bookfundid'}){
219 print " Selected";
221 print ">$bookfund[$i]->{'bookfundname'}";
224 my $rrp=$results[0]->{'rrp'};
225 if ($results[0]->{'quantityreceived'} == 0){
226 $results[0]->{'quantityreceived'}='';
228 if ($results[0]->{'unitprice'} == 0){
229 $results[0]->{'unitprice'}='';
231 print <<EOP
232 </select>
233 </td>
234 </tr>
235 <TR VALIGN=TOP>
236 <TD>Quantity Ordered</td>
237 <td><input type=text size=20 name=quantity value=$results[0]->{'quantity'}>
238 </td>
239 </tr>
240 <TR VALIGN=TOP bgcolor=#ffffcc>
241 <TD><B>Quantity Received *</B></td>
242 <td><input type=text size=20 name=quantityrec value=$results[0]->{'quantityreceived'}>
243 </td>
244 </tr>
245 <TR VALIGN=TOP>
246 <TD>Replacement Cost</td>
247 <td><input type=text size=20 name=rrp value=$rrp>
248 </tr>
249 <TR VALIGN=TOP>
250 <TD>
251 Budgeted Cost </td>
252 <td><input type=text size=20 name=ecost value="$results[0]->{'ecost'}">
253 </td>
254 </tr>
255 <TR VALIGN=TOP bgcolor=#ffffcc>
256 <TD><B>Actual Cost *</B></td>
257 <td><input type=text size=20 name=cost value="$results[0]->{'unitprice'}">
258 </td>
259 </tr>
260 <TR VALIGN=TOP bgcolor=#ffffcc>
261 <TD>Invoice Number</td>
262 <td>$invoice
263 <input type=hidden name=invoice value="$invoice">
264 </td>
265 </tr>
266 <TR VALIGN=TOP>
267 <TD>Notes</td>
268 <td><input type=text size=20 name=notes value="$results[0]->{'notes'}">
269 </td>
270 </tr>
271 </table>
272 </form>
273 </center>
274 <br clear=all>
275 <p> &nbsp; </p>
279 } else {
280 print "<center><table>";
281 print <<EOP
282 <tr valign=top bgcolor=#99cc33>
284 <td background="/images/background-mem.gif"><b>ISBN</b></td>
285 <td background="/images/background-mem.gif"><b>TITLE</b></td>
286 <td background="/images/background-mem.gif"><b>AUTHOR</b></td>
287 </tr>
290 for (my $i=0;$i<$count;$i++){
291 print "<tr><td>$results[$i]->{'isbn'}</td>
292 <td><a href=acquire.pl?recieve=$results[$i]->{'ordernumber'}&biblio=$results[$i]->{'biblionumber'}&invoice=$invoice&freight=$freight&gst=$gst>$results[$i]->{'title'}</a></td>
293 <td>$results[$i]->{'author'}</td></tr>";
295 print "</table></center>";
300 print endmenu('acquisitions');
302 print endpage;