Lines 2365-2370
sub GetMarcHosts {
Link Here
|
2365 |
return $marchostsarray; |
2365 |
return $marchostsarray; |
2366 |
} |
2366 |
} |
2367 |
|
2367 |
|
|
|
2368 |
=head2 UpsertMarcSubfield |
2369 |
|
2370 |
my $record = C4::Biblio::UpsertMarcSubfield($MARC::Record, $fieldTag, $subfieldCode, $subfieldContent); |
2371 |
|
2372 |
=cut |
2373 |
|
2374 |
sub UpsertMarcSubfield { |
2375 |
my ($record, $tag, $code, $content) = @_; |
2376 |
my $f = $record->field($tag); |
2377 |
|
2378 |
if ($f) { |
2379 |
$f->update( $code => $content ); |
2380 |
} |
2381 |
else { |
2382 |
my $f = MARC::Field->new( $tag, '', '', $code => $content); |
2383 |
$record->insert_fields_ordered( $f ); |
2384 |
} |
2385 |
} |
2386 |
|
2387 |
=head2 UpsertMarcControlField |
2388 |
|
2389 |
my $record = C4::Biblio::UpsertMarcControlField($MARC::Record, $fieldTag, $content); |
2390 |
|
2391 |
=cut |
2392 |
|
2393 |
sub UpsertMarcControlField { |
2394 |
my ($record, $tag, $content) = @_; |
2395 |
die "UpsertMarcControlField() \$tag '$tag' is not a control field\n" unless 0+$tag < 10; |
2396 |
my $f = $record->field($tag); |
2397 |
|
2398 |
if ($f) { |
2399 |
$f->update( $content ); |
2400 |
} |
2401 |
else { |
2402 |
my $f = MARC::Field->new($tag, $content); |
2403 |
$record->insert_fields_ordered( $f ); |
2404 |
} |
2405 |
} |
2406 |
|
2368 |
=head2 GetFrameworkCode |
2407 |
=head2 GetFrameworkCode |
2369 |
|
2408 |
|
2370 |
$frameworkcode = GetFrameworkCode( $biblionumber ) |
2409 |
$frameworkcode = GetFrameworkCode( $biblionumber ) |
Lines 3317-3372
the MARC XML.
Link Here
|
3317 |
sub _koha_marc_update_bib_ids { |
3356 |
sub _koha_marc_update_bib_ids { |
3318 |
my ( $record, $frameworkcode, $biblionumber, $biblioitemnumber ) = @_; |
3357 |
my ( $record, $frameworkcode, $biblionumber, $biblioitemnumber ) = @_; |
3319 |
|
3358 |
|
3320 |
# we must add bibnum and bibitemnum in MARC::Record... |
|
|
3321 |
# we build the new field with biblionumber and biblioitemnumber |
3322 |
# we drop the original field |
3323 |
# we add the new builded field. |
3324 |
my ( $biblio_tag, $biblio_subfield ) = GetMarcFromKohaField( "biblio.biblionumber", $frameworkcode ); |
3359 |
my ( $biblio_tag, $biblio_subfield ) = GetMarcFromKohaField( "biblio.biblionumber", $frameworkcode ); |
3325 |
die qq{No biblionumber tag for framework "$frameworkcode"} unless $biblio_tag; |
3360 |
die qq{No biblionumber tag for framework "$frameworkcode"} unless $biblio_tag; |
3326 |
my ( $biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField( "biblioitems.biblioitemnumber", $frameworkcode ); |
3361 |
my ( $biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField( "biblioitems.biblioitemnumber", $frameworkcode ); |
3327 |
die qq{No biblioitemnumber tag for framework "$frameworkcode"} unless $biblioitem_tag; |
3362 |
die qq{No biblioitemnumber tag for framework "$frameworkcode"} unless $biblioitem_tag; |
3328 |
|
3363 |
|
3329 |
if ( $biblio_tag == $biblioitem_tag ) { |
3364 |
if ( $biblio_tag < 10 ) { |
3330 |
|
3365 |
C4::Biblio::UpsertMarcControlField( $record, $biblio_tag, $biblionumber ); |
3331 |
# biblionumber & biblioitemnumber are in the same field (can't be <10 as fields <10 have only 1 value) |
|
|
3332 |
my $new_field = MARC::Field->new( |
3333 |
$biblio_tag, '', '', |
3334 |
"$biblio_subfield" => $biblionumber, |
3335 |
"$biblioitem_subfield" => $biblioitemnumber |
3336 |
); |
3337 |
|
3338 |
# drop old field and create new one... |
3339 |
my $old_field = $record->field($biblio_tag); |
3340 |
$record->delete_field($old_field) if $old_field; |
3341 |
$record->insert_fields_ordered($new_field); |
3342 |
} else { |
3366 |
} else { |
3343 |
|
3367 |
C4::Biblio::UpsertMarcSubfield($record, $biblio_tag, $biblio_subfield, $biblionumber); |
3344 |
# biblionumber & biblioitemnumber are in different fields |
3368 |
} |
3345 |
|
3369 |
if ( $biblioitem_tag < 10 ) { |
3346 |
# deal with biblionumber |
3370 |
C4::Biblio::UpsertMarcControlField( $record, $biblioitem_tag, $biblioitemnumber ); |
3347 |
my ( $new_field, $old_field ); |
3371 |
} else { |
3348 |
if ( $biblio_tag < 10 ) { |
3372 |
C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber); |
3349 |
$new_field = MARC::Field->new( $biblio_tag, $biblionumber ); |
|
|
3350 |
} else { |
3351 |
$new_field = MARC::Field->new( $biblio_tag, '', '', "$biblio_subfield" => $biblionumber ); |
3352 |
} |
3353 |
|
3354 |
# drop old field and create new one... |
3355 |
$old_field = $record->field($biblio_tag); |
3356 |
$record->delete_field($old_field) if $old_field; |
3357 |
$record->insert_fields_ordered($new_field); |
3358 |
|
3359 |
# deal with biblioitemnumber |
3360 |
if ( $biblioitem_tag < 10 ) { |
3361 |
$new_field = MARC::Field->new( $biblioitem_tag, $biblioitemnumber, ); |
3362 |
} else { |
3363 |
$new_field = MARC::Field->new( $biblioitem_tag, '', '', "$biblioitem_subfield" => $biblioitemnumber, ); |
3364 |
} |
3365 |
|
3366 |
# drop old field and create new one... |
3367 |
$old_field = $record->field($biblioitem_tag); |
3368 |
$record->delete_field($old_field) if $old_field; |
3369 |
$record->insert_fields_ordered($new_field); |
3370 |
} |
3373 |
} |
3371 |
} |
3374 |
} |
3372 |
|
3375 |
|