mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Upgrading payment engine for templates
This commit is contained in:
parent
9fee3c538c
commit
c6d6150a32
@ -95,46 +95,54 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
->setViewText('');
|
->setViewText('');
|
||||||
|
|
||||||
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) {
|
|
||||||
|
|
||||||
if($this->is_refund && strlen($invoice->client->getSetting('payment_refund_design_id')) > 2) {
|
$template_in_use = false;
|
||||||
$pdf = (new TemplateAction(
|
|
||||||
[$this->payment->hashed_id],
|
|
||||||
$invoice->client->getSetting('payment_refund_design_id'),
|
|
||||||
Payment::class,
|
|
||||||
$this->payment->user_id,
|
|
||||||
$this->payment->company,
|
|
||||||
$this->payment->company->db,
|
|
||||||
'nohash',
|
|
||||||
false
|
|
||||||
))->handle();
|
|
||||||
|
|
||||||
$file_name = ctrans('texts.payment_refund_receipt', ['number' => $this->payment->number ]) . '.pdf';
|
if($this->is_refund && strlen($this->payment->client->getSetting('payment_refund_design_id')) > 2) {
|
||||||
$file_name = str_replace(' ', '_', $file_name);
|
$pdf = (new TemplateAction(
|
||||||
|
[$this->payment->hashed_id],
|
||||||
|
$this->payment->client->getSetting('payment_refund_design_id'),
|
||||||
|
Payment::class,
|
||||||
|
$this->payment->user_id,
|
||||||
|
$this->payment->company,
|
||||||
|
$this->payment->company->db,
|
||||||
|
'nohash',
|
||||||
|
false
|
||||||
|
))->handle();
|
||||||
|
|
||||||
}
|
$file_name = ctrans('texts.payment_refund_receipt', ['number' => $this->payment->number ]) . '.pdf';
|
||||||
elseif(!$this->is_refund && strlen($invoice->client->getSetting('payment_receipt_design_id')) > 2){
|
$file_name = str_replace(' ', '_', $file_name);
|
||||||
$pdf = (new TemplateAction(
|
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]);
|
||||||
[$this->payment->hashed_id],
|
$template_in_use = true;
|
||||||
$invoice->client->getSetting('payment_refund_design_id'),
|
|
||||||
Payment::class,
|
|
||||||
$this->payment->user_id,
|
|
||||||
$this->payment->company,
|
|
||||||
$this->payment->company->db,
|
|
||||||
'nohash',
|
|
||||||
false))->handle();
|
|
||||||
|
|
||||||
$file_name = ctrans('texts.payment_receipt', ['number' => $this->payment->number ]) . '.pdf';
|
|
||||||
$file_name = str_replace(' ', '_', $file_name);
|
|
||||||
|
|
||||||
}
|
} elseif(!$this->is_refund && strlen($this->payment->client->getSetting('payment_receipt_design_id')) > 2) {
|
||||||
else {
|
$pdf = (new TemplateAction(
|
||||||
|
[$this->payment->hashed_id],
|
||||||
|
$this->payment->client->getSetting('payment_receipt_design_id'),
|
||||||
|
Payment::class,
|
||||||
|
$this->payment->user_id,
|
||||||
|
$this->payment->company,
|
||||||
|
$this->payment->company->db,
|
||||||
|
'nohash',
|
||||||
|
false
|
||||||
|
))->handle();
|
||||||
|
|
||||||
|
$file_name = ctrans('texts.payment_receipt', ['number' => $this->payment->number ]) . '.pdf';
|
||||||
|
$file_name = str_replace(' ', '_', $file_name);
|
||||||
|
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]);
|
||||||
|
$template_in_use = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->payment->invoices->each(function ($invoice) use($template_in_use){
|
||||||
|
|
||||||
|
if(!$template_in_use)
|
||||||
|
{
|
||||||
$pdf = ((new CreateRawPdf($invoice->invitations->first(), $invoice->company->db))->handle());
|
$pdf = ((new CreateRawPdf($invoice->invitations->first(), $invoice->company->db))->handle());
|
||||||
$file_name = $invoice->numberFormatter().'.pdf';
|
$file_name = $invoice->numberFormatter().'.pdf';
|
||||||
|
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]);
|
|
||||||
|
|
||||||
//attach invoice documents also to payments
|
//attach invoice documents also to payments
|
||||||
if ($this->client->getSetting('document_email_attachment') !== false) {
|
if ($this->client->getSetting('document_email_attachment') !== false) {
|
||||||
foreach ($invoice->documents as $document) {
|
foreach ($invoice->documents as $document) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user