Lines 32-41
use Koha::CsvProfiles;
Link Here
|
32 |
use Koha::Exporter::Record; |
32 |
use Koha::Exporter::Record; |
33 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
33 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
34 |
|
34 |
|
35 |
my ( $output_format, $timestamp, $dont_export_items, $csv_profile_id, $deleted_barcodes, $clean, $filename, $record_type, $id_list_file, $starting_authid, $ending_authid, $authtype, $starting_biblionumber, $ending_biblionumber, $itemtype, $starting_callnumber, $ending_callnumber, $start_accession, $end_accession, $help ); |
35 |
my ( |
|
|
36 |
$output_format, |
37 |
$timestamp, |
38 |
$include_deleted, |
39 |
$deleted_only, |
40 |
$dont_export_items, |
41 |
$csv_profile_id, |
42 |
$deleted_barcodes, |
43 |
$clean, |
44 |
$filename, |
45 |
$record_type, |
46 |
$id_list_file, |
47 |
$starting_authid, |
48 |
$ending_authid, |
49 |
$authtype, |
50 |
$starting_biblionumber, |
51 |
$ending_biblionumber, |
52 |
$itemtype, |
53 |
$starting_callnumber, |
54 |
$ending_callnumber, |
55 |
$start_accession, |
56 |
$end_accession, |
57 |
$help |
58 |
); |
59 |
|
36 |
GetOptions( |
60 |
GetOptions( |
37 |
'format=s' => \$output_format, |
61 |
'format=s' => \$output_format, |
38 |
'date=s' => \$timestamp, |
62 |
'date=s' => \$timestamp, |
|
|
63 |
'include_deleted' => \$include_deleted, |
64 |
'deleted_only' => \$deleted_only, |
39 |
'dont_export_items' => \$dont_export_items, |
65 |
'dont_export_items' => \$dont_export_items, |
40 |
'csv_profile_id=s' => \$csv_profile_id, |
66 |
'csv_profile_id=s' => \$csv_profile_id, |
41 |
'deleted_barcodes' => \$deleted_barcodes, |
67 |
'deleted_barcodes' => \$deleted_barcodes, |
Lines 67-72
$record_type ||= 'bibs';
Link Here
|
67 |
# Retrocompatibility for the format parameter |
93 |
# Retrocompatibility for the format parameter |
68 |
$output_format = 'iso2709' if $output_format eq 'marc'; |
94 |
$output_format = 'iso2709' if $output_format eq 'marc'; |
69 |
|
95 |
|
|
|
96 |
if ($include_deleted || $deleted_only) { |
97 |
if ($record_type ne 'bibs') { |
98 |
pod2usage(q|Option "--include_deleted" or "--deleted_only" can only be used with "--record-type=bibs"|); |
99 |
} |
100 |
if (!$timestamp) { |
101 |
pod2usage(q|Option "--include_deleted" or "--deleted_only" requires that "--date" is also set|); |
102 |
} |
103 |
if ($output_format eq 'csv') { |
104 |
pod2usage(q|Option "--include_deleted" or "--deleted_only" cannot be used with "--format=csv"|); |
105 |
} |
106 |
} |
107 |
|
70 |
if ( $output_format eq 'csv' and $record_type eq 'auths' ) { |
108 |
if ( $output_format eq 'csv' and $record_type eq 'auths' ) { |
71 |
pod2usage(q|CSV output is only available for biblio records|); |
109 |
pod2usage(q|CSV output is only available for biblio records|); |
72 |
} |
110 |
} |
Lines 97-122
open STDOUT, '>', $filename if $filename;
Link Here
|
97 |
|
135 |
|
98 |
|
136 |
|
99 |
my @record_ids; |
137 |
my @record_ids; |
|
|
138 |
my @deleted_record_ids; |
100 |
|
139 |
|
101 |
$timestamp = ($timestamp) ? output_pref({ dt => dt_from_string($timestamp), dateformat => 'iso', dateonly => 0, }): ''; |
140 |
$timestamp = ($timestamp) ? output_pref({ dt => dt_from_string($timestamp), dateformat => 'iso', dateonly => 0, }): ''; |
102 |
|
141 |
|
103 |
if ( $record_type eq 'bibs' ) { |
142 |
if ( $record_type eq 'bibs' ) { |
104 |
if ( $timestamp ) { |
143 |
if ( $timestamp ) { |
105 |
push @record_ids, $_->{biblionumber} for @{ |
144 |
unless ($deleted_only) { |
106 |
$dbh->selectall_arrayref(q| ( |
145 |
push @record_ids, $_->{biblionumber} for @{ |
107 |
SELECT biblio_metadata.biblionumber |
146 |
$dbh->selectall_arrayref(q| ( |
108 |
FROM biblio_metadata |
147 |
SELECT biblio_metadata.biblionumber |
109 |
LEFT JOIN items USING(biblionumber) |
148 |
FROM biblio_metadata |
110 |
WHERE biblio_metadata.timestamp >= ? |
149 |
LEFT JOIN items USING(biblionumber) |
111 |
OR items.timestamp >= ? |
150 |
WHERE biblio_metadata.timestamp >= ? |
112 |
) UNION ( |
151 |
OR items.timestamp >= ? |
113 |
SELECT biblio_metadata.biblionumber |
152 |
) UNION ( |
114 |
FROM biblio_metadata |
153 |
SELECT biblio_metadata.biblionumber |
115 |
LEFT JOIN deleteditems USING(biblionumber) |
154 |
FROM biblio_metadata |
116 |
WHERE biblio_metadata.timestamp >= ? |
155 |
LEFT JOIN deleteditems USING(biblionumber) |
117 |
OR deleteditems.timestamp >= ? |
156 |
WHERE biblio_metadata.timestamp >= ? |
118 |
) |, { Slice => {} }, ( $timestamp ) x 4 ); |
157 |
OR deleteditems.timestamp >= ? |
119 |
}; |
158 |
) |, { Slice => {} }, ( $timestamp ) x 4 ); |
|
|
159 |
}; |
160 |
} |
161 |
if ($include_deleted || $deleted_only) { |
162 |
push @deleted_record_ids, $_->{biblionumber} for @{ |
163 |
$dbh->selectall_arrayref(q| |
164 |
SELECT `biblionumber` |
165 |
FROM `deletedbiblio` |
166 |
WHERE `timestamp` >= ? |
167 |
|, { Slice => {} }, $timestamp); |
168 |
}; |
169 |
} |
120 |
} else { |
170 |
} else { |
121 |
my $conditions = { |
171 |
my $conditions = { |
122 |
( $starting_biblionumber or $ending_biblionumber ) |
172 |
( $starting_biblionumber or $ending_biblionumber ) |
Lines 199-204
else {
Link Here
|
199 |
Koha::Exporter::Record::export( |
249 |
Koha::Exporter::Record::export( |
200 |
{ record_type => $record_type, |
250 |
{ record_type => $record_type, |
201 |
record_ids => \@record_ids, |
251 |
record_ids => \@record_ids, |
|
|
252 |
deleted_record_ids => \@deleted_record_ids, |
202 |
format => $output_format, |
253 |
format => $output_format, |
203 |
csv_profile_id => $csv_profile_id, |
254 |
csv_profile_id => $csv_profile_id, |
204 |
export_items => (not $dont_export_items), |
255 |
export_items => (not $dont_export_items), |
Lines 215-221
export records - This script exports record (biblios or authorities)
Link Here
|
215 |
|
266 |
|
216 |
=head1 SYNOPSIS |
267 |
=head1 SYNOPSIS |
217 |
|
268 |
|
218 |
export_records.pl [-h|--help] [--format=format] [--date=datetime] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile |
269 |
export_records.pl [-h|--help] [--format=format] [--date=datetime] [--include_deleted] [--deleted_only] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile |
219 |
|
270 |
|
220 |
=head1 OPTIONS |
271 |
=head1 OPTIONS |
221 |
|
272 |
|
Lines 236-241
Print a brief help message.
Link Here
|
236 |
mm/dd/yyyy[ hh:mm:ss] for us) records exported are the ones that |
287 |
mm/dd/yyyy[ hh:mm:ss] for us) records exported are the ones that |
237 |
have been modified since DATETIME. |
288 |
have been modified since DATETIME. |
238 |
|
289 |
|
|
|
290 |
=item B<--include_deleted> |
291 |
|
292 |
--include_deleted If enabled, when using --date option, deleted records will be included in export as marc records |
293 |
with leader record status set to "d" (deleted). |
294 |
|
295 |
=item B<--include_deleted> |
296 |
|
297 |
--include_deleted If enabled, when using --date option, only deleted records will be included in export as marc |
298 |
records with leader record status set to "d" (deleted). |
299 |
|
239 |
=item B<--record-type> |
300 |
=item B<--record-type> |
240 |
|
301 |
|
241 |
--record-type=TYPE TYPE is 'bibs' or 'auths'. |
302 |
--record-type=TYPE TYPE is 'bibs' or 'auths'. |