<div style="padding:5px;min-width:1200px;">
<div style="padding:20px;"></div>
<button class="btn btnExcel" style="width:150px;text-align:center;">Export Excel</button></div>
<table id="view_laporan" border="0" class="cetakExcel" cellpadding="2" cellspacing="0" style="margin:10px;min-width:1200px;">
	<tbody>
		<tr>
			<td align="center" colspan="12" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;">LAPORAN PERKARA <?php echo $perkara_nama;?> YANG DIMOHONKAN GRASI</td>
		</tr>
		<tr>
			<td align="center" colspan="12" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
		</tr>
		<tr>
			<td align="center" colspan="12" 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>
	<th rowspan="2" colspan="1">NOMOR URUT</th>
		<th rowspan="2" colspan="1">NOMOR PERKARA</th>
		<th rowspan="1" colspan="2">NAMA</th>
		<th rowspan="1" colspan="5">TANGGAL</th>
		<th rowspan="2" colspan="1">KETERANGAN</th>
		<th rowspan="2" colspan="2">REKAPITULASI</th>
	</tr>
	<tr>
		<th colspan="1" style="border-left:0px;">TERPIDANA</th>
		<th colspan="1">PEMOHON GRASI</th>
		<th colspan="1">PERMOHONAN GRASI</th>
		<th colspan="1">PENGIRIMAN SALINAN PERMOHONAN GRASI BERIKUT BERKAS PERKARA  DARI PN KE MA</th>
		<th colspan="1">PENGIRIMAN PERTIMBANGAN BERIKUT BERKAS PERKARA OLEH MA KE PRESIDEN</th>
		<th colspan="1">KEPUTUSAN PRESIDEN</th>
		<th colspan="1">PENERIMAAN SALINAN KEPUTUSAN PRESIDEN KE PN</th>
	</tr>
	<tr>
	<?php
		for ($i=1; $i<=10 ; $i++) { 
			echo "<th style='width:20px;'>".$i."</th>";
		}
		echo "<th colspan='2'>11</th>";
		?>
	</tr>
	<tr>
		<?php
		for ($i=1; $i<=10 ; $i++) { 
			echo "<td style='padding:10px;'></td>";
		}
		echo "<td colspan='2'></td>";
		?>
	</tr>
	<?php
	
	$rekap = array();
	if($stat!=''){
		if($stat->num_rows>0){
			foreach ($stat->result() as $row) {
				array_push($rekap, $row);
			}
		}
	}

	if($laporan!=''){
		if($laporan->num_rows>0){
			$i=0;
			foreach ($laporan->result() as $row) {
				$i++;
				echo "<tr>";
					echo "<td style='width:20px;'>".$i."</td>";
					echo "<td>".$row->nomor_perkara_pn."</td>";
					echo "<td>".$row->terdakwa_nama."</td>";
					echo "<td>".$row->pemohon_grasi."</td>";
					echo "<td>".parse_date($row->permohonan_grasi)."</td>";
					echo "<td>".parse_date($row->pengiriman_berkas_grasi_ke_ma)."</td>";
					echo "<td>".parse_date($row->pengiriman_pertimbangan_hakim_grasi)."</td>";
					echo "<td>".parse_date($row->tanggal_putusan_grasi)."</td>";
					echo "<td>".parse_date($row->tanggal_penerimaan_kembali_berkas_grasi)."</td>";
					echo "<td>".$row->catatan_putusan_grasi."</td>";
					echo "<td style='width:150px;'>".parse_stat($i,1)."</td>";
					echo "<td>".parse_stat($i,2,$rekap)."</td>";
				echo "</tr>";
			}
			if($i<4){
				for ($x=$i+1; $x <=4; $x++) { 
					echo "<tr>";
					echo "<td style='width:20px;'></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td style='width:150px;'>".parse_stat($x,1)."</td>";
					echo "<td>".parse_stat($x,2,$rekap)."</td>";
				echo "</tr>";
				}
			}
		}
	}

	
	function parse_stat($x,$y,$rekap=NULL){
		if($x==1 AND $y==1){return 'REKAPITULASI';}
		elseif($x==2 AND $y==1){return 'Jumlah Permohonan Grasi';}
		elseif($x==3 AND $y==1){return 'Jumlah Permohonan Grasi yang ditolak';}
		elseif($x==4 AND $y==1){return 'Jumlah Permohonan Grasi yang dikabulkan';}

		elseif($x==2 AND $y==2){return $rekap[0]->masuk;}
		elseif($x==3 AND $y==2){return $rekap[0]->tolak;}
		elseif($x==4 AND $y==2){return $rekap[0]->kabul;}
	}
	?>
</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>