Merge pull request 'Uncommented the mail schedule logic' (#27) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s

Reviewed-on: #27
This commit was merged in pull request #27.
This commit is contained in:
2025-11-29 12:33:52 +00:00

View File

@@ -1,10 +1,7 @@
<?php
use App\Models\AlertMailRule;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
@@ -13,88 +10,88 @@ Artisan::command('inspire', function () {
// Schedule::command('send:invoice-report');
// Schedule::command('send:production-report');
// app()->booted(function () {
// $schedule = app(Schedule::class);
app()->booted(function () {
$schedule = app(Schedule::class);
// // $schedule->command('report:send-daily-production')->dailyAt('07:59');
// $schedule->command('report:send-daily-production')->dailyAt('07:59');
// if (Schema::hasTable('alert_mail_rules')) {
if (Schema::hasTable('alert_mail_rules')) {
// // Production report scheduling
// $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->select('plant', 'schedule_type')
// ->distinct()
// ->get();
// Production report scheduling
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->select('plant', 'schedule_type')
->distinct()
->get();
// foreach ($productionRules as $rule) {
// $type = $rule->schedule_type;
// $plantId = $rule->plant;
foreach ($productionRules as $rule) {
$type = $rule->schedule_type;
$plantId = $rule->plant;
// $command = $schedule->command('send:production-report', [$type, $plantId]);
// // ->appendOutputTo(storage_path('logs/scheduler.log'));
$command = $schedule->command('send:production-report', [$type, $plantId]);
// ->appendOutputTo(storage_path('logs/scheduler.log'));
// switch ($type) {
// case 'Live':
// $command->everyMinute();
// break;
// case 'Hourly':
// $command->hourly();
// break;
// case 'Daily':
// $command->dailyAt('07:59');
// break;
// }
// }
switch ($type) {
case 'Live':
$command->everyMinute();
break;
case 'Hourly':
$command->hourly();
break;
case 'Daily':
$command->dailyAt('07:59');
break;
}
}
// // Invoice report scheduling
// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
// ->select('plant', 'schedule_type')
// ->distinct()
// ->get();
// Invoice report scheduling
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
->select('plant', 'schedule_type')
->distinct()
->get();
// foreach ($invoiceRules as $rule) {
// $type = $rule->schedule_type;
// $plantId = $rule->plant;
foreach ($invoiceRules as $rule) {
$type = $rule->schedule_type;
$plantId = $rule->plant;
// $command = $schedule->command('send:invoice-report', [$type, $plantId]);
$command = $schedule->command('send:invoice-report', [$type, $plantId]);
// switch ($type) {
// case 'Live':
// $command->everyMinute();
// break;
// case 'Hourly':
// $command->hourly();
// break;
// case 'Daily':
// $command->dailyAt('07:59');
// break;
// }
// }
switch ($type) {
case 'Live':
$command->everyMinute();
break;
case 'Hourly':
$command->hourly();
break;
case 'Daily':
$command->dailyAt('07:59');
break;
}
}
// // Invoice Data Report Scheduling
// $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
// ->select('plant', 'schedule_type')
// ->distinct()
// ->get();
// Invoice Data Report Scheduling
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
->select('plant', 'schedule_type')
->distinct()
->get();
// foreach ($invoiceDataRules as $rule) {
// $type = $rule->schedule_type;
// $plantId = $rule->plant;
foreach ($invoiceDataRules as $rule) {
$type = $rule->schedule_type;
$plantId = $rule->plant;
// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
$command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
// switch ($type) {
// case 'Live':
// $command->everyMinute();
// break;
// case 'Hourly':
// $command->hourly();
// break;
// case 'Daily':
// $command->dailyAt('10:00');
// break;
// }
// }
// }
// });
switch ($type) {
case 'Live':
$command->everyMinute();
break;
case 'Hourly':
$command->hourly();
break;
case 'Daily':
$command->dailyAt('10:00');
break;
}
}
}
});