issue solved in production report
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user