mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 12:24:35 -04:00
Refactor remaining entities to attach using data rather than paths
This commit is contained in:
parent
93c96e0d78
commit
d0bb55f0c2
@ -39,6 +39,6 @@ class ValidCompanyQuantity implements Rule
|
|||||||
*/
|
*/
|
||||||
public function message()
|
public function message()
|
||||||
{
|
{
|
||||||
return ctrans('texts.company_limit_reached');
|
return ctrans('texts.company_limit_reached', ['limit' => Ninja::isSelfHost() ? 10 : auth()->user()->company()->account->hosted_company_count]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Mail\Engine;
|
namespace App\Mail\Engine;
|
||||||
|
|
||||||
|
use App\Jobs\Entity\CreateRawPdf;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Utils\HtmlEngine;
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
@ -117,11 +118,17 @@ class CreditEmailEngine extends BaseEmailEngine
|
|||||||
->setTextBody($text_body);
|
->setTextBody($text_body);
|
||||||
|
|
||||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->credit->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->credit->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||||
if (Ninja::isHosted()) {
|
// if (Ninja::isHosted()) {
|
||||||
$this->setAttachments([$this->credit->pdf_file_path($this->invitation, 'url', true)]);
|
// $this->setAttachments([$this->credit->pdf_file_path($this->invitation, 'url', true)]);
|
||||||
} else {
|
// } else {
|
||||||
$this->setAttachments([$this->credit->pdf_file_path($this->invitation)]);
|
// $this->setAttachments([$this->credit->pdf_file_path($this->invitation)]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
$pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle());
|
||||||
|
|
||||||
|
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->credit->numberFormatter().'.pdf']]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//attach third party documents
|
//attach third party documents
|
||||||
@ -129,11 +136,11 @@ class CreditEmailEngine extends BaseEmailEngine
|
|||||||
|
|
||||||
// Storage::url
|
// Storage::url
|
||||||
foreach ($this->credit->documents as $document) {
|
foreach ($this->credit->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())]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->credit->company->documents as $document) {
|
foreach ($this->credit->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())]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Mail\Engine;
|
namespace App\Mail\Engine;
|
||||||
|
|
||||||
use App\DataMapper\EmailTemplateDefaults;
|
use App\DataMapper\EmailTemplateDefaults;
|
||||||
|
use App\Jobs\Entity\CreateRawPdf;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Utils\Helpers;
|
use App\Utils\Helpers;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
@ -89,11 +90,15 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
|
|
||||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||||
$this->payment->invoices->each(function ($invoice) {
|
$this->payment->invoices->each(function ($invoice) {
|
||||||
if (Ninja::isHosted()) {
|
// if (Ninja::isHosted()) {
|
||||||
$this->setAttachments([$invoice->pdf_file_path($invoice->invitations->first(), 'url', true)]);
|
// $this->setAttachments([$invoice->pdf_file_path($invoice->invitations->first(), 'url', true)]);
|
||||||
} else {
|
// } else {
|
||||||
$this->setAttachments([$invoice->pdf_file_path($invoice->invitations->first())]);
|
// $this->setAttachments([$invoice->pdf_file_path($invoice->invitations->first())]);
|
||||||
}
|
// }
|
||||||
|
$pdf = ((new CreateRawPdf($invoice->invitations->first(), $invoice->company->db))->handle());
|
||||||
|
|
||||||
|
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $invoice->numberFormatter().'.pdf']]);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace App\Mail\Engine;
|
|||||||
|
|
||||||
use App\DataMapper\EmailTemplateDefaults;
|
use App\DataMapper\EmailTemplateDefaults;
|
||||||
use App\Jobs\Entity\CreateEntityPdf;
|
use App\Jobs\Entity\CreateEntityPdf;
|
||||||
|
use App\Jobs\Vendor\CreatePurchaseOrderPdf;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\PurchaseOrder;
|
||||||
@ -125,11 +126,16 @@ class PurchaseOrderEmailEngine extends BaseEmailEngine
|
|||||||
->setTextBody($text_body);
|
->setTextBody($text_body);
|
||||||
|
|
||||||
if ($this->vendor->getSetting('pdf_email_attachment') !== false && $this->purchase_order->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
if ($this->vendor->getSetting('pdf_email_attachment') !== false && $this->purchase_order->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||||
if (Ninja::isHosted()) {
|
// if (Ninja::isHosted()) {
|
||||||
$this->setAttachments([$this->purchase_order->pdf_file_path($this->invitation, 'url', true)]);
|
// $this->setAttachments([$this->purchase_order->pdf_file_path($this->invitation, 'url', true)]);
|
||||||
} else {
|
// } else {
|
||||||
$this->setAttachments([$this->purchase_order->pdf_file_path($this->invitation)]);
|
// $this->setAttachments([$this->purchase_order->pdf_file_path($this->invitation)]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
$pdf = (new CreatePurchaseOrderPdf($this->invitation))->rawPdf();
|
||||||
|
|
||||||
|
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->purchase_order->numberFormatter().'.pdf']]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//attach third party documents
|
//attach third party documents
|
||||||
@ -137,11 +143,13 @@ class PurchaseOrderEmailEngine extends BaseEmailEngine
|
|||||||
|
|
||||||
// Storage::url
|
// Storage::url
|
||||||
foreach ($this->purchase_order->documents as $document) {
|
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]]);
|
||||||
|
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->purchase_order->company->documents as $document) {
|
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]]);
|
||||||
|
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Mail\Engine;
|
namespace App\Mail\Engine;
|
||||||
|
|
||||||
|
use App\Jobs\Entity\CreateRawPdf;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Utils\HtmlEngine;
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
@ -116,11 +117,15 @@ class QuoteEmailEngine extends BaseEmailEngine
|
|||||||
->setTextBody($text_body);
|
->setTextBody($text_body);
|
||||||
|
|
||||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->quote->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->quote->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||||
if (Ninja::isHosted()) {
|
// if (Ninja::isHosted()) {
|
||||||
$this->setAttachments([$this->quote->pdf_file_path($this->invitation, 'url', true)]);
|
// $this->setAttachments([$this->quote->pdf_file_path($this->invitation, 'url', true)]);
|
||||||
} else {
|
// } else {
|
||||||
$this->setAttachments([$this->quote->pdf_file_path($this->invitation)]);
|
// $this->setAttachments([$this->quote->pdf_file_path($this->invitation)]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
$pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle());
|
||||||
|
|
||||||
|
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->quote->numberFormatter().'.pdf']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//attach third party documents
|
//attach third party documents
|
||||||
@ -128,11 +133,11 @@ class QuoteEmailEngine extends BaseEmailEngine
|
|||||||
|
|
||||||
// Storage::url
|
// Storage::url
|
||||||
foreach ($this->quote->documents as $document) {
|
foreach ($this->quote->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())]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->quote->company->documents as $document) {
|
foreach ($this->quote->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())]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,31 +120,31 @@ class TemplateEmail extends Mailable
|
|||||||
|
|
||||||
/*In the hosted platform we need to slow things down a little for Storage to catch up.*/
|
/*In the hosted platform we need to slow things down a little for Storage to catch up.*/
|
||||||
|
|
||||||
if(Ninja::isHosted() && $this->invitation){
|
// if(Ninja::isHosted() && $this->invitation){
|
||||||
|
|
||||||
$path = false;
|
// $path = false;
|
||||||
|
|
||||||
if($this->invitation->invoice)
|
// if($this->invitation->invoice)
|
||||||
$path = $this->client->invoice_filepath($this->invitation).$this->invitation->invoice->numberFormatter().'.pdf';
|
// $path = $this->client->invoice_filepath($this->invitation).$this->invitation->invoice->numberFormatter().'.pdf';
|
||||||
elseif($this->invitation->quote)
|
// elseif($this->invitation->quote)
|
||||||
$path = $this->client->quote_filepath($this->invitation).$this->invitation->quote->numberFormatter().'.pdf';
|
// $path = $this->client->quote_filepath($this->invitation).$this->invitation->quote->numberFormatter().'.pdf';
|
||||||
elseif($this->invitation->credit)
|
// elseif($this->invitation->credit)
|
||||||
$path = $this->client->credit_filepath($this->invitation).$this->invitation->credit->numberFormatter().'.pdf';
|
// $path = $this->client->credit_filepath($this->invitation).$this->invitation->credit->numberFormatter().'.pdf';
|
||||||
|
|
||||||
sleep(1);
|
// sleep(1);
|
||||||
|
|
||||||
if($path && !Storage::disk(config('filesystems.default'))->exists($path)){
|
// if($path && !Storage::disk(config('filesystems.default'))->exists($path)){
|
||||||
|
|
||||||
sleep(2);
|
// sleep(2);
|
||||||
|
|
||||||
if(!Storage::disk(config('filesystems.default'))->exists($path)) {
|
// if(!Storage::disk(config('filesystems.default'))->exists($path)) {
|
||||||
(new CreateEntityPdf($this->invitation))->handle();
|
// (new CreateEntityPdf($this->invitation))->handle();
|
||||||
sleep(2);
|
// sleep(2);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
// $file = (new CreateRawPdf($invitation, $invitation->company->db))->handle();
|
// $file = (new CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||||
|
|
||||||
|
@ -116,34 +116,37 @@ class VendorTemplateEmail extends Mailable
|
|||||||
//});
|
//});
|
||||||
// ->tag($this->company->company_key);
|
// ->tag($this->company->company_key);
|
||||||
|
|
||||||
if(Ninja::isHosted() && $this->invitation){
|
// if(Ninja::isHosted() && $this->invitation){
|
||||||
|
|
||||||
$path = false;
|
// $path = false;
|
||||||
|
|
||||||
if($this->invitation->purchase_order)
|
// if($this->invitation->purchase_order)
|
||||||
$path = $this->vendor->purchase_order_filepath($this->invitation).$this->invitation->purchase_order->numberFormatter().'.pdf';
|
// $path = $this->vendor->purchase_order_filepath($this->invitation).$this->invitation->purchase_order->numberFormatter().'.pdf';
|
||||||
|
|
||||||
sleep(1);
|
// sleep(1);
|
||||||
|
|
||||||
if($path && !Storage::disk(config('filesystems.default'))->exists($path)){
|
// if($path && !Storage::disk(config('filesystems.default'))->exists($path)){
|
||||||
|
|
||||||
sleep(2);
|
// sleep(2);
|
||||||
|
|
||||||
if(!Storage::disk(config('filesystems.default'))->exists($path)) {
|
// if(!Storage::disk(config('filesystems.default'))->exists($path)) {
|
||||||
(new CreatePurchaseOrderPdf($this->invitation))->handle();
|
// (new CreatePurchaseOrderPdf($this->invitation))->handle();
|
||||||
sleep(2);
|
// sleep(2);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
foreach ($this->build_email->getAttachments() as $file) {
|
foreach ($this->build_email->getAttachments() as $file) {
|
||||||
if (is_string($file)) {
|
// if (is_string($file)) {
|
||||||
$this->attach($file);
|
// $this->attach($file);
|
||||||
} elseif (is_array($file)) {
|
// } elseif (is_array($file)) {
|
||||||
$this->attach($file['path'], ['as' => $file['name'], 'mime' => null]);
|
// $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
$this->attachData(base64_decode($file['file']), $file['name']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -4061,7 +4061,7 @@ $LANG = array(
|
|||||||
'save_payment_method_details' => 'Save payment method details',
|
'save_payment_method_details' => 'Save payment method details',
|
||||||
'new_card' => 'New card',
|
'new_card' => 'New card',
|
||||||
'new_bank_account' => 'New bank account',
|
'new_bank_account' => 'New bank account',
|
||||||
'company_limit_reached' => 'Limit of 10 companies per account.',
|
'company_limit_reached' => 'Limit of :limit companies per account.',
|
||||||
'credits_applied_validation' => 'Total credits applied cannot be MORE than total of invoices',
|
'credits_applied_validation' => 'Total credits applied cannot be MORE than total of invoices',
|
||||||
'credit_number_taken' => 'Credit number already taken',
|
'credit_number_taken' => 'Credit number already taken',
|
||||||
'credit_not_found' => 'Credit not found',
|
'credit_not_found' => 'Credit not found',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user