Glens updates to automatically increment barcode, and to remove hardcoded itemtypes...
[koha.git] / acqui / acquire.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 C4::Database;
9 use C4::Search;
10 use CGI;
11 use strict;
12
13 my $input=new CGI;
14 print $input->header();
15 my $id=$input->param('id');
16
17 print startpage;
18
19 print startmenu('acquisitions');
20
21 my $search=$input->param('recieve');
22 my $invoice=$input->param('invoice');
23 my $freight=$input->param('freight');
24 my $biblio=$input->param('biblio');
25 my $catview=$input->param('catview');
26 my $gst=$input->param('gst');
27 my ($count,@results)=ordersearch($search,$biblio,$catview);
28 my ($count2,@booksellers)=bookseller($results[0]->{'booksellerid'}); 
29 #print $count;
30 my @date=split('-',$results[0]->{'entrydate'});
31 my $date="$date[2]/$date[1]/$date[0]";
32
33 if ($count == 1){
34
35
36 print <<EOP
37
38 <script language="javascript" type="text/javascript">
39 <!--
40 function messenger(X,Y,etc){
41 win=window.open("","mess","height="+X+",width="+Y+",screenX=150,screenY=0");
42 win.focus();
43 win.document.close();
44 win.document.write("<body link='#333333' bgcolor='#ffffff' text='#000000'><font size=2><p><br>");
45 win.document.write(etc);
46 win.document.write("<center><form><input type=button onclick='self.close()' value=Close></form></center>");
47 win.document.write("</font></body></html>");
48 }
49 //-->
50 </script>
51 <form action="/cgi-bin/koha/acqui/finishreceive.pl" method=post>
52 <input type=hidden name=biblio value=$results[0]->{'biblionumber'}>
53 <input type=hidden name=ordnum value=$results[0]->{'ordernumber'}>
54 <input type=hidden name=biblioitemnum value=$results[0]->{'biblioitemnumber'}>
55 <input type=hidden name=bookseller value=$results[0]->{'booksellerid'}>
56 <input type=hidden name=freight value=$freight>
57 <input type=hidden name=gst value=$gst>
58 EOP
59 ;
60 if ($catview ne 'yes'){
61   print "<input type=image  name=submit src=/images/save-changes.gif border=0 width=187 height=42 align=right>";
62 } else {
63   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>";
64 }
65 print <<EOP
66 <FONT SIZE=6><em>$results[0]->{'ordernumber'} - Receive Order</em></FONT><br>
67 Shopping Basket For: $booksellers[0]->{'name'}
68 <br> Order placed: $date
69 <P>
70 <CENTER>
71 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left width="40%">
72 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>CATALOGUE DETAILS</B></td></tr>
73
74 <TR VALIGN=TOP>
75 <TD><b>Title *</b></td>
76 <td><input type=text size=20 name=title value="$results[0]->{'title'}" >
77 </td>
78 </tr>
79 <TR VALIGN=TOP>
80 <TD>Author</td>
81 <td><input type=text size=20 name=author value="$results[0]->{'author'}" >
82 </td>
83 </tr>
84 <TR VALIGN=TOP>
85 <TD>Copyright Date</td>
86 <td><input type=text size=20 name=copyright value="$results[0]->{'copyrightdate'}" >
87 </td>
88 </tr>
89 <TR VALIGN=TOP>
90
91 <TD>Format</td>
92 <td>
93 <select name=format size=1>
94 EOP
95 ;
96
97 my $dbh=C4Connect;
98 my $query="Select itemtype,description from itemtypes order by description";
99 my $sth=$dbh->prepare($query);
100 $sth->execute;
101 while (my $data=$sth->fetchrow_hashref){
102   if ($data->{'itemtype'} eq $results[0]->{'itemtype'}) {
103     print "<option SELECTED value=\"" . $data->{'itemtype'} . "\">" . $data->{'description'} . "\n";
104   } else {
105     print "<option value=\"" . $data->{'itemtype'} . "\">" . $data->{'description'} . "\n";
106   }
107 }
108 $sth->finish;
109 $dbh->disconnect;
110
111 print <<EOP
112 </select>
113
114 </td>
115 </tr>
116
117 <TR VALIGN=TOP>
118
119 <TD>ISBN</td>
120 <td><input type=text size=20 name=ISBN value="$results[0]->{'isbn'}">
121 </td>
122 </tr>
123
124 <TR VALIGN=TOP>
125
126 <TD>Series</td>
127 <td><input type=text size=20 name=Series value="$results[0]->{'seriestitle'}">
128 </td>
129 </tr>
130
131 <TR VALIGN=TOP>
132 <TD>Branch</td>
133 <td><select name=branch size=1>
134 EOP
135 ;
136 my ($count2,@branches)=branches();                                                                         
137 for (my $i=0;$i<$count2;$i++){                                                                           
138   print "<option value=$branches[$i]->{'branchcode'}";                                                   
139   if ($results[0]->{'branchcode'} == $branches[$i]->{'branchcode'}){                                           
140   print " Selected";                                                                                   
141   }                                                                                                      
142   print ">$branches[$i]->{'branchname'}";                                                                
143 }   
144 print <<EOP
145 </select>
146 </td>
147 </tr>
148
149 <TR VALIGN=TOP bgcolor=#ffffcc >
150 <TD><B>Item Barcode *</B></td>
151
152 <td><input type=text size=20 name=barcode value=
153 EOP
154 ;
155
156 my %systemprefs=systemprefs();
157 if ($systemprefs{'autoBarcode'} eq '1') {
158   my $dbh=C4Connect;
159   my $query="Select barcode from items order by barcode desc";
160   my $sth=$dbh->prepare($query);
161   $sth->execute;
162   my $data=$sth->fetchrow_hashref;
163   print $data->{'barcode'}+1;
164   $sth->finish;
165   $dbh->disconnect;
166 }
167
168 print <<EOP
169 >
170 </td>
171 </tr>
172
173 <TR VALIGN=TOP bgcolor=#ffffcc >
174 <TD><B>Volume Info (for serials) *</B></td>
175
176 <td><input type=text size=20 name=volinf>
177 </td>
178 </tr>
179 </table>
180
181
182
183 <img src="/images/holder.gif" width=32 height=250 align=left>
184
185 <table border=1 cellspacing=0 cellpadding=5 width="40%">
186
187 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>ACCOUNTING DETAILS</B></td></tr>
188 <TR VALIGN=TOP>
189 <TD><B>Bookfund *</B></td>
190 <td><select name=bookfund size=1>
191 EOP
192 ;
193 my ($count2,@bookfund)=bookfunds;                                                    
194 for (my $i=0;$i<$count2;$i++){                                                       
195   print "<option value=$bookfund[$i]->{'bookfundid'}";
196   if ($bookfund[$i]->{'bookfundid'}==$results[0]->{'bookfundid'}){
197     print " Selected";
198   }
199   print ">$bookfund[$i]->{'bookfundname'}";
200 }      
201
202 my $rrp=$results[0]->{'rrp'};
203 if ($results[0]->{'quantityreceived'} == 0){
204   $results[0]->{'quantityreceived'}='';
205 }
206 if ($results[0]->{'unitprice'} == 0){
207   $results[0]->{'unitprice'}='';
208 }
209 print <<EOP
210 </select>
211 </td>
212 </tr>
213 <TR VALIGN=TOP>
214 <TD>Quantity Ordered</td>
215 <td><input type=text size=20 name=quantity value=$results[0]->{'quantity'}>
216 </td>
217 </tr>
218 <TR VALIGN=TOP bgcolor=#ffffcc>
219 <TD><B>Quantity Received *</B></td>
220 <td><input type=text size=20 name=quantityrec value=$results[0]->{'quantityreceived'}>
221 </td>
222 </tr>
223 <TR VALIGN=TOP>
224 <TD>Replacement Cost</td>
225 <td><input type=text size=20 name=rrp value=$rrp>
226 </tr>
227 <TR VALIGN=TOP>
228 <TD>
229 Budgeted Cost </td>
230 <td><input type=text size=20 name=ecost value="$results[0]->{'ecost'}">
231 </td>
232 </tr>
233 <TR VALIGN=TOP bgcolor=#ffffcc>
234 <TD><B>Actual Cost *</B></td>
235 <td><input type=text size=20 name=cost value="$results[0]->{'unitprice'}">
236 </td>
237 </tr>
238 <TR VALIGN=TOP bgcolor=#ffffcc>
239 <TD>Invoice Number</td>
240 <td>$invoice
241 <input type=hidden name=invoice value="$invoice">
242 </td>
243 </tr>
244 <TR VALIGN=TOP>
245 <TD>Notes</td>
246 <td><input type=text size=20 name=notes value="$results[0]->{'notes'}">
247 </td>
248 </tr>
249 </table>
250 </form>
251 </center>
252 <br clear=all>          
253 <p> &nbsp; </p>
254
255 EOP
256 ;
257 } else {
258 print "<center><table>";
259 print <<EOP
260 <tr valign=top bgcolor=#99cc33>                                                                
261
262 <td background="/images/background-mem.gif"><b>ISBN</b></td>                                   
263 <td background="/images/background-mem.gif"><b>TITLE</b></td>                                  
264 <td background="/images/background-mem.gif"><b>AUTHOR</b></td>                                 
265 </tr>
266 EOP
267 ;
268 for (my $i=0;$i<$count;$i++){
269   print "<tr><td>$results[$i]->{'isbn'}</td>
270   <td><a href=acquire.pl?recieve=$results[$i]->{'ordernumber'}&biblio=$results[$i]->{'biblionumber'}&invoice=$invoice&freight=$freight&gst=$gst>$results[$i]->{'title'}</a></td>
271   <td>$results[$i]->{'author'}</td></tr>";
272 }
273 print "</table></center>";
274 }
275
276
277
278 print endmenu('acquisitions');
279
280 print endpage;