From 705d62d7ac69c1d51b04018260fb88b77e86b2dd Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 29 Sep 2026 10:36:39 +0530 Subject: [PATCH 1/2] Added day shift and night shift logic in production report --- app/Console/Commands/SendProductionReport.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index 7d29995..07aba92 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -249,6 +249,33 @@ class SendProductionReport extends Command $efficiency = 0; } + $dayShiftPlanQuan = ($totalTargetQuantity / 2); + + $nightShiftPlanQuan = ($totalTargetQuantity / 2); + + if (strtolower($line->type) == 'fg line') { + + $dayproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(8, 0, 0), + $endDate->copy()->setTime(19, 30, 0), + ]) + ->count(); + + $nightproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(19, 30, 0), + $endDate->copy()->addDay()->setTime(8, 0, 0), + ]) + ->count(); + } + + $dayShiftEfficiency = $dayShiftPlanQuan > 0 ? ($dayproductionQuantity / $dayShiftPlanQuan) * 100 : 0; + + $nightShiftEfficiency = $dayShiftPlanQuan > 0 ? ($nightproductionQuantity / $nightShiftPlanQuan) * 100 : 0; + $efficiency = round($efficiency, 2); $tableData[] = [ @@ -257,6 +284,12 @@ class SendProductionReport extends Command 'type' => $line->type, 'line' => $line->name, 'capacityQuantity' => floor($capacityQuan), + 'dayShiftPlanQuantity' => floor($dayShiftPlanQuan), + 'dayShiftActualQuantity' => floor($dayShiftPlanQuan), + 'dayShiftEfficiency' => floor($dayShiftEfficiency), + 'nightShiftPlanQuantity' => floor($nightShiftPlanQuan), + 'nightShiftActualQuantity' => floor($nightShiftPlanQuan), + 'nightShiftEfficiency' => floor($nightShiftEfficiency), 'targetQuantity' => floor($totalTargetQuantity), 'productionQuantity' => $productionQuantity, 'efficiency' => $efficiency . '%', -- 2.49.1 From 71358225ffe51b2397e029e68cf6bdde4ea5fdf3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 29 Sep 2026 10:37:56 +0530 Subject: [PATCH 2/2] Added day and night shift column in production report --- .../views/mail/production_report.blade.php | 128 ++++++++++++++++-- 1 file changed, 118 insertions(+), 10 deletions(-) diff --git a/resources/views/mail/production_report.blade.php b/resources/views/mail/production_report.blade.php index ea597b9..c05e8d7 100644 --- a/resources/views/mail/production_report.blade.php +++ b/resources/views/mail/production_report.blade.php @@ -55,15 +55,26 @@ --}} - + {{--
- - {{-- --}} - + --}} + {{-- --}} + {{-- @@ -72,7 +83,7 @@ @foreach($tableData as $row) @php $efficiency = (float) $row['efficiency']; if ($efficiency < 80) { $bgColor = '#ff4d4d'; } - elseif ($efficiency < 99) { $bgColor = '#ffd633'; + elseif ($efficiency < 95) { $bgColor = '#ffd633'; } else { $bgColor = '#4caf50'; } @endphp @@ -80,17 +91,26 @@ - + --}} {{-- --}} - - + {{-- --}} + {{-- + --}} {{-- --}} - @endforeach +
No Plant LineLine TypeCapacity QuantityPlan QuantityLine TypePlan Quantity +
+ Plan Quantity +
+ + + + + + +
Day ShiftPlan QuantityEfficiency
+
Actual Quantity Plan Vs Actual Efficiency(%)
{{ $row['no'] }} {{ $row['plant'] }} {{ $row['line'] }}{{ $row['type'] }}{{ $row['type'] }}{{ $row['capacityQuantity'] }}{{ $row['targetQuantity'] }}{{ $row['productionQuantity'] }}{{ $row['targetQuantity'] }} + + + + + + +
{{ $row['dayShift'] ?? '-' }}{{ $row['targetQuantity'] }}{{ $row['planEfficiency'] ?? '-' }}
+
{{ $row['productionQuantity'] }}{{ $row['efficiency'] }}= 99 ? '#ffffff' : '#000000' }}; + color: {{ $efficiency < 80 || $efficiency >= 95 ? '#ffffff' : '#000000' }}; font-weight: bold; "> {{ $row['efficiency'] }} @@ -98,6 +118,94 @@
--}} + + {{-- new logic --}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach($tableData as $row) + @php $efficiency = (float) $row['efficiency']; if ($efficiency < 80) { $bgColor = '#ff4d4d'; + } + elseif ($efficiency < 95) { $bgColor = '#ffd633'; + } + else { $bgColor = '#4caf50'; + } @endphp + + + + + + + + + + + + + + + + + + + + + + + + + @endforeach + +
NoPlantLineLine Type + Day Shift + + Night Shift + Plan QuantityActual QuantityPlan Vs Actual Efficiency(%)
Plan QuantityActual QuantityPlan Vs Actual Efficiency(%)Plan QuantityActual QuantityPlan Vs Actual Efficiency(%)
{{ $row['no'] }}{{ $row['plant'] }}{{ $row['line'] }}{{ $row['type'] }} + {{ $row['dayShiftPlanQuantity'] }} + + {{ $row['dayShiftActualQuantity'] }} + + {{ $row['dayShiftEfficiency'] }} + + {{ $row['nightShiftPlanQuantity'] }} + + {{ $row['nightShiftActualQuantity'] }} + + {{ $row['nightShiftEfficiency'] }} + + {{ $row['targetQuantity'] }} + + {{ $row['productionQuantity'] }} + + {{ $row['efficiency'] }} +

{!! $wishes !!}

-- 2.49.1