From 9afc11a9ebb94bd303c8c3205516b5a3b08b6e6e Mon Sep 17 00:00:00 2001 From: Christophe Croullebois Date: Wed, 7 Dec 2011 11:54:29 +0100 Subject: [PATCH] Bug 7329: Items onloan are deleted when undoing import into catalog 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 Signed-off-by: Chris Cormack (cherry picked from commit 0b39f30a69da728586d9cb27ed6f50983e3336d9) --- C4/ImportBatch.pm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 63cc60b600..64c8c8a97b 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -644,13 +644,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; -- 2.39.5