Bugzilla – Attachment 34300 Details for
Bug 12404
CSV profiles improvements (concatenations, substrings, conditions...)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12404: tools/export.pl allows CSV export
Bug-12404-toolsexportpl-allows-CSV-export.patch (text/plain), 6.08 KB, created by
Jonathan Druart
on 2014-12-11 09:57:53 UTC
(
hide
)
Description:
Bug 12404: tools/export.pl allows CSV export
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-12-11 09:57:53 UTC
Size:
6.08 KB
patch
obsolete
>From 8e5d5b4d8b176b3c1d135e2dd43b3d63e428e208 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 5 Feb 2014 16:44:24 +0100 >Subject: [PATCH] Bug 12404: tools/export.pl allows CSV export > >--- > .../prog/en/modules/circ/circulation.tt | 1 - > .../intranet-tmpl/prog/en/modules/tools/export.tt | 21 ++++++++++++- > tools/export.pl | 36 +++++++++++++++++++--- > 3 files changed, 51 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index b938724..f6d86f2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -774,7 +774,6 @@ No patron matched <span class="ex">[% message %]</span> > [% ELSE %] > <a href="#reserves" id="holds-tab">0 Holds</a> > [% END %] >- </li> > > <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li> > </ul> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >index 2e85732..5e6f55a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >@@ -6,6 +6,17 @@ > //<![CDATA[ > $(document).ready(function() { > $('#exporttype').tabs(); >+ >+ $("li.csv_profiles").hide(); >+ >+ $("#bibs select[name='output_format']").on('change', function(){ >+ var format = $(this).val(); >+ if ( format == 'csv' ) { >+ $("#bibs li.csv_profiles").show(); >+ } else { >+ $("#bibs li.csv_profiles").hide(); >+ } >+ }); > }); > //]]> > </script> >@@ -130,8 +141,16 @@ $(document).ready(function() { > <select id="output_format" name="output_format"> > <option value="iso2709">marc</option> > <option value="xml">xml</option> >+ <option value="csv">csv</option> >+ </select> >+ </li> >+ <li class="csv_profiles"> >+ <label for="bibs_csv_profile">CSV profile: </label> >+ <select id="bibs_csv_profile" name="csv_profile"> >+ [% FOR csv_profile IN csv_profiles %] >+ <option value="[% csv_profile.export_format_id %]">[% csv_profile.profile %]</option> >+ [% END %] > </select> >- > </li> > <li> > <label for="filename">File name:</label><input id="filename" type="text" name="filename" value="koha.mrc" /> >diff --git a/tools/export.pl b/tools/export.pl >index bae6941..90fcaea 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -48,6 +48,10 @@ my $output_format = $query->param("format") || $query->param("output_format") || > # Checks if the script is called from commandline > my $commandline = not defined $ENV{GATEWAY_INTERFACE}; > >+ >+# @biblionumbers is only use for csv export from circulation.pl >+my @biblionumbers = uniq $query->param("biblionumbers"); >+ > if ( $commandline ) { > > # Getting parameters >@@ -145,10 +149,21 @@ if ( C4::Context->preference("IndependentBranches") > my $backupdir = C4::Context->config('backupdir'); > > if ( $op eq "export" ) { >- if ( $output_format eq "iso2709" or $output_format eq "xml" ) { >+ if ( >+ $output_format eq "iso2709" >+ or $output_format eq "xml" >+ or ( >+ $output_format eq 'csv' >+ and not @biblionumbers >+ ) >+ ) { > my $charset = 'utf-8'; > my $mimetype = 'application/octet-stream'; >- binmode STDOUT, ':encoding(UTF-8)'; >+ >+ binmode STDOUT, ':encoding(UTF-8)' >+ if $filename =~ m/\.gz$/ >+ or $filename =~ m/\.bz2$/; >+ > if ( $filename =~ m/\.gz$/ ) { > $mimetype = 'application/x-gzip'; > $charset = ''; >@@ -162,7 +177,7 @@ if ( $op eq "export" ) { > print $query->header( > -type => $mimetype, > -charset => $charset, >- -attachment => $filename >+ -attachment => $filename, > ) unless ($commandline); > > $record_type = $query->param("record_type") unless ($commandline); >@@ -416,7 +431,7 @@ if ( $op eq "export" ) { > print MARC::File::XML::record($record); > print "\n"; > } >- else { >+ elsif ( $output_format eq 'iso2709' ) { > my $errorcount_on_decode = eval { scalar(MARC::File::USMARC->decode( $record->as_usmarc )->warnings()) }; > if ($errorcount_on_decode or $@){ > warn $@ if $@; >@@ -431,15 +446,25 @@ if ( $op eq "export" ) { > print MARC::File::XML::footer(); > print "\n"; > } >+ if ( $output_format eq 'csv' ) { >+ my $csv_profile_id = $query->param('csv_profile') >+ || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); >+ my $output = >+ marc2csv( \@recordids, >+ $csv_profile_id ); >+ >+ print $output; >+ } > > exit; > } > elsif ( $output_format eq "csv" ) { > my @biblionumbers = uniq $query->param("biblionumbers"); > my @itemnumbers = $query->param("itemnumbers"); >+ my $csv_profile_id = $query->param('csv_profile') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); > my $output = > marc2csv( \@biblionumbers, >- GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ), >+ $csv_profile_id, > \@itemnumbers, ); > print $query->header( > -type => 'application/octet-stream', >@@ -513,6 +538,7 @@ else { > itemtypeloop => \@itemtypesloop, > authtypeloop => \@authtypesloop, > export_remove_fields => C4::Context->preference("ExportRemoveFields"), >+ csv_profiles => C4::Csv::GetCsvProfiles('marc'), > ); > > output_html_with_http_headers $query, $cookie, $template->output; >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12404
:
28767
|
28768
|
28769
|
28770
|
28771
|
33170
|
33171
|
33172
|
33173
|
33174
|
33263
|
33477
|
34288
|
34289
|
34290
|
34291
|
34292
|
34293
|
34294
|
34300
|
34301
|
34302
|
34303
|
34405
|
34406
|
34407
|
34408
|
34409
|
34410
|
34411
|
35048
|
35049
|
35050
|
35051
|
35052
|
35053
|
35054