<div style="padding:5px;min-width:1700px">
<div style="padding:20px;"></div>
<button class="btn btnExcel" style="width:150px;text-align:center;">Export Excel</button></div>
<table id="view_laporan" class="cetakExcel" border="0" cellpadding="2" cellspacing="0" style="margin:10px;">
  <tbody>
    <tr>
      <td align="center" colspan="78" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;">LAPORAN PERKARA <?php echo $perkara_nama;?></td>
    </tr>
    <tr>
      <td align="center" colspan="78" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
    </tr>
    <tr>
      <td align="center" colspan="78" style="text-align: center;border:0px;font-size:14px;border-bottom:1px solid #000000;border-right:0px;">Bulan <?php echo fetch_montd($bulan);?> <?php echo $tahun;?></td>
    </tr>
  </tbody>

    <tr>
  <th rowspan=7>NO URUT</td>
  <th rowspan=7>NOMOR PERKARA</td>
  <th colspan=2 rowspan=5>NAMA</td>
  <th rowspan=7>KODE KLASIFIKASI</td>
  <th colspan=4 rowspan=4>TERDAKWA</td>
  <th colspan=5 rowspan=5>TANGGAL</td>
  <th colspan=4 rowspan=4>TERPIDANA</td>
  <th colspan=58>AMAR PUTUSAN</td>
  <th colspan=2 rowspan=7>REKAPITULASI</td>
 </tr>
 <tr>
  <th colspan=50 style="border-left: 0px">DIJATUHI PUTUSAN</td>
  <th colspan=4 rowspan=3 >BEBAS DARI DAKWAAN</td>
  <th colspan=4 rowspan=3 >LEPAS DARI TUNTUTAN</td>
 </tr>
 <tr>
  <th colspan=21 style="border-left: 0px">PIDANA POKOK</td>
  <th colspan=4 rowspan=2  >PIDANA TAMBAHAN</td>
  <th colspan=4 rowspan=2  >BERSYARAT</td>
  <th colspan=8  >TINDAKAN</td>
  <th colspan=13 >SUBSIDER</td>
 </tr>
 <tr>
  <th colspan=4  style="border-left: 0px">MATI</td>
  <th colspan=8  >PENJARA</td>
  <th colspan=4  >KURUNGAN</td>
  <th colspan=5  >DENDA</td>
  <th colspan=2 rowspan=2  >DIKEMBALIKAN PADA ORANG TUA</td>
  <th colspan=2 rowspan=2  >DIKEMBALIKAN PADA PEMERINTAH/NEGARA</td>
  <th colspan=4 rowspan=2  >REHABILITASI</td>
  <th colspan=4  >PENJARA</td>
  <th colspan=4  >KURUNGAN</td>
  <th colspan=5  >DENDA</td>
 </tr>
 <tr>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=4  >SEUMUR HIDUP</td>
  <th colspan=4  >WAKTU TERTENTU</td>
  <th colspan=2  style="border-left: 0px">DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  style="border-left: 0px">DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th rowspan=3  >JUMLAH (Rp)</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th rowspan=3  >JUMLAH (Rp)</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >DEWASA</td>
  <th colspan=2  >ANAK</td>
 </tr>
 <tr >
  <th rowspan=2  style="border-left: 0px">MAJELIS HAKIM</td>
  <th rowspan=2  >PP</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >PENDAFTARAN PERKARA</td>
  <th rowspan=2  >PENUNJUKAN MAJELIS HAKIM</td>
  <th rowspan=2  >SIDANG PERTAMA</td>
  <th rowspan=2  >PUTUSAN</td>
  <th rowspan=2  >MINUTASI</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th colspan=2  style="border-left: 0px">DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  style="border-left: 0px">DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  >ANAK</td>
  <th colspan=2  style="border-left: 0px">DEWASA</td>
  <th colspan=2  >ANAK</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
  <th rowspan=2  >L</td>
  <th rowspan=2  >P</td>
 </tr>
 <tr>
  <th  >L</td>
  <th  >P</td>
  <th  >L</td>
  <th  >P</td>
  <th  >P</td>
  <th  >L</td>
  <th  >P</td>
  <th  >L</td>
  <th  >P</td>
  <th  >L</td>
  <th  >P</td>
  <th  >L</td>
  <th  >P</td>
  <th  >L</td>
  <th  >P</td>
  <th  >P</td>
 </tr>
    <tr>
    <?php for ($a=1; $a<=76;$a++){
      echo "<td>".$a."</td>";
          }
      echo "<td colspan=\"2\">77</td>";
    ?>
    </tr>

  <?php
  $rekap = array();
  if($stat!=''){
    if($stat->num_rows>0){
      foreach ($stat->result() as $row) {
        array_push($rekap, $row);
        $total = $row->sisa + $row->putus_blm_minut + $row->med_blm_minut;
      }
    }
  }
  if($laporan!=''){
    if($laporan->num_rows>0){
      $i=0;
      foreach ($laporan->result() as $row) {
        $i++;
        echo "<tr>";
          echo "<td style='width:20px;'>".$i."</td>";
          echo "<td>".$row->nomor_perkara."</td>";
          echo "<td>".$row->majelis_hakim."</td>";
          echo "<td>".$row->panitera_pengganti_text."</td>";
          echo "<td>".$row->jenis_perkara_kode."</td>";
          echo "<td>".$row->terdakwa_dewasa_l."</td>";
          echo "<td>".$row->terdakwa_dewasa_p."</td>";
          echo "<td>".$row->terdakwa_anak_l."</td>";
          echo "<td>".$row->terdakwa_anak_p."</td>";
          echo "<td>".parse_date($row->tanggal_pendaftaran)."</td>";
          echo "<td>".parse_date($row->penetapan_majelis_hakim)."</td>";
          echo "<td>".parse_date($row->sidang_pertama)."</td>";
          echo "<td>".parse_date($row->tanggal_putusan)."</td>";
          echo "<td>".parse_date($row->tanggal_minutasi)."</td>";

          echo "<td>".$row->terpidana_dewasa_l."</td>";
          echo "<td>".$row->terpidana_dewasa_p."</td>";
          echo "<td>".$row->terpidana_anak_l."</td>";
          echo "<td>".$row->terpidana_anak_p."</td>";

          echo "<td>".$row->terpidana_mati_dewasa_l."</td>";
          echo "<td>".$row->terpidana_mati_dewasa_p."</td>";
          echo "<td>".$row->terpidana_mati_anak_l."</td>";
          echo "<td>".$row->terpidana_mati_anak_p."</td>";

          echo "<td>".$row->terpidana_seumurhdp_dewasa_l."</td>";
          echo "<td>".$row->terpidana_seumurhdp_dewasa_p."</td>";
          echo "<td>".$row->terpidana_seumurhdp_anak_l."</td>";
          echo "<td>".$row->terpidana_seumurhdp_anak_p."</td>";

          echo "<td>".$row->terpidana_wkttt_dewasa_l."</td>";
          echo "<td>".$row->terpidana_wkttt_dewasa_p."</td>";
          echo "<td>".$row->terpidana_wkttt_anak_l."</td>";
          echo "<td>".$row->terpidana_wkttt_anak_p."</td>";

          echo "<td>".$row->terpidana_kurungan_dewasa_l."</td>";
          echo "<td>".$row->terpidana_kurungan_dewasa_p."</td>";
          echo "<td>".$row->terpidana_kurungan_anak_l."</td>";
          echo "<td>".$row->terpidana_kurungan_anak_p."</td>";

          echo "<td>".$row->terpidana_denda_dewasa_l."</td>";
          echo "<td>".$row->terpidana_denda_dewasa_p."</td>";
          echo "<td>".$row->terpidana_denda_anak_l."</td>";
          echo "<td>".$row->terpidana_denda_anak_p."</td>";
          echo "<td>".$row->denda."</td>";

          echo "<td>".$row->pidana_tambahan_dewasa_l."</td>";
          echo "<td>".$row->pidana_tambahan_dewasa_p."</td>";
          echo "<td>".$row->pidana_tambahan_anak_l."</td>";
          echo "<td>".$row->pidana_tambahan_anak_p."</td>";

          echo "<td>".$row->pidana_bersyarat_dewasa_l."</td>";
          echo "<td>".$row->pidana_bersyarat_dewasa_p."</td>";
          echo "<td>".$row->pidana_bersyarat_anak_l."</td>";
          echo "<td>".$row->pidana_bersyarat_anak_p."</td>";

          echo "<td>".$row->kembalikan_org_tua_anak_l."</td>";
          echo "<td>".$row->kembalikan_org_tua_anak_p."</td>";
          echo "<td>".$row->kembalikan_pemerintah_anak_l."</td>";
          echo "<td>".$row->kembalikan_pemerintah_anak_p."</td>";

          echo "<td>".$row->rehabilitasi_dewasa_l."</td>";
          echo "<td>".$row->rehabilitasi_dewasa_p."</td>";
          echo "<td>".$row->rehabilitasi_anak_l."</td>";
          echo "<td>".$row->rehabilitasi_anak_p."</td>";

          echo "<td>".$row->subsider_penjara_dewasa_l."</td>";
          echo "<td>".$row->subsider_penjara_dewasa_p."</td>";
          echo "<td>".$row->subsider_penjara_anak_l."</td>";
          echo "<td>".$row->subsider_penjara_anak_p."</td>";

          echo "<td>".$row->subsider_kurungan_dewasa_l."</td>";
          echo "<td>".$row->subsider_kurungan_dewasa_p."</td>";
          echo "<td>".$row->subsider_kurungan_anak_l."</td>";
          echo "<td>".$row->subsider_kurungan_anak_p."</td>";

          echo "<td>".$row->subsider_denda_dewasa_l."</td>";
          echo "<td>".$row->subsider_denda_dewasa_p."</td>";
          echo "<td>".$row->subsider_denda_anak_l."</td>";
          echo "<td>".$row->subsider_denda_anak_p."</td>";
          echo "<td>".$row->denda."</td>";

          echo "<td>".$row->bebas_dakwaan_dewasa_l."</td>";
          echo "<td>".$row->bebas_dakwaan_dewasa_p."</td>";
          echo "<td>".$row->bebas_dakwaan_anak_l."</td>"; 
          echo "<td>".$row->bebas_dakwaan_anak_p."</td>"; 

          echo "<td>".$row->lepas_tuntutan_dewasa_l."</td>"; 
          echo "<td>".$row->lepas_tuntutan_dewasa_p."</td>"; 
          echo "<td>".$row->lepas_tuntutan_anak_l."</td>"; 
          echo "<td>".$row->lepas_tuntutan_anak_p."</td>"; 


          
          echo "<td style='width:150px;'>".parse_stat($i,1)."</td>";
          echo "<td>".parse_stat($i,2,$rekap)."</td>";
        echo "</tr>";
        
      }
      if($i<11){
        for ($x=$i+1; $x <=11; $x++) {
          echo "<tr>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";

            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";

            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";

            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";

            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";

            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";

            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            echo "<td></td>";
            
            echo "<td style='width:150px;'>".parse_stat($x,1)."</td>";
            echo "<td>".parse_stat($x,2,$rekap)."</td>";
          echo "</tr>";
        }
      }
    }
  }

  
  function parse_stat($x,$y,$rekap=NULL){
    if($x==1 AND $y==1){return '1. Sisa Bulan Lalu';}
    elseif($x==2 AND $y==1){return '  a. Belum Putus';}
    elseif($x==3 AND $y==1){return '  b. Sudah Putus Belum Minutasi';}
    elseif($x==4 AND $y==1){return '  ';}
    elseif($x==5 AND $y==1){return '2. Tambah Bulan Ini';}
    elseif($x==6 AND $y==1){return '3. Beban Bulan Ini';}
    elseif($x==7 AND $y==1){return '4. Belum Pembagian Majelis';}
    elseif($x==8 AND $y==1){return '5. Putus Bulan Ini';}
    elseif($x==9 AND $y==1){return '6. Minutir Bulan Ini';}
    elseif($x==10 AND $y==1){return '7. Belum Minutir Bulan Ini';}

    elseif($x==11 AND $y==1){return '8. Terdakwa';}
    elseif($x==12 AND $y==1){return '9. Terpidana';}
    
    elseif($x==1 AND $y==2){return $rekap[0]->sisa + $rekap[0]->putus_blm_minut + $rekap[0]->med_blm_minut;}
    elseif($x==2 AND $y==2){return $rekap[0]->sisa;}
    elseif($x==3 AND $y==2){return $rekap[0]->putus_blm_minut;}
    elseif($x==4 AND $y==2){return '';}
    elseif($x==5 AND $y==2){return $rekap[0]->masuk;}
    elseif($x==6 AND $y==2){return $rekap[0]->sisa + $rekap[0]->putus_blm_minut + $rekap[0]->med_blm_minut + $rekap[0]->masuk;}
    elseif($x==7 AND $y==2){return $rekap[0]->blm_majelis;}
    elseif($x==8 AND $y==2){return $rekap[0]->putus;}
    elseif($x==9 AND $y==2){return $rekap[0]->minut;}
    elseif($x==10 AND $y==2){return $rekap[0]->blm_minut;}
    elseif($x==11 AND $y==2){return $rekap[0]->terdakwa;}
    elseif($x==12 AND $y==2){return $rekap[0]->terpidana;}
    
  }
  ?>
</table>
</div>
<div style="padding:15px;"></div>
<script src="resources/js/jquery.table2excel.js"></script>
<script>
$(function() {
  $(".btnExcel").click(function(){
    $(".cetakExcel").table2excel({
      exclude: ".noExl",
      name: "Excel Document Name",
      filename: "Cetak Excel"
    });
  });
});
</script>