1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/app/Helpers/Email/QuoteEmail.php
michael-hampton f7650d0692
Ft email (#3326)
* Emails

* change to user service

* refactor emails

* refactor emails

* refactor emails

* refactor emails

* emails

* emails

* emails

* emails

* emails

* emails

* emails

* emails

* emails

* emails

* Update EmailPayment.php

* Update SendEmail.php

* Update SendEmail.php

* Update SendEmail.php

* Update and rename BuildEmail.php to EmailBuilder.php

* Create InvoiceEmail

* Create QuoteEmail.php

* Rename InvoiceEmail to InvoiceEmail.php

* Create PaymentEmail.php

* Update SendEmail.php

* Update SendEmail.php

* Update SendEmail.php

* Update SendEmail.php

* Update InvoiceEmail.php

* Update EmailInvoice.php

* Update SendEmail.php

* Update TemplateEmail.php

* Update EmailBuilder.php

* Update InvoiceEmail.php

* Update QuoteEmail.php

* Update PaymentEmail.php

* Update InvoiceEmail.php

* Update QuoteEmail.php

* Update QuoteInvitation.php

* Update EmailQuote.php

* Update SendEmail.php

* Update SendEmail.php

* Update PaymentService.php

* Update PaymentEmail.php

* Update PaymentEmail.php

* Update PaymentEmail.php

* Update EmailBuilder.php

* Update PaymentEmail.php

* Update EmailPayment.php

* Update SendEmail.php

* Update InvoiceService.php

* Update SendEmail.php

* Update PaymentService.php

* Update SendEmail.php

* Update QuoteService.php

* Update EmailPayment.php

Co-authored-by: David Bomba <turbo124@gmail.com>
2020-02-15 20:01:15 +11:00

59 lines
1.9 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: michael.hampton
* Date: 14/02/2020
* Time: 19:51
*/
namespace App\Helpers\Email;
use App\Models\Quote;
class QuoteEmail extends EmailBuilder
{
public function build(Quote $quote, $reminder_template, $contact = null)
{
$client = $quote->client;
$this->template_style = $quote->client->getSetting('email_style');
$body_template = $client->getSetting('email_template_' . $reminder_template);
/* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) {
$body_template = trans('texts.quote_message',
['amount' => $quote->amount, 'company' => $quote->company->present()->name()], null,
$quote->client->locale());
}
$subject_template = $client->getSetting('email_subject_' . $reminder_template);
if (iconv_strlen($subject_template) == 0) {
if ($reminder_template == 'quote') {
$subject_template = trans('texts.quote_subject',
['number' => $quote->number, 'company' => $quote->company->present()->name()],
null, $quote->client->locale());
} else {
$subject_template = trans('texts.reminder_subject',
['number' => $quote->number, 'company' => $quote->company->present()->name()],
null, $quote->client->locale());
}
}
$this->setTemplate($quote->client->getSetting('email_style'))
->setContact($contact)
->setFooter("<a href='{$quote->invitations->first()->getLink()}'>Invoice Link</a>")
->setVariables($quote->makeValues($contact))
->setSubject($subject_template)
->setBody($body_template);
if ($client->getSetting('pdf_email_attachment') !== false) {
$this->attachments = $quote->pdf_file_path();
}
return $this;
}
}