<div class="centering" style="padding:5px;min-width:1024px;margin: 0% auto 25px;">
<div style="padding:5px;"></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;font-size:14px; width:80% ">
	<tbody>
		<tr>
			<td align="center" colspan="22" 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="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);?> <?php echo $tahun;?></td>
		</tr>
	</tbody>
	<tr height="20">
	    <th width="5%" rowspan="2">No</th>
	    <th width="20%" rowspan="2">Jenis Perkara</th>
	    <th width="7%" rowspan="2">Jumlah</th>
	    <th width="7%" rowspan="2">Persentase</th>
	    <th colspan="3">Karakteristik Perkara</th>
	    <th colspan="4">Status Penyelesaian</th>
  </tr>
  <tr>
  	<th style="border-left: 0px none;" width="7%">Non Ganti Kerugian</th>
  	<th width="7%">Jumlah Petitum </br> (Ganti Kerugian)</th>
  	<th width="7%">Jumlah Kabul </br>(Ganti Kerugian)</th>
  	<th width="7%">Perdamaian</th>
  	<th width="7%">Penetapan </br> Dismissal</th>
  	<th width="7%">Penetapan </br> Gugur</th>
  	<th width="7%">Putusan</th>
  </tr>
  <?php
  	function isNOOL($data){
		if(($data==0)or(empty($data))){
			return "-";
		} else {
			return $data;
		}
	}
  	if($laporan!=''){
		if($laporan->num_rows>0){
			$i=0;
			$jumPerkaraDiterima = 0;
			$jumPerkaraKerugianNULL = 0;
			$jumNilaiSengketa = 0;
			$jumGantiKerugian = 0;
			$jumPerdamaian = 0;
			$jumDismissal = 0;
			$jumGugur = 0;
			$jumPutusan = 0;
			$jumProsentasePerkara = 0;
			foreach ($laporan->result() as $row) {
				$i++;
				$jumPerkaraDiterima += $row->perkaraDiterima; 
				$jumPerkaraKerugianNULL += $row->perkaraKerugianNULL;
				$jumNilaiSengketa += $row->jumlahNilaiSengketa;
				$jumGantiKerugian += $row->jumlahGantiKerugian;
				$jumPerdamaian += $row->jumlahPerdamaian;
				$jumDismissal += $row->jumlahDismissal;
				$jumGugur += $row->jumlahGugur;
				$jumPutusan += $row->jumlahPutusan;

				if(!empty($row->totalDiterima)){
					$prosentasePerkara = ($row->perkaraDiterima/$row->totalDiterima)*100;
					$jumProsentasePerkara += $prosentasePerkara;
				} else {
					$prosentasePerkara = '';
					//$jumProsentasePerkara = 0;
				}


				




				echo "<tr>";
					echo "<td style='width:20px;'><div align='center'>".$i."</div></td>";
					echo "<td>".$row->namaJenisPerkara."</td>";
					echo "<td><div align='center'>".isNOOL($row->perkaraDiterima)."</div></td>";
					echo "<td><div align='center'>".isNOOL(round($prosentasePerkara))."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->perkaraKerugianNULL)."</div></td>";
					echo "<td><div align='center'>".isNOOL(number_format($row->jumlahNilaiSengketa))."</div></td>";
					echo "<td><div align='center'>".isNOOL(number_format($row->jumlahGantiKerugian))."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->jumlahPerdamaian)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->jumlahDismissal)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->jumlahGugur)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->jumlahPutusan)."</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($jumProsentasePerkara)."</div></td>";
					echo "<td><div align='center'>".isNOOL($jumPerkaraKerugianNULL)."</div></td>";
					echo "<td><div align='center'>".isNOOL(number_format($jumNilaiSengketa))."</div></td>";
					echo "<td><div align='center'>".isNOOL(number_format($jumGantiKerugian))."</div></td>";
					echo "<td><div align='center'>".isNOOL($jumPerdamaian)."</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 "</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>