<?
session_start();
include"../plg/ses.php";
include"../plg/kon.php";
$id = $_GET['id'];
$sqle = "select * from masterkpi where id='$id'";
$rese = $conn->query($sqle);
while($k = $rese->fetch_assoc()){
  $kpi = $k['kpi'];
  $kode = $k['kode'];
  $pola = $k['pola'];
  $des = $k['des'];
  $sat = $k['sat'];
  $fok = $k['fok'];
  $area = $k['area'];
  $kodejab = $k['kodejab'];
  //$saverec = $k['saverec'];
}
if($saverec == '0'){
  $fung = "ceknip()";
  $btndis = "none";
}
if($saverec == '1'){
  $nipdis = "readonly";
}
?>
<link rel="stylesheet" href="../plg/w3.css">
<form action="savedatakpi.php" method="post" id="formdatakpi">
  <input type="hidden"name="id" value="<?=$id?>">
<table class="w3-table" id="" style="">
  <tr>
    <th style="width:150px" class="w3-small w3-border w3-blue-gray w3-center">KPI</th>
    <th style="width:150px" class="w3-small w3-border w3-blue-gray w3-center">KODE</th>
    <th style="width:150px" class="w3-small w3-border w3-blue-gray w3-center">POLARISASI</th>
    <th style="width:100px" class="w3-small w3-border w3-blue-gray w3-center">SATUAN</th>
    <th style="width:300px" class="w3-small w3-border w3-blue-gray w3-center">FOKUS</th>
    <th style="width:150px" class="w3-small w3-border w3-blue-gray w3-center">AREA</th>
    <th style="width:300px" class="w3-small w3-border w3-blue-gray w3-center">KODE JABATAN</th>
  </tr>
  <tr>
    <td class="w3-small w3-border">
      <input type="text" name="kpi" id="" class="w3-border w3-input" value="<?=$kpi?>" <?=$nipdis?>>
    </td>
    <td class="w3-small w3-border">
      <input type="text" name="kode" class="w3-border w3-input" value="<?=$kode?>" onclick="<?=$fung?>"/>
    </td>
    <td class="w3-small w3-border">
      <select class="w3-border w3-input" name="pola">
        <option><?=$pola?></option>
        <option>Positif</option>
        <option>Negatif</option>
      </select>
    </td>
    <td class="w3-small w3-border">
      <input type="text" name="sat" class="w3-border w3-input" value="<?=$sat?>" onclick="<?=$fung?>"/>
    </td>
    <td class="w3-small w3-border">
      <select class="w3-border w3-input" name="fok">
        <option><?=$fok?></option>
      <?
      $sqld = "select distinct(fok)as fokus from masterkpi order by foktan";
      $resd = $conn->query($sqld);
      while($d = $resd->fetch_assoc()){
        ?>
        <option><?=$d['fokus']?></option>
        <?
      }
      ?>
      </select>
    </td>
    <td class="w3-small w3-border">
      <select class="w3-border w3-input" name="area">
        <option><?=$area?></option>
        <option>Pusat</option>
        <option>Cabang</option>
      </select>
    </td>
    <td class="w3-small w3-border">
      <input type="text" name="kodejab" id="" class="w3-border w3-input" value="<?=$kodejab?>" <?=$nipdis?>/>
    </td>
  </tr>
</table>
<br/>
<table class="w3-table" id="" style="">
  <tr>
    <th style="width:150px" class="w3-small w3-border w3-blue-gray w3-center">DESCRIPTION KPI</th>
  </tr>
  <tr>
    <td class="w3-small w3-border">
      <input type="text" name="des" id="nip" class="w3-border w3-input" value="<?=$des?>" <?=$nipdis?>>
    </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="batalkpi()">CANCEL</div>
</center>
<iframe style="display:none" id="rangka2"></iframe>
<script>
function loncatisi(a,y,d){
  document.getElementById(y).value=a;
  dropFunction(d);
}
function editkpi(){
  var r = confirm('UPDATE DATA KPI ?...');
  if(r == true){
    document.getElementById('formdatakpi').submit();
  }
}
function batalkpi(){
  parent.keluar();
  parent.kembalikan();
}
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>
