<div class="centering" style="padding:5px;width:1024px;margin: 0% auto 25px;">
<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;?></td></tr>
	</tbody>
	<tr height="20">
	    <th width="30" rowspan="3">No</th>
	    <th width="200" rowspan="3">Jenis Perkara</th>
	    <th colspan="10">Lama Waktu Persiapan Perkara</th>
  </tr>
  <tr>
  	<th colspan="2" style='border-left:0px;'>1 hari</th>
  	<th colspan="2">2 hari</th>
  	<th colspan="2">3 hari</th>
    <th colspan="2">Lebih dari 3 hari</th>
  </tr>
  <tr>
  	<th width="50" style='border-left:0px;'>Jumlah</th>
  	<th width="50">%</th>
  	<th width="50">Jumlah</th>
  	<th width="50">%</th>
  	<th width="50">Jumlah</th>
  	<th width="50">%</th>
  	<th width="50">Jumlah</th>
  	<th width="50">%</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;
			foreach ($rekap->result() as $row) {$i++;
				$jumlahTotal = $row->jumlahTotal;
				if($row->value1==0){
		          $persen1 = '0';
		        } else {
		          $persen1 = ($row->value1/$jumlahTotal)*100;
		        }
		        if($row->value2==0){
		          $persen2 = '0';
		        } else {
		          $persen2 = ($row->value2/$jumlahTotal)*100;
		        }
		        if($row->value3==0){
		          $persen3 = '0';
		        } else {
		          $persen3 = ($row->value3/$jumlahTotal)*100;
		        }
		        if($row->value4==0){
		          $persen4 = '0';
		        } else {
		          $persen4 = ($row->value4/$jumlahTotal)*100;
		        }
				echo "<tr>";
					echo "<td style='width:20px;'><div align='center'>".$i."</div></td>";
					echo "<td>".$row->jenis_perkara_nama."</td>";
					echo "<td><div align='center'>".isNOOL($row->value1)."</div></td>";
					echo "<td><div align='center'>".isNOOL($persen1)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->value2)."</div></td>";
					echo "<td><div align='center'>".isNOOL($persen2)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->value3)."</div></td>";
					echo "<td><div align='center'>".isNOOL($persen3)."</div></td>";
					echo "<td><div align='center'>".isNOOL($row->value4)."</td>";
					echo "<td><div align='center'>".isNOOL($persen4)."</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>