<?
session_start();
include"../plg/ses.php";
?>
<!DOCTYPE html>
<?
$idkar = $_GET['idkar'];
$smt = substr($idkar,0,8);
?>
<html>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../plg/w3.css">
<link rel="stylesheet" href="../plg/hijaucss.css">
<body>
<?include"../menu2.php";?>
<hr/>
<div class="w3-container">
  <h4>SEMESTER <?=$smt?></h4>
  <table class="w3-table w3-card-2" id="myTable" style="">
    <tr>
      <th style="width:300px" class="w3-small w3-border w3-blue-gray w3-center">NAMA</th>
      <th style="width:150px" class="w3-small w3-border w3-blue-gray w3-center">NIP</th>
      <th style="width:200px" class="w3-small w3-border w3-blue-gray w3-center">UNIT</th>
      <th style="width:400px" class="w3-small w3-border w3-blue-gray w3-center">JABATAN</th>
      <th style="width:200px" class="w3-small w3-border w3-blue-gray w3-center">LOKASI</th>
    </tr>
    <?
    include"../plg/kon.php";
    $sql = "select * from kpikar where idkar='$idkar'";
    $res = $conn->query($sql);
    while($b = $res->fetch_assoc()){

      $kuncicetak = $b['lok'];
      if($kuncicetak == 'Kantor Pusat'){
        $viscetak = "display:none";
        $viscetakpus = "display:";
      }
      if($kuncicetak !== 'Kantor Pusat'){
        $viscetak = "display:";
        $viscetakpus = "display:none";
      }

      $lokk = $b['lok'];
      $kunci = $b['kunci'];
      if($kunci == 'Selesai'){
        $kuncimati = "xxx";
        $kuncipesan = "alert('KPI SUDAH CLOSING !...')";
      }
    ?>
    <tr style="font-weight:bold" class="w3-light-gray">
      <td class="w3-small w3-border"><?=$b['nama']?></td>
      <td class="w3-small w3-border"><?=$b['nip']?></td>
      <td class="w3-small w3-border"><?=$b['unit']?></td>
      <td class="w3-small w3-border"><?=$b['jab']?></td>
      <td class="w3-small w3-border"><?=$lokk?></td>
    </tr>
    <?}?>
  </table>
<hr/>
  <table class="w3-table-all w3-hoverable">
    <thead>
      <tr class="w3-blue-gray w3-center">
        <th class="w3-small w3-center w3-border" rowspan="2">NO</th>
        <th class="w3-small w3-center w3-border" rowspan="2">KODE</th>
        <th class="w3-small w3-center w3-border" rowspan="2">KPI</th>
        <th class="w3-small w3-center w3-border" rowspan="2">POLA<br/>RISASI</th>
        <th class="w3-small w3-center w3-border" rowspan="2">KEY PERFORMANCE INDICATOR<br/>(SASARAN KINERJA)</th>
        <th class="w3-small w3-center w3-border" rowspan="2">SATUAN</th>
        <th class="w3-small w3-center w3-border" rowspan="2">VOLUME</th>
        <th class="w3-small w3-center w3-border" rowspan="2">KUALITAS</th>
        <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>
    <?
    include"../plg/kon.php";
    $sqlpo = "update kpiuser set pola='Positif' where idkar='$idkar' and pola like'%Positif%'";
    $respo = $conn->query($sqlpo);
    $sqlne = "update kpiuser set pola='Negatif' where idkar='$idkar' and pola like'%Negatif%'";
    $resne = $conn->query($sqlne);
    $i= 1;
    $sql = "select * from kpiuser where idkar='$idkar' and del='0' order by kpi asc";
    $res = $conn->query($sql);
    while($a = $res->fetch_assoc()){
      $idx = $a['id'];
      $uang = $a['foktan'];
      $pkvoll = number_format($a['pkvol']);
      $hpkuanx = $a['hpkuan'];
      $kodexx = $a['kode'];
      $nol = $a['nol'];
      if($uang == '1'){
        $warna = "w3-light-blue";$ket = $a['fok'];
      }elseif($uang == "2"){
        $warna = "w3-cyan";$ket = $a['fok'];
      }elseif($uang == "3"){
        $warna = "w3-aqua";$ket = $a['fok'];
      }elseif($uang == "4"){
        $warna = "w3-teal";$ket = $a['fok'];
      }elseif($uang == "5"){
        $warna = "w3-green";$ket = $a['fok'];
      }elseif($uang == "6"){
        $warna = "w3-light-green";$ket = $a['fok'];
      }elseif($uang == "7"){
        $warna = "w3-amber";$ket = $a['fok'];
      }
      if($hpkuanx !== '0'){
        $ro = "readonly";
        $psn = "alert('USER SUDAH INPUT VOLUME PENCAPAIAN')";
        $wd = "w3-pale-yellow";
        $wd2 = "w3-pale-blue";
      }else{
        $ro = "";
        $psn = "";
        $wd = "";
        $wd2 = "";
      }
      ?>
      <tr onclick="<?=$kuncipesan?>;editkan<?=$kuncimati?>('<?=$idx?>','<?=$a['vol']?>','<?=$nol?>');" class="<?=$warna?>"
        title="<?=strtoupper($ket)?>" style="cursor:pointer">
        <td class="w3-small w3-center w3-border"><?=$i++?></td>
        <td class="w3-small w3-border"><?=$a['kode']?></td>
        <td class="w3-small w3-border"><?=$a['kpi']?></td>
        <td class="w3-small w3-center w3-border"><?=$a['pola']?></td>
        <td class="w3-small w3-border"><?=$a['des']?></td>
        <td class="w3-small w3-center w3-border"><?=$a['sat']?></td>
        <td class="w3-small w3-center w3-border"><?=number_format($a['vol'],2)?></td>
        <td class="w3-small w3-center w3-border"><?=$a['kua']?> %</td>
        <td class="w3-small w3-center w3-border <?=$wd?>"><?=$a['pkvol']?></td>
        <td class="w3-small w3-center w3-border <?=$wd?>"><?=$a['pkkua']?></td>
        <td class="w3-small w3-center w3-border <?=$wd?>"><?=$a['pkcat']?></td>
        <td class="w3-small w3-center w3-border <?=$wd2?>"><?=$a['hpkuan']?> %</td>
        <td class="w3-small w3-center w3-border <?=$wd2?>"><?=$a['hpkua']?> %</td>
      </tr>
      <?
    }
    include"rumus.php";
    ?>

    <tr>
      <td class="w3-small w3-center w3-border" colspan="10"></td>

      <td class="w3-small w3-center w3-border" colspan="1"><b>TOTAL</b></td>
      <td class="w3-small w3-center w3-border" colspan="1"><b><?=$hasilkuantab?> %</b></td>
      <td class="w3-small w3-center w3-border" colspan="1"><b><?=$hasilkuatab?> %</b></td>
    </tr>
    <tr>
      <td class="w3-small w3-center w3-border" colspan="10"></td>
      <td class="w3-small w3-center w3-border" colspan="1"><b>KATEGORI</b></td>
      <td class="w3-small w3-center w3-border" colspan="1"><b><?=$kategori?></b></td>
      <td class="w3-small w3-center w3-border" colspan="1"><b><?=$hasilnya?></b></td>
    </tr>
  </table>
  <br/>
  <center>
    <div class="w3-btn w3-black w3-small w3-card-2" style="<?=$viscetakpus?>" onclick="cetakpusat('<?=$idkar?>')">Export To Pdf(P)</div>
    <div class="w3-btn w3-black w3-small w3-card-2" style="<?=$viscetak?>">Export To Pdf(C)</div>
  </center>
  <?
  $sqlakhir = "update kpikar set hasilkuan='$kategori', hasilkua='$hasilnya' where idkar='$idkar'";
  $resakhir = $conn->query($sqlakhir);
  ?>

  <br/><br/><hr/>
</div>
<div id="id01" class="w3-modal">
  <div class="w3-modal-content" style="width:95%;">
    <div class="w3-container" style="">
        <span onclick="batal()"
        class="w3-button w3-display-topright w3-red">&times;</b></span>
        <br/><hr/>
        <iframe style="border:1px solid white;width:100%;height:680px;" id="rangka"></iframe>
    </div>
  </div>
</body>
<script>
function editkan(a,b,c){
  if(b=='0' && c=='0'){
    alert("KOLOM KPI TIDAK BISA DI ENTRY, KARENA VOLUME MASIH KOSONG !...");
  }else{
    document.getElementById('id01').style.display='block';
    document.getElementById('rangka').src="perkpiuser.php?kode="+a;
  }
}

function batal(){
  document.getElementById('id01').style.display='none';
}

function isiulang(){
  location.reload();
}

function reset(a,b){
  var r = confirm("ITEM DENGAN KODE "+a+"\nAPAKAH AKAN DI RESET ?...\nSEMUA VOLUME AKAN MENJADI NOL KEMBALI \n"+
  "SEGERA HUBUNGI ATASAN ANDA ATAU ADMIN SIMKP\nAGAR NILAI VOLUME DIISI KEMBALI !.");
  if(r == true){
    location.href="resetvol.php?id="+b;
  }
}
function cetakcabang(x){
  window.open("cetakkpiuser.php?idkar="+x,"_blank");
}
function cetakpusat(x){
  window.open("cetakpusat.php?idkar="+x,"_blank");
}
</script>
</html>
