diff --git a/app/Console/Commands/Scheduler.php b/app/Console/Commands/Scheduler.php index bbc5185..09d1fe0 100644 --- a/app/Console/Commands/Scheduler.php +++ b/app/Console/Commands/Scheduler.php @@ -183,6 +183,41 @@ class Scheduler extends Command break; } } + + $invoiceTransitRules = AlertMailRule::where('module', 'InvoiceTransit') + ->where('rule_name', 'InvoiceTransitMail') + ->select('plant', 'schedule_type') + ->distinct() + ->get(); + + foreach ($invoiceTransitRules as $rule) { + + switch ($rule->schedule_type) { + case 'Live': + // Run every minute + \Artisan::call('send:invoice-transit-report', [ + 'schedule_type' => $rule->schedule_type, + 'plant' => $rule->plant, + ]); + break; + case 'Hourly': + if (now()->minute == 0) { + \Artisan::call('send:invoice-transit-report', [ + 'schedule_type' => $rule->schedule_type, + 'plant' => $rule->plant, + ]); + } + break; + case 'Daily': + if (now()->format('H:i') == '10:00') { + \Artisan::call('send:invoice-transit-report', [ + 'schedule_type' => $rule->schedule_type, + 'plant' => $rule->plant, + ]); + } + break; + } + } }