<div class="centering" style="padding:5px;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;">
	<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 height="60" width="64">No</th>
    <th width="500">Jenis Gugatan</th>
    <th width="100">Dikabulkan</th>
    <th width="100">Dikabulkan Sebagian</th>
    <th width="100">Ditolak</th>
    <th width="100">Tidak Diterima</th>
    <th width="100">Perdamaian</th>
    <th width="100">Dinyatakan Gugur</th>
    <th width="100">Dicabut</th>
    <th width="100">Mengabulkan Eksepsi</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;
			$jumDikabulkan = 0;
			$jumDikabulkanSebagian = 0;
			$jumDitolak = 0;
			$jumTidakDiterima = 0;
			$jumPerdamaian = 0;
			$jumDinyatakanGugur = 0;
			$jumMengabulkanEksepsi = 0;
			$jumDicabut = 0;
			foreach ($laporan->result() as $row) {$i++;

				if(!empty($row->dikabulkan)){ $jumDikabulkan += $row->dikabulkan; }
    			if(!empty($row->dikabulkanSebagian)){ $jumDikabulkanSebagian += $row->dikabulkanSebagian; }
    			if(!empty($row->ditolak)){ $jumDitolak += $row->ditolak; }
    			if(!empty($row->tidakDiterima)){ $jumTidakDiterima += $row->tidakDiterima; }
    			if(!empty($row->perdamaian)){ $jumPerdamaian += $row->perdamaian; }
    			if(!empty($row->dinyatakanGugur)){ $jumDinyatakanGugur += $row->dinyatakanGugur; }
    			if(!empty($row->dicabut)){ $jumDicabut += $row->dicabut; }
    			if(!empty($row->mengabulkanEksepsi)){ $jumMengabulkanEksepsi += $row->mengabulkanEksepsi; }
    							
				echo "<tr>";
					echo "<td style='width:20px;'>".$i."</td>";
					echo "<td>".$row->namaLengkap."</td>";
					echo "<td><div align='center'>".isNOOL($row->dikabulkan)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->dikabulkanSebagian)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->ditolak)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->tidakDiterima)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->perdamaian)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->dinyatakanGugur)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->dicabut)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->mengabulkanEksepsi)."</div></td>";
				echo "</tr>";
				
			}
			echo "<tr>";
				echo "<td colspan='2'>JUMLAH</td>";
				echo "<td><div align='center'>".isNOOL($jumDikabulkan)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumDikabulkanSebagian)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumDitolak)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumTidakDiterima)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumPerdamaian)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumDinyatakanGugur)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumDicabut)."</div></td>";
				echo "<td><div align='center'>".isNOOL($jumMengabulkanEksepsi)."</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>