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 $title=$biblio->{'title'};
68 my $q_title=$dbh->quote($title);
69 my $subtitle=$biblio->{'subtitle'};
70 my $q_subtitle=$dbh->quote($subtitle);
71 ($q_subtitle) || ($q_subtitle="''");
72 my $author=$biblio->{'author'};
73 my $q_author=$dbh->quote($author);
74 my $unititle=$biblio->{'unititle'};
75 my $q_unititle=$dbh->quote($unititle);
76 my $copyrightdate=$biblio->{'copyrightdate'};
77 my $serial=$biblio->{'serial'};
78 my $seriestitle=$biblio->{'seriestitle'};
79 my $q_seriestitle=$dbh->quote($seriestitle);
80 my $notes=$biblio->{'notes'};
81 my $q_notes=$dbh->quote($notes);
82 my $subject=$biblio->{'subject'};
83 my $additionalauthors=$biblio->{'additionalauthors'};
84 my $sth=$dbh->prepare("select max(biblionumber) from biblio");
86 my ($biblionumber) = $sth->fetchrow;
88 $sth=$dbh->prepare("insert into biblio (biblionumber,title,author,unititle,copyrightdate,serial,seriestitle,notes) values ($biblionumber,$q_title,$q_author,$q_unititle,$copyrightdate,$serial,$q_seriestitle,$q_notes)");
90 $sth=$dbh->prepare("insert into bibliosubtitle (biblionumber,subtitle) values ($biblionumber,$q_subtitle)");
93 my $q_subject=$dbh->quote($_);
94 my $sth=$dbh->prepare("insert into bibliosubject (biblionumber,subject) values ($biblionumber,$q_subject)");
97 foreach (@$additionalauthors) {
98 my $q_additionalauthor=$dbh->quote($_);
99 my $sth=$dbh->prepare("insert into additionalauthors (biblionumber,author) values ($biblionumber,$q_additionalauthor)");
106 # Subroutine changes a subfield value given a Record_ID, Tag, and Subfield_Mark.
107 # Routine should be made more robust. It currently checks to make sure that
108 # the existing Subfield_Value is the same as the one passed in. What if no
109 # subfield matches this Subfield_OldValue? Create a new Subfield? Maybe check
110 # to make sure that the mark is repeatable first and that no other subfield
111 # with that mark already exists? Ability to return errors and status?
113 # Also, currently, if more than one subfield matches the Record_ID, Tag,
114 # Subfield_Mark, and Subfield_OldValue, only the first one will be modified.
116 # Might be nice to be able to pass a Subfield_ID or Subfield_Key directly to
117 # this routine to remove ambiguity, if possible.
119 # Pass barcode to remove ambiguity for changes to individual items. Look up
120 # field link and sequence number based on barcode.
124 my $firstdigit=substr($tag, 0, 1);
125 my $Subfield_Mark=shift;
126 my $Subfield_OldValue=shift;
127 my $Subfield_Value=shift;
128 my $Subfield_ID=shift;
129 my $Subfield_Key=shift;
131 my $q_Subfield_Value=$dbh->quote($Subfield_Value);
133 # Great. Subfield_Key makes the record absolutely unique. Just make
135 my $sth=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_Value=$q_Subfield_Value where Subfield_Key=$Subfield_Key");
137 } elsif ($Subfield_ID) {
138 # Subfield_ID does not make the record unique. Could be multiple
139 # records with the same mark. This is a bad situation.
140 my $sth=$dbh->prepare("select Subfield_Key, Subfield_Value from $firstdigit\XX_Subfield_Table where Subfield_Mark='$Subfield_Mark' and Subfield_ID=$Subfield_ID");
142 while (my ($key, $Value) = $sth->fetchrow) {
143 if ($Value eq $Subfield_OldValue) {
144 my $sti=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_Value=$q_Subfield_Value where Subfield_Key=$key");
151 my $sth=$dbh->prepare("select S.Subfield_Key, S.Subfield_ID, S.Subfield_Value from Bib_Table B, $firstdigit\XX_Tag_Table T, $firstdigit\XX_Subfield_Table S where B.Record_ID=$Record_ID and B.Tag_$firstdigit\XX_ID=T.Tag_ID and T.Subfield_ID=S.Subfield_ID and S.Subfield_Mark='$Subfield_Mark'");
153 while (my ($key, $ID, $Value) = $sth->fetchrow) {
154 if ($Value eq $Subfield_OldValue) {
155 my $sti=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_Value=$q_Subfield_Value where Subfield_Key=$key");
163 return($Subfield_ID, $Subfield_Key);
167 # Update the biblio with biblionumber $biblio->{'biblionumber'}
168 # I guess this routine should search through all marc records for a record that
169 # has the same biblionumber stored in it, and modify the MARC record as well as
172 # Also, this subroutine should search through the $biblio object and compare it
173 # to the existing record and _LOG ALL CHANGES MADE_ in some way. I'd like for
174 # this logging feature to be usable to undo changes easily.
176 my ($env, $biblio) = @_;
177 my $biblionumber=$biblio->{'biblionumber'};
179 my $sth=$dbh->prepare("select * from biblio where biblionumber=$biblionumber");
181 my $origbiblio=$sth->fetchrow_hashref;
182 $sth=$dbh->prepare("select subtitle from bibliosubtitle where biblionumber=$biblionumber");
184 my ($subtitle)=$sth->fetchrow;
185 $origbiblio->{'subtitle'}=$subtitle;
186 $sth=$dbh->prepare("select author from additionalauthors where biblionumber=$biblionumber");
188 my $origadditionalauthors;
189 while (my ($author) = $sth->fetchrow) {
190 push (@{$origbiblio->{'additionalauthors'}}, $author);
191 $origadditionalauthors->{$author}=1;
193 $sth=$dbh->prepare("select subject from bibliosubject where biblionumber=$biblionumber");
196 while (my ($subject) = $sth->fetchrow) {
197 push (@{$origbiblio->{'subjects'}}, $subject);
198 $origsubjects->{$subject}=1;
202 # Obtain a list of MARC Record_ID's that are tied to this biblio
203 $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_Value=$biblionumber and S.Subfield_Mark='c'");
206 while (my ($Record_ID) = $sth->fetchrow) {
207 push(@marcrecords, $Record_ID);
213 if ($biblio->{'author'} ne $origbiblio->{'author'}) {
214 my $q_author=$dbh->quote($biblio->{'author'});
215 logchange('kohadb', 'change', 'biblio', 'author', $origbiblio->{'author'}, $biblio->{'author'});
216 my $sti=$dbh->prepare("update biblio set author=$q_author where biblionumber=$biblio->{'biblionumber'}");
218 foreach $Record_ID (@marcrecords) {
219 logchange('marc', 'change', $Record_ID, '100', 'a', $origbiblio->{'author'}, $biblio->{'author'});
220 changeSubfield($Record_ID, '100', 'a', $origbiblio->{'author'}, $biblio->{'author'});
223 if ($biblio->{'title'} ne $origbiblio->{'title'}) {
224 my $q_title=$dbh->quote($biblio->{'title'});
225 logchange('kohadb', 'change', 'biblio', 'title', $origbiblio->{'title'}, $biblio->{'title'});
226 my $sti=$dbh->prepare("update biblio set title=$q_title where biblionumber=$biblio->{'biblionumber'}");
228 foreach $Record_ID (@marcrecords) {
229 logchange('marc', 'change', $Record_ID, '245', 'a', $origbiblio->{'title'}, $biblio->{'title'});
230 changeSubfield($Record_ID, '245', 'a', $origbiblio->{'title'}, $biblio->{'title'});
233 if ($biblio->{'subtitle'} ne $origbiblio->{'subtitle'}) {
234 my $q_subtitle=$dbh->quote($biblio->{'subtitle'});
235 logchange('kohadb', 'change', 'biblio', 'subtitle', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
236 my $sti=$dbh->prepare("update bibliosubtitle set subtitle=$q_subtitle where biblionumber=$biblio->{'biblionumber'}");
238 foreach $Record_ID (@marcrecords) {
239 logchange('marc', 'change', $Record_ID, '245', 'b', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
240 changeSubfield($Record_ID, '245', 'b', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
243 if ($biblio->{'unititle'} ne $origbiblio->{'unititle'}) {
244 my $q_unititle=$dbh->quote($biblio->{'unititle'});
245 logchange('kohadb', 'change', 'biblio', 'unititle', $origbiblio->{'unititle'}, $biblio->{'unititle'});
246 my $sti=$dbh->prepare("update biblio set unititle=$q_unititle where biblionumber=$biblio->{'biblionumber'}");
249 if ($biblio->{'notes'} ne $origbiblio->{'notes'}) {
250 my $q_notes=$dbh->quote($biblio->{'notes'});
251 logchange('kohadb', 'change', 'biblio', 'notes', $origbiblio->{'notes'}, $biblio->{'notes'});
252 my $sti=$dbh->prepare("update biblio set notes=$q_notes where biblionumber=$biblio->{'biblionumber'}");
254 foreach $Record_ID (@marcrecords) {
255 logchange('marc', 'change', $Record_ID, '500', 'a', $origbiblio->{'notes'}, $biblio->{'notes'});
256 changeSubfield($Record_ID, '500', 'a', $origbiblio->{'notes'}, $biblio->{'notes'});
259 if ($biblio->{'serial'} ne $origbiblio->{'serial'}) {
260 my $q_serial=$dbh->quote($biblio->{'serial'});
261 logchange('kohadb', 'change', 'biblio', 'serial', $origbiblio->{'serial'}, $biblio->{'serial'});
262 my $sti=$dbh->prepare("update biblio set serial=$q_serial where biblionumber=$biblio->{'biblionumber'}");
265 if ($biblio->{'seriestitle'} ne $origbiblio->{'seriestitle'}) {
266 my $q_seriestitle=$dbh->quote($biblio->{'seriestitle'});
267 logchange('kohadb', 'change', 'biblio', 'seriestitle', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
268 my $sti=$dbh->prepare("update biblio set seriestitle=$q_seriestitle where biblionumber=$biblio->{'biblionumber'}");
270 foreach $Record_ID (@marcrecords) {
271 logchange('marc', 'change', $Record_ID, '440', 'a', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
272 changeSubfield($Record_ID, '440', 'a', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
275 if ($biblio->{'copyrightdate'} ne $origbiblio->{'copyrightdate'}) {
276 my $q_copyrightdate=$dbh->quote($biblio->{'copyrightdate'});
277 logchange('kohadb', 'change', 'biblio', 'copyrightdate', $origbiblio->{'copyrightdate'}, $biblio->{'copyrightdate'});
278 my $sti=$dbh->prepare("update biblio set copyrightdate=$q_copyrightdate where biblionumber=$biblio->{'biblionumber'}");
280 foreach $Record_ID (@marcrecords) {
281 logchange('marc', 'change', $Record_ID, '260', 'c', "c$origbiblio->{'notes'}", "c$biblio->{'notes'}");
282 changeSubfield($Record_ID, '260', 'c', "c$origbiblio->{'notes'}", "c$biblio->{'notes'}");
286 # Check for subject heading changes
290 foreach $newsubject (@{$biblio->{'subject'}}) {
291 $subjects->{$newsubject}=1;
292 if ($origsubjects->{$newsubject}) {
293 $subjects->{$newsubject}=2;
295 my $q_newsubject=$dbh->quote($newsubject);
296 my $sth=$dbh->prepare("insert into bibliosubject (subject,biblionumber) values ($q_newsubject, $biblionumber)");
298 logchange('kohadb', 'add', 'biblio', 'subject', $newsubject);
300 $subfields->{1}->{'Subfield_Mark'}='a';
301 $subfields->{1}->{'Subfield_Value'}=$newsubject;
304 foreach $Record_ID (@marcrecords) {
305 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
306 logchange('marc', 'add', $Record_ID, '650', 'a', $newsubject);
311 foreach $origsubject (keys %$origsubjects) {
312 if ($subjects->{$origsubject} == 1) {
313 my $q_origsubject=$dbh->quote($origsubject);
314 logchange('kohadb', 'delete', 'biblio', '$biblionumber', 'subject', $origsubject);
315 my $sth=$dbh->prepare("delete from bibliosubject where biblionumber=$biblionumber and subject=$q_origsubject");
321 # At the moment this is just a straight copy of the subject code. Needs heavy
322 # modification to work for additional authors, obviously.
323 # Check for additional author changes
325 my $newadditionalauthor='';
326 my $additionalauthors;
327 foreach $newadditionalauthor (@{$biblio->{'additionalauthor'}}) {
328 $additionalauthors->{$newadditionalauthor}=1;
329 if ($origadditionalauthors->{$newadditionalauthor}) {
330 $additionalauthors->{$newadditionalauthor}=2;
332 my $q_newadditionalauthor=$dbh->quote($newadditionalauthor);
333 my $sth=$dbh->prepare("insert into biblioadditionalauthors (additionalauthor,biblionumber) values ($q_newadditionalauthor, $biblionumber)");
335 logchange('kohadb', 'add', 'biblio', 'additionalauthor', $newadditionalauthor);
337 $subfields->{1}->{'Subfield_Mark'}='a';
338 $subfields->{1}->{'Subfield_Value'}=$newadditionalauthor;
341 foreach $Record_ID (@marcrecords) {
342 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
343 logchange('marc', 'add', $Record_ID, '650', 'a', $newadditionalauthor);
347 my $origadditionalauthor;
348 foreach $origadditionalauthor (keys %$origadditionalauthors) {
349 if ($additionalauthors->{$origadditionalauthor} == 1) {
350 my $q_origadditionalauthor=$dbh->quote($origadditionalauthor);
351 logchange('kohadb', 'delete', 'biblio', '$biblionumber', 'additionalauthor', $origadditionalauthor);
352 my $sth=$dbh->prepare("delete from biblioadditionalauthors where biblionumber=$biblionumber and additionalauthor=$q_origadditionalauthor");
362 # Subroutine to log changes to databases
364 if ($database eq 'kohadb') {
370 print STDERR "KOHA: $type $section $item $original $new\n";
371 } elsif ($database eq 'marc') {
376 my $subfield_ID=shift;
379 print STDERR "MARC: $type $Record_ID $tag $mark $subfield_ID $original $new\n";
384 # Subroutine to add a tag to an existing MARC Record. If a new linkage id is
385 # desired, set $env->{'linkage'} to 1. If an existing linkage id should be
386 # set, set $env->{'linkid'} to the link number.
387 my ($env, $Record_ID, $tag, $Indicator1, $Indicator2, $subfields) = @_;
389 ($Indicator1) || ($Indicator1=' ');
390 ($Indicator2) || ($Indicator2=' ');
391 my $firstdigit=substr($tag,0,1);
393 foreach (sort keys %$subfields) {
394 my $Subfield_Mark=$subfields->{$_}->{'Subfield_Mark'};
395 my $Subfield_Value=$subfields->{$_}->{'Subfield_Value'};
396 my $q_Subfield_Value=$dbh->quote($Subfield_Value);
398 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '$Subfield_Mark', $q_Subfield_Value)");
401 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_Mark, Subfield_Value) values ('$Subfield_Mark', $q_Subfield_Value)");
403 my $Subfield_Key=$dbh->{'mysql_insertid'};
404 $Subfield_ID=$Subfield_Key;
405 $sth=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_ID=$Subfield_ID where Subfield_Key=$Subfield_Key");
409 if (my $linkid=$env->{'linkid'}) {
411 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$linkid')");
414 my $sth=$dbh->prepare("insert into $firstdigit\XX_Tag_Table (Indicator1, Indicator2, Tag, Subfield_ID) values ('$Indicator1', '$Indicator2', '$tag', $Subfield_ID)");
416 my $Tag_Key=$dbh->{'mysql_insertid'};
418 $sth=$dbh->prepare("update $firstdigit\XX_Tag_Table set Tag_ID=$Tag_ID where Tag_Key=$Tag_Key");
420 $sth=$dbh->prepare("insert into Bib_Table (Record_ID, Tag_$firstdigit\XX_ID) values ($Record_ID, $Tag_ID)");
422 if ($env->{'linkage'}) {
423 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$Tag_ID')");
429 return ($env, $Tag_ID);
433 my ($env, $biblioitem) = @_;
435 my $biblionumber=$biblioitem->{'biblionumber'};
436 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
437 my $volume=$biblioitem->{'volume'};
438 my $q_volume=$dbh->quote($volume);
439 my $number=$biblioitem->{'number'};
440 my $q_number=$dbh->quote($number);
441 my $classification=$biblioitem->{'classification'};
442 my $q_classification=$dbh->quote($classification);
443 my $itemtype=$biblioitem->{'itemtype'};
444 my $q_itemtype=$dbh->quote($itemtype);
445 my $isbn=$biblioitem->{'isbn'};
446 my $q_isbn=$dbh->quote($isbn);
447 my $issn=$biblioitem->{'issn'};
448 my $q_issn=$dbh->quote($issn);
449 my $dewey=$biblioitem->{'dewey'};
451 ($dewey == 0) && ($dewey='');
452 my $subclass=$biblioitem->{'subclass'};
453 my $q_subclass=$dbh->quote($subclass);
454 my $publicationyear=$biblioitem->{'publicationyear'};
455 my $publishercode=$biblioitem->{'publishercode'};
456 my $q_publishercode=$dbh->quote($publishercode);
457 my $volumedate=$biblioitem->{'volumedate'};
458 my $q_volumedate=$dbh->quote($volumedate);
459 my $illus=$biblioitem->{'illus'};
460 my $q_illus=$dbh->quote($illus);
461 my $pages=$biblioitem->{'pages'};
462 my $q_pages=$dbh->quote($pages);
463 my $notes=$biblioitem->{'notes'};
464 my $q_notes=$dbh->quote($notes);
465 my $size=$biblioitem->{'size'};
466 my $q_size=$dbh->quote($size);
467 my $place=$biblioitem->{'place'};
468 my $q_place=$dbh->quote($place);
469 my $lccn=$biblioitem->{'lccn'};
470 my $q_lccn=$dbh->quote($lccn);
473 # Unless the $env->{'marconly'} flag is set, update the biblioitems table with
476 unless ($env->{'marconly'}) {
477 #my $sth=$dbh->prepare("lock tables biblioitems write");
479 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
481 my ($biblioitemnumber) =$sth->fetchrow;
483 $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)");
485 #my $sth=$dbh->prepare("unlock tables");
490 # Should we check if there is already a biblioitem/marc with the
491 # same isbn/lccn/issn?
493 my $sth=$dbh->prepare("select title,unititle,seriestitle,copyrightdate,notes,author from biblio where biblionumber=$biblionumber");
495 my ($title, $unititle,$seriestitle,$copyrightdate,$biblionotes,$author) = $sth->fetchrow;
496 $sth=$dbh->prepare("select subtitle from bibliosubtitle where biblionumber=$biblionumber");
498 my ($subtitle) = $sth->fetchrow;
499 $sth=$dbh->prepare("select author from additionalauthors where biblionumber=$biblionumber");
501 my @additionalauthors;
502 while (my ($additionalauthor) = $sth->fetchrow) {
503 push (@additionalauthors, $additionalauthor);
505 $sth=$dbh->prepare("select subject from bibliosubject where biblionumber=$biblionumber");
508 while (my ($subject) = $sth->fetchrow) {
509 push (@subjects, $subject);
514 $sth=$dbh->prepare("insert into Resource_Table (Record_ID) values (0)");
516 my $Resource_ID=$dbh->{'mysql_insertid'};
517 my $Record_ID=$Resource_ID;
518 $sth=$dbh->prepare("update Resource_Table set Record_ID=$Record_ID where Resource_ID=$Resource_ID");
524 $subfields->{1}->{'Subfield_Mark'}='a';
525 $subfields->{1}->{'Subfield_Value'}=$title;
527 $subfields->{2}->{'Subfield_Mark'}='b';
528 $subfields->{2}->{'Subfield_Value'}=$subtitle;
531 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
537 $subfields->{1}->{'Subfield_Mark'}='a';
538 $subfields->{1}->{'Subfield_Value'}=$author;
540 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
545 $subfields->{1}->{'Subfield_Mark'}='a';
546 $subfields->{1}->{'Subfield_Value'}=$seriestitle;
548 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
553 $subfields->{1}->{'Subfield_Mark'}='a';
554 $subfields->{1}->{'Subfield_Value'}=$biblionotes;
555 $subfields->{2}->{'Subfield_Mark'}='3';
556 $subfields->{2}->{'Subfield_Value'}='biblio';
558 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
561 foreach (@additionalauthors) {
563 (next) unless ($author);
565 $subfields->{1}->{'Subfield_Mark'}='a';
566 $subfields->{1}->{'Subfield_Value'}=$author;
567 $subfields->{2}->{'Subfield_Mark'}='e';
568 $subfields->{2}->{'Subfield_Value'}='author';
570 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
574 (next) unless ($illus);
576 $subfields->{1}->{'Subfield_Mark'}='a';
577 $subfields->{1}->{'Subfield_Value'}=$illus;
578 $subfields->{2}->{'Subfield_Mark'}='e';
579 $subfields->{2}->{'Subfield_Value'}='illustrator';
581 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
584 foreach (@subjects) {
586 (next) unless ($subject);
588 $subfields->{1}->{'Subfield_Mark'}='a';
589 $subfields->{1}->{'Subfield_Value'}=$subject;
591 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
598 $subfields->{1}->{'Subfield_Mark'}='a';
599 $subfields->{1}->{'Subfield_Value'}=$isbn;
601 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
606 $subfields->{1}->{'Subfield_Mark'}='a';
607 $subfields->{1}->{'Subfield_Value'}=$lccn;
609 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
614 $subfields->{1}->{'Subfield_Mark'}='a';
615 $subfields->{1}->{'Subfield_Value'}=$issn;
617 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
622 $subfields->{1}->{'Subfield_Mark'}='a';
623 $subfields->{1}->{'Subfield_Value'}=$dewey;
625 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
627 # DEWEY subclass and itemtype
630 $subfields->{1}->{'Subfield_Mark'}='a';
631 $subfields->{1}->{'Subfield_Value'}=$itemtype;
632 $subfields->{2}->{'Subfield_Mark'}='b';
633 $subfields->{2}->{'Subfield_Value'}=$subclass;
634 $subfields->{3}->{'Subfield_Mark'}='c';
635 $subfields->{3}->{'Subfield_Value'}=$biblionumber;
636 $subfields->{4}->{'Subfield_Mark'}='d';
637 $subfields->{4}->{'Subfield_Value'}=$biblioitemnumber;
639 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
644 $subfields->{1}->{'Subfield_Mark'}='a';
645 $subfields->{1}->{'Subfield_Value'}=$place;
646 $subfields->{2}->{'Subfield_Mark'}='b';
647 $subfields->{2}->{'Subfield_Value'}=$publishercode;
648 $subfields->{3}->{'Subfield_Mark'}='c';
649 $subfields->{3}->{'Subfield_Value'}=$publicationyear;
650 if ($copyrightdate) {
651 $subfields->{4}->{'Subfield_Mark'}='c';
652 $subfields->{4}->{'Subfield_Value'}="c$copyrightdate";
655 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
658 if ($pages || $size) {
660 $subfields->{1}->{'Subfield_Mark'}='a';
661 $subfields->{1}->{'Subfield_Value'}=$pages;
662 $subfields->{2}->{'Subfield_Mark'}='c';
663 $subfields->{2}->{'Subfield_Value'}=$size;
665 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
668 if ($volume || $number) {
670 $subfields->{1}->{'Subfield_Mark'}='v';
671 $subfields->{1}->{'Subfield_Value'}=$volume;
672 $subfields->{2}->{'Subfield_Mark'}='n';
673 $subfields->{2}->{'Subfield_Value'}=$number;
675 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
680 $subfields->{1}->{'Subfield_Mark'}='a';
681 $subfields->{1}->{'Subfield_Value'}=$notes;
682 $subfields->{2}->{'Subfield_Mark'}='3';
683 $subfields->{2}->{'Subfield_Value'}='biblioitem';
685 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
689 return ($env, $Record_ID);
692 sub updateBiblioItem {
693 # Update the biblioitem with biblioitemnumber $biblioitem->{'biblioitemnumber'}
695 # This routine should also check to see which fields are actually being
696 # modified, and log all changes.
698 my ($env, $biblioitem) = @_;
701 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
702 my $sth=$dbh->prepare("select * from biblioitems where biblioitemnumber=$biblioitemnumber");
703 # obi = original biblioitem
704 my $obi=$sth->fetchrow_hashref;
705 $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");
707 my ($Record_ID) = $sth->fetchrow;
708 if ($biblioitem->{'biblionumber'} ne $obi->{'biblionumber'}) {
709 logchange('kohadb', 'change', 'biblioitems', 'biblionumber', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
710 my $sth=$dbh->prepare("update biblioitems set biblionumber=$biblioitem->{'biblionumber'} where biblioitemnumber=$biblioitemnumber");
711 logchange('marc', 'change', $Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
712 changeSubfield($Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
714 if ($biblioitem->{'volume'} ne $obi->{'volume'}) {
715 logchange('kohadb', 'change', 'biblioitems', 'volume', $obi->{'volume'}, $biblioitem->{'volume'});
716 my $q_volume=$dbh->quote($biblioitem->{'volume'});
717 my $sth=$dbh->prepare("update biblioitems set volume=$q_volume where biblioitemnumber=$biblioitemnumber");
718 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
719 changeSubfield($Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
721 if ($biblioitem->{'number'} ne $obi->{'number'}) {
722 logchange('kohadb', 'change', 'biblioitems', 'number', $obi->{'number'}, $biblioitem->{'number'});
723 my $q_number=$dbh->quote($biblioitem->{'number'});
724 my $sth=$dbh->prepare("update biblioitems set number=$q_number where biblioitemnumber=$biblioitemnumber");
725 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
726 changeSubfield($Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
728 if ($biblioitem->{'itemtype'} ne $obi->{'itemtype'}) {
729 logchange('kohadb', 'change', 'biblioitems', 'itemtype', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
730 my $q_itemtype=$dbh->quote($biblioitem->{'itemtype'});
731 my $sth=$dbh->prepare("update biblioitems set itemtype=$q_itemtype where biblioitemnumber=$biblioitemnumber");
732 logchange('marc', 'change', $Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
733 changeSubfield($Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
735 if ($biblioitem->{'isbn'} ne $obi->{'isbn'}) {
736 logchange('kohadb', 'change', 'biblioitems', 'isbn', $obi->{'isbn'}, $biblioitem->{'isbn'});
737 my $q_isbn=$dbh->quote($biblioitem->{'isbn'});
738 my $sth=$dbh->prepare("update biblioitems set isbn=$q_isbn where biblioitemnumber=$biblioitemnumber");
739 logchange('marc', 'change', $Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
740 changeSubfield($Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
742 if ($biblioitem->{'issn'} ne $obi->{'issn'}) {
743 logchange('kohadb', 'change', 'biblioitems', 'issn', $obi->{'issn'}, $biblioitem->{'issn'});
744 my $q_issn=$dbh->quote($biblioitem->{'issn'});
745 my $sth=$dbh->prepare("update biblioitems set issn=$q_issn where biblioitemnumber=$biblioitemnumber");
746 logchange('marc', 'change', $Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
747 changeSubfield($Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
749 if ($biblioitem->{'dewey'} ne $obi->{'dewey'}) {
750 logchange('kohadb', 'change', 'biblioitems', 'dewey', $obi->{'dewey'}, $biblioitem->{'dewey'});
751 my $sth=$dbh->prepare("update biblioitems set dewey=$biblioitem->{'dewey'} where biblioitemnumber=$biblioitemnumber");
752 logchange('marc', 'change', $Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
753 changeSubfield($Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
755 if ($biblioitem->{'subclass'} ne $obi->{'subclass'}) {
756 logchange('kohadb', 'change', 'biblioitems', 'subclass', $obi->{'subclass'}, $biblioitem->{'subclass'});
757 my $q_subclass=$dbh->quote($biblioitem->{'subclass'});
758 my $sth=$dbh->prepare("update biblioitems set subclass=$q_subclass where biblioitemnumber=$biblioitemnumber");
759 logchange('marc', 'change', $Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
760 changeSubfield($Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
762 if ($biblioitem->{'place'} ne $obi->{'place'}) {
763 logchange('kohadb', 'change', 'biblioitems', 'place', $obi->{'place'}, $biblioitem->{'place'});
764 my $q_place=$dbh->quote($biblioitem->{'place'});
765 my $sth=$dbh->prepare("update biblioitems set place=$q_place where biblioitemnumber=$biblioitemnumber");
766 logchange('marc', 'change', $Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
767 changeSubfield($Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
769 if ($biblioitem->{'publishercode'} ne $obi->{'publishercode'}) {
770 logchange('kohadb', 'change', 'biblioitems', 'publishercode', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
771 my $q_publishercode=$dbh->quote($biblioitem->{'publishercode'});
772 my $sth=$dbh->prepare("update biblioitems set publishercode=$q_publishercode where biblioitemnumber=$biblioitemnumber");
773 logchange('marc', 'change', $Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
774 changeSubfield($Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
776 if ($biblioitem->{'publicationyear'} ne $obi->{'publicationyear'}) {
777 logchange('kohadb', 'change', 'biblioitems', 'publicationyear', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
778 my $q_publicationyear=$dbh->quote($biblioitem->{'publicationyear'});
779 my $sth=$dbh->prepare("update biblioitems set publicationyear=$q_publicationyear where biblioitemnumber=$biblioitemnumber");
780 logchange('marc', 'change', $Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
781 changeSubfield($Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
783 if ($biblioitem->{'illus'} ne $obi->{'illus'}) {
784 logchange('kohadb', 'change', 'biblioitems', 'illus', $obi->{'illus'}, $biblioitem->{'illus'});
785 my $q_illus=$dbh->quote($biblioitem->{'illus'});
786 my $sth=$dbh->prepare("update biblioitems set illus=$q_illus where biblioitemnumber=$biblioitemnumber");
787 logchange('marc', 'change', $Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
788 changeSubfield($Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
790 if ($biblioitem->{'pages'} ne $obi->{'pages'}) {
791 logchange('kohadb', 'change', 'biblioitems', 'pages', $obi->{'pages'}, $biblioitem->{'pages'});
792 my $q_pages=$dbh->quote($biblioitem->{'pages'});
793 my $sth=$dbh->prepare("update biblioitems set pages=$q_pages where biblioitemnumber=$biblioitemnumber");
794 logchange('marc', 'change', $Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
795 changeSubfield($Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
797 if ($biblioitem->{'size'} ne $obi->{'size'}) {
798 logchange('kohadb', 'change', 'biblioitems', 'size', $obi->{'size'}, $biblioitem->{'size'});
799 my $q_size=$dbh->quote($biblioitem->{'size'});
800 my $sth=$dbh->prepare("update biblioitems set size=$q_size where biblioitemnumber=$biblioitemnumber");
801 logchange('marc', 'change', $Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
802 changeSubfield($Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
804 if ($biblioitem->{'notes'} ne $obi->{'notes'}) {
805 logchange('kohadb', 'change', 'biblioitems', 'notes', $obi->{'notes'}, $biblioitem->{'notes'});
806 my $q_notes=$dbh->quote($biblioitem->{'notes'});
807 my $sth=$dbh->prepare("update biblioitems set notes=$q_notes where biblioitemnumber=$biblioitemnumber");
808 logchange('marc', 'change', $Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
809 changeSubfield($Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
811 if ($biblioitem->{'lccn'} ne $obi->{'lccn'}) {
812 logchange('kohadb', 'change', 'biblioitems', 'lccn', $obi->{'lccn'}, $biblioitem->{'lccn'});
813 my $q_lccn=$dbh->quote($biblioitem->{'lccn'});
814 my $sth=$dbh->prepare("update biblioitems set lccn=$q_lccn where biblioitemnumber=$biblioitemnumber");
815 logchange('marc', 'change', $Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
816 changeSubfield($Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
825 my ($env, $Record_ID, $item) = @_;
827 my $barcode=$item->{'barcode'};
828 my $q_barcode=$dbh->quote($barcode);
829 my $biblionumber=$item->{'biblionumber'};
830 my $biblioitemnumber=$item->{'biblioitemnumber'};
831 my $dateaccessioned=$item->{'dateaccessioned'};
832 my $booksellerid=$item->{'booksellerid'};
833 my $q_booksellerid=$dbh->quote($booksellerid);
834 my $homebranch=$item->{'homebranch'};
835 my $q_homebranch=$dbh->quote($homebranch);
836 my $holdingbranch=$item->{'holdingbranch'};
837 my $price=$item->{'price'};
838 my $replacementprice=$item->{'replacementprice'};
839 my $replacementpricedate=$item->{'replacementpricedate'};
840 my $q_replacementpricedate=$dbh->quote($replacementpricedate);
841 my $notforloan=$item->{'notforloan'};
842 my $itemlost=$item->{'itemlost'};
843 my $wthdrawn=$item->{'wthdrawn'};
844 my $restricted=$item->{'restricted'};
845 my $itemnotes=$item->{'itemnotes'};
846 my $q_itemnotes=$dbh->quote($itemnotes);
847 my $itemtype=$item->{'itemtype'};
848 my $subclass=$item->{'subclass'};
852 unless ($env->{'marconly'}) {
853 my $sth=$dbh->prepare("select max(itemnumber) from items");
855 my ($itemnumber) =$sth->fetchrow;
857 $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)");
864 $subfields->{1}->{'Subfield_Mark'}='p';
865 $subfields->{1}->{'Subfield_Value'}=$barcode;
866 $subfields->{2}->{'Subfield_Mark'}='d';
867 $subfields->{2}->{'Subfield_Value'}=$dateaccessioned;
868 $subfields->{3}->{'Subfield_Mark'}='e';
869 $subfields->{3}->{'Subfield_Value'}=$booksellerid;
870 $subfields->{4}->{'Subfield_Mark'}='b';
871 $subfields->{4}->{'Subfield_Value'}=$homebranch;
872 $subfields->{5}->{'Subfield_Mark'}='l';
873 $subfields->{5}->{'Subfield_Value'}=$holdingbranch;
874 $subfields->{6}->{'Subfield_Mark'}='c';
875 $subfields->{6}->{'Subfield_Value'}=$price;
876 $subfields->{7}->{'Subfield_Mark'}='c';
877 $subfields->{7}->{'Subfield_Value'}=$replacementprice;
878 $subfields->{8}->{'Subfield_Mark'}='d';
879 $subfields->{8}->{'Subfield_Value'}=$replacementpricedate;
881 $subfields->{9}->{'Subfield_Mark'}='h';
882 $subfields->{9}->{'Subfield_Value'}='Not for loan';
885 $subfields->{10}->{'Subfield_Mark'}='j';
886 $subfields->{10}->{'Subfield_Value'}='Item lost';
889 $subfields->{11}->{'Subfield_Mark'}='j';
890 $subfields->{11}->{'Subfield_Value'}='Item withdrawn';
893 $subfields->{12}->{'Subfield_Mark'}='z';
894 $subfields->{12}->{'Subfield_Value'}=$itemnotes;
899 ($env, $Tag_ID) = addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
901 $env->{'linkid'}=$Tag_ID;
904 $subfields2->{1}->{'Subfield_Mark'}='a';
905 $subfields2->{1}->{'Subfield_Value'}='Coast Mountains School District';
906 $subfields2->{1}->{'Subfield_Mark'}='b';
907 $subfields2->{1}->{'Subfield_Value'}=$homebranch;
908 $subfields2->{1}->{'Subfield_Mark'}='c';
909 $subfields2->{1}->{'Subfield_Value'}=$itemtype;
910 $subfields2->{2}->{'Subfield_Mark'}='m';
911 $subfields2->{2}->{'Subfield_Value'}=$subclass;
912 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields2);
917 # Update the item with itemnumber $item->{'itemnumber'}
918 # This routine should also modify the corresponding MARC record data. (852 and
919 # 876 tags with 876p tag the same as $item->{'barcode'}
921 # This routine should also check to see which fields are actually being
922 # modified, and log all changes.
924 my ($env, $item) = @_;
926 my $itemnumber=$item->{'itemnumber'};
927 my $biblionumber=$item->{'biblionumber'};
928 my $biblioitemnumber=$item->{'biblioitemnumber'};
929 my $barcode=$item->{'barcode'};
930 my $dateaccessioned=$item->{'dateaccessioned'};
931 my $booksellerid=$item->{'booksellerid'};
932 my $homebranch=$item->{'homebranch'};
933 my $price=$item->{'price'};
934 my $replacementprice=$item->{'replacementprice'};
935 my $replacementpricedate=$item->{'replacementpricedate'};
936 my $multivolume=$item->{'multivolume'};
937 my $stack=$item->{'stack'};
938 my $notforloan=$item->{'notforloan'};
939 my $itemlost=$item->{'itemlost'};
940 my $wthdrawn=$item->{'wthdrawn'};
941 my $bulk=$item->{'bulk'};
942 my $restricted=$item->{'restricted'};
943 my $binding=$item->{'binding'};
944 my $itemnotes=$item->{'itemnotes'};
945 my $holdingbranch=$item->{'holdingbranch'};
946 my $interim=$item->{'interim'};
947 my $sth=$dbh->prepare("select * from items where itemnumber=$itemnumber");
949 my $olditem=$sth->fetchrow_hashref;
950 my $q_barcode=$dbh->quote($olditem->{'barcode'});
951 $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");
953 my ($Subfield876_ID, $Record_ID) = $sth->fetchrow;
954 $sth=$dbh->prepare("select Subfield_Value from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_ID=$Subfield876_ID");
956 my ($link) = $sth->fetchrow;
957 $sth=$dbh->prepare("select Subfield_ID from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_Value=$link and !(Subfield_ID=$Subfield876_ID)");
959 my ($Subfield852_ID) = $sth->fetchrow;
961 if ($item->{'barcode'} ne $olditem->{'barcode'}) {
962 logchange('kohadb', 'change', 'items', 'barcode', $olditem->{'barcode'}, $item->{'barcode'});
963 my $q_barcode=$dbh->quote($item->{'barcode'});
964 my $sth=$dbh->prepare("update items set barcode=$q_barcode where itemnumber=$itemnumber");
966 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'p', $olditem->{'barcode'}, $item->{'barcode'}, $Subfield876_ID);
967 logchange('marc', 'change', $Record_ID, '876', 'p', $Subfield_Key, $olditem->{'barcode'}, $item->{'barcode'});
969 if ($item->{'booksellerid'} ne $olditem->{'booksellerid'}) {
970 logchange('kohadb', 'change', 'items', 'booksellerid', $olditem->{'booksellerid'}, $item->{'booksellerid'});
971 my $q_booksellerid=$dbh->quote($item->{'booksellerid'});
972 my $sth=$dbh->prepare("update items set booksellerid=$q_booksellerid where itemnumber=$itemnumber");
974 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'e', $olditem->{'booksellerid'}, $item->{'booksellerid'}, $Subfield876_ID);
975 logchange('marc', 'change', $Record_ID, '876', 'e', $Subfield_Key, $olditem->{'booksellerid'}, $item->{'booksellerid'});
977 if ($item->{'dateaccessioned'} ne $olditem->{'dateaccessioned'}) {
978 logchange('kohadb', 'change', 'items', 'dateaccessioned', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
979 my $q_dateaccessioned=$dbh->quote($item->{'dateaccessioned'});
980 my $sth=$dbh->prepare("update items set dateaccessioned=$q_dateaccessioned where itemnumber=$itemnumber");
982 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'd', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'}, $Subfield876_ID);
983 logchange('marc', 'change', $Record_ID, '876', 'd', $Subfield_Key, $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
985 if ($item->{'homebranch'} ne $olditem->{'homebranch'}) {
986 logchange('kohadb', 'change', 'items', 'homebranch', $olditem->{'homebranch'}, $item->{'homebranch'});
987 my $q_homebranch=$dbh->quote($item->{'homebranch'});
988 my $sth=$dbh->prepare("update items set homebranch=$q_homebranch where itemnumber=$itemnumber");
990 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'b', $olditem->{'homebranch'}, $item->{'homebranch'}, $Subfield876_ID);
991 logchange('marc', 'change', $Record_ID, '876', 'b', $Subfield_Key, $olditem->{'homebranch'}, $item->{'homebranch'});
993 if ($item->{'holdingbranch'} ne $olditem->{'holdingbranch'}) {
994 logchange('kohadb', 'change', 'items', 'holdingbranch', $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
995 my $q_holdingbranch=$dbh->quote($item->{'holdingbranch'});
996 my $sth=$dbh->prepare("update items set holdingbranch=$q_holdingbranch where itemnumber=$itemnumber");
998 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'l', $olditem->{'holdingbranch'}, $item->{'holdingbranch'}, $Subfield876_ID);
999 logchange('marc', 'change', $Record_ID, '876', 'l', $Subfield_Key, $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
1001 if ($item->{'price'} ne $olditem->{'price'}) {
1002 logchange('kohadb', 'change', 'items', 'price', $olditem->{'price'}, $item->{'price'});
1003 my $q_price=$dbh->quote($item->{'price'});
1004 my $sth=$dbh->prepare("update items set price=$q_price where itemnumber=$itemnumber");
1006 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'price'}, $item->{'price'}, $Subfield876_ID);
1007 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'price'}, $item->{'price'});
1009 if ($item->{'itemnotes'} ne $olditem->{'itemnotes'}) {
1010 logchange('kohadb', 'change', 'items', 'itemnotes', $olditem->{'itemnotes'}, $item->{'itemnotes'});
1011 my $q_itemnotes=$dbh->quote($item->{'itemnotes'});
1012 my $sth=$dbh->prepare("update items set itemnotes=$q_itemnotes where itemnumber=$itemnumber");
1014 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'itemnotes'}, $item->{'itemnotes'}, $Subfield876_ID);
1015 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'itemnotes'}, $item->{'itemnotes'});
1017 if ($item->{'notforloan'} ne $olditem->{'notforloan'}) {
1018 logchange('kohadb', 'change', 'items', 'notforloan', $olditem->{'notforloan'}, $item->{'notforloan'});
1019 my $sth=$dbh->prepare("update items set notforloan=$notforloan where itemnumber=$itemnumber");
1021 if ($item->{'notforloan'}) {
1022 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
1023 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
1025 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
1026 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
1029 if ($item->{'itemlost'} ne $olditem->{'itemlost'}) {
1030 logchange('kohadb', 'change', 'items', 'itemlost', $olditem->{'itemlost'}, $item->{'itemlost'});
1031 my $sth=$dbh->prepare("update items set itemlost=$itemlost where itemnumber=$itemnumber");
1033 if ($item->{'itemlost'}) {
1034 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
1035 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
1037 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
1038 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
1041 if ($item->{'wthdrawn'} ne $olditem->{'wthdrawn'}) {
1042 logchange('kohadb', 'change', 'items', 'wthdrawn', $olditem->{'wthdrawn'}, $item->{'wthdrawn'});
1043 my $sth=$dbh->prepare("update items set wthdrawn=$wthdrawn where itemnumber=$itemnumber");
1045 if ($item->{'wthdrawn'}) {
1046 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
1047 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1049 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
1050 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1053 if ($item->{'restricted'} ne $olditem->{'restricted'}) {
1054 logchange('kohadb', 'change', 'items', 'restricted', $olditem->{'restricted'}, $item->{'restricted'});
1055 my $sth=$dbh->prepare("update items set restricted=$restricted where itemnumber=$itemnumber");
1057 if ($item->{'restricted'}) {
1058 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1059 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1061 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1062 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1069 END { } # module clean-up code here (global destructor)