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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +1 lines)
Lines 953-959 No patron matched <span class="ex">[% message %]</span> Link Here
953
            </select>
953
            </select>
954
           <label for="export_remove_fields">Don't export fields:</label> <input type="text" id="export_remove_fields" name="export_remove_fields" value="[% export_remove_fields %]" title="Use for iso2709 exports" />
954
           <label for="export_remove_fields">Don't export fields:</label> <input type="text" id="export_remove_fields" name="export_remove_fields" value="[% export_remove_fields %]" title="Use for iso2709 exports" />
955
            <input type="hidden" name="op" value="export" />
955
            <input type="hidden" name="op" value="export" />
956
            <input type="hidden" id="export_format" name="format" value="iso2709" />
956
            <input type="hidden" id="export_format" name="output_format" value="iso2709" />
957
            <input type="hidden" id="dont_export_item" name="dont_export_item" value="0" />
957
            <input type="hidden" id="dont_export_item" name="dont_export_item" value="0" />
958
            <input type="hidden" id="record_type" name="record_type" value="bibs" />
958
            <input type="hidden" id="record_type" name="record_type" value="bibs" />
959
            <input type="button" id="export_submit" value="Export" />
959
            <input type="button" id="export_submit" value="Export" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt (-1 / +20 lines)
Lines 6-11 Link Here
6
//<![CDATA[
6
//<![CDATA[
7
$(document).ready(function() {
7
$(document).ready(function() {
8
    $('#exporttype').tabs();
8
    $('#exporttype').tabs();
9
10
    $("li.csv_profiles").hide();
11
12
    $("#bibs select[name='output_format']").on('change', function(){
13
        var format = $(this).val();
14
        if ( format == 'csv' ) {
15
            $("#bibs li.csv_profiles").show();
16
        } else {
17
            $("#bibs li.csv_profiles").hide();
18
        }
19
    });
9
});
20
});
10
//]]>
21
//]]>
11
</script>
22
</script>
Lines 130-137 $(document).ready(function() { Link Here
130
            <select id="output_format" name="output_format">
141
            <select id="output_format" name="output_format">
131
                <option value="marc">marc</option>
142
                <option value="marc">marc</option>
132
                <option value="xml">xml</option>
143
                <option value="xml">xml</option>
144
                <option value="csv">csv</option>
145
            </select>
146
        </li>
147
        <li class="csv_profiles">
148
            <label for="bibs_csv_profile">CSV profile: </label>
149
            <select id="bibs_csv_profile" name="csv_profile">
150
                [% FOR csv_profile IN csv_profiles %]
151
                    <option value="[% csv_profile.export_format_id %]">[% csv_profile.profile %]</option>
152
                [% END %]
133
            </select>
153
            </select>
134
            
135
        </li>
154
        </li>
136
        <li>
155
        <li>
137
        <label for="filename">File name:</label><input id="filename" type="text" name="filename" value="koha.mrc" />
156
        <label for="filename">File name:</label><input id="filename" type="text" name="filename" value="koha.mrc" />
(-)a/tools/export.pl (-13 / +34 lines)
Lines 33-39 use C4::Record; Link Here
33
my $query = new CGI;
33
my $query = new CGI;
34
34
35
my $clean;
35
my $clean;
36
my $output_format;
37
my $dont_export_items;
36
my $dont_export_items;
38
my $deleted_barcodes;
37
my $deleted_barcodes;
39
my $timestamp;
38
my $timestamp;
Lines 44-54 my $op = $query->param("op") || ''; Link Here
44
my $filename = $query->param("filename") || 'koha.mrc';
43
my $filename = $query->param("filename") || 'koha.mrc';
45
my $dbh      = C4::Context->dbh;
44
my $dbh      = C4::Context->dbh;
46
my $marcflavour = C4::Context->preference("marcflavour");
45
my $marcflavour = C4::Context->preference("marcflavour");
47
my $format = $query->param("format") || 'iso2709';
46
my $output_format = $query->param("output_format") || 'iso2709';
48
47
49
# Checks if the script is called from commandline
48
# Checks if the script is called from commandline
50
my $commandline = not defined $ENV{GATEWAY_INTERFACE};
49
my $commandline = not defined $ENV{GATEWAY_INTERFACE};
51
50
51
52
# @biblionumbers is only use for csv export from circulation.pl
53
my @biblionumbers = uniq $query->param("biblionumbers");
54
52
if ( $commandline ) {
55
if ( $commandline ) {
53
56
54
    # Getting parameters
57
    # Getting parameters
Lines 94-100 _USAGE_ Link Here
94
    }
97
    }
95
98
96
    # Default parameters values :
99
    # Default parameters values :
97
    $output_format     ||= 'marc';
100
    $output_format     ||= 'iso2709';
98
    $timestamp         ||= '';
101
    $timestamp         ||= '';
99
    $dont_export_items ||= 0;
102
    $dont_export_items ||= 0;
100
    $deleted_barcodes  ||= 0;
103
    $deleted_barcodes  ||= 0;
Lines 142-151 if ( C4::Context->preference("IndependentBranches") Link Here
142
my $backupdir = C4::Context->config('backupdir');
145
my $backupdir = C4::Context->config('backupdir');
143
146
144
if ( $op eq "export" ) {
147
if ( $op eq "export" ) {
145
    if ( $format eq "iso2709" or $format eq "xml" ) {
148
    if (
149
        $output_format eq "iso2709"
150
            or $output_format eq "xml"
151
            or (
152
                $output_format eq 'csv'
153
                    and not @biblionumbers
154
            )
155
    ) {
146
        my $charset  = 'utf-8';
156
        my $charset  = 'utf-8';
147
        my $mimetype = 'application/octet-stream';
157
        my $mimetype = 'application/octet-stream';
148
        binmode STDOUT, ':encoding(UTF-8)';
158
159
        binmode STDOUT, ':encoding(UTF-8)'
160
            if $filename =~ m/\.gz$/
161
                or $filename =~ m/\.bz2$/;
162
149
        if ( $filename =~ m/\.gz$/ ) {
163
        if ( $filename =~ m/\.gz$/ ) {
150
            $mimetype = 'application/x-gzip';
164
            $mimetype = 'application/x-gzip';
151
            $charset  = '';
165
            $charset  = '';
Lines 159-170 if ( $op eq "export" ) { Link Here
159
        print $query->header(
173
        print $query->header(
160
            -type       => $mimetype,
174
            -type       => $mimetype,
161
            -charset    => $charset,
175
            -charset    => $charset,
162
            -attachment => $filename
176
            -attachment => $filename,
163
        ) unless ($commandline);
177
        ) unless ($commandline);
164
178
165
        $record_type = $query->param("record_type") unless ($commandline);
179
        $record_type = $query->param("record_type") unless ($commandline);
166
        $output_format = $query->param("output_format") || 'marc'
167
          unless ($commandline);
168
        my $export_remove_fields = $query->param("export_remove_fields");
180
        my $export_remove_fields = $query->param("export_remove_fields");
169
        my @biblionumbers      = $query->param("biblionumbers");
181
        my @biblionumbers      = $query->param("biblionumbers");
170
        my @itemnumbers        = $query->param("itemnumbers");
182
        my @itemnumbers        = $query->param("itemnumbers");
Lines 415-421 if ( $op eq "export" ) { Link Here
415
                    print MARC::File::XML::record($record);
427
                    print MARC::File::XML::record($record);
416
                    print "\n";
428
                    print "\n";
417
                }
429
                }
418
                else {
430
                elsif ( $output_format eq 'iso2709' ) {
419
                    my (@result_build_tag) = MARC::File::USMARC::_build_tag_directory($record);
431
                    my (@result_build_tag) = MARC::File::USMARC::_build_tag_directory($record);
420
                    if ($result_build_tag[2] > 99999) {
432
                    if ($result_build_tag[2] > 99999) {
421
                        warn "record (number $recordid) length ".$result_build_tag[2]." is larger than the MARC spec allows (99999 bytes)";
433
                        warn "record (number $recordid) length ".$result_build_tag[2]." is larger than the MARC spec allows (99999 bytes)";
Lines 429-443 if ( $op eq "export" ) { Link Here
429
            print MARC::File::XML::footer();
441
            print MARC::File::XML::footer();
430
            print "\n";
442
            print "\n";
431
        }
443
        }
444
        if ( $output_format eq 'csv' ) {
445
            my $csv_profile_id = $query->param('csv_profile')
446
                || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') );
447
            my $output =
448
              marc2csv( \@recordids,
449
                $csv_profile_id );
450
451
            print $output;
452
        }
432
453
433
        exit;
454
        exit;
434
    }
455
    }
435
    elsif ( $format eq "csv" ) {
456
    elsif ( $output_format eq "csv" ) {
436
        my @biblionumbers = uniq $query->param("biblionumbers");
437
        my @itemnumbers   = $query->param("itemnumbers");
457
        my @itemnumbers   = $query->param("itemnumbers");
458
        my $csv_profile_id = $query->param('csv_profile') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') );
438
        my $output =
459
        my $output =
439
          marc2csv( \@biblionumbers,
460
          marc2csv( \@biblionumbers,
440
            GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ),
461
            $csv_profile_id,
441
            \@itemnumbers, );
462
            \@itemnumbers, );
442
        print $query->header(
463
        print $query->header(
443
            -type                        => 'application/octet-stream',
464
            -type                        => 'application/octet-stream',
Lines 511-516 else { Link Here
511
        itemtypeloop             => \@itemtypesloop,
532
        itemtypeloop             => \@itemtypesloop,
512
        authtypeloop             => \@authtypesloop,
533
        authtypeloop             => \@authtypesloop,
513
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
534
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
535
        csv_profiles             => C4::Csv::GetCsvProfiles('marc'),
514
    );
536
    );
515
537
516
    output_html_with_http_headers $query, $cookie, $template->output;
538
    output_html_with_http_headers $query, $cookie, $template->output;
517
- 

Return to bug 12404