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