Added magic RCS comment.
[koha.git] / acqui.simple / additem.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 use CGI;
23 use strict;
24 use C4::Catalogue;
25 use C4::Biblio;
26 use C4::Output;
27
28 my $input = new CGI;
29 my $biblionumber = $input->param('biblionumber');
30 my $error        = $input->param('error');
31 my $maxbarcode;
32 my $isbn;
33 my $bibliocount;
34 my @biblios;
35 my $biblioitemcount;
36 my @biblioitems;
37 my $branchcount;
38 my @branches;
39 my %branchnames;
40 my $itemcount;
41 my @items;
42 my $itemtypecount;
43 my @itemtypes;
44 my %itemtypedescriptions;
45
46 if (! $biblionumber) {
47     print $input->redirect('addbooks.pl');
48 } else {
49
50     ($bibliocount, @biblios)  = &getbiblio($biblionumber);
51
52     if (! $bibliocount) {
53         print $input->redirect('addbooks.pl');
54     } else {
55
56         ($biblioitemcount, @biblioitems) = &getbiblioitembybiblionumber($biblionumber);
57         ($branchcount, @branches)        = &branches;
58         ($itemtypecount, @itemtypes)     = &getitemtypes;
59
60         for (my $i = 0; $i < $itemtypecount; $i++) {
61             $itemtypedescriptions{$itemtypes[$i]->{'itemtype'}} = $itemtypes[$i]->{'description'};
62         } # for
63
64         for (my $i = 0; $i < $branchcount; $i++) {
65             $branchnames{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
66         } # for
67
68         print $input->header;
69         print startpage();
70         print startmenu('acquisitions');
71
72         print << "EOF";
73 <font size="6"><em>$biblios[0]->{'title'}</em></font>
74 <p>
75 EOF
76
77         if ($error eq "nobarcode") {
78             print << "EOF";
79 <font size="5" color="red">You must give the item a barcode</font>
80 <p>
81 EOF
82         } elsif ($error eq "nobiblioitem") {
83             print << "EOF";
84 <font size="5" color="red">You must create a new group for your item to be added to</font>
85 <p>
86 EOF
87         } elsif ($error eq "barcodeinuse") {
88             print << "EOF";
89 <font size="5" color="red">Sorry, that barcode is already in use</font>
90 <p>
91 EOF
92         } # elsif
93         print << "EOF";
94 <table align="left" cellpadding="5" cellspacing="0" border="1" width="220">
95 <tr valign="top" bgcolor="#CCCC99">
96 <td background="/images/background-mem.gif"><b>BIBLIO RECORD $biblionumber</b></td>
97 </tr>
98 <tr valign="top">
99 <td><b>Author:</b> $biblios[0]->{'author'}<br>
100 <b>Copyright:</b> $biblios[0]->{'copyrightdate'}<br>
101 <b>Series Title:</b> $biblios[0]->{'seriestitle'}<br>
102 <b>Notes:</b> $biblios[0]->{'notes'}</td>
103 </tr>
104 EOF
105
106         for (my $i = 0; $i < $biblioitemcount; $i++) {
107             if ($biblioitems[$i]->{'itemtype'} eq "WEB") {
108
109                 print << "EOF";
110 <tr valign="top" bgcolor="#CCCC99">
111 <td background="/images/background-mem.gif"><b>$biblioitems[$i]->{'biblioitemnumber'} GROUP - $itemtypedescriptions{$biblioitems[$i]->{'itemtype'}}</b></td>
112 </tr>
113 <tr valign="top">
114 <td><b>URL:</b> $biblioitems[$i]->{'url'}<br>
115 <b>Date:</b> $biblioitems[$i]->{'publicationyear'}<br>
116 <b>Notes:</b> $biblioitems[$i]->{'notes'}</td>
117 </tr>
118 EOF
119
120             } else {
121                 $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
122                 $biblioitems[$i]->{'dewey'} = $1;
123
124                 print << "EOF";
125 <tr valign="top" bgcolor="#CCCC99">
126 <td background="/images/background-mem.gif"><b>$biblioitems[$i]->{'biblioitemnumber'} GROUP - $itemtypedescriptions{$biblioitems[$i]->{'itemtype'}}</b></td>
127 </tr>
128 <tr valign="top">
129 <td><b>ISBN:</b> $biblioitems[$i]->{'isbn'}<br>
130 <b>Dewey:</b> $biblioitems[$i]->{'dewey'}<br>
131 <b>Publisher:</b> $biblioitems[$i]->{'publishercode'}<br>
132 <b>Place:</b> $biblioitems[$i]->{'place'}<br>
133 <b>Date:</b> $biblioitems[$i]->{'publicationyear'}</td>
134 </tr>
135 EOF
136
137                 ($itemcount, @items) = &getitemsbybiblioitem($biblioitems[$i]->{'biblioitemnumber'});
138
139                 for (my $j = 0; $j < $itemcount; $j++) {
140                     print << "EOF";
141 <tr valign="top" bgcolor="#FFFFCC">
142 <td><b>Item:</b> $items[$j]->{'barcode'}<br>
143 <b>Home Branch:</b> $branchnames{$items[$j]->{'homebranch'}}<br>
144 <b>Notes:</b> $items[$j]->{'itemnotes'}</td>
145 </tr>
146 EOF
147                 } # for
148             } # else
149         } # for
150
151         print << "EOF";
152 </table>
153 <img src="/images/holder.gif" width="16" height="650" align="left">
154
155 <center>
156
157 <form action="saveitem.pl" method="post">
158 <input type="hidden" name="biblionumber" value="$biblionumber">
159 <table border="1" cellspacing="0" cellpadding="5">
160 <tr valign="top" bgcolor="#CCCC99">
161 <td background="/images/background-mem.gif" colspan="2"><b>ADD NEW ITEM:</b><br>
162 <small><i>For a website add the group only</i></small></td>
163 </tr>
164 <tr valign="top">
165 <td>Item Barcode:</td>
166 <td><input type="text" name="barcode" size="40"></td>
167 </tr>
168 <tr valign="top">
169 <td>Branch:</td>
170 <td><select name="homebranch">
171 EOF
172
173         for (my $i = 0; $i < $branchcount; $i++) {
174             print << "EOF";
175 <option value="$branches[$i]->{'branchcode'}">$branches[$i]->{'branchname'}</option>
176 EOF
177         } # for
178
179         print << "EOF";
180 </select></td>
181 </tr>
182 <tr valign="top">
183 <td>Replacement Price:</td>
184 <td><input type="text" name="replacementprice" size="40"></td>
185 </tr>
186 <tr valign="top">
187 <td>Notes:</td>
188 <td><textarea name="itemnotes" cols="30" rows="6"></textarea></td>
189 </tr>
190 <tr valign="top" bgcolor="#CCCC99">
191 <td colspan="2" background="/images/background-mem.gif"><b>Add to existing group:</b></td>
192 </tr>
193 <tr valign="top">
194 <td>Group:</td>
195 <td><select name="biblioitemnumber">
196 EOF
197
198         for (my $i = 0; $i < $biblioitemcount; $i++) {
199             if ($biblioitems[$i]->{'itemtype'} ne "WEB") {
200                 print << "EOF";
201 <option value="$biblioitems[$i]->{'biblioitemnumber'}">$itemtypedescriptions{$biblioitems[$i]->{'itemtype'}}</option>
202 EOF
203             } # if
204         } # for
205
206         print << "EOF";
207 </select></td>
208 </tr>
209 <tr valign="top">
210 <td colspan="2" align="center"><input type="submit" name="existinggroup" value="Add New Item to Existing Group"></td>
211 </tr>
212 <tr valign="top" bgcolor="#CCCC99">
213 <td colspan="2" background="/images/background-mem.gif"><b>OR Add to a new Group:</b></td>
214 </tr>
215 <tr valign="top">
216 <td>Format:</td>
217 <td><select name="itemtype">
218 EOF
219
220         for (my $i = 0; $i < $itemtypecount; $i++) {
221             print << "EOF";
222 <option value="$itemtypes[$i]->{'itemtype'}">$itemtypes[$i]->{'description'}</option>
223 EOF
224         } # for
225
226         print << "EOF";
227 </select></td>
228 </tr>
229 <tr valign="top">
230 <td>ISBN:</td>
231 <td><input name="isbn" size="40"></td>
232 </tr>
233 <tr valign="top">
234 <td>Publisher:</td>
235 <td><input name="publishercode" size="40"></td>
236 </tr>
237 <tr valign="top">
238 <td>Publication Year:</td>
239 <td><input name="publicationyear" size="40"></td>
240 </tr>
241 <tr valign="top">
242 <td>Place of Publication:</td>
243 <td><input name="place" size="40"></td>
244 </tr>
245 <tr valign="top">
246 <td>Illustrator:</td>
247 <td><INPUT name="illus" size="40"></td>
248 </tr>
249 <tr valign="top">
250 <td>Additional Authors:<br><i>One Author per line</i></td>
251 <td><textarea name="additionalauthors" cols="30" rows="6"></textarea></td>
252 </tr>
253 <tr valign="top">
254 <td>Subject Headings:<br><i>One Subject per line</i></td>
255 <td><textarea name="subjectheadings" cols="30" rows="6"></textarea></td>
256 </tr>
257 <tr valign="top">
258 <td>Website URL:</td>
259 <td><INPUT name="url" size="40"></td>
260 </tr>
261 <tr valign="top">
262 <td>Dewey:</td>
263 <td><INPUT name="dewey" size="40"></td>
264 </tr>
265 <tr valign="top">
266 <td>Dewey Subclass:</td>
267 <td><input name="subclass" size="40"></td>
268 </tr>
269 <tr valign="top">
270 <td>ISSN:</td>
271 <td><input name="issn" size="40"></td>
272 </tr>
273 <tr valign="top">
274 <td>LCCN:</td>
275 <td><input name="lccn" size="40"</td>
276 </tr>
277 <tr valign="top">
278 <td>Volume:</td>
279 <td><input name="volume" size="40"></td>
280 </tr>
281 <tr valign="top">
282 <td>Number:</td>
283 <td><input name="number" size="40"></td>
284 </tr>
285 <tr valign="top">
286 <td>Volume Description:</td>
287 <td><input name="volumeddesc" size="40"></td>
288 </tr>
289 <tr valign="top">
290 <td>Pages:</td>
291 <td><input name="pages" size="40"></td>
292 </tr>
293 <tr valign="top">
294 <td>Size:</td>
295 <td><input name="size" size="40"></td>
296 </tr>
297 <tr valign="top">
298 <td>Notes:</td>
299 <td><textarea name="notes" cols="30" rows="6"></textarea></td>
300 </tr>
301 <tr valign="top">
302 <td colspan="2" align="center"><input type="submit" name="newgroup" value="Add New Item to New Group"></td>
303 </tr>
304 </table>
305
306 </form>
307 </center>
308 EOF
309
310         print endmenu('acquisitions');
311         print endpage();
312     } # if
313 } # if