From: Moritz Bunkus
Date: Mon, 7 Mar 2011 12:21:52 +0000 (+0100)
Subject: Beispieldatei bei CSV-Import herunterladen
X-Git-Tag: release-2.7.0beta1~396^2~5
X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6759902aeb338d4f5efe8cadadf4103c2bf35849;p=kivitendo-erp.git
Beispieldatei bei CSV-Import herunterladen
---
diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm
index c0967ac0c..c30634b96 100644
--- a/SL/Controller/CsvImport.pm
+++ b/SL/Controller/CsvImport.pm
@@ -67,6 +67,26 @@ sub action_destroy {
$self->redirect_to(action => 'new', 'profile.type' => $self->type);
}
+sub action_download_sample {
+ my $self = shift;
+
+ $self->profile_from_form;
+ $self->setup_help;
+
+ my $file_name = 'csv_import_sample_' . $self->type . '.csv';
+ my $file = SL::SessionFile->new($file_name, mode => '>', encoding => $self->profile->get('charset'));
+ my $csv = Text::CSV_XS->new({ binary => 1, map { ( $_ => $self->profile->get($_) ) } qw(sep_char escape_char quote_char),});
+
+ $csv->print($file->fh, [ map { $_->{name} } @{ $self->displayable_columns } ]);
+ $file->fh->print("\r\n");
+ $csv->print($file->fh, [ map { $_->{description} } @{ $self->displayable_columns } ]);
+ $file->fh->print("\r\n");
+
+ $file->fh->close;
+
+ $self->send_file($file->file_name);
+}
+
#
# filters
#
diff --git a/locale/de/all b/locale/de/all
index 0c238bfd5..7647d94bf 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -614,6 +614,7 @@ $self->{texts} = {
'Documents in the WebDAV repository' => 'Dokumente im WebDAV-Repository',
'Done' => 'Fertig',
'Download SEPA XML export file' => 'SEPA-XML-Exportdatei herunterladen',
+ 'Download sample file' => 'Beispieldatei herunterladen',
'Download the backup' => 'Die Sicherungsdatei herunterladen',
'Draft saved.' => 'Entwurf gespeichert.',
'Drawing' => 'Zeichnung',
diff --git a/templates/webpages/csv_import/form.html b/templates/webpages/csv_import/form.html
index c9c9133c9..b146465a8 100644
--- a/templates/webpages/csv_import/form.html
+++ b/templates/webpages/csv_import/form.html
@@ -85,6 +85,10 @@
[%- END %]
+
+ [%- L.submit_tag('action_download_sample', LxERP.t8('Download sample file')) %]
+
+