[PATCH 03/11] [SIGNED-OFF] bug 5579: fix moving items from bib to another

Galen Charlton gmcharlt at gmail.com
Fri Mar 4 00:24:19 CET 2011


* Must signal both bibs to be reindexed

Signed-off-by: Galen Charlton <gmcharlt at gmail.com>
Signed-off-by: Claire Hernandez <claire.hernandez at biblibre.com>
---
 C4/Items.pm |   55 +++++++------------------------------------------------
 1 files changed, 7 insertions(+), 48 deletions(-)

diff --git a/C4/Items.pm b/C4/Items.pm
index 741ea4d..50e3760 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -2021,59 +2021,18 @@ sub MoveItemFromBiblio {
     $sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?");
     my $return = $sth->execute($tobiblioitem, $tobiblio, $itemnumber, $frombiblio);
     if ($return == 1) {
-
-	# Getting framework
-	my $frameworkcode = GetFrameworkCode($frombiblio);
-
-	# Getting marc field for itemnumber
-	my ($itemtag, $itemsubfield) = GetMarcFromKohaField('items.itemnumber', $frameworkcode);
-
-	# Getting the record we want to move the item from
-	my $record = GetMarcBiblio($frombiblio);
-
-	# The item we want to move
-	my $item;
-
-	# For each item
-	foreach my $fielditem ($record->field($itemtag)){
-		# If it is the item we want to move
-		if ($fielditem->subfield($itemsubfield) == $itemnumber) {
-		    # We save it
-		    $item = $fielditem;
-		    # Then delete it from the record
-		    $record->delete_field($fielditem) 
-		}
-	}
-
-	# If we found an item (should always true, except in case of database-marcxml inconsistency)
-	if ($item) {
-
+        ModZebra( $tobiblio, "specialUpdate", "biblioserver", undef, undef );
+        ModZebra( $frombiblio, "specialUpdate", "biblioserver", undef, undef );
 	    # Checking if the item we want to move is in an order 
-	    my $order = GetOrderFromItemnumber($itemnumber);
+        my $order = GetOrderFromItemnumber($itemnumber);
 	    if ($order) {
-		# Replacing the biblionumber within the order if necessary
-		$order->{'biblionumber'} = $tobiblio;
+		    # Replacing the biblionumber within the order if necessary
+		    $order->{'biblionumber'} = $tobiblio;
 	        ModOrder($order);
 	    }
-
-	    # Saving the modification
-	    #ModBiblioMarc($record, $frombiblio, $frameworkcode);
-
-	    # Getting the record we want to move the item to
-	    #$record = GetMarcBiblio($tobiblio);
-
-	    # Inserting the previously saved item
-	    #$record->insert_fields_ordered($item);	
-
-	    # Saving the modification
-	    #ModBiblioMarc($record, $tobiblio, $frameworkcode);
-
-	} else {
-	    return undef;
+        return $tobiblio;
 	}
-    } else {
-	return undef;
-    }
+    return;
 }
 
 =head2 DelItemCheck
-- 
1.7.1




More information about the Koha-patches mailing list