<style type="text/css">
  .tabelLap{
    font-size:10px;
    border:0.1px solid #ddd;
  }
  .tabelLap th{
    color:#fff;
    border:0.1px solid #ddd;
    font-weight: bold;
  }
  .tabelLap td{
    color:#333;
    border:0.1px solid #ddd;
    font-weight: normal;
  }
</style>
<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" border="0" cellpadding="2" cellspacing="0" style="margin:10px;min-width:1813;">
  <tbody>
    <tr>
      <td align="center" colspan="16" 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="16" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
    </tr>
    <tr>
      <td align="center" colspan="16" style="text-align: center;border:0px;font-size:14px;">Bulan <?php echo fetch_montd($bulan);?> <?php echo $tahun;?></td>
    </tr>
  </tbody>
</table>

<table width="1813" class="cetakExcel tabelLap" cellspacing="0">
  <tr>
    <th width="48" rowspan="2" bgcolor="#5fb85c">No<br />
    Urut</th>
    <th width="163" rowspan="2" bgcolor="#5fb85c" >Nomor Perkara</th>
    <th colspan="2" bgcolor="#5fb85c" >Nama</th>
    <th width="77" rowspan="2" bgcolor="#5fb85c" >Kode Klasifikasi</th>
    <th width="200" rowspan="2" bgcolor="#5fb85c" >Nama Pemohon</th>
    <th width="200" rowspan="2" bgcolor="#5fb85c" >Nama Termohon</th>
    <th colspan="6" bgcolor="#5fb85c" >Tanggal</th>
    <th colspan="2" bgcolor="#5fb85c" >Amar Putusan</th>
    <th width="166" rowspan="2" colspan='2' bgcolor="#5fb85c" >Rekapitulasi</th>
  </tr>
  <tr>
    <th width="200" height="61" bgcolor="#5fb85c" >Majelis Hakim</th>
    <th width="200" bgcolor="#5fb85c" >PP</th>
    <th width="80" bgcolor="#5fb85c" >Pendaftaran Perkara</th>
    <th width="80" bgcolor="#5fb85c" >Penunjukan Majelis Hakim</th>
    <th width="80" bgcolor="#5fb85c" >Sidang Pertama</th>
    <th width="80" bgcolor="#5fb85c" >Putusan</th>
    <th width="80" bgcolor="#5fb85c" >Minutasi</th>
    <th width="80" bgcolor="#5fb85c" >Pemberitahuan Putusan</th>
    <th width="93" bgcolor="#5fb85c" >Diterima</th>
    <th width="81" bgcolor="#5fb85c" >Ditolak</th>
    
  </tr>
    <tr>
    <?php for ($a=1; $a<=15;$a++){
      echo "<th bgcolor='#5fb85c' >".$a."</th>";
          }
      echo "<th bgcolor='#5fb85c' colspan='2' >16</th>";
    ?>
    </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 class='isitabel'>";
          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->pihak1_text."</td>";
          echo "<td>".$row->pihak2_text."</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>".parse_date($row->tanggal_pemberitahuan_putusan)."</td>";

          echo "<td>".$row->diterima."</td>"; 
          echo "<td>".$row->ditolak."</td>"; 
          

          
          echo "<td style='width:150px;'>".parse_stat($i,1)."</td>";
          echo "<td style='border-left:0px solid #fff;border-right:1px solid #ddd;border-bottom:0px solid #fff;'>".parse_stat($i,2,$rekap)."</td>";
        echo "</tr>";
        
      }
      if($i<11){
        for ($x=$i+1; $x <=11; $x++) {
          echo "<tr class='isitabel' style='border-left:0px solid #fff;border-right:1px solid #ddd;border-bottom:0px solid #fff;'>";
            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 style='border-left:0px solid #fff;border-right:1px solid #ddd;border-bottom:0px solid #fff;'>".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 '6. Minutir Bulan Ini';}
    elseif($x==9 AND $y==1){return '7. Belum Minutir Bulan Ini';}

    elseif($x==10 AND $y==1){return '8. Pemohon';}
    elseif($x==11 AND $y==1){return '9. Termohon';}
    
    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]->minut;}
    elseif($x==9 AND $y==2){return $rekap[0]->blm_minut;}
    elseif($x==10 AND $y==2){return $rekap[0]->terdakwa;}
    elseif($x==11 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>