@@ -, +, @@ --- C4/Csv.pm | 13 ------------- Koha/Exporter/Record.pm | 3 ++- misc/export_records.pl | 7 ++++++- tools/export.pl | 10 ++++++++-- 4 files changed, 16 insertions(+), 17 deletions(-) --- a/C4/Csv.pm +++ a/C4/Csv.pm @@ -34,7 +34,6 @@ $VERSION = 3.07.00.049; @EXPORT = qw( &GetCsvProfile - &GetCsvProfileId &GetMarcFieldsForCsv ); @@ -51,18 +50,6 @@ sub GetCsvProfile { return ($sth->fetchrow_hashref); } -# Returns id of csv profile about a given csv profile name -sub GetCsvProfileId { - my ($name) = @_; - my $dbh = C4::Context->dbh; - my $query = "SELECT export_format_id FROM export_format WHERE profile=?"; - - $sth = $dbh->prepare($query); - $sth->execute($name); - - return ( $sth->fetchrow ); -} - # Returns fields to extract for the given csv profile sub GetMarcFieldsForCsv { --- a/Koha/Exporter/Record.pm +++ a/Koha/Exporter/Record.pm @@ -7,6 +7,7 @@ use MARC::File::USMARC; use C4::AuthoritiesMarc; use C4::Biblio; use C4::Record; +use Koha::CsvProfiles; sub _get_record_for_export { my ($params) = @_; @@ -133,7 +134,7 @@ sub export { print MARC::File::XML::footer(); print "\n"; } elsif ( $format eq 'csv' ) { - $csv_profile_id ||= C4::Csv::GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); + $csv_profile_id ||= Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') })->export_format_id; print marc2csv( $record_ids, $csv_profile_id, $itemnumbers ); } --- a/misc/export_records.pl +++ a/misc/export_records.pl @@ -29,6 +29,7 @@ use C4::Record; use Koha::Biblioitems; use Koha::Database; +use Koha::CsvProfiles; use Koha::Exporter::Record; use Koha::DateUtils qw( dt_from_string output_pref ); @@ -194,11 +195,15 @@ if ($deleted_barcodes) { } } 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, format => $output_format, - csv_profile_id => ( $csv_profile_id || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ), + csv_profile_id => $csv_profile_id, export_items => (not $dont_export_items), clean => $clean || 0, } --- a/tools/export.pl +++ a/tools/export.pl @@ -190,6 +190,12 @@ if ( $op eq "export" ) { -attachment => $filename, ); + my $csv_profile_id = $query->param('csv_profile_id'); + 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, @@ -197,7 +203,7 @@ if ( $op eq "export" ) { filename => $filename, itemnumbers => \@itemnumbers, dont_export_fields => $export_remove_fields, - csv_profile_id => ( $query->param('csv_profile_id') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ), + csv_profile_id => $csv_profile_id, export_items => (not $dont_export_items), } ); @@ -316,7 +322,7 @@ else { itemtypeloop => \@itemtypesloop, authtypeloop => \@authtypesloop, export_remove_fields => C4::Context->preference("ExportRemoveFields"), - csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }), + csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ], ); output_html_with_http_headers $query, $cookie, $template->output; --