<div style="padding:5px;min-width:1550px;">
<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;min-width:1500px;">
	<tbody>
		<tr>
			<td align="center" colspan="18" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;">LAPORAN PERKARA <?php echo $perkara_nama;?> YANG DIMOHONKAN KASASI</td>
		</tr>
		<tr>
			<td align="center" colspan="18" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
		</tr>
		<tr>
			<td align="center" colspan="18" 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="3" colspan="1">NOMOR URUT</th>
		<th rowspan="2" colspan="3">NOMOR PERKARA</th>
		<th rowspan="2" colspan="3">NAMA</th>
		<th rowspan="1" colspan="9">TANGGAL</th>
		<th rowspan="3" colspan="2">KETERANGAN</th>
	</tr>
	<tr>
		<th rowspan="1" colspan="2" style="border-left:0px;">PUTUSAN</th>
		<th rowspan="2" colspan="1">PEMBERITAHUAN PUTUSAN PT KEPADA PEMOHON</th>
		<th rowspan="2" colspan="1">PERMOHONAN</th>
		<th rowspan="2" colspan="1">PENERIMAAN MEMORI KASASI</th>
		<th rowspan="2" colspan="1">PENGIRIMAN BERKAS KASASI</th>
		<th rowspan="2" colspan="1">PENERIMAAN BERKAS KASASI</th>
		<th rowspan="2" colspan="1">PUTUSAN MA</th>
		<th rowspan="2" colspan="1">PEMBERITAHUAN PUTUSAN KEPADA PEMOHON/TERMOHON</th>
	</tr>
	<tr>
		<th rowspan="1" colspan="1" style="border-left:0px;">PN</th>
		<th rowspan="1" colspan="1">PT</th>
		<th rowspan="1" colspan="1">MA (Kasasi)</th>
		<th rowspan="1" colspan="1">MAJELIS HAKIM KASASI</th>
		<th rowspan="1" colspan="1">PANITERA PENGGANTI KASASI</th>
		<th rowspan="1" colspan="1">PEMOHON</th>
		<th rowspan="1" colspan="1">PN</th>
		<th rowspan="1" colspan="1">PT</th>
	</tr>
	<tr>
	<?php
		for ($i=1; $i<=17 ; $i++) { 
			echo "<th style='width:20px;'>".$i."</th>";
		}
		echo "<th colspan='2'>18</th>";
		?>
	</tr>
	<tr>
		<?php
		for ($i=1; $i<=17 ; $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->nomor_perkara_banding."</td>";
					echo "<td>".$row->nomor_perkara_kasasi."</td>";
					echo "<td style='width:120px;'>".$row->hakim1_kasasi."</td>";
					echo "<td style='width:120px;'>".$row->panitera_pengganti_kasasi."</td>";
					echo "<td style='width:120px;'>".$row->pemohon_kasasi."</td>";
					echo "<td>".parse_date($row->putusan_pn)."</td>";
					echo "<td>".parse_date($row->putusan_banding)."</td>";
					echo "<td>".parse_date($row->pemberitahuan_putusan_banding)."</td>";
					echo "<td>".parse_date($row->permohonan_kasasi)."</td>";
					echo "<td>".parse_date($row->penerimaan_memori_kasasi)."</td>";
					echo "<td>".parse_date($row->pengiriman_berkas_kasasi)."</td>";
					echo "<td>".parse_date($row->penerimaan_berkas_kasasi)."</td>";
					echo "<td>".parse_date($row->putusan_kasasi)."</td>";
					echo "<td>".parse_date($row->pemberitahuan_putusan_kasasi)."</td>";
					echo "<td style='width:150px;'>".parse_stat($i,1)."</td>";
					echo "<td>".parse_stat($i,2,$rekap)."</td>";
				echo "</tr>";
				
			}
			if($i<7){
				for ($x=$i+1; $x <=7; $x++) {
					echo "<tr>";
						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></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 'Permohonan kasasi';}
		elseif($x==3 AND $y==1){return 'Pengiriman Berkas kasasi';}
		elseif($x==4 AND $y==1){return 'Putus kasasi';}
		elseif($x==5 AND $y==1){return 'Belum Putus kasasi';}
		elseif($x==6 AND $y==1){return 'Penerimaan Kembali Berkas kasasi';}
		elseif($x==7 AND $y==1){return 'Pemberitahuan Putusan kasasi';}

		elseif($x==2 AND $y==2){return $rekap[0]->masuk;}
		elseif($x==3 AND $y==2){return $rekap[0]->kirim_berkas;}
		elseif($x==4 AND $y==2){return $rekap[0]->putusan;}
		elseif($x==5 AND $y==2){return $rekap[0]->blm_putusan;}
		elseif($x==6 AND $y==2){return $rekap[0]->penerimaan_berkas;}
		elseif($x==7 AND $y==2){return $rekap[0]->pemberitahuan_putusan;}
	}
	?>
</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>