<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="cssTable">
<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;">Bulan <?php echo fetch_montd($bulan);?> Tahun <?php echo $tahun;?></td>
		</tr>
	</tbody>
  <tr height="20">
    <th rowspan="3" height="60" width="64">No</th>
    <th rowspan="3" width="241">Status Mediator</th>
    <th rowspan="3" width="64">Jumlah Perkara Yang Dimediasi</th>
    <th colspan="10" width="640">Jumlah Hasil Mediasi dan % Hasil Mediasi Terhadap Jumlah Perkara Mediasi</th>
  </tr>
  <tr height="20">
    <th colspan="6" height="20" style="border-left:0px;">Berhasil</th>
    <th rowspan="2" width="64">Tidak Berhasil</th>
    <th rowspan="2" width="64">%</th>
    <th rowspan="2" width="64">Tidak Dapat Dilaksanakan</th>
    <th rowspan="2" width="64">%</th>
  </tr>
  <tr height="20">
    <th height="20" width="64" style="border-left:0px;">Akta Perdamaian/Putusan</th>
    <th width="64">%</th>
    <th width="64">Berhasil Sebagian</th>
    <th width="64">%</th>
    <th width="64">Pencabutan</th>
    <th width="64">%</th>
  </tr>


    <tr>
    <?php for ($a=1; $a<=13;$a++){
        echo "<th style='width:20px;'>".$a."</th>";
          }
    ?>
    </tr>

	<?php
	if($laporan!=''){
		if($laporan->num_rows>0){
			$i=0;
			$jml_mediasi=0;
			$jml_berhasil_akta=0;
			$jml_berhasil_sebagian=0;
			$jml_berhasil_cabut=0;
			$jml_tdk_berhasil=0;
			$jml_tdk_laksana=0;
			$persen_berhasil_akta='-';
			$persen_berhasil_sebagian='-';
			$persen_berhasil_cabut='-';
			$persen_tdk_berhasil='-';
			$persen_tdk_laksana='-';

			for ($i=1; $i <= $laporan->num_rows(); $i++) { 
  				echo '<tr>';
  				echo '<td style="text-align:center">'.$i.'</td>';
  				echo '<td style="text-align:left">'.array_values($laporan->row_array($i-1))[0].'</td>';	
  				for ($j=1; $j <= 11; $j++) {
  					echo '<td style="text-align:center">'.$this->templatehelper->isnull(array_values($laporan->row_array($i-1))[$j]).'</td>';
  				}  				
  				echo '</tr>';
  				$jml_mediasi=$jml_mediasi+array_values($laporan->row_array($i-1))[1];
				$jml_berhasil_akta=$jml_berhasil_akta+array_values($laporan->row_array($i-1))[2];
				$jml_berhasil_sebagian=$jml_berhasil_sebagian+array_values($laporan->row_array($i-1))[4];
				$jml_berhasil_cabut=$jml_berhasil_cabut+array_values($laporan->row_array($i-1))[6];
				$jml_tdk_berhasil=$jml_tdk_berhasil+array_values($laporan->row_array($i-1))[8];
				$jml_tdk_laksana=$jml_tdk_laksana+array_values($laporan->row_array($i-1))[10];
  			}
  			if($jml_mediasi>0){
  				if($jml_berhasil_akta>0){
  					$persen_berhasil_akta=round($jml_berhasil_akta/$jml_mediasi*100).'%';	
  				}
  				if($jml_berhasil_sebagian>0){
  					$persen_berhasil_sebagian=round($jml_berhasil_sebagian/$jml_mediasi*100).'%';	
  				}
  				if($jml_berhasil_cabut>0){
  					$persen_berhasil_cabut=round($jml_berhasil_cabut/$jml_mediasi*100).'%';	
  				}
  				if($jml_tdk_berhasil>0){
  					$persen_tdk_berhasil=round($jml_tdk_berhasil/$jml_mediasi*100).'%';	
  				}
  				if($jml_tdk_laksana>0){
  					$persen_tdk_laksana=round($jml_tdk_laksana/$jml_mediasi*100).'%';	
  				}
  			}
			echo "<td colspan='2' style ='text-align:center ;font-weight:bold'>Total</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$jml_mediasi."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$jml_berhasil_akta."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$persen_berhasil_akta."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$jml_berhasil_sebagian."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$persen_berhasil_sebagian."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$jml_berhasil_cabut."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$persen_berhasil_cabut."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$jml_tdk_berhasil."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$persen_tdk_berhasil."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$jml_tdk_laksana."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$persen_tdk_laksana."</td>";
		}
	}
	?>
	<tr height="20">
    	<td colspan="13" style="border:none;"> </td>
  	</tr>
	<tr height="20">
		<td colspan="5" style="border:none;text-align:center;"><br>Mengetahui<br>Ketua <?php echo ucwords(strtolower($nama_pn));?></td>
		<td colspan="3" 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 cols	pan="13" style="border:none;"> </td>
	</tr>
	<tr height="20">
		<td colspan="5" style="border:none;text-align:center;"><?php echo '<u>'.$nama_ketua.'</u><br>NIP.'.$nip_ketua;?></td>
		<td colspan="3" 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>
<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>