1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00

Fixes for reminder template emails

This commit is contained in:
David Bomba 2020-11-08 08:17:30 +11:00
parent a79447d4cf
commit 0d4ad91cd4
4 changed files with 21 additions and 8 deletions

View File

@ -3,7 +3,6 @@ APP_DEBUG=true
APP_LOCALE=en APP_LOCALE=en
APP_URL=http://127.0.0.1:8000 APP_URL=http://127.0.0.1:8000
APP_KEY=s7epnjtomsdond5zgfqgaqmwhhcjct02 APP_KEY=s7epnjtomsdond5zgfqgaqmwhhcjct02
APP_CIPHER=AES-256-CBC
REQUIRE_HTTPS=false REQUIRE_HTTPS=false
NINJA_ENVIRONMENT=development NINJA_ENVIRONMENT=development
@ -26,4 +25,3 @@ MAIL_FROM_ADDRESS=
MAIL_PASSWORD= MAIL_PASSWORD=
MAILGUN_DOMAIN= MAILGUN_DOMAIN=
MAILGUN_SECRET= MAILGUN_SECRET=
AUTH_PROVIDER=users

View File

@ -178,6 +178,7 @@ class EmailTemplateDefaults
public static function emailReminder1Subject() public static function emailReminder1Subject()
{ {
info("reminder 1 subject");
return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']); return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']);
} }

View File

@ -88,6 +88,8 @@ class SendReminders implements ShouldQueue
$reminder_template = $invoice->calculateTemplate('invoice'); $reminder_template = $invoice->calculateTemplate('invoice');
info("hitting a reminder for {$invoice->number} with template {$reminder_template}");
if(in_array($reminder_template, ['reminder1', 'reminder2', 'reminder3', 'endless_reminder'])) if(in_array($reminder_template, ['reminder1', 'reminder2', 'reminder3', 'endless_reminder']))
$this->sendReminder($invoice, $reminder_template); $this->sendReminder($invoice, $reminder_template);
@ -216,15 +218,18 @@ class SendReminders implements ShouldQueue
//only send if enable_reminder setting is toggled to yes //only send if enable_reminder setting is toggled to yes
if($this->checkSendSetting($invoice, $template)) { if($this->checkSendSetting($invoice, $template)) {
EmailEntity::dispatchNow($invitation, $invitation->company, $template); info("firing email");
event(new InvoiceWasEmailed($invitation, $invoice->company, Ninja::eventVars())); EmailEntity::dispatchNow($invitation, $invitation->company, $template);
} }
}); });
if($this->checkSendSetting($invoice, $template))
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars()));
$invoice->last_sent_date = now(); $invoice->last_sent_date = now();
$invoice->next_send_date = $this->calculateNextSendDate($invoice); $invoice->next_send_date = $this->calculateNextSendDate($invoice);
@ -232,7 +237,6 @@ class SendReminders implements ShouldQueue
if(in_array($template, ['reminder1', 'reminder2', 'reminder3'])) if(in_array($template, ['reminder1', 'reminder2', 'reminder3']))
$invoice->{$template."_sent"} = now(); $invoice->{$template."_sent"} = now();
$invoice->save(); $invoice->save();
} }

View File

@ -44,11 +44,14 @@ class InvoiceEmailEngine extends BaseEmailEngine
if(is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) if(is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0)
$body_template = $this->template_data['body']; $body_template = $this->template_data['body'];
elseif(strlen($this->client->getSetting('email_template_'.$this->reminder_template)) > 0)
$body_template = $this->client->getSetting('email_template_'.$this->reminder_template);
else{ else{
//$body_template = $this->client->getSetting('email_template_'.$this->reminder_template); //$body_template = $this->client->getSetting('email_template_'.$this->reminder_template);
$body_template = EmailTemplateDefaults::getDefaultTemplate($this->client->getSetting('email_template_'.$this->reminder_template), $this->client->locale()); $body_template = EmailTemplateDefaults::getDefaultTemplate('email_template_'.$this->reminder_template, $this->client->locale());
} }
/* Use default translations if a custom message has not been set*/ /* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) { if (iconv_strlen($body_template) == 0) {
$body_template = trans( $body_template = trans(
@ -63,10 +66,17 @@ class InvoiceEmailEngine extends BaseEmailEngine
); );
} }
if(is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) if(is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0){
$subject_template = $this->template_data['subject']; $subject_template = $this->template_data['subject'];
info("subject = template data");
}
elseif(strlen($this->client->getSetting('email_subject_'.$this->reminder_template)) > 0){
$subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
info("subject = settings var");
}
else{ else{
$subject_template = EmailTemplateDefaults::getDefaultTemplate($this->client->getSetting('email_subject_'.$this->reminder_template), $this->client->locale()); info("subject = default template " . 'email_subject_'.$this->reminder_template);
$subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_'.$this->reminder_template, $this->client->locale());
// $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); // $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
} }