View | Details | Raw Unified | Return to bug 15451
Collapse All | Expand All

(-)a/C4/Csv.pm (-13 lines)
Lines 32-38 use vars qw(@ISA @EXPORT); Link Here
32
32
33
@EXPORT = qw(
33
@EXPORT = qw(
34
  &GetCsvProfile
34
  &GetCsvProfile
35
  &GetCsvProfileId
36
  &GetMarcFieldsForCsv
35
  &GetMarcFieldsForCsv
37
);
36
);
38
37
Lines 49-66 sub GetCsvProfile { Link Here
49
    return ($sth->fetchrow_hashref);
48
    return ($sth->fetchrow_hashref);
50
}
49
}
51
50
52
# Returns id of csv profile about a given csv profile name
53
sub GetCsvProfileId {
54
    my ($name)  = @_;
55
    my $dbh   = C4::Context->dbh;
56
    my $query = "SELECT export_format_id FROM export_format WHERE profile=?";
57
58
    $sth = $dbh->prepare($query);
59
    $sth->execute($name);
60
61
    return ( $sth->fetchrow );
62
}
63
64
# Returns fields to extract for the given csv profile
51
# Returns fields to extract for the given csv profile
65
sub GetMarcFieldsForCsv {
52
sub GetMarcFieldsForCsv {
66
53
(-)a/Koha/Exporter/Record.pm (-1 / +2 lines)
Lines 7-12 use MARC::File::USMARC; Link Here
7
use C4::AuthoritiesMarc;
7
use C4::AuthoritiesMarc;
8
use C4::Biblio;
8
use C4::Biblio;
9
use C4::Record;
9
use C4::Record;
10
use Koha::CsvProfiles;
10
11
11
sub _get_record_for_export {
12
sub _get_record_for_export {
12
    my ($params)           = @_;
13
    my ($params)           = @_;
Lines 133-139 sub export { Link Here
133
        print MARC::File::XML::footer();
134
        print MARC::File::XML::footer();
134
        print "\n";
135
        print "\n";
135
    } elsif ( $format eq 'csv' ) {
136
    } elsif ( $format eq 'csv' ) {
136
        $csv_profile_id ||= C4::Csv::GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') );
137
        $csv_profile_id ||= Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') })->export_format_id;
137
        print marc2csv( $record_ids, $csv_profile_id, $itemnumbers );
138
        print marc2csv( $record_ids, $csv_profile_id, $itemnumbers );
138
    }
139
    }
139
140
(-)a/misc/export_records.pl (-1 / +6 lines)
Lines 29-34 use C4::Record; Link Here
29
29
30
use Koha::Biblioitems;
30
use Koha::Biblioitems;
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::CsvProfiles;
32
use Koha::Exporter::Record;
33
use Koha::Exporter::Record;
33
use Koha::DateUtils qw( dt_from_string output_pref );
34
use Koha::DateUtils qw( dt_from_string output_pref );
34
35
Lines 195-205 if ($deleted_barcodes) { Link Here
195
    }
196
    }
196
}
197
}
197
else {
198
else {
199
    unless ( $csv_profile_id ) {
200
        my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
201
        $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef;
202
    }
198
    Koha::Exporter::Record::export(
203
    Koha::Exporter::Record::export(
199
        {   record_type        => $record_type,
204
        {   record_type        => $record_type,
200
            record_ids         => \@record_ids,
205
            record_ids         => \@record_ids,
201
            format             => $output_format,
206
            format             => $output_format,
202
            csv_profile_id     => ( $csv_profile_id || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ),
207
            csv_profile_id     => $csv_profile_id,
203
            export_items       => (not $dont_export_items),
208
            export_items       => (not $dont_export_items),
204
            clean              => $clean || 0,
209
            clean              => $clean || 0,
205
        }
210
        }
(-)a/tools/export.pl (-3 / +8 lines)
Lines 193-198 if ( $op eq "export" ) { Link Here
193
            -attachment => $filename,
193
            -attachment => $filename,
194
        );
194
        );
195
195
196
        my $csv_profile_id = $query->param('csv_profile_id');
197
        unless ( $csv_profile_id ) {
198
            my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
199
            $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef;
200
        }
201
196
        Koha::Exporter::Record::export(
202
        Koha::Exporter::Record::export(
197
            {   record_type        => $record_type,
203
            {   record_type        => $record_type,
198
                record_ids         => \@record_ids,
204
                record_ids         => \@record_ids,
Lines 200-206 if ( $op eq "export" ) { Link Here
200
                filename           => $filename,
206
                filename           => $filename,
201
                itemnumbers        => \@itemnumbers,
207
                itemnumbers        => \@itemnumbers,
202
                dont_export_fields => $export_remove_fields,
208
                dont_export_fields => $export_remove_fields,
203
                csv_profile_id     => ( $query->param('csv_profile_id') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ),
209
                csv_profile_id     => $csv_profile_id,
204
                export_items       => (not $dont_export_items),
210
                export_items       => (not $dont_export_items),
205
            }
211
            }
206
        );
212
        );
Lines 310-316 else { Link Here
310
        itemtypeloop             => \@itemtypesloop,
316
        itemtypeloop             => \@itemtypesloop,
311
        authority_types          => $authority_types,
317
        authority_types          => $authority_types,
312
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
318
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
313
        csv_profiles             => [ Koha::CsvProfiles->search({ type => 'marc' }),
319
        csv_profiles             => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
314
    );
320
    );
315
321
316
    output_html_with_http_headers $query, $cookie, $template->output;
322
    output_html_with_http_headers $query, $cookie, $template->output;
317
- 

Return to bug 15451