ActionBar: alte Funktionen zum E-Mail-Versand entfernt
[kivitendo-erp.git] / SL / BackgroundJob / CsvImport.pm
index 7df8b9b..9815ddf 100644 (file)
@@ -5,6 +5,7 @@ use strict;
 use parent qw(SL::BackgroundJob::Base);
 
 use YAML ();
+use SL::JSON;
 use SL::DB::CsvImportProfile;
 use SL::SessionFile::Random;
 
@@ -60,6 +61,7 @@ sub do_import {
   my $job = $self->{db_obj};
 
   $c->profile($self->profile);
+  $c->mappings(SL::JSON::from_json($self->profile->get('json_mappings'))) if $self->profile->get('json_mappings');
   $c->type($job->data_as_hash->{type});
   $c->{employee_id} = $job->data_as_hash->{employee_id};
 
@@ -82,20 +84,25 @@ sub do_import {
   );
   $c->add_progress_tracker($self);
 
+  my $session_id = $job->data_as_hash->{session_id};
 
-  $c->test_and_import(test => $test, session_id => $job->data_as_hash->{session_id});
-
+  $c->test_and_import(test => $test, session_id => $session_id);
+  my $result;
   if ($c->errors) {
     $job->set_data(
       errors   => $c->errors,
     )->save;
+    $result = $::locale->text('Import finished with errors.');
   } else {
 
-    my $report_id = $c->save_report;
+    my $report_id = $c->save_report(session_id => $session_id, test => $test);
     $job->set_data(report_id => $report_id)->save;
 
     $c->track_progress(finished => 1);
+    $result = $::locale->text('Import finished without errors.');
   }
+
+  return $result;
 }
 
 sub track_progress {