      
<?php
include '../../../../config/koneksi.php';
session_start();
?>

       <?php
       echo  $_GET['kode_sub_skpd'];
       echo  $_GET['kode_sub_kegiatan'];
       $kode_sub_skpd=$_GET['kode_sub_skpd'];
       $kode_sub_kegiatan=$_GET['kode_sub_kegiatan'];


$sqlie  = mysqli_query($koneksi, "SELECT 
    distinct a.kode_sub_kegiatan,a.sub_kegiatan,
    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.satuan_sub_kegiatan

    from(( renja as a)
    left join
    (
     SELECT a.kode_sub_skpd,a.kode_sub_kegiatan,a.tahun,a.indikator_sub_kegiatan,
    a.k_target_sub_kegiatan_renstra,
    a.rp_target_sub_kegiatan_renstra,
    a.k_realisasi_sub_kegiatan_renstra,
    a.rp_realisasi_sub_kegiatan_renstra,
    a.target_sub_kegiatan_renja,
    a.t_sub_kegiatan1,
    a.t_sub_kegiatan2,
    a.t_sub_kegiatan3,
    a.t_sub_kegiatan4,
    a.satuan_sub_kegiatan

    from evsub_kegiatan as a where a.kode_sub_skpd='$kode_sub_skpd' and a.kode_sub_kegiatan='$kode_sub_kegiatan' and a.tahun='$_SESSION[tahun]'
    ) as pr on pr.kode_sub_skpd=a.kode_sub_skpd and pr.kode_sub_kegiatan=a.kode_sub_kegiatan)


    where 
    a.kode_sub_skpd='$kode_sub_skpd' and a.kode_sub_kegiatan='$kode_sub_kegiatan' 

    ");
foreach ($sqlie as $rowe) {

    ?>
              
              
                <table class="table">
                    <tr>
                        <td style="text-align:center; vertical-align: middle;width:20px">
                            <label>Target Renstra SKPD pada Tahun 2026<br> (Kondisi Akhir Periode Rencana)</label>
                        </td>
                        <td style="width:10px"></td>
                        <td style="text-align:center; vertical-align: middle;width:20px">
                            <label>Realisasi  Capaian sub_kegiatan Renstra SKPD <br> sampai dengan Renja SKPD Tahun <?php  echo ($_SESSION['tahun'])-1;?></label>
                        </td>
                        <td style="width:10px"></td>
                        <td style="text-align:center; vertical-align: middle;width:20px">
                            <label>Target Kinerja dan Anggaran Renja SKPD Tahun Berjalan yang dievaluasi (<?php  echo $_SESSION['tahun'];?>)</label>
                        </td>
                        <td style="width:10px"></td>
                        
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">
            <table>
             <tr><td>(K)</td><td><input type="text" id="k_target_sub_kegiatan_renstra" class="form-control" value="<?php echo $rowe['k_target_sub_kegiatan_renstra'] ?>" ></td></tr>
             <tr><td>(RP)</td><td><input type="text" id="rp_target_sub_kegiatan_renstra" class="form-control uang" value="<?php echo str_replace(",", ".",number_format( $rowe['rp_target_sub_kegiatan_renstra'])) ?>" ></td></tr>
            
             </table>
                           
                        </td>
                        <td style="width:50px"></td>
                        <td  style="vertical-align: top;">
            <table>
             <tr><td>(K)</td><td><input type="text" id="k_realisasi_sub_kegiatan_renstra" value="<?php echo $rowe['k_realisasi_sub_kegiatan_renstra'] ?>" class="form-control" ></td></tr>
             <tr><td>(Rp)</td><td><input type="text" id="rp_realisasi_sub_kegiatan_renstra" value="<?php echo str_replace(",", ".",number_format($rowe['rp_realisasi_sub_kegiatan_renstra'])); ?>" class="form-control uang" ></td></tr>
            </table>
                        </td>
                        <td style="width:50px"></td>
                         <td style="vertical-align: top;">
            <table>
              <tr><td>(K)</td><td><input type="text" id="target_sub_kegiatan_renja" class="form-control" value="<?php echo $rowe['target_sub_kegiatan_renja'] ?>"></td></tr>
            
            </table>
                         </td>
                         

                    </tr>
                </table>
             
              <table class="table">
                  <tr><th colspan="8" style="text-align: center;">Realisasi  Triwulan</th></tr>
                  <tr>
                    <th colspan="2" style="text-align: center;">I</th>
                    <th colspan="2" style="text-align: center;">II</th>
                    <th colspan="2" style="text-align: center;">III</th>
                    <th colspan="2" style="text-align: center;">IV</th>
                </tr>
                  <tr>
                    <td>Kinerja(K)</td>
                    <td><input type="text" id="t_sub_kegiatan1" class="form-control" value="<?php echo $rowe['t_sub_kegiatan1'] ?>"></td>
                    <td>Kinerja(K)</td>
                    <td><input type="text" id="t_sub_kegiatan2" class="form-control" value="<?php echo $rowe['t_sub_kegiatan2'] ?>"></td>
                    <td>Kinerja(K)</td>
                    <td><input type="text" id="t_sub_kegiatan3" class="form-control" value="<?php echo $rowe['t_sub_kegiatan3'] ?>"></td>
                    <td>Kinerja(K)</td>
                    <td><input type="text" id="t_sub_kegiatan4" class="form-control" value="<?php echo $rowe['t_sub_kegiatan4'] ?>"></td></tr>
              </table>

              <div class="modal-footer justify-content-between" style="background-image: linear-gradient(white,white,orange); border-radius: 18px;">
              
             <button style="float:right" class="btn btn-danger" data-dismiss="modal" >Batal</button>

             <?php
             if(empty($rowe['k_target_sub_kegiatan_renstra']))
             {
             ?>
             <button style="float:left" class="btn btn-success " data-dismiss="modal" onclick="inputsub_kegiatan()">Simpan</button>
             <?php
         }
         else
         {

            ?>
             <button style="float:left" class="btn btn-success " data-dismiss="modal" onclick="ubahsub_kegiatan()">Ubah</button>
        

            <?php 
        }
        ?>
             
            </div>
              
             <?php }

mysqli_close($koneksi);
         ?>