mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-15 09:52:55 -05:00
Send Invoices/Estimates/Payments as email attachments
This commit is contained in:
@@ -379,8 +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;
|
||||
|
||||
\Mail::to($data['to'])->send(new SendEstimateMail($data));
|
||||
\Mail::to($data['to'])->send(new SendEstimateMail($data, $pdfData));
|
||||
|
||||
if ($this->status == Estimate::STATUS_DRAFT) {
|
||||
$this->status = Estimate::STATUS_SENT;
|
||||
@@ -468,6 +469,17 @@ class Estimate extends Model implements HasMedia
|
||||
return $this->getFormattedString($this->notes);
|
||||
}
|
||||
|
||||
public function getEmailAttachmentSetting()
|
||||
{
|
||||
$estimateAsAttachment = CompanySetting::getSetting('estimate_email_attachment', $this->company_id);
|
||||
|
||||
if($estimateAsAttachment == 'NO') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getEmailBody($body)
|
||||
{
|
||||
$values = array_merge($this->getFieldsArray(), $this->getExtraFields());
|
||||
|
||||
Reference in New Issue
Block a user