1 package C4::Catalogue; #asummes C4/Acquisitions.pm
3 # Continue working on updateItem!!!!!!
11 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
13 # set the version for version checking
17 @EXPORT = qw(&newBiblio &newBiblioItem &newItem &updateBiblio &updateBiblioItem
18 &updateItem &changeSubfield);
19 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
21 # your exported package globals go here,
22 # as well as any optionally exported functions
24 @EXPORT_OK = qw($Var1 %Hashit);
27 # non-exported package globals go here
28 use vars qw(@more $stuff);
30 # initalize package globals, first exported ones
36 # then the others (which are still accessible as $Some::Module::stuff)
40 # all file-scoped lexicals must be created before
41 # the functions below that use them.
43 # file-private lexicals go here
47 # here's a file-private function as a closure,
48 # callable as &$priv_func; it cannot be prototyped.
53 # make all your functions, whether exported or not;
58 # This subroutine makes no modifications to the MARC tables. MARC records are
59 # only created when new biblioitems are added.
60 my ($env, $biblio) = @_;
62 my $title=$biblio->{'title'};
63 my $q_title=$dbh->quote($title);
64 my $subtitle=$biblio->{'subtitle'};
65 my $q_subtitle=$dbh->quote($subtitle);
66 ($q_subtitle) || ($q_subtitle="''");
67 my $author=$biblio->{'author'};
68 my $q_author=$dbh->quote($author);
69 my $unititle=$biblio->{'unititle'};
70 my $q_unititle=$dbh->quote($unititle);
71 my $copyrightdate=$biblio->{'copyrightdate'};
72 my $serial=$biblio->{'serial'};
73 my $seriestitle=$biblio->{'seriestitle'};
74 my $q_seriestitle=$dbh->quote($seriestitle);
75 my $notes=$biblio->{'notes'};
76 my $q_notes=$dbh->quote($notes);
77 my $subject=$biblio->{'subject'};
78 my $additionalauthors=$biblio->{'additionalauthors'};
79 my $sth=$dbh->prepare("select max(biblionumber) from biblio");
81 my ($biblionumber) = $sth->fetchrow;
83 $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)");
85 $sth=$dbh->prepare("insert into bibliosubtitle (biblionumber,subtitle) values ($biblionumber,$q_subtitle)");
88 my $q_subject=$dbh->quote($_);
89 my $sth=$dbh->prepare("insert into bibliosubject (biblionumber,subject) values ($biblionumber,$q_subject)");
92 foreach (@$additionalauthors) {
93 my $q_additionalauthor=$dbh->quote($_);
94 my $sth=$dbh->prepare("insert into additionalauthors (biblionumber,author) values ($biblionumber,$q_additionalauthor)");
101 # Subroutine changes a subfield value given a Record_ID, Tag, and Subfield_Mark.
102 # Routine should be made more robust. It currently checks to make sure that
103 # the existing Subfield_Value is the same as the one passed in. What if no
104 # subfield matches this Subfield_OldValue? Create a new Subfield? Maybe check
105 # to make sure that the mark is repeatable first and that no other subfield
106 # with that mark already exists? Ability to return errors and status?
108 # Also, currently, if more than one subfield matches the Record_ID, Tag,
109 # Subfield_Mark, and Subfield_OldValue, only the first one will be modified.
111 # Might be nice to be able to pass a Subfield_ID or Subfield_Key directly to
112 # this routine to remove ambiguity, if possible.
114 # Pass barcode to remove ambiguity for changes to individual items. Look up
115 # field link and sequence number based on barcode.
119 my $firstdigit=substr($tag, 0, 1);
120 my $Subfield_Mark=shift;
121 my $Subfield_OldValue=shift;
122 my $Subfield_Value=shift;
123 my $Subfield_ID=shift;
124 my $Subfield_Key=shift;
126 my $q_Subfield_Value=$dbh->quote($Subfield_Value);
128 # Great. Subfield_Key makes the record absolutely unique. Just make
130 my $sth=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_Value=$q_Subfield_Value where Subfield_Key=$Subfield_Key");
132 } elsif ($Subfield_ID) {
133 # Subfield_ID does not make the record unique. Could be multiple
134 # records with the same mark. This is a bad situatoin.
135 my $sth=$dbh->prepare("select Subfield_Key, Subfield_Value from $firstdigit\XX_Subfield_Table where Subfield_Mark='$Subfield_Mark' and Subfield_ID=$Subfield_ID");
137 while (my ($key, $Value) = $sth->fetchrow) {
138 if ($Value eq $Subfield_OldValue) {
139 my $sti=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_Value=$q_Subfield_Value where Subfield_Key=$key");
146 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'");
148 while (my ($key, $ID, $Value) = $sth->fetchrow) {
149 if ($Value eq $Subfield_OldValue) {
150 my $sti=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_Value=$q_Subfield_Value where Subfield_Key=$key");
157 return($Subfield_ID, $Subfield_Key);
161 # Update the biblio with biblionumber $biblio->{'biblionumber'}
162 # I guess this routine should search through all marc records for a record that
163 # has the same biblionumber stored in it, and modify the MARC record as well as
166 # Also, this subroutine should search through the $biblio object and compare it
167 # to the existing record and _LOG ALL CHANGES MADE_ in some way. I'd like for
168 # this logging feature to be usable to undo changes easily.
170 # Need to add support for bibliosubject, additionalauthors, bibliosubtitle tables
172 my ($env, $biblio) = @_;
173 my $biblionumber=$biblio->{'biblionumber'};
175 my $sth=$dbh->prepare("select * from biblio where biblionumber=$biblionumber");
177 my $origbiblio=$sth->fetchrow_hashref;
178 $sth=$dbh->prepare("select subtitle from bibliosubtitle where biblionumber=$biblionumber"):
180 my ($subtitle)=$sth->fetchrow;
181 $origbiblio->{'subtitle'}=$subtitle;
182 $sth=$dbh->prepare("select author from additionalauthors where biblionumber=$biblionumber");
184 my $origadditionalauthors;
185 while (my ($author) = $sth->fetchrow) {
186 push (@{$origbiblio->{'additionalauthors'}}, $author);
187 $origadditionalauthors->{$subject}=1;
189 $sth=$dbh->prepare("select subject from bibliosubjects where biblionumber=$biblionumber");
192 while (my ($subject) = $sth->fetchrow) {
193 push (@{$origbiblio->{'subjects'}}, $subject);
194 $origsubjects->{$subject}=1;
198 # Obtain a list of MARC Record_ID's that are tied to this biblio
199 $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'");
202 while (my ($Record_ID) = $sth->fetchrow) {
203 push(@marcrecords, $Record_ID);
209 if ($biblio->{'author'} ne $origbiblio->{'author'}) {
210 my $q_author=$dbh->quote($biblio->{'author'});
211 logchange('kohadb', 'change', 'biblio', 'author', $origbiblio->{'author'}, $biblio->{'author'});
212 my $sti=$dbh->prepare("update biblio set author=$q_author where biblionumber=$biblio->{'biblionumber'}");
214 foreach $Record_ID (@marcrecords) {
215 logchange('marc', 'change', $Record_ID, '100', 'a', $origbiblio->{'author'}, $biblio->{'author'});
216 changeSubfield($Record_ID, '100', 'a', $origbiblio->{'author'}, $biblio->{'author'});
219 if ($biblio->{'title'} ne $origbiblio->{'title'}) {
220 my $q_title=$dbh->quote($biblio->{'title'});
221 logchange('kohadb', 'change', 'biblio', 'title', $origbiblio->{'title'}, $biblio->{'title'});
222 my $sti=$dbh->prepare("update biblio set title=$q_title where biblionumber=$biblio->{'biblionumber'}");
224 foreach $Record_ID (@marcrecords) {
225 logchange('marc', 'change', $Record_ID, '245', 'a', $origbiblio->{'title'}, $biblio->{'title'});
226 changeSubfield($Record_ID, '245', 'a', $origbiblio->{'title'}, $biblio->{'title'});
229 if ($biblio->{'subtitle'} ne $origbiblio->{'subtitle'}) {
230 my $q_subtitle=$dbh->quote($biblio->{'subtitle'});
231 logchange('kohadb', 'change', 'biblio', 'subtitle', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
232 my $sti=$dbh->prepare("update bibliosubtitle set subtitle=$q_subtitle where biblionumber=$biblio->{'biblionumber'}");
234 foreach $Record_ID (@marcrecords) {
235 logchange('marc', 'change', $Record_ID, '245', 'b', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
236 changeSubfield($Record_ID, '245', 'b', $origbiblio->{'subtitle'}, $biblio->{'subtitle'});
239 if ($biblio->{'unititle'} ne $origbiblio->{'unititle'}) {
240 my $q_unititle=$dbh->quote($biblio->{'unititle'});
241 logchange('kohadb', 'change', 'biblio', 'unititle', $origbiblio->{'unititle'}, $biblio->{'unititle'});
242 my $sti=$dbh->prepare("update biblio set unititle=$q_unititle where biblionumber=$biblio->{'biblionumber'}");
245 if ($biblio->{'notes'} ne $origbiblio->{'notes'}) {
246 my $q_notes=$dbh->quote($biblio->{'notes'});
247 logchange('kohadb', 'change', 'biblio', 'notes', $origbiblio->{'notes'}, $biblio->{'notes'});
248 my $sti=$dbh->prepare("update biblio set notes=$q_notes where biblionumber=$biblio->{'biblionumber'}");
250 foreach $Record_ID (@marcrecords) {
251 logchange('marc', 'change', $Record_ID, '500', 'a', $origbiblio->{'notes'}, $biblio->{'notes'});
252 changeSubfield($Record_ID, '500', 'a', $origbiblio->{'notes'}, $biblio->{'notes'});
255 if ($biblio->{'serial'} ne $origbiblio->{'serial'}) {
256 my $q_serial=$dbh->quote($biblio->{'serial'});
257 logchange('kohadb', 'change', 'biblio', 'serial', $origbiblio->{'serial'}, $biblio->{'serial'});
258 my $sti=$dbh->prepare("update biblio set serial=$q_serial where biblionumber=$biblio->{'biblionumber'}");
261 if ($biblio->{'seriestitle'} ne $origbiblio->{'seriestitle'}) {
262 my $q_seriestitle=$dbh->quote($biblio->{'seriestitle'});
263 logchange('kohadb', 'change', 'biblio', 'seriestitle', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
264 my $sti=$dbh->prepare("update biblio set seriestitle=$q_seriestitle where biblionumber=$biblio->{'biblionumber'}");
266 foreach $Record_ID (@marcrecords) {
267 logchange('marc', 'change', $Record_ID, '440', 'a', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
268 changeSubfield($Record_ID, '440', 'a', $origbiblio->{'seriestitle'}, $biblio->{'seriestitle'});
271 if ($biblio->{'copyrightdate'} ne $origbiblio->{'copyrightdate'}) {
272 my $q_copyrightdate=$dbh->quote($biblio->{'copyrightdate'});
273 logchange('kohadb', 'change', 'biblio', 'copyrightdate', $origbiblio->{'copyrightdate'}, $biblio->{'copyrightdate'});
274 my $sti=$dbh->prepare("update biblio set copyrightdate=$q_copyrightdate where biblionumber=$biblio->{'biblionumber'}");
276 foreach $Record_ID (@marcrecords) {
277 logchange('marc', 'change', $Record_ID, '260', 'c', "c$origbiblio->{'notes'}", "c$biblio->{'notes'}");
278 changeSubfield($Record_ID, '260', 'c', "c$origbiblio->{'notes'}", "c$biblio->{'notes'}");
282 # Check for subject heading changes
285 foreach $newsubject (@{$biblio->{'subject'}}) {
286 $subjects->{$newsubject}=1;
287 if ($origsubjects->{$newsubject}) {
288 $subjects->{$newsubject}=2;
290 my $q_newsubject=$dbh->quote($newsubject);
291 my $sth=$dbh->prepare("insert into bibliosubjects (subject,biblionumber) values ($q_newsubject, $biblionumber)");
293 logchange('kohadb', 'add', 'biblio', 'subject', $newsubject);
295 $subfields->{1}->{'Subfield_Mark'}='a';
296 $subfields->{1}->{'Subfield_Value'}=$newsubject;
299 foreach $Record_ID (@marcrecords) {
300 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
301 logchange('marc', 'add', $Record_ID, '650', 'a', $newsubject);
305 foreach $origsubject (keys %$origsubjects) {
306 if ($subjects->{$origsubject} == 1) {
307 my $q_origsubject=$dbh->quote($origsubject);
308 logchange('kohadb', 'delete', 'biblio', '$biblionumber', 'subject', $origsubject);
309 my $sth=$dbh->prepare("delete from bibliosubjects where biblionumber=$biblionumber and subject=$q_origsubject");
317 # Subroutine to log changes to databases
319 if ($database eq 'kohadb') {
325 print "KOHA: $section $item $original $new\n";
326 } elsif ($database eq 'marc') {
330 my $subfield_ID=shift;
333 print "MARC: $tag $mark $subfield_ID $original $new\n";
338 # Subroutine to add a tag to an existing MARC Record. If a new linkage id is
339 # desired, set $env->{'linkage'} to 1. If an existing linkage id should be
340 # set, set $env->{'linkid'} to the link number.
341 my ($env, $Record_ID, $tag, $Indicator1, $Indicator2, $subfields) = @_;
343 ($Indicator1) || ($Indicator1=' ');
344 ($Indicator2) || ($Indicator2=' ');
345 my $firstdigit=substr($tag,0,1);
347 foreach (sort keys %$subfields) {
348 my $Subfield_Mark=$subfields->{$_}->{'Subfield_Mark'};
349 my $Subfield_Value=$subfields->{$_}->{'Subfield_Value'};
350 my $q_Subfield_Value=$dbh->quote($Subfield_Value);
352 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '$Subfield_Mark', $q_Subfield_Value)");
355 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_Mark, Subfield_Value) values ('$Subfield_Mark', $q_Subfield_Value)");
357 my $Subfield_Key=$dbh->{'mysql_insertid'};
358 $Subfield_ID=$Subfield_Key;
359 $sth=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_ID=$Subfield_ID where Subfield_Key=$Subfield_Key");
363 if (my $linkid=$env->{'linkid'}) {
365 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$linkid')");
368 my $sth=$dbh->prepare("insert into $firstdigit\XX_Tag_Table (Indicator1, Indicator2, Tag, Subfield_ID) values ('$Indicator1', '$Indicator2', '$tag', $Subfield_ID)");
370 my $Tag_Key=$dbh->{'mysql_insertid'};
372 $sth=$dbh->prepare("update $firstdigit\XX_Tag_Table set Tag_ID=$Tag_ID where Tag_Key=$Tag_Key");
374 $sth=$dbh->prepare("insert into Bib_Table (Record_ID, Tag_$firstdigit\XX_ID) values ($Record_ID, $Tag_ID)");
376 if ($env->{'linkage'}) {
377 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$Tag_ID')");
383 return ($env, $Tag_ID);
387 my ($env, $biblioitem) = @_;
389 my $biblionumber=$biblioitem->{'biblionumber'};
390 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
391 my $volume=$biblioitem->{'volume'};
392 my $q_volume=$dbh->quote($volume);
393 my $number=$biblioitem->{'number'};
394 my $q_number=$dbh->quote($number);
395 my $classification=$biblioitem->{'classification'};
396 my $q_classification=$dbh->quote($classification);
397 my $itemtype=$biblioitem->{'itemtype'};
398 my $q_itemtype=$dbh->quote($itemtype);
399 my $isbn=$biblioitem->{'isbn'};
400 my $q_isbn=$dbh->quote($isbn);
401 my $issn=$biblioitem->{'issn'};
402 my $q_issn=$dbh->quote($issn);
403 my $dewey=$biblioitem->{'dewey'};
405 ($dewey == 0) && ($dewey='');
406 my $subclass=$biblioitem->{'subclass'};
407 my $q_subclass=$dbh->quote($subclass);
408 my $publicationyear=$biblioitem->{'publicationyear'};
409 my $publishercode=$biblioitem->{'publishercode'};
410 my $q_publishercode=$dbh->quote($publishercode);
411 my $volumedate=$biblioitem->{'volumedate'};
412 my $q_volumedate=$dbh->quote($volumedate);
413 my $illus=$biblioitem->{'illus'};
414 my $q_illus=$dbh->quote($illus);
415 my $pages=$biblioitem->{'pages'};
416 my $q_pages=$dbh->quote($pages);
417 my $notes=$biblioitem->{'notes'};
418 my $q_notes=$dbh->quote($notes);
419 my $size=$biblioitem->{'size'};
420 my $q_size=$dbh->quote($size);
421 my $place=$biblioitem->{'place'};
422 my $q_place=$dbh->quote($place);
423 my $lccn=$biblioitem->{'lccn'};
424 my $q_lccn=$dbh->quote($lccn);
427 # Unless the $env->{'marconly'} flag is set, update the biblioitems table with
430 unless ($env->{'marconly'}) {
431 #my $sth=$dbh->prepare("lock tables biblioitems write");
433 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
435 my ($biblioitemnumber) =$sth->fetchrow;
437 $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)");
439 #my $sth=$dbh->prepare("unlock tables");
444 # Should we check if there is already a biblioitem/marc with the
445 # same isbn/lccn/issn?
447 my $sth=$dbh->prepare("select title,unititle,seriestitle,copyrightdate,notes,author from biblio where biblionumber=$biblionumber");
449 my ($title, $unititle,$seriestitle,$copyrightdate,$biblionotes,$author) = $sth->fetchrow;
450 $sth=$dbh->prepare("select subtitle from bibliosubtitle where biblionumber=$biblionumber");
452 my ($subtitle) = $sth->fetchrow;
453 $sth=$dbh->prepare("select author from additionalauthors where biblionumber=$biblionumber");
455 my @additionalauthors;
456 while (my ($additionalauthor) = $sth->fetchrow) {
457 push (@additionalauthors, $additionalauthor);
459 $sth=$dbh->prepare("select subject from bibliosubject where biblionumber=$biblionumber");
462 while (my ($subject) = $sth->fetchrow) {
463 push (@subjects, $subject);
468 $sth=$dbh->prepare("insert into Resource_Table (Record_ID) values (0)");
470 my $Resource_ID=$dbh->{'mysql_insertid'};
471 my $Record_ID=$Resource_ID;
472 $sth=$dbh->prepare("update Resource_Table set Record_ID=$Record_ID where Resource_ID=$Resource_ID");
478 $subfields->{1}->{'Subfield_Mark'}='a';
479 $subfields->{1}->{'Subfield_Value'}=$title;
481 $subfields->{2}->{'Subfield_Mark'}='b';
482 $subfields->{2}->{'Subfield_Value'}=$subtitle;
485 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
491 $subfields->{1}->{'Subfield_Mark'}='a';
492 $subfields->{1}->{'Subfield_Value'}=$author;
494 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
499 $subfields->{1}->{'Subfield_Mark'}='a';
500 $subfields->{1}->{'Subfield_Value'}=$seriestitle;
502 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
507 $subfields->{1}->{'Subfield_Mark'}='a';
508 $subfields->{1}->{'Subfield_Value'}=$biblionotes;
509 $subfields->{2}->{'Subfield_Mark'}='3';
510 $subfields->{2}->{'Subfield_Value'}='biblio';
512 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
515 foreach (@additionalauthors) {
517 (next) unless ($author);
519 $subfields->{1}->{'Subfield_Mark'}='a';
520 $subfields->{1}->{'Subfield_Value'}=$author;
521 $subfields->{2}->{'Subfield_Mark'}='e';
522 $subfields->{2}->{'Subfield_Value'}='author';
524 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
528 (next) unless ($illus);
530 $subfields->{1}->{'Subfield_Mark'}='a';
531 $subfields->{1}->{'Subfield_Value'}=$illus;
532 $subfields->{2}->{'Subfield_Mark'}='e';
533 $subfields->{2}->{'Subfield_Value'}='illustrator';
535 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
538 foreach (@subjects) {
540 (next) unless ($subject);
542 $subfields->{1}->{'Subfield_Mark'}='a';
543 $subfields->{1}->{'Subfield_Value'}=$subject;
545 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
552 $subfields->{1}->{'Subfield_Mark'}='a';
553 $subfields->{1}->{'Subfield_Value'}=$isbn;
555 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
560 $subfields->{1}->{'Subfield_Mark'}='a';
561 $subfields->{1}->{'Subfield_Value'}=$lccn;
563 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
568 $subfields->{1}->{'Subfield_Mark'}='a';
569 $subfields->{1}->{'Subfield_Value'}=$issn;
571 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
576 $subfields->{1}->{'Subfield_Mark'}='a';
577 $subfields->{1}->{'Subfield_Value'}=$dewey;
579 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
581 # DEWEY subclass and itemtype
584 $subfields->{1}->{'Subfield_Mark'}='a';
585 $subfields->{1}->{'Subfield_Value'}=$itemtype;
586 $subfields->{2}->{'Subfield_Mark'}='b';
587 $subfields->{2}->{'Subfield_Value'}=$subclass;
588 $subfields->{3}->{'Subfield_Mark'}='c';
589 $subfields->{3}->{'Subfield_Value'}=$biblionumber;
590 $subfields->{4}->{'Subfield_Mark'}='d';
591 $subfields->{4}->{'Subfield_Value'}=$biblioitemnumber;
593 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
598 $subfields->{1}->{'Subfield_Mark'}='a';
599 $subfields->{1}->{'Subfield_Value'}=$place;
600 $subfields->{2}->{'Subfield_Mark'}='b';
601 $subfields->{2}->{'Subfield_Value'}=$publishercode;
602 $subfields->{3}->{'Subfield_Mark'}='c';
603 $subfields->{3}->{'Subfield_Value'}=$publicationyear;
604 if ($copyrightdate) {
605 $subfields->{4}->{'Subfield_Mark'}='c';
606 $subfields->{4}->{'Subfield_Value'}="c$copyrightdate";
609 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
612 if ($pages || $size) {
614 $subfields->{1}->{'Subfield_Mark'}='a';
615 $subfields->{1}->{'Subfield_Value'}=$pages;
616 $subfields->{2}->{'Subfield_Mark'}='c';
617 $subfields->{2}->{'Subfield_Value'}=$size;
619 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
622 if ($volume || $number) {
624 $subfields->{1}->{'Subfield_Mark'}='v';
625 $subfields->{1}->{'Subfield_Value'}=$volume;
626 $subfields->{2}->{'Subfield_Mark'}='n';
627 $subfields->{2}->{'Subfield_Value'}=$number;
629 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
634 $subfields->{1}->{'Subfield_Mark'}='a';
635 $subfields->{1}->{'Subfield_Value'}=$notes;
636 $subfields->{2}->{'Subfield_Mark'}='3';
637 $subfields->{2}->{'Subfield_Value'}='biblioitem';
639 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
643 return ($env, $Record_ID);
646 sub updateBiblioItem {
647 # Update the biblioitem with biblioitemnumber $biblioitem->{'biblioitemnumber'}
649 # This routine should also check to see which fields are actually being
650 # modified, and log all changes.
652 my ($env, $biblioitem) = @_;
655 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
656 my $sth=$dbh->prepare("select * from biblioitems where biblioitemnumber=$biblioitemnumber");
657 # obi = original biblioitem
658 my $obi=$sth->fetchrow_hashref;
659 $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");
661 my ($Record_ID) = $sth->fetchrow;
662 if ($biblioitem->{'biblionumber'} ne $obi->{'biblionumber'}) {
663 logchange('kohadb', 'change', 'biblioitems', 'biblionumber', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
664 my $sth=$dbh->prepare("update biblioitems set biblionumber=$biblioitem->{'biblionumber'} where biblioitemnumber=$biblioitemnumber");
665 logchange('marc', 'change', $Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
666 changeSubfield($Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
668 if ($biblioitem->{'volume'} ne $obi->{'volume'}) {
669 logchange('kohadb', 'change', 'biblioitems', 'volume', $obi->{'volume'}, $biblioitem->{'volume'});
670 my $q_volume=$dbh->quote($biblioitem->{'volume'});
671 my $sth=$dbh->prepare("update biblioitems set volume=$q_volume where biblioitemnumber=$biblioitemnumber");
672 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
673 changeSubfield($Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
675 if ($biblioitem->{'number'} ne $obi->{'number'}) {
676 logchange('kohadb', 'change', 'biblioitems', 'number', $obi->{'number'}, $biblioitem->{'number'});
677 my $q_number=$dbh->quote($biblioitem->{'number'});
678 my $sth=$dbh->prepare("update biblioitems set number=$q_number where biblioitemnumber=$biblioitemnumber");
679 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
680 changeSubfield($Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
682 if ($biblioitem->{'itemtype'} ne $obi->{'itemtype'}) {
683 logchange('kohadb', 'change', 'biblioitems', 'itemtype', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
684 my $q_itemtype=$dbh->quote($biblioitem->{'itemtype'});
685 my $sth=$dbh->prepare("update biblioitems set itemtype=$q_itemtype where biblioitemnumber=$biblioitemnumber");
686 logchange('marc', 'change', $Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
687 changeSubfield($Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
689 if ($biblioitem->{'isbn'} ne $obi->{'isbn'}) {
690 logchange('kohadb', 'change', 'biblioitems', 'isbn', $obi->{'isbn'}, $biblioitem->{'isbn'});
691 my $q_isbn=$dbh->quote($biblioitem->{'isbn'});
692 my $sth=$dbh->prepare("update biblioitems set isbn=$q_isbn where biblioitemnumber=$biblioitemnumber");
693 logchange('marc', 'change', $Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
694 changeSubfield($Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
696 if ($biblioitem->{'issn'} ne $obi->{'issn'}) {
697 logchange('kohadb', 'change', 'biblioitems', 'issn', $obi->{'issn'}, $biblioitem->{'issn'});
698 my $q_issn=$dbh->quote($biblioitem->{'issn'});
699 my $sth=$dbh->prepare("update biblioitems set issn=$q_issn where biblioitemnumber=$biblioitemnumber");
700 logchange('marc', 'change', $Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
701 changeSubfield($Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
703 if ($biblioitem->{'dewey'} ne $obi->{'dewey'}) {
704 logchange('kohadb', 'change', 'biblioitems', 'dewey', $obi->{'dewey'}, $biblioitem->{'dewey'});
705 my $sth=$dbh->prepare("update biblioitems set dewey=$biblioitem->{'dewey'} where biblioitemnumber=$biblioitemnumber");
706 logchange('marc', 'change', $Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
707 changeSubfield($Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
709 if ($biblioitem->{'subclass'} ne $obi->{'subclass'}) {
710 logchange('kohadb', 'change', 'biblioitems', 'subclass', $obi->{'subclass'}, $biblioitem->{'subclass'});
711 my $q_subclass=$dbh->quote($biblioitem->{'subclass'});
712 my $sth=$dbh->prepare("update biblioitems set subclass=$q_subclass where biblioitemnumber=$biblioitemnumber");
713 logchange('marc', 'change', $Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
714 changeSubfield($Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
716 if ($biblioitem->{'place'} ne $obi->{'place'}) {
717 logchange('kohadb', 'change', 'biblioitems', 'place', $obi->{'place'}, $biblioitem->{'place'});
718 my $q_place=$dbh->quote($biblioitem->{'place'});
719 my $sth=$dbh->prepare("update biblioitems set place=$q_place where biblioitemnumber=$biblioitemnumber");
720 logchange('marc', 'change', $Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
721 changeSubfield($Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
723 if ($biblioitem->{'publishercode'} ne $obi->{'publishercode'}) {
724 logchange('kohadb', 'change', 'biblioitems', 'publishercode', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
725 my $q_publishercode=$dbh->quote($biblioitem->{'publishercode'});
726 my $sth=$dbh->prepare("update biblioitems set publishercode=$q_publishercode where biblioitemnumber=$biblioitemnumber");
727 logchange('marc', 'change', $Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
728 changeSubfield($Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
730 if ($biblioitem->{'publicationyear'} ne $obi->{'publicationyear'}) {
731 logchange('kohadb', 'change', 'biblioitems', 'publicationyear', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
732 my $q_publicationyear=$dbh->quote($biblioitem->{'publicationyear'});
733 my $sth=$dbh->prepare("update biblioitems set publicationyear=$q_publicationyear where biblioitemnumber=$biblioitemnumber");
734 logchange('marc', 'change', $Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
735 changeSubfield($Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
737 if ($biblioitem->{'illus'} ne $obi->{'illus'}) {
738 logchange('kohadb', 'change', 'biblioitems', 'illus', $obi->{'illus'}, $biblioitem->{'illus'});
739 my $q_illus=$dbh->quote($biblioitem->{'illus'});
740 my $sth=$dbh->prepare("update biblioitems set illus=$q_illus where biblioitemnumber=$biblioitemnumber");
741 logchange('marc', 'change', $Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
742 changeSubfield($Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
744 if ($biblioitem->{'pages'} ne $obi->{'pages'}) {
745 logchange('kohadb', 'change', 'biblioitems', 'pages', $obi->{'pages'}, $biblioitem->{'pages'});
746 my $q_pages=$dbh->quote($biblioitem->{'pages'});
747 my $sth=$dbh->prepare("update biblioitems set pages=$q_pages where biblioitemnumber=$biblioitemnumber");
748 logchange('marc', 'change', $Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
749 changeSubfield($Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
751 if ($biblioitem->{'size'} ne $obi->{'size'}) {
752 logchange('kohadb', 'change', 'biblioitems', 'size', $obi->{'size'}, $biblioitem->{'size'});
753 my $q_size=$dbh->quote($biblioitem->{'size'});
754 my $sth=$dbh->prepare("update biblioitems set size=$q_size where biblioitemnumber=$biblioitemnumber");
755 logchange('marc', 'change', $Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
756 changeSubfield($Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
758 if ($biblioitem->{'notes'} ne $obi->{'notes'}) {
759 logchange('kohadb', 'change', 'biblioitems', 'notes', $obi->{'notes'}, $biblioitem->{'notes'});
760 my $q_notes=$dbh->quote($biblioitem->{'notes'});
761 my $sth=$dbh->prepare("update biblioitems set notes=$q_notes where biblioitemnumber=$biblioitemnumber");
762 logchange('marc', 'change', $Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
763 changeSubfield($Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
765 if ($biblioitem->{'lccn'} ne $obi->{'lccn'}) {
766 logchange('kohadb', 'change', 'biblioitems', 'lccn', $obi->{'lccn'}, $biblioitem->{'lccn'});
767 my $q_lccn=$dbh->quote($biblioitem->{'lccn'});
768 my $sth=$dbh->prepare("update biblioitems set lccn=$q_lccn where biblioitemnumber=$biblioitemnumber");
769 logchange('marc', 'change', $Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
770 changeSubfield($Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
777 my ($env, $Record_ID, $item) = @_;
779 my $barcode=$item->{'barcode'};
780 my $q_barcode=$dbh->quote($barcode);
781 my $biblionumber=$item->{'biblionumber'};
782 my $biblioitemnumber=$item->{'biblioitemnumber'};
783 my $dateaccessioned=$item->{'dateaccessioned'};
784 my $booksellerid=$item->{'booksellerid'};
785 my $q_booksellerid=$dbh->quote($booksellerid);
786 my $homebranch=$item->{'homebranch'};
787 my $q_homebranch=$dbh->quote($homebranch);
788 my $holdingbranch=$item->{'holdingbranch'};
789 my $price=$item->{'price'};
790 my $replacementprice=$item->{'replacementprice'};
791 my $replacementpricedate=$item->{'replacementpricedate'};
792 my $q_replacementpricedate=$dbh->quote($replacementpricedate);
793 my $notforloan=$item->{'notforloan'};
794 my $itemlost=$item->{'itemlost'};
795 my $wthdrawn=$item->{'wthdrawn'};
796 my $restricted=$item->{'restricted'};
797 my $itemnotes=$item->{'itemnotes'};
798 my $q_itemnotes=$dbh->quote($itemnotes);
799 my $itemtype=$item->{'itemtype'};
800 my $subclass=$item->{'subclass'};
804 unless ($env->{'marconly'}) {
805 my $sth=$dbh->prepare("select max(itemnumber) from items");
807 my ($itemnumber) =$sth->fetchrow;
809 $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)");
816 $subfields->{1}->{'Subfield_Mark'}='p';
817 $subfields->{1}->{'Subfield_Value'}=$barcode;
818 $subfields->{2}->{'Subfield_Mark'}='d';
819 $subfields->{2}->{'Subfield_Value'}=$dateaccessioned;
820 $subfields->{3}->{'Subfield_Mark'}='e';
821 $subfields->{3}->{'Subfield_Value'}=$booksellerid;
822 $subfields->{4}->{'Subfield_Mark'}='b';
823 $subfields->{4}->{'Subfield_Value'}=$homebranch;
824 $subfields->{5}->{'Subfield_Mark'}='l';
825 $subfields->{5}->{'Subfield_Value'}=$holdingbranch;
826 $subfields->{6}->{'Subfield_Mark'}='c';
827 $subfields->{6}->{'Subfield_Value'}=$price;
828 $subfields->{7}->{'Subfield_Mark'}='c';
829 $subfields->{7}->{'Subfield_Value'}=$replacementprice;
830 $subfields->{8}->{'Subfield_Mark'}='d';
831 $subfields->{8}->{'Subfield_Value'}=$replacementpricedate;
833 $subfields->{9}->{'Subfield_Mark'}='h';
834 $subfields->{9}->{'Subfield_Value'}='Not for loan';
837 $subfields->{10}->{'Subfield_Mark'}='j';
838 $subfields->{10}->{'Subfield_Value'}='Item lost';
841 $subfields->{11}->{'Subfield_Mark'}='j';
842 $subfields->{11}->{'Subfield_Value'}='Item withdrawn';
845 $subfields->{12}->{'Subfield_Mark'}='z';
846 $subfields->{12}->{'Subfield_Value'}=$itemnotes;
851 ($env, $Tag_ID) = addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
853 $env->{'linkid'}=$Tag_ID;
856 $subfields2->{1}->{'Subfield_Mark'}='a';
857 $subfields2->{1}->{'Subfield_Value'}='Coast Mountains School District';
858 $subfields2->{1}->{'Subfield_Mark'}='b';
859 $subfields2->{1}->{'Subfield_Value'}=$homebranch;
860 $subfields2->{1}->{'Subfield_Mark'}='c';
861 $subfields2->{1}->{'Subfield_Value'}=$itemtype;
862 $subfields2->{2}->{'Subfield_Mark'}='m';
863 $subfields2->{2}->{'Subfield_Value'}=$subclass;
864 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields2);
869 # Update the item with itemnumber $item->{'itemnumber'}
870 # This routine should also modify the corresponding MARC record data. (852 and
871 # 876 tags with 876p tag the same as $item->{'barcode'}
873 # This routine should also check to see which fields are actually being
874 # modified, and log all changes.
876 my ($env, $item) = @_;
878 my $itemnumber=$item->{'itemnumber'};
879 my $biblionumber=$item->{'biblionumber'};
880 my $biblioitemnumber=$item->{'biblioitemnumber'};
881 my $barcode=$item->{'barcode'};
882 my $dateaccessioned=$item->{'dateaccessioned'};
883 my $booksellerid=$item->{'booksellerid'};
884 my $homebranch=$item->{'homebranch'};
885 my $price=$item->{'price'};
886 my $replacementprice=$item->{'replacementprice'};
887 my $replacementpricedate=$item->{'replacementpricedate'};
888 my $multivolume=$item->{'multivolume'};
889 my $stack=$item->{'stack'};
890 my $notforloan=$item->{'notforloan'};
891 my $itemlost=$item->{'itemlost'};
892 my $wthdrawn=$item->{'wthdrawn'};
893 my $bulk=$item->{'bulk'};
894 my $restricted=$item->{'restricted'};
895 my $binding=$item->{'binding'};
896 my $itemnotes=$item->{'itemnotes'};
897 my $holdingbranch=$item->{'holdingbranch'};
898 my $interim=$item->{'interim'};
899 my $sth=$dbh->prepare("select * from items where itemnumber=$itemnumber");
901 my $olditem=$sth->fetchrow_hashref;
902 my $q_barcode=$dbh->quote($olditem->{'barcode'});
903 $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");
905 my ($Subfield876_ID, $Record_ID) = $sth->fetchrow;
906 $sth=$dbh->prepare("select Subfield_Value from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_ID=$Subfield876_ID");
908 my ($link) = $sth->fetchrow;
909 $sth=$dbh->prepare("select Subfield_ID from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_Value=$link and !(Subfield_ID=$Subfield876_ID)");
911 my ($Subfield852_ID) = $sth->fetchrow;
913 if ($item->{'barcode'} ne $olditem->{'barcode'}) {
914 logchange('kohadb', 'change', 'items', 'barcode', $olditem->{'barcode'}, $item->{'barcode'});
915 my $q_barcode=$dbh->quote($item->{'barcode'});
916 my $sth=$dbh->prepare("update items set barcode=$q_barcode where itemnumber=$itemnumber");
918 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'p', $olditem->{'barcode'}, $item->{'barcode'}, $Subfield876_ID);
919 logchange('marc', 'change', $Record_ID, '876', 'p', $Subfield_Key, $olditem->{'barcode'}, $item->{'barcode'});
921 if ($item->{'booksellerid'} ne $olditem->{'booksellerid'}) {
922 logchange('kohadb', 'change', 'items', 'booksellerid', $olditem->{'booksellerid'}, $item->{'booksellerid'});
923 my $q_booksellerid=$dbh->quote($item->{'booksellerid'});
924 my $sth=$dbh->prepare("update items set booksellerid=$q_booksellerid where itemnumber=$itemnumber");
926 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'e', $olditem->{'booksellerid'}, $item->{'booksellerid'}, $Subfield876_ID);
927 logchange('marc', 'change', $Record_ID, '876', 'e', $Subfield_Key, $olditem->{'booksellerid'}, $item->{'booksellerid'});
929 if ($item->{'dateaccessioned'} ne $olditem->{'dateaccessioned'}) {
930 logchange('kohadb', 'change', 'items', 'dateaccessioned', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
931 my $q_dateaccessioned=$dbh->quote($item->{'dateaccessioned'});
932 my $sth=$dbh->prepare("update items set dateaccessioned=$q_dateaccessioned where itemnumber=$itemnumber");
934 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'd', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'}, $Subfield876_ID);
935 logchange('marc', 'change', $Record_ID, '876', 'd', $Subfield_Key, $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
937 if ($item->{'homebranch'} ne $olditem->{'homebranch'}) {
938 logchange('kohadb', 'change', 'items', 'homebranch', $olditem->{'homebranch'}, $item->{'homebranch'});
939 my $q_homebranch=$dbh->quote($item->{'homebranch'});
940 my $sth=$dbh->prepare("update items set homebranch=$q_homebranch where itemnumber=$itemnumber");
942 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'b', $olditem->{'homebranch'}, $item->{'homebranch'}, $Subfield876_ID);
943 logchange('marc', 'change', $Record_ID, '876', 'b', $Subfield_Key, $olditem->{'homebranch'}, $item->{'homebranch'});
945 if ($item->{'holdingbranch'} ne $olditem->{'holdingbranch'}) {
946 logchange('kohadb', 'change', 'items', 'holdingbranch', $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
947 my $q_holdingbranch=$dbh->quote($item->{'holdingbranch'});
948 my $sth=$dbh->prepare("update items set holdingbranch=$q_holdingbranch where itemnumber=$itemnumber");
950 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'l', $olditem->{'holdingbranch'}, $item->{'holdingbranch'}, $Subfield876_ID);
951 logchange('marc', 'change', $Record_ID, '876', 'l', $Subfield_Key, $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
953 if ($item->{'price'} ne $olditem->{'price'}) {
954 logchange('kohadb', 'change', 'items', 'price', $olditem->{'price'}, $item->{'price'});
955 my $q_price=$dbh->quote($item->{'price'});
956 my $sth=$dbh->prepare("update items set price=$q_price where itemnumber=$itemnumber");
958 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'price'}, $item->{'price'}, $Subfield876_ID);
959 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'price'}, $item->{'price'});
961 if ($item->{'itemnotes'} ne $olditem->{'itemnotes'}) {
962 logchange('kohadb', 'change', 'items', 'itemnotes', $olditem->{'itemnotes'}, $item->{'itemnotes'});
963 my $q_itemnotes=$dbh->quote($item->{'itemnotes'});
964 my $sth=$dbh->prepare("update items set itemnotes=$q_itemnotes where itemnumber=$itemnumber");
966 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'itemnotes'}, $item->{'itemnotes'}, $Subfield876_ID);
967 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'itemnotes'}, $item->{'itemnotes'});
969 if ($item->{'notforloan'} ne $olditem->{'notforloan'}) {
970 logchange('kohadb', 'change', 'items', 'notforloan', $olditem->{'notforloan'}, $item->{'notforloan'});
971 my $sth=$dbh->prepare("update items set notforloan=$notforloan where itemnumber=$itemnumber");
973 if ($item->{'notforloan'}) {
974 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
975 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
977 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
978 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
981 if ($item->{'itemlost'} ne $olditem->{'itemlost'}) {
982 logchange('kohadb', 'change', 'items', 'itemlost', $olditem->{'itemlost'}, $item->{'itemlost'});
983 my $sth=$dbh->prepare("update items set itemlost=$itemlost where itemnumber=$itemnumber");
985 if ($item->{'itemlost'}) {
986 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
987 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
989 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
990 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
993 if ($item->{'wthdrawn'} ne $olditem->{'wthdrawn'}) {
994 logchange('kohadb', 'change', 'items', 'wthdrawn', $olditem->{'wthdrawn'}, $item->{'wthdrawn'});
995 my $sth=$dbh->prepare("update items set wthdrawn=$wthdrawn where itemnumber=$itemnumber");
997 if ($item->{'wthdrawn'}) {
998 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
999 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1001 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
1002 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1005 if ($item->{'restricted'} ne $olditem->{'restricted'}) {
1006 logchange('kohadb', 'change', 'items', 'restricted', $olditem->{'restricted'}, $item->{'restricted'});
1007 my $sth=$dbh->prepare("update items set restricted=$restricted where itemnumber=$itemnumber");
1009 if ($item->{'restricted'}) {
1010 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1011 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1013 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1014 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1019 END { } # module clean-up code here (global destructor)