From b93586c4a2693f295ebcb1af33aa09b3b96216a0 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Fri, 28 Aug 2009 23:47:42 +0200 Subject: [PATCH] Bug Fixing : GetMarcItem Adding Item2Marc Using itemtag in order to add subfields to the correct field --- C4/Items.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 4d53d91512..e8e0cef3d9 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -46,6 +46,7 @@ BEGIN { AddItem AddItemBatchFromMarc ModItemFromMarc + Item2Marc ModItem ModDateLastSeen ModItemTransfer @@ -1648,23 +1649,28 @@ sub GetMarcItem { # Tack on 'items.' prefix to column names so that TransformKohaToMarc will work. # Also, don't emit a subfield if the underlying field is blank. + + + return Item2Marc($itemrecord,$biblionumber); + +} +sub Item2Marc { + my ($itemrecord,$biblionumber)=@_; my $mungeditem = { map { defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () } keys %{ $itemrecord } }; my $itemmarc = TransformKohaToMarc($mungeditem); + my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",GetFrameworkCode($biblionumber)||''); my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'}); if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) { - my @fields = $itemmarc->fields(); - if ($#fields > -1) { - $fields[0]->add_subfields(@$unlinked_item_subfields); + foreach my $field ($itemmarc->field($itemtag)){ + $field->add_subfields(@$unlinked_item_subfields); } } - - return $itemmarc; - + return $itemmarc; } =head1 PRIVATE FUNCTIONS AND VARIABLES -- 2.39.5