4 # Modified saas@users.sf.net 12:00 01 April 2001
5 # The biblioitemnumber was not correctly initialised
6 # The max(barcode) value was broken - koha 'barcode' is a string value!
7 # - If left blank, barcode value now defaults to max(biblionumber)
12 # Error checking for pre-existing barcodes, biblionumbers and maybe others
14 # Add info on biblioitems and items already entered as you enter new ones
17 # Copyright 2000-2002 Katipo Communications
19 # This file is part of Koha.
21 # Koha is free software; you can redistribute it and/or modify it under the
22 # terms of the GNU General Public License as published by the Free Software
23 # Foundation; either version 2 of the License, or (at your option) any later
26 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
27 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
28 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
30 # You should have received a copy of the GNU General Public License along with
31 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
32 # Suite 330, Boston, MA 02111-1307 USA
40 use C4::Circulation::Circ2;
45 my $lccn=$input->param('lccn');
46 my $q_lccn=$dbh->quote($lccn);
51 print startmenu('acquisitions');
53 ($input->param('checkforbiblio')) && (checkforbiblio());
54 ($input->param('newbiblioitem')) && (newbiblioitem());
55 ($input->param('newitem')) && (newitem());
58 my $title=$input->param('title');
59 my $q_title=$dbh->quote($title);
60 my $author=$input->param('author');
61 my $q_author=$dbh->quote($author);
62 my $seriestitle=$input->param('seriestitle');
64 ($seriestitle) && ($serial=1);
65 my $q_seriestitle=$dbh->quote($seriestitle);
66 my $copyrightdate=$input->param('copyrightdate');
67 my $q_copyrightdate=$dbh->quote($copyrightdate);
68 my $notes=$input->param('notes');
69 my $q_notes=$dbh->quote($notes);
70 my $subtitle=$input->param('subtitle');
71 my $q_subtitle=$dbh->quote($subtitle);
72 my $sth=$dbh->prepare("select biblionumber from biblio where title=$q_title
73 and author=$q_author and copyrightdate=$q_copyrightdate");
77 ($biblionumber) = $sth->fetchrow;
79 print "Adding new biblio for <i>$title</i> by $author<br>\n";
80 my $sth=$dbh->prepare("select max(biblionumber) from biblio");
82 ($biblionumber) = $sth->fetchrow;
84 $sth=$dbh->prepare("insert into biblio (biblionumber, title, author,
85 serial, seriestitle, copyrightdate, notes) values ($biblionumber,
86 $q_title, $q_author, $serial, $q_seriestitle, $q_copyrightdate,
89 $sth=$dbh->prepare("insert into bibliosubtitle (subtitle, biblionumber)
90 values ($q_subtitle, $biblionumber)");
93 my $itemtypeselect='';
94 $sth=$dbh->prepare("select itemtype,description from itemtypes");
96 while (my ($itemtype, $description) = $sth->fetchrow) {
97 $itemtypeselect.="<option value=$itemtype>$itemtype - $description\n";
99 my $authortext="by $author";
100 ($author) || ($authortext='');
102 $sth=$dbh->prepare("select BI.isbn,IT.description,BI.volume,BI.number,BI.volumeddesc,BI.dewey,BI.subclass from biblioitems BI, itemtypes IT where BI.itemtype=IT.itemtype and biblionumber=$biblionumber");
104 my $biblioitemdata='';
105 while (my ($isbn, $itemtype, $volume, $number, $volumeddesc, $dewey, $subclass) = $sth->fetchrow) {
109 $volumeinfo="V$volume, N$number";
111 $volumeinfo="Vol $volume";
115 $volumeinfo.=" $volumeddesc";
118 $biblioitemdata.="<tr><td>$isbn</td><td align=center>$itemtype</td><td align=center>$volumeinfo</td><td align=center>$dewey$subclass</td></tr>\n";
121 if ($biblioitemdata) {
125 <table border=1 bgcolor=#dddddd>
127 <th colspan=4>Existing entries using Biblio number $biblionumber</th>
130 <th>ISBN</th><th>Item Type</th><th>Volume</th><th>Classification</th></tr>
140 <table border=1 bgcolor=#dddddd>
141 <tr><th colspan=4>Section Two: Publication Information for<br><i>$title</i>
142 $authortext</th></tr>
144 <tr><td align=right>Publisher</td><td colspan=3><input name=publishercode size=30></td></tr>
145 <tr><td align=right>Publication Year</td><td><input name=publicationyear size=10></td>
146 <td align=right>Place of Publication</td><td><input name=place size=20></td></tr>
147 <tr><td align=right>Illustrator</td><td colspan=3><input name=illus size=20></td></tr>
148 <tr><td align=right>Additional Authors<br>(One author per line)</td><td colspan=3><textarea
149 name=additionalauthors rows=4 cols=30></textarea></td></tr>
150 <tr><td align=right>Subject Headings<br>(One subject per line)</td><td colspan=3><textarea
151 name=subjectheadings rows=4 cols=30></textarea></td></tr>
152 <tr><td align=right>Item Type</td><td colspan=3><select name=itemtype>$itemtypeselect</select></td></tr>
153 <tr><td align=right>Dewey</td><td><input name=dewey size=10></td>
154 <td align=right>Dewey Subclass</td><td><input name=subclass size=10></td></tr>
155 <tr><td align=right>ISSN</td><td colspan=3><input name=issn size=10></td></tr>
156 <tr><td align=right>ISBN</td><td colspan=3><input name=isbn size=10></td></tr>
157 <tr><td align=right>Volume</td><td><input name=volume size=10></td>
158 <td align=right>Number</td><td><input name=number size=10></td></tr>
159 <tr><td align=right>Volume Description</td><td colspan=3><input name=volumeddesc size=40></td></tr>
160 <tr><td align=right>Pages</td><td><input name=pages size=10></td>
161 <td align=right>Size</td><td><input name=size size=10></td></tr>
163 <tr><td align=right>Notes</td><td colspan=3><textarea name=notes rows=4 cols=50
164 wrap=physical></textarea></td></tr>
169 <input type=submit value="Add New Bibliography Item">
171 <input type=hidden name=biblionumber value=$biblionumber>
172 <input type=hidden name=lccn value=$lccn>
173 <input type=hidden name=newbiblioitem value=1>
183 my $biblionumber=$input->param('biblionumber');
184 my $volume=$input->param('volume');
185 my $q_volume=$dbh->quote($volume);
186 my $number=$input->param('number');
187 my $q_number=$dbh->quote($number);
188 my $classification=$input->param('classification');
189 my $q_classification=$dbh->quote($classification);
190 my $itemtype=$input->param('itemtype');
191 my $q_itemtype=$dbh->quote($itemtype);
192 my $issn=$input->param('issn');
193 my $q_issn=$dbh->quote($issn);
194 my $isbn=$input->param('isbn');
195 my $q_isbn=$dbh->quote($isbn);
196 my $dewey=$input->param('dewey');
197 my $q_dewey=$dbh->quote($dewey);
198 my $subclass=$input->param('subclass');
199 my $q_subclass=$dbh->quote($subclass);
200 my $publicationyear=$input->param('publicationyear');
201 my $q_publicationyear=$dbh->quote($publicationyear);
202 my $publishercode=$input->param('publishercode');
203 my $q_publishercode=$dbh->quote($publishercode);
204 my $volumedate=$input->param('volumedate');
205 my $q_volumedate=$dbh->quote($volumedate);
206 my $volumeddesc=$input->param('volumeddesc');
207 my $q_volumeddesc=$dbh->quote($volumeddesc);
208 my $illus=$input->param('illus');
209 my $q_illus=$dbh->quote($illus);
210 my $pages=$input->param('pages');
211 my $q_pages=$dbh->quote($pages);
212 my $notes=$input->param('notes');
213 my $q_notes=$dbh->quote($notes);
214 my $size=$input->param('size');
215 my $q_size=$dbh->quote($size);
216 my $place=$input->param('place');
217 my $q_place=$dbh->quote($place);
218 my $subjectheadings=$input->param('subjectheadings');
219 my $additionalauthors=$input->param('additionalauthors');
220 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
222 ($biblioitemnumber) = $sth->fetchrow;
224 # print STDERR "NEW BiblioItemNumber: $biblioitemnumber \n";
225 ($q_lccn='') if ($q_lccn eq 'NULL');
226 $sth=$dbh->prepare("insert into biblioitems (biblioitemnumber,
227 biblionumber, volume, number, classification, itemtype, isbn, issn, lccn, dewey, subclass,
228 publicationyear, publishercode, volumedate, volumeddesc, illus, pages,
229 notes, size, place) values ($biblioitemnumber, $biblionumber, $q_volume,
230 $q_number, $q_classification, $q_itemtype, $q_isbn, $q_issn, $q_lccn, $q_dewey, $q_subclass,
231 $q_publicationyear, $q_publishercode, $q_volumedate, $q_volumeddesc,
232 $q_illus, $q_pages, $q_notes, $q_size, $q_place)");
234 my @subjectheadings=split(/\n/,$subjectheadings);
236 foreach $subjectheading (@subjectheadings) {
237 # remove any line ending characters (Ctrl-J or M)
238 $subjectheading=~s/\013//g;
239 $subjectheading=~s/\010//g;
240 # convert to upper case
241 $subjectheading=uc($subjectheading);
242 print STDERR "S: $biblionumber, $subjectheading ";
243 chomp ($subjectheading);
244 print STDERR "B: ".ord(substr($subjectheading, length($subjectheading)-1, 1))." ";
245 while (ord(substr($subjectheading, length($subjectheading)-1, 1))<14) {
246 chop $subjectheading;
248 print STDERR "A: ".ord(substr($subjectheading, length($subjectheading)-1, 1))."\n";
250 my $q_subjectheading=$dbh->quote($subjectheading);
251 $sth=$dbh->prepare("insert into bibliosubject (biblionumber,subject)
252 values ($biblionumber, $q_subjectheading)");
255 my @additionalauthors=split(/\n/,$additionalauthors);
256 my $additionalauthor;
257 foreach $additionalauthor (@additionalauthors) {
258 # remove any line ending characters (Ctrl-L or Ctrl-M)
259 $additionalauthor=~s/\013//g;
260 $additionalauthor=~s/\010//g;
261 # convert to upper case
262 $additionalauthor=uc($additionalauthor);
264 my $q_additionalauthor=$dbh->quote($additionalauthor);
265 $sth=$dbh->prepare("insert into additionalauthors (biblionumber,author)
266 values ($biblionumber, $q_additionalauthor)");
272 my $biblionumber=$input->param('biblionumber');
273 my $biblioitemnumber=$input->param('biblioitemnumber');
274 my $barcode=$input->param('barcode');
275 my $itemnotes=$input->param('notes');
276 my $q_itemnotes=$dbh->quote($itemnotes);
277 my $replacementprice=$input->param('replacementprice');
278 ($replacementprice) || ($replacementprice=0);
279 my $sth=$dbh->prepare("select max(itemnumber) from items");
281 my ($itemnumber) = $sth->fetchrow;
283 my @datearr=localtime(time);
284 my $date=(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
285 my $q_homebranch=$dbh->quote($input->param('homebranch'));
286 $sth=$dbh->prepare("insert into items (itemnumber, biblionumber,
287 biblioitemnumber,barcode, itemnotes, holdingbranch, homebranch, dateaccessioned, replacementprice) values ($itemnumber,
288 $biblionumber, $biblioitemnumber, $barcode, $q_itemnotes, $q_homebranch, $q_homebranch, '$date', $replacementprice)");
294 if ($lccn eq 'NULL') {
295 # set biblioitemnumber if not already initialised...
296 if ($biblioitemnumber eq '') {
297 $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
299 ($biblioitemnumber) = $sth->fetchrow;
301 # print STDERR "BiblioItemNumber was missing: $biblioitemnumber \n";
303 $sth=$dbh->prepare("select biblionumber,biblioitemnumber from
304 biblioitems where biblioitemnumber=$biblioitemnumber");
306 $sth=$dbh->prepare("select biblionumber,biblioitemnumber from
307 biblioitems where lccn=$q_lccn");
310 if (my ($biblionumber, $biblioitemnumber) = $sth->fetchrow) {
312 $sth=$dbh->prepare("select I.barcode,I.itemnotes,B.title,B.author from items I, biblio B where B.biblionumber=I.biblionumber and biblioitemnumber=$biblioitemnumber");
315 while (my ($barcode, $itemnotes, $title, $author) = $sth->fetchrow) {
316 $itemdata.="<tr><td align=center>$barcode</td><td><u>$title</u></td><td>$author</td><td>$itemnotes</td></tr>\n";
323 <table border=1 bgcolor=#dddddd>
325 <th colspan=4>Existing Items with LCCN $lccn</th>
328 <th>Barcode</th><th>Title</th><th>Author</th><th>Notes</th></tr>
335 # my $sth=$dbh->prepare("select max(barcode) from items");
337 # my ($maxbarcode) = $sth->fetchrow;
339 # print STDERR "MaxBarCode: $maxbarcode";
342 <h2>Section Three: Specific Item Information</h2>
344 <input type=hidden name=newitem value=1>
345 <input type=hidden name=biblionumber value=$biblionumber>
346 <input type=hidden name=biblioitemnumber value=$biblioitemnumber>
348 <!-- tr><td>BARCODE</td><td><input name=barcode size=10 value=\$maxbarcode -->
349 <tr><td>BARCODE</td><td><input name=barcode size=10 value=$biblionumber>
350 Home Branch: <select name=homebranch>
352 my $branches=getbranches();
353 foreach my $key (sort(keys %$branches)) {
354 print "<option value=\"$key\">$branches->{$key}->{'branchname'}</option>";
358 </tr><td colspan=2>Replacement Price: <input name=replacementprice size=10></td></tr>
359 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
360 wrap=physical></textarea></td></tr>
362 <input type=submit value="Add Item">
364 <h3>LCCN $lccn Information</h3>
373 <input type=hidden name=lccn value='$lccn'>
374 <input type=hidden name=checkforbiblio value=1>
376 <tr><th colspan=2>Section One: Copyright Information</th></tr>
377 <tr><td>Title</td><td><input name=title size=40></td></tr>
378 <tr><td>Subtitle</td><td><input name=subtitle size=40></td></tr>
379 <tr><td>Author</td><td><input name=author size=40></td></tr>
380 <tr><td>Series Title<br>(if applicable)</td><td><input name=seriestitle
382 <tr><td>Copyright Date</td><td><input name=copyrightdate size=10></td></tr>
383 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
384 wrap=physical></textarea></td></tr>
386 <input type=submit value="Add new Bibliography">
392 <h2>Adding new items to the Library Inventory</h2>
393 To add a new item, scan or type the LCCN number:
396 LCCN: <input name=lccn>
399 <a href=addbooks.pl?lccn=NULL>Enter book with no LCCN</a>
401 Or use the <a href=marcimport.pl>MARC Importing tool</a>
414 <table border=1 width=70% bgcolor=#bbddbb>
418 Koha stores data in three sections.
421 <li>The first section records bibliographic data such as title, author and
422 copyright for a particular work.
423 <li>The second records bibliographic data for a particular publication of that
424 work, such as ISBN number, physical description, publisher information, etc.
425 <li>The third section holds specific item information, such as the bar code