|
Lines 47-52
GetOptions(
Link Here
|
| 47 |
pod2usage(1) if $want_help; |
47 |
pod2usage(1) if $want_help; |
| 48 |
pod2usage("Parameter marc is mandatory") unless $os_marc_input; |
48 |
pod2usage("Parameter marc is mandatory") unless $os_marc_input; |
| 49 |
|
49 |
|
|
|
50 |
$| = 1; # flushes output |
| 51 |
|
| 50 |
sub _read_marc_code { |
52 |
sub _read_marc_code { |
| 51 |
my $input = shift; |
53 |
my $input = shift; |
| 52 |
my ( $field, $subfield ); |
54 |
my ( $field, $subfield ); |
|
Lines 129-145
my $count_modified = 0;
Link Here
|
| 129 |
|
131 |
|
| 130 |
while ( my ($biblionumber) = $query->fetchrow ) { |
132 |
while ( my ($biblionumber) = $query->fetchrow ) { |
| 131 |
$count_total++; |
133 |
$count_total++; |
| 132 |
my $biblio = Koha::Biblios->find($biblionumber); |
|
|
| 133 |
unless ($biblio) { |
| 134 |
warn "Error in biblio $biblionumber : not found"; |
| 135 |
next; |
| 136 |
} |
| 137 |
my $marc_record = $biblio->metadata->record; |
| 138 |
unless ($marc_record) { |
| 139 |
warn "Error in biblio $biblionumber : can't parse record"; |
| 140 |
next; |
| 141 |
} |
| 142 |
eval { |
134 |
eval { |
|
|
135 |
my $biblio = Koha::Biblios->find($biblionumber); |
| 136 |
unless ($biblio) { |
| 137 |
say "Error with record biblionumber=$biblionumber : not found"; |
| 138 |
next; |
| 139 |
} |
| 140 |
my $marc_record = $biblio->metadata->record; |
| 141 |
unless ($marc_record) { |
| 142 |
say "Error with record biblionumber=$biblionumber : can not parse record"; |
| 143 |
next; |
| 144 |
} |
| 143 |
my $os_new_value = _get_new_value( $biblio, $rules ); |
145 |
my $os_new_value = _get_new_value( $biblio, $rules ); |
| 144 |
my $os_old_value = _get_old_value( $marc_record, $os_field_input, $os_subfield_input ); |
146 |
my $os_old_value = _get_old_value( $marc_record, $os_field_input, $os_subfield_input ); |
| 145 |
if ( $os_new_value != $os_old_value ) { |
147 |
if ( $os_new_value != $os_old_value ) { |
|
Lines 148-166
while ( my ($biblionumber) = $query->fetchrow ) {
Link Here
|
| 148 |
C4::Biblio::ModBiblio( $marc_record, $biblionumber, $biblio->frameworkcode, { disable_autolink => 1 } ); |
150 |
C4::Biblio::ModBiblio( $marc_record, $biblionumber, $biblio->frameworkcode, { disable_autolink => 1 } ); |
| 149 |
$count_modified++; |
151 |
$count_modified++; |
| 150 |
if ($verbose) { |
152 |
if ($verbose) { |
| 151 |
say "Bibliographic record $biblionumber changed to " . ( $os_new_value ? "hidden" : "visible" ) . " in OPAC"; |
153 |
say "Record biblionumber=$biblionumber changed to " . ( $os_new_value ? "hidden" : "visible" ) . " in OPAC"; |
| 152 |
} |
154 |
} |
| 153 |
} elsif ($verbose) { |
155 |
} elsif ($verbose) { |
| 154 |
say "Bibliographic record $biblionumber would have been changed to " . ( $os_new_value ? "hidden" : "visible" ) . " in OPAC"; |
156 |
say "Record biblionumber=$biblionumber would have been changed to " . ( $os_new_value ? "hidden" : "visible" ) . " in OPAC"; |
| 155 |
} |
157 |
} |
| 156 |
} |
158 |
} |
| 157 |
}; |
159 |
}; |
| 158 |
if ($@) { |
160 |
if ($@) { |
| 159 |
warn "Problem with biblio $biblionumber : $@"; |
161 |
say "Error with record biblionumber=$biblionumber : not processed"; |
|
|
162 |
} |
| 163 |
if ($verbose) { |
| 164 |
say "$count_total records processed" unless $count_total % 1000; |
| 160 |
} |
165 |
} |
| 161 |
} |
166 |
} |
| 162 |
|
167 |
|
| 163 |
say "$count_total records processed, $count_modified modified" if $verbose; |
168 |
if ($verbose) { |
|
|
169 |
say "Total $count_total records processed"; |
| 170 |
say "Total $count_modified modified" if $confirm; |
| 171 |
} |
| 164 |
|
172 |
|
| 165 |
=head1 NAME |
173 |
=head1 NAME |
| 166 |
|
174 |
|
| 167 |
- |
|
|