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

(-)a/C4/Csv.pm (-13 lines)
Lines 34-40 $VERSION = 3.07.00.049; Link Here
34
34
35
@EXPORT = qw(
35
@EXPORT = qw(
36
  &GetCsvProfile
36
  &GetCsvProfile
37
  &GetCsvProfileId
38
  &GetMarcFieldsForCsv
37
  &GetMarcFieldsForCsv
39
);
38
);
40
39
Lines 51-68 sub GetCsvProfile { Link Here
51
    return ($sth->fetchrow_hashref);
50
    return ($sth->fetchrow_hashref);
52
}
51
}
53
52
54
# Returns id of csv profile about a given csv profile name
55
sub GetCsvProfileId {
56
    my ($name)  = @_;
57
    my $dbh   = C4::Context->dbh;
58
    my $query = "SELECT export_format_id FROM export_format WHERE profile=?";
59
60
    $sth = $dbh->prepare($query);
61
    $sth->execute($name);
62
63
    return ( $sth->fetchrow );
64
}
65
66
# Returns fields to extract for the given csv profile
53
# Returns fields to extract for the given csv profile
67
sub GetMarcFieldsForCsv {
54
sub GetMarcFieldsForCsv {
68
55
(-)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 194-204 if ($deleted_barcodes) { Link Here
194
    }
195
    }
195
}
196
}
196
else {
197
else {
198
    unless ( $csv_profile_id ) {
199
        my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
200
        $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef;
201
    }
197
    Koha::Exporter::Record::export(
202
    Koha::Exporter::Record::export(
198
        {   record_type        => $record_type,
203
        {   record_type        => $record_type,
199
            record_ids         => \@record_ids,
204
            record_ids         => \@record_ids,
200
            format             => $output_format,
205
            format             => $output_format,
201
            csv_profile_id     => ( $csv_profile_id || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ),
206
            csv_profile_id     => $csv_profile_id,
202
            export_items       => (not $dont_export_items),
207
            export_items       => (not $dont_export_items),
203
            clean              => $clean || 0,
208
            clean              => $clean || 0,
204
        }
209
        }
(-)a/tools/export.pl (-3 / +8 lines)
Lines 190-195 if ( $op eq "export" ) { Link Here
190
            -attachment => $filename,
190
            -attachment => $filename,
191
        );
191
        );
192
192
193
        my $csv_profile_id = $query->param('csv_profile_id');
194
        unless ( $csv_profile_id ) {
195
            my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
196
            $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef;
197
        }
198
193
        Koha::Exporter::Record::export(
199
        Koha::Exporter::Record::export(
194
            {   record_type        => $record_type,
200
            {   record_type        => $record_type,
195
                record_ids         => \@record_ids,
201
                record_ids         => \@record_ids,
Lines 197-203 if ( $op eq "export" ) { Link Here
197
                filename           => $filename,
203
                filename           => $filename,
198
                itemnumbers        => \@itemnumbers,
204
                itemnumbers        => \@itemnumbers,
199
                dont_export_fields => $export_remove_fields,
205
                dont_export_fields => $export_remove_fields,
200
                csv_profile_id     => ( $query->param('csv_profile_id') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ),
206
                csv_profile_id     => $csv_profile_id,
201
                export_items       => (not $dont_export_items),
207
                export_items       => (not $dont_export_items),
202
            }
208
            }
203
        );
209
        );
Lines 316-322 else { Link Here
316
        itemtypeloop             => \@itemtypesloop,
322
        itemtypeloop             => \@itemtypesloop,
317
        authtypeloop             => \@authtypesloop,
323
        authtypeloop             => \@authtypesloop,
318
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
324
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
319
        csv_profiles             => [ Koha::CsvProfiles->search({ type => 'marc' }),
325
        csv_profiles             => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
320
    );
326
    );
321
327
322
    output_html_with_http_headers $query, $cookie, $template->output;
328
    output_html_with_http_headers $query, $cookie, $template->output;
323
- 

Return to bug 15451