      
<?php
include '../../../config/koneksi.php';
session_start();
?>
<!DOCTYPE html>
<html>
   
   
    <head>
        <script src="ambildata.js"></script>
        <script src="efekscrol.js"></script>
        <title>Halaman OPD</title>

     
    </head>
    <body>
   
    <div class="content-wrapper">
   
            
        <div class ="wrapper">
        <div class="panel-body"  style ="overflow-x :auto ; overflow-y :auto ">
            
<button onclick="excelcetak()" class="fas fa-file-excel bg-green btn" style="border-radius: 14px; float: right;"> Excel</button>
       <?php

$sqlsopd  = mysqli_query($koneksi, "SELECT 
kode_sub_skpd,sub_skpd from sub_skpd
    ");
foreach ($sqlsopd as $rowsopd) {
    $kode_sub_skpd=$rowsopd['kode_sub_skpd'];

    ?>
<strong><?php echo $rowsopd['kode_sub_skpd'] . " " . $rowsopd['sub_skpd'] ?></strong>

<div hidden="hidden"><input type="text" id="sub_skpd"  value="<?php echo $rowsopd['sub_skpd'] ?>"></div>
<table width="100%"  id="example1s" class="table table-bordered table-striped">
    <tr style="text-align:center ; background-color:lightgrey">
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <th rowspan="3" style="text-align:center ;vertical-align: middle;"  >No</th>
        <th rowspan="3" style="text-align:center ;vertical-align: middle;"  >Sasaran</th>
       <th rowspan="3"  colspan="9" style="text-align:center ;vertical-align: middle;"   >Urusan/ SKPD/ Sub SKPD/ Bidang/ program/ Kegiatan/ Sub_Kegiatan </th>
       <th rowspan="3"  style="text-align:center ;vertical-align: middle;"  >Indikator Kinerja Program (Outcome) / Keluaran Kegiatan / Sub Kegiatan (Output)</th>
       <th rowspan="3"   colspan="3" style="text-align:center ;vertical-align: middle;"  >Target Renstra SKPD pada Tahun 2026 (Kondisi Akhir Periode Rencana)</th>
       <th rowspan="3"  colspan="3" style="text-align:center ;vertical-align: middle;"  >Realisasi Capaian Kinerja Renstra SKPD sampai dengan Renja SKPD Tahun <?php echo ($_SESSION['tahun'])-1 ?></th>
       <th rowspan="3"  colspan="3" style="text-align:center ;vertical-align: middle;"  >Target Kinerja dan Anggaran Renja SKPD Tahun Berjalan yang dievaluasi (<?php echo $_SESSION['tahun'] ?>)</th>
       <th rowspan="2"  colspan="8" style="text-align:center ;vertical-align: middle;"  >Realisasi Kinerja pada Triwulan <?php echo $_SESSION['tahun'] ?></th>
       <th rowspan="3" colspan="2" style="text-align:center ;vertical-align: middle;"  >Realisasi Capaian Kinerja dan Anggaran Renja SKPD yang Dievaluasi (<?php echo $_SESSION['tahun'] ?>)</th>
       <th rowspan="3" colspan="2" style="text-align:center ;vertical-align: middle;"  >Target Capaian Kinerja dan Realisasi Anggaran Renja SKPD tahun   <?php echo $_SESSION['tahun'] ?> (%)</th>
       
       <th rowspan="3" colspan="2" style="text-align:center ;vertical-align: middle;"  >Realisasi Kinerja dan Anggaran Renstra SKPD s/d Tahun 2026(Akhir Tahun Pelaksanaan Renja SKPD Tahun <?php echo $_SESSION['tahun'] ?> (%)</th>
       <th rowspan="3" colspan="2" style="text-align:center ;vertical-align: middle;"  >Tingkat Capaian Kinerja dan Realisasi Anggaran Renstra SKPD s/d Tahun   <?php echo $_SESSION['tahun'] ?> (%)</th>

       <th rowspan="3"style="text-align:center ;vertical-align: middle;"  >Sisa Anggaran <br> ( Rp )  </th>
       <th rowspan="3"style="text-align:center ;vertical-align: middle;"  >SKPD Penanggung Jawab</th>
       <th rowspan="3"style="text-align:center ;vertical-align: middle;"  >Sumber Dana</th>
    </tr>

       <tr></tr>

       <tr style="text-align:center ; background-color:lightgrey" >
       <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >I</th>
       <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >II</th>
       <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >III</th>
       <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >IV</th>


       </tr>
        <tr style="text-align:center ; background-color:lightgrey" >
            <th rowspan="2"  style="text-align:center ;vertical-align: middle;"  >1</th>
       <th rowspan="2"  style="text-align:center ;vertical-align: middle;"  >2</th>
       <th rowspan="2" colspan="9" style="text-align:center ;vertical-align: middle;"  >3</th>
       <th rowspan="2" style="text-align:center ;vertical-align: middle;"  >4</th>
       <th colspan="3" style="text-align:center ;vertical-align: middle;"  >5</th>
       <th colspan="3" style="text-align:center ;vertical-align: middle;"  >6</th>
       <th colspan="3" style="text-align:center ;vertical-align: middle;"  >7</th>
       <th colspan="2" style="text-align:center ;vertical-align: middle;"  >8</th>
       <th colspan="2" style="text-align:center ;vertical-align: middle;"  >9</th>
       <th colspan="2" style="text-align:center ;vertical-align: middle;"  >10</th>
       <th colspan="2" style="text-align:center ;vertical-align: middle;"  >11</th>
        <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >12=8+9+10+11</th>
        <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >13=12/7x100%</th>
        <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >14=6+12</th>
        <th colspan="2"  style="text-align:center ;vertical-align: middle;"  >15=14/5x100%</th>
        <th colspan="1"  style="text-align:center ;vertical-align: middle;"  >16=7-12</th>
        <th rowspan="2"  style="text-align:center ;vertical-align: middle;"  >17</th>
        <th rowspan="2"  style="text-align:center ;vertical-align: middle;"  >18</th>
      </tr>
      <tr style="text-align:center ; background-color:lightgrey" >
       <th colspan="2" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="2" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="2" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >K</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
       <th colspan="1" style="text-align:center ;vertical-align: middle;"  >Rp</th>
      </tr>
    


      
       <tbody>
<?php


$nourusan=1;
$sqlurusan  = mysqli_query($koneksi, "SELECT 
    distinct a.kode_urusan,a.urusan,
    ri.total,
    rl.treal,
    rl1.treal1,
    rl2.treal2,
    rl3.treal3,
    rl4.treal4,
    (ri.total-rl.treal) as sisar,


    k5.rpk5,k6.rpk6,
    ((rl.treal/ri.total)*100) as rp13,
    (k6.rpk6 + rl.treal) as rp14,
    (((k6.rpk6 + rl.treal)/(k5.rpk5))*100) as rp15,

    per.per1,
    ((rl.treal/ri.total) * 100) as per2,
    (((rl.treal/ri.total) * 100)+(per.per1)/2) as ratacapaian

    from (((((((((( urusan as a
    inner join bidang_urusan as b on a.kode_urusan=b.kode_urusan
    inner join program as c on b.kode_bidang_urusan=c.kode_bidang_urusan
    inner join kegiatan as d on c.kode_program=d.kode_program
    inner join sub_kegiatan as e on d.kode_kegiatan=e.kode_kegiatan
    inner join renja as f on e.kode_sub_kegiatan=f.kode_sub_kegiatan
    inner join sub_skpd as g on f.kode_sub_skpd=g.kode_sub_skpd
    inner join skpd as h on g.kode_skpd=h.kode_skpd )
    left join
    (select kode_urusan,kode_sub_skpd, sum(rincian) as total from renja group by kode_urusan,kode_sub_skpd ) as ri on ri.kode_urusan=a.kode_urusan and ri.kode_sub_skpd=g.kode_sub_skpd)
    left join
    (select kode_urusan,kode_sub_skpd, sum(realisasi) as treal from realisasi group by kode_urusan,kode_sub_skpd ) as rl on rl.kode_urusan=a.kode_urusan and rl.kode_sub_skpd=g.kode_sub_skpd)
    left join
    (select kode_urusan,kode_sub_skpd, sum(realisasi) as treal1 from realisasi where bulan between '$_SESSION[tahun]-01-01' and '$_SESSION[tahun]-03-31' group by kode_urusan,kode_sub_skpd ) as rl1 on rl1.kode_urusan=a.kode_urusan and rl1.kode_sub_skpd=g.kode_sub_skpd)
    left join
    (select kode_urusan,kode_sub_skpd, sum(realisasi) as treal2 from realisasi where bulan between '$_SESSION[tahun]-04-01' and '$_SESSION[tahun]-06-30' group by kode_urusan,kode_sub_skpd ) as rl2 on rl2.kode_urusan=a.kode_urusan and rl2.kode_sub_skpd=g.kode_sub_skpd)
     left join
    (select kode_urusan,kode_sub_skpd, sum(realisasi) as treal3 from realisasi where bulan between '$_SESSION[tahun]-07-01' and '$_SESSION[tahun]-09-31' group by kode_urusan,kode_sub_skpd ) as rl3 on rl3.kode_urusan=a.kode_urusan and rl3.kode_sub_skpd=g.kode_sub_skpd)
    left join
    (select kode_urusan,kode_sub_skpd, sum(realisasi) as treal4 from realisasi where bulan between '$_SESSION[tahun]-10-01' and '$_SESSION[tahun]-12-31' group by kode_urusan,kode_sub_skpd ) as rl4 on rl4.kode_urusan=a.kode_urusan and rl4.kode_sub_skpd=g.kode_sub_skpd)

 left join 
    (select f.kode_urusan,a.kode_sub_skpd, sum(distinct a.rp_target_sub_kegiatan_renstra) as rpk5 from evsub_kegiatan as a 
    inner join sub_kegiatan as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan
    inner join kegiatan as c on b.kode_kegiatan=c.kode_kegiatan
    inner join program as d on c.kode_program=d.kode_program
    inner join bidang_urusan as e on d.kode_bidang_urusan=e.kode_bidang_urusan
    inner join urusan as f on e.kode_urusan=f.kode_urusan
     group by a.kode_sub_skpd,f.kode_urusan ) as k5 on  k5.kode_sub_skpd=g.kode_sub_skpd and k5.kode_urusan=a.kode_urusan)
      left join 
    (select f.kode_urusan,a.kode_sub_skpd, sum(distinct a.rp_realisasi_sub_kegiatan_renstra) as rpk6 from evsub_kegiatan as a 
    inner join sub_kegiatan as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan
    inner join kegiatan as c on b.kode_kegiatan=c.kode_kegiatan
    inner join program as d on c.kode_program=d.kode_program
    inner join bidang_urusan as e on d.kode_bidang_urusan=e.kode_bidang_urusan
    inner join urusan as f on e.kode_urusan=f.kode_urusan
     group by a.kode_sub_skpd,f.kode_urusan ) as k6 on  k6.kode_sub_skpd=g.kode_sub_skpd and k6.kode_urusan=a.kode_urusan)

           left join
    (select a.kode_sub_skpd,f.kode_urusan,
    (((sum(a.t_sub_kegiatan1) + sum(a.t_sub_kegiatan2) + sum(a.t_sub_kegiatan3) + sum(a.t_sub_kegiatan4)) / (sum(target_sub_kegiatan_renja)))*100) as per1 from evsub_kegiatan as a 
    inner join sub_kegiatan as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan
    inner join kegiatan as c on b.kode_kegiatan=c.kode_kegiatan
    inner join program as d on c.kode_program=d.kode_program
    inner join bidang_urusan as e on d.kode_bidang_urusan=e.kode_bidang_urusan
    inner join urusan as f on e.kode_urusan=f.kode_urusan
    group by a.kode_sub_skpd,f.kode_urusan) as per on per.kode_urusan=a.kode_urusan and per.kode_sub_skpd=g.kode_sub_skpd)
    

    where g.kode_sub_skpd='$kode_sub_skpd'
    
    order by a.kode_urusan
    ");
foreach ($sqlurusan as $rowurusan) {

    ?>
    <tr>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td><?php echo($nourusan++) ?></td>
        <td></td>
        <td><strong><?php echo $rowurusan["kode_urusan"]; ?></strong></td>
<td colspan="8"><strong><?php echo $rowurusan["urusan"]; ?></strong></td>
<td></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rpk5"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rpk6"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["total"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal1"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal2"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal3"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal4"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rp13"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rp14"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rp15"],2); ?></strong></td>

<td style="text-align:right;"><strong><?php if(empty($rowurusan["treal"])){echo number_format($rowurusan["total"],2);}else{ echo number_format($rowurusan["sisar"],2);} ?></strong></td>
<td></td>
<td></td>
</tr>
     <?php
$nobidang=1;
$sqlbidang  = mysqli_query($koneksi, "SELECT 
    distinct b.kode_bidang_urusan,b.bidang_urusan,h.kode_skpd,g.kode_sub_skpd,
    ri.total,
    rl.treal,
    rl1.treal1,
    rl2.treal2,
    rl3.treal3,
    rl4.treal4,
    (ri.total-rl.treal) as sisar,


    k5.rpk5,k6.rpk6,
    ((rl.treal/ri.total)*100) as rp13,
    (k6.rpk6 + rl.treal) as rp14,
    (((k6.rpk6 + rl.treal)/(k5.rpk5))*100) as rp15
  
    from ((((((((( urusan as a
    inner join bidang_urusan as b on a.kode_urusan=b.kode_urusan
    inner join program as c on b.kode_bidang_urusan=c.kode_bidang_urusan
    inner join kegiatan as d on c.kode_program=d.kode_program
    inner join sub_kegiatan as e on d.kode_kegiatan=e.kode_kegiatan
    inner join renja as f on e.kode_sub_kegiatan=f.kode_sub_kegiatan
    inner join sub_skpd as g on f.kode_sub_skpd=g.kode_sub_skpd
    inner join skpd as h on g.kode_skpd=h.kode_skpd)
    left join
    (select kode_bidang_urusan,kode_sub_skpd, sum(rincian) as total from renja group by kode_bidang_urusan,kode_sub_skpd ) as ri on ri.kode_bidang_urusan=b.kode_bidang_urusan and ri.kode_sub_skpd=g.kode_sub_skpd)
    left join
     (select bidang,kode_sub_skpd, sum(realisasi) as treal from realisasi  group by bidang,kode_sub_skpd) as rl on rl.bidang=b.bidang_urusan and rl.kode_sub_skpd=g.kode_sub_skpd)
     left join
     (select bidang,kode_sub_skpd, sum(realisasi) as treal1 from realisasi where bulan between '$_SESSION[tahun]-01-01' and '$_SESSION[tahun]-03-31'  group by bidang,kode_sub_skpd) as rl1 on rl1.bidang=b.bidang_urusan and rl1.kode_sub_skpd=g.kode_sub_skpd)
     left join
     (select bidang,kode_sub_skpd, sum(realisasi) as treal2 from realisasi where bulan between '$_SESSION[tahun]-04-01' and '$_SESSION[tahun]-06-30'  group by bidang,kode_sub_skpd) as rl2 on rl2.bidang=b.bidang_urusan and rl2.kode_sub_skpd=g.kode_sub_skpd)
     left join
     (select bidang,kode_sub_skpd, sum(realisasi) as treal3 from realisasi where bulan between '$_SESSION[tahun]-07-01' and '$_SESSION[tahun]-09-31'  group by bidang,kode_sub_skpd) as rl3 on rl3.bidang=b.bidang_urusan and rl3.kode_sub_skpd=g.kode_sub_skpd)
     left join
     (select bidang,kode_sub_skpd, sum(realisasi) as treal4 from realisasi where bulan between '$_SESSION[tahun]-10-01' and '$_SESSION[tahun]-12-31'  group by bidang,kode_sub_skpd) as rl4 on rl4.bidang=b.bidang_urusan and rl4.kode_sub_skpd=g.kode_sub_skpd)

      left join 
    (select e.kode_bidang_urusan,a.kode_sub_skpd, sum(distinct a.rp_target_sub_kegiatan_renstra) as rpk5 from evsub_kegiatan as a 
    inner join sub_kegiatan as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan
    inner join kegiatan as c on b.kode_kegiatan=c.kode_kegiatan
    inner join program as d on c.kode_program=d.kode_program
    inner join bidang_urusan as e on d.kode_bidang_urusan=e.kode_bidang_urusan
     group by a.kode_sub_skpd,e.kode_bidang_urusan ) as k5 on  k5.kode_sub_skpd=g.kode_sub_skpd and k5.kode_bidang_urusan=b.kode_bidang_urusan)
      left join 
    (select e.kode_bidang_urusan,a.kode_sub_skpd, sum(distinct a.rp_realisasi_sub_kegiatan_renstra) as rpk6 from evsub_kegiatan as a 
    inner join sub_kegiatan as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan
    inner join kegiatan as c on b.kode_kegiatan=c.kode_kegiatan
    inner join program as d on c.kode_program=d.kode_program
    inner join bidang_urusan as e on d.kode_bidang_urusan=e.kode_bidang_urusan
     group by a.kode_sub_skpd,e.kode_bidang_urusan ) as k6 on  k6.kode_sub_skpd=g.kode_sub_skpd and k6.kode_bidang_urusan=b.kode_bidang_urusan)
    
    where g.kode_sub_skpd='$kode_sub_skpd'
    and b.kode_urusan='$rowurusan[kode_urusan]'
    
    order by b.kode_bidang_urusan
    ");
foreach ($sqlbidang as $rowbidang) {

    ?>
    <tr>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td><?php echo($nobidang++) ?></td>
        <td></td>
        <td><strong><?php echo $rowbidang["kode_bidang_urusan"]; ?></strong></td>

        <td></td>
<td colspan="7"><strong><?php echo $rowbidang["bidang_urusan"]; ?></strong></td>
<td></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["rpk5"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["rpk6"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["total"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["treal1"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["treal2"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["treal3"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["treal4"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["treal"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["rp13"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["rp14"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowbidang["rp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php if(empty($rowbidang["treal"])){echo number_format($rowbidang["total"],2);}else{ echo number_format($rowbidang["sisar"],2);} ?></strong></td>
<td></td>
<td></td>
     </tr>

     <?php

$sqlskpd  = mysqli_query($koneksi, "SELECT 
    distinct h.kode_skpd,h.skpd,
     ri.total,
    rl.treal,
    rl1.treal1,
    rl2.treal2,
    rl3.treal3,
    rl4.treal4,
    (ri.total-rl.treal) as sisar,

    k5.rpk5,k6.rpk6,
    ((rl.treal/ri.total)*100) as rp13,
    (k6.rpk6 + rl.treal) as rp14,
    (((k6.rpk6 + rl.treal)/(k5.rpk5))*100) as rp15
  
    from ((((((((( urusan as a
    inner join bidang_urusan as b on a.kode_urusan=b.kode_urusan
    inner join program as c on b.kode_bidang_urusan=c.kode_bidang_urusan
    inner join kegiatan as d on c.kode_program=d.kode_program
    inner join sub_kegiatan as e on d.kode_kegiatan=e.kode_kegiatan
    inner join renja as f on e.kode_sub_kegiatan=f.kode_sub_kegiatan
    inner join sub_skpd as g on f.kode_sub_skpd=g.kode_sub_skpd
    inner join skpd as h on f.kode_skpd=h.kode_skpd)
       left join
    (select kode_skpd,kode_bidang_urusan, sum(rincian) as total from renja group by kode_skpd,kode_bidang_urusan ) as ri on ri.kode_skpd=h.kode_skpd and ri.kode_bidang_urusan=b.kode_bidang_urusan)
  
    left join
     (select kode_skpd,bidang, sum(realisasi) as treal from realisasi  group by kode_skpd,bidang) as rl on  rl.kode_skpd=h.kode_skpd and rl.bidang=b.bidang_urusan)
      left join
     (select bidang,kode_skpd, sum(realisasi) as treal1 from realisasi where bulan between '$_SESSION[tahun]-01-01' and '$_SESSION[tahun]-03-31'  group by kode_skpd,bidang) as rl1 on  rl1.kode_skpd=h.kode_skpd and rl1.bidang=b.bidang_urusan)
     left join
     (select bidang,kode_skpd, sum(realisasi) as treal2 from realisasi where bulan between '$_SESSION[tahun]-04-01' and '$_SESSION[tahun]-06-30'  group by kode_skpd,bidang) as rl2 on  rl2.kode_skpd=h.kode_skpd and rl2.bidang=b.bidang_urusan)
     left join
     (select bidang,kode_skpd, sum(realisasi) as treal3 from realisasi where bulan between '$_SESSION[tahun]-07-01' and '$_SESSION[tahun]-09-31'  group by kode_skpd,bidang) as rl3 on  rl3.kode_skpd=h.kode_skpd and rl3.bidang=b.bidang_urusan)
     left join
     (select bidang,kode_skpd, sum(realisasi) as treal4 from realisasi where bulan between '$_SESSION[tahun]-10-01' and '$_SESSION[tahun]-12-31'  group by kode_skpd,bidang) as rl4 on  rl4.kode_skpd=h.kode_skpd and rl4.bidang=b.bidang_urusan)
     left join 
    (select c.kode_skpd,a.kode_sub_skpd, sum(distinct a.rp_target_sub_kegiatan_renstra) as rpk5 from evsub_kegiatan as a 
    inner join sub_skpd as b on a.kode_sub_skpd=b.kode_sub_skpd
    inner join skpd as c on b.kode_skpd=c.kode_skpd
     group by a.kode_sub_skpd,c.kode_skpd ) as k5 on  k5.kode_sub_skpd=g.kode_sub_skpd and k5.kode_skpd=h.kode_skpd)
      left join 
    (select c.kode_skpd,a.kode_sub_skpd, sum(distinct a.rp_realisasi_sub_kegiatan_renstra) as rpk6 from evsub_kegiatan as a 
    inner join sub_skpd as b on a.kode_sub_skpd=b.kode_sub_skpd
    inner join skpd as c on b.kode_skpd=c.kode_skpd
     group by a.kode_sub_skpd,c.kode_skpd ) as k6 on  k6.kode_sub_skpd=g.kode_sub_skpd and k6.kode_skpd=h.kode_skpd)


    where g.kode_sub_skpd='$kode_sub_skpd'
    and b.kode_bidang_urusan='$rowbidang[kode_bidang_urusan]'
    order by h.kode_skpd
    ");
foreach ($sqlskpd as $rowskpd) {

    ?>
    <tr>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td></td>
        <td></td>
        <td><strong hidden="hidden"><?php echo $rowskpd["kode_skpd"]; ?></strong></td>
        <td></td>
        <td></td>
<td colspan="6"><strong><?php echo $rowskpd["skpd"]; ?></strong></td>
<td></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["rpk5"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["rpk6"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["total"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["treal1"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["treal2"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["treal3"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["treal4"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["treal"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["rp13"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["rp14"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowskpd["rp15"],2); ?></strong></td>
<td style="text-align:right;"><?php if(empty($rowskpd["treal"])){echo number_format($rowskpd["total"],2);}else{ echo number_format($rowskpd["sisar"],2);} ?></strong></td>
<td><?php echo $rowskpd["skpd"]; ?></td>
<td></td>
     </tr>


     <?php

$sqlsubskpd  = mysqli_query($koneksi, "SELECT 
    distinct g.kode_sub_skpd,g.sub_skpd,b.kode_bidang_urusan,
  
    ri.total,
    rl.treal,
    rl1.treal1,
    rl2.treal2,
    rl3.treal3,
    rl4.treal4,
    (ri.total-rl.treal) as sisar,
    k5.rpk5,k6.rpk6,
    ((rl.treal/ri.total)*100) as rp13,
    (k6.rpk6 + rl.treal) as rp14,
    (((k6.rpk6 + rl.treal)/(k5.rpk5))*100) as rp15
  
    from ((((((((( urusan as a
    inner join bidang_urusan as b on a.kode_urusan=b.kode_urusan
    inner join program as c on b.kode_bidang_urusan=c.kode_bidang_urusan
    inner join kegiatan as d on c.kode_program=d.kode_program
    inner join sub_kegiatan as e on d.kode_kegiatan=e.kode_kegiatan
    inner join renja as f on e.kode_sub_kegiatan=f.kode_sub_kegiatan
    inner join sub_skpd as g on f.kode_sub_skpd=g.kode_sub_skpd 
    inner join skpd as h on f.kode_skpd=h.kode_skpd)
    left join
    (select kode_sub_skpd,kode_bidang_urusan, sum(rincian) as total from renja group by kode_sub_skpd,kode_bidang_urusan ) as ri on ri.kode_sub_skpd=g.kode_sub_skpd and ri.kode_bidang_urusan=b.kode_bidang_urusan)
  
    left join
     (select kode_sub_skpd,bidang, sum(realisasi) as treal from realisasi  group by kode_sub_skpd,bidang) as rl on  rl.kode_sub_skpd=g.kode_sub_skpd and rl.bidang=b.bidang_urusan)
     left join
     (select kode_sub_skpd,bidang, sum(realisasi) as treal1 from realisasi where bulan between '$_SESSION[tahun]-01-01' and '$_SESSION[tahun]-03-31' group by kode_sub_skpd,bidang) as rl1 on  rl1.kode_sub_skpd=g.kode_sub_skpd and rl1.bidang=b.bidang_urusan)
     left join
     (select kode_sub_skpd,bidang, sum(realisasi) as treal2 from realisasi where bulan between '$_SESSION[tahun]-04-01' and '$_SESSION[tahun]-06-30' group by kode_sub_skpd,bidang) as rl2 on  rl2.kode_sub_skpd=g.kode_sub_skpd and rl2.bidang=b.bidang_urusan)
     left join
     (select kode_sub_skpd,bidang, sum(realisasi) as treal3 from realisasi where bulan between '$_SESSION[tahun]-07-01' and '$_SESSION[tahun]-09-31'  group by kode_sub_skpd,bidang) as rl3 on  rl3.kode_sub_skpd=g.kode_sub_skpd and rl3.bidang=b.bidang_urusan)
     left join
     (select kode_sub_skpd,bidang, sum(realisasi) as treal4 from realisasi where bulan between '$_SESSION[tahun]-10-01' and '$_SESSION[tahun]-12-31'  group by kode_sub_skpd,bidang) as rl4 on  rl4.kode_sub_skpd=g.kode_sub_skpd and rl4.bidang=b.bidang_urusan)
     left join 
    (select a.kode_sub_skpd, sum(distinct a.rp_target_sub_kegiatan_renstra) as rpk5 from evsub_kegiatan as a 
     group by a.kode_sub_skpd ) as k5 on  k5.kode_sub_skpd=g.kode_sub_skpd)
      left join 
    (select a.kode_sub_skpd, sum(distinct a.rp_realisasi_sub_kegiatan_renstra) as rpk6 from evsub_kegiatan as a 
     group by a.kode_sub_skpd ) as k6 on  k6.kode_sub_skpd=g.kode_sub_skpd)
    
    where g.kode_sub_skpd='$kode_sub_skpd'
    and b.kode_bidang_urusan='$rowbidang[kode_bidang_urusan]'
    and g.kode_skpd='$rowskpd[kode_skpd]'
    order by g.kode_sub_skpd
    ");
foreach ($sqlsubskpd as $rowsubskpd) {

    ?>
    <tr>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td></td>
        <td></td>
        <td><strong hidden="hidden"><?php echo $rowsubskpd["kode_sub_skpd"]; ?></strong></td>
         <td></td>
        <td></td>
         <td></td>
        
<td colspan="5"><strong><?php echo $rowsubskpd["sub_skpd"]; ?></strong></td>
<td></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["rpk5"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["rpk6"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["total"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["treal1"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["treal2"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["treal3"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["treal4"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["treal"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["rp13"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["rp14"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowsubskpd["rp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php if(empty($rowsubskpd["treal"])){echo number_format($rowsubskpd["total"],2);}else{ echo number_format($rowsubskpd["sisar"],2);} ?></strong></td>
<td><?php echo $rowskpd["skpd"]; ?></td>
<td></td>
     </tr>


     <?php
$noprogram=1;
$sqlprogram = mysqli_query($koneksi, "SELECT 
    distinct c.kode_program,c.program,
  
      ri.total,
    rl.treal,
    rl1.treal1,
    rl2.treal2,
    rl3.treal3,
    rl4.treal4,
    (ri.total-rl.treal) as sisar,

    ((rl.treal/ri.total)*100) as rp13,

    pr.indikator_program,
    pr.k_target_program_renstra,
    pr.k_realisasi_program_renstra,
    pr.target_program_renja,
    pr.t_program1,
    pr.t_program2,
    pr.t_program3,
    pr.t_program4,
    pr.satuan_program,
    ((pr.t_program1)+(pr.t_program2)+(pr.t_program3)+(pr.t_program4)) as tp12,
    ((((pr.t_program1)+(pr.t_program2)+(pr.t_program3)+(pr.t_program4))/pr.target_program_renja * 100)) as tp13,
    (((pr.t_program1)+(pr.t_program2)+(pr.t_program3)+(pr.t_program4))+ (pr.k_realisasi_program_renstra)) as tp14,
    (((((pr.t_program1)+(pr.t_program2)+(pr.t_program3)+(pr.t_program4))+ (pr.k_realisasi_program_renstra))/(pr.k_target_program_renstra))*100) as tp15,
    k5.rpk5,k6.rpk6,
    (k6.rpk6 + rl.treal) as rp14,
    (((k6.rpk6 + rl.treal)/(k5.rpk5))*100) as rp15,
     per.per1,
    ((rl.treal/ri.total) * 100) as per2,
    (((rl.treal/ri.total) * 100)+(per.per1)/2) as ratacapaian


    from ((((((((((( urusan as a
    inner join bidang_urusan as b on a.kode_urusan=b.kode_urusan
    inner join program as c on b.kode_bidang_urusan=c.kode_bidang_urusan
    inner join kegiatan as d on c.kode_program=d.kode_program
    inner join sub_kegiatan as e on d.kode_kegiatan=e.kode_kegiatan
    inner join renja as f on e.kode_sub_kegiatan=f.kode_sub_kegiatan
    inner join sub_skpd as g on f.kode_sub_skpd=g.kode_sub_skpd
    inner join skpd as h on g.kode_skpd=h.kode_skpd)
      left join
    (select kode_sub_skpd,kode_program, sum(rincian) as total from renja group by kode_sub_skpd,kode_program ) as ri on ri.kode_sub_skpd=g.kode_sub_skpd and ri.kode_program=c.kode_program)
  
    left join
    (select kode_sub_skpd,program, sum(realisasi) as treal from realisasi  group by kode_sub_skpd,program) as rl on  rl.kode_sub_skpd=g.kode_sub_skpd and rl.program=c.program)
    left join
    (select kode_sub_skpd,program, sum(realisasi) as treal1 from realisasi where bulan between '$_SESSION[tahun]-01-01' and '$_SESSION[tahun]-03-31'   group by kode_sub_skpd,program) as rl1 on  rl1.kode_sub_skpd=g.kode_sub_skpd and rl1.program=c.program)
    left join
    (select kode_sub_skpd,program, sum(realisasi) as treal2 from realisasi where bulan between '$_SESSION[tahun]-04-01' and '$_SESSION[tahun]-06-30'   group by kode_sub_skpd,program) as rl2 on  rl2.kode_sub_skpd=g.kode_sub_skpd and rl2.program=c.program)
    left join
    (select kode_sub_skpd,program, sum(realisasi) as treal3 from realisasi  where bulan between '$_SESSION[tahun]-07-01' and '$_SESSION[tahun]-09-31'  group by kode_sub_skpd,program) as rl3 on  rl3.kode_sub_skpd=g.kode_sub_skpd and rl3.program=c.program)
    left join
    (select kode_sub_skpd,program, sum(realisasi) as treal4 from realisasi  where bulan between '$_SESSION[tahun]-10-01' and '$_SESSION[tahun]-12-31' group by kode_sub_skpd,program) as rl4 on  rl4.kode_sub_skpd=g.kode_sub_skpd and rl4.program=c.program)
    left join
    (select kode_sub_skpd,kode_program,indikator_program,k_target_program_renstra,k_realisasi_program_renstra,target_program_renja,t_program1,t_program2,t_program3,t_program4,satuan_program from evprogram ) as pr on pr.kode_sub_skpd=g.kode_sub_skpd and pr.kode_program=c.kode_program)

    left join 
    (select b.kode_program,a.kode_sub_skpd, sum(distinct a.rp_target_sub_kegiatan_renstra) as rpk5 from evsub_kegiatan as a 
    inner join renja as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan and a.kode_sub_skpd=b.kode_sub_skpd
     group by b.kode_program,a.kode_sub_skpd ) as k5 on k5.kode_program=c.kode_program and k5.kode_sub_skpd=g.kode_sub_skpd)
      left join 
    (select b.kode_program,a.kode_sub_skpd, sum(distinct a.rp_realisasi_sub_kegiatan_renstra) as rpk6 from evsub_kegiatan as a 
    inner join renja as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan and a.kode_sub_skpd=b.kode_sub_skpd
     group by b.kode_program,a.kode_sub_skpd ) as k6 on k6.kode_program=c.kode_program and k6.kode_sub_skpd=g.kode_sub_skpd)
      left join
    (select a.kode_sub_skpd,d.kode_program,
    (((sum(a.t_sub_kegiatan1) + sum(a.t_sub_kegiatan2) + sum(a.t_sub_kegiatan3) + sum(a.t_sub_kegiatan4)) / (sum(target_sub_kegiatan_renja)))*100) as per1 from evsub_kegiatan as a 
    inner join sub_kegiatan as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan
    inner join kegiatan as c on b.kode_kegiatan=c.kode_kegiatan
    inner join program as d on c.kode_program=d.kode_program
    group by a.kode_sub_skpd,d.kode_program) as per on per.kode_program=c.kode_program and per.kode_sub_skpd=g.kode_sub_skpd)
    
    where g.kode_sub_skpd='$kode_sub_skpd'
    and c.kode_bidang_urusan='$rowsubskpd[kode_bidang_urusan]'
    order by c.kode_program
    ");
foreach ($sqlprogram as $rowprogram) {

    ?>
    <tr>
        <td hidden="hidden"><?php echo $rowprogram["kode_program"]; ?></td>
        <td hidden="hidden"><?php echo $rowprogram["program"]; ?></td>
        <td hidden="hidden"></td>
        <td><?php echo ($noprogram++) ?></td>
        <td><?php 
$sqlsasaran = mysqli_query($koneksi, "SELECT 
    kode_sub_skpd,kode_program,sasaran from evsasaran
    where kode_program='$rowprogram[kode_program]' and kode_sub_skpd='$kode_sub_skpd'
    ");
foreach ($sqlsasaran as $rowsas) {
    ?>
<?php echo $rowsas['sasaran']; ?>
<?php
}
    ?>
   </td>
        <td><strong><?php echo $rowprogram["kode_program"]; ?></strong></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>

<td colspan="4"><strong><?php echo $rowprogram["program"]; ?></strong>
   </td>
<td><strong><?php echo $rowprogram["indikator_program"]; ?></strong></td>
<td><strong><?php echo $rowprogram["k_target_program_renstra"]; ?></strong></td>
<td><strong><?php echo $rowprogram["satuan_program"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rpk5"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo $rowprogram["k_realisasi_program_renstra"]; ?></strong></td>
<td><strong><?php echo $rowprogram["satuan_program"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rpk6"],2); ?></strong></td>
<td><strong><?php echo $rowprogram["target_program_renja"]; ?></strong></td>
<td><strong><?php echo $rowprogram["satuan_program"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["total"],2); ?></strong></td>
<td><strong><?php echo $rowprogram["t_program1"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal1"],2); ?></strong></td>
<td><strong><?php echo $rowprogram["t_program2"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal2"],2); ?></strong></td>
<td><strong><?php echo $rowprogram["t_program3"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal3"],2); ?></strong></td>
<td><strong><?php echo $rowprogram["t_program4"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal4"],2); ?></strong></td>
<td><strong><?php echo number_format($rowprogram["tp12"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal"],2); ?></strong></td>
<td><strong><?php echo number_format($rowprogram["tp13"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rp13"],2); ?></strong></td>
<td><strong><?php echo number_format($rowprogram["tp14"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rp14"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["tp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php if(empty($rowprogram["treal"])){echo number_format($rowprogram["total"],2);}else{ echo number_format($rowprogram["sisar"],2);} ?></strong></td>
<td><?php echo $rowskpd["skpd"]; ?></td>
<td></td>
     </tr>


    <?php
$sqliprogram = mysqli_query($koneksi, "SELECT 
     id_iprogram,
     kode_sub_skpd,
     kode_program,
     indikator_iprogram,
     k_target_iprogram_renstra,
     k_realisasi_iprogram_renstra,
     target_iprogram_renja,
     t_iprogram1,
     t_iprogram2,
     t_iprogram3,
     t_iprogram4,
     satuan_iprogram,
     (t_iprogram1 + t_iprogram2 + t_iprogram3 + t_iprogram4) as tp12,
     (((t_iprogram1 + t_iprogram2 + t_iprogram3 + t_iprogram4)/target_iprogram_renja)*100) as tp13,
     (k_realisasi_iprogram_renstra + (t_iprogram1 + t_iprogram2 + t_iprogram3 + t_iprogram4)) as tp14

     from iprogram where kode_program='$rowprogram[kode_program]' and kode_sub_skpd='$kode_sub_skpd'
    ");
foreach ($sqliprogram as $rowiprogram) {

    ?>
    <tr>
     
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>

<td colspan="4">
   </td>
<td><strong><?php echo $rowiprogram["indikator_iprogram"]; ?></strong>
</td>
<td><strong><?php echo $rowiprogram["k_target_iprogram_renstra"]; ?></strong></td>
<td><strong><?php echo $rowiprogram["satuan_iprogram"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rpk5"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo $rowiprogram["k_realisasi_iprogram_renstra"]; ?></strong></td>
<td><strong><?php echo $rowiprogram["satuan_iprogram"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rpk6"],2); ?></strong></td>
<td><strong><?php echo $rowiprogram["target_iprogram_renja"]; ?></strong></td>
<td><strong><?php echo $rowiprogram["satuan_iprogram"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["total"],2); ?></strong></td>
<td><strong><?php echo $rowiprogram["t_iprogram1"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal1"],2); ?></strong></td>
<td><strong><?php echo $rowiprogram["t_iprogram2"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal2"],2); ?></strong></td>
<td><strong><?php echo $rowiprogram["t_iprogram3"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal3"],2); ?></strong></td>
<td><strong><?php echo $rowiprogram["t_iprogram4"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal4"],2); ?></strong></td>
<td><strong><?php echo number_format($rowiprogram["tp12"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["treal"],2); ?></strong></td>
<td><strong><?php echo number_format($rowiprogram["tp13"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rp13"],2); ?></strong></td>
<td><strong><?php echo number_format($rowiprogram["tp14"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rp14"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["tp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowprogram["rp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php if(empty($rowprogram["treal"])){echo number_format($rowprogram["total"],2);}else{ echo number_format($rowprogram["sisar"],2);} ?></strong></td>
<td><?php echo $rowskpd["skpd"]; ?></td>
<td></td>
     </tr>
<?php
}
?>


      <?php
      $nokeg=1;
    $sqlkegiatan = mysqli_query($koneksi, "SELECT 
    distinct d.kode_kegiatan,d.kegiatan,
    
     ri.total,
    rl.treal,
    rl1.treal1,
    rl2.treal2,
    rl3.treal3,
    rl4.treal4,
    (ri.total-rl.treal) as sisar,

    ((rl.treal/ri.total)*100) as rp13,

    pr.indikator_kegiatan,
    pr.k_target_kegiatan_renstra,
    pr.k_realisasi_kegiatan_renstra,
    pr.target_kegiatan_renja,
    pr.t_kegiatan1,
    pr.t_kegiatan2,
    pr.t_kegiatan3,
    pr.t_kegiatan4,
    pr.satuan_kegiatan,
    ((pr.t_kegiatan1)+(pr.t_kegiatan2)+(pr.t_kegiatan3)+(pr.t_kegiatan4)) as tp12,
    ((((pr.t_kegiatan1)+(pr.t_kegiatan2)+(pr.t_kegiatan3)+(pr.t_kegiatan4))/pr.target_kegiatan_renja * 100)) as tp13,
    (((pr.t_kegiatan1)+(pr.t_kegiatan2)+(pr.t_kegiatan3)+(pr.t_kegiatan4))+ (pr.k_realisasi_kegiatan_renstra)) as tp14,
    (((((pr.t_kegiatan1)+(pr.t_kegiatan2)+(pr.t_kegiatan3)+(pr.t_kegiatan4))+ (pr.k_realisasi_kegiatan_renstra))/(pr.k_target_kegiatan_renstra))*100) as tp15,

    k5.rpk5,k6.rpk6,
    (k6.rpk6 + rl.treal) as rp14,
    (((k6.rpk6 + rl.treal)/(k5.rpk5))*100) as rp15,
    per.per1,
    ((rl.treal/ri.total) * 100) as per2,
    (((rl.treal/ri.total) * 100)+(per.per1)/2) as ratacapaian
  
    from ((((((((((( urusan as a
    inner join bidang_urusan as b on a.kode_urusan=b.kode_urusan
    inner join program as c on b.kode_bidang_urusan=c.kode_bidang_urusan
    inner join kegiatan as d on c.kode_program=d.kode_program
    inner join sub_kegiatan as e on d.kode_kegiatan=e.kode_kegiatan
    inner join renja as f on e.kode_sub_kegiatan=f.kode_sub_kegiatan
    inner join sub_skpd as g on f.kode_sub_skpd=g.kode_sub_skpd
    inner join skpd as h on g.kode_skpd=h.kode_skpd )
     left join
    (select kode_sub_skpd,kode_kegiatan, sum(rincian) as total from renja group by kode_sub_skpd,kode_kegiatan ) as ri on ri.kode_sub_skpd=g.kode_sub_skpd and ri.kode_kegiatan=d.kode_kegiatan)
  
    left join
    (select kode_sub_skpd,kode_kegiatan, sum(realisasi) as treal from realisasi  group by kode_sub_skpd,kode_kegiatan) as rl on  rl.kode_sub_skpd=g.kode_sub_skpd and rl.kode_kegiatan=d.kode_kegiatan)
    
    left join
    (select kode_sub_skpd,kode_kegiatan, sum(realisasi) as treal1 from realisasi  where bulan between '$_SESSION[tahun]-01-01' and '$_SESSION[tahun]-03-31'  group by kode_sub_skpd,kode_kegiatan) as rl1 on  rl1.kode_sub_skpd=g.kode_sub_skpd and rl1.kode_kegiatan=d.kode_kegiatan)
    
    left join
    (select kode_sub_skpd,kode_kegiatan, sum(realisasi) as treal2 from realisasi  where bulan between '$_SESSION[tahun]-04-01' and '$_SESSION[tahun]-06-30'  group by kode_sub_skpd,kode_kegiatan) as rl2 on  rl2.kode_sub_skpd=g.kode_sub_skpd and rl2.kode_kegiatan=d.kode_kegiatan)
    
    left join
    (select kode_sub_skpd,kode_kegiatan, sum(realisasi) as treal3 from realisasi  where bulan between '$_SESSION[tahun]-07-01' and '$_SESSION[tahun]-09-31'  group by kode_sub_skpd,kode_kegiatan) as rl3 on  rl3.kode_sub_skpd=g.kode_sub_skpd and rl3.kode_kegiatan=d.kode_kegiatan)
    
    left join
    (select kode_sub_skpd,kode_kegiatan, sum(realisasi) as treal4 from realisasi  where bulan between '$_SESSION[tahun]-10-01' and '$_SESSION[tahun]-12-31'  group by kode_sub_skpd,kode_kegiatan) as rl4 on  rl4.kode_sub_skpd=g.kode_sub_skpd and rl4.kode_kegiatan=d.kode_kegiatan)
     left join
    (select kode_sub_skpd,kode_kegiatan,indikator_kegiatan,k_target_kegiatan_renstra,k_realisasi_kegiatan_renstra,target_kegiatan_renja,t_kegiatan1,t_kegiatan2,t_kegiatan3,t_kegiatan4,satuan_kegiatan from evkegiatan ) as pr on pr.kode_sub_skpd=g.kode_sub_skpd and pr.kode_kegiatan=d.kode_kegiatan)
    left join 
    (select b.kode_kegiatan,a.kode_sub_skpd, sum(distinct a.rp_target_sub_kegiatan_renstra) as rpk5 from evsub_kegiatan as a 
    inner join renja as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan and a.kode_sub_skpd=b.kode_sub_skpd
     group by b.kode_kegiatan,a.kode_sub_skpd ) as k5 on k5.kode_kegiatan=d.kode_kegiatan and k5.kode_sub_skpd=g.kode_sub_skpd)
     left join 
    (select b.kode_kegiatan,a.kode_sub_skpd, sum(distinct a.rp_realisasi_sub_kegiatan_renstra) as rpk6 from evsub_kegiatan as a 
    inner join renja as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan and a.kode_sub_skpd=b.kode_sub_skpd
     group by b.kode_kegiatan,a.kode_sub_skpd ) as k6 on k6.kode_kegiatan=d.kode_kegiatan and k6.kode_sub_skpd=g.kode_sub_skpd)
      left join
    (select a.kode_sub_skpd,c.kode_kegiatan,
    (((sum(a.t_sub_kegiatan1) + sum(a.t_sub_kegiatan2) + sum(a.t_sub_kegiatan3) + sum(a.t_sub_kegiatan4)) / (sum(target_sub_kegiatan_renja)))*100) as per1 from evsub_kegiatan as a 
    inner join sub_kegiatan as b on a.kode_sub_kegiatan=b.kode_sub_kegiatan
    inner join kegiatan as c on b.kode_kegiatan=c.kode_kegiatan
    group by a.kode_sub_skpd,c.kode_kegiatan) as per on per.kode_kegiatan=d.kode_kegiatan and per.kode_sub_skpd=g.kode_sub_skpd)


    where g.kode_sub_skpd='$kode_sub_skpd'
    and d.kode_program='$rowprogram[kode_program]'
    
    order by d.kode_kegiatan
    ");
foreach ($sqlkegiatan as $rowkegiatan) {

    ?>
    <tr>
        <td hidden="hidden"><?php echo $rowkegiatan["kode_kegiatan"]; ?></td>
        <td hidden="hidden"><?php echo $rowkegiatan["kegiatan"]; ?></td>
        <td hidden="hidden"></td>
        <td><?php echo ($nokeg++) ?></td>
        <td></td>
        <td><strong><?php echo $rowkegiatan["kode_kegiatan"]; ?></strong></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
<td colspan="3"><strong><?php echo $rowkegiatan["kegiatan"]; ?></strong></td>
<td><strong><?php echo $rowkegiatan["indikator_kegiatan"]; ?></strong></td>
<td><strong><?php echo $rowkegiatan["k_target_kegiatan_renstra"]; ?></strong></td>
<td><strong><?php echo $rowkegiatan["satuan_kegiatan"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["rpk5"],2); ?></strong></td>
<td><strong><?php echo $rowkegiatan["k_realisasi_kegiatan_renstra"]; ?></strong></td>
<td><strong><?php echo $rowkegiatan["satuan_kegiatan"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["rpk6"],2); ?></td>
<td><strong><?php echo $rowkegiatan["target_kegiatan_renja"]; ?></strong></td>
<td><strong><?php echo $rowkegiatan["satuan_kegiatan"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["total"],2); ?></strong></td>
<td><?php echo $rowkegiatan["t_kegiatan1"]; ?></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["treal1"],2); ?></strong></td>
<td><?php echo $rowkegiatan["t_kegiatan2"]; ?></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["treal2"],2); ?></strong></td>
<td><?php echo $rowkegiatan["t_kegiatan3"]; ?></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["treal3"],2); ?></strong></td>
<td><?php echo $rowkegiatan["t_kegiatan4"]; ?></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["treal4"],2); ?></strong></td>
<td><strong><?php echo $rowkegiatan["tp12"]; ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["treal"],2); ?></strong></td>
<td><strong><?php echo number_format($rowkegiatan["tp13"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["rp13"],2); ?></strong></td>
<td><strong><?php echo number_format($rowkegiatan["tp14"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["rp14"],2); ?></strong></td>
<td><strong><?php echo number_format($rowkegiatan["tp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php echo number_format($rowkegiatan["rp15"],2); ?></strong></td>
<td style="text-align:right;"><strong><?php if(empty($rowkegiatan["treal"])){echo number_format($rowkegiatan["total"],2);}else{ echo number_format($rowkegiatan["sisar"],2);} ?></strong></td>
<td><?php echo $rowskpd["skpd"]; ?></td>
<td></td>

     </tr>


  <?php
  $nosub=1;
    $sqlsub = mysqli_query($koneksi, "SELECT 
   distinct  e.kode_sub_kegiatan,e.sub_kegiatan,
        ri.total,
    rl.treal,
    rl1.treal1,
    rl2.treal2,
    rl3.treal3,
    rl4.treal4,
    (ri.total-rl.treal) as sisar,
    indi.indikator,
    indi.satuan ,



    ((rl.treal/ri.total)*100) as rp13,

    pr.indikator_sub_kegiatan,
    pr.k_target_sub_kegiatan_renstra,
    pr.rp_target_sub_kegiatan_renstra,
    pr.k_realisasi_sub_kegiatan_renstra,
    pr.rp_realisasi_sub_kegiatan_renstra,
    pr.target_sub_kegiatan_renja,
    pr.t_sub_kegiatan1,
    pr.t_sub_kegiatan2,
    pr.t_sub_kegiatan3,
    pr.t_sub_kegiatan4,
    ((pr.t_sub_kegiatan1)+(pr.t_sub_kegiatan2)+(pr.t_sub_kegiatan3)+(pr.t_sub_kegiatan4)) as tp12,
    ((((pr.t_sub_kegiatan1)+(pr.t_sub_kegiatan2)+(pr.t_sub_kegiatan3)+(pr.t_sub_kegiatan4))/pr.target_sub_kegiatan_renja * 100)) as tp13,
    (((pr.t_sub_kegiatan1)+(pr.t_sub_kegiatan2)+(pr.t_sub_kegiatan3)+(pr.t_sub_kegiatan4))+ (pr.k_realisasi_sub_kegiatan_renstra)) as tp14,
    (((((pr.t_sub_kegiatan1)+(pr.t_sub_kegiatan2)+(pr.t_sub_kegiatan3)+(pr.t_sub_kegiatan4))+ (pr.k_realisasi_sub_kegiatan_renstra))/(pr.k_target_sub_kegiatan_renstra))*100) as tp15,
    (pr.rp_realisasi_sub_kegiatan_renstra + rl.treal) as rp14,
    (((pr.rp_realisasi_sub_kegiatan_renstra + rl.treal)/pr.rp_target_sub_kegiatan_renstra)*100) as rp15

    from ((((((((( urusan as a
    inner join bidang_urusan as b on a.kode_urusan=b.kode_urusan
    inner join program as c on b.kode_bidang_urusan=c.kode_bidang_urusan
    inner join kegiatan as d on c.kode_program=d.kode_program
    inner join sub_kegiatan as e on d.kode_kegiatan=e.kode_kegiatan
    inner join renja as f on e.kode_sub_kegiatan=f.kode_sub_kegiatan
    inner join sub_skpd as g on f.kode_sub_skpd=g.kode_sub_skpd
    inner join skpd as h on g.kode_skpd=h.kode_skpd)
       left join
    (select kode_sub_skpd,kode_sub_kegiatan, sum(rincian) as total from renja group by kode_sub_skpd,kode_sub_kegiatan ) as ri on ri.kode_sub_skpd=g.kode_sub_skpd and ri.kode_sub_kegiatan=e.kode_sub_kegiatan)
  
    left join
    (select kode_sub_skpd,kode_sub_kegiatan, sum(realisasi) as treal from realisasi  group by kode_sub_skpd,kode_sub_kegiatan) as rl on  rl.kode_sub_skpd=g.kode_sub_skpd and rl.kode_sub_kegiatan=e.kode_sub_kegiatan)

     left join
    (select kode_sub_skpd,kode_sub_kegiatan, sum(realisasi) as treal1 from realisasi where bulan between '$_SESSION[tahun]-01-01' and '$_SESSION[tahun]-03-31' group by kode_sub_skpd,kode_sub_kegiatan) as rl1 on  rl1.kode_sub_skpd=g.kode_sub_skpd and rl1.kode_sub_kegiatan=e.kode_sub_kegiatan)
     left join
    (select kode_sub_skpd,kode_sub_kegiatan, sum(realisasi) as treal2 from realisasi  where bulan between '$_SESSION[tahun]-04-01' and '$_SESSION[tahun]-06-30'  group by kode_sub_skpd,kode_sub_kegiatan) as rl2 on  rl2.kode_sub_skpd=g.kode_sub_skpd and rl2.kode_sub_kegiatan=e.kode_sub_kegiatan)
     left join
    (select kode_sub_skpd,kode_sub_kegiatan, sum(realisasi) as treal3 from realisasi  where bulan between '$_SESSION[tahun]-07-01' and '$_SESSION[tahun]-09-31' group by kode_sub_skpd,kode_sub_kegiatan) as rl3 on  rl3.kode_sub_skpd=g.kode_sub_skpd and rl3.kode_sub_kegiatan=e.kode_sub_kegiatan)
     left join
    (select kode_sub_skpd,kode_sub_kegiatan, sum(realisasi) as treal4 from realisasi  where bulan between '$_SESSION[tahun]-10-01' and '$_SESSION[tahun]-12-31' group by kode_sub_skpd,kode_sub_kegiatan) as rl4 on  rl4.kode_sub_skpd=g.kode_sub_skpd and rl4.kode_sub_kegiatan=e.kode_sub_kegiatan)
    left join
    (select uraian,indikator,satuan from indikator) as indi on indi.uraian=e.sub_kegiatan )
    left join
    (select kode_sub_skpd,kode_sub_kegiatan,indikator_sub_kegiatan,k_target_sub_kegiatan_renstra,rp_target_sub_kegiatan_renstra,k_realisasi_sub_kegiatan_renstra,rp_realisasi_sub_kegiatan_renstra,target_sub_kegiatan_renja,t_sub_kegiatan1,t_sub_kegiatan2,t_sub_kegiatan3,t_sub_kegiatan4 from evsub_kegiatan ) as pr on pr.kode_sub_skpd=g.kode_sub_skpd and pr.kode_sub_kegiatan=e.kode_sub_kegiatan)
    
    
    where g.kode_sub_skpd='$kode_sub_skpd'
    and e.kode_kegiatan='$rowkegiatan[kode_kegiatan]'
    
    order by e.kode_sub_kegiatan
    ");
foreach ($sqlsub as $rowsub) {

    ?>
    <tr>
        <td hidden="hidden"><?php echo $rowsub["kode_sub_kegiatan"]; ?></td>
        <td hidden="hidden"><?php echo $rowsub["sub_kegiatan"]; ?></td>
        <td hidden="hidden"><?php echo $rowsub["indikator"]; ?></td>
        <td><?php echo ($nosub++) ?></td>
        <td></td>
        <td><?php echo $rowsub["kode_sub_kegiatan"]; ?></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
<td colspan="2"><?php echo $rowsub["sub_kegiatan"]; ?></td>
<td><?php echo $rowsub["indikator"]; ?></td>
<td><?php echo $rowsub["k_target_sub_kegiatan_renstra"]; ?></td>
<td><?php echo $rowsub["satuan"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["rp_target_sub_kegiatan_renstra"],2); ?></td>
<td><?php echo $rowsub["k_realisasi_sub_kegiatan_renstra"]; ?></td>
<td><?php echo $rowsub["satuan"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["rp_realisasi_sub_kegiatan_renstra"],2); ?></td>
<td><?php echo $rowsub["target_sub_kegiatan_renja"]; ?></td>
<td><?php echo $rowsub["satuan"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["total"],2); ?></td>
<td><?php echo $rowsub["t_sub_kegiatan1"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["treal1"],2); ?></td>
<td><?php echo $rowsub["t_sub_kegiatan2"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["treal2"],2); ?></td>
<td><?php echo $rowsub["t_sub_kegiatan3"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["treal3"],2); ?></td>
<td><?php echo $rowsub["t_sub_kegiatan4"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["treal4"],2); ?></td>
<td><?php echo $rowsub["tp12"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["treal"],2); ?></td>
<td><?php echo $rowsub["tp13"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["rp13"]); ?></td>
<td><?php echo $rowsub["tp14"]; ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["rp14"],2); ?></td>
<td><?php echo number_format($rowsub["tp15"],2); ?></td>
<td style="text-align:right;"><?php echo number_format($rowsub["rp15"],2); ?></td>
<td style="text-align:right;"><?php if(empty($rowsub["treal"])){echo number_format($rowsub["total"],2);}else{ echo number_format($rowsub["sisar"],2);} ?></td>
<td><?php echo $rowskpd["skpd"]; ?></td>
<td><?php
    $sqlsd = mysqli_query($koneksi, "SELECT 
   distinct  a.sumber_dana from sumber_dana as a inner join renja as b on  a.kode_sumber_dana=b.kode_sumber_dana 
   where kode_sub_kegiatan='$rowsub[kode_sub_kegiatan]' and b.kode_sub_skpd='$kode_sub_skpd'
    ");
foreach ($sqlsd as $rowsd) {

    ?>
       - <?php echo $rowsd['sumber_dana']; ?> 
        <br>


        <?php }
        ?>
    </td>
</tr>

   


        <?php
 
    
 
    
}
?>
<tr>
    <td hidden=""></td>
<td colspan="29" style="text-align:right;"><strong>Rata - Rata Capaian Kinerja ( % ) </strong></td>
<td ><strong><?php echo number_format($rowkegiatan['per1'],0) ?> %</strong></td>
<td><strong><?php echo number_format($rowkegiatan['per2'],0) ?> %</strong></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td ></td>
<td></td>
<td></td>
     </tr>
     <tr>
<td colspan="29" style="text-align:right;"><strong>Predikat Kinerja </strong></td>
<td ><strong>
    <?php if($rowkegiatan['per1']>=91){echo "Sangat Tinggi";}; ?>
    <?php if($rowkegiatan['per1']<=90 and $rowkegiatan['per1']>=76){echo "Tinggi";}; ?>
    <?php if($rowkegiatan['per1']<=75 and $rowkegiatan['per1']>=66){echo "Sedang";}; ?>
    <?php if($rowkegiatan['per1']<=65 and $rowkegiatan['per1']>=50){echo "Rendah";}; ?>
    <?php if($rowkegiatan['per1']<=49 ){echo "Sangat Rendah";}; ?>
</strong>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td ></td>
<td></td>
<td></td>
     </tr>

<?php
}
?>
<tr>
    <td hidden=""></td>
<td colspan="29" style="text-align:right;"><strong>Rata - Rata Capaian Kinerja ( % ) </strong></td>
<td ><strong><?php echo number_format($rowprogram['per1'],0) ?> %</strong></td>
<td><strong><?php echo number_format($rowprogram['per2'],0) ?> %</strong></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td ></td>
<td></td>
<td></td>
     </tr>
     <tr>
<td colspan="29" style="text-align:right;"><strong>Predikat Kinerja </strong></td>
<td ><strong>
    <?php if($rowprogram['per1']>=91){echo "Sangat Tinggi";}; ?>
    <?php if($rowprogram['per1']<=90 and $rowprogram['per1']>=76){echo "Tinggi";}; ?>
    <?php if($rowprogram['per1']<=75 and $rowprogram['per1']>=66){echo "Sedang";}; ?>
    <?php if($rowprogram['per1']<=65 and $rowprogram['per1']>=50){echo "Rendah";}; ?>
    <?php if($rowprogram['per1']<=49 ){echo "Sangat Rendah";}; ?>
</strong>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td ></td>
<td></td>
<td></td>
     </tr>
<?php
}
}
}
}
}
?>
  <tr>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td hidden="hidden"></td>
        <td></td>
        <td></td>
        <td></td>
<td colspan="8">Total</strong></td>
<td></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rpk5"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rpk6"],2); ?></strong></td>
<td></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["total"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal1"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal2"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal3"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal4"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["treal"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rp13"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rp14"],2); ?></strong></td>
<td></td>
<td style="text-align:right;"><strong><?php echo number_format($rowurusan["rp15"],2); ?></strong></td>

<td style="text-align:right;"><strong><?php if(empty($rowurusan["treal"])){echo number_format($rowurusan["total"],2);}else{ echo number_format($rowurusan["sisar"],2);} ?></strong></td>
<td></td>
<td></td>
</tr>


<tr>
    <td hidden=""></td>
<td colspan="29" style="text-align:right;"><strong>Rata - Rata Capaian Kinerja ( % ) </strong></td>
<td><strong><?php echo number_format($rowurusan['per1'],0) ?> %</strong></td>
<td><strong><?php echo number_format($rowurusan['per2'],0) ?> %</strong></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td ></td>
<td></td>
<td></td>
     </tr>
     <tr>
<td colspan="29" style="text-align:right;"><strong>Predikat Kinerja </strong></td>
<td ><strong>
    <?php if($rowurusan['per1']>=91){echo "Sangat Tinggi";}; ?>
    <?php if($rowurusan['per1']<=90 and $rowurusan['per1']>=76){echo "Tinggi";}; ?>
    <?php if($rowurusan['per1']<=75 and $rowurusan['per1']>=66){echo "Sedang";}; ?>
    <?php if($rowurusan['per1']<=65 and $rowurusan['per1']>=50){echo "Rendah";}; ?>
    <?php if($rowurusan['per1']<=49 ){echo "Sangat Rendah";}; ?>
</strong>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td ></td>
<td></td>
<td></td>
     </tr>

 </tbody>
  </table>

<br>
<br>

<?php

}
mysqli_close($koneksi);
?> 
  
          <script>
              $(document).ready(function () {
                 $(".selsasaran").on('click', function () {
                    
                    var currentRow = $(this).closest("tr");
              
                      var col0 = currentRow.find("td:eq(0)").html();
                      var col1 = currentRow.find("td:eq(1)").html();
                      
                      col0 = col0.replace(/^\s+|\s+$/g, '');
                     
                      
                    
                      $("#kode_programs").val(col0);
                      $("#programs").val(col1);
                       tampilsasaran();
                     

                      
                          });

                 $(".selprogram").on('click', function () {
                    
                    var currentRow = $(this).closest("tr");
              
                      var col0 = currentRow.find("td:eq(0)").html();
                      var col1 = currentRow.find("td:eq(1)").html();
                      
                      col0 = col0.replace(/^\s+|\s+$/g, '');
                     
                      
                    
                      $("#kode_program").val(col0);
                      $("#program").val(col1);
                       tampilprogram();
                     

                      
                          });
                
                  
                 $(".selkegiatan").on('click', function () {
                    
                    var currentRow = $(this).closest("tr");
              
                      var col0 = currentRow.find("td:eq(0)").html();
                      var col1 = currentRow.find("td:eq(1)").html();
                      
                      col0 = col0.replace(/^\s+|\s+$/g, '');
                     
                      
                    
                      $("#kode_kegiatan").val(col0);
                      $("#kegiatan").val(col1);
                       tampilkegiatan();
                     

                      
                          });
                    $(".selsubkegiatan").on('click', function () {
                    
                    var currentRow = $(this).closest("tr");
              
                      var col0 = currentRow.find("td:eq(0)").html();
                      var col1 = currentRow.find("td:eq(1)").html();
                      var col2 = currentRow.find("td:eq(2)").html();
                      
                      col0 = col0.replace(/^\s+|\s+$/g, '');
                      col1 = col1.replace(/^\s+|\s+$/g, '');
                      col2 = col2.replace(/^\s+|\s+$/g, '');
                     
                      
                    
                      $("#kode_sub_kegiatan").val(col0);
                      $("#sub_kegiatan").val(col1);
                      $("#indikator_sub_kegiatan").val(col2);
                       tampilsub_kegiatan();
                     

                          });
                
                                        


                  });

                  
           
</script>

                
<script type="text/javascript">
      function loadul(){
    
        $('#tumbsi').summernote(
        {
            placeholder:'input data anda',
            height:200,
            toolbar: [
['style', []],
['font', []],
['color', []],
['para', []],
['table', []],
['insert', ['picture']],
['view', ['fullscreen']]
]
        });


       
   
 }
</script>
        <script>

  $(function () {
    // Summernote
    $('#summernote1').summernote(
        {
            placeholder:'input data anda',
            height:200,
        });

   
   $('#tumbsi').summernote(
        {
            placeholder:'input data anda',
            height:200,
            toolbar: [
['style', []],
['font', []],
['color', []],
['para', []],
['table', []],
['insert', ['picture']],
['view', ['fullscreen']]
]
        });

   

   
    CodeMirror.fromTextArea(document.getElementById("beritai"), {
      mode: "htmlmixed",
      theme: "monokai"
    });


  })
</script>
          
         <script>
            $(function () {
                $("#example1").DataTable({
                    "responsive": true,
                    "lengthChange": true,
                    "autoWidth": true,
                    "buttons": ["copy", "csv", "excel", "pdf", "print"]
                }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
                $('#example2').DataTable({
                    "paging": true,
                    "lengthChange": false,
                    "searching": false,
                    "ordering": true,
                    "info": true,
                    "autoWidth": false,
                    "responsive": true,
                });
            });
</script>
 
</body>
</html>