MT 1094, Following : added a test to check if we really found the item

This commit is contained in:
Matthias Meusburger 2009-09-25 15:30:12 +02:00 committed by Henri-Damien LAURENT
parent 56750eebba
commit d4f06e5023
2 changed files with 19 additions and 11 deletions

View file

@ -2025,6 +2025,7 @@ MoveItemFromBiblio($itenumber, $frombiblio, $tobiblio);
Moves an item from a biblio to another
Returns undef if the move failed or the biblionumber of the destination record otherwise
=cut
sub MoveItemFromBiblio {
my ($itemnumber, $frombiblio, $tobiblio) = @_;
@ -2055,19 +2056,27 @@ sub MoveItemFromBiblio {
$record->delete_field($fielditem)
}
}
# Saving the modification
ModBiblioMarc($record, $frombiblio, $frameworkcode);
# Getting the record we want to move the item to
$record = GetMarcBiblio($tobiblio);
# If we found an item (should always true, except in case of database-marcxml inconsistency)
if ($item) {
# Inserting the previously saved item
$record->insert_fields_ordered($item);
# Saving the modification
ModBiblioMarc($record, $frombiblio, $frameworkcode);
# Saving the modification
ModBiblioMarc($record, $tobiblio, $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;
}
} else {
return -1;
return undef;
}
}

View file

@ -70,10 +70,9 @@ if ($barcode && $biblionumber) {
if ($item) {
my $results = GetBiblioFromItemNumber($itemnumber, $barcode);
my $frombiblionumber = $results->{'biblionumber'};
my $frombiblionumber = $results->{'biblionumber'};
my $moveresult = MoveItemFromBiblio($itemnumber, $frombiblionumber, $biblionumber);
if ($moveresult) {
$template->param(success => 1);
} else {