View | Details | Raw Unified | Return to bug 12343
Collapse All | Expand All

(-)a/C4/Biblio.pm (-10 / +13 lines)
Lines 2190-2209 sub TransformKohaToMarc { Link Here
2190
    my $record = MARC::Record->new();
2190
    my $record = MARC::Record->new();
2191
    SetMarcUnicodeFlag( $record, C4::Context->preference("marcflavour") );
2191
    SetMarcUnicodeFlag( $record, C4::Context->preference("marcflavour") );
2192
    my $db_to_marc = C4::Context->marcfromkohafield;
2192
    my $db_to_marc = C4::Context->marcfromkohafield;
2193
    my $tag_hr = {};
2193
    while ( my ($name, $value) = each %$hash ) {
2194
    while ( my ($name, $value) = each %$hash ) {
2194
        next unless my $dtm = $db_to_marc->{''}->{$name};
2195
        next unless my $dtm = $db_to_marc->{''}->{$name};
2195
        next unless ( scalar( @$dtm ) );
2196
        next unless ( scalar( @$dtm ) );
2196
        my ($tag, $letter) = @$dtm;
2197
        my ($tag, $letter) = @$dtm; $tag .= '';
2197
        foreach my $value ( split(/\s?\|\s?/, $value, -1) ) {
2198
        foreach my $value ( split(/\s?\|\s?/, $value, -1) ) {
2198
            if ( my $field = $record->field($tag) ) {
2199
            $value eq '' && next;
2199
                $field->add_subfields( $letter => $value );
2200
            $tag_hr->{$tag} //= [];
2200
            }
2201
            push @{$tag_hr->{$tag}}, [($letter, $value)];
2201
            else {
2202
                $record->insert_fields_ordered( MARC::Field->new(
2203
                    $tag, " ", " ", $letter => $value ) );
2204
            }
2205
        }
2202
        }
2206
2203
    }
2204
    foreach my $tag (sort keys %$tag_hr) {
2205
        my @sfl = @{$tag_hr->{$tag}};
2206
        @sfl = sort { $a->[0] cmp $b->[0]; } @sfl;
2207
        @sfl = map { @{$_}; } @sfl;
2208
        $record->insert_fields_ordered(
2209
            MARC::Field->new($tag, " ", " ", @sfl)
2210
        );
2207
    }
2211
    }
2208
    return $record;
2212
    return $record;
2209
}
2213
}
2210
- 

Return to bug 12343