<?
$sqltotkuan = "select sum(hpkuan) as totalkuan from kpiuser where idkar='$idkar' and del='0'";
$restotkuan = $conn->query($sqltotkuan);
while($tk = $restotkuan->fetch_assoc()){
  $totalkuan = $tk['totalkuan'];
}
$sqltotkuan2 = "select count(id) as totalkuanbar from kpiuser where idkar='$idkar' and del='0'";
$restotkuan2 = $conn->query($sqltotkuan2);
while($tk2 = $restotkuan2->fetch_assoc()){
$totalkuan2 = $tk2['totalkuanbar'];
}
$hasilkuan = $totalkuan/$totalkuan2;
$hasilkuantab = round($hasilkuan);
//------------------------
$sqltotkua = "select sum(hpkua) as totalkuan from kpiuser where idkar='$idkar' and del='0'";
$restotkua = $conn->query($sqltotkua);
while($tkk = $restotkua->fetch_assoc()){
  $totalkua = $tkk['totalkuan'];
}

$hasilkua = $totalkua/$totalkuan2;
$hasilkuatab = round($hasilkua);
//number_format($hasilkua);

$kategori = round(($hasilkuan+$hasilkua)/2);
if($kategori <= 90){
  $hasilnya =  "KURANG";
}elseif($kategori > 90 && $kategori < 99){
  $hasilnya = "CUKUP";
}elseif($kategori >99 && $kategori <= 120){
  $hasilnya = "BAIK";
}elseif($kategori > 120){
  $hasilnya = "LUAR BIASA";
}
$hasilnya;

?>
