<?
session_start();
include"../plg/ses.php";
 $id = $_POST['id'];
 $vol = $_POST['vol'];
 $pkvol = $_POST['pkvol'];
 $pkkua = $_POST['pkkua'];
 $pkcat = $_POST['pkcat'];
 $kode = $_POST['kode'];
 //$hpkuan = $_POST['hpkuan'];
 //$hpkua = $_POST['hpkua'];
 $kua = $_POST['kua'];
 $polax = $_POST['pola'];
 $pola = substr($polax,0,2);
 $nol = $_POST['nol'];

 //$hasilkuan = "0";
 //$hasilkua = "0";

include"../plg/kon.php";

if($nol=='1'){
  if($pkvol == '0'){
    $hasilkuan = '100';
    $hasilkua = $pkkua;
  }
  if($pkvol == '1'){
    $hasilkuan = '95';
    $hasilkua = $pkkua;
  }
  if($pkvol == '2'){
    $hasilkuan = '90';
    $hasilkua = $pkkua;
  }
  if($pkvol == '3'){
    $hasilkuan = '85';
    $hasilkua = $pkkua;
  }
  if($pkvol == '4'){
    $hasilkuan = '80';
    $hasilkua = $pkkua;
  }
  if($pkvol == '5'){
    $hasilkuan = '75';
    $hasilkua = $pkkua;
  }
}


if($pola == 'Po' && $nol=='0'){
  $hasilkuan = $pkvol/$vol*100;
  if($hasilkuan > 120){
    $hasilkuan = "120";
  }
  $hasilkua = $pkkua/$kua*100;
  if($hasilkua > 120){
   $hasilkua = "120";
 }
}

if($pola == 'Ne' && $nol=='0'){
  $hasilkuan = $vol/$pkvol*100;
  if($hasilkuan > 120){
    $hasilkuan = "120";
  }
  $hasilkua = $pkkua/$kua*100;
  if($hasilkua > 120){
   $hasilkua = "120";
 }
}

/*
$hasilkuan = $pkvol/$vol*100;
if($hasilkuan > 120){
  $hasilkuan = "120";
}
$hasilkua = $pkkua/$kua*100;
if($hasilkua > 120){
 $hasilkua = "120";
}
*/

$sql = "update kpiuser set vol='$vol',pkvol='$pkvol', pkkua='$pkkua', pkcat='$pkcat', hpkuan='$hasilkuan', hpkua='$hasilkua' where id='$id'";
$res = $conn->query($sql);
 echo "<script>parent.isiulang()</script>";
//echo "test";
 //pkvol='$pkvol', pkkua='$pkkua', pkcat='$pkcat', hpkuan='$hpkuan', hpkua='$hpkua'
?>
