bug 1616: update bib MARC and zebraqueue on item update
authorGalen Charlton <galen.charlton@liblime.com>
Tue, 27 Nov 2007 16:28:09 +0000 (10:28 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 27 Nov 2007 21:51:47 +0000 (15:51 -0600)
Fixed so that when using updateitem.pl to change an
item's lost, damaged, or withdrawn status, the
bib's MARC XML is updated and an entry is added
to zebraqueue.

As part of the fix, C4::Biblio::ModItemInMarconefield
now works correctly.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Biblio.pm
catalogue/updateitem.pl

index 816925b..6444c3c 100755 (executable)
@@ -472,7 +472,8 @@ sub ModItemInMarconefield {
             $tag->update( $tagsubfield => $newvalue );
             $record->delete_field($tag);
             $record->insert_fields_ordered($tag);
-            &ModItemInMarc( $record, $biblionumber, $itemnumber, 0 );
+            my $frameworkcode = GetFrameworkCode( $biblionumber );
+            &ModItemInMarc( $record, $biblionumber, $itemnumber, $frameworkcode );
         }
     }
 }
@@ -481,7 +482,7 @@ sub ModItemInMarconefield {
 
 =over
 
-&ModItemInMarc( $record, $biblionumber, $itemnumber )
+&ModItemInMarc( $record, $biblionumber, $itemnumber, $frameworkcode )
 
 =back
 
index 5add727..b414c30 100755 (executable)
@@ -38,14 +38,18 @@ my $damaged=$cgi->param('damaged');
 my $confirm=$cgi->param('confirm');
 my $dbh = C4::Context->dbh;
 # get the rest of this item's information
-my $item_data_sth = $dbh->prepare("SELECT * FROM items WHERE itemnumber=?");
-$item_data_sth->execute($itemnumber);
-my $item_data_hashref = $item_data_sth->fetchrow_hashref();
+my $item_data_hashref = GetItem($itemnumber, undef);
 
-# superimpose the new on the old
-$item_data_hashref->{'itemlost'} = $itemlost if $itemlost;
-$item_data_hashref->{'wthdrawn'} = $wthdrawn if $wthdrawn;
-$item_data_hashref->{'damaged'} = $damaged if $damaged;
+# modify bib MARC
+if ($itemlost ne $item_data_hashref->{'itemlost'}) {
+    ModItemInMarconefield($biblionumber, $itemnumber, 'items.itemlost', $itemlost);
+}
+if ($wthdrawn ne $item_data_hashref->{'wthdrawn'}) {
+    ModItemInMarconefield($biblionumber, $itemnumber, 'items.wthdrawn', $wthdrawn);
+}
+if ($damaged ne $item_data_hashref->{'damaged'}) {
+    ModItemInMarconefield($biblionumber, $itemnumber, 'items.damaged', $damaged);
+}
 
 # check reservations
 my ($status, $reserve) = CheckReserves($itemnumber, $item_data_hashref->{'barcode'});