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
22 use C4::Circulation::Circ2;
27 my $lccn=$input->param('lccn');
28 my $q_lccn=$dbh->quote($lccn);
33 print startmenu('acquisitions');
35 ($input->param('checkforbiblio')) && (checkforbiblio());
36 ($input->param('newbiblioitem')) && (newbiblioitem());
37 ($input->param('newitem')) && (newitem());
40 my $title=$input->param('title');
41 my $q_title=$dbh->quote($title);
42 my $author=$input->param('author');
43 my $q_author=$dbh->quote($author);
44 my $seriestitle=$input->param('seriestitle');
46 ($seriestitle) && ($serial=1);
47 my $q_seriestitle=$dbh->quote($seriestitle);
48 my $copyrightdate=$input->param('copyrightdate');
49 my $q_copyrightdate=$dbh->quote($copyrightdate);
50 my $notes=$input->param('notes');
51 my $q_notes=$dbh->quote($notes);
52 my $subtitle=$input->param('subtitle');
53 my $q_subtitle=$dbh->quote($subtitle);
54 my $sth=$dbh->prepare("select biblionumber from biblio where title=$q_title
55 and author=$q_author and copyrightdate=$q_copyrightdate");
59 ($biblionumber) = $sth->fetchrow;
61 print "Adding new biblio for <i>$title</i> by $author<br>\n";
62 my $sth=$dbh->prepare("select max(biblionumber) from biblio");
64 ($biblionumber) = $sth->fetchrow;
66 $sth=$dbh->prepare("insert into biblio (biblionumber, title, author,
67 serial, seriestitle, copyrightdate, notes) values ($biblionumber,
68 $q_title, $q_author, $serial, $q_seriestitle, $q_copyrightdate,
71 $sth=$dbh->prepare("insert into bibliosubtitle (subtitle, biblionumber)
72 values ($q_subtitle, $biblionumber)");
75 my $itemtypeselect='';
76 $sth=$dbh->prepare("select itemtype,description from itemtypes");
78 while (my ($itemtype, $description) = $sth->fetchrow) {
79 $itemtypeselect.="<option value=$itemtype>$itemtype - $description\n";
81 my $authortext="by $author";
82 ($author) || ($authortext='');
84 $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");
86 my $biblioitemdata='';
87 while (my ($isbn, $itemtype, $volume, $number, $volumeddesc, $dewey, $subclass) = $sth->fetchrow) {
91 $volumeinfo="V$volume, N$number";
93 $volumeinfo="Vol $volume";
97 $volumeinfo.=" $volumeddesc";
100 $biblioitemdata.="<tr><td>$isbn</td><td align=center>$itemtype</td><td align=center>$volumeinfo</td><td align=center>$dewey$subclass</td></tr>\n";
103 if ($biblioitemdata) {
107 <table border=1 bgcolor=#dddddd>
109 <th colspan=4>Existing entries using Biblio number $biblionumber</th>
112 <th>ISBN</th><th>Item Type</th><th>Volume</th><th>Classification</th></tr>
122 <table border=1 bgcolor=#dddddd>
123 <tr><th colspan=4>Section Two: Publication Information for<br><i>$title</i>
124 $authortext</th></tr>
126 <tr><td align=right>Publisher</td><td colspan=3><input name=publishercode size=30></td></tr>
127 <tr><td align=right>Publication Year</td><td><input name=publicationyear size=10></td>
128 <td align=right>Place of Publication</td><td><input name=place size=20></td></tr>
129 <tr><td align=right>Illustrator</td><td colspan=3><input name=illus size=20></td></tr>
130 <tr><td align=right>Additional Authors<br>(One author per line)</td><td colspan=3><textarea
131 name=additionalauthors rows=4 cols=30></textarea></td></tr>
132 <tr><td align=right>Subject Headings<br>(One subject per line)</td><td colspan=3><textarea
133 name=subjectheadings rows=4 cols=30></textarea></td></tr>
134 <tr><td align=right>Item Type</td><td colspan=3><select name=itemtype>$itemtypeselect</select></td></tr>
135 <tr><td align=right>Dewey</td><td><input name=dewey size=10></td>
136 <td align=right>Dewey Subclass</td><td><input name=subclass size=10></td></tr>
137 <tr><td align=right>ISSN</td><td colspan=3><input name=issn size=10></td></tr>
138 <tr><td align=right>ISBN</td><td colspan=3><input name=isbn size=10></td></tr>
139 <tr><td align=right>Volume</td><td><input name=volume size=10></td>
140 <td align=right>Number</td><td><input name=number size=10></td></tr>
141 <tr><td align=right>Volume Description</td><td colspan=3><input name=volumeddesc size=40></td></tr>
142 <tr><td align=right>Pages</td><td><input name=pages size=10></td>
143 <td align=right>Size</td><td><input name=size size=10></td></tr>
145 <tr><td align=right>Notes</td><td colspan=3><textarea name=notes rows=4 cols=50
146 wrap=physical></textarea></td></tr>
151 <input type=submit value="Add New Bibliography Item">
153 <input type=hidden name=biblionumber value=$biblionumber>
154 <input type=hidden name=lccn value=$lccn>
155 <input type=hidden name=newbiblioitem value=1>
165 my $biblionumber=$input->param('biblionumber');
166 my $volume=$input->param('volume');
167 my $q_volume=$dbh->quote($volume);
168 my $number=$input->param('number');
169 my $q_number=$dbh->quote($number);
170 my $classification=$input->param('classification');
171 my $q_classification=$dbh->quote($classification);
172 my $itemtype=$input->param('itemtype');
173 my $q_itemtype=$dbh->quote($itemtype);
174 my $issn=$input->param('issn');
175 my $q_issn=$dbh->quote($issn);
176 my $isbn=$input->param('isbn');
177 my $q_isbn=$dbh->quote($isbn);
178 my $dewey=$input->param('dewey');
179 my $q_dewey=$dbh->quote($dewey);
180 my $subclass=$input->param('subclass');
181 my $q_subclass=$dbh->quote($subclass);
182 my $publicationyear=$input->param('publicationyear');
183 my $q_publicationyear=$dbh->quote($publicationyear);
184 my $publishercode=$input->param('publishercode');
185 my $q_publishercode=$dbh->quote($publishercode);
186 my $volumedate=$input->param('volumedate');
187 my $q_volumedate=$dbh->quote($volumedate);
188 my $volumeddesc=$input->param('volumeddesc');
189 my $q_volumeddesc=$dbh->quote($volumeddesc);
190 my $illus=$input->param('illus');
191 my $q_illus=$dbh->quote($illus);
192 my $pages=$input->param('pages');
193 my $q_pages=$dbh->quote($pages);
194 my $notes=$input->param('notes');
195 my $q_notes=$dbh->quote($notes);
196 my $size=$input->param('size');
197 my $q_size=$dbh->quote($size);
198 my $place=$input->param('place');
199 my $q_place=$dbh->quote($place);
200 my $subjectheadings=$input->param('subjectheadings');
201 my $additionalauthors=$input->param('additionalauthors');
202 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
204 ($biblioitemnumber) = $sth->fetchrow;
206 # print STDERR "NEW BiblioItemNumber: $biblioitemnumber \n";
207 ($q_lccn='') if ($q_lccn eq 'NULL');
208 $sth=$dbh->prepare("insert into biblioitems (biblioitemnumber,
209 biblionumber, volume, number, classification, itemtype, isbn, issn, lccn, dewey, subclass,
210 publicationyear, publishercode, volumedate, volumeddesc, illus, pages,
211 notes, size, place) values ($biblioitemnumber, $biblionumber, $q_volume,
212 $q_number, $q_classification, $q_itemtype, $q_isbn, $q_issn, $q_lccn, $q_dewey, $q_subclass,
213 $q_publicationyear, $q_publishercode, $q_volumedate, $q_volumeddesc,
214 $q_illus, $q_pages, $q_notes, $q_size, $q_place)");
216 my @subjectheadings=split(/\n/,$subjectheadings);
218 foreach $subjectheading (@subjectheadings) {
219 # remove any line ending characters (Ctrl-J or M)
220 $subjectheading=~s/\013//g;
221 $subjectheading=~s/\010//g;
222 # convert to upper case
223 $subjectheading=uc($subjectheading);
224 print STDERR "S: $biblionumber, $subjectheading ";
225 chomp ($subjectheading);
226 print STDERR "B: ".ord(substr($subjectheading, length($subjectheading)-1, 1))." ";
227 while (ord(substr($subjectheading, length($subjectheading)-1, 1))<14) {
228 chop $subjectheading;
230 print STDERR "A: ".ord(substr($subjectheading, length($subjectheading)-1, 1))."\n";
232 my $q_subjectheading=$dbh->quote($subjectheading);
233 $sth=$dbh->prepare("insert into bibliosubject (biblionumber,subject)
234 values ($biblionumber, $q_subjectheading)");
237 my @additionalauthors=split(/\n/,$additionalauthors);
238 my $additionalauthor;
239 foreach $additionalauthor (@additionalauthors) {
240 # remove any line ending characters (Ctrl-L or Ctrl-M)
241 $additionalauthor=~s/\013//g;
242 $additionalauthor=~s/\010//g;
243 # convert to upper case
244 $additionalauthor=uc($additionalauthor);
246 my $q_additionalauthor=$dbh->quote($additionalauthor);
247 $sth=$dbh->prepare("insert into additionalauthors (biblionumber,author)
248 values ($biblionumber, $q_additionalauthor)");
254 my $biblionumber=$input->param('biblionumber');
255 my $biblioitemnumber=$input->param('biblioitemnumber');
256 my $barcode=$input->param('barcode');
257 my $itemnotes=$input->param('notes');
258 my $q_itemnotes=$dbh->quote($itemnotes);
259 my $replacementprice=$input->param('replacementprice');
260 ($replacementprice) || ($replacementprice=0);
261 my $sth=$dbh->prepare("select max(itemnumber) from items");
263 my ($itemnumber) = $sth->fetchrow;
265 my @datearr=localtime(time);
266 my $date=(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
267 my $q_homebranch=$dbh->quote($input->param('homebranch'));
268 $sth=$dbh->prepare("insert into items (itemnumber, biblionumber,
269 biblioitemnumber,barcode, itemnotes, holdingbranch, homebranch, dateaccessioned, replacementprice) values ($itemnumber,
270 $biblionumber, $biblioitemnumber, $barcode, $q_itemnotes, $q_homebranch, $q_homebranch, '$date', $replacementprice)");
276 if ($lccn eq 'NULL') {
277 # set biblioitemnumber if not already initialised...
278 if ($biblioitemnumber eq '') {
279 $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
281 ($biblioitemnumber) = $sth->fetchrow;
283 # print STDERR "BiblioItemNumber was missing: $biblioitemnumber \n";
285 $sth=$dbh->prepare("select biblionumber,biblioitemnumber from
286 biblioitems where biblioitemnumber=$biblioitemnumber");
288 $sth=$dbh->prepare("select biblionumber,biblioitemnumber from
289 biblioitems where lccn=$q_lccn");
292 if (my ($biblionumber, $biblioitemnumber) = $sth->fetchrow) {
294 $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");
297 while (my ($barcode, $itemnotes, $title, $author) = $sth->fetchrow) {
298 $itemdata.="<tr><td align=center>$barcode</td><td><u>$title</u></td><td>$author</td><td>$itemnotes</td></tr>\n";
305 <table border=1 bgcolor=#dddddd>
307 <th colspan=4>Existing Items with LCCN $lccn</th>
310 <th>Barcode</th><th>Title</th><th>Author</th><th>Notes</th></tr>
317 # my $sth=$dbh->prepare("select max(barcode) from items");
319 # my ($maxbarcode) = $sth->fetchrow;
321 # print STDERR "MaxBarCode: $maxbarcode";
324 <h2>Section Three: Specific Item Information</h2>
326 <input type=hidden name=newitem value=1>
327 <input type=hidden name=biblionumber value=$biblionumber>
328 <input type=hidden name=biblioitemnumber value=$biblioitemnumber>
330 <!-- tr><td>BARCODE</td><td><input name=barcode size=10 value=\$maxbarcode -->
331 <tr><td>BARCODE</td><td><input name=barcode size=10 value=$biblionumber>
332 Home Branch: <select name=homebranch>
334 my $branches=getbranches();
335 foreach my $key (sort(keys %$branches)) {
336 print "<option value=\"$key\">$branches->{$key}->{'branchname'}</option>";
340 </tr><td colspan=2>Replacement Price: <input name=replacementprice size=10></td></tr>
341 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
342 wrap=physical></textarea></td></tr>
344 <input type=submit value="Add Item">
346 <h3>LCCN $lccn Information</h3>
355 <input type=hidden name=lccn value='$lccn'>
356 <input type=hidden name=checkforbiblio value=1>
358 <tr><th colspan=2>Section One: Copyright Information</th></tr>
359 <tr><td>Title</td><td><input name=title size=40></td></tr>
360 <tr><td>Subtitle</td><td><input name=subtitle size=40></td></tr>
361 <tr><td>Author</td><td><input name=author size=40></td></tr>
362 <tr><td>Series Title<br>(if applicable)</td><td><input name=seriestitle
364 <tr><td>Copyright Date</td><td><input name=copyrightdate size=10></td></tr>
365 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
366 wrap=physical></textarea></td></tr>
368 <input type=submit value="Add new Bibliography">
374 <h2>Adding new items to the Library Inventory</h2>
375 To add a new item, scan or type the LCCN number:
378 LCCN: <input name=lccn>
381 <a href=addbooks.pl?lccn=NULL>Enter book with no LCCN</a>
383 Or use the <a href=marcimport.pl>MARC Importing tool</a>
396 <table border=1 width=70% bgcolor=#bbddbb>
400 Koha stores data in three sections.
403 <li>The first section records bibliographic data such as title, author and
404 copyright for a particular work.
405 <li>The second records bibliographic data for a particular publication of that
406 work, such as ISBN number, physical description, publisher information, etc.
407 <li>The third section holds specific item information, such as the bar code