Revision 29269e99
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/Controller/CsvImport.pm | ||
---|---|---|
5 | 5 |
use SL::DB::Buchungsgruppe; |
6 | 6 |
use SL::DB::CsvImportProfile; |
7 | 7 |
use SL::Helper::Flash; |
8 |
use SL::SessionFile; |
|
8 | 9 |
|
9 | 10 |
use List::MoreUtils qw(none); |
10 | 11 |
|
... | ... | |
12 | 13 |
|
13 | 14 |
use Rose::Object::MakeMethods::Generic |
14 | 15 |
( |
15 |
scalar => [ qw(type profile all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen) ], |
|
16 |
scalar => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen) ],
|
|
16 | 17 |
); |
17 | 18 |
|
18 | 19 |
__PACKAGE__->run_before('check_auth'); |
... | ... | |
108 | 109 |
$self->$sub(($char_map{$type}->{$char} || [])->[0] || $char); |
109 | 110 |
} |
110 | 111 |
|
112 |
$self->file(SL::SessionFile->new($self->csv_file_name)); |
|
113 |
|
|
111 | 114 |
my $title = $self->type eq 'customers_vendors' ? $::locale->text('CSV import: customers and vendors') |
112 | 115 |
: $self->type eq 'addresses' ? $::locale->text('CSV import: shipping addresses') |
113 | 116 |
: $self->type eq 'contacts' ? $::locale->text('CSV import: contacts') |
... | ... | |
124 | 127 |
|
125 | 128 |
$self->profile_from_form; |
126 | 129 |
|
130 |
if ($::form->{file}) { |
|
131 |
my $file = SL::SessionFile->new($self->csv_file_name, "w"); |
|
132 |
$file->fh->print($::form->{file}); |
|
133 |
$file->fh->close; |
|
134 |
} |
|
135 |
|
|
136 |
my $file = SL::SessionFile->new($self->csv_file_name, "w"); |
|
137 |
if (!$file->fh) { |
|
138 |
flash('error', $::locale->text('No file has been uploaded yet.')); |
|
139 |
return $self->action_new; |
|
140 |
} |
|
141 |
|
|
127 | 142 |
# do the import thingy... |
128 | 143 |
$self->action_new; |
129 | 144 |
} |
... | ... | |
186 | 201 |
); |
187 | 202 |
} |
188 | 203 |
|
204 |
sub csv_file_name { |
|
205 |
my ($self) = @_; |
|
206 |
return "csv-import-" . $self->type . ".csv"; |
|
207 |
} |
|
208 |
|
|
189 | 209 |
1; |
Auch abrufbar als: Unified diff
Hochladen und Anzeigen von hochgeladenen Dateien implementiert