Tidying up more warnings.
[koha.git] / acqui / newbiblio.pl
1 #!/usr/bin/perl
2
3 #script to show display basket of orders
4 #written by chris@katipo.co.nz 24/2/2000
5
6 use C4::Acquisitions;
7 use C4::Output;
8 use C4::Search;
9 use C4::Database;
10 use CGI;
11 use strict;
12
13 my $input=new CGI;
14 print $input->header();
15 my $id=$input->param('id');
16 my $title=$input->param('title');
17 my $author=$input->param('author');
18 my $copyright=$input->param('copyright');
19 my ($count,@booksellers)=bookseller($id);
20 my $ordnum=$input->param('ordnum');
21 my $biblio=$input->param('biblio');
22 my $data;
23 my $new;
24 if ($ordnum eq ''){
25   $new='yes';
26   $ordnum=newordernum;
27   $data=bibdata($biblio);
28   if ($data->{'title'} eq ''){
29     $data->{'title'}=$title;
30     $data->{'author'}=$author;
31     $data->{'copyrightdate'}=$copyright;
32   }
33 }else {
34   $data=getsingleorder($ordnum);
35   $biblio=$data->{'biblionumber'};
36
37
38 print startpage;
39
40 print startmenu('acquisitions');
41
42
43 my $basket=$input->param('basket');
44 print <<printend
45
46
47 <script language="javascript" type="text/javascript">
48
49 <!--
50
51 function update(f){
52   //collect values
53   quantity=f.quantity.value
54   discount=f.discount.value
55   listinc=parseInt(f.listinc.value)
56   currency=f.currency.value
57   applygst=parseInt(f.applygst.value)
58   listprice=f.list_price.value
59   //  rrp=f.rrp.value
60   //  ecost=f.ecost.value  //budgetted cost
61   //  GST=f.GST.value
62   //  total=f.total.value  
63   //make useful constants out of the above  
64   exchangerate=f.elements[currency].value      //get exchange rate  
65   gst_on=(!listinc && applygst);
66   //do real stuff  
67   rrp=listprice*exchangerate;
68   ecost=rrp*(100-discount)/100
69   GST=0;
70   if (gst_on){
71     rrp=rrp*1.125;
72     GST=ecost*0.125
73   }
74   
75   total=(ecost+GST)*quantity
76   
77   
78   f.rrp.value=display(rrp)
79   f.ecost.value=display(ecost)
80   f.GST.value=display(GST)
81   f.total.value=display(total)
82   
83 }
84                                                                       
85
86
87 function messenger(X,Y,etc){
88 win=window.open("","mess","height="+X+",width="+Y+",screenX=150,screenY=0");
89 win.focus();
90 win.document.close();
91 win.document.write("<body link='#333333' bgcolor='#ffffff' text='#000000'><font size=2><p><br>");
92 win.document.write(etc);
93 win.document.write("<center><form><input type=button onclick='self.close()' value=Close></form></center>");
94 win.document.write("</font></body></html>");
95 }
96 //-->
97
98 </script>
99 <form action=/cgi-bin/koha/acqui/addorder.pl method=post name=frusin>
100 printend
101 ;
102
103 if ($biblio eq ''){
104   print "<input type=hidden name=existing value=no>";
105 }
106
107 print <<printend
108 <!--$title-->
109 <input type=hidden name=ordnum value=$ordnum>
110 <input type=hidden name=basket value=$basket>
111 <input type=hidden name=supplier value=$id>
112 <input type=hidden name=biblio value=$biblio>
113 <input type=hidden name=bibitemnum value=$data->{'biblioitemnumber'}>
114 <input type=hidden name=oldtype value=$data->{'itemtype'}>
115 <input type=hidden name=discount value=$booksellers[0]->{'discount'}>
116 <input type=hidden name=listinc value=$booksellers[0]->{'listincgst'}>
117 <input type=hidden name=currency value=$booksellers[0]->{'listprice'}>
118 <input type=hidden name=applygst value=$booksellers[0]->{'gstreg'}>
119 printend
120 ;
121 my ($count2,$currencies)=getcurrencies;
122 for (my $i=0;$i<$count2;$i++){
123   print "<input type=hidden name=\"$currencies->[$i]->{'currency'}\" value=$currencies->[0]->{'rate'}>\n";
124 }
125 if ($new ne 'yes'){
126   print "<input type=hidden name=orderexists value=yes>\n";
127 }
128 print <<printend
129 <a href=basket.pl?basket=$basket><img src=/images/view-basket.gif width=187 heigth=42 border=0 align=right alt="View Basket"></a> 
130 <FONT SIZE=6><em>$ordnum - Order Details </em></FONT><br>
131 Shopping Basket For: $booksellers[0]->{'name'}
132 <P>
133 <CENTER>
134 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left width="40%">
135 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>CATALOGUE DETAILS</B></td></tr>
136 <TR VALIGN=TOP>
137 <TD><b>Title *</b></td>
138 <td><input type=text size=20 name=title value="$data->{'title'}">
139 </td>
140 </tr>
141 <TR VALIGN=TOP>
142 <TD>Author</td>
143 <td><input type=text size=20 name=author value="$data->{'author'}" >
144 </td>
145 </tr>
146 <TR VALIGN=TOP>
147 <TD>Copyright Date</td>
148 <td><input type=text size=20 name=copyright value="$data->{'copyrightdate'}">
149 </td>
150 </tr>
151 <TR VALIGN=TOP>
152 <TD>Format</td>
153 <td>
154 <select name=format size=1>
155 printend
156 ;
157
158 my $dbh=C4Connect;
159 my $query="Select itemtype,description from itemtypes order by description";
160 my $sth=$dbh->prepare($query);
161 $sth->execute;
162 print "<option value=\"\">Please choose:\n";
163 while (my $data=$sth->fetchrow_hashref){
164   print "<option value=\"" . $data->{'itemtype'} . "\">" . $data->{'description'} . "\n";
165 }
166 $sth->finish;
167 $dbh->disconnect;
168
169 print <<printend
170 </select>
171
172
173 </td>
174 </tr>
175 <TR VALIGN=TOP>
176 <TD>ISBN</td>
177 <td><input type=text size=20 name=ISBN value=$data->{'isbn'}>
178 </td>
179 </tr>
180 <TR VALIGN=TOP>
181 <TD>Series</td>
182 <td><input type=text size=20 name=Series value="$data->{'seriestitle'}">
183 </td>
184 </tr>
185 <TR VALIGN=TOP>
186 <TD>Branch</td>
187 <td><select name=branch size=1>
188 printend
189 ;
190 my @branches;
191 ($count2,@branches)=branches();
192 for (my $i=0;$i<$count2;$i++){
193   print "<option value=$branches[$i]->{'branchcode'}";
194   if ($data->{'branchcode'} == $branches[$i]->{'branchcode'}){
195     print " Selected";
196   }
197   print ">$branches[$i]->{'branchname'}";
198 }
199
200 print <<printend
201 </select>
202 </td>
203 </tr>
204 <TR VALIGN=TOP  bgcolor=#ffffcc>
205 <TD >Item Barcode</td>
206 <td><input type=text size=20 name=barcode value=
207 printend
208 ;
209
210 my %systemprefs=systemprefs();
211 if ($systemprefs{'autoBarcode'} eq '1') {
212   my $dbh=C4Connect;
213   my $query="Select barcode from items order by barcode desc";
214   my $sth=$dbh->prepare($query);
215   $sth->execute;
216   my $data=$sth->fetchrow_hashref;
217   print $data->{'barcode'}+1;
218   $sth->finish;
219   $dbh->disconnect;
220 }
221
222 print <<printend
223 >
224 </td>
225 </tr>
226 </table>
227 <img src="/images/holder.gif" width=32 height=250 align=left>
228 <table border=1 cellspacing=0 cellpadding=5 width="40%">
229 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>ACCOUNTING DETAILS</B></td></tr>
230 <TR VALIGN=TOP>
231 <TD>Quantity</td>
232 <td><input type=text size=20 name=quantity value="$data->{'quantity'}" onchange='update(this.form)' >
233 </td>
234 </tr>
235 <TR VALIGN=TOP>
236 <TD>Bookfund</td>
237 <td><select name=bookfund size=1>
238 printend
239 ;
240 my @bookfund;
241 ($count2,@bookfund)=bookfunds();
242 for (my $i=0;$i<$count2;$i++){
243   print "<option value=$bookfund[$i]->{'bookfundid'}";
244   if ($data->{'bookfundid'} == $bookfund[$i]->{'bookfundid'}){
245     print " Selected";
246   }
247   print ">$bookfund[$i]->{'bookfundname'}";
248 }
249
250 print <<printend
251 </select>
252 </td>
253 </tr>
254 <TR VALIGN=TOP>
255 <TD>Suppliers List Price</td>
256 <td><input type=text size=20 name=list_price value="$data->{'listprice'}" onchange='update(this.form)'>
257 </tr>
258 <TR VALIGN=TOP>
259 <TD>Replacement Cost <br>
260 <FONT SIZE=2>(NZ\$ inc GST)</td>
261 <td><input type=text size=20 name=rrp value="$data->{'rrp'}" onchange='update(this.form)'>
262 </tr>
263 <TR VALIGN=TOP>
264 <TD>
265 Budgeted Cost<BR>
266 <FONT SIZE=2>(NZ\$ ex GST, inc discount)</FONT> </td>
267 <td><input type=text size=20 name=ecost value="$data->{'ecost'}" onchange='update(this.form)'>
268 </td>
269 </tr>
270 <TR VALIGN=TOP>
271 <TD>
272 Budgeted GST</td>
273 <td><input type=text size=20 name=GST value="" onchange='update(this.form)'>
274 </td>
275 </tr>
276 <TR VALIGN=TOP>
277 <TD><B>
278 BUDGETED TOTAL</B></td>
279 <td><input type=text size=20 name=total value="" onchange='update(this.form)'>
280 </td>
281 </tr>
282 <TR VALIGN=TOP  bgcolor=#ffffcc>
283 <TD>Actual Cost</td>
284 <td><input type=text size=20 name=cost>
285 </td>
286 </tr>
287 <TR VALIGN=TOP  bgcolor=#ffffcc>
288 <TD>Invoice Number *</td>
289 <td><input type=text size=20 name=invoice >
290 <TR VALIGN=TOP>
291 <TD>Notes</td>
292 <td><input type=text size=20 name=notes value="$data->{'notes'}">
293 </td>
294 </tr>
295 <TR VALIGN=TOP>
296 <TD colspan=2>
297 <input type=image  name=submit src=/images/add-order.gif border=0 width=187 height=42 align=right>
298 </td>
299 </tr>
300 </table>
301 </form>
302 </center>
303 <table>
304 <tr><td bgcolor=#cccc99  background="/images/background-mem.gif"><B>HELP</B><br>
305 <UL>
306 <LI>If ordering more than one copy of an item you will be prompted to  choose additional bookfunds, and put in additional barcodes at the next screen<P>
307 <LI><B>Bold</B> fields must be filled in to create a new bibilo and item.<p>
308 <LI>Shaded fields can be used to do a "quick" receive, when items have been purchased locally or gifted. In this case the quantity "ordered" will also  be entered into the database as the quantity received.
309 </UL>
310 </td></tr></table>
311 <p> &nbsp; </p>
312 printend
313 ;
314
315 print endmenu('acquisitions');
316
317 print endpage;