Bug 7329: Items onloan are deleted when undoing import into catalog
authorChristophe Croullebois <christophe.croullebois@biblibre.com>
Wed, 7 Dec 2011 10:54:29 +0000 (11:54 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Wed, 20 Jun 2012 07:20:40 +0000 (09:20 +0200)
this patch checks the "on loan" and "reserved" status before deleting item, and
do noting in this case, so the record can't be deleted due to existing item.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
C4/ImportBatch.pm

index 5bf79bf..c133b5d 100644 (file)
@@ -715,13 +715,18 @@ sub BatchRevertItems {
     $sth->bind_param(1, $import_record_id);
     $sth->execute();
     while (my $row = $sth->fetchrow_hashref()) {
-        DelItem($dbh, $biblionumber, $row->{'itemnumber'});
-        my $updsth = $dbh->prepare("UPDATE import_items SET status = ? WHERE import_items_id = ?");
-        $updsth->bind_param(1, 'reverted');
-        $updsth->bind_param(2, $row->{'import_items_id'});
-        $updsth->execute();
-        $updsth->finish();
-        $num_items_deleted++;
+        my $error = DelItemCheck($dbh, $biblionumber, $row->{'itemnumber'});
+        if ($error == 1){
+            my $updsth = $dbh->prepare("UPDATE import_items SET status = ? WHERE import_items_id = ?");
+            $updsth->bind_param(1, 'reverted');
+            $updsth->bind_param(2, $row->{'import_items_id'});
+            $updsth->execute();
+            $updsth->finish();
+            $num_items_deleted++;
+        }
+        else {
+            next;
+        }
     }
     $sth->finish();
     return $num_items_deleted;