<?
session_start();
include"../plg/ses.php";
$kode = $_GET['kode'];
include"../plg/kon.php";



?>
<link rel="stylesheet" href="../plg/w3.css">
<table class="w3-table-all w3-hoverable">
  <thead>
    <tr class="w3-light-grey">
      <th class="w3-small w3-center w3-border" rowspan="">KODE (N)</th>
      <th class="w3-small w3-center w3-border" rowspan="">KPI</th>
      <th class="w3-small w3-center w3-border" rowspan="">POLARISASI</th>
      <th class="w3-small w3-center w3-border" rowspan="">KEY PERFORMANCE INDICATOR<br/>(ASARAN KINERJA)</th>
      <th class="w3-small w3-center w3-border" rowspan="">SATUAN</th>
      <th class="w3-small w3-center w3-border" rowspan="">VOLUME</th>
      <th class="w3-small w3-center w3-border" rowspan="">KUALITAS</th>
    </tr>
  </thead>
    <?
    $sql = "select * from kpiuser where id='$kode'";
    $res = $conn->query($sql);
    while($a = $res->fetch_assoc()){
      $kode2 = $a['kode'];
      $pkvol= $a['pkvol'];
      $pkkua = $a['pkkua'];
      $pkcat = $a['pkcat'];
      $hpkuan = $a['hpkuan'];
      $hpkua = $a['hpkua'];
      $vol = $a['vol'];
      $id = $a['id'];
      $kua = $a['kua'];
      $pola = $a['pola'];
      $nol = $a['nol'];
    ?>
    <tr>
      <td class="w3-small w3-border"><b><?=$a['kode']?></b></td>
      <td class="w3-small w3-center w3-border"><b><?=$a['kpi']?></b></td>
      <td class="w3-small w3-center w3-border"><b><?=$a['pola']?></td>
      <td class="w3-small w3-border w3-border"><b><?=$a['des']?></td>
      <td class="w3-small w3-center w3-border"><b><?=$a['sat']?></td>
      <td class="w3-small w3-center w3-border"><b><?=$vol?></td>
      <td class="w3-small w3-center w3-border"><b><?=$a['kua']?> %</b></td>
    </tr>
    <?}?>
</table>
<br/>
<form action="editkpiuser.php" method="post" id="form">
  <input type="hidden" name="id" value="<?=$id?>"/>
  <input type="hidden" name="vol" value="<?=$vol?>" id="vol"/>
  <input type="hidden" name="kua" value="<?=$kua?>" />
  <input type="hidden" name="pola" value="<?=$pola?>"/>
  <input type="hidden" name="kode" value="<?=$kode2?>"/>
  <input type="hidden" name="nol" value="<?=$nol?>"/>
<table class="w3-table-all w3-hoverable" style="width:100%;">
  <thead>
    <tr class="w3-light-grey">
      <th class="w3-small w3-center w3-border w3-pale-yellow" colspan="3">PENCAPAIAN KINERJA</th>
      <th class="w3-small w3-center w3-border w3-pale-blue" colspan="2">HASIL PENILAIAN</th>
    </tr>
    <tr>
      <th class="w3-small w3-center w3-border w3-pale-yellow" colspan="">VOLUME</th>
      <th class="w3-small w3-center w3-border w3-pale-yellow" colspan="">KUALITAS %</th>
      <th class="w3-small w3-center w3-border w3-pale-yellow" colspan="">CATATAN</th>
      <th class="w3-small w3-center w3-border w3-pale-blue" colspan="">KUANTITAS</th>
      <th class="w3-small w3-center w3-border w3-pale-blue" colspan="">KUALITAS</th>
    </tr>
  </thead>
  <tr>
    <td class="w3-small w3-border w3-pale-yellow" style="width:150px;">
      <input type="number" id="pkvol" name="pkvol" class="w3-border w3-small w3-input" value="<?=$pkvol?>"/>
    </td>
    <td class="w3-small w3-border w3-pale-yellow" style="width:100px">
      <input type="number" id="pkkua" name="pkkua" class="w3-border w3-small w3-input" value="<?=$pkkua?>"
    </td>
    <td class="w3-small w3-border w3-pale-yellow" style="width:700px;">
      <input type="text" id="" name="pkcat" class="w3-border w3-small w3-input" onclick="" value="<?=$pkcat?>"/>
    </td>
    <td class="w3-large w3- w3-pale-blue w3-center" style="width:100px">
      <input type="hidden" name="hpkuan" value="<?=$hpkuan?>"/><?=$hpkuan?> %
    </td>
    <td class="w3-large w3-border w3-pale-blue w3-center" style="width:150px;">
      <input type="hidden" name="hpkua" value="<?=$hpkua?>"/><?=$hpkua?> %
    </td>
  </tr>
</table>
</form>
<br/>
<center>
<div class="w3-btn w3-blue w3-small w3-round-large" onclick="edit('<?=$kode?>')">UPDATE</div>
&nbsp;&nbsp;
<div class="w3-btn w3-red w3-small w3-round-large" onclick="parent.batal()">CANCEL</div>
&nbsp;&nbsp;
<div class="w3-btn w3-green w3-small w3-round-large" onclick="formupload('<?=$kode?>')">UPLOAD</div>
&nbsp;&nbsp;
<div class="w3-btn w3-black w3-small w3-round-large" onclick="parent.reset('<?=$kode2?>','<?=$id?>')">RESET</div>
<hr/>
<iframe style="border:none;width:100%;height:300px" src="listdockpi.php?id=<?=$kode?>" id="frmupl"></iframe>
</center>
<br/>

<script>
function edit(a){
  pkvol = document.getElementById('pkvol').value;
  pkkua = document.getElementById('pkkua').value;
  var r = confirm("APAKAH KPI "+a+" AKAN DI UPDATE ?...");
  if((pkvol == '') || (pkkua == '')){
    alert("KOLOM VOLUME DAN KUALITAS TIDAK BOLEH KOSONG !...");
    document.getElementById('pkvol').value="0";
    document.getElementById('pkkua').value="0";
  }else{
    if(r == true){
      document.getElementById('form').submit();
    }
  }
}
function formupload(x){
  document.getElementById('frmupl').src="formupload.php?id="+x;
}
</script>
