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 situatoin.
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 bibliosubjects 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 bibliosubjects (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 bibliosubjects where biblionumber=$biblionumber and subject=$q_origsubject");
324 # Subroutine to log changes to databases
326 if ($database eq 'kohadb') {
332 print "KOHA: $type $section $item $original $new\n";
333 } elsif ($database eq 'marc') {
338 my $subfield_ID=shift;
341 print "MARC: $type $Record_ID $tag $mark $subfield_ID $original $new\n";
346 # Subroutine to add a tag to an existing MARC Record. If a new linkage id is
347 # desired, set $env->{'linkage'} to 1. If an existing linkage id should be
348 # set, set $env->{'linkid'} to the link number.
349 my ($env, $Record_ID, $tag, $Indicator1, $Indicator2, $subfields) = @_;
351 ($Indicator1) || ($Indicator1=' ');
352 ($Indicator2) || ($Indicator2=' ');
353 my $firstdigit=substr($tag,0,1);
355 foreach (sort keys %$subfields) {
356 my $Subfield_Mark=$subfields->{$_}->{'Subfield_Mark'};
357 my $Subfield_Value=$subfields->{$_}->{'Subfield_Value'};
358 my $q_Subfield_Value=$dbh->quote($Subfield_Value);
360 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '$Subfield_Mark', $q_Subfield_Value)");
363 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_Mark, Subfield_Value) values ('$Subfield_Mark', $q_Subfield_Value)");
365 my $Subfield_Key=$dbh->{'mysql_insertid'};
366 $Subfield_ID=$Subfield_Key;
367 $sth=$dbh->prepare("update $firstdigit\XX_Subfield_Table set Subfield_ID=$Subfield_ID where Subfield_Key=$Subfield_Key");
371 if (my $linkid=$env->{'linkid'}) {
373 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$linkid')");
376 my $sth=$dbh->prepare("insert into $firstdigit\XX_Tag_Table (Indicator1, Indicator2, Tag, Subfield_ID) values ('$Indicator1', '$Indicator2', '$tag', $Subfield_ID)");
378 my $Tag_Key=$dbh->{'mysql_insertid'};
380 $sth=$dbh->prepare("update $firstdigit\XX_Tag_Table set Tag_ID=$Tag_ID where Tag_Key=$Tag_Key");
382 $sth=$dbh->prepare("insert into Bib_Table (Record_ID, Tag_$firstdigit\XX_ID) values ($Record_ID, $Tag_ID)");
384 if ($env->{'linkage'}) {
385 my $sth=$dbh->prepare("insert into $firstdigit\XX_Subfield_Table (Subfield_ID, Subfield_Mark, Subfield_Value) values ($Subfield_ID, '8', '$Tag_ID')");
391 return ($env, $Tag_ID);
395 my ($env, $biblioitem) = @_;
397 my $biblionumber=$biblioitem->{'biblionumber'};
398 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
399 my $volume=$biblioitem->{'volume'};
400 my $q_volume=$dbh->quote($volume);
401 my $number=$biblioitem->{'number'};
402 my $q_number=$dbh->quote($number);
403 my $classification=$biblioitem->{'classification'};
404 my $q_classification=$dbh->quote($classification);
405 my $itemtype=$biblioitem->{'itemtype'};
406 my $q_itemtype=$dbh->quote($itemtype);
407 my $isbn=$biblioitem->{'isbn'};
408 my $q_isbn=$dbh->quote($isbn);
409 my $issn=$biblioitem->{'issn'};
410 my $q_issn=$dbh->quote($issn);
411 my $dewey=$biblioitem->{'dewey'};
413 ($dewey == 0) && ($dewey='');
414 my $subclass=$biblioitem->{'subclass'};
415 my $q_subclass=$dbh->quote($subclass);
416 my $publicationyear=$biblioitem->{'publicationyear'};
417 my $publishercode=$biblioitem->{'publishercode'};
418 my $q_publishercode=$dbh->quote($publishercode);
419 my $volumedate=$biblioitem->{'volumedate'};
420 my $q_volumedate=$dbh->quote($volumedate);
421 my $illus=$biblioitem->{'illus'};
422 my $q_illus=$dbh->quote($illus);
423 my $pages=$biblioitem->{'pages'};
424 my $q_pages=$dbh->quote($pages);
425 my $notes=$biblioitem->{'notes'};
426 my $q_notes=$dbh->quote($notes);
427 my $size=$biblioitem->{'size'};
428 my $q_size=$dbh->quote($size);
429 my $place=$biblioitem->{'place'};
430 my $q_place=$dbh->quote($place);
431 my $lccn=$biblioitem->{'lccn'};
432 my $q_lccn=$dbh->quote($lccn);
435 # Unless the $env->{'marconly'} flag is set, update the biblioitems table with
438 unless ($env->{'marconly'}) {
439 #my $sth=$dbh->prepare("lock tables biblioitems write");
441 my $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
443 my ($biblioitemnumber) =$sth->fetchrow;
445 $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)");
447 #my $sth=$dbh->prepare("unlock tables");
452 # Should we check if there is already a biblioitem/marc with the
453 # same isbn/lccn/issn?
455 my $sth=$dbh->prepare("select title,unititle,seriestitle,copyrightdate,notes,author from biblio where biblionumber=$biblionumber");
457 my ($title, $unititle,$seriestitle,$copyrightdate,$biblionotes,$author) = $sth->fetchrow;
458 $sth=$dbh->prepare("select subtitle from bibliosubtitle where biblionumber=$biblionumber");
460 my ($subtitle) = $sth->fetchrow;
461 $sth=$dbh->prepare("select author from additionalauthors where biblionumber=$biblionumber");
463 my @additionalauthors;
464 while (my ($additionalauthor) = $sth->fetchrow) {
465 push (@additionalauthors, $additionalauthor);
467 $sth=$dbh->prepare("select subject from bibliosubject where biblionumber=$biblionumber");
470 while (my ($subject) = $sth->fetchrow) {
471 push (@subjects, $subject);
476 $sth=$dbh->prepare("insert into Resource_Table (Record_ID) values (0)");
478 my $Resource_ID=$dbh->{'mysql_insertid'};
479 my $Record_ID=$Resource_ID;
480 $sth=$dbh->prepare("update Resource_Table set Record_ID=$Record_ID where Resource_ID=$Resource_ID");
486 $subfields->{1}->{'Subfield_Mark'}='a';
487 $subfields->{1}->{'Subfield_Value'}=$title;
489 $subfields->{2}->{'Subfield_Mark'}='b';
490 $subfields->{2}->{'Subfield_Value'}=$subtitle;
493 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
499 $subfields->{1}->{'Subfield_Mark'}='a';
500 $subfields->{1}->{'Subfield_Value'}=$author;
502 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
507 $subfields->{1}->{'Subfield_Mark'}='a';
508 $subfields->{1}->{'Subfield_Value'}=$seriestitle;
510 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
515 $subfields->{1}->{'Subfield_Mark'}='a';
516 $subfields->{1}->{'Subfield_Value'}=$biblionotes;
517 $subfields->{2}->{'Subfield_Mark'}='3';
518 $subfields->{2}->{'Subfield_Value'}='biblio';
520 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
523 foreach (@additionalauthors) {
525 (next) unless ($author);
527 $subfields->{1}->{'Subfield_Mark'}='a';
528 $subfields->{1}->{'Subfield_Value'}=$author;
529 $subfields->{2}->{'Subfield_Mark'}='e';
530 $subfields->{2}->{'Subfield_Value'}='author';
532 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
536 (next) unless ($illus);
538 $subfields->{1}->{'Subfield_Mark'}='a';
539 $subfields->{1}->{'Subfield_Value'}=$illus;
540 $subfields->{2}->{'Subfield_Mark'}='e';
541 $subfields->{2}->{'Subfield_Value'}='illustrator';
543 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
546 foreach (@subjects) {
548 (next) unless ($subject);
550 $subfields->{1}->{'Subfield_Mark'}='a';
551 $subfields->{1}->{'Subfield_Value'}=$subject;
553 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
560 $subfields->{1}->{'Subfield_Mark'}='a';
561 $subfields->{1}->{'Subfield_Value'}=$isbn;
563 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
568 $subfields->{1}->{'Subfield_Mark'}='a';
569 $subfields->{1}->{'Subfield_Value'}=$lccn;
571 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
576 $subfields->{1}->{'Subfield_Mark'}='a';
577 $subfields->{1}->{'Subfield_Value'}=$issn;
579 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
584 $subfields->{1}->{'Subfield_Mark'}='a';
585 $subfields->{1}->{'Subfield_Value'}=$dewey;
587 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
589 # DEWEY subclass and itemtype
592 $subfields->{1}->{'Subfield_Mark'}='a';
593 $subfields->{1}->{'Subfield_Value'}=$itemtype;
594 $subfields->{2}->{'Subfield_Mark'}='b';
595 $subfields->{2}->{'Subfield_Value'}=$subclass;
596 $subfields->{3}->{'Subfield_Mark'}='c';
597 $subfields->{3}->{'Subfield_Value'}=$biblionumber;
598 $subfields->{4}->{'Subfield_Mark'}='d';
599 $subfields->{4}->{'Subfield_Value'}=$biblioitemnumber;
601 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
606 $subfields->{1}->{'Subfield_Mark'}='a';
607 $subfields->{1}->{'Subfield_Value'}=$place;
608 $subfields->{2}->{'Subfield_Mark'}='b';
609 $subfields->{2}->{'Subfield_Value'}=$publishercode;
610 $subfields->{3}->{'Subfield_Mark'}='c';
611 $subfields->{3}->{'Subfield_Value'}=$publicationyear;
612 if ($copyrightdate) {
613 $subfields->{4}->{'Subfield_Mark'}='c';
614 $subfields->{4}->{'Subfield_Value'}="c$copyrightdate";
617 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
620 if ($pages || $size) {
622 $subfields->{1}->{'Subfield_Mark'}='a';
623 $subfields->{1}->{'Subfield_Value'}=$pages;
624 $subfields->{2}->{'Subfield_Mark'}='c';
625 $subfields->{2}->{'Subfield_Value'}=$size;
627 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
630 if ($volume || $number) {
632 $subfields->{1}->{'Subfield_Mark'}='v';
633 $subfields->{1}->{'Subfield_Value'}=$volume;
634 $subfields->{2}->{'Subfield_Mark'}='n';
635 $subfields->{2}->{'Subfield_Value'}=$number;
637 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
642 $subfields->{1}->{'Subfield_Mark'}='a';
643 $subfields->{1}->{'Subfield_Value'}=$notes;
644 $subfields->{2}->{'Subfield_Mark'}='3';
645 $subfields->{2}->{'Subfield_Value'}='biblioitem';
647 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
651 return ($env, $Record_ID);
654 sub updateBiblioItem {
655 # Update the biblioitem with biblioitemnumber $biblioitem->{'biblioitemnumber'}
657 # This routine should also check to see which fields are actually being
658 # modified, and log all changes.
660 my ($env, $biblioitem) = @_;
663 my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
664 my $sth=$dbh->prepare("select * from biblioitems where biblioitemnumber=$biblioitemnumber");
665 # obi = original biblioitem
666 my $obi=$sth->fetchrow_hashref;
667 $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");
669 my ($Record_ID) = $sth->fetchrow;
670 if ($biblioitem->{'biblionumber'} ne $obi->{'biblionumber'}) {
671 logchange('kohadb', 'change', 'biblioitems', 'biblionumber', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
672 my $sth=$dbh->prepare("update biblioitems set biblionumber=$biblioitem->{'biblionumber'} where biblioitemnumber=$biblioitemnumber");
673 logchange('marc', 'change', $Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
674 changeSubfield($Record_ID, '090', 'c', $obi->{'biblionumber'}, $biblioitem->{'biblionumber'});
676 if ($biblioitem->{'volume'} ne $obi->{'volume'}) {
677 logchange('kohadb', 'change', 'biblioitems', 'volume', $obi->{'volume'}, $biblioitem->{'volume'});
678 my $q_volume=$dbh->quote($biblioitem->{'volume'});
679 my $sth=$dbh->prepare("update biblioitems set volume=$q_volume where biblioitemnumber=$biblioitemnumber");
680 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
681 changeSubfield($Record_ID, '440', 'v', $obi->{'volume'}, $biblioitem->{'volume'});
683 if ($biblioitem->{'number'} ne $obi->{'number'}) {
684 logchange('kohadb', 'change', 'biblioitems', 'number', $obi->{'number'}, $biblioitem->{'number'});
685 my $q_number=$dbh->quote($biblioitem->{'number'});
686 my $sth=$dbh->prepare("update biblioitems set number=$q_number where biblioitemnumber=$biblioitemnumber");
687 logchange('marc', 'change', $Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
688 changeSubfield($Record_ID, '440', 'v', $obi->{'number'}, $biblioitem->{'number'});
690 if ($biblioitem->{'itemtype'} ne $obi->{'itemtype'}) {
691 logchange('kohadb', 'change', 'biblioitems', 'itemtype', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
692 my $q_itemtype=$dbh->quote($biblioitem->{'itemtype'});
693 my $sth=$dbh->prepare("update biblioitems set itemtype=$q_itemtype where biblioitemnumber=$biblioitemnumber");
694 logchange('marc', 'change', $Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
695 changeSubfield($Record_ID, '090', 'a', $obi->{'itemtype'}, $biblioitem->{'itemtype'});
697 if ($biblioitem->{'isbn'} ne $obi->{'isbn'}) {
698 logchange('kohadb', 'change', 'biblioitems', 'isbn', $obi->{'isbn'}, $biblioitem->{'isbn'});
699 my $q_isbn=$dbh->quote($biblioitem->{'isbn'});
700 my $sth=$dbh->prepare("update biblioitems set isbn=$q_isbn where biblioitemnumber=$biblioitemnumber");
701 logchange('marc', 'change', $Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
702 changeSubfield($Record_ID, '020', 'a', $obi->{'isbn'}, $biblioitem->{'isbn'});
704 if ($biblioitem->{'issn'} ne $obi->{'issn'}) {
705 logchange('kohadb', 'change', 'biblioitems', 'issn', $obi->{'issn'}, $biblioitem->{'issn'});
706 my $q_issn=$dbh->quote($biblioitem->{'issn'});
707 my $sth=$dbh->prepare("update biblioitems set issn=$q_issn where biblioitemnumber=$biblioitemnumber");
708 logchange('marc', 'change', $Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
709 changeSubfield($Record_ID, '022', 'a', $obi->{'issn'}, $biblioitem->{'issn'});
711 if ($biblioitem->{'dewey'} ne $obi->{'dewey'}) {
712 logchange('kohadb', 'change', 'biblioitems', 'dewey', $obi->{'dewey'}, $biblioitem->{'dewey'});
713 my $sth=$dbh->prepare("update biblioitems set dewey=$biblioitem->{'dewey'} where biblioitemnumber=$biblioitemnumber");
714 logchange('marc', 'change', $Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
715 changeSubfield($Record_ID, '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
717 if ($biblioitem->{'subclass'} ne $obi->{'subclass'}) {
718 logchange('kohadb', 'change', 'biblioitems', 'subclass', $obi->{'subclass'}, $biblioitem->{'subclass'});
719 my $q_subclass=$dbh->quote($biblioitem->{'subclass'});
720 my $sth=$dbh->prepare("update biblioitems set subclass=$q_subclass where biblioitemnumber=$biblioitemnumber");
721 logchange('marc', 'change', $Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
722 changeSubfield($Record_ID, '090', 'b', $obi->{'subclass'}, $biblioitem->{'subclass'});
724 if ($biblioitem->{'place'} ne $obi->{'place'}) {
725 logchange('kohadb', 'change', 'biblioitems', 'place', $obi->{'place'}, $biblioitem->{'place'});
726 my $q_place=$dbh->quote($biblioitem->{'place'});
727 my $sth=$dbh->prepare("update biblioitems set place=$q_place where biblioitemnumber=$biblioitemnumber");
728 logchange('marc', 'change', $Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
729 changeSubfield($Record_ID, '260', 'a', $obi->{'place'}, $biblioitem->{'place'});
731 if ($biblioitem->{'publishercode'} ne $obi->{'publishercode'}) {
732 logchange('kohadb', 'change', 'biblioitems', 'publishercode', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
733 my $q_publishercode=$dbh->quote($biblioitem->{'publishercode'});
734 my $sth=$dbh->prepare("update biblioitems set publishercode=$q_publishercode where biblioitemnumber=$biblioitemnumber");
735 logchange('marc', 'change', $Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
736 changeSubfield($Record_ID, '260', 'b', $obi->{'publishercode'}, $biblioitem->{'publishercode'});
738 if ($biblioitem->{'publicationyear'} ne $obi->{'publicationyear'}) {
739 logchange('kohadb', 'change', 'biblioitems', 'publicationyear', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
740 my $q_publicationyear=$dbh->quote($biblioitem->{'publicationyear'});
741 my $sth=$dbh->prepare("update biblioitems set publicationyear=$q_publicationyear where biblioitemnumber=$biblioitemnumber");
742 logchange('marc', 'change', $Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
743 changeSubfield($Record_ID, '260', 'c', $obi->{'publicationyear'}, $biblioitem->{'publicationyear'});
745 if ($biblioitem->{'illus'} ne $obi->{'illus'}) {
746 logchange('kohadb', 'change', 'biblioitems', 'illus', $obi->{'illus'}, $biblioitem->{'illus'});
747 my $q_illus=$dbh->quote($biblioitem->{'illus'});
748 my $sth=$dbh->prepare("update biblioitems set illus=$q_illus where biblioitemnumber=$biblioitemnumber");
749 logchange('marc', 'change', $Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
750 changeSubfield($Record_ID, '700', 'a', $obi->{'illus'}, $biblioitem->{'illus'});
752 if ($biblioitem->{'pages'} ne $obi->{'pages'}) {
753 logchange('kohadb', 'change', 'biblioitems', 'pages', $obi->{'pages'}, $biblioitem->{'pages'});
754 my $q_pages=$dbh->quote($biblioitem->{'pages'});
755 my $sth=$dbh->prepare("update biblioitems set pages=$q_pages where biblioitemnumber=$biblioitemnumber");
756 logchange('marc', 'change', $Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
757 changeSubfield($Record_ID, '300', 'a', $obi->{'pages'}, $biblioitem->{'pages'});
759 if ($biblioitem->{'size'} ne $obi->{'size'}) {
760 logchange('kohadb', 'change', 'biblioitems', 'size', $obi->{'size'}, $biblioitem->{'size'});
761 my $q_size=$dbh->quote($biblioitem->{'size'});
762 my $sth=$dbh->prepare("update biblioitems set size=$q_size where biblioitemnumber=$biblioitemnumber");
763 logchange('marc', 'change', $Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
764 changeSubfield($Record_ID, '300', 'c', $obi->{'size'}, $biblioitem->{'size'});
766 if ($biblioitem->{'notes'} ne $obi->{'notes'}) {
767 logchange('kohadb', 'change', 'biblioitems', 'notes', $obi->{'notes'}, $biblioitem->{'notes'});
768 my $q_notes=$dbh->quote($biblioitem->{'notes'});
769 my $sth=$dbh->prepare("update biblioitems set notes=$q_notes where biblioitemnumber=$biblioitemnumber");
770 logchange('marc', 'change', $Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
771 changeSubfield($Record_ID, '500', 'a', $obi->{'notes'}, $biblioitem->{'notes'});
773 if ($biblioitem->{'lccn'} ne $obi->{'lccn'}) {
774 logchange('kohadb', 'change', 'biblioitems', 'lccn', $obi->{'lccn'}, $biblioitem->{'lccn'});
775 my $q_lccn=$dbh->quote($biblioitem->{'lccn'});
776 my $sth=$dbh->prepare("update biblioitems set lccn=$q_lccn where biblioitemnumber=$biblioitemnumber");
777 logchange('marc', 'change', $Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
778 changeSubfield($Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
787 my ($env, $Record_ID, $item) = @_;
789 my $barcode=$item->{'barcode'};
790 my $q_barcode=$dbh->quote($barcode);
791 my $biblionumber=$item->{'biblionumber'};
792 my $biblioitemnumber=$item->{'biblioitemnumber'};
793 my $dateaccessioned=$item->{'dateaccessioned'};
794 my $booksellerid=$item->{'booksellerid'};
795 my $q_booksellerid=$dbh->quote($booksellerid);
796 my $homebranch=$item->{'homebranch'};
797 my $q_homebranch=$dbh->quote($homebranch);
798 my $holdingbranch=$item->{'holdingbranch'};
799 my $price=$item->{'price'};
800 my $replacementprice=$item->{'replacementprice'};
801 my $replacementpricedate=$item->{'replacementpricedate'};
802 my $q_replacementpricedate=$dbh->quote($replacementpricedate);
803 my $notforloan=$item->{'notforloan'};
804 my $itemlost=$item->{'itemlost'};
805 my $wthdrawn=$item->{'wthdrawn'};
806 my $restricted=$item->{'restricted'};
807 my $itemnotes=$item->{'itemnotes'};
808 my $q_itemnotes=$dbh->quote($itemnotes);
809 my $itemtype=$item->{'itemtype'};
810 my $subclass=$item->{'subclass'};
814 unless ($env->{'marconly'}) {
815 my $sth=$dbh->prepare("select max(itemnumber) from items");
817 my ($itemnumber) =$sth->fetchrow;
819 $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)");
826 $subfields->{1}->{'Subfield_Mark'}='p';
827 $subfields->{1}->{'Subfield_Value'}=$barcode;
828 $subfields->{2}->{'Subfield_Mark'}='d';
829 $subfields->{2}->{'Subfield_Value'}=$dateaccessioned;
830 $subfields->{3}->{'Subfield_Mark'}='e';
831 $subfields->{3}->{'Subfield_Value'}=$booksellerid;
832 $subfields->{4}->{'Subfield_Mark'}='b';
833 $subfields->{4}->{'Subfield_Value'}=$homebranch;
834 $subfields->{5}->{'Subfield_Mark'}='l';
835 $subfields->{5}->{'Subfield_Value'}=$holdingbranch;
836 $subfields->{6}->{'Subfield_Mark'}='c';
837 $subfields->{6}->{'Subfield_Value'}=$price;
838 $subfields->{7}->{'Subfield_Mark'}='c';
839 $subfields->{7}->{'Subfield_Value'}=$replacementprice;
840 $subfields->{8}->{'Subfield_Mark'}='d';
841 $subfields->{8}->{'Subfield_Value'}=$replacementpricedate;
843 $subfields->{9}->{'Subfield_Mark'}='h';
844 $subfields->{9}->{'Subfield_Value'}='Not for loan';
847 $subfields->{10}->{'Subfield_Mark'}='j';
848 $subfields->{10}->{'Subfield_Value'}='Item lost';
851 $subfields->{11}->{'Subfield_Mark'}='j';
852 $subfields->{11}->{'Subfield_Value'}='Item withdrawn';
855 $subfields->{12}->{'Subfield_Mark'}='z';
856 $subfields->{12}->{'Subfield_Value'}=$itemnotes;
861 ($env, $Tag_ID) = addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
863 $env->{'linkid'}=$Tag_ID;
866 $subfields2->{1}->{'Subfield_Mark'}='a';
867 $subfields2->{1}->{'Subfield_Value'}='Coast Mountains School District';
868 $subfields2->{1}->{'Subfield_Mark'}='b';
869 $subfields2->{1}->{'Subfield_Value'}=$homebranch;
870 $subfields2->{1}->{'Subfield_Mark'}='c';
871 $subfields2->{1}->{'Subfield_Value'}=$itemtype;
872 $subfields2->{2}->{'Subfield_Mark'}='m';
873 $subfields2->{2}->{'Subfield_Value'}=$subclass;
874 addTag($env, $Record_ID, $tag, ' ', ' ', $subfields2);
879 # Update the item with itemnumber $item->{'itemnumber'}
880 # This routine should also modify the corresponding MARC record data. (852 and
881 # 876 tags with 876p tag the same as $item->{'barcode'}
883 # This routine should also check to see which fields are actually being
884 # modified, and log all changes.
886 my ($env, $item) = @_;
888 my $itemnumber=$item->{'itemnumber'};
889 my $biblionumber=$item->{'biblionumber'};
890 my $biblioitemnumber=$item->{'biblioitemnumber'};
891 my $barcode=$item->{'barcode'};
892 my $dateaccessioned=$item->{'dateaccessioned'};
893 my $booksellerid=$item->{'booksellerid'};
894 my $homebranch=$item->{'homebranch'};
895 my $price=$item->{'price'};
896 my $replacementprice=$item->{'replacementprice'};
897 my $replacementpricedate=$item->{'replacementpricedate'};
898 my $multivolume=$item->{'multivolume'};
899 my $stack=$item->{'stack'};
900 my $notforloan=$item->{'notforloan'};
901 my $itemlost=$item->{'itemlost'};
902 my $wthdrawn=$item->{'wthdrawn'};
903 my $bulk=$item->{'bulk'};
904 my $restricted=$item->{'restricted'};
905 my $binding=$item->{'binding'};
906 my $itemnotes=$item->{'itemnotes'};
907 my $holdingbranch=$item->{'holdingbranch'};
908 my $interim=$item->{'interim'};
909 my $sth=$dbh->prepare("select * from items where itemnumber=$itemnumber");
911 my $olditem=$sth->fetchrow_hashref;
912 my $q_barcode=$dbh->quote($olditem->{'barcode'});
913 $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");
915 my ($Subfield876_ID, $Record_ID) = $sth->fetchrow;
916 $sth=$dbh->prepare("select Subfield_Value from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_ID=$Subfield876_ID");
918 my ($link) = $sth->fetchrow;
919 $sth=$dbh->prepare("select Subfield_ID from 8XX_Subfield_Table where Subfield_Mark=8 and Subfield_Value=$link and !(Subfield_ID=$Subfield876_ID)");
921 my ($Subfield852_ID) = $sth->fetchrow;
923 if ($item->{'barcode'} ne $olditem->{'barcode'}) {
924 logchange('kohadb', 'change', 'items', 'barcode', $olditem->{'barcode'}, $item->{'barcode'});
925 my $q_barcode=$dbh->quote($item->{'barcode'});
926 my $sth=$dbh->prepare("update items set barcode=$q_barcode where itemnumber=$itemnumber");
928 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'p', $olditem->{'barcode'}, $item->{'barcode'}, $Subfield876_ID);
929 logchange('marc', 'change', $Record_ID, '876', 'p', $Subfield_Key, $olditem->{'barcode'}, $item->{'barcode'});
931 if ($item->{'booksellerid'} ne $olditem->{'booksellerid'}) {
932 logchange('kohadb', 'change', 'items', 'booksellerid', $olditem->{'booksellerid'}, $item->{'booksellerid'});
933 my $q_booksellerid=$dbh->quote($item->{'booksellerid'});
934 my $sth=$dbh->prepare("update items set booksellerid=$q_booksellerid where itemnumber=$itemnumber");
936 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'e', $olditem->{'booksellerid'}, $item->{'booksellerid'}, $Subfield876_ID);
937 logchange('marc', 'change', $Record_ID, '876', 'e', $Subfield_Key, $olditem->{'booksellerid'}, $item->{'booksellerid'});
939 if ($item->{'dateaccessioned'} ne $olditem->{'dateaccessioned'}) {
940 logchange('kohadb', 'change', 'items', 'dateaccessioned', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
941 my $q_dateaccessioned=$dbh->quote($item->{'dateaccessioned'});
942 my $sth=$dbh->prepare("update items set dateaccessioned=$q_dateaccessioned where itemnumber=$itemnumber");
944 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'd', $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'}, $Subfield876_ID);
945 logchange('marc', 'change', $Record_ID, '876', 'd', $Subfield_Key, $olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
947 if ($item->{'homebranch'} ne $olditem->{'homebranch'}) {
948 logchange('kohadb', 'change', 'items', 'homebranch', $olditem->{'homebranch'}, $item->{'homebranch'});
949 my $q_homebranch=$dbh->quote($item->{'homebranch'});
950 my $sth=$dbh->prepare("update items set homebranch=$q_homebranch where itemnumber=$itemnumber");
952 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'b', $olditem->{'homebranch'}, $item->{'homebranch'}, $Subfield876_ID);
953 logchange('marc', 'change', $Record_ID, '876', 'b', $Subfield_Key, $olditem->{'homebranch'}, $item->{'homebranch'});
955 if ($item->{'holdingbranch'} ne $olditem->{'holdingbranch'}) {
956 logchange('kohadb', 'change', 'items', 'holdingbranch', $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
957 my $q_holdingbranch=$dbh->quote($item->{'holdingbranch'});
958 my $sth=$dbh->prepare("update items set holdingbranch=$q_holdingbranch where itemnumber=$itemnumber");
960 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'l', $olditem->{'holdingbranch'}, $item->{'holdingbranch'}, $Subfield876_ID);
961 logchange('marc', 'change', $Record_ID, '876', 'l', $Subfield_Key, $olditem->{'holdingbranch'}, $item->{'holdingbranch'});
963 if ($item->{'price'} ne $olditem->{'price'}) {
964 logchange('kohadb', 'change', 'items', 'price', $olditem->{'price'}, $item->{'price'});
965 my $q_price=$dbh->quote($item->{'price'});
966 my $sth=$dbh->prepare("update items set price=$q_price where itemnumber=$itemnumber");
968 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'price'}, $item->{'price'}, $Subfield876_ID);
969 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'price'}, $item->{'price'});
971 if ($item->{'itemnotes'} ne $olditem->{'itemnotes'}) {
972 logchange('kohadb', 'change', 'items', 'itemnotes', $olditem->{'itemnotes'}, $item->{'itemnotes'});
973 my $q_itemnotes=$dbh->quote($item->{'itemnotes'});
974 my $sth=$dbh->prepare("update items set itemnotes=$q_itemnotes where itemnumber=$itemnumber");
976 my ($Subfield_ID, $Subfield_Key) = changeSubfield($Record_ID, '876', 'c', $olditem->{'itemnotes'}, $item->{'itemnotes'}, $Subfield876_ID);
977 logchange('marc', 'change', $Record_ID, '876', 'c', $Subfield_Key, $olditem->{'itemnotes'}, $item->{'itemnotes'});
979 if ($item->{'notforloan'} ne $olditem->{'notforloan'}) {
980 logchange('kohadb', 'change', 'items', 'notforloan', $olditem->{'notforloan'}, $item->{'notforloan'});
981 my $sth=$dbh->prepare("update items set notforloan=$notforloan where itemnumber=$itemnumber");
983 if ($item->{'notforloan'}) {
984 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
985 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
987 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Not for loan', $Subfield876_ID);
988 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Not for loan');
991 if ($item->{'itemlost'} ne $olditem->{'itemlost'}) {
992 logchange('kohadb', 'change', 'items', 'itemlost', $olditem->{'itemlost'}, $item->{'itemlost'});
993 my $sth=$dbh->prepare("update items set itemlost=$itemlost where itemnumber=$itemnumber");
995 if ($item->{'itemlost'}) {
996 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
997 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
999 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Item lost', $Subfield876_ID);
1000 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Item lost');
1003 if ($item->{'wthdrawn'} ne $olditem->{'wthdrawn'}) {
1004 logchange('kohadb', 'change', 'items', 'wthdrawn', $olditem->{'wthdrawn'}, $item->{'wthdrawn'});
1005 my $sth=$dbh->prepare("update items set wthdrawn=$wthdrawn where itemnumber=$itemnumber");
1007 if ($item->{'wthdrawn'}) {
1008 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
1009 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1011 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Withdrawn', $Subfield876_ID);
1012 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Withdrawn');
1015 if ($item->{'restricted'} ne $olditem->{'restricted'}) {
1016 logchange('kohadb', 'change', 'items', 'restricted', $olditem->{'restricted'}, $item->{'restricted'});
1017 my $sth=$dbh->prepare("update items set restricted=$restricted where itemnumber=$itemnumber");
1019 if ($item->{'restricted'}) {
1020 my ($Subfield_ID, $Subfield_Key) = addSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1021 logchange('marc', 'add', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1023 my ($Subfield_ID, $Subfield_Key) = deleteSubfield($Record_ID, '876', 'h', 'Restricted', $Subfield876_ID);
1024 logchange('marc', 'delete', $Record_ID, '876', 'h', $Subfield_Key, 'Restricted');
1031 END { } # module clean-up code here (global destructor)