      
<?php
include '../../../config/koneksi.php';
session_start();
?>
<!DOCTYPE html>
<html>
   
   
    <head>
  

     
    </head>
    <body>
   
   
                <?php


$sqlsskpd  = mysqli_query($koneksi, "SELECT kode_sub_skpd,sub_skpd from sub_skpd
    ");
foreach ($sqlsskpd as $rowsskpd) {

    ?>
    <strong><?php echo $rowsskpd['kode_sub_skpd'] . ' '. $rowsskpd['sub_skpd']?></strong>
<table width="100%"  id="example1s" class="table table-bordered table-striped" border="1">

       <tr style="text-align:center ; background-color:lightgrey" >
       <th style="text-align:center ;vertical-align: middle;"  >Kode </th>
       <th colspan="7" style="text-align:center ;vertical-align: middle;"   >Urusan/SKPD/Sub SKPD/Bidang/program/Kegiatan/Sub_Kegiatan <br>/Akun</th>
      
       <th style="text-align:center ;vertical-align: middle;"  >Jumlah </th>
       <?php

$sqlsdh  = mysqli_query($koneksi, "SELECT 
  sumber_dana from renja where kode_sub_skpd='$rowsskpd[kode_sub_skpd]'
  group by sumber_dana
  order by sumber_dana
    ");
foreach ($sqlsdh as $rowsdh) {

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



$sqlurusan  = mysqli_query($koneksi, "SELECT 
    a.kode_urusan,a.urusan,
    count(distinct a.kode_urusan)as cu,
    count(distinct b.kode_bidang_urusan)as cb,
    count(distinct c.kode_program)as cp,
    count(distinct d.kode_kegiatan)as ck,
    count(distinct e.kode_sub_kegiatan)as cs,
    count(distinct f.id_renja)as cr,
    sum(f.rincian) as total
  
    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
    
    where g.kode_sub_skpd='$rowsskpd[kode_sub_skpd]'
    group by a.kode_urusan
    order by a.kode_urusan
    ");
foreach ($sqlurusan as $rowurusan) {

    ?>
    <tr>
        <td><strong><?php echo $rowurusan["kode_urusan"]; ?></strong></td>
<td colspan="7"><strong><?php echo $rowurusan["urusan"]; ?></strong></td>

<td style="text-align:right;"><strong><?php echo $rowurusan["total"]; ?></strong></td>

<?php

$sqlsdu  = mysqli_query($koneksi, "SELECT 
     a.sumber_dana,sd.sumber from
      ((renja as a)
      left join
      (select sumber_dana, sum(rincian) as sumber from renja where kode_sub_skpd='$rowsskpd[kode_sub_skpd]' and kode_urusan='$rowurusan[kode_urusan]' group by sumber_dana)as sd on sd.sumber_dana=a.sumber_dana)  
      where a.kode_sub_skpd='$rowsskpd[kode_sub_skpd]' 
  group by a.sumber_dana
   
    ");
foreach ($sqlsdu as $rowsdu) {

    ?>

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

$sqlbidang  = mysqli_query($koneksi, "SELECT 
    b.kode_bidang_urusan,b.bidang_urusan,h.kode_skpd,
    count(distinct a.kode_urusan)as cu,
    count(distinct b.kode_bidang_urusan)as cb,
    count(distinct c.kode_program)as cp,
    count(distinct d.kode_kegiatan)as ck,
    count(distinct e.kode_sub_kegiatan)as cs,
    count(distinct f.id_renja)as cr,
    sum(f.rincian) as total
  
    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
    
    where g.kode_sub_skpd='$rowsskpd[kode_sub_skpd]'
    and b.kode_urusan='$rowurusan[kode_urusan]'
    group by b.kode_bidang_urusan
    order by b.kode_bidang_urusan
    ");
foreach ($sqlbidang as $rowbidang) {

    ?>
    <tr>
        <td><strong><?php echo $rowbidang["kode_bidang_urusan"]; ?></strong></td>

        <td></td>
<td colspan="6"><strong><?php echo $rowbidang["bidang_urusan"]; ?></strong></td>

<td style="text-align:right;"><strong><?php echo $rowbidang["total"]; ?></strong></td>
<?php

$sqlsdp  = mysqli_query($koneksi, "SELECT 
     a.sumber_dana,sd.sumber from
      ((renja as a)
      left join
      (select sumber_dana, sum(rincian) as sumber from renja where kode_sub_skpd='$rowsskpd[kode_sub_skpd]' and kode_bidang_urusan='$rowbidang[kode_bidang_urusan]' group by sumber_dana)as sd on sd.sumber_dana=a.sumber_dana)  
      where a.kode_sub_skpd='$rowsskpd[kode_sub_skpd]' 
  group by a.sumber_dana
  order by a.sumber_dana
   
    ");
foreach ($sqlsdp as $rowsdp) {

    ?>

     <?php
 }
     ?>
     </tr>

     <?php

$sqlskpd  = mysqli_query($koneksi, "SELECT 
    h.kode_skpd,h.skpd,
    count(distinct a.kode_urusan)as cu,
    count(distinct b.kode_bidang_urusan)as cb,
    count(distinct c.kode_program)as cp,
    count(distinct d.kode_kegiatan)as ck,
    count(distinct e.kode_sub_kegiatan)as cs,
    count(distinct f.id_renja)as cr,
    sum(f.rincian) as total
  
    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
    
    where g.kode_sub_skpd='$rowsskpd[kode_sub_skpd]'
    and b.kode_bidang_urusan='$rowbidang[kode_bidang_urusan]'
    group by h.kode_skpd
    order by h.kode_skpd
    ");
foreach ($sqlskpd as $rowskpd) {

    ?>
    <tr>
        <td><strong><?php echo $rowskpd["kode_skpd"]; ?></strong></td>
        <td></td>
        <td></td>
<td colspan="5"><strong><?php echo $rowskpd["skpd"]; ?></strong></td>

<td style="text-align:right;"><strong><?php echo $rowskpd["total"]; ?></strong></td>
<?php

$sqlsds  = mysqli_query($koneksi, "SELECT 
     a.sumber_dana,sd.sumber from
      ((renja as a)
      left join
      (select sumber_dana, sum(rincian) as sumber from renja where kode_sub_skpd='$rowsskpd[kode_sub_skpd]' and kode_bidang_urusan='$rowbidang[kode_bidang_urusan]' group by sumber_dana)as sd on sd.sumber_dana=a.sumber_dana)  
      where a.kode_sub_skpd='$rowsskpd[kode_sub_skpd]' 
  group by a.sumber_dana
  order by a.sumber_dana
   
    ");
foreach ($sqlsds as $rowsds) {

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


     <?php

$sqlsubskpd  = mysqli_query($koneksi, "SELECT 
    g.kode_sub_skpd,g.sub_skpd,b.kode_bidang_urusan,
    count(distinct a.kode_urusan)as cu,
    count(distinct b.kode_bidang_urusan)as cb,
    count(distinct c.kode_program)as cp,
    count(distinct d.kode_kegiatan)as ck,
    count(distinct e.kode_sub_kegiatan)as cs,
    count(distinct f.id_renja)as cr,
    sum(f.rincian) as total
  
    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
    
    where g.kode_sub_skpd='$rowsskpd[kode_sub_skpd]'
    and b.kode_bidang_urusan='$rowbidang[kode_bidang_urusan]'
    and g.kode_skpd='$rowskpd[kode_skpd]'
    group by g.kode_sub_skpd
    order by g.kode_sub_skpd
    ");
foreach ($sqlsubskpd as $rowsubskpd) {

    ?>
    <tr>
        <td><strong><?php echo $rowsubskpd["kode_sub_skpd"]; ?></strong></td>
         <td></td>
        <td></td>
         <td></td>
        
<td colspan="4"><strong><?php echo $rowsubskpd["sub_skpd"]; ?></strong></td>

<td style="text-align:right;"><strong><?php echo $rowsubskpd["total"]; ?></strong></td>
<?php

$sqlsdss  = mysqli_query($koneksi, "SELECT 
     a.sumber_dana,sd.sumber from
      ((renja as a)
      left join
      (select sumber_dana, sum(rincian) as sumber from renja where kode_sub_skpd='$rowsskpd[kode_sub_skpd]' and kode_bidang_urusan='$rowbidang[kode_bidang_urusan]' group by sumber_dana)as sd on sd.sumber_dana=a.sumber_dana)  
      where a.kode_sub_skpd='$rowsskpd[kode_sub_skpd]' 
  group by a.sumber_dana
  order by a.sumber_dana
   
    ");
foreach ($sqlsdss as $rowsdss) {

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


     <?php

$sqlprogram = mysqli_query($koneksi, "SELECT 
    c.kode_program,c.program,
    count(distinct a.kode_urusan)as cu,
    count(distinct b.kode_bidang_urusan)as cb,
    count(distinct c.kode_program)as cp,
    count(distinct d.kode_kegiatan)as ck,
    count(distinct e.kode_sub_kegiatan)as cs,
    count(distinct f.id_renja)as cr,
    sum(f.rincian) as total
  
    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
    
    where g.kode_sub_skpd='$rowsskpd[kode_sub_skpd]'
    and c.kode_bidang_urusan='$rowsubskpd[kode_bidang_urusan]'
    group by c.kode_program
    order by c.kode_program
    ");
foreach ($sqlprogram as $rowprogram) {

    ?>
    <tr>
        <td><strong><?php echo $rowprogram["kode_program"]; ?></strong></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
<td colspan="3"><strong><?php echo $rowprogram["program"]; ?></strong></td>

<td style="text-align:right;"><strong><?php echo $rowprogram["total"]; ?></strong></td>
<?php

$sqlsdp  = mysqli_query($koneksi, "SELECT 
     a.sumber_dana,sd.sumber from
      ((renja as a)
      left join
      (select sumber_dana, sum(rincian) as sumber from renja where kode_sub_skpd='$rowsskpd[kode_sub_skpd]' and kode_program='$rowprogram[kode_program]' group by sumber_dana)as sd on sd.sumber_dana=a.sumber_dana)  
      where a.kode_sub_skpd='$rowsskpd[kode_sub_skpd]' 
  group by a.sumber_dana
  order by a.sumber_dana
   
    ");
foreach ($sqlsdp as $rowsdp) {

    ?>
   
     <?php
 }
     ?>

     </tr>




   


     
        <?php
 
    
 
    


}
}
}
}
}
?>





  </table>

<?php
}
mysqli_close($koneksi);
?> 


 
</body>
</html>