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
21 use C4::Circulation::Circ2;
26 my $isbn=$input->param('isbn');
27 my $q_isbn=$dbh->quote($isbn);
32 print startmenu('acquisitions');
34 ($input->param('checkforbiblio')) && (checkforbiblio());
35 ($input->param('newbiblioitem')) && (newbiblioitem());
36 ($input->param('newitem')) && (newitem());
39 my $title=$input->param('title');
40 my $q_title=$dbh->quote($title);
41 my $author=$input->param('author');
42 my $q_author=$dbh->quote($author);
43 my $seriestitle=$input->param('seriestitle');
45 ($seriestitle) && ($serial=1);
46 my $q_seriestitle=$dbh->quote($seriestitle);
47 my $copyrightdate=$input->param('copyrightdate');
48 my $q_copyrightdate=$dbh->quote($copyrightdate);
49 my $notes=$input->param('notes');
50 my $q_notes=$dbh->quote($notes);
51 my $subtitle=$input->param('subtitle');
52 my $q_subtitle=$dbh->quote($subtitle);
53 my $sth=$dbh->prepare("select biblionumber from biblio where title=$q_title
54 and author=$q_author and copyrightdate=$q_copyrightdate");
58 ($biblionumber) = $sth->fetchrow;
60 print "Adding new biblio for <i>$title</i> by $author<br>\n";
61 my $sth=$dbh->prepare("select max(biblionumber) from biblio");
63 ($biblionumber) = $sth->fetchrow;
65 $sth=$dbh->prepare("insert into biblio (biblionumber, title, author,
66 serial, seriestitle, copyrightdate, notes) values ($biblionumber,
67 $q_title, $q_author, $serial, $q_seriestitle, $q_copyrightdate,
70 $sth=$dbh->prepare("insert into bibliosubtitle (subtitle, biblionumber)
71 values ($q_subtitle, $biblionumber)");
74 my $itemtypeselect='';
75 $sth=$dbh->prepare("select itemtype,description from itemtypes");
77 while (my ($itemtype, $description) = $sth->fetchrow) {
78 $itemtypeselect.="<option value=$itemtype>$itemtype - $description\n";
80 my $authortext="by $author";
81 ($author) || ($authortext='');
83 $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");
85 my $biblioitemdata='';
86 while (my ($isbn, $itemtype, $volume, $number, $volumeddesc, $dewey, $subclass) = $sth->fetchrow) {
90 $volumeinfo="V$volume, N$number";
92 $volumeinfo="Vol $volume";
96 $volumeinfo.=" $volumeddesc";
99 $biblioitemdata.="<tr><td>$isbn</td><td align=center>$itemtype</td><td align=center>$volumeinfo</td><td align=center>$dewey$subclass</td></tr>\n";
102 if ($biblioitemdata) {
106 <table border=1 bgcolor=#dddddd>
108 <th colspan=4>Existing entries using Biblio number $biblionumber</th>
111 <th>ISBN</th><th>Item Type</th><th>Volume</th><th>Classification</th></tr>
121 <table border=1 bgcolor=#dddddd>
122 <tr><th colspan=4>Section Two: Publication Information for<br><i>$title</i>
123 $authortext</th></tr>
125 <tr><td align=right>Publisher</td><td colspan=3><input name=publishercode size=30></td></tr>
126 <tr><td align=right>Publication Year</td><td><input name=publicationyear size=10></td>
127 <td align=right>Place of Publication</td><td><input name=place size=20></td></tr>
128 <tr><td align=right>Illustrator</td><td colspan=3><input name=illus size=20></td></tr>
129 <tr><td align=right>Additional Authors<br>(One author per line)</td><td colspan=3><textarea
130 name=additionalauthors rows=4 cols=30></textarea></td></tr>
131 <tr><td align=right>Subject Headings<br>(One subject per line)</td><td colspan=3><textarea
132 name=subjectheadings rows=4 cols=30></textarea></td></tr>
133 <tr><td align=right>Item Type</td><td colspan=3><select name=itemtype>$itemtypeselect</select></td></tr>
134 <tr><td align=right>Dewey</td><td><input name=dewey size=10></td>
135 <td align=right>Dewey Subclass</td><td><input name=subclass size=10></td></tr>
136 <tr><td align=right>ISSN</td><td colspan=3><input name=issn size=10></td></tr>
137 <tr><td align=right>LCCN</td><td colspan=3><input name=lccn size=10></td></tr>
138 <tr><td align=right>Volume</td><td><input name=volume size=10></td>
139 <td align=right>Number</td><td><input name=number size=10></td></tr>
140 <tr><td align=right>Volume Description</td><td colspan=3><input name=volumeddesc size=40></td></tr>
141 <tr><td align=right>Pages</td><td><input name=pages size=10></td>
142 <td align=right>Size</td><td><input name=size size=10></td></tr>
144 <tr><td align=right>Notes</td><td colspan=3><textarea name=notes rows=4 cols=50
145 wrap=physical></textarea></td></tr>
148 <input type=submit value="Add New Bibliography Item">
150 <input type=hidden name=biblionumber value=$biblionumber>
151 <input type=hidden name=isbn value=$isbn>
152 <input type=hidden name=newbiblioitem value=1>
164 my $biblionumber=$input->param('biblionumber');
165 my $volume=$input->param('volume');
166 my $q_volume=$dbh->quote($volume);
167 my $number=$input->param('number');
168 my $q_number=$dbh->quote($number);
169 my $classification=$input->param('classification');
170 my $q_classification=$dbh->quote($classification);
171 my $itemtype=$input->param('itemtype');
172 my $q_itemtype=$dbh->quote($itemtype);
173 my $issn=$input->param('issn');
174 my $q_issn=$dbh->quote($issn);
175 my $lccn=$input->param('lccn');
176 my $q_lccn=$dbh->quote($lccn);
177 my $dewey=$input->param('dewey');
178 my $q_dewey=$dbh->quote($dewey);
179 my $subclass=$input->param('subclass');
180 my $q_subclass=$dbh->quote($subclass);
181 my $publicationyear=$input->param('publicationyear');
182 my $q_publicationyear=$dbh->quote($publicationyear);
183 my $publishercode=$input->param('publishercode');
184 my $q_publishercode=$dbh->quote($publishercode);
185 my $volumedate=$input->param('volumedate');
186 my $q_volumedate=$dbh->quote($volumedate);
187 my $volumeddesc=$input->param('volumeddesc');
188 my $q_volumeddesc=$dbh->quote($volumeddesc);
189 my $illus=$input->param('illus');
190 my $q_illus=$dbh->quote($illus);
191 my $pages=$input->param('pages');
192 my $q_pages=$dbh->quote($pages);
193 my $notes=$input->param('notes');
194 my $q_notes=$dbh->quote($notes);
195 my $size=$input->param('size');
196 my $q_size=$dbh->quote($size);
197 my $place=$input->param('place');
198 my $q_place=$dbh->quote($place);
199 my $subjectheadings=$input->param('subjectheadings');
200 my $additionalauthors=$input->param('additionalauthors');
201 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
203 ($biblioitemnumber) = $sth->fetchrow;
205 # print STDERR "NEW BiblioItemNumber: $biblioitemnumber \n";
206 ($q_isbn='') if ($q_isbn eq 'NULL');
207 my $query="insert into biblioitems (biblioitemnumber,
208 biblionumber, volume, number, classification, itemtype, isbn, issn, lccn, dewey, subclass,
209 publicationyear, publishercode, volumedate, volumeddesc, illus, pages,
210 notes, size, place) values ($biblioitemnumber, $biblionumber, $q_volume,
211 $q_number, $q_classification, $q_itemtype, $q_isbn, $q_issn, $q_lccn, $q_dewey, $q_subclass,
212 $q_publicationyear, $q_publishercode, $q_volumedate, $q_volumeddesc,
213 $q_illus, $q_pages, $q_notes, $q_size, $q_place)";
214 $sth=$dbh->prepare($query);
217 my @subjectheadings=split(/\n/,$subjectheadings);
219 foreach $subjectheading (@subjectheadings) {
220 # remove any line ending characters (Ctrl-J or M)
221 $subjectheading=~s/\013//g;
222 $subjectheading=~s/\010//g;
223 # convert to upper case
224 $subjectheading=uc($subjectheading);
225 print STDERR "S: $biblionumber, $subjectheading ";
226 chomp ($subjectheading);
227 print STDERR "B: ".ord(substr($subjectheading, length($subjectheading)-1, 1))." ";
228 while (ord(substr($subjectheading, length($subjectheading)-1, 1))<14) {
229 chop $subjectheading;
231 print STDERR "A: ".ord(substr($subjectheading, length($subjectheading)-1, 1))."\n";
233 my $q_subjectheading=$dbh->quote($subjectheading);
234 $sth=$dbh->prepare("insert into bibliosubject (biblionumber,subject)
235 values ($biblionumber, $q_subjectheading)");
238 my @additionalauthors=split(/\n/,$additionalauthors);
239 my $additionalauthor;
240 foreach $additionalauthor (@additionalauthors) {
241 # remove any line ending characters (Ctrl-L or Ctrl-M)
242 $additionalauthor=~s/\013//g;
243 $additionalauthor=~s/\010//g;
244 # convert to upper case
245 $additionalauthor=uc($additionalauthor);
247 my $q_additionalauthor=$dbh->quote($additionalauthor);
248 $sth=$dbh->prepare("insert into additionalauthors (biblionumber,author)
249 values ($biblionumber, $q_additionalauthor)");
255 my $biblionumber=$input->param('biblionumber');
256 my $biblioitemnumber=$input->param('biblioitemnumber');
257 my $barcode=$input->param('barcode');
258 my $itemnotes=$input->param('notes');
259 my $q_itemnotes=$dbh->quote($itemnotes);
260 my $replacementprice=$input->param('replacementprice');
261 ($replacementprice) || ($replacementprice=0);
262 my $sth=$dbh->prepare("select max(itemnumber) from items");
264 my ($itemnumber) = $sth->fetchrow;
266 my @datearr=localtime(time);
267 my $date=(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
268 my $q_homebranch=$dbh->quote($input->param('homebranch'));
269 my $query="insert into items (itemnumber, biblionumber,
270 biblioitemnumber,barcode, itemnotes, holdingbranch, homebranch, dateaccessioned, replacementprice) values ($itemnumber,
271 $biblionumber, $biblioitemnumber, $barcode, $q_itemnotes, $q_homebranch, $q_homebranch, '$date', $replacementprice)";
272 $sth=$dbh->prepare($query);
279 if ($isbn eq 'NULL') {
280 # set biblioitemnumber if not already initialised...
281 if ($biblioitemnumber eq '') {
282 $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
284 ($biblioitemnumber) = $sth->fetchrow;
286 # print STDERR "BiblioItemNumber was missing: $biblioitemnumber \n";
288 $sth=$dbh->prepare("select biblionumber,biblioitemnumber from
289 biblioitems where biblioitemnumber=$biblioitemnumber");
291 $sth=$dbh->prepare("select biblionumber, biblioitemnumber from
292 biblioitems where isbn=$q_isbn");
295 if (my ($biblionumber, $biblioitemnumber) = $sth->fetchrow) {
297 $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");
300 while (my ($barcode, $itemnotes, $title, $author) = $sth->fetchrow) {
301 $itemdata.="<tr><td align=center>$barcode</td><td><u>$title</u></td><td>$author</td><td>$itemnotes</td></tr>\n";
309 <table border=1 bgcolor=#dddddd>
311 <th colspan=4>Existing Items with ISBN $isbn</th>
314 <th>Barcode</th><th>Title</th><th>Author</th><th>Notes</th></tr>
321 # my $sth=$dbh->prepare("select max(barcode) from items");
323 # my ($maxbarcode) = $sth->fetchrow;
325 # print STDERR "MaxBarcode: $maxbarcode \n";
328 <h2>Section Three: Specific Item Information</h2>
330 <input type=hidden name=newitem value=1>
331 <input type=hidden name=biblionumber value=$biblionumber>
332 <input type=hidden name=biblioitemnumber value=$biblioitemnumber>
334 <!-- tr><td>BARCODE</td><td><input name=barcode size=10 value=\$maxbarcode -->
335 <tr><td>BARCODE</td><td><input name=barcode size=10 value=$biblionumber>
336 Home Branch: <select name=homebranch>
339 my $branches=getbranches();
340 foreach my $key (sort(keys %$branches)) {
341 print "<option value=\"$key\">$branches->{$key}->{'branchname'}</option>";
345 </tr><td colspan=2>Replacement Price: <input name=replacementprice size=10></td></tr>
346 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
347 wrap=physical></textarea></td></tr>
349 <input type=submit value="Add Item">
351 <h3>ISBN $isbn Information</h3>
360 <input type=hidden name=isbn value='$isbn'>
361 <input type=hidden name=checkforbiblio value=1>
363 <tr><th colspan=2>Section One: Copyright Information</th></tr>
364 <tr><td>Title</td><td><input name=title size=40></td></tr>
365 <tr><td>Subtitle</td><td><input name=subtitle size=40></td></tr>
366 <tr><td>Author</td><td><input name=author size=40></td></tr>
367 <tr><td>Series Title<br>(if applicable)</td><td><input name=seriestitle
369 <tr><td>Copyright Date</td><td><input name=copyrightdate size=10></td></tr>
370 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
371 wrap=physical></textarea></td></tr>
373 <input type=submit value="Add new Bibliography">
379 <h2>Adding new items to the Library Inventory</h2>
380 To add a new item, scan or type the ISBN number:
383 ISBN: <input name=isbn>
386 <a href=addbooks.pl?isbn=NULL>Enter book with no ISBN</a>
389 <h2>Tools for importing MARC records into Koha</h2>
391 <li><a href=marcimport.pl?menu=z3950>Z39.50 Search Tool</a>
392 <li><a href=marcimport.pl?menu=uploadmarc>Upload MARC records</a>
404 <table border=1 width=70% bgcolor=#bbddbb>
408 Koha stores data in three sections.
411 <li>The first section records bibliographic data such as title, author and
412 copyright for a particular work.
413 <li>The second records bibliographic data for a particular publication of that
414 work, such as ISBN number, physical description, publisher information, etc.
415 <li>The third section holds specific item information, such as the bar code