|
Lines 21-26
use MARC::File::XML;
Link Here
|
| 21 |
use List::MoreUtils qw( uniq ); |
21 |
use List::MoreUtils qw( uniq ); |
| 22 |
use Getopt::Long qw( GetOptions ); |
22 |
use Getopt::Long qw( GetOptions ); |
| 23 |
use Pod::Usage qw( pod2usage ); |
23 |
use Pod::Usage qw( pod2usage ); |
|
|
24 |
use Carp; |
| 24 |
|
25 |
|
| 25 |
use Koha::Script; |
26 |
use Koha::Script; |
| 26 |
use C4::Auth; |
27 |
use C4::Auth; |
|
Lines 56-61
my (
Link Here
|
| 56 |
$start_accession, |
57 |
$start_accession, |
| 57 |
$end_accession, |
58 |
$end_accession, |
| 58 |
$marc_conditions, |
59 |
$marc_conditions, |
|
|
60 |
$set_deleted_marc_conditions, |
| 59 |
$help |
61 |
$help |
| 60 |
); |
62 |
); |
| 61 |
|
63 |
|
|
Lines 82-87
GetOptions(
Link Here
|
| 82 |
'start_accession=s' => \$start_accession, |
84 |
'start_accession=s' => \$start_accession, |
| 83 |
'end_accession=s' => \$end_accession, |
85 |
'end_accession=s' => \$end_accession, |
| 84 |
'marc_conditions=s' => \$marc_conditions, |
86 |
'marc_conditions=s' => \$marc_conditions, |
|
|
87 |
'set_deleted_marc_conditions=s' => \$set_deleted_marc_conditions, |
| 85 |
'h|help|?' => \$help |
88 |
'h|help|?' => \$help |
| 86 |
) || pod2usage(1); |
89 |
) || pod2usage(1); |
| 87 |
|
90 |
|
|
Lines 131-139
if ( $deleted_barcodes and $record_type ne 'bibs' ) {
Link Here
|
| 131 |
$start_accession = dt_from_string( $start_accession ) if $start_accession; |
134 |
$start_accession = dt_from_string( $start_accession ) if $start_accession; |
| 132 |
$end_accession = dt_from_string( $end_accession ) if $end_accession; |
135 |
$end_accession = dt_from_string( $end_accession ) if $end_accession; |
| 133 |
|
136 |
|
| 134 |
# Parse marc conditions |
137 |
|
| 135 |
my @marc_conditions; |
138 |
sub _parse_marc_conditions { |
| 136 |
if ($marc_conditions) { |
139 |
my ($marc_conditions) = @_; |
|
|
140 |
my @marc_conditions; |
| 137 |
foreach my $condition (split(/,\s*/, $marc_conditions)) { |
141 |
foreach my $condition (split(/,\s*/, $marc_conditions)) { |
| 138 |
if ($condition =~ /^(\d{3})([\w\d]?)(=|(?:!=)|>|<)([^,]+)$/) { |
142 |
if ($condition =~ /^(\d{3})([\w\d]?)(=|(?:!=)|>|<)([^,]+)$/) { |
| 139 |
push @marc_conditions, [$1, $2, $3, $4]; |
143 |
push @marc_conditions, [$1, $2, $3, $4]; |
|
Lines 142-150
if ($marc_conditions) {
Link Here
|
| 142 |
push @marc_conditions, [$2, $3, $1 eq 'exists' ? '?' : '!?']; |
146 |
push @marc_conditions, [$2, $3, $1 eq 'exists' ? '?' : '!?']; |
| 143 |
} |
147 |
} |
| 144 |
else { |
148 |
else { |
| 145 |
die("Invalid condititon: $condition"); |
149 |
croak "Invalid condititon: $condition"; |
| 146 |
} |
150 |
} |
| 147 |
} |
151 |
} |
|
|
152 |
return @marc_conditions; |
| 153 |
} |
| 154 |
|
| 155 |
# Parse marc conditions |
| 156 |
my @marc_conditions; |
| 157 |
if ($marc_conditions) { |
| 158 |
@marc_conditions = _parse_marc_conditions($marc_conditions); |
| 159 |
} |
| 160 |
|
| 161 |
my @set_deleted_marc_conditions; |
| 162 |
if ($set_deleted_marc_conditions) { |
| 163 |
@set_deleted_marc_conditions = _parse_marc_conditions($set_deleted_marc_conditions); |
| 148 |
} |
164 |
} |
| 149 |
|
165 |
|
| 150 |
my $dbh = C4::Context->dbh; |
166 |
my $dbh = C4::Context->dbh; |
|
Lines 283-288
else {
Link Here
|
| 283 |
{ record_type => $record_type, |
299 |
{ record_type => $record_type, |
| 284 |
record_ids => \@record_ids, |
300 |
record_ids => \@record_ids, |
| 285 |
record_conditions => @marc_conditions ? \@marc_conditions : undef, |
301 |
record_conditions => @marc_conditions ? \@marc_conditions : undef, |
|
|
302 |
deleted_record_conditions => @set_deleted_marc_conditions ? \@set_deleted_marc_conditions : undef, |
| 286 |
deleted_record_ids => \@deleted_record_ids, |
303 |
deleted_record_ids => \@deleted_record_ids, |
| 287 |
format => $output_format, |
304 |
format => $output_format, |
| 288 |
csv_profile_id => $csv_profile_id, |
305 |
csv_profile_id => $csv_profile_id, |
|
Lines 428-433
Print a brief help message.
Link Here
|
| 428 |
<marc_target> exists regardless of target value, and |
445 |
<marc_target> exists regardless of target value, and |
| 429 |
"exists(<marc_target>)" will include marc records where |
446 |
"exists(<marc_target>)" will include marc records where |
| 430 |
no <marc_target> exists. |
447 |
no <marc_target> exists. |
|
|
448 |
=item B<--set_deleted_marc_conditions> |
| 449 |
|
| 450 |
--set_deleted_marc_conditions=CONDITIONS Set record deleted flag for biblios with MARC |
| 451 |
data matching CONDITIONS.Only include biblios with MARC data matching CONDITIONS. |
| 452 |
See --marc_conditions for more information about the CONDITIONS format. |
| 431 |
|
453 |
|
| 432 |
=back |
454 |
=back |
| 433 |
|
455 |
|