6 # Modified saas@users.sf.net 12:00 01 April 2001
7 # The biblioitemnumber was not correctly initialised
8 # The max(barcode) value was broken - koha 'barcode' is a string value!
9 # - If left blank, barcode value now defaults to max(biblionumber)
14 # Error checking for pre-existing barcodes, biblionumbers and maybe others
16 # Add info on biblioitems and items already entered as you enter new ones
19 # Copyright 2000-2002 Katipo Communications
21 # This file is part of Koha.
23 # Koha is free software; you can redistribute it and/or modify it under the
24 # terms of the GNU General Public License as published by the Free Software
25 # Foundation; either version 2 of the License, or (at your option) any later
28 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
29 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
30 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
32 # You should have received a copy of the GNU General Public License along with
33 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
34 # Suite 330, Boston, MA 02111-1307 USA
42 use C4::Circulation::Circ2;
45 my $dbh = C4::Context->dbh;
47 my $lccn=$input->param('lccn');
48 my $q_lccn=$dbh->quote($lccn);
53 print startmenu('acquisitions');
55 ($input->param('checkforbiblio')) && (checkforbiblio());
56 ($input->param('newbiblioitem')) && (newbiblioitem());
57 ($input->param('newitem')) && (newitem());
60 my $title=$input->param('title');
61 my $q_title=$dbh->quote($title);
62 my $author=$input->param('author');
63 my $q_author=$dbh->quote($author);
64 my $seriestitle=$input->param('seriestitle');
66 ($seriestitle) && ($serial=1);
67 my $q_seriestitle=$dbh->quote($seriestitle);
68 my $copyrightdate=$input->param('copyrightdate');
69 my $q_copyrightdate=$dbh->quote($copyrightdate);
70 my $notes=$input->param('notes');
71 my $q_notes=$dbh->quote($notes);
72 my $subtitle=$input->param('subtitle');
73 my $q_subtitle=$dbh->quote($subtitle);
74 my $sth=$dbh->prepare("select biblionumber from biblio where title=$q_title
75 and author=$q_author and copyrightdate=$q_copyrightdate");
79 ($biblionumber) = $sth->fetchrow;
81 print "Adding new biblio for <i>$title</i> by $author<br>\n";
82 my $sth=$dbh->prepare("select max(biblionumber) from biblio");
84 ($biblionumber) = $sth->fetchrow;
86 $sth=$dbh->prepare("insert into biblio (biblionumber, title, author,
87 serial, seriestitle, copyrightdate, notes) values ($biblionumber,
88 $q_title, $q_author, $serial, $q_seriestitle, $q_copyrightdate,
91 $sth=$dbh->prepare("insert into bibliosubtitle (subtitle, biblionumber)
92 values ($q_subtitle, $biblionumber)");
95 my $itemtypeselect='';
96 $sth=$dbh->prepare("select itemtype,description from itemtypes");
98 while (my ($itemtype, $description) = $sth->fetchrow) {
99 $itemtypeselect.="<option value=$itemtype>$itemtype - $description\n";
101 my $authortext="by $author";
102 ($author) || ($authortext='');
104 $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");
106 my $biblioitemdata='';
107 while (my ($isbn, $itemtype, $volume, $number, $volumeddesc, $dewey, $subclass) = $sth->fetchrow) {
111 $volumeinfo="V$volume, N$number";
113 $volumeinfo="Vol $volume";
117 $volumeinfo.=" $volumeddesc";
120 $biblioitemdata.="<tr><td>$isbn</td><td align=center>$itemtype</td><td align=center>$volumeinfo</td><td align=center>$dewey$subclass</td></tr>\n";
123 if ($biblioitemdata) {
127 <table border=1 bgcolor=#dddddd>
129 <th colspan=4>Existing entries using Biblio number $biblionumber</th>
132 <th>ISBN</th><th>Item Type</th><th>Volume</th><th>Classification</th></tr>
142 <table border=1 bgcolor=#dddddd>
143 <tr><th colspan=4>Section Two: Publication Information for<br><i>$title</i>
144 $authortext</th></tr>
146 <tr><td align=right>Publisher</td><td colspan=3><input name=publishercode size=30></td></tr>
147 <tr><td align=right>Publication Year</td><td><input name=publicationyear size=10></td>
148 <td align=right>Place of Publication</td><td><input name=place size=20></td></tr>
149 <tr><td align=right>Illustrator</td><td colspan=3><input name=illus size=20></td></tr>
150 <tr><td align=right>Additional Authors<br>(One author per line)</td><td colspan=3><textarea
151 name=additionalauthors rows=4 cols=30></textarea></td></tr>
152 <tr><td align=right>Subject Headings<br>(One subject per line)</td><td colspan=3><textarea
153 name=subjectheadings rows=4 cols=30></textarea></td></tr>
154 <tr><td align=right>Item Type</td><td colspan=3><select name=itemtype>$itemtypeselect</select></td></tr>
155 <tr><td align=right>Dewey</td><td><input name=dewey size=10></td>
156 <td align=right>Dewey Subclass</td><td><input name=subclass size=10></td></tr>
157 <tr><td align=right>ISSN</td><td colspan=3><input name=issn size=10></td></tr>
158 <tr><td align=right>ISBN</td><td colspan=3><input name=isbn size=10></td></tr>
159 <tr><td align=right>Volume</td><td><input name=volume size=10></td>
160 <td align=right>Number</td><td><input name=number size=10></td></tr>
161 <tr><td align=right>Volume Description</td><td colspan=3><input name=volumeddesc size=40></td></tr>
162 <tr><td align=right>Pages</td><td><input name=pages size=10></td>
163 <td align=right>Size</td><td><input name=size size=10></td></tr>
165 <tr><td align=right>Notes</td><td colspan=3><textarea name=notes rows=4 cols=50
166 wrap=physical></textarea></td></tr>
171 <input type=submit value="Add New Bibliography Item">
173 <input type=hidden name=biblionumber value=$biblionumber>
174 <input type=hidden name=lccn value=$lccn>
175 <input type=hidden name=newbiblioitem value=1>
183 # FIXME - There's already a &C4::Biblio::newbiblioitem.
185 my $biblionumber=$input->param('biblionumber');
186 my $volume=$input->param('volume');
187 my $q_volume=$dbh->quote($volume);
188 my $number=$input->param('number');
189 my $q_number=$dbh->quote($number);
190 my $classification=$input->param('classification');
191 my $q_classification=$dbh->quote($classification);
192 my $itemtype=$input->param('itemtype');
193 my $q_itemtype=$dbh->quote($itemtype);
194 my $issn=$input->param('issn');
195 my $q_issn=$dbh->quote($issn);
196 my $isbn=$input->param('isbn');
197 my $q_isbn=$dbh->quote($isbn);
198 my $dewey=$input->param('dewey');
199 my $q_dewey=$dbh->quote($dewey);
200 my $subclass=$input->param('subclass');
201 my $q_subclass=$dbh->quote($subclass);
202 my $publicationyear=$input->param('publicationyear');
203 my $q_publicationyear=$dbh->quote($publicationyear);
204 my $publishercode=$input->param('publishercode');
205 my $q_publishercode=$dbh->quote($publishercode);
206 my $volumedate=$input->param('volumedate');
207 my $q_volumedate=$dbh->quote($volumedate);
208 my $volumeddesc=$input->param('volumeddesc');
209 my $q_volumeddesc=$dbh->quote($volumeddesc);
210 my $illus=$input->param('illus');
211 my $q_illus=$dbh->quote($illus);
212 my $pages=$input->param('pages');
213 my $q_pages=$dbh->quote($pages);
214 my $notes=$input->param('notes');
215 my $q_notes=$dbh->quote($notes);
216 my $size=$input->param('size');
217 my $q_size=$dbh->quote($size);
218 my $place=$input->param('place');
219 my $q_place=$dbh->quote($place);
220 my $subjectheadings=$input->param('subjectheadings');
221 my $additionalauthors=$input->param('additionalauthors');
222 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
224 ($biblioitemnumber) = $sth->fetchrow;
226 # print STDERR "NEW BiblioItemNumber: $biblioitemnumber \n";
227 ($q_lccn='') if ($q_lccn eq 'NULL');
228 $sth=$dbh->prepare("insert into biblioitems (biblioitemnumber,
229 biblionumber, volume, number, classification, itemtype, isbn, issn, lccn, dewey, subclass,
230 publicationyear, publishercode, volumedate, volumeddesc, illus, pages,
231 notes, size, place) values ($biblioitemnumber, $biblionumber, $q_volume,
232 $q_number, $q_classification, $q_itemtype, $q_isbn, $q_issn, $q_lccn, $q_dewey, $q_subclass,
233 $q_publicationyear, $q_publishercode, $q_volumedate, $q_volumeddesc,
234 $q_illus, $q_pages, $q_notes, $q_size, $q_place)");
236 my @subjectheadings=split(/\n/,$subjectheadings);
238 foreach $subjectheading (@subjectheadings) {
239 # remove any line ending characters (Ctrl-J or M)
240 $subjectheading=~s/\013//g;
241 $subjectheading=~s/\010//g;
242 # convert to upper case
243 $subjectheading=uc($subjectheading);
244 print STDERR "S: $biblionumber, $subjectheading ";
245 chomp ($subjectheading);
246 print STDERR "B: ".ord(substr($subjectheading, length($subjectheading)-1, 1))." ";
247 while (ord(substr($subjectheading, length($subjectheading)-1, 1))<14) {
248 chop $subjectheading;
250 print STDERR "A: ".ord(substr($subjectheading, length($subjectheading)-1, 1))."\n";
252 my $q_subjectheading=$dbh->quote($subjectheading);
253 $sth=$dbh->prepare("insert into bibliosubject (biblionumber,subject)
254 values ($biblionumber, $q_subjectheading)");
257 my @additionalauthors=split(/\n/,$additionalauthors);
258 my $additionalauthor;
259 foreach $additionalauthor (@additionalauthors) {
260 # remove any line ending characters (Ctrl-L or Ctrl-M)
261 $additionalauthor=~s/\013//g;
262 $additionalauthor=~s/\010//g;
263 # convert to upper case
264 $additionalauthor=uc($additionalauthor);
266 my $q_additionalauthor=$dbh->quote($additionalauthor);
267 $sth=$dbh->prepare("insert into additionalauthors (biblionumber,author)
268 values ($biblionumber, $q_additionalauthor)");
274 my $biblionumber=$input->param('biblionumber');
275 my $biblioitemnumber=$input->param('biblioitemnumber');
276 my $barcode=$input->param('barcode');
277 my $itemnotes=$input->param('notes');
278 my $q_itemnotes=$dbh->quote($itemnotes);
279 my $replacementprice=$input->param('replacementprice');
280 ($replacementprice) || ($replacementprice=0);
281 my $sth=$dbh->prepare("select max(itemnumber) from items");
283 my ($itemnumber) = $sth->fetchrow;
285 my @datearr=localtime(time);
286 my $date=(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
287 my $q_homebranch=$dbh->quote($input->param('homebranch'));
288 $sth=$dbh->prepare("insert into items (itemnumber, biblionumber,
289 biblioitemnumber,barcode, itemnotes, holdingbranch, homebranch, dateaccessioned, replacementprice) values ($itemnumber,
290 $biblionumber, $biblioitemnumber, $barcode, $q_itemnotes, $q_homebranch, $q_homebranch, '$date', $replacementprice)");
296 if ($lccn eq 'NULL') {
297 # set biblioitemnumber if not already initialised...
298 if ($biblioitemnumber eq '') {
299 $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
301 ($biblioitemnumber) = $sth->fetchrow;
303 # print STDERR "BiblioItemNumber was missing: $biblioitemnumber \n";
305 $sth=$dbh->prepare("select biblionumber,biblioitemnumber from
306 biblioitems where biblioitemnumber=$biblioitemnumber");
308 $sth=$dbh->prepare("select biblionumber,biblioitemnumber from
309 biblioitems where lccn=$q_lccn");
312 if (my ($biblionumber, $biblioitemnumber) = $sth->fetchrow) {
314 $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");
317 while (my ($barcode, $itemnotes, $title, $author) = $sth->fetchrow) {
318 $itemdata.="<tr><td align=center>$barcode</td><td><u>$title</u></td><td>$author</td><td>$itemnotes</td></tr>\n";
325 <table border=1 bgcolor=#dddddd>
327 <th colspan=4>Existing Items with LCCN $lccn</th>
330 <th>Barcode</th><th>Title</th><th>Author</th><th>Notes</th></tr>
337 # my $sth=$dbh->prepare("select max(barcode) from items");
339 # my ($maxbarcode) = $sth->fetchrow;
341 # print STDERR "MaxBarCode: $maxbarcode";
344 <h2>Section Three: Specific Item Information</h2>
346 <input type=hidden name=newitem value=1>
347 <input type=hidden name=biblionumber value=$biblionumber>
348 <input type=hidden name=biblioitemnumber value=$biblioitemnumber>
350 <!-- tr><td>BARCODE</td><td><input name=barcode size=10 value=\$maxbarcode -->
351 <tr><td>BARCODE</td><td><input name=barcode size=10 value=$biblionumber>
352 Home Branch: <select name=homebranch>
354 my $branches=getbranches();
355 foreach my $key (sort(keys %$branches)) {
356 print "<option value=\"$key\">$branches->{$key}->{'branchname'}</option>";
360 </tr><td colspan=2>Replacement Price: <input name=replacementprice size=10></td></tr>
361 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
362 wrap=physical></textarea></td></tr>
364 <input type=submit value="Add Item">
366 <h3>LCCN $lccn Information</h3>
375 <input type=hidden name=lccn value='$lccn'>
376 <input type=hidden name=checkforbiblio value=1>
378 <tr><th colspan=2>Section One: Copyright Information</th></tr>
379 <tr><td>Title</td><td><input name=title size=40></td></tr>
380 <tr><td>Subtitle</td><td><input name=subtitle size=40></td></tr>
381 <tr><td>Author</td><td><input name=author size=40></td></tr>
382 <tr><td>Series Title<br>(if applicable)</td><td><input name=seriestitle
384 <tr><td>Copyright Date</td><td><input name=copyrightdate size=10></td></tr>
385 <tr><td>Notes</td><td><textarea name=notes rows=4 cols=40
386 wrap=physical></textarea></td></tr>
388 <input type=submit value="Add new Bibliography">
394 <h2>Adding new items to the Library Inventory</h2>
395 To add a new item, scan or type the LCCN number:
398 LCCN: <input name=lccn>
401 <a href=addbooks.pl?lccn=NULL>Enter book with no LCCN</a>
403 Or use the <a href=marcimport.pl>MARC Importing tool</a>
416 <table border=1 width=70% bgcolor=#bbddbb>
420 Koha stores data in three sections.
423 <li>The first section records bibliographic data such as title, author and
424 copyright for a particular work.
425 <li>The second records bibliographic data for a particular publication of that
426 work, such as ISBN number, physical description, publisher information, etc.
427 <li>The third section holds specific item information, such as the bar code