changed logic for sending mails for only have schedule types in production report
This commit is contained in:
@@ -17,7 +17,8 @@ class SendProductionReport extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'send:production-report';
|
//protected $signature = 'send:production-report';
|
||||||
|
protected $signature = 'send:production-report {schedule_type}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@@ -32,8 +33,11 @@ class SendProductionReport extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$scheduleType = $this->argument('schedule_type');
|
||||||
|
|
||||||
$mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
$mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
->where('rule_name', 'ProductionMail')
|
->where('rule_name', 'ProductionMail')
|
||||||
|
->where('schedule_type', $scheduleType)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$emails = $mailRules->pluck('email')->unique()->toArray();
|
$emails = $mailRules->pluck('email')->unique()->toArray();
|
||||||
|
|||||||
@@ -141,31 +141,25 @@ Artisan::command('inspire', function () {
|
|||||||
app()->booted(function () {
|
app()->booted(function () {
|
||||||
$schedule = app(Schedule::class);
|
$schedule = app(Schedule::class);
|
||||||
|
|
||||||
// Get all production rules with logging
|
|
||||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
->where('rule_name', 'ProductionMail')
|
->where('rule_name', 'ProductionMail')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
foreach ($productionRules as $rule) {
|
$types = $productionRules->pluck('schedule_type')->unique();
|
||||||
$command = $schedule->command("send:production-report");
|
|
||||||
|
|
||||||
switch ($rule->schedule_type) {
|
foreach ($types as $type) {
|
||||||
|
$command = $schedule->command("send:production-report", [$type]);
|
||||||
|
switch ($type) {
|
||||||
case 'Live':
|
case 'Live':
|
||||||
$command->everyMinute();
|
$command->everyMinute();
|
||||||
// Log::info("Scheduled Live production report for");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Hourly':
|
case 'Hourly':
|
||||||
$command->hourly();
|
$command->hourly();
|
||||||
//Log::info("Scheduled Hourly production report for {$rule->email}");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Daily':
|
case 'Daily':
|
||||||
$command->dailyAt('07:59');
|
$command->dailyAt('07:59');
|
||||||
// Log::info("Scheduled Daily production report for {$rule->email}");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user