<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;"><?php echo 'Tahun '.$tahun;?></td></tr>
	</tbody>
	<tr height="20">
	    <th width="5%" rowspan="3">No</th>
	    <th width="25%" rowspan="3">Nama Hakim</th>
	    <th colspan="8">Lama Waktu Penyelesaian Perkara</th>
  </tr>
  <tr>
  	<th colspan="2" style='border-left:0px;'>1 - 7 hari</th>
  	<th colspan="2">8 - 14 hari</th>
  	<th colspan="2">15 - 25 hari</th>
  	<th colspan="2">Lebih dari 25 hari</th>
  </tr>
  <tr>
  	<th width="7%" style='border-left:0px;'>Jumlah</th>
  	<th width="7%">%</th>
  	<th width="7%">Jumlah</th>
  	<th width="7%">%</th>
  	<th width="7%">Jumlah</th>
  	<th width="7%">%</th>
  	<th width="7%">Jumlah</th>
  	<th width="7%">%</th>
  </tr>
  <?php
  	function isNOOL($data){
		if(($data==0)or(empty($data))){
			return "-";
		} else {
			return $data;
		}
	}
  	if($rekap!=''){
  		$jumValue1 = 0;
		$jumValue2 = 0;
		$jumValue3 = 0;
		$jumValue4 = 0;
		if($rekap->num_rows>0){
			$i=0;
			foreach ($rekap->result() as $row) {$i++;
				$jumlahPerkara = $row->jumlah_perkara;
				if((empty($row->value1))or($row->value1==0)){
					$value1 = "-";
					$persen1 = "-";
				} else {
					$value1 = $row->value1;
					$persen1 = ($row->value1/$jumlahPerkara)*100;
				}
				if((empty($row->value2))or($row->value2==0)){
					$value2 = "-";
					$persen2 = "-";
				} else {
					$value2 = $row->value2;
					$persen2 = ($row->value2/$jumlahPerkara)*100;
				}
				if((empty($row->value3))or($row->value3==0)){
					$value3 = "-";
					$persen3 = "-";
				} else {
					$value3 = $row->value3;
					$persen3 = ($row->value3/$jumlahPerkara)*100;
				}
				if((empty($row->value4))or($row->value4==0)){
					$value4 = "-";
					$persen4 = "-";
				} else {
					$value4 = $row->value4;
					$persen4 = ($row->value4/$jumlahPerkara)*100;
				}
				

				$jumValue1 += $value1;
				$jumValue2 += $value2;
				$jumValue3 += $value3;
				$jumValue4 += $value4;

				
				

				echo "<tr>";
					echo "<td style='width:20px;'><div align='center'>".$i."</div></td>";
					echo "<td>".$row->hakim_nama."</td>";
					echo "<td><div align='center'>".isNOOL($value1)."</div></td>";
					echo "<td><div align='center'>".isNOOL($persen1)."</div></td>";
					echo "<td><div align='center'>".isNOOL($value2)."</div></td>";
					echo "<td><div align='center'>".isNOOL($persen2)."</div></td>";
					echo "<td><div align='center'>".isNOOL($value3)."</div></td>";
					echo "<td><div align='center'>".isNOOL($persen3)."</div></td>";
					echo "<td><div align='center'>".isNOOL($value4)."</div></td>";
					echo "<td><div align='center'>".isNOOL($persen4)."</div></td>";
				echo "</tr>";
			}
				echo "<tr>";
					echo "<td style='width:20px;' colspan='2'><div align='center'>TOTAL</div></td>";
					echo "<td colspan='2'><div align='center'>".isNOOL($jumValue1)."</div></td>";
					echo "<td colspan='2'><div align='center'>".isNOOL($jumValue2)."</div></td>";
					echo "<td colspan='2'><div align='center'>".isNOOL($jumValue3)."</div></td>";
					echo "<td colspan='2'><div align='center'>".isNOOL($jumValue4)."</div></td>";
				echo "</tr>";
		}else{
			echo "<tr><td colspan='11'></td></tr>";
			echo "<tr><td colspan='11' style='text-align:center;'>Belum Ada Data Hakim</td></tr>";
		}
	}else{
		echo "<tr><td colspan='11'></td></tr>";
		echo "<tr><td colspan='11' style='text-align:center;'>Belum Ada Data Hakim</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>