Initial revision
[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 CGI;
10 use strict;
11
12 my $input=new CGI;
13 print $input->header();
14 my $id=$input->param('id');
15 my $title=$input->param('title');
16 my $author=$input->param('author');
17 my $copyright=$input->param('copyright');
18 my ($count,@booksellers)=bookseller($id);
19 my $ordnum=$input->param('ordnum');
20 my $biblio=$input->param('biblio');
21 my $data;
22 my $new;
23 if ($ordnum eq ''){
24   $new='yes';
25   $ordnum=newordernum;
26   $data=bibdata($biblio);
27   if ($data->{'title'} eq ''){
28     $data->{'title'}=$title;
29     $data->{'author'}=$author;
30     $data->{'copyrightdate'}=$copyright;
31   }
32 }else {
33   $data=getsingleorder($ordnum);
34   $biblio=$data->{'biblionumber'};
35
36
37 print startpage;
38
39 print startmenu('acquisitions');
40
41
42 my $basket=$input->param('basket');
43 print <<printend
44
45
46 <script language="javascript" type="text/javascript">
47
48 <!--
49
50 function update(f){
51   //collect values
52   quantity=f.quantity.value
53   discount=f.discount.value
54   listinc=parseInt(f.listinc.value)
55   currency=f.currency.value
56   applygst=parseInt(f.applygst.value)
57   listprice=f.list_price.value
58   //  rrp=f.rrp.value
59   //  ecost=f.ecost.value  //budgetted cost
60   //  GST=f.GST.value
61   //  total=f.total.value  
62   //make useful constants out of the above  
63   exchangerate=f.elements[currency].value      //get exchange rate  
64   gst_on=(!listinc && applygst);
65   //do real stuff  
66   rrp=listprice*exchangerate;
67   ecost=rrp*(100-discount)/100
68   GST=0;
69   if (gst_on){
70     rrp=rrp*1.125;
71     GST=ecost*0.125
72   }
73   
74   total=(ecost+GST)*quantity
75   
76   
77   f.rrp.value=display(rrp)
78   f.ecost.value=display(ecost)
79   f.GST.value=display(GST)
80   f.total.value=display(total)
81   
82 }
83                                                                       
84
85
86 function messenger(X,Y,etc){
87 win=window.open("","mess","height="+X+",width="+Y+",screenX=150,screenY=0");
88 win.focus();
89 win.document.close();
90 win.document.write("<body link='#333333' bgcolor='#ffffff' text='#000000'><font size=2><p><br>");
91 win.document.write(etc);
92 win.document.write("<center><form><input type=button onclick='self.close()' value=Close></form></center>");
93 win.document.write("</font></body></html>");
94 }
95 //-->
96
97 </script>
98 <form action=/cgi-bin/koha/acqui/addorder.pl method=post name=frusin>
99 printend
100 ;
101
102 if ($biblio eq ''){
103   print "<input type=hidden name=existing value=no>";
104 }
105
106 print <<printend
107 <!--$title-->
108 <input type=hidden name=ordnum value=$ordnum>
109 <input type=hidden name=basket value=$basket>
110 <input type=hidden name=supplier value=$id>
111 <input type=hidden name=biblio value=$biblio>
112 <input type=hidden name=bibitemnum value=$data->{'biblioitemnumber'}>
113 <input type=hidden name=oldtype value=$data->{'itemtype'}>
114 <input type=hidden name=discount value=$booksellers[0]->{'discount'}>
115 <input type=hidden name=listinc value=$booksellers[0]->{'listincgst'}>
116 <input type=hidden name=currency value=$booksellers[0]->{'listprice'}>
117 <input type=hidden name=applygst value=$booksellers[0]->{'gstreg'}>
118 printend
119 ;
120 my ($count2,$currencies)=getcurrencies;
121 for (my $i=0;$i<$count2;$i++){
122   print "<input type=hidden name=\"$currencies->[$i]->{'currency'}\" value=$currencies->[0]->{'rate'}>\n";
123 }
124 if ($new ne 'yes'){
125   print "<input type=hidden name=orderexists value=yes>\n";
126 }
127 print <<printend
128 <a href=basket.pl?basket=$basket><img src=/images/view-basket.gif width=187 heigth=42 border=0 align=right alt="View Basket"></a> 
129 <FONT SIZE=6><em>$ordnum - Order Details </em></FONT><br>
130 Shopping Basket For: $booksellers[0]->{'name'}
131 <P>
132 <CENTER>
133 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left width="40%">
134 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>CATALOGUE DETAILS</B></td></tr>
135 <TR VALIGN=TOP>
136 <TD><b>Title *</b></td>
137 <td><input type=text size=20 name=title value="$data->{'title'}">
138 </td>
139 </tr>
140 <TR VALIGN=TOP>
141 <TD>Author</td>
142 <td><input type=text size=20 name=author value="$data->{'author'}" >
143 </td>
144 </tr>
145 <TR VALIGN=TOP>
146 <TD>Copyright Date</td>
147 <td><input type=text size=20 name=copyright value="$data->{'copyrightdate'}">
148 </td>
149 </tr>
150 <TR VALIGN=TOP>
151 <TD><A HREF="popbox.html" onclick="messenger(600,300,'ITEMTYPES<BR>ART = Art Print<BR>BCD = CD-ROM from book<BR>CAS = Cassette<BR>CD = Compact disc (WN)<BR>F = Free Fiction<BR>FVID = Free video<BR>FYA = Young Adult Fiction<BR>GWB = Get Well Bag<BR>HCVF = Horowhenua Collection Vertical File<BR>IL = Interloan<BR>JCF = Junior Castle Fiction<BR>JCNF = Junior Castle Non-fiction<BR>JF = Junior Fiction<BR>JHC = Junior Horowhenua Collection VF<BR>JIG = Jigsaw puzzle<BR>JK = Junior Kermit<BR>JNF = Junior Non-Fiction<BR>JPB = Junior Paperbacks<BR>JPC = Junior Picture Book<BR>JPER = Junior Periodical<BR>JREF = Junior Reference<BR>JVF = Junior Vertical File<BR>LP = Large Print<BR>MAP = Map<BR>NF = Adult NonFiction<BR>NFLP = NonFiction LargePrint<BR>NGA = Nga Pukapuka<BR>PAY = Pay Collection<BR>PB = Pamphlet Box<BR>PER = Periodical<BR>PHOT = Photograph<BR>POS = Junior Poster<BR>REF = Adult Reference<BR>ROM = CD-Rom<BR>STF = Stack Fiction<BR>STJ = Stack Junior<BR>STLP = Stack Large Print<BR>STNF = Stack Non-fiction<BR>TB = Talking Book<BR>TREF = Taonga<BR>VF = Vertical File<BR>VID = Video'); return false"><b>Format *</b></A></td>
152 <td><input type=text size=20 name=format value=$data->{'itemtype'}>
153 </td>
154 </tr>
155 <TR VALIGN=TOP>
156 <TD>ISBN</td>
157 <td><input type=text size=20 name=ISBN value=$data->{'isbn'}>
158 </td>
159 </tr>
160 <TR VALIGN=TOP>
161 <TD>Series</td>
162 <td><input type=text size=20 name=Series value="$data->{'seriestitle'}">
163 </td>
164 </tr>
165 <TR VALIGN=TOP>
166 <TD>Branch</td>
167 <td><select name=branch size=1>
168 printend
169 ;
170 my ($count2,@branches)=branches;
171 for (my $i=0;$i<$count2;$i++){
172   print "<option value=$branches[$i]->{'branchcode'}";
173   if ($data->{'branchcode'} == $branches[$i]->{'branchcode'}){
174     print " Selected";
175   }
176   print ">$branches[$i]->{'branchname'}";
177 }
178
179 print <<printend
180 </select>
181 </td>
182 </tr>
183 <TR VALIGN=TOP  bgcolor=#ffffcc>
184 <TD >Item Barcode</td>
185 <td><input type=text size=20 name=barcode>
186 </td>
187 </tr>
188 </table>
189 <img src="/images/holder.gif" width=32 height=250 align=left>
190 <table border=1 cellspacing=0 cellpadding=5 width="40%">
191 <tr valign=top bgcolor=#99cc33><td background="/images/background-mem.gif" colspan=2><B>ACCOUNTING DETAILS</B></td></tr>
192 <TR VALIGN=TOP>
193 <TD>Quantity</td>
194 <td><input type=text size=20 name=quantity value="$data->{'quantity'}" onchange='update(this.form)' >
195 </td>
196 </tr>
197 <TR VALIGN=TOP>
198 <TD>Bookfund</td>
199 <td><select name=bookfund size=1>
200 printend
201 ;
202
203 my ($count2,@bookfund)=bookfunds;
204 for (my $i=0;$i<$count2;$i++){
205   print "<option value=$bookfund[$i]->{'bookfundid'}";
206   if ($data->{'bookfundid'} == $bookfund[$i]->{'bookfundid'}){
207     print " Selected";
208   }
209   print ">$bookfund[$i]->{'bookfundname'}";
210 }
211
212 print <<printend
213 </select>
214 </td>
215 </tr>
216 <TR VALIGN=TOP>
217 <TD>Suppliers List Price</td>
218 <td><input type=text size=20 name=list_price value="$data->{'listprice'}" onchange='update(this.form)'>
219 </tr>
220 <TR VALIGN=TOP>
221 <TD>Replacement Cost <br>
222 <FONT SIZE=2>(NZ\$ inc GST)</td>
223 <td><input type=text size=20 name=rrp value="$data->{'rrp'}" onchange='update(this.form)'>
224 </tr>
225 <TR VALIGN=TOP>
226 <TD>
227 Budgeted Cost<BR>
228 <FONT SIZE=2>(NZ\$ ex GST, inc discount)</FONT> </td>
229 <td><input type=text size=20 name=ecost value="$data->{'ecost'}" onchange='update(this.form)'>
230 </td>
231 </tr>
232 <TR VALIGN=TOP>
233 <TD>
234 Budgeted GST</td>
235 <td><input type=text size=20 name=GST value="" onchange='update(this.form)'>
236 </td>
237 </tr>
238 <TR VALIGN=TOP>
239 <TD><B>
240 BUDGETED TOTAL</B></td>
241 <td><input type=text size=20 name=total value="" onchange='update(this.form)'>
242 </td>
243 </tr>
244 <TR VALIGN=TOP  bgcolor=#ffffcc>
245 <TD>Actual Cost</td>
246 <td><input type=text size=20 name=cost>
247 </td>
248 </tr>
249 <TR VALIGN=TOP  bgcolor=#ffffcc>
250 <TD>Invoice Number *</td>
251 <td><input type=text size=20 name=invoice >
252 <TR VALIGN=TOP>
253 <TD>Notes</td>
254 <td><input type=text size=20 name=notes value="$data->{'notes'}">
255 </td>
256 </tr>
257 <TR VALIGN=TOP>
258 <TD colspan=2>
259 <input type=image  name=submit src=/images/add-order.gif border=0 width=187 height=42 align=right>
260 </td>
261 </tr>
262 </table>
263 </form>
264 </center>
265 <table>
266 <tr><td bgcolor=#cccc99  background="/images/background-mem.gif"><B>HELP</B><br>
267 <UL>
268 <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>
269 <LI><B>Bold</B> fields must be filled in to create a new bibilo and item.<p>
270 <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.
271 </UL>
272 </td></tr></table>
273 <p> &nbsp; </p>
274 printend
275 ;
276
277 print endmenu('acquisitions');
278
279 print endpage;