Lines 2211-2216
sub GetMarcHosts {
Link Here
|
2211 |
return $marchostsarray; |
2211 |
return $marchostsarray; |
2212 |
} |
2212 |
} |
2213 |
|
2213 |
|
|
|
2214 |
=head2 UpsertMarcSubfield |
2215 |
|
2216 |
my $record = C4::Biblio::UpsertMarcSubfield($MARC::Record, $fieldTag, $subfieldCode, $subfieldContent); |
2217 |
|
2218 |
=cut |
2219 |
|
2220 |
sub UpsertMarcSubfield { |
2221 |
my ($record, $tag, $code, $content) = @_; |
2222 |
my $f = $record->field($tag); |
2223 |
|
2224 |
if ($f) { |
2225 |
$f->update( $code => $content ); |
2226 |
} |
2227 |
else { |
2228 |
my $f = MARC::Field->new( $tag, '', '', $code => $content); |
2229 |
$record->insert_fields_ordered( $f ); |
2230 |
} |
2231 |
} |
2232 |
|
2233 |
=head2 UpsertMarcControlField |
2234 |
|
2235 |
my $record = C4::Biblio::UpsertMarcControlField($MARC::Record, $fieldTag, $content); |
2236 |
|
2237 |
=cut |
2238 |
|
2239 |
sub UpsertMarcControlField { |
2240 |
my ($record, $tag, $content) = @_; |
2241 |
die "UpsertMarcControlField() \$tag '$tag' is not a control field\n" unless 0+$tag < 10; |
2242 |
my $f = $record->field($tag); |
2243 |
|
2244 |
if ($f) { |
2245 |
$f->update( $content ); |
2246 |
} |
2247 |
else { |
2248 |
my $f = MARC::Field->new($tag, $content); |
2249 |
$record->insert_fields_ordered( $f ); |
2250 |
} |
2251 |
} |
2252 |
|
2214 |
=head2 GetFrameworkCode |
2253 |
=head2 GetFrameworkCode |
2215 |
|
2254 |
|
2216 |
$frameworkcode = GetFrameworkCode( $biblionumber ) |
2255 |
$frameworkcode = GetFrameworkCode( $biblionumber ) |
Lines 3035-3090
the MARC XML.
Link Here
|
3035 |
sub _koha_marc_update_bib_ids { |
3074 |
sub _koha_marc_update_bib_ids { |
3036 |
my ( $record, $frameworkcode, $biblionumber, $biblioitemnumber ) = @_; |
3075 |
my ( $record, $frameworkcode, $biblionumber, $biblioitemnumber ) = @_; |
3037 |
|
3076 |
|
3038 |
# we must add bibnum and bibitemnum in MARC::Record... |
|
|
3039 |
# we build the new field with biblionumber and biblioitemnumber |
3040 |
# we drop the original field |
3041 |
# we add the new builded field. |
3042 |
my ( $biblio_tag, $biblio_subfield ) = GetMarcFromKohaField( "biblio.biblionumber", $frameworkcode ); |
3077 |
my ( $biblio_tag, $biblio_subfield ) = GetMarcFromKohaField( "biblio.biblionumber", $frameworkcode ); |
3043 |
die qq{No biblionumber tag for framework "$frameworkcode"} unless $biblio_tag; |
3078 |
die qq{No biblionumber tag for framework "$frameworkcode"} unless $biblio_tag; |
3044 |
my ( $biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField( "biblioitems.biblioitemnumber", $frameworkcode ); |
3079 |
my ( $biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField( "biblioitems.biblioitemnumber", $frameworkcode ); |
3045 |
die qq{No biblioitemnumber tag for framework "$frameworkcode"} unless $biblioitem_tag; |
3080 |
die qq{No biblioitemnumber tag for framework "$frameworkcode"} unless $biblioitem_tag; |
3046 |
|
3081 |
|
3047 |
if ( $biblio_tag == $biblioitem_tag ) { |
3082 |
if ( $biblio_tag < 10 ) { |
3048 |
|
3083 |
C4::Biblio::UpsertMarcControlField( $record, $biblio_tag, $biblionumber ); |
3049 |
# biblionumber & biblioitemnumber are in the same field (can't be <10 as fields <10 have only 1 value) |
|
|
3050 |
my $new_field = MARC::Field->new( |
3051 |
$biblio_tag, '', '', |
3052 |
"$biblio_subfield" => $biblionumber, |
3053 |
"$biblioitem_subfield" => $biblioitemnumber |
3054 |
); |
3055 |
|
3056 |
# drop old field and create new one... |
3057 |
my $old_field = $record->field($biblio_tag); |
3058 |
$record->delete_field($old_field) if $old_field; |
3059 |
$record->insert_fields_ordered($new_field); |
3060 |
} else { |
3084 |
} else { |
3061 |
|
3085 |
C4::Biblio::UpsertMarcSubfield($record, $biblio_tag, $biblio_subfield, $biblionumber); |
3062 |
# biblionumber & biblioitemnumber are in different fields |
3086 |
} |
3063 |
|
3087 |
if ( $biblioitem_tag < 10 ) { |
3064 |
# deal with biblionumber |
3088 |
C4::Biblio::UpsertMarcControlField( $record, $biblioitem_tag, $biblioitemnumber ); |
3065 |
my ( $new_field, $old_field ); |
3089 |
} else { |
3066 |
if ( $biblio_tag < 10 ) { |
3090 |
C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber); |
3067 |
$new_field = MARC::Field->new( $biblio_tag, $biblionumber ); |
|
|
3068 |
} else { |
3069 |
$new_field = MARC::Field->new( $biblio_tag, '', '', "$biblio_subfield" => $biblionumber ); |
3070 |
} |
3071 |
|
3072 |
# drop old field and create new one... |
3073 |
$old_field = $record->field($biblio_tag); |
3074 |
$record->delete_field($old_field) if $old_field; |
3075 |
$record->insert_fields_ordered($new_field); |
3076 |
|
3077 |
# deal with biblioitemnumber |
3078 |
if ( $biblioitem_tag < 10 ) { |
3079 |
$new_field = MARC::Field->new( $biblioitem_tag, $biblioitemnumber, ); |
3080 |
} else { |
3081 |
$new_field = MARC::Field->new( $biblioitem_tag, '', '', "$biblioitem_subfield" => $biblioitemnumber, ); |
3082 |
} |
3083 |
|
3084 |
# drop old field and create new one... |
3085 |
$old_field = $record->field($biblioitem_tag); |
3086 |
$record->delete_field($old_field) if $old_field; |
3087 |
$record->insert_fields_ordered($new_field); |
3088 |
} |
3091 |
} |
3089 |
} |
3092 |
} |
3090 |
|
3093 |
|