From d6cdb0102164ea75fd45cdc2f09c83334f93ef0d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Aug 2023 20:41:06 +1000 Subject: [PATCH] Minor fixeS --- app/Export/CSV/BaseExport.php | 11 ++++------- app/Export/CSV/CreditExport.php | 9 ++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index c65a5180f361..741f21a2a335 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -845,7 +845,7 @@ class BaseExport $key = array_search($value, $this->entity_keys); $original_key = $key; - nlog("{$key} => {$value}"); + // nlog("{$key} => {$value}"); $prefix = ''; if(!$key) { @@ -938,20 +938,15 @@ class BaseExport } elseif(count($parts) == 2 && stripos($parts[0], 'contact') !== false) { - nlog("2"); $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; } elseif(count($parts) == 2 && in_array(substr($original_key, 0, -1), ['credit','quote','invoice','purchase_order','recurring_invoice'])){ - nlog("3"); - $custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, "product".substr($original_key,-1))) > 1 ? $helper->makeCustomField($this->company->custom_fields, "product".substr($original_key,-1)) : ctrans("texts.{$parts[1]}"); - nlog(ctrans("texts.{$parts[0]}") . " " . $custom_field_string); $header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string; } else{ - nlog("else".$key); $header[] = "{$prefix}" . ctrans("texts.{$key}"); } @@ -961,7 +956,9 @@ class BaseExport $header[] = "{$prefix}" . ctrans("texts.{$key}"); } } -nlog($header); + + nlog($header); + return $header; } } diff --git a/app/Export/CSV/CreditExport.php b/app/Export/CSV/CreditExport.php index ffc979513949..bfde3d169df2 100644 --- a/app/Export/CSV/CreditExport.php +++ b/app/Export/CSV/CreditExport.php @@ -41,13 +41,12 @@ class CreditExport extends BaseExport { $query = $this->init(); - $header = []; $headerdisplay = $this->buildHeader(); - foreach ($this->input['report_keys'] as $key => $value) { - $header[] = ['identifier' => $value, 'display_value' => $headerdisplay[$key]]; - } - + $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ + return ['identifier' => $value, 'display_value' => $headerdisplay[$key]]; + })->toArray(); + $report = $query->cursor() ->map(function ($credit) { $row = $this->buildRow($credit);