<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="15" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;">LAPORAN PERKARA <?php echo $perkara_nama;?> YANG DIMOHONKAN EKSEKUSI</td>
		</tr>
		<tr>
			<td align="center" colspan="15" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
		</tr>
		<tr>
			<td align="center" colspan="15" 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 PN</th>
		<th rowspan="1" colspan="11">TANGGAL</th>
		<th rowspan="2" colspan="2">KETERANGAN</th>
	</tr>
	<tr>
		<th rowspan="1" colspan="1" style="border-left:0px;">PERMOHONAN EKSEKUSI</th>
		<th rowspan="1" colspan="1">PENETAPAN TEGURAN</th>
		<th rowspan="1" colspan="1">PELAKSANAAN TEGURAN</th>
		<th rowspan="1" colspan="1">PENETAPAN SITA EKSEKUSI</th>
		<th rowspan="1" colspan="1">PELAKSANAAN SITA EKSEKUSI</th>
		<th rowspan="1" colspan="1">PENETAPAN EKSEKUSI LELANG</th>
		<th rowspan="1" colspan="1">PENETAPAN EKSEKUSI RIIL</th>
		<th rowspan="1" colspan="1">PELAKSANAAN EKSEKUSI LELANG</th>
		<th rowspan="1" colspan="1">PENYERAHAN HASIL LELANG</th>
		<th rowspan="1" colspan="1">PELAKSANAAN EKSEKUSI RIIL</th>
		<th rowspan="1" colspan="1">PENETAPAN NON-EKSEKUTABEL</th>
	</tr>
	<tr>
	<?php
		for ($i=1; $i<=14 ; $i++) { 
			echo "<th style='width:20px;'>".$i."</th>";
		}
		echo "<th colspan='2'>15</th>";
		?>
	</tr>
	<tr>
		<?php
		for ($i=1; $i<=14 ; $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>".parse_date($row->permohonan_eksekusi)."</td>";
					echo "<td>".parse_date($row->penetapan_teguran_eksekusi)."</td>";
					echo "<td>".parse_date($row->pelaksanaan_teguran_eksekusi)."</td>";
					echo "<td>".parse_date($row->penetapan_sita_eksekusi)."</td>";
					echo "<td>".parse_date($row->pelaksanaan_sita_eksekusi)."</td>";
					echo "<td>".parse_date($row->penetapan_perintah_eksekusi_lelang)."</td>";
					echo "<td>".parse_date($row->penetapan_perintah_eksekusi_rill)."</td>";
					echo "<td>".parse_date($row->pelaksanaan_eksekusi_lelang)."</td>";
					echo "<td>".parse_date($row->penyerahan_hasil_lelang)."</td>";
					echo "<td>".parse_date($row->pelaksanaan_eksekusi_rill)."</td>";
					echo "<td>".parse_date($row->penetapan_noneksekusi)."</td>";
					echo "<td style='width:150px;'>".parse_stat($i,1)."</td>";
					echo "<td>".parse_stat($i,2,$rekap)."</td>";
				echo "</tr>";
			}
			if($i<5){
				for ($x=$i+1; $x <=5; $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></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 'Sisa Bulan Lalu';}
		elseif($x==3 AND $y==1){return 'Masuk Bulan Ini';}
		elseif($x==4 AND $y==1){return 'Selesai Bulan Ini';}
		elseif($x==5 AND $y==1){return 'Sisa Bulan Ini';}

		elseif($x==2 AND $y==2){return $rekap[0]->sisa_lalu;}
		elseif($x==3 AND $y==2){return $rekap[0]->masuk;}
		elseif($x==4 AND $y==2){return $rekap[0]->selesai;}
		elseif($x==5 AND $y==2){return $rekap[0]->sisa_lalu+$rekap[0]->masuk-$rekap[0]->selesai;}
	}
	?>
</table>
</div>
<div style="padding:15px;"></div>
<script src="resources/js/jquery-1.10.2.min.js"></script>
<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>