1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Endless reminders

This commit is contained in:
Hillel Coren 2017-12-26 12:11:58 +02:00
parent d6c8191b7e
commit 57549437f9
4 changed files with 31 additions and 1 deletions

View File

@ -132,6 +132,9 @@ class SendReminders extends Command
foreach ($invoices as $invoice) {
if ($reminder = $account->getInvoiceReminder($invoice)) {
if ($invoice->last_sent_date == date('Y-m-d')) {
continue;
}
$this->info('Send email: ' . $invoice->id);
$this->mailer->sendInvoice($invoice, $reminder);
}
@ -142,6 +145,9 @@ class SendReminders extends Command
$this->info($account->name . ': ' . count($invoices) . ' endless invoices found');
foreach ($invoices as $invoice) {
if ($invoice->last_sent_date == date('Y-m-d')) {
continue;
}
$this->info('Send email: ' . $invoice->id);
$this->mailer->sendInvoice($invoice, 'reminder4');
}

View File

@ -3,6 +3,7 @@
namespace App\Listeners;
use App\Events\QuoteInvitationWasViewed;
use App\Events\QuoteWasEmailed;
/**
* Class QuoteListener.
@ -17,4 +18,15 @@ class QuoteListener
$invitation = $event->invitation;
$invitation->markViewed();
}
/**
* @param InvoiceWasEmailed $event
*/
public function emailedQuote(QuoteWasEmailed $event)
{
$quote = $event->quote;
$quote->last_sent_date = date('Y-m-d');
$quote->save();
}
}

View File

@ -55,8 +55,8 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\ActivityListener@restoredInvoice',
],
'App\Events\InvoiceWasEmailed' => [
'App\Listeners\NotificationListener@emailedInvoice',
'App\Listeners\InvoiceListener@emailedInvoice',
'App\Listeners\NotificationListener@emailedInvoice',
],
'App\Events\InvoiceInvitationWasEmailed' => [
'App\Listeners\ActivityListener@emailedInvoice',
@ -90,6 +90,7 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\ActivityListener@restoredQuote',
],
'App\Events\QuoteWasEmailed' => [
'App\Listeners\QuoteListener@emailedQuote',
'App\Listeners\NotificationListener@emailedQuote',
],
'App\Events\QuoteInvitationWasEmailed' => [

View File

@ -83,6 +83,17 @@ class AddRemember2faToken extends Migration
where invoices.id = activities.invoice_id
and invoices.is_recurring = 0
and invoices.invoice_type_id = 1");
DB::statement("update invoices, (
select max(created_at) created_at, invoice_id
from activities
where activity_type_id = 20
group by invoice_id
) as activities
set invoices.last_sent_date = activities.created_at
where invoices.id = activities.invoice_id
and invoices.is_recurring = 0
and invoices.invoice_type_id = 2");
}
/**