@@ -, +, @@ authority links also get imported --- C4/Biblio.pm | 36 ++++++++++++++++++++++++++++++++++++ acqui/neworderempty.pl | 6 ++---- cataloguing/addbiblio.pl | 3 ++- 3 files changed, 40 insertions(+), 5 deletions(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -136,6 +136,7 @@ BEGIN { &TransformHtmlToMarc &TransformHtmlToXml prepare_host_field + &RemoveItemsAndAuthidsFromRecord ); } @@ -2777,6 +2778,41 @@ sub get_koha_field_from_marc { return $kohafield; } +=head2 RemoveItemsAndAuthidsFromRecord + + RemoveItemsAndAuthidsFromRecord($record); + + Remove all items (952) from the record. + Also removes all authids (subfield 9 in headings) + +=cut + +sub RemoveItemsAndAuthidsFromRecord { + my $record = shift; + my $frameworkcode = shift || ''; + + my $marcflavour = C4::Context->preference("marcflavour"); + my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); + + # Remove all the items from the record + foreach my $item ($record->field($itemtag)) { + $record->delete_field($item); + } + + # Remove all authid links ($9) in the record + if ( $marcflavour eq "MARC21" ) { + my @heading = qw(100 110 111 130 440 600 610 611 630 648 650 651 655 700 710 711 730 800 810 811 830); + foreach (@heading) { + foreach my $field ($record->field($_)) { + $field->delete_subfield(code => '9'); + unless($field->subfields()) { + $record->delete_field($field); + } + } + } + } +} + =head2 TransformMarcToKohaOneField $result = TransformMarcToKohaOneField( $kohatable, $kohafield, $record, $result, $frameworkcode ) --- a/acqui/neworderempty.pl +++ a/acqui/neworderempty.pl @@ -145,10 +145,8 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){ my ($marcrecord, $encoding) = MARCfindbreeding($params->{'breedingid'}); die("Could not find the selected record in the reservoir, bailing") unless $marcrecord; - # Remove all the items (952) from the imported record - foreach my $item ($marcrecord->field('952')) { - $marcrecord->delete_field($item); - } + # Do a cleanup on the imported record + RemoveItemsAndAuthidsFromRecord($marcrecord, $params->{'frameworkcode'}); my $duplicatetitle; #look for duplicates --- a/cataloguing/addbiblio.pl +++ a/cataloguing/addbiblio.pl @@ -795,7 +795,8 @@ if (($biblionumber) && !($breedingid)){ $record = GetMarcBiblio($biblionumber); } if ($breedingid) { - ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ; + ( $record, $encoding ) = MARCfindbreeding( $breedingid ); + RemoveItemsAndAuthidsFromRecord($record, $frameworkcode) if $record; } #populate hostfield if hostbiblionumber is available --