invoice; $passwordHTML = isset($data['password'])?'

'.trans('texts.password').': '.$data['password'].'

':false; $documentsHTML = ''; if ($account->hasFeature(FEATURE_DOCUMENTS) && $invoice->hasDocuments()) { $documentsHTML .= trans('texts.email_documents_header').'

'; } $variables = [ '$footer' => $account->getEmailFooter(), '$client' => $client->getDisplayName(), '$account' => $account->getDisplayName(), '$dueDate' => $account->formatDate($invoice->due_date), '$invoiceDate' => $account->formatDate($invoice->invoice_date), '$contact' => $invitation->contact->getDisplayName(), '$firstName' => $invitation->contact->first_name, '$amount' => $account->formatMoney($data['amount'], $client), '$invoice' => $invoice->invoice_number, '$quote' => $invoice->invoice_number, '$link' => $invitation->getLink(), '$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' => $client->custom_value1, '$customClient2' => $client->custom_value2, '$customInvoice1' => $invoice->custom_text_value1, '$customInvoice2' => $invoice->custom_text_value2, '$documents' => $documentsHTML, '$autoBill' => empty($data['autobill'])?'':$data['autobill'], '$portalLink' => $invitation->contact->link, '$portalButton' => Form::emailViewButton($invitation->contact->link, 'portal'), ]; // Add variables for available payment types foreach (Gateway::$gatewayTypes as $type) { if ($type == GATEWAY_TYPE_TOKEN) { continue; } $camelType = Utils::toCamelCase(GatewayType::getAliasFromId($type)); $snakeCase = Utils::toSnakeCase(GatewayType::getAliasFromId($type)); $variables["\${$camelType}Link"] = $invitation->getLink('payment') . "/{$snakeCase}"; $variables["\${$camelType}Button"] = Form::emailPaymentButton($invitation->getLink('payment') . "/{$snakeCase}"); } $includesPasswordPlaceholder = strpos($template, '$password') !== false; $str = str_replace(array_keys($variables), array_values($variables), $template); 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); $str = autolink($str, 100); return $str; } }