diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index f829d0931291..895ce82fb821 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -925,21 +925,27 @@ class BaseExport { $parts = explode(".", $value); - if(in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])){ + if(count($parts) == 2 && in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])){ $entity = "invoice".substr($parts[1], -1); + $header[] = "{$prefix}" . $helper->makeCustomField($this->company->custom_fields, $entity); } - else { - $entity = $parts[0].substr($parts[1], -1); + elseif(count($parts) == 2 && stripos($parts[0], 'contact') !== false) { + $entity = "contact".substr($parts[1], -1); + $custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, $entity)) > 1 ? $helper->makeCustomField($this->company->custom_fields, $entity) : ctrans("texts.{$parts[1]}"); + $header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string; } - - $header[] = $helper->makeCustomField($this->company->custom_fields, $entity); + else{ + nlog("else".$key); + $header[] = "{$prefix}" . ctrans("texts.{$key}"); + } + } else { $header[] = "{$prefix}" . ctrans("texts.{$key}"); } } - +nlog($header); return $header; } } diff --git a/tests/Feature/Export/ReportCsvGenerationTest.php b/tests/Feature/Export/ReportCsvGenerationTest.php index a0ead0a357f2..47e447eaecf9 100644 --- a/tests/Feature/Export/ReportCsvGenerationTest.php +++ b/tests/Feature/Export/ReportCsvGenerationTest.php @@ -673,7 +673,7 @@ class ReportCsvGenerationTest extends TestCase ])->post('/api/v1/reports/clients', $data); $csv = $response->streamedContent(); - +nlog($csv); $reader = Reader::createFromString($csv); $reader->setHeaderOffset(0);