From 171c675014aec94917ab5874c21e6c4d83493e7c Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 7 Jul 2025 18:19:17 +0530 Subject: [PATCH] issue solved in production report --- app/Console/Commands/SendProductionReport.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index 8e67cd854..8dfb575f9 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -59,12 +59,12 @@ class SendProductionReport extends Command $plants = ProductionQuantity::select('plant_id')->distinct()->pluck('plant_id'); // 4. Get production quantities for FG and non-FG lines in one go - // $fgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity')) - // ->whereBetween('created_at', [$startDate, $endDate]) - // ->whereIn('line_id', $fgLineIds) - // ->groupBy('line_id') - // ->pluck('total_quantity', 'line_id') - // ->toArray(); + $fgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity')) + ->whereBetween('created_at', [$startDate, $endDate]) + ->whereIn('line_id', $fgLineIds) + ->groupBy('line_id') + ->pluck('total_quantity', 'line_id') + ->toArray(); $nonFgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity')) ->whereBetween('created_at', [$startDate, $endDate]) @@ -94,16 +94,17 @@ class SendProductionReport extends Command ->where('line_id', $lineId) ->whereBetween('created_at', [$startDate, $endDate]) ->sum('plan_quantity'); + $productionQuantity = 0; // Use the correct production quantity array based on line type if (in_array($lineId, $nonFgLineIds)) { $productionQuantity = $nonFgProduction[$lineId] ?? 0; } - // else - // { - // $productionQuantity = $nonFgProduction[$lineId] ?? 0; - // } + else + { + $fgproductionQuan = $fgProduction[$lineId] ?? 0; + } $tableData[] = [ 'no' => $no++, 'plant' => $plantName, @@ -118,7 +119,7 @@ class SendProductionReport extends Command if (!empty($emails)) { // Mail::to($emails)->send(new test($tableData)); - // $this->info('Invoice report email sent successfully to: ' . implode(', ', $emails)); + $this->info('production report email sent successfully to: ' . implode(', ', $emails)); foreach ($emails as $email) { Mail::to($email)->send(new ProductionMail($tableData));