Lines 74-80
at your option, any later version of Perl 5 you may have available.
Link Here
|
74 |
=cut |
74 |
=cut |
75 |
|
75 |
|
76 |
sub copy_field { |
76 |
sub copy_field { |
77 |
my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_; |
77 |
my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n, $dont_erase ) = @_; |
78 |
C4::Koha::Log( "C4::SimpleMARC::copy_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug; |
78 |
C4::Koha::Log( "C4::SimpleMARC::copy_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug; |
79 |
|
79 |
|
80 |
if ( ! ( $record && $fromFieldName && $toFieldName ) ) { return; } |
80 |
if ( ! ( $record && $fromFieldName && $toFieldName ) ) { return; } |
Lines 90-96
sub copy_field {
Link Here
|
90 |
} |
90 |
} |
91 |
} |
91 |
} |
92 |
|
92 |
|
93 |
update_field( $record, $toFieldName, $toSubfieldName, @values ); |
93 |
update_field( $record, $toFieldName, $toSubfieldName, @values, $dont_erase ); |
94 |
|
94 |
|
95 |
} |
95 |
} |
96 |
|
96 |
|
Lines 109-115
sub copy_field {
Link Here
|
109 |
=cut |
109 |
=cut |
110 |
|
110 |
|
111 |
sub update_field { |
111 |
sub update_field { |
112 |
my ( $record, $fieldName, $subfieldName, @values ) = @_; |
112 |
my ( $record, $fieldName, $subfieldName, @values, $dont_erase ) = @_; |
113 |
C4::Koha::Log( "C4::SimpleMARC::update_field( $record, $fieldName, $subfieldName, @values )" ) if $debug; |
113 |
C4::Koha::Log( "C4::SimpleMARC::update_field( $record, $fieldName, $subfieldName, @values )" ) if $debug; |
114 |
|
114 |
|
115 |
if ( ! ( $record && $fieldName ) ) { return; } |
115 |
if ( ! ( $record && $fieldName ) ) { return; } |
Lines 123-130
sub update_field {
Link Here
|
123 |
my $field; |
123 |
my $field; |
124 |
if ( $subfieldName ) { |
124 |
if ( $subfieldName ) { |
125 |
if ( my @fields = $record->field( $fieldName ) ) { |
125 |
if ( my @fields = $record->field( $fieldName ) ) { |
126 |
foreach my $field ( @fields ) { |
126 |
unless ( $dont_erase ) { |
127 |
$field->update( "$subfieldName" => $values[$i++] ); |
127 |
foreach my $field ( @fields ) { |
|
|
128 |
$field->update( "$subfieldName" => $values[$i++] ); |
129 |
} |
128 |
} |
130 |
} |
129 |
if ( $i <= scalar @values - 1 ) { |
131 |
if ( $i <= scalar @values - 1 ) { |
130 |
foreach my $field ( @fields ) { |
132 |
foreach my $field ( @fields ) { |
Lines 260-266
sub field_equals {
Link Here
|
260 |
sub move_field { |
262 |
sub move_field { |
261 |
my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_; |
263 |
my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_; |
262 |
C4::Koha::Log( "C4::SimpleMARC::move_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug; |
264 |
C4::Koha::Log( "C4::SimpleMARC::move_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug; |
263 |
copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ); |
265 |
copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , "don't_erase"); |
264 |
delete_field( $record, $fromFieldName, $fromSubfieldName, $n ); |
266 |
delete_field( $record, $fromFieldName, $fromSubfieldName, $n ); |
265 |
} |
267 |
} |
266 |
|
268 |
|
267 |
- |
|
|