mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
feat(emails): implemented sending invoice, estimates and payments as attachements
This commit is contained in:
@ -13,17 +13,15 @@ class SendEstimateMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $data = [];
|
||||
public $pdfData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data, $pdfData)
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->pdfData = $pdfData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,22 +40,15 @@ class SendEstimateMail extends Mailable
|
||||
'mailable_id' => $this->data['estimate']['id']
|
||||
]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
$mailContent = $this->from($this->data['from'])
|
||||
$mailContent = $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.estimate', ['data', $this->data]);
|
||||
=======
|
||||
return $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.estimate', ['data', $this->data]);
|
||||
>>>>>>> master
|
||||
|
||||
if ($this->pdfData) {
|
||||
if ($this->data['attach']['data'])
|
||||
$mailContent->attachData(
|
||||
$this->pdfData->output(),
|
||||
$this->data['attach']['data']->output(),
|
||||
$this->data['estimate']['estimate_number'] . '.pdf'
|
||||
);
|
||||
}
|
||||
|
||||
return $mailContent;
|
||||
}
|
||||
|
||||
@ -14,17 +14,15 @@ class SendInvoiceMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $data = [];
|
||||
public $pdfData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data, $pdfData)
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->pdfData = $pdfData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,23 +41,16 @@ class SendInvoiceMail extends Mailable
|
||||
'mailable_id' => $this->data['invoice']['id']
|
||||
]);
|
||||
|
||||
$mailContent = $this->from($this->data['from'])
|
||||
$mailContent = $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.invoice', ['data', $this->data]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if ($this->pdfData) {
|
||||
if ($this->data['attach']['data'])
|
||||
$mailContent->attachData(
|
||||
$this->pdfData->output(),
|
||||
$this->data['attach']['data']->output(),
|
||||
$this->data['invoice']['invoice_number'] . '.pdf'
|
||||
);
|
||||
}
|
||||
|
||||
return $mailContent;
|
||||
=======
|
||||
return $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.invoice', ['data', $this->data]);
|
||||
>>>>>>> master
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,17 +14,15 @@ class SendPaymentMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $data = [];
|
||||
public $pdfData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data, $pdfData)
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->pdfData = $pdfData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,24 +41,16 @@ class SendPaymentMail extends Mailable
|
||||
'mailable_id' => $this->data['payment']['id']
|
||||
]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
$mailContent = $this->from($this->data['from'])
|
||||
$mailContent = $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.payment', ['data', $this->data]);
|
||||
|
||||
if ($this->pdfData) {
|
||||
if ($this->data['attach']['data'])
|
||||
$mailContent->attachData(
|
||||
$this->pdfData->output(),
|
||||
$this->data['attach']['data']->output(),
|
||||
$this->data['payment']['payment_number'] . '.pdf'
|
||||
);
|
||||
}
|
||||
|
||||
return $mailContent;
|
||||
=======
|
||||
return $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.payment', ['data', $this->data]);
|
||||
|
||||
>>>>>>> master
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,9 +379,9 @@ class Estimate extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = $this->company->toArray();
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$pdfData = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
\Mail::to($data['to'])->send(new SendEstimateMail($data, $pdfData));
|
||||
\Mail::to($data['to'])->send(new SendEstimateMail($data));
|
||||
|
||||
if ($this->status == Estimate::STATUS_DRAFT) {
|
||||
$this->status = Estimate::STATUS_SENT;
|
||||
|
||||
@ -429,7 +429,7 @@ class Invoice extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = Company::find($this->company_id);
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$pdfData = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
if ($this->status == Invoice::STATUS_DRAFT) {
|
||||
$this->status = Invoice::STATUS_SENT;
|
||||
@ -437,7 +437,7 @@ class Invoice extends Model implements HasMedia
|
||||
$this->save();
|
||||
}
|
||||
|
||||
\Mail::to($data['to'])->send(new SendInvoiceMail($data, $pdfData));
|
||||
\Mail::to($data['to'])->send(new SendInvoiceMail($data));
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
|
||||
@ -124,9 +124,9 @@ class Payment extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = Company::find($this->company_id);
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$pdfData = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
\Mail::to($data['to'])->send(new SendPaymentMail($data, $pdfData));
|
||||
\Mail::to($data['to'])->send(new SendPaymentMail($data));
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
|
||||
2
public/assets/css/crater.css
vendored
2
public/assets/css/crater.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,24 +1,24 @@
|
||||
/*!
|
||||
* tiptap v1.29.6
|
||||
* (c) 2020 überdosis GbR (limited liability)
|
||||
* tiptap v1.30.0
|
||||
* (c) 2021 überdosis GbR (limited liability)
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*!
|
||||
* tiptap-commands v1.14.6
|
||||
* (c) 2020 überdosis GbR (limited liability)
|
||||
* tiptap-commands v1.15.0
|
||||
* (c) 2021 überdosis GbR (limited liability)
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*!
|
||||
* tiptap-extensions v1.33.1
|
||||
* (c) 2020 überdosis GbR (limited liability)
|
||||
* tiptap-extensions v1.33.2
|
||||
* (c) 2021 überdosis GbR (limited liability)
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*!
|
||||
* tiptap-utils v1.10.4
|
||||
* (c) 2020 überdosis GbR (limited liability)
|
||||
* tiptap-utils v1.11.0
|
||||
* (c) 2021 überdosis GbR (limited liability)
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
@ -88,8 +88,8 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
* vue-i18n v8.22.4
|
||||
* (c) 2021 kazuya kawaguchi
|
||||
* vue-i18n v8.22.2
|
||||
* (c) 2020 kazuya kawaguchi
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
@ -100,8 +100,8 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
* vuex v3.6.2
|
||||
* (c) 2021 Evan You
|
||||
* vuex v3.6.0
|
||||
* (c) 2020 Evan You
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"/assets/js/app.js": "/assets/js/app.js?id=55c4ce4eeeff3bbd8033",
|
||||
"/assets/css/crater.css": "/assets/css/crater.css?id=d0c099a892a9295e5c6d"
|
||||
"/assets/js/app.js": "/assets/js/app.js?id=8fb7348f2257eedcb3e8",
|
||||
"/assets/css/crater.css": "/assets/css/crater.css?id=7a822f915d7e413148f6"
|
||||
}
|
||||
|
||||
@ -746,7 +746,7 @@
|
||||
"autogenerate_invoice_number": "Auto-generate Invoice Number",
|
||||
"invoice_setting_description": "Disable this, If you don't wish to auto-generate invoice numbers each time you create a new invoice.",
|
||||
"invoice_email_attachment": "Send invoices as attachments",
|
||||
"invoice_email_attachment_setting_description": "Enable this if you want to send invoices as email attachment.",
|
||||
"invoice_email_attachment_setting_description": "Enable this if you want to send invoices as email attachment. Please note that 'View Invoice' button in emails will not be displayed anymore when enabled.",
|
||||
"enter_invoice_prefix": "Enter invoice prefix",
|
||||
"terms_and_conditions": "Terms and Conditions",
|
||||
"company_address_format": "Company Address Format",
|
||||
@ -762,7 +762,7 @@
|
||||
"autogenerate_estimate_number": "Auto-generate Estimate Number",
|
||||
"estimate_setting_description": "Disable this, If you don't wish to auto-generate estimate numbers each time you create a new estimate.",
|
||||
"estimate_email_attachment": "Send estimates as attachments",
|
||||
"estimate_email_attachment_setting_description": "Enable this if you want to send the estimates as an email attachment.",
|
||||
"estimate_email_attachment_setting_description": "Enable this if you want to send the estimates as an email attachment. Please note that 'View Estimate' button in emails will not be displayed anymore when enabled.",
|
||||
"enter_estimate_prefix": "Enter estmiate prefix",
|
||||
"estimate_setting_updated": "Estimate Setting updated successfully",
|
||||
"company_address_format": "Company Address Format",
|
||||
@ -778,7 +778,7 @@
|
||||
"autogenerate_payment_number": "Auto-generate Payment Number",
|
||||
"payment_setting_description": "Disable this, If you don't wish to auto-generate payment numbers each time you create a new payment.",
|
||||
"payment_email_attachment": "Send payments as attachments",
|
||||
"payment_email_attachment_setting_description": "Enable this if you want to send the payment receipts as an email attachment.",
|
||||
"payment_email_attachment_setting_description": "Enable this if you want to send the payment receipts as an email attachment. Please note that 'View Payment' button in emails will not be displayed anymore when enabled.",
|
||||
"enter_payment_prefix": "Enter Payment Prefix",
|
||||
"payment_setting_updated": "Payment Setting updated successfully",
|
||||
"payment_modes": "Payment Modes",
|
||||
|
||||
@ -216,9 +216,9 @@ export default {
|
||||
this.payment_email_attachment = val ? val.payment_email_attachment : ''
|
||||
|
||||
if (this.payment_email_attachment === 'YES') {
|
||||
this.payment_email_attachment = true
|
||||
this.paymentAsAttachment = true
|
||||
} else {
|
||||
this.payment_email_attachment = false
|
||||
this.paymentAsAttachment = false
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
@slot('subcopy')
|
||||
@component('mail::subcopy')
|
||||
{!! $data['body'] !!}
|
||||
@if(!$pdfData)
|
||||
@if(!$data['attach']['data'])
|
||||
@component('mail::button', ['url' => url('/customer/estimates/pdf/'.$data['estimate']['unique_hash'])])
|
||||
View Estimate
|
||||
@endcomponent
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
@slot('subcopy')
|
||||
@component('mail::subcopy')
|
||||
{!! $data['body'] !!}
|
||||
@if(!$pdfData)
|
||||
@if(!$data['attach']['data'])
|
||||
@component('mail::button', ['url' => url('/customer/invoices/pdf/'.$data['invoice']['unique_hash'])])
|
||||
View Invoice
|
||||
@endcomponent
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
@slot('subcopy')
|
||||
@component('mail::subcopy')
|
||||
{!! $data['body'] !!}
|
||||
@if(!$pdfData)
|
||||
@if(!$data['attach']['data'])
|
||||
@component('mail::button', ['url' => url('/payments/pdf/'.$data['payment']['unique_hash'])])
|
||||
View Payment
|
||||
@endcomponent
|
||||
|
||||
Reference in New Issue
Block a user