diff --git a/.env.dusk.example b/.env.dusk.example index 60dd0ac0e9..4ad2e62efc 100644 --- a/.env.dusk.example +++ b/.env.dusk.example @@ -3,7 +3,6 @@ APP_DEBUG=true APP_LOCALE=en APP_URL=http://127.0.0.1:8000 APP_KEY=s7epnjtomsdond5zgfqgaqmwhhcjct02 -APP_CIPHER=AES-256-CBC REQUIRE_HTTPS=false NINJA_ENVIRONMENT=development @@ -26,4 +25,3 @@ MAIL_FROM_ADDRESS= MAIL_PASSWORD= MAILGUN_DOMAIN= MAILGUN_SECRET= -AUTH_PROVIDER=users diff --git a/app/DataMapper/EmailTemplateDefaults.php b/app/DataMapper/EmailTemplateDefaults.php index 5fc3288a95..0ab17319ad 100644 --- a/app/DataMapper/EmailTemplateDefaults.php +++ b/app/DataMapper/EmailTemplateDefaults.php @@ -178,6 +178,7 @@ class EmailTemplateDefaults public static function emailReminder1Subject() { + info("reminder 1 subject"); return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']); } diff --git a/app/Jobs/Ninja/SendReminders.php b/app/Jobs/Ninja/SendReminders.php index 89d5dbe285..ec9d9aaf7e 100644 --- a/app/Jobs/Ninja/SendReminders.php +++ b/app/Jobs/Ninja/SendReminders.php @@ -88,6 +88,8 @@ class SendReminders implements ShouldQueue $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'])) $this->sendReminder($invoice, $reminder_template); @@ -216,15 +218,18 @@ class SendReminders implements ShouldQueue //only send if enable_reminder setting is toggled to yes 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->next_send_date = $this->calculateNextSendDate($invoice); @@ -232,7 +237,6 @@ class SendReminders implements ShouldQueue if(in_array($template, ['reminder1', 'reminder2', 'reminder3'])) $invoice->{$template."_sent"} = now(); - $invoice->save(); } diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index 0eb4ce4cf9..4adfe2df06 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -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) $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{ //$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*/ if (iconv_strlen($body_template) == 0) { $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']; + 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{ - $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); }