1 package C4::Catalogue; #asummes C4/Acquisitions.pm
3 # Continue working on updateItem!!!!!!
5 # updateItem is looking not bad. Need to add addSubfield and deleteSubfield
8 # Trying to track down $dbh's that aren't disconnected....
16 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
18 # set the version for version checking
22 @EXPORT = qw(&newBiblio &newBiblioItem &newItem &updateBiblio &updateBiblioItem
23 &updateItem &changeSubfield);
24 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
26 # your exported package globals go here,
27 # as well as any optionally exported functions
29 @EXPORT_OK = qw($Var1 %Hashit);
32 # non-exported package globals go here
33 use vars qw(@more $stuff);
35 # initalize package globals, first exported ones
41 # then the others (which are still accessible as $Some::Module::stuff)
45 # all file-scoped lexicals must be created before
46 # the functions below that use them.
48 # file-private lexicals go here
52 # here's a file-private function as a closure,
53 # callable as &$priv_func; it cannot be prototyped.
58 # make all your functions, whether exported or not;
63 # This subroutine makes no modifications to the MARC tables. MARC records are
64 # only created when new biblioitems are added.
65 my ($env, $biblio) = @_;
67 my $subject=$biblio->{'subject'};
68 my $additionalauthors=$biblio->{'additionalauthors'};
70 # Why am I doing this? This is a potential race condition. At the very least,
71 # this needs code to ensure that two inserts didn't use the same
74 # Get next biblio number
75 my $sth=$dbh->prepare("select max(biblionumber) from biblio");
77 my ($biblionumber) = $sth->fetchrow;
80 $sth=$dbh->prepare("insert into biblio
81 (biblionumber,title,author,
82 unititle,copyrightdate,
83 serial,seriestitle,notes)
84 values (?, ?, ?, ?, ?, ?, ?, ?)");
85 $sth->execute($biblionumber, $biblio->{'title'}, $biblio->{'author'},
86 $biblio->{'unititle'}, $biblio->{'copyrightdate'},
87 $biblio->{'serial'}, $biblio->{'seriestitle'}, $biblio->{'notes'} );
88 $sth=$dbh->prepare("insert into bibliosubtitle
89 (biblionumber,subtitle)
91 $sth->execute($biblionumber, $biblio->{'subtitle'} );
93 my $sth=$dbh->prepare("insert into bibliosubject
94 (biblionumber,subject)
96 foreach $_ (@$subject) {
97 $sth->execute($biblionumber,$_);
99 my $sth=$dbh->prepare("insert into additionalauthors
100 (biblionumber,author)
102 foreach $_ (@$additionalauthors) {
103 $sth->execute($biblionumber, $_ );
109 # Subroutine changes a subfield value given a subfieldid.
110 my ( $subfieldid, $subfieldvalue )=@_;
113 my $sth=$dbh->prepare("update marc_subfield_table set subfieldvalue=? where subfieldid=?");
114 $sth->execute($subfieldvalue, $subfieldid);
117 return($Subfield_ID, $Subfield_Key);
121 # find a subfieldid given bibid, tag, subfieldcode, subfieldvalue this is
122 # inherently dangerous. There could be multiple subfields that match the given
123 # parameters. What then? What if no subfields match? That one's easy, just
125 my ($bibid,$tag,$subfieldcode,$subfieldvalue) = @_;
129 my $sth=$dbh->prepare("select tagid from marc_$firstdigit\XX_tag_table where bibid=$bibid");
131 my $sti=$dbh->prepare("select subfieldid from marc_subfield_table where tag=? and subfieldcode=? and subfieldvalue=?");
132 $sti->execute($tag, $subfieldcode,$subfieldvalue);
133 while (($subfieldid) = $sti->fetchrow) {
136 if ($resultcounter>1) {
137 # Error condition. Values given did not resolve into a unique record. Don't know what to edit
145 # Add a new subfield to a tag.
148 my $subfieldcode=shift;
149 my $subfieldvalue=shift;
150 my $subfieldorder=shift;
153 unless ($subfieldorder) {
154 my $sth=$dbh->prepare("select max(subfieldorder) from marc_subfield_table where tagid=$tagid");
157 ($subfieldorder) = $sth->fetchrow;
163 my $sth=$dbh->prepare("insert into marc_subfield_table (tagid,bibid,subfieldorder,subfieldcode,subfieldvalue) values (?,?,?,?,?)");
164 $sth->execute($tagid,$bibid,$subfieldorder,$subfieldcode,$subfieldvalue);
169 # Update the biblio with biblionumber $biblio->{'biblionumber'}
170 # I guess this routine should search through all marc records for a record that
171 # has the same biblionumber stored in it, and modify the MARC record as well as
174 # Also, this subroutine should search through the $biblio object and compare it
175 # to the existing record and _LOG ALL CHANGES MADE_ in some way. I'd like for
176 # this logging feature to be usable to undo changes easily.
178 my ($env, $biblio) = @_;
180 my $biblionumber=$biblio->{'biblionumber'};
182 my $sth=$dbh->prepare("select * from biblio where biblionumber=$biblionumber");
184 my $origbiblio=$sth->fetchrow_hashref;
185 $sth=$dbh->prepare("select subtitle from bibliosubtitle where biblionumber=$biblionumber");
187 my ($subtitle)=$sth->fetchrow;
188 $origbiblio->{'subtitle'}=$subtitle;
189 $sth=$dbh->prepare("select author from additionalauthors where biblionumber=$biblionumber");
191 my $origadditionalauthors;
192 while (my ($author) = $sth->fetchrow) {
193 push (@{$origbiblio->{'additionalauthors'}}, $author);
194 $origadditionalauthors->{$author}=1;
196 $sth=$dbh->prepare("select subject from bibliosubject where biblionumber=$biblionumber");
199 while (my ($subject) = $sth->fetchrow) {
200 push (@{$origbiblio->{'subjects'}}, $subject);
201 $origsubjects->{$subject}=1;
205 # Obtain a list of MARC Record_ID's that are tied to this biblio
206 $sth=$dbh->prepare("select bibid from marc_subfield_table where tag='090' and subfieldvalue=$biblionumber and subfieldcode='c'");
209 while (my ($bibid) = $sth->fetchrow) {
210 push(@marcrecords, $bibid);
216 if ($biblio->{'author'} ne $origbiblio->{'author'}) {
217 my $q_author=$dbh->quote($biblio->{'author'});
218 logchange('kohadb', 'change', 'biblio', 'author', $origbiblio->{'author'}, $biblio->{'author'});
219 my $sti=$dbh->prepare("update biblio set author=$q_author where biblionumber=$biblio->{'biblionumber'}");
221 foreach $bibid (@marcrecords) {
222 logchange('marc', 'change', $bibid, '100', 'a', $origbiblio->{'author'}, $biblio->{'author'});
223 changeSubfield($bibid, '100', 'a', $origbiblio->{'author'}, $biblio->{'author'});
226 if ($biblio->{'title'} ne $origbiblio->{'title'}) {
227 my $q_title=$dbh->quote($biblio->{'title'});
228 logchange('kohadb', 'change', 'biblio', 'title', $origbiblio->{'title'}, $biblio->{'title'});
229 my $sti=$dbh->prepare("update biblio set title=$q_title where biblionumber=$biblio->{'biblionumber'}");
231 foreach $Record_ID (@marcrecords) {
232 logchange('marc', 'change', $Record_ID, '245', 'a', $origbiblio->{'title'}, $biblio->{'title'});
233 changeSubfield($Record_ID, '245', 'a', $origbiblio->{'title'}, $biblio->{'title'});
236 if ($biblio->{'subtitle'} ne $origbiblio->{'subtitle'}) {
237 my $q_subtitle=$dbh->quote($biblio->{'subtitle'});
238 logchange('kohadb', 'change', 'biblio', 'subtitle', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
239 my $sti=$dbh->prepare("update bibliosubtitle set subtitle=$q_subtitle where biblionumber=$biblio->{'biblionumber'}");
241 foreach $Record_ID (@marcrecords) {
242 logchange('marc', 'change', $Record_ID, '245', 'b', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
243 changeSubfield($Record_ID, '245', 'b', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
246 if ($biblio->{'unititle'} ne $origbiblio->{'unititle'}) {
247 my $q_unititle=$dbh->quote($biblio->{'unititle'});
248 logchange('kohadb', 'change', 'biblio', 'unititle', $origbiblio->{'unititle'}, $biblio->{'unititle'});
249 my $sti=$dbh->prepare("update biblio set unititle=$q_unititle where biblionumber=$biblio->{'biblionumber'}");
252 if ($biblio->{'notes'} ne $origbiblio->{'notes'}) {
253 my $q_notes=$dbh->quote($biblio->{'notes'});
254 logchange('kohadb', 'change', 'biblio', 'notes', $origbiblio->{'notes'}, $biblio->{'notes'});
255 my $sti=$dbh->prepare("update biblio set notes=$q_notes where biblionumber=$biblio->{'biblionumber'}");
257 foreach $Record_ID (@marcrecords) {
258 logchange('marc', 'change', $Record_ID, '500', 'a', $origbiblio->{'notes'}, $biblio->{'notes'});
259 changeSubfield($Record_ID, '500', 'a', $origbiblio->{'notes'}, $biblio->{'notes'});
262 if ($biblio->{'serial'} ne $origbiblio->{'serial'}) {
263 my $q_serial=$dbh->quote($biblio->{'serial'});
264 logchange('kohadb', 'change', 'biblio', 'serial', $origbiblio->{'serial'}, $biblio->{'serial'});
265 my $sti=$dbh->prepare("update biblio set serial=$q_serial where biblionumber=$biblio->{'biblionumber'}");
268 if ($biblio->{'seriestitle'} ne $origbiblio->{'seriestitle'}) {
269 my $q_seriestitle=$dbh->quote($biblio->{'seriestitle'});
270 logchange('kohadb', 'change', 'biblio', 'seriestitle', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
271 my $sti=$dbh->prepare("update biblio set seriestitle=$q_seriestitle where biblionumber=$biblio->{'biblionumber'}");
273 foreach $Record_ID (@marcrecords) {
274 logchange('marc', 'change', $Record_ID, '440', 'a', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
275 changeSubfield($Record_ID, '440', 'a', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
278 if ($biblio->{'copyrightdate'} ne $origbiblio->{'copyrightdate'}) {
279 my $q_copyrightdate=$dbh->quote($biblio->{'copyrightdate'});
280 logchange('kohadb', 'change', 'biblio', 'copyrightdate', $origbiblio->{'copyrightdate'}, $biblio->{'copyrightdate'});
281 my $sti=$dbh->prepare("update biblio set copyrightdate=$q_copyrightdate where biblionumber=$biblio->{'biblionumber'}");
283 foreach $Record_ID (@marcrecords) {
284 logchange('marc', 'change', $Record_ID, '260', 'c', "c$origbiblio->{'notes'}", "c$biblio->{'notes'}");
285 changeSubfield($Record_ID, '260', 'c', "c$origbiblio->{'notes'}", "c$biblio->{'notes'}");
289 # Check for subject heading changes
293 foreach $newsubject (@{$biblio->{'subject'}}) {
294 $subjects->{$newsubject}=1;
295 if ($origsubjects->{$newsubject}) {
296 $subjects->{$newsubject}=2;
298 my $q_newsubject=$dbh->quote($newsubject);
299 my $sth=$dbh->prepare("insert into bibliosubject (subject,biblionumber) values ($q_newsubject, $biblionumber)");
301 logchange('kohadb', 'add', 'biblio', 'subject', $newsubject);
303 $subfields->{1}->{'Subfield_Mark'}='a';
304 $subfields->{1}->{'Subfield_Value'}=$newsubject;
307 foreach $Record_ID (@marcrecords) {
308 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
309 logchange('marc', 'add', $Record_ID, '650', 'a', $newsubject);
314 foreach $origsubject (keys %$origsubjects) {
315 if ($subjects->{$origsubject} == 1) {
316 my $q_origsubject=$dbh->quote($origsubject);
317 logchange('kohadb', 'delete', 'biblio', '$biblionumber', 'subject', $origsubject);
318 my $sth=$dbh->prepare("delete from bibliosubject where biblionumber=$biblionumber and subject=$q_origsubject");
324 # At the moment this is just a straight copy of the subject code. Needs heavy
325 # modification to work for additional authors, obviously.
326 # Check for additional author changes
328 my $newadditionalauthor='';
329 my $additionalauthors;
330 foreach $newadditionalauthor (@{$biblio->{'additionalauthor'}}) {
331 $additionalauthors->{$newadditionalauthor}=1;
332 if ($origadditionalauthors->{$newadditionalauthor}) {
333 $additionalauthors->{$newadditionalauthor}=2;
335 my $q_newadditionalauthor=$dbh->quote($newadditionalauthor);
336 my $sth=$dbh->prepare("insert into biblioadditionalauthors (additionalauthor,biblionumber) values ($q_newadditionalauthor, $biblionumber)");
338 logchange('kohadb', 'add', 'biblio', 'additionalauthor', $newadditionalauthor);
340 $subfields->{1}->{'Subfield_Mark'}='a';
341 $subfields->{1}->{'Subfield_Value'}=$newadditionalauthor;
344 foreach $Record_ID (@marcrecords) {
345 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
346 logchange('marc', 'add', $Record_ID, '650', 'a', $newadditionalauthor);
350 my $origadditionalauthor;
351 foreach $origadditionalauthor (keys %$origadditionalauthors) {
352 if ($additionalauthors->{$origadditionalauthor} == 1) {
353 my $q_origadditionalauthor=$dbh->quote($origadditionalauthor);
354 logchange('kohadb', 'delete', 'biblio', '$biblionumber', 'additionalauthor', $origadditionalauthor);
355 my $sth=$dbh->prepare("delete from biblioadditionalauthors where biblionumber=$biblionumber and additionalauthor=$q_origadditionalauthor");
365 # Subroutine to log changes to databases
366 # Eventually, this subroutine will be used to create a log of all changes made,
367 # with the possibility of "undo"ing some changes
369 if ($database eq 'kohadb') {
375 print STDERR "KOHA: $type $section $item $original $new\n";
376 } elsif ($database eq 'marc') {
381 my $subfield_ID=shift;
384 print STDERR "MARC: $type $Record_ID $tag $mark $subfield_ID $original $new\n";
389 # Subroutine to add a tag to an existing MARC Record. If a new linkage id is
390 # desired, set $env->{'linkage'} to 1. If an existing linkage id should be
391 # set, set $env->{'linkid'} to the link number.
392 my ($env, $Record_ID, $tag, $Indicator1, $Indicator2, $subfields) = @_;
394 ($Indicator1) || ($Indicator1=' ');
395 ($Indicator2) || ($Indicator2=' ');
396 my $firstdigit=substr($tag,0,1);
398 foreach (sort keys %$subfields) {
399 my $Subfield_Mark=$subfields->{$_}->{'Subfield_Mark'};
400 my $Subfield_Value=$subfields->{$_}->{'Subfield_Value'};
401 my $q_Subfield_Value=$dbh->quote($Subfield_Value);
403 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '$Subfield_Mark', $q_Subfield_Value)");
406 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_Mark, Subfield_Value) values ('$Subfield_Mark', $q_Subfield_Value)");
408 my $Subfield_Key=$dbh->{'mysql_insertid'};
409 $Subfield_ID=$Subfield_Key;
410 $sth=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_ID=$Subfield_ID where Subfield_Key=$Subfield_Key");
414 if (my $linkid=$env->{'linkid'}) {
416 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$linkid')");
419 my $sth=$dbh->prepare("insert into $firstdigit\XX_Tag_Table (Indicator1, Indicator2, Tag, Subfield_ID) values ('$Indicator1', '$Indicator2', '$tag', $Subfield_ID)");
421 my $Tag_Key=$dbh->{'mysql_insertid'};
423 $sth=$dbh->prepare("update $firstdigit\XX_Tag_Table set Tag_ID=$Tag_ID where Tag_Key=$Tag_Key");
425 $sth=$dbh->prepare("insert into Bib_Table (Record_ID, Tag_$firstdigit\XX_ID) values ($Record_ID, $Tag_ID)");
427 if ($env->{'linkage'}) {
428 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$Tag_ID')");
434 return ($env, $Tag_ID);
438 my ($env, $biblioitem) = @_;
440 my $biblionumber=$biblioitem->{'biblionumber'};
441 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
442 my $volume=$biblioitem->{'volume'};
443 my $q_volume=$dbh->quote($volume);
444 my $number=$biblioitem->{'number'};
445 my $q_number=$dbh->quote($number);
446 my $classification=$biblioitem->{'classification'};
447 my $q_classification=$dbh->quote($classification);
448 my $itemtype=$biblioitem->{'itemtype'};
449 my $q_itemtype=$dbh->quote($itemtype);
450 my $isbn=$biblioitem->{'isbn'};
451 my $q_isbn=$dbh->quote($isbn);
452 my $issn=$biblioitem->{'issn'};
453 my $q_issn=$dbh->quote($issn);
454 my $dewey=$biblioitem->{'dewey'};
456 ($dewey == 0) && ($dewey='');
457 my $subclass=$biblioitem->{'subclass'};
458 my $q_subclass=$dbh->quote($subclass);
459 my $publicationyear=$biblioitem->{'publicationyear'};
460 my $publishercode=$biblioitem->{'publishercode'};
461 my $q_publishercode=$dbh->quote($publishercode);
462 my $volumedate=$biblioitem->{'volumedate'};
463 my $q_volumedate=$dbh->quote($volumedate);
464 my $illus=$biblioitem->{'illus'};
465 my $q_illus=$dbh->quote($illus);
466 my $pages=$biblioitem->{'pages'};
467 my $q_pages=$dbh->quote($pages);
468 my $notes=$biblioitem->{'notes'};
469 my $q_notes=$dbh->quote($notes);
470 my $size=$biblioitem->{'size'};
471 my $q_size=$dbh->quote($size);
472 my $place=$biblioitem->{'place'};
473 my $q_place=$dbh->quote($place);
474 my $lccn=$biblioitem->{'lccn'};
475 my $q_lccn=$dbh->quote($lccn);
478 # Unless the $env->{'marconly'} flag is set, update the biblioitems table with
481 unless ($env->{'marconly'}) {
482 #my $sth=$dbh->prepare("lock tables biblioitems write");
484 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
486 my ($biblioitemnumber) =$sth->fetchrow;
488 $sth=$dbh->prepare("insert into biblioitems (biblionumber,biblioitemnumber,volume,number,classification,itemtype,isbn,issn,dewey,subclass,publicationyear,publishercode,volumedate,illus,pages,notes,size,place,lccn) values ($biblionumber, $biblioitemnumber, $q_volume, $q_number, $q_classification, $q_itemtype, $q_isbn, $q_issn, $dewey, $q_subclass, $publicationyear, $q_publishercode, $q_volumedate, $q_illus, $q_pages,$q_notes, $q_size, $q_place, $q_lccn)");
490 #my $sth=$dbh->prepare("unlock tables");
495 # Should we check if there is already a biblioitem/marc with the
496 # same isbn/lccn/issn?
498 my $sth=$dbh->prepare("select title,unititle,seriestitle,copyrightdate,notes,author from biblio where biblionumber=$biblionumber");
500 my ($title, $unititle,$seriestitle,$copyrightdate,$biblionotes,$author) = $sth->fetchrow;
501 $sth=$dbh->prepare("select subtitle from bibliosubtitle where biblionumber=$biblionumber");
503 my ($subtitle) = $sth->fetchrow;
504 $sth=$dbh->prepare("select author from additionalauthors where biblionumber=$biblionumber");
506 my @additionalauthors;
507 while (my ($additionalauthor) = $sth->fetchrow) {
508 push (@additionalauthors, $additionalauthor);
510 $sth=$dbh->prepare("select subject from bibliosubject where biblionumber=$biblionumber");
513 while (my ($subject) = $sth->fetchrow) {
514 push (@subjects, $subject);
519 $sth=$dbh->prepare("insert into Resource_Table (Record_ID) values (0)");
521 my $Resource_ID=$dbh->{'mysql_insertid'};
522 my $Record_ID=$Resource_ID;
523 $sth=$dbh->prepare("update Resource_Table set Record_ID=$Record_ID where Resource_ID=$Resource_ID");
529 $subfields->{1}->{'Subfield_Mark'}='a';
530 $subfields->{1}->{'Subfield_Value'}=$title;
532 $subfields->{2}->{'Subfield_Mark'}='b';
533 $subfields->{2}->{'Subfield_Value'}=$subtitle;
536 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
542 $subfields->{1}->{'Subfield_Mark'}='a';
543 $subfields->{1}->{'Subfield_Value'}=$author;
545 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
550 $subfields->{1}->{'Subfield_Mark'}='a';
551 $subfields->{1}->{'Subfield_Value'}=$seriestitle;
553 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
558 $subfields->{1}->{'Subfield_Mark'}='a';
559 $subfields->{1}->{'Subfield_Value'}=$biblionotes;
560 $subfields->{2}->{'Subfield_Mark'}='3';
561 $subfields->{2}->{'Subfield_Value'}='biblio';
563 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
566 foreach (@additionalauthors) {
568 (next) unless ($author);
570 $subfields->{1}->{'Subfield_Mark'}='a';
571 $subfields->{1}->{'Subfield_Value'}=$author;
572 $subfields->{2}->{'Subfield_Mark'}='e';
573 $subfields->{2}->{'Subfield_Value'}='author';
575 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
579 (next) unless ($illus);
581 $subfields->{1}->{'Subfield_Mark'}='a';
582 $subfields->{1}->{'Subfield_Value'}=$illus;
583 $subfields->{2}->{'Subfield_Mark'}='e';
584 $subfields->{2}->{'Subfield_Value'}='illustrator';
586 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
589 foreach (@subjects) {
591 (next) unless ($subject);
593 $subfields->{1}->{'Subfield_Mark'}='a';
594 $subfields->{1}->{'Subfield_Value'}=$subject;
596 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
603 $subfields->{1}->{'Subfield_Mark'}='a';
604 $subfields->{1}->{'Subfield_Value'}=$isbn;
606 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
611 $subfields->{1}->{'Subfield_Mark'}='a';
612 $subfields->{1}->{'Subfield_Value'}=$lccn;
614 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
619 $subfields->{1}->{'Subfield_Mark'}='a';
620 $subfields->{1}->{'Subfield_Value'}=$issn;
622 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
627 $subfields->{1}->{'Subfield_Mark'}='a';
628 $subfields->{1}->{'Subfield_Value'}=$dewey;
630 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
632 # DEWEY subclass and itemtype
635 $subfields->{1}->{'Subfield_Mark'}='a';
636 $subfields->{1}->{'Subfield_Value'}=$itemtype;
637 $subfields->{2}->{'Subfield_Mark'}='b';
638 $subfields->{2}->{'Subfield_Value'}=$subclass;
639 $subfields->{3}->{'Subfield_Mark'}='c';
640 $subfields->{3}->{'Subfield_Value'}=$biblionumber;
641 $subfields->{4}->{'Subfield_Mark'}='d';
642 $subfields->{4}->{'Subfield_Value'}=$biblioitemnumber;
644 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
649 $subfields->{1}->{'Subfield_Mark'}='a';
650 $subfields->{1}->{'Subfield_Value'}=$place;
651 $subfields->{2}->{'Subfield_Mark'}='b';
652 $subfields->{2}->{'Subfield_Value'}=$publishercode;
653 $subfields->{3}->{'Subfield_Mark'}='c';
654 $subfields->{3}->{'Subfield_Value'}=$publicationyear;
655 if ($copyrightdate) {
656 $subfields->{4}->{'Subfield_Mark'}='c';
657 $subfields->{4}->{'Subfield_Value'}="c$copyrightdate";
660 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
663 if ($pages || $size) {
665 $subfields->{1}->{'Subfield_Mark'}='a';
666 $subfields->{1}->{'Subfield_Value'}=$pages;
667 $subfields->{2}->{'Subfield_Mark'}='c';
668 $subfields->{2}->{'Subfield_Value'}=$size;
670 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
673 if ($volume || $number) {
675 $subfields->{1}->{'Subfield_Mark'}='v';
676 $subfields->{1}->{'Subfield_Value'}=$volume;
677 $subfields->{2}->{'Subfield_Mark'}='n';
678 $subfields->{2}->{'Subfield_Value'}=$number;
680 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
685 $subfields->{1}->{'Subfield_Mark'}='a';
686 $subfields->{1}->{'Subfield_Value'}=$notes;
687 $subfields->{2}->{'Subfield_Mark'}='3';
688 $subfields->{2}->{'Subfield_Value'}='biblioitem';
690 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
694 return ($env, $Record_ID);
697 sub updateBiblioItem {
698 # Update the biblioitem with biblioitemnumber $biblioitem->{'biblioitemnumber'}
700 # This routine should also check to see which fields are actually being
701 # modified, and log all changes.
703 my ($env, $biblioitem) = @_;
706 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
707 my $sth=$dbh->prepare("select * from biblioitems where biblioitemnumber=$biblioitemnumber");
708 # obi = original biblioitem
709 my $obi=$sth->fetchrow_hashref;
710 $sth=$dbh->prepare("select B.Record_ID from Bib_Table B, 0XX_Tag_Table T, 0XX_Subfield_Table S where B.Tag_0XX_ID=T.Tag_ID and T.Subfield_ID=S.Subfield_ID and T.Tag='090' and S.Subfield_Mark='c' and S.Subfield_Value=$biblioitemnumber");
712 my ($Record_ID) = $sth->fetchrow;
713 if ($biblioitem->{'biblionumber'} ne $obi->{'biblionumber'}) {
714 logchange('kohadb', 'change', 'biblioitems', 'biblionumber', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
715 my $sth=$dbh->prepare("update biblioitems set biblionumber=$biblioitem->{'biblionumber'} where biblioitemnumber=$biblioitemnumber");
716 logchange('marc', 'change', $Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
717 changeSubfield($Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
719 if ($biblioitem->{'volume'} ne $obi->{'volume'}) {
720 logchange('kohadb', 'change', 'biblioitems', 'volume', $obi->{'volume'}, $biblioitem->{'volume'});
721 my $q_volume=$dbh->quote($biblioitem->{'volume'});
722 my $sth=$dbh->prepare("update biblioitems set volume=$q_volume where biblioitemnumber=$biblioitemnumber");
723 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
724 changeSubfield($Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
726 if ($biblioitem->{'number'} ne $obi->{'number'}) {
727 logchange('kohadb', 'change', 'biblioitems', 'number', $obi->{'number'}, $biblioitem->{'number'});
728 my $q_number=$dbh->quote($biblioitem->{'number'});
729 my $sth=$dbh->prepare("update biblioitems set number=$q_number where biblioitemnumber=$biblioitemnumber");
730 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
731 changeSubfield($Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
733 if ($biblioitem->{'itemtype'} ne $obi->{'itemtype'}) {
734 logchange('kohadb', 'change', 'biblioitems', 'itemtype', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
735 my $q_itemtype=$dbh->quote($biblioitem->{'itemtype'});
736 my $sth=$dbh->prepare("update biblioitems set itemtype=$q_itemtype where biblioitemnumber=$biblioitemnumber");
737 logchange('marc', 'change', $Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
738 changeSubfield($Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
740 if ($biblioitem->{'isbn'} ne $obi->{'isbn'}) {
741 logchange('kohadb', 'change', 'biblioitems', 'isbn', $obi->{'isbn'}, $biblioitem->{'isbn'});
742 my $q_isbn=$dbh->quote($biblioitem->{'isbn'});
743 my $sth=$dbh->prepare("update biblioitems set isbn=$q_isbn where biblioitemnumber=$biblioitemnumber");
744 logchange('marc', 'change', $Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
745 changeSubfield($Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
747 if ($biblioitem->{'issn'} ne $obi->{'issn'}) {
748 logchange('kohadb', 'change', 'biblioitems', 'issn', $obi->{'issn'}, $biblioitem->{'issn'});
749 my $q_issn=$dbh->quote($biblioitem->{'issn'});
750 my $sth=$dbh->prepare("update biblioitems set issn=$q_issn where biblioitemnumber=$biblioitemnumber");
751 logchange('marc', 'change', $Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
752 changeSubfield($Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
754 if ($biblioitem->{'dewey'} ne $obi->{'dewey'}) {
755 logchange('kohadb', 'change', 'biblioitems', 'dewey', $obi->{'dewey'}, $biblioitem->{'dewey'});
756 my $sth=$dbh->prepare("update biblioitems set dewey=$biblioitem->{'dewey'} where biblioitemnumber=$biblioitemnumber");
757 logchange('marc', 'change', $Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
758 changeSubfield($Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
760 if ($biblioitem->{'subclass'} ne $obi->{'subclass'}) {
761 logchange('kohadb', 'change', 'biblioitems', 'subclass', $obi->{'subclass'}, $biblioitem->{'subclass'});
762 my $q_subclass=$dbh->quote($biblioitem->{'subclass'});
763 my $sth=$dbh->prepare("update biblioitems set subclass=$q_subclass where biblioitemnumber=$biblioitemnumber");
764 logchange('marc', 'change', $Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
765 changeSubfield($Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
767 if ($biblioitem->{'place'} ne $obi->{'place'}) {
768 logchange('kohadb', 'change', 'biblioitems', 'place', $obi->{'place'}, $biblioitem->{'place'});
769 my $q_place=$dbh->quote($biblioitem->{'place'});
770 my $sth=$dbh->prepare("update biblioitems set place=$q_place where biblioitemnumber=$biblioitemnumber");
771 logchange('marc', 'change', $Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
772 changeSubfield($Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
774 if ($biblioitem->{'publishercode'} ne $obi->{'publishercode'}) {
775 logchange('kohadb', 'change', 'biblioitems', 'publishercode', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
776 my $q_publishercode=$dbh->quote($biblioitem->{'publishercode'});
777 my $sth=$dbh->prepare("update biblioitems set publishercode=$q_publishercode where biblioitemnumber=$biblioitemnumber");
778 logchange('marc', 'change', $Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
779 changeSubfield($Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
781 if ($biblioitem->{'publicationyear'} ne $obi->{'publicationyear'}) {
782 logchange('kohadb', 'change', 'biblioitems', 'publicationyear', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
783 my $q_publicationyear=$dbh->quote($biblioitem->{'publicationyear'});
784 my $sth=$dbh->prepare("update biblioitems set publicationyear=$q_publicationyear where biblioitemnumber=$biblioitemnumber");
785 logchange('marc', 'change', $Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
786 changeSubfield($Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
788 if ($biblioitem->{'illus'} ne $obi->{'illus'}) {
789 logchange('kohadb', 'change', 'biblioitems', 'illus', $obi->{'illus'}, $biblioitem->{'illus'});
790 my $q_illus=$dbh->quote($biblioitem->{'illus'});
791 my $sth=$dbh->prepare("update biblioitems set illus=$q_illus where biblioitemnumber=$biblioitemnumber");
792 logchange('marc', 'change', $Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
793 changeSubfield($Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
795 if ($biblioitem->{'pages'} ne $obi->{'pages'}) {
796 logchange('kohadb', 'change', 'biblioitems', 'pages', $obi->{'pages'}, $biblioitem->{'pages'});
797 my $q_pages=$dbh->quote($biblioitem->{'pages'});
798 my $sth=$dbh->prepare("update biblioitems set pages=$q_pages where biblioitemnumber=$biblioitemnumber");
799 logchange('marc', 'change', $Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
800 changeSubfield($Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
802 if ($biblioitem->{'size'} ne $obi->{'size'}) {
803 logchange('kohadb', 'change', 'biblioitems', 'size', $obi->{'size'}, $biblioitem->{'size'});
804 my $q_size=$dbh->quote($biblioitem->{'size'});
805 my $sth=$dbh->prepare("update biblioitems set size=$q_size where biblioitemnumber=$biblioitemnumber");
806 logchange('marc', 'change', $Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
807 changeSubfield($Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
809 if ($biblioitem->{'notes'} ne $obi->{'notes'}) {
810 logchange('kohadb', 'change', 'biblioitems', 'notes', $obi->{'notes'}, $biblioitem->{'notes'});
811 my $q_notes=$dbh->quote($biblioitem->{'notes'});
812 my $sth=$dbh->prepare("update biblioitems set notes=$q_notes where biblioitemnumber=$biblioitemnumber");
813 logchange('marc', 'change', $Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
814 changeSubfield($Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
816 if ($biblioitem->{'lccn'} ne $obi->{'lccn'}) {
817 logchange('kohadb', 'change', 'biblioitems', 'lccn', $obi->{'lccn'}, $biblioitem->{'lccn'});
818 my $q_lccn=$dbh->quote($biblioitem->{'lccn'});
819 my $sth=$dbh->prepare("update biblioitems set lccn=$q_lccn where biblioitemnumber=$biblioitemnumber");
820 logchange('marc', 'change', $Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
821 changeSubfield($Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
830 my ($env, $Record_ID, $item) = @_;
832 my $barcode=$item->{'barcode'};
833 my $q_barcode=$dbh->quote($barcode);
834 my $biblionumber=$item->{'biblionumber'};
835 my $biblioitemnumber=$item->{'biblioitemnumber'};
836 my $dateaccessioned=$item->{'dateaccessioned'};
837 my $booksellerid=$item->{'booksellerid'};
838 my $q_booksellerid=$dbh->quote($booksellerid);
839 my $homebranch=$item->{'homebranch'};
840 my $q_homebranch=$dbh->quote($homebranch);
841 my $holdingbranch=$item->{'holdingbranch'};
842 my $price=$item->{'price'};
843 my $replacementprice=$item->{'replacementprice'};
844 my $replacementpricedate=$item->{'replacementpricedate'};
845 my $q_replacementpricedate=$dbh->quote($replacementpricedate);
846 my $notforloan=$item->{'notforloan'};
847 my $itemlost=$item->{'itemlost'};
848 my $wthdrawn=$item->{'wthdrawn'};
849 my $restricted=$item->{'restricted'};
850 my $itemnotes=$item->{'itemnotes'};
851 my $q_itemnotes=$dbh->quote($itemnotes);
852 my $itemtype=$item->{'itemtype'};
853 my $subclass=$item->{'subclass'};
857 unless ($env->{'marconly'}) {
858 my $sth=$dbh->prepare("select max(itemnumber) from items");
860 my ($itemnumber) =$sth->fetchrow;
862 $sth=$dbh->prepare("insert into items (itemnumber,biblionumber,biblioitemnumber,barcode,dateaccessioned,booksellerid,homebranch,price,replacementprice,replacementpricedate,notforloan,itemlost,wthdrawn,restricted,itemnotes) values ($itemnumber,$biblionumber,$biblioitemnumber,$q_barcode,$dateaccessioned,$q_booksellerid,$q_homebranch,$price,$q_replacementpricedate,$notforloan,$itemlost,$wthdrawn,$restricted,$q_itemnotes)");
869 $subfields->{1}->{'Subfield_Mark'}='p';
870 $subfields->{1}->{'Subfield_Value'}=$barcode;
871 $subfields->{2}->{'Subfield_Mark'}='d';
872 $subfields->{2}->{'Subfield_Value'}=$dateaccessioned;
873 $subfields->{3}->{'Subfield_Mark'}='e';
874 $subfields->{3}->{'Subfield_Value'}=$booksellerid;
875 $subfields->{4}->{'Subfield_Mark'}='b';
876 $subfields->{4}->{'Subfield_Value'}=$homebranch;
877 $subfields->{5}->{'Subfield_Mark'}='l';
878 $subfields->{5}->{'Subfield_Value'}=$holdingbranch;
879 $subfields->{6}->{'Subfield_Mark'}='c';
880 $subfields->{6}->{'Subfield_Value'}=$price;
881 $subfields->{7}->{'Subfield_Mark'}='c';
882 $subfields->{7}->{'Subfield_Value'}=$replacementprice;
883 $subfields->{8}->{'Subfield_Mark'}='d';
884 $subfields->{8}->{'Subfield_Value'}=$replacementpricedate;
886 $subfields->{9}->{'Subfield_Mark'}='h';
887 $subfields->{9}->{'Subfield_Value'}='Not for loan';
890 $subfields->{10}->{'Subfield_Mark'}='j';
891 $subfields->{10}->{'Subfield_Value'}='Item lost';
894 $subfields->{11}->{'Subfield_Mark'}='j';
895 $subfields->{11}->{'Subfield_Value'}='Item withdrawn';
898 $subfields->{12}->{'Subfield_Mark'}='z';
899 $subfields->{12}->{'Subfield_Value'}=$itemnotes;
904 ($env, $Tag_ID) = addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
906 $env->{'linkid'}=$Tag_ID;
909 $subfields2->{1}->{'Subfield_Mark'}='a';
910 $subfields2->{1}->{'Subfield_Value'}='Coast Mountains School District';
911 $subfields2->{1}->{'Subfield_Mark'}='b';
912 $subfields2->{1}->{'Subfield_Value'}=$homebranch;
913 $subfields2->{1}->{'Subfield_Mark'}='c';
914 $subfields2->{1}->{'Subfield_Value'}=$itemtype;
915 $subfields2->{2}->{'Subfield_Mark'}='m';
916 $subfields2->{2}->{'Subfield_Value'}=$subclass;
917 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields2);
922 # Update the item with itemnumber $item->{'itemnumber'}
923 # This routine should also modify the corresponding MARC record data. (852 and
924 # 876 tags with 876p tag the same as $item->{'barcode'}
926 # This routine should also check to see which fields are actually being
927 # modified, and log all changes.
929 my ($env, $item) = @_;
931 my $itemnumber=$item->{'itemnumber'};
932 my $biblionumber=$item->{'biblionumber'};
933 my $biblioitemnumber=$item->{'biblioitemnumber'};
934 my $barcode=$item->{'barcode'};
935 my $dateaccessioned=$item->{'dateaccessioned'};
936 my $booksellerid=$item->{'booksellerid'};
937 my $homebranch=$item->{'homebranch'};
938 my $price=$item->{'price'};
939 my $replacementprice=$item->{'replacementprice'};
940 my $replacementpricedate=$item->{'replacementpricedate'};
941 my $multivolume=$item->{'multivolume'};
942 my $stack=$item->{'stack'};
943 my $notforloan=$item->{'notforloan'};
944 my $itemlost=$item->{'itemlost'};
945 my $wthdrawn=$item->{'wthdrawn'};
946 my $bulk=$item->{'bulk'};
947 my $restricted=$item->{'restricted'};
948 my $binding=$item->{'binding'};
949 my $itemnotes=$item->{'itemnotes'};
950 my $holdingbranch=$item->{'holdingbranch'};
951 my $interim=$item->{'interim'};
952 my $sth=$dbh->prepare("select * from items where itemnumber=$itemnumber");
954 my $olditem=$sth->fetchrow_hashref;
955 my $q_barcode=$dbh->quote($olditem->{'barcode'});
956 $sth=$dbh->prepare("select S.Subfield_ID, B.Record_ID from 8XX_Subfield_Table S, 8XX_Tag_Table T, Bib_Table B where B.Tag_8XX_ID=T.Tag_ID and T.Subfield_ID=S.Subfield_ID and Subfield_Mark='p' and Subfield_Value=$q_barcode");
958 my ($Subfield876_ID, $Record_ID) = $sth->fetchrow;
959 $sth=$dbh->prepare("select Subfield_Value from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_ID=$Subfield876_ID");
961 my ($link) = $sth->fetchrow;
962 $sth=$dbh->prepare("select Subfield_ID from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_Value=$link and !(Subfield_ID=$Subfield876_ID)");
964 my ($Subfield852_ID) = $sth->fetchrow;
966 if ($item->{'barcode'} ne $olditem->{'barcode'}) {
967 logchange('kohadb', 'change', 'items', 'barcode', $olditem->{'barcode'}, $item->{'barcode'});
968 my $q_barcode=$dbh->quote($item->{'barcode'});
969 my $sth=$dbh->prepare("update items set barcode=$q_barcode where itemnumber=$itemnumber");
971 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'p', $olditem->{'barcode'}, $item->{'barcode'}, $Subfield876_ID);
972 logchange('marc', 'change', $Record_ID, '876', 'p', $Subfield_Key, $olditem->{'barcode'}, $item->{'barcode'});
974 if ($item->{'booksellerid'} ne $olditem->{'booksellerid'}) {
975 logchange('kohadb', 'change', 'items', 'booksellerid', $olditem->{'booksellerid'}, $item->{'booksellerid'});
976 my $q_booksellerid=$dbh->quote($item->{'booksellerid'});
977 my $sth=$dbh->prepare("update items set booksellerid=$q_booksellerid where itemnumber=$itemnumber");
979 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'e', $olditem->{'booksellerid'}, $item->{'booksellerid'}, $Subfield876_ID);
980 logchange('marc', 'change', $Record_ID, '876', 'e', $Subfield_Key, $olditem->{'booksellerid'}, $item->{'booksellerid'});
982 if ($item->{'dateaccessioned'} ne $olditem->{'dateaccessioned'}) {
983 logchange('kohadb', 'change', 'items', 'dateaccessioned', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
984 my $q_dateaccessioned=$dbh->quote($item->{'dateaccessioned'});
985 my $sth=$dbh->prepare("update items set dateaccessioned=$q_dateaccessioned where itemnumber=$itemnumber");
987 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'd', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'}, $Subfield876_ID);
988 logchange('marc', 'change', $Record_ID, '876', 'd', $Subfield_Key, $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
990 if ($item->{'homebranch'} ne $olditem->{'homebranch'}) {
991 logchange('kohadb', 'change', 'items', 'homebranch', $olditem->{'homebranch'}, $item->{'homebranch'});
992 my $q_homebranch=$dbh->quote($item->{'homebranch'});
993 my $sth=$dbh->prepare("update items set homebranch=$q_homebranch where itemnumber=$itemnumber");
995 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'b', $olditem->{'homebranch'}, $item->{'homebranch'}, $Subfield876_ID);
996 logchange('marc', 'change', $Record_ID, '876', 'b', $Subfield_Key, $olditem->{'homebranch'}, $item->{'homebranch'});
998 if ($item->{'holdingbranch'} ne $olditem->{'holdingbranch'}) {
999 logchange('kohadb', 'change', 'items', 'holdingbranch', $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
1000 my $q_holdingbranch=$dbh->quote($item->{'holdingbranch'});
1001 my $sth=$dbh->prepare("update items set holdingbranch=$q_holdingbranch where itemnumber=$itemnumber");
1003 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'l', $olditem->{'holdingbranch'}, $item->{'holdingbranch'}, $Subfield876_ID);
1004 logchange('marc', 'change', $Record_ID, '876', 'l', $Subfield_Key, $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
1006 if ($item->{'price'} ne $olditem->{'price'}) {
1007 logchange('kohadb', 'change', 'items', 'price', $olditem->{'price'}, $item->{'price'});
1008 my $q_price=$dbh->quote($item->{'price'});
1009 my $sth=$dbh->prepare("update items set price=$q_price where itemnumber=$itemnumber");
1011 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'price'}, $item->{'price'}, $Subfield876_ID);
1012 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'price'}, $item->{'price'});
1014 if ($item->{'itemnotes'} ne $olditem->{'itemnotes'}) {
1015 logchange('kohadb', 'change', 'items', 'itemnotes', $olditem->{'itemnotes'}, $item->{'itemnotes'});
1016 my $q_itemnotes=$dbh->quote($item->{'itemnotes'});
1017 my $sth=$dbh->prepare("update items set itemnotes=$q_itemnotes where itemnumber=$itemnumber");
1019 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'itemnotes'}, $item->{'itemnotes'}, $Subfield876_ID);
1020 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'itemnotes'}, $item->{'itemnotes'});
1022 if ($item->{'notforloan'} ne $olditem->{'notforloan'}) {
1023 logchange('kohadb', 'change', 'items', 'notforloan', $olditem->{'notforloan'}, $item->{'notforloan'});
1024 my $sth=$dbh->prepare("update items set notforloan=$notforloan where itemnumber=$itemnumber");
1026 if ($item->{'notforloan'}) {
1027 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
1028 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
1030 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
1031 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
1034 if ($item->{'itemlost'} ne $olditem->{'itemlost'}) {
1035 logchange('kohadb', 'change', 'items', 'itemlost', $olditem->{'itemlost'}, $item->{'itemlost'});
1036 my $sth=$dbh->prepare("update items set itemlost=$itemlost where itemnumber=$itemnumber");
1038 if ($item->{'itemlost'}) {
1039 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
1040 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
1042 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
1043 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
1046 if ($item->{'wthdrawn'} ne $olditem->{'wthdrawn'}) {
1047 logchange('kohadb', 'change', 'items', 'wthdrawn', $olditem->{'wthdrawn'}, $item->{'wthdrawn'});
1048 my $sth=$dbh->prepare("update items set wthdrawn=$wthdrawn where itemnumber=$itemnumber");
1050 if ($item->{'wthdrawn'}) {
1051 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
1052 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1054 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
1055 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1058 if ($item->{'restricted'} ne $olditem->{'restricted'}) {
1059 logchange('kohadb', 'change', 'items', 'restricted', $olditem->{'restricted'}, $item->{'restricted'});
1060 my $sth=$dbh->prepare("update items set restricted=$restricted where itemnumber=$itemnumber");
1062 if ($item->{'restricted'}) {
1063 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1064 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1066 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1067 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1074 END { } # module clean-up code here (global destructor)