diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index bacc80d77399..3ceded3e85c4 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -359,7 +359,7 @@ class InvoiceController extends BaseController Session::flash('message', $message); if ($action == 'email') { - $this->emailInvoice($invoice, Input::get('pdfupload')); + $this->emailInvoice($invoice, Input::get('reminder'), Input::get('pdfupload'), Input::get('emailTemplate')); } return url($invoice->getRoute()); @@ -390,13 +390,13 @@ class InvoiceController extends BaseController } elseif ($action == 'convert') { return $this->convertQuote($request, $invoice->public_id); } elseif ($action == 'email') { - $this->emailInvoice($invoice, Input::get('pdfupload')); + $this->emailInvoice($invoice, Input::get('reminder'), Input::get('pdfupload'), Input::get('emailTemplate')); } return url($invoice->getRoute()); } - private function emailInvoice($invoice, $pdfUpload) + private function emailInvoice($invoice, $reminder = false, $pdfUpload = false, $template = false) { $entityType = $invoice->getEntityType(); $pdfUpload = Utils::decodePDF($pdfUpload); @@ -413,9 +413,9 @@ class InvoiceController extends BaseController } else { // TODO remove this with Laravel 5.3 (https://github.com/invoiceninja/invoiceninja/issues/1303) if (config('queue.default') === 'sync') { - $response = app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice, false, $pdfUpload); + $response = app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice, $reminder, $pdfUpload, $template); } else { - $this->dispatch(new SendInvoiceEmail($invoice, false, $pdfUpload)); + $this->dispatch(new SendInvoiceEmail($invoice, $reminder, $pdfUpload, $template)); $response = true; } } diff --git a/app/Jobs/SendInvoiceEmail.php b/app/Jobs/SendInvoiceEmail.php index e1ea2c39908c..a638b2b049c0 100644 --- a/app/Jobs/SendInvoiceEmail.php +++ b/app/Jobs/SendInvoiceEmail.php @@ -31,6 +31,11 @@ class SendInvoiceEmail extends Job implements ShouldQueue */ protected $pdfString; + /** + * @var array + */ + protected $template; + /** * Create a new job instance. * @@ -39,11 +44,12 @@ class SendInvoiceEmail extends Job implements ShouldQueue * @param bool $reminder * @param mixed $pdfString */ - public function __construct(Invoice $invoice, $reminder = false, $pdfString = false) + public function __construct(Invoice $invoice, $reminder = false, $pdfString = false, $template = false) { $this->invoice = $invoice; $this->reminder = $reminder; $this->pdfString = $pdfString; + $this->template = $template; } /** @@ -53,7 +59,7 @@ class SendInvoiceEmail extends Job implements ShouldQueue */ public function handle(ContactMailer $mailer) { - $mailer->sendInvoice($this->invoice, $this->reminder, $this->pdfString); + $mailer->sendInvoice($this->invoice, $this->reminder, $this->pdfString, $this->template); } /* diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 963bc82aa1cd..12143cb6deee 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -36,7 +36,7 @@ class ContactMailer extends Mailer * * @return bool|null|string */ - public function sendInvoice(Invoice $invoice, $reminder = false, $pdfString = false) + public function sendInvoice(Invoice $invoice, $reminder = false, $pdfString = false, $template = false) { if ($invoice->is_recurring) { return false; @@ -57,8 +57,8 @@ class ContactMailer extends Mailer } $account->loadLocalizationSettings($client); - $emailTemplate = $account->getEmailTemplate($reminder ?: $entityType); - $emailSubject = $account->getEmailSubject($reminder ?: $entityType); + $emailTemplate = !empty($template['body']) ? $template['body'] : $account->getEmailTemplate($reminder ?: $entityType); + $emailSubject = !empty($template['subject']) ? $template['subject'] : $account->getEmailSubject($reminder ?: $entityType); $sent = false; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 97d9c232ee5e..c5e58adde117 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2354,6 +2354,7 @@ $LANG = array( 'days_ago' => ':count day ago|:count days ago', 'sent_by' => 'Sent by :user', 'recipients' => 'Recipients', + 'today' => 'Today', ); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index d7944a25ff49..087f053d4517 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -11,6 +11,8 @@ + + diff --git a/resources/views/partials/email_templates.blade.php b/resources/views/partials/email_templates.blade.php index 6731094b6417..333e790a4420 100644 --- a/resources/views/partials/email_templates.blade.php +++ b/resources/views/partials/email_templates.blade.php @@ -5,7 +5,7 @@ return ''; } - var passwordHtml = "{!! $account->isPro() && $account->enable_portal_password && $account->send_portal_password?'
'.trans('texts.password').': XXXXXXXXX
':'' !!}";
+ var passwordHtml = "{!! $account->isPro() && $account->enable_portal_password && $account->send_portal_password?'
'.trans('texts.password').': XXXXXXXXX
':'' !!}";
@if ($account->isPro())
var documentsHtml = "{!! trans('texts.email_documents_header').'