MT 1975 : Fixed broken MoveItemFromBiblio in Items.pm
This commit is contained in:
parent
9eba7dc594
commit
56750eebba
1 changed files with 29 additions and 2 deletions
31
C4/Items.pm
31
C4/Items.pm
|
@ -2032,12 +2032,39 @@ sub MoveItemFromBiblio {
|
|||
my $sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?");
|
||||
my $return = $sth->execute($tobiblio, $tobiblio, $itemnumber, $frombiblio);
|
||||
if ($return == 1) {
|
||||
my $record = GetMarcBiblio($frombiblio);
|
||||
|
||||
# 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)
|
||||
}
|
||||
}
|
||||
# Saving the modification
|
||||
ModBiblioMarc($record, $frombiblio, $frameworkcode);
|
||||
|
||||
# Getting the record we want to move the item to
|
||||
$record = GetMarcBiblio($tobiblio);
|
||||
$frameworkcode = GetFrameworkCode($frombiblio);
|
||||
|
||||
# Inserting the previously saved item
|
||||
$record->insert_fields_ordered($item);
|
||||
|
||||
# Saving the modification
|
||||
ModBiblioMarc($record, $tobiblio, $frameworkcode);
|
||||
} else {
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue