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');
|
$plants = ProductionQuantity::select('plant_id')->distinct()->pluck('plant_id');
|
||||||
|
|
||||||
// 4. Get production quantities for FG and non-FG lines in one go
|
// 4. Get production quantities for FG and non-FG lines in one go
|
||||||
// $fgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity'))
|
$fgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity'))
|
||||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
// ->whereIn('line_id', $fgLineIds)
|
->whereIn('line_id', $fgLineIds)
|
||||||
// ->groupBy('line_id')
|
->groupBy('line_id')
|
||||||
// ->pluck('total_quantity', 'line_id')
|
->pluck('total_quantity', 'line_id')
|
||||||
// ->toArray();
|
->toArray();
|
||||||
|
|
||||||
$nonFgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity'))
|
$nonFgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity'))
|
||||||
->whereBetween('created_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
@@ -94,16 +94,17 @@ class SendProductionReport extends Command
|
|||||||
->where('line_id', $lineId)
|
->where('line_id', $lineId)
|
||||||
->whereBetween('created_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->sum('plan_quantity');
|
->sum('plan_quantity');
|
||||||
|
$productionQuantity = 0;
|
||||||
|
|
||||||
// Use the correct production quantity array based on line type
|
// Use the correct production quantity array based on line type
|
||||||
if (in_array($lineId, $nonFgLineIds))
|
if (in_array($lineId, $nonFgLineIds))
|
||||||
{
|
{
|
||||||
$productionQuantity = $nonFgProduction[$lineId] ?? 0;
|
$productionQuantity = $nonFgProduction[$lineId] ?? 0;
|
||||||
}
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// $productionQuantity = $nonFgProduction[$lineId] ?? 0;
|
$fgproductionQuan = $fgProduction[$lineId] ?? 0;
|
||||||
// }
|
}
|
||||||
$tableData[] = [
|
$tableData[] = [
|
||||||
'no' => $no++,
|
'no' => $no++,
|
||||||
'plant' => $plantName,
|
'plant' => $plantName,
|
||||||
@@ -118,7 +119,7 @@ class SendProductionReport extends Command
|
|||||||
if (!empty($emails))
|
if (!empty($emails))
|
||||||
{
|
{
|
||||||
// Mail::to($emails)->send(new test($tableData));
|
// 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)
|
foreach ($emails as $email)
|
||||||
{
|
{
|
||||||
Mail::to($email)->send(new ProductionMail($tableData));
|
Mail::to($email)->send(new ProductionMail($tableData));
|
||||||
|
|||||||
Reference in New Issue
Block a user