mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Attaching documents
This commit is contained in:
parent
2d3fe13c82
commit
32363d85ca
@ -309,11 +309,7 @@ class MailBuild
|
|||||||
|
|
||||||
if ($this->settings->document_email_attachment && $this->mail_entity->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
if ($this->settings->document_email_attachment && $this->mail_entity->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
||||||
|
|
||||||
foreach ($this->mail_entity->company->documents as $document) {
|
$this->attachDocuments($this->mail_entity->company->documents);
|
||||||
|
|
||||||
$this->mail_entity->mail_object->attachments = array_merge($this->mail_entity->mail_object->attachments, ['file' => base64_encode($document->getFile()), 'name' => $document->name]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,6 +317,21 @@ class MailBuild
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function attachDocuments($documents): self
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach ($documents as $document) {
|
||||||
|
|
||||||
|
if($document->size > $this->max_attachment_size)
|
||||||
|
$this->mail_entity->mail_object->attachment_links = array_merge($this->mail_entity->mail_object->attachment_links, [["<a class='doc_links' href='" . URL::signedRoute('documents.public_download', ['document_hash' => $document->hash]) ."'>". $document->name ."</a>"]]);
|
||||||
|
else
|
||||||
|
$this->mail_entity->mail_object->attachments = array_merge($this->mail_entity->mail_object->attachments,[['file' => base64_encode($document->getFile()), 'name' => $document->name]]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Depending on context we may need to resolve the
|
* Depending on context we may need to resolve the
|
||||||
* attachment dependencies.
|
* attachment dependencies.
|
||||||
@ -346,15 +357,8 @@ class MailBuild
|
|||||||
|
|
||||||
if ($this->vendor->getSetting('document_email_attachment') !== false && $this->mail_entity->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
if ($this->vendor->getSetting('document_email_attachment') !== false && $this->mail_entity->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
||||||
|
|
||||||
// Storage::url
|
$this->attachDocuments($this->mail_entity->invitation->purchase_order->documents);
|
||||||
foreach ($this->mail_entity->invitation->purchase_order->documents as $document) {
|
|
||||||
|
|
||||||
if($document->size > $this->max_attachment_size)
|
|
||||||
$this->mail_entity->mail_object->attachment_links = array_merge($this->mail_entity->mail_object->attachment_links, [["<a class='doc_links' href='" . URL::signedRoute('documents.public_download', ['document_hash' => $document->hash]) ."'>". $document->name ."</a>"]]);
|
|
||||||
else
|
|
||||||
$this->mail_entity->mail_object->attachments = array_merge($this->mail_entity->mail_object->attachments, [['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -378,15 +382,8 @@ class MailBuild
|
|||||||
|
|
||||||
if ($this->client->getSetting('document_email_attachment') !== false && $this->mail_entity->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
if ($this->client->getSetting('document_email_attachment') !== false && $this->mail_entity->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
||||||
|
|
||||||
// Storage::url
|
$this->attachDocuments($this->mail_entity->invitation->{$entity}->documents);
|
||||||
foreach ($this->mail_entity->invitation->{$entity}->documents as $document) {
|
|
||||||
|
|
||||||
if($document->size > $this->max_attachment_size)
|
|
||||||
$this->mail_entity->mail_object->attachment_links = array_merge($this->mail_entity->mail_object->attachment_links, [["<a class='doc_links' href='" . URL::signedRoute('documents.public_download', ['document_hash' => $document->hash]) ."'>". $document->name ."</a>"]]);
|
|
||||||
else
|
|
||||||
$this->mail_entity->mail_object->attachments = array_merge($this->mail_entity->mail_object->attachments, [['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -416,15 +413,9 @@ class MailBuild
|
|||||||
->where('invoice_documents', 1)
|
->where('invoice_documents', 1)
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function ($expense) {
|
->each(function ($expense) {
|
||||||
foreach ($expense->documents as $document) {
|
|
||||||
|
|
||||||
if($document->size > $this->max_attachment_size)
|
$this->attachDocuments($expense->documents);
|
||||||
$this->mail_entity->mail_object->attachment_links = array_merge($this->mail_entity->mail_object->attachment_links, [["<a class='doc_links' href='" . URL::signedRoute('documents.public_download', ['document_hash' => $document->hash]) ."'>". $document->name ."</a>"]]);
|
|
||||||
else
|
|
||||||
$this->mail_entity->mail_object->attachments = array_merge($this->mail_entity->mail_object->attachments, [['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,14 +429,9 @@ class MailBuild
|
|||||||
$tasks = Task::whereIn('id', $this->transformKeys($task_ids))
|
$tasks = Task::whereIn('id', $this->transformKeys($task_ids))
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function ($task) {
|
->each(function ($task) {
|
||||||
foreach ($task->documents as $document) {
|
|
||||||
|
|
||||||
if($document->size > $this->max_attachment_size)
|
$this->attachDocuments($task->documents);
|
||||||
$this->mail_entity->mail_object->attachment_links = array_merge($this->mail_entity->mail_object->attachment_links, [["<a class='doc_links' href='" . URL::signedRoute('documents.public_download', ['document_hash' => $document->hash]) ."'>". $document->name ."</a>"]]);
|
|
||||||
else
|
|
||||||
$this->mail_entity->mail_object->attachments = array_merge($this->mail_entity->mail_object->attachments, [['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user