Refactor for attachments

This commit is contained in:
David Bomba 2022-11-28 15:45:25 +11:00
parent d0bb55f0c2
commit 448d3a2246
4 changed files with 16 additions and 13 deletions

View File

@ -143,11 +143,11 @@ class InvoiceEmailEngine extends BaseEmailEngine
// Storage::url
foreach ($this->invoice->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
}
foreach ($this->invoice->company->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
}
$line_items = $this->invoice->line_items;
@ -165,7 +165,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
->cursor()
->each(function ($expense) {
foreach ($expense->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
}
});
}
@ -181,7 +181,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
->cursor()
->each(function ($task) {
foreach ($task->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
}
});
}

View File

@ -143,13 +143,13 @@ class PurchaseOrderEmailEngine extends BaseEmailEngine
// Storage::url
foreach ($this->purchase_order->documents as $document) {
// $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
// $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
}
foreach ($this->purchase_order->company->documents as $document) {
// $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
// $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
}
}

View File

@ -123,7 +123,7 @@ class QuoteEmailEngine extends BaseEmailEngine
// $this->setAttachments([$this->quote->pdf_file_path($this->invitation)]);
// }
$pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle());
$pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle());
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->quote->numberFormatter().'.pdf']]);
}
@ -133,11 +133,11 @@ class QuoteEmailEngine extends BaseEmailEngine
// Storage::url
foreach ($this->quote->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
}
foreach ($this->quote->company->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
}
}

View File

@ -162,8 +162,11 @@ class TemplateEmail extends Mailable
// // $this->attachData($file_data, $file['name']);
// $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]);
// }
$this->attachData(base64_decode($file['file']), $file['name']);
if(array_key_exists('file', $file))
$this->attachData(base64_decode($file['file']), $file['name']);
else
$this->attach($file['path'], ['as' => $file['name'], 'mime' => null]);
}
if ($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {