<?php 
    function  bulanlap($bln){
        switch  ($bln){
            case 1: return  "Jan"; break;
            case 2: return  "Feb"; break;
            case 3: return  "Mar"; break;
            case 4: return  "Apr"; break;
            case 5: return  "Mei"; break;
            case 6: return  "Juni"; break;
            case 7: return  "Juli"; break;
            case 8: return  "Agu"; break;
            case 9: return  "Sep"; break;
            case 10: return "Okt"; break;
            case 11: return "Nov"; break;
            case 12: return "Des"; break;
        }
    }
    $data=array();
    $exc=array(74,76,78,80,82);
?>
<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>
<div class="cssTabel">
<table id="view_laporan" class="cetakExcel" border="0" cellpadding="2" cellspacing="0" style="margin:10px;">
	<tbody>
		<tr>
			<td align="center" colspan="84" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;"><?php echo $perkara_nama;?></td>
		</tr>
		<tr>
			<td align="center" colspan="84" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
		</tr>
		<tr>
			<td align="center" colspan="84" style="text-align: center;border:0px;font-size:14px;border-bottom:1px solid #000000;border-right:0px;">Tahun <?php echo $tahun;?></td>
		</tr>
	</tbody>
    <?php $n=12;?>
  <tr height="20">
    <th rowspan="3">No</th>
    <th rowspan="3">Jenis Perkara </th>
    <th colspan="<?php echo $n;?>" rowspan="2">Perkara yang Dimediasi</th>
    <th colspan="<?php echo $n * 3;?>">Berhasil</th>
    <th colspan="<?php echo $n;?>" rowspan="2">Tidak Berhasil</th>
    <th colspan="<?php echo $n;?>" rowspan="2">Tidak Dapat Dilaksanakan</th>
    <th colspan="10">Jumlah Hasil Mediasi dan % Hasil Mediasi Terhada\p Jumlah Perkara Mediasi</th>
  </tr>
  <tr height="20">
    <th colspan="<?php echo $n;?>">Akta Perdamaian/Putusan</th>
    <th colspan="<?php echo $n;?>">Berhasil Sebagian</th>
    <th colspan="<?php echo $n;?>">Pencabutan</th>
    <th colspan="6">Berhasil</th>
    <th rowspan="2">Tidak Berhasil</th>
    <th rowspan="2">%</th>
    <th rowspan="2">Tidak Dapat Dilaksanakan</th>
    <th rowspan="2">%</th>
  </tr>
  <tr height="20">
    <?php 
        for ($j=1; $j <=6 ; $j++) { 
            for ($i=1; $i <=$n ; $i++) { 
                echo '<th>'.bulanlap($i).'</th>';        
            }   
        }
    ?>
    <th width="54" style="border-left:0px;">Akta Perdamaian/Putusan</th>
    <th width="59">%</th>
    <th width="51">Berhasil Sebagian</th>
    <th width="51">%</th>
    <th width="41">Pencabutan</th>
    <th width="44">%</th>
  </tr>
    <tr>
    <?php 
        for ($a=1; $a<=(12 + $n*6);$a++){
            echo "<th style='width:20px;'>".$a."</th>";
        }
    ?>
    </tr>
    <?php
    if($rekap!=''){
        if($rekap->num_rows>0){
            $i=0;
            for ($i=1; $i <= $rekap->num_rows(); $i++) { 
                echo '<tr>';
                echo '<td style="text-align:center">'.$i.'</td>';
                echo '<td style="text-align:left">'.array_values($rekap->row_array($i-1))[0].'</td>';   
                for ($j=1; $j <=(12 + $n*6)-2; $j++) {
                    echo '<td style="text-align:center">'.$this->templatehelper->isnull(array_values($rekap->row_array($i-1))[$j]).'</td>';
                    
                    $k=array_values($rekap->row_array($i-1))[$j];
                    if(in_array($j, $exc)){
                        $k=0;
                    }
                    $data[$j-1]+=$k;
                }               
                echo '</tr>';
            }
            for ($j=1; $j <=12; $j++) {
                $jml_mediasi+=$data[$j-1];    
            }
            if($jml_mediasi>0){
                if($data[72]>0){
                    $data[73]=round($data[72]/$jml_mediasi*100).'%';   
                }
                if($data[74]>0){
                    $data[75]=round($data[74]/$jml_mediasi*100).'%';   
                }
                if($data[76]>0){
                    $data[77]=round($data[76]/$jml_mediasi*100).'%'; 
                }
                if($data[78]>0){
                    $data[79]=round($data[78]/$jml_mediasi*100).'%'; 
                }
                if($data[80]>0){
                    $data[81]=round($data[80]/$jml_mediasi*100).'%';   
                }
            }
            echo "<td colspan='2' style ='text-align:center ;font-weight:bold'>Total</td>";
            for ($j=1; $j <=(12 + $n*6)-2; $j++) {
                echo "<td style ='text-align:center ;font-weight:bold'>".$data[$j-1]."</td>";
            }                 
        }
    }
    ?>
    <tr height="20">
        <td colspan="84" style="border:none;"> </td>
    </tr>
    <tr height="20">
        <td colspan="14" style="border:none;text-align:center;"><br>Mengetahui<br>Ketua <?php echo ucwords(strtolower($nama_pn));?></td>
        <td colspan="60" style="border:none;"></td>
        <td colspan="10" style="border:none;text-align:center;"><?php echo str_replace('Pengadilan Negeri ', '', str_replace('Pengadilan Agama ', '', str_replace("Mahkamah Syar'iyah ", '', ucwords(strtolower($nama_pn))))).', '.$this->templatehelper->convertKeTglIndo(date("Y/m/d"));?><br><br>Panitera</td>
    </tr>
    <tr height="60">
        <td colspan="84" style="border:none;"> </td>
    </tr>
    <tr height="20">
        <td colspan="14" style="border:none;text-align:center;"><?php echo '<u>'.$nama_ketua.'</u><br>NIP.'.$nip_ketua;?></td>
        <td colspan="60" style="border:none;"></td>
        <td colspan="10" style="border:none;text-align:center;"><?php echo '<u>'.$nama_pan.'</u><br>NIP.'.$nip_pan;?></td>
    </tr>
</table>
</div>
<div style="padding:15px;"></div>
</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>