diff --git a/app/Http/routes.php b/app/Http/routes.php index 2ab62a29a687..abe20b1eab4a 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -360,6 +360,7 @@ Route::get('/comments/feed', function() { }); if (!defined('CONTACT_EMAIL')) { + define('APP_NAME', env('APP_NAME', 'Invoice Ninja')); define('CONTACT_EMAIL', config('mail.from.address')); define('CONTACT_NAME', config('mail.from.name')); define('SITE_URL', config('app.url')); diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index ea675f6c74b1..8d9214acf59d 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -485,14 +485,24 @@ class ImportService $csv->heading = false; $csv->auto($filename); - Session::put("{$entityType}-data", $csv->data); - $headers = false; $hasHeaders = false; $mapped = []; if (count($csv->data) > 0) { $headers = $csv->data[0]; + + // Remove Invoice Ninja headers + if (count($headers) && count($csv->data) > 4) { + $firstCell = $headers[0]; + if (strstr($firstCell, APP_NAME)) { + array_shift($csv->data); // Invoice Ninja... + array_shift($csv->data); // + array_shift($csv->data); // Enitty Type Header + } + $headers = $csv->data[0]; + } + foreach ($headers as $title) { if (strpos(strtolower($title), 'name') > 0) { $hasHeaders = true; @@ -514,6 +524,8 @@ class ImportService } } + Session::put("{$entityType}-data", $csv->data); + $data = [ 'entityType' => $entityType, 'data' => $csv->data,