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