diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index 6b7b88d..d0f9736 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -241,7 +241,7 @@ class SendProductionReport extends Command } if ($totalTargetQuantity > 0) { - $efficiency = ($totalTargetQuantity / $productionQuantity) * 100; + $efficiency = ($productionQuantity / $totalTargetQuantity) * 100; } else { $efficiency = 0; } diff --git a/resources/views/mail/production_report.blade.php b/resources/views/mail/production_report.blade.php index 9bb759a..2ed2fdf 100644 --- a/resources/views/mail/production_report.blade.php +++ b/resources/views/mail/production_report.blade.php @@ -70,6 +70,12 @@ @foreach($tableData as $row) + @php $efficiency = (float) $row['efficiency']; if ($efficiency < 80) { $bgColor = '#ff4d4d'; + } + elseif ($efficiency < 99) { $bgColor = '#ffd633'; + } + else { $bgColor = '#4caf50'; + } @endphp {{ $row['no'] }} {{ $row['plant'] }} @@ -78,7 +84,17 @@ {{-- {{ $row['capacityQuantity'] }} --}} {{ $row['targetQuantity'] }} {{ $row['productionQuantity'] }} - {{ $row['efficiency'] }} + {{-- {{ $row['efficiency'] }} --}} + + {{ $row['efficiency'] }} + @endforeach