<?php 
    $data=array();
    $exc=array(5,7,9,11,13,15,17);
?>
<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="22" 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="22" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
		</tr>
		<tr>
			<td align="center" colspan="22" style="text-align: center;border:0px;font-size:14px;border-bottom:1px solid #000000;border-right:0px;">Tahun <?php echo $tahun;?></td>
		</tr>
	</tbody>
  <tr height="20">
    <th rowspan="2">No.</th>
    <th rowspan="2">Bulan</th>
    <th rowspan="2" width="64">Jumlah Para Pihak Yang Melakukan Mediasi</th>
    <th colspan="4">Jumlah dan % Pihak Berdasarkan Jenis Kelamin</th>
    <th rowspan="2" width="64">Jumlah Diffabel</th>
    <th rowspan="2" width="64">%</th>
    <th rowspan="2" width="64">Jumlah Non Diffabel</th>
    <th rowspan="2" width="64">%</th>
    <th rowspan="2" width="64">Jumlah Pihak Individual</th>
    <th rowspan="2" width="64">%</th>
    <th rowspan="2" width="64">Jumlah Pemerintah</th>
    <th rowspan="2" width="64">% Pihak Pemerintah</th>
    <th rowspan="2" width="64">Jumlah BUMN</th>
    <th rowspan="2" width="64">% Pihak BUMN</th>
  </tr>
  <tr height="20">
    <th width="64">Pria</th>
    <th width="64">%</th>
    <th width="64">Wanita</th>
    <th width="64">%</th>
  </tr>


    <tr>
    <?php for ($a=1; $a<=17;$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 <=15; $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+2]+=$k;
                }               
                echo '</tr>';
            }
            $jml_mediasi=$data[3];
            if($jml_mediasi>0){
                if($data[4]>0){
                    $data[5]=round($data[4]/$jml_mediasi*100).'%';   
                }
                if($data[6]>0){
                    $data[7]=round($data[6]/$jml_mediasi*100).'%';   
                }
                if($data[8]>0){
                    $data[9]=round($data[8]/$jml_mediasi*100).'%'; 
                }
                if($data[10]>0){
                    $data[11]=round($data[10]/$jml_mediasi*100).'%'; 
                }
                if($data[12]>0){
                    $data[13]=round($data[12]/$jml_mediasi*100).'%';   
                }
                if($data[14]>0){
                    $data[15]=round($data[14]/$jml_mediasi*100).'%';   
                }
                if($data[16]>0){
                    $data[17]=round($data[16]/$jml_mediasi*100).'%';   
                }
            }
            echo "<td colspan='2' style ='text-align:center ;font-weight:bold'>Total</td>";
            for ($j=3; $j <=17; $j++) {
                echo "<td style ='text-align:center ;font-weight:bold'>".$data[$j]."</td>";
            }                 
        }
    }
	?>
    <tr height="20">
        <td colspan="17" style="border:none;"> </td>
    </tr>
    <tr height="20">
        <td colspan="7" style="border:none;text-align:center;"><br>Mengetahui<br>Ketua <?php echo ucwords(strtolower($nama_pn));?></td>
        <td colspan="5" style="border:none;"></td>
        <td colspan="5" 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="17" style="border:none;"> </td>
    </tr>
    <tr height="20">
        <td colspan="7" style="border:none;text-align:center;"><?php echo '<u>'.$nama_ketua.'</u><br>NIP.'.$nip_ketua;?></td>
        <td colspan="5" style="border:none;"></td>
        <td colspan="5" 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>
<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>