Don't render pdf if not attached and fix typo

This commit is contained in:
Hillel Coren 2016-05-29 19:32:45 +03:00
parent a7f9847978
commit d175fc872a
3 changed files with 10 additions and 5 deletions

View File

@ -1317,7 +1317,7 @@ class Account extends Eloquent
return Utils::isEmpty($entity->$field) ? false : true;
}
public function attatchPDF()
public function attachPDF()
{
return $this->hasFeature(FEATURE_PDF_ATTACHMENT) && $this->pdf_email_attachment;
}

View File

@ -59,7 +59,7 @@ class ContactMailer extends Mailer
$sent = false;
if ($account->attatchPDF() && !$pdfString) {
if ($account->attachPDF() && !$pdfString) {
$pdfString = $invoice->getPDFString();
}
@ -156,7 +156,7 @@ class ContactMailer extends Mailer
'documents' => $documentStrings,
];
if ($account->attatchPDF()) {
if ($account->attachPDF()) {
$data['pdfString'] = $pdfString;
$data['pdfFileName'] = $invoice->getFileName();
}
@ -235,7 +235,7 @@ class ContactMailer extends Mailer
'entityType' => ENTITY_INVOICE,
];
if ($account->attatchPDF()) {
if ($account->attachPDF()) {
$data['pdfString'] = $invoice->getPDFString();
$data['pdfFileName'] = $invoice->getFileName();
}

View File

@ -1209,8 +1209,13 @@
if (confirm('{!! trans("texts.confirm_email_$entityType") !!}' + '\n\n' + getSendToEmails())) {
var accountLanguageId = parseInt({{ $account->language_id ?: '0' }});
var clientLanguageId = parseInt(model.invoice().client().language_id()) || 0;
var attachPDF = {{ $account->attachPDF() ? 'true' : 'false' }};
// if they aren't attaching the pdf no need to generate it
if ( ! attachPDF) {
submitAction('email');
// if the client's language is different then we can't use the browser version of the PDF
if (clientLanguageId && clientLanguageId != accountLanguageId) {
} else if (clientLanguageId && clientLanguageId != accountLanguageId) {
submitAction('email');
} else {
preparePdfData('email');