diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index f0b26ad7d7c7..ebaa8cb8b000 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -118,9 +118,36 @@ class ImportController extends Controller })->toArray(); - + //Exact string match foreach($headers as $key => $value) { + foreach($translated_keys as $tkey => $tvalue) { + + $concat_needle = str_ireplace(" ", "", $tvalue['index'].$tvalue['label']); + $concat_value = str_ireplace(" ", "", $value); + + if($this->testMatch($concat_value, $concat_needle)) { + + $hit = $tvalue['key']; + $hints[$key] = $hit; + unset($translated_keys[$tkey]); + break; + + } else { + $hints[$key] = null; + } + + } + + } + + //Label Match + foreach($headers as $key => $value) { + + if(isset($hints[$key])) { + continue; + } + foreach($translated_keys as $tkey => $tvalue) { if($this->testMatch($value, $tvalue['label'])) { @@ -134,10 +161,9 @@ class ImportController extends Controller } - } - //second pass using the index of the translation here + //Index matching pass using the index of the translation here foreach($headers as $key => $value) { if(isset($hints[$key])) { continue; diff --git a/app/Repositories/CompanyRepository.php b/app/Repositories/CompanyRepository.php index d292bed0273d..a2a2195d3b85 100644 --- a/app/Repositories/CompanyRepository.php +++ b/app/Repositories/CompanyRepository.php @@ -58,9 +58,8 @@ class CompanyRepository extends BaseRepository $company->smtp_password = $data['smtp_password']; } - if(isset($data['e_invoice'])){ + if(isset($data['e_invoice']) && is_array($data['e_invoice'])){ //ensure it is normalized first! - $data['e_invoice'] = $this->arrayFilterRecursive($data['e_invoice']); $company->e_invoice = $data['e_invoice']; diff --git a/app/Services/Template/TemplateService.php b/app/Services/Template/TemplateService.php index 39e660f41d09..c4894b674dd9 100644 --- a/app/Services/Template/TemplateService.php +++ b/app/Services/Template/TemplateService.php @@ -980,6 +980,7 @@ class TemplateService return [ 'name' => $user->present()->name(), 'email' => $user->email, + 'signature' => $user->signature ?? '', ]; } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index aadea2190f25..89b7d470e598 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -399,7 +399,9 @@ class HtmlEngine $data['$taxes'] = ['value' => Number::formatMoney($this->entity_calc->getItemTotalTaxes(), $this->client) ?: ' ', 'label' => ctrans('texts.taxes')]; $data['$invoice.taxes'] = &$data['$taxes']; + $data['$user.name'] = ['value' => $this->entity->user->present()->name(), 'label' => ctrans('texts.name')]; + $data['$user.signature'] = ['value' => $this->entity->user->signature ?? '', 'label' => ctrans('texts.signature')]; $data['$user.first_name'] = ['value' => $this->entity->user->first_name, 'label' => ctrans('texts.first_name')]; $data['$user.last_name'] = ['value' => $this->entity->user->last_name, 'label' => ctrans('texts.last_name')]; $data['$created_by_user'] = &$data['$user.name'];