diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index e9e3cf6bcb61..486d12726849 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers; +use App\DataMapper\CompanySettings; use App\Events\Invoice\InvoiceWasCreated; use App\Events\Invoice\InvoiceWasEmailed; use App\Events\Invoice\InvoiceWasUpdated; @@ -711,7 +712,10 @@ class InvoiceController extends BaseController break; case 'email': //check query paramater for email_type and set the template else use calculateTemplate - $this->reminder_template = $invoice->calculateTemplate(); + if(request()->has('email_type') && property_exists($invoice->company->settings, request()->input('email_type'))) + $this->reminder_template = $invoice->client->getSetting(request()->input('email_type')); + else + $this->reminder_template = $invoice->calculateTemplate(); $invoice->invitations->load('contact.client.country','invoice.client.country','invoice.company')->each(function ($invitation) use ($invoice) { diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 3a5152d279f3..c5d8796006ab 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -239,6 +239,8 @@ class HtmlEngine $data['$contact.phone'] = ['value' => $this->contact->phone, 'label' => ctrans('texts.phone')]; $data['$contact.name'] = ['value' => isset($this->contact) ? $this->contact->present()->name() : 'no contact name on record', 'label' => ctrans('texts.contact_name')]; + $data['$contact.first_name'] = ['value' => isset($contact) ? $contact->first_name : '', 'label' => ctrans('texts.first_name')]; + $data['$contact.last_name'] = ['value' => isset($contact) ? $contact->last_name : '', 'label' => ctrans('texts.last_name')]; $data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->makeCustomField('contact1')]; $data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->makeCustomField('contact1')]; $data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->makeCustomField('contact1')]; diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index e5d573c54491..62b4d311c052 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -334,6 +334,8 @@ trait MakesInvoiceValues $data['$contact.phone'] = ['value' => $contact->phone, 'label' => ctrans('texts.phone')]; $data['$contact.name'] = ['value' => isset($contact) ? $contact->present()->name() : 'no contact name on record', 'label' => ctrans('texts.contact_name')]; + $data['$contact.first_name'] = ['value' => isset($contact) ? $contact->first_name : '', 'label' => ctrans('texts.first_name')]; + $data['$contact.last_name'] = ['value' => isset($contact) ? $contact->last_name : '', 'label' => ctrans('texts.last_name')]; $data['$contact.custom1'] = ['value' => isset($contact) ? $contact->custom_value1 : ' ', 'label' => $this->makeCustomField('contact1')]; $data['$contact.custom2'] = ['value' => isset($contact) ? $contact->custom_value2 : ' ', 'label' => $this->makeCustomField('contact1')]; $data['$contact.custom3'] = ['value' => isset($contact) ? $contact->custom_value3 : ' ', 'label' => $this->makeCustomField('contact1')];