This commit is contained in:
Duidev Software House
2025-12-05 19:38:39 +07:00
parent fdbe9c2522
commit e63353db3d
6 changed files with 231 additions and 156 deletions
@@ -32,6 +32,47 @@ use Session;
class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
private function cekBatasAtas($value, $rule) {
if (!$rule || !str_contains($rule, '>')) return false;
$angka = (int) filter_var($rule, FILTER_SANITIZE_NUMBER_INT);
return $value > $angka;
}
private function cekMidRange($value, $rule) {
if (!$rule) return false;
$rule = trim($rule);
if ($rule === '-' || $rule === '') return false;
if (!str_contains($rule, '-')) return false;
[$min, $max] = array_map('trim', explode('-', $rule));
if (!is_numeric($min) || !is_numeric($max)) return false;
return $value >= (int)$min && $value <= (int)$max;
}
private function cekBatasBawah($value, $rule) {
if (!$rule || !str_contains($rule, '<')) return false;
$angka = (int) filter_var($rule, FILTER_SANITIZE_NUMBER_INT);
return $value < $angka;
}
protected function cekInterpretasi($value, $data) {
if ($this->cekBatasAtas($value, $data->batasatas)) {
return "S";
}
if ($this->cekMidRange($value, $data->midrange)) {
return "I";
}
if ($this->cekBatasBawah($value, $data->batasbawah)) {
return "R";
}
return null;
}
protected function getStyledValue($value, $color, $strong = false) {
return $strong ? "<strong><font color=\"$color\">$value</font></strong>" : "<font color=\"$color\">$value</font>";
}