]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/CsvImport/BaseMulti.pm
Merge branch 'master' of http://wagnertech.de/git/mfinanz
[mfinanz.git] / SL / Controller / CsvImport / BaseMulti.pm
index b97539489152794c738e72515cdac0db8d028305..94cfa843192f2a5bb0b9eacd7a481c196bc733c0 100644 (file)
@@ -33,8 +33,8 @@ sub run {
 
   $self->controller->track_progress(progress => 10);
 
-  my $old_numberformat      = $::myconfig{numberformat};
-  $::myconfig{numberformat} = $self->controller->profile->get('numberformat');
+  local $::myconfig{numberformat} = $self->controller->profile->get('numberformat');
+  local $::myconfig{dateformat}   = $self->controller->profile->get('dateformat');
 
   $self->csv->parse;
 
@@ -71,6 +71,10 @@ sub run {
   $self->controller->info_headers($info_headers);
 
   my $objects  = $self->csv->get_objects;
+  if ($self->csv->errors) {
+    $self->controller->errors([ $self->csv->errors ]) ;
+    return;
+  }
 
   $self->controller->track_progress(progress => 70);
 
@@ -90,8 +94,17 @@ sub run {
   $self->fix_field_lengths;
 
   $self->controller->track_progress(progress => 100);
+}
+
+sub init_manager_class {
+  my ($self) = @_;
 
-  $::myconfig{numberformat} = $old_numberformat;
+  my @manager_classes;
+  foreach my $class (@{ $self->class }) {
+    $class =~ m/^SL::DB::(.+)/;
+    push @manager_classes, "SL::DB::Manager::" . $1;
+  }
+  $self->manager_class(\@manager_classes);
 }
 
 sub add_columns {
@@ -159,9 +172,11 @@ sub handle_cvars {
   my ($self, $entry, %params) = @_;
 
   return if @{ $entry->{errors} };
+  return unless $entry->{object}->can('cvars_by_config');
 
   my %type_to_column = ( text      => 'text_value',
                          textfield => 'text_value',
+                         htmlfield => 'text_value',
                          select    => 'text_value',
                          date      => 'timestamp_value_as_date',
                          timestamp => 'timestamp_value_as_date',
@@ -172,7 +187,7 @@ sub handle_cvars {
 
   # autovivify all cvars (cvars_by_config will do that for us)
   my @cvars;
-  @cvars = @{ $entry->{object}->cvars_by_config } if $entry->{object}->can('cvars_by_config');
+  @cvars = @{ $entry->{object}->cvars_by_config };
 
   foreach my $config (@{ $self->cvar_configs_by->{row_ident}->{$entry->{raw_data}->{datatype}} }) {
     next unless exists $entry->{raw_data}->{ "cvar_" . $config->name };