<div class="centering" style="padding:5px;min-width:1024px;margin: 0% auto 25px;">
<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;width:800px;">
	<tbody>
		<tr><td align="center" colspan="22" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;">LAPORAN <?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;"><?php echo $tahun;?></td></tr>
	</tbody>
	<tr height="20">
	    <th width="5%" rowspan="2">No</th>
	    <th width="15%" rowspan="2">Periode</th>
	    <th width="10%" rowspan="2">Jumlah Perkara Diterima</th>
	    <th width="10%" rowspan="2">Jumlah Perkara Diputus</th>
	    <th colspan="4">Status Penyelesaian Perkara</th>
	    <th colspan="2">Jenis Kelamin</th>
  </tr>
  <tr>
  	<th width="10%" style='border-left:0px;'>Akta Perdamaian</th>
  	<th width="10%">Penetapan Dismissal</th>
  	<th width="10%">Penetapan Gugur</th>
  	<th width="10%">Putusan</th>
  	<th width="10%">Laki - Laki</th>
  	<th width="10%">Perempuan</th>
  </tr>
  <?php
  	function isNOOL($data){
		if(($data==0)or(empty($data))){
			return "-";
		} else {
			return $data;
		}
	}
  	if($rekap!=''){
		if($rekap->num_rows>0){
			$i=0;
			$jumPerkaraDiterima = 0;
			$jumPerkaraPutus  = 0;
			$jumAktaPerdamaian = 0;
			$jumPutusan = 0;
			$jumLaki = 0;
			$jumPerempuan = 0;  
			$jumDismissal = 0;
			$jumGugur = 0;
			foreach ($rekap->result() as $row) {$i++;
				$jumPerkaraDiterima += $row->perkara_diterima;
				$jumPerkaraPutus  += $row->perkara_putus;
				$jumAktaPerdamaian += $row->akta_perdamaian;
				$jumDismissal += $row->dismissal;
				$jumGugur += $row->penetepan_gugur;
				$jumPutusan += $row->putusan;
				$jumLaki += $row->laki2;
				$jumPerempuan += $row->perempuan;  
				echo "<tr>";
					echo "<td style='width:20px;'><div align='center'>".$i."</div></td>";
					echo "<td>".$row->bulan_nama."</td>";
					echo "<td><div align='center'>".isNOOL($row->perkara_diterima)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->perkara_putus)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->akta_perdamaian)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->dismissal)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->penetepan_gugur)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->putusan)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->laki2)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->perempuan)."</div></td>";
				echo "</tr>";
			}
			echo "<tr>";
				echo "<td colspan='2'><div align='center'>TOTAL</div></td>";
				echo "<td><div align='center'>".isNOOL($jumPerkaraDiterima)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumPerkaraPutus)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumAktaPerdamaian)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumDismissal)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumGugur)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumPutusan)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumLaki)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumPerempuan)."</div></td>";
			echo "</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>