diff --git a/src/resources/views/layout/threshold.blade.php b/src/resources/views/layout/threshold.blade.php index 00b8697c..b1cd254d 100644 --- a/src/resources/views/layout/threshold.blade.php +++ b/src/resources/views/layout/threshold.blade.php @@ -100,41 +100,53 @@ $runningAvg[$index] = round($sum / ($index + 1), 2); } - $cumulativeAvg = []; - foreach ($hours as $i => $v) { - $sum += $v; - $cumulativeAvg[] = $sum / ($i + 1); // cumulative average - } - $allHours = true; foreach($hours as $h) { - if($h == null || $h<=15) + if($h == null || $h<=0) { $allHours = false; - $thresholdvalue = 0; break; } } - - - if($allHours) + if(!$allHours) { - $rainfallsum = array_sum($hours); - $thresholdvalue = $rainfallsum / 6; - } - - if($thresholdvalue == 0) - { - $status = 'Normal'; - + $status = '-'; + $statusStyle = ''; } else { - $status = __('messages.warning'); + $rainfallsum = array_sum($hours); + $thresholdvalue = $rainfallsum / 6; + + if($thresholdvalue >= 1 && $thresholdvalue <= 10) + { + $status = 'Light'; + $statusStyle = 'background-color:#28a745;color:white;'; + } + elseif($thresholdvalue >= 11 && $thresholdvalue <= 30) + { + $status = 'Moderate'; + $statusStyle = 'background-color:#ffc107;color:white;'; + } + elseif($thresholdvalue >= 31 && $thresholdvalue <= 60) + { + $status = 'Heavy'; + $statusStyle = 'background-color:#fd7e14;color:white;'; + } + elseif($thresholdvalue > 60) + { + $status = 'Very Heavy'; + $statusStyle = 'background-color:#dc3545;color:white;'; + } + else + { + $status = 'Normal'; + $statusStyle = ''; + } } @endphp @@ -142,7 +154,7 @@ {{$row->name}} {{$row->district}} {{$row ->last_update}} - {{$status}} + {{$status}} {{$row ->hour6_value}} {{$row ->hour5_value}} {{$row ->hour4_value}} @@ -163,28 +175,9 @@ - @endforeach - - Example - - - - - - - 15 - 30 - 20 - 25 - 26 - 27 - 15 - 22.5 - 21.7 - 22.5 - 23.2 - 23.8 - - +@endforeach - +