changed logici n production mail report

This commit is contained in:
dhanabalan
2025-07-10 15:08:32 +05:30
parent 3c9cc702d4
commit 4311c64531
4 changed files with 164 additions and 244 deletions

View File

@@ -12,130 +12,29 @@ Artisan::command('inspire', function () {
// Schedule::command('send:invoice-report');
// Schedule::command('send:production-report');
// $rules = [
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'InvoiceMail',
// 'argument' => 'InvoiceMail',
// ],
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'SerialInvoiceMail',
// 'argument' => 'SerialInvoiceMail',
// ],
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'MaterialInvoiceMail',
// 'argument' => 'MaterialInvoiceMail',
// ],
// ];
// foreach ($rules as $rule) {
// $scheduleType = AlertMailRule::where('module', $rule['module'])
// ->where('rule_name', $rule['rule_name'])
// ->value('schedule_type');
// switch ($scheduleType) {
// case 'Live':
// Schedule::command("send:invoice-report {$rule['argument']}")->everyMinute();
// break;
// case 'Hourly':
// Schedule::command("send:invoice-report {$rule['argument']}")->hourly();
// break;
// case 'Daily':
// Schedule::command("send:invoice-report {$rule['argument']}")->dailyAt('07:59');
// break;
// default:
// Schedule::command("send:invoice-report {$rule['argument']}")->hourly();
// break;
// }
// }
// // Production Report Scheduling
// $productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->value('schedule_type');
// // $this->info($productionScheduleType);
// // \Log::info('Production Schedule Type: ' . $productionScheduleType);
// switch ($productionScheduleType) {
// case 'Live':
// Schedule::command('send:production-report')->everyMinute();
// break;
// case 'Hourly':
// Schedule::command('send:production-report')->hourly();
// break;
// case 'Daily':
// Schedule::command('send:production-report')->dailyAt('07:59');
// break;
// default:
// Schedule::command('send:production-report')->hourly();
// break;
// }
// app()->booted(function () {
// $schedule = app(Schedule::class);
// // Dynamic rules for invoice reports
// $rules = [
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'InvoiceMail',
// 'argument' => 'InvoiceMail',
// ],
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'SerialInvoiceMail',
// 'argument' => 'SerialInvoiceMail',
// ],
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'MaterialInvoiceMail',
// 'argument' => 'MaterialInvoiceMail',
// ],
// ];
// $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->get();
// foreach ($rules as $rule) {
// $scheduleType = AlertMailRule::where('module', $rule['module'])
// ->where('rule_name', $rule['rule_name'])
// ->value('schedule_type');
// $types = $productionRules->pluck('schedule_type')->unique();
// switch ($scheduleType) {
// foreach ($types as $type) {
// $command = $schedule->command("send:production-report", [$type]);
// switch ($type) {
// case 'Live':
// $schedule->command("send:invoice-report {$rule['argument']}")->everyMinute();
// $command->everyMinute();
// break;
// case 'Hourly':
// $schedule->command("send:invoice-report {$rule['argument']}")->hourly();
// $command->hourly();
// break;
// case 'Daily':
// $schedule->command("send:invoice-report {$rule['argument']}")->dailyAt('07:59');
// break;
// default:
// $schedule->command("send:invoice-report {$rule['argument']}")->hourly();
// $command->dailyAt('07:59');
// break;
// }
// }
// // Production Report Scheduling
// $productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->value('schedule_type');
// switch ($productionScheduleType) {
// case 'Live':
// $schedule->command('send:production-report')->everyMinute();
// break;
// case 'Hourly':
// $schedule->command('send:production-report')->hourly();
// break;
// case 'Daily':
// $schedule->command('send:production-report')->dailyAt('07:59');
// break;
// default:
// $schedule->command('send:production-report')->hourly();
// break;
// }
// });
app()->booted(function () {
@@ -145,10 +44,13 @@ app()->booted(function () {
->where('rule_name', 'ProductionMail')
->get();
$types = $productionRules->pluck('schedule_type')->unique();
// Loop each mail rule individually (plant + schedule_type)
foreach ($productionRules as $rule) {
$type = $rule->schedule_type;
$plantId = $rule->plant;
$command = $schedule->command('send:production-report', [$type, $plantId]);
foreach ($types as $type) {
$command = $schedule->command("send:production-report", [$type]);
switch ($type) {
case 'Live':
$command->everyMinute();
@@ -163,3 +65,4 @@ app()->booted(function () {
}
});