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