diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 9ebfe51fa8c6..b6d5184627cf 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -262,6 +262,7 @@ class ContactMailer extends Mailer $client = $data['client']; $invitation = $data['invitation']; $invoice = $invitation->invoice; + $passwordHTML = isset($data['password'])?'
'.trans('texts.password').': '.$data['password'].'
':false; $variables = [ '$footer' => $account->getEmailFooter(), @@ -275,15 +276,15 @@ class ContactMailer extends Mailer '$invoice' => $invoice->invoice_number, '$quote' => $invoice->invoice_number, '$link' => $invitation->getLink(), - '$viewLink' => $invitation->getLink(), - '$viewButton' => Form::emailViewButton($invitation->getLink(), $invoice->getEntityType()), - '$paymentLink' => $invitation->getLink('payment'), - '$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')), + '$password' => $passwordHTML, + '$viewLink' => $invitation->getLink().'$password', + '$viewButton' => Form::emailViewButton($invitation->getLink(), $invoice->getEntityType()).'$password', + '$paymentLink' => $invitation->getLink('payment').'$password', + '$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')).'$password', '$customClient1' => $account->custom_client_label1, '$customClient2' => $account->custom_client_label2, '$customInvoice1' => $account->custom_invoice_text_label1, '$customInvoice2' => $account->custom_invoice_text_label2, - '$password' => isset($data['password'])?$data['password']:false, ]; // Add variables for available payment types @@ -293,9 +294,21 @@ class ContactMailer extends Mailer $variables["\${$camelType}Link"] = $invitation->getLink() . "/{$type}"; $variables["\${$camelType}Button"] = Form::emailPaymentButton($invitation->getLink('payment') . "/{$type}"); } - + + $includesPasswordPlaceholder = strpos($template, '$password') !== false; + $str = str_replace(array_keys($variables), array_values($variables), $template); $str = autolink($str, 100); + + if(!$includesPasswordPlaceholder && $passwordHTML){ + $pos = strrpos($str, '$password'); + if($pos !== false) + { + $str = substr_replace($str, $passwordHTML, $pos, 9/* length of "$password" */); + } + } + $str = str_replace('$password', '', $str); + return $str; } diff --git a/resources/views/accounts/templates_and_reminders.blade.php b/resources/views/accounts/templates_and_reminders.blade.php index 55e2a6ae5526..22a3a8a4a08c 100644 --- a/resources/views/accounts/templates_and_reminders.blade.php +++ b/resources/views/accounts/templates_and_reminders.blade.php @@ -200,6 +200,7 @@ } var keys = {!! json_encode(\App\Ninja\Mailers\ContactMailer::$variableFields) !!}; + var passwordHtml = "{!! $account->isPro() && $account->enable_portal_password && $account->send_portal_password?'
'.trans('texts.password').': 6h2NWNdw6
':'' !!}";
var vals = [
{!! json_encode($emailFooter) !!},
"{{ $account->getDisplayName() }}",
@@ -211,11 +212,11 @@
"First Name",
"0001",
"0001",
- '6h2NWNdw6',
- "{{ URL::to('/view/...') }}",
- '{!! Form::flatButton('view_invoice', '#0b4d78') !!}',
- "{{ URL::to('/payment/...') }}",
- '{!! Form::flatButton('pay_now', '#36c157') !!}',
+ passwordHtml,
+ "{{ URL::to('/view/...') }}$password",
+ '{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password',
+ "{{ URL::to('/payment/...') }}$password",
+ '{!! Form::flatButton('pay_now', '#36c157') !!}$password',
];
// Add blanks for custom values
@@ -231,10 +232,18 @@
{!! "vals.push('" . Form::flatButton('pay_now', '#36c157') . "');" !!}
@endforeach
+ var includesPasswordPlaceholder = str.indexOf('$password') != -1;
+
for (var i=0; i