From 9bb6e05589b95b6aa10149a52c471d4dd7697eb8 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 8 May 2026 14:43:06 +0530 Subject: [PATCH] Added import transit scheduling mail in scheduler page --- app/Console/Commands/Scheduler.php | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/app/Console/Commands/Scheduler.php b/app/Console/Commands/Scheduler.php index 8ae79a6..e32a451 100644 --- a/app/Console/Commands/Scheduler.php +++ b/app/Console/Commands/Scheduler.php @@ -40,6 +40,7 @@ class Scheduler extends Command { $this->call('approval:trigger-mails'); + // $this->call('sftp:process-files'); // --- Production Rules --- $productionRules = AlertMailRule::where('module', 'ProductionQuantities') @@ -234,6 +235,55 @@ class Scheduler extends Command break; } } + + $ImportTransitRules = AlertMailRule::where('module', 'ImportTransit') + ->where('rule_name', 'ImportTransitMail') + ->select('plant', 'schedule_type') + ->distinct() + ->get(); + + foreach ($ImportTransitRules as $rule) { + + switch ($rule->schedule_type) { + case 'Live': + // Run every minute + \Artisan::call('send-import-transit', [ + 'schedule_type' => $rule->schedule_type, + 'plant' => $rule->plant, + ]); + break; + case 'Hourly': + if (now()->minute == 0) { + \Artisan::call('send-import-transit', [ + 'schedule_type' => $rule->schedule_type, + 'plant' => $rule->plant, + ]); + } + break; + case 'Daily': + if (now()->format('H:i') == '11:10') { + try { + \Artisan::call('send-import-transit', [ + 'schedule_type' => $rule->schedule_type, + 'plant' => $rule->plant, + ]); + + Log::info('Invoice Transit executed', [ + 'plant' => $rule->plant, + 'type' => $rule->schedule_type, + ]); + } + catch (\Throwable $e) { + Log::error('Invoice Transit FAILED', [ + 'plant' => $rule->plant, + 'error' => $e->getMessage(), + 'trace' => $e->getTraceAsString(), + ]); + } + } + break; + } + } } /**