Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f87763cd

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID f87763cd84d89aafc4c4110ba42d041b02ce4371
  • Vorgänger 0389fbc6
  • Nachfolger 7b81cb26

Kunden-/Lieferantenstammdatenimport: zumindest das Testen funktioniert

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
6 6
use SL::DB::CsvImportProfile;
7 7
use SL::Helper::Flash;
8 8
use SL::SessionFile;
9
use SL::Controller::CsvImport::CustomerVendor;
9 10

  
10 11
use List::MoreUtils qw(none);
11 12

  
......
13 14

  
14 15
use Rose::Object::MakeMethods::Generic
15 16
(
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) ],
17
 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
18
                import_status errors headers data num_imported) ],
17 19
);
18 20

  
19 21
__PACKAGE__->run_before('check_auth');
......
128 130
  $self->profile_from_form;
129 131

  
130 132
  if ($::form->{file}) {
131
    my $file = SL::SessionFile->new($self->csv_file_name, "w");
133
    my $file = SL::SessionFile->new($self->csv_file_name, mode => '>');
132 134
    $file->fh->print($::form->{file});
133 135
    $file->fh->close;
134 136
  }
135 137

  
136
  my $file = SL::SessionFile->new($self->csv_file_name, "w");
138
  my $file = SL::SessionFile->new($self->csv_file_name, mode => '<', encoding => $self->profile->get('charset'));
137 139
  if (!$file->fh) {
138 140
    flash('error', $::locale->text('No file has been uploaded yet.'));
139 141
    return $self->action_new;
140 142
  }
141 143

  
142
  # do the import thingy...
144
  my $worker = $self->{type} eq 'customers_vendors' ? SL::Controller::CsvImport::CustomerVendor->new(controller => $self, file => $file)
145
    :                                                 die "Program logic error";
146

  
147
  $worker->run;
148
  $worker->save_objects if !$params{test};
149

  
150
  $self->import_status($params{test} ? 'tested' : 'imported');
151

  
143 152
  $self->action_new;
144 153
}
145 154

  

Auch abrufbar als: Unified diff