<?
session_start();
include"../plg/ses.php";
include"../plg/kon.php";
$id = $_GET['kode'];
$sqle = "select * from dbkpi where kode='$id'";
$rese = $conn->query($sqle);
while($k = $rese->fetch_assoc()){
  $kode = $k['kode'];
  $pola = $k['pola'];
  $des = $k['kpides'];
  $sat = $k['sat'];
  $vol = $k['vol'];
  $kua = $k['kua'];
  $sv = $k['saverec'];
}

if($sv == '1'){
  $ketkode = "readonly";
}

?>
<link rel="stylesheet" href="../plg/w3.css">
<form action="savedatakpi.php" method="post" id="formdatkpi">
<table class="w3-table" id="">
  <tr>
    <th style="width:200px" class="w3-small w3-border w3-blue-gray w3-center">KODE</th>
    <th style="width:400px" class="w3-small w3-border w3-blue-gray w3-center">POLARISASI</th>
    <th style="width:200px" class="w3-small w3-border w3-blue-gray w3-center">DESCRIPTION</th>
    <th style="width:200px" class="w3-small w3-border w3-blue-gray w3-center">SATUAN</th>
    <th style="width:200px" class="w3-small w3-border w3-blue-gray w3-center">VOLUME</th>
    <th style="width:200px" class="w3-small w3-border w3-blue-gray w3-center">KUALITAS</th>
  </tr>
  <tr>
    <td class="w3-small w3-border">
      <input class="w3-input w3-border w3-padding" type="text" id="kode" name="kode" value="<?=$kode?>" style="width:180px;" <?=$ketkode?>>
    </td>
    <td class="w3-small w3-border">
      <input class="w3-input w3-border w3-padding" type="text" id="pola" name="pola" value="<?=$pola?>" style="width:150px;">
    </td>
    <td class="w3-small w3-border">
      <textarea class="w3-input w3-border w3-padding" rows="4" style="width:400px" name="des"><?=$des?></textarea>
    </td>
    <td class="w3-small w3-border">
      <input class="w3-input w3-border w3-padding" type="text" id="sat" name="sat" value="<?=$sat?>" style="width:100px;">
    </td>
    <td class="w3-small w3-border">
      <input class="w3-input w3-border w3-padding" type="number" id="vol" name="vol" value="<?=$vol?>" style="width:100px;">
    </td>
    <td class="w3-small w3-border">
      <input class="w3-input w3-border w3-padding" type="number" id="kua" name="kua" value="<?=$kua?>" style="width:100px;">
    </td>
  </tr>
</table>
</form>
<hr/>
<center>
<div class="w3-btn w3-blue w3-small w3-round-large" onclick="editkpi()" id="btnsave" style="display:<?=$btndis?>">SAVE</div>
&nbsp;
<div class="w3-btn w3-red w3-small w3-round-large" onclick="batalkar()">CANCEL</div>
</center>
<iframe style="display:none" id="rangka2"></iframe>

<script>

function editkpi(){
  kode = document.getElementById('kode').value;
  var r = confirm('UPDATE DATA KPI ?...');
  if(r == true){
    if(kode == ''){
      alert("KOLOM KODE TIDAK BOLEH KOSONG !...");
    }else{
      document.getElementById('formdatkpi').submit();
    }
  }
}

function batalkar(){
  parent.keluar();
}
function ceknip(){
  nip = document.getElementById('nip').value;
  document.getElementById('rangka2').src="ceknip.php?nip="+nip;
}
function ulang(){
  document.getElementById('nip').focus();
  document.getElementById('btnsave').style="display:none";
}
// Dropdown
function dropFunction(x) {
  var x = document.getElementById(x);
  if (x.className.indexOf("w3-show") == -1) {
    x.className += " w3-show";
  } else {
    x.className = x.className.replace(" w3-show", "");
  }
}

// Filter
function filterFunction(x,y) {
  var input, filter, ul, li, a, i;
  input = document.getElementById(y);
  filter = input.value.toUpperCase();
  div = document.getElementById(x);
  a = div.getElementsByTagName("a");
  for (i = 0; i < a.length; i++) {
    txtValue = a[i].textContent || a[i].innerText;
    if (txtValue.toUpperCase().indexOf(filter) > -1) {
      a[i].style.display = "";
    } else {
      a[i].style.display = "none";
    }
  }
}
</script>
