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; return Utils::isEmpty($entity->$field) ? false : true;
} }
public function attatchPDF() public function attachPDF()
{ {
return $this->hasFeature(FEATURE_PDF_ATTACHMENT) && $this->pdf_email_attachment; return $this->hasFeature(FEATURE_PDF_ATTACHMENT) && $this->pdf_email_attachment;
} }

View File

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

View File

@ -1209,8 +1209,13 @@
if (confirm('{!! trans("texts.confirm_email_$entityType") !!}' + '\n\n' + getSendToEmails())) { if (confirm('{!! trans("texts.confirm_email_$entityType") !!}' + '\n\n' + getSendToEmails())) {
var accountLanguageId = parseInt({{ $account->language_id ?: '0' }}); var accountLanguageId = parseInt({{ $account->language_id ?: '0' }});
var clientLanguageId = parseInt(model.invoice().client().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 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'); submitAction('email');
} else { } else {
preparePdfData('email'); preparePdfData('email');