pod2usage(q|CSV output is only available for biblio records|);
}
+if ( $output_format eq 'csv' and not $csv_profile_id ) {
+ pod2usage(q|Define a csv profile to export in CSV|);
+}
if ( $timestamp and $record_type ne 'bibs' ) {
pod2usage(q|--timestamp can only be used with biblios|);
my @record_ids;
-$timestamp = ($timestamp) ? output_pref({ dt => dt_from_string($timestamp), dateformat => 'iso', dateonly => 1, }): '';
+$timestamp = ($timestamp) ? output_pref({ dt => dt_from_string($timestamp), dateformat => 'iso', dateonly => 0, }): '';
if ( $record_type eq 'bibs' ) {
if ( $timestamp ) {
push @record_ids, $_->{biblionumber} for @{
$dbh->selectall_arrayref(q| (
- SELECT biblionumber
- FROM biblioitems
+ SELECT biblio_metadata.biblionumber
+ FROM biblio_metadata
LEFT JOIN items USING(biblionumber)
- WHERE biblioitems.timestamp >= ?
+ WHERE biblio_metadata.timestamp >= ?
OR items.timestamp >= ?
) UNION (
- SELECT biblionumber
- FROM biblioitems
+ SELECT biblio_metadata.biblionumber
+ FROM biblio_metadata
LEFT JOIN deleteditems USING(biblionumber)
- WHERE biblioitems.timestamp >= ?
+ WHERE biblio_metadata.timestamp >= ?
OR deleteditems.timestamp >= ?
) |, { Slice => {} }, ( $timestamp ) x 4 );
};
?
C4::Context->preference('item-level_itypes')
? ( 'items.itype' => $itemtype )
- : ( 'biblioitems.itemtype' => $itemtype )
+ : ( 'me.itemtype' => $itemtype )
: ()
),
if ($deleted_barcodes) {
for my $record_id ( @record_ids ) {
- my $q = q|
- |;
- my $barcode = $dbh->selectall_arrayref(q| (
+ my $barcode = $dbh->selectall_arrayref(q|
SELECT DISTINCT barcode
FROM deleteditems
WHERE deleteditems.biblionumber = ?
|, { Slice => {} }, $record_id );
- say $_->{barcode} for @$barcode
+ say $_->{barcode} for @$barcode;
}
}
else {
- unless ( $csv_profile_id ) {
- my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
- $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef;
- }
Koha::Exporter::Record::export(
{ record_type => $record_type,
record_ids => \@record_ids,
=head1 SYNOPSIS
-export_records.pl [-h|--help] [--format=format] [--date=date] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile
+export_records.pl [-h|--help] [--format=format] [--date=datetime] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile
=head1 OPTIONS
=item B<--date>
- --date=DATE DATE should be entered as the 'dateformat' syspref is
- set (dd/mm/yyyy for metric, yyyy-mm-dd for iso,
- mm/dd/yyyy for us) records exported are the ones that
- have been modified since DATE.
+ --date=DATETIME DATETIME should be entered as the 'dateformat' syspref is
+ set (dd/mm/yyyy[ hh:mm:ss] for metric, yyyy-mm-dd[ hh:mm:ss] for iso,
+ mm/dd/yyyy[ hh:mm:ss] for us) records exported are the ones that
+ have been modified since DATETIME.
=item B<--record-type>
=item B<--csv_profile_id>
--csv_profile_id=ID Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl)
- Unless provided, the one defined in the system preference 'ExportWithCsvProfile' will be used.
This can only be used to export biblio records.
=item B<--deleted_barcodes>