<div style="padding:5px;width:1500px;">
<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;width:1500px;">
	<tbody>
		<tr>
			<td align="center" colspan="17" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;">LAPORAN PERKARA <?php echo $perkara_nama;?> YANG DIMOHONKAN BANDING</td>
		</tr>
		<tr>
			<td align="center" colspan="17" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
		</tr>
		<tr>
			<td align="center" colspan="17" 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="3" colspan="1">NOMOR PERKARA PN</th>
      <th rowspan="3" colspan="1">NOMOR PERKARA PT</th>
      <th rowspan="1" colspan="3">NAMA</th>
      <th rowspan="1" colspan="11">TANGGAL</th>
      <th rowspan="3" colspan="2">KETERANGAN</th>
    </tr>
    <tr>
      <th rowspan="2" colspan="1">MAJELIS HAKIM TINGKAT BANDING</th>
      <th rowspan="2" colspan="1">PANITERA PENGGANTI TINGKAT BANDING</th>
      <th rowspan="2" colspan="1">PEMOHON</th>
      <th rowspan="2" colspan="1">PUTUSAN PN</th>
      <th rowspan="2" colspan="1">PERMOHONAN</th>
      <th rowspan="1" colspan="2">PEMBERITAHUAN BANDING</th>
      <th rowspan="1" colspan="2">INSAGE</th>
      <th rowspan="2" colspan="1">PENGIRIMAN BERKAS BANDING</th>
      <th rowspan="2" colspan="1">PENERIMAAN BERKAS BANDING</th>
      <th rowspan="2" colspan="1">PUTUSAN PT</th>
      <th rowspan="1" colspan="2">PEMBERITAHUAN PUTUSAN PT</th>
    </tr>
    <tr>
      <th rowspan="1" colspan="1" style="border-left:'0'">TERDAKWA</th>
      <th rowspan="1" colspan="1">JAKSA</th>
      <th rowspan="1" colspan="1">PEMBERITAHUAN</th>
      <th rowspan="1" colspan="1">PELAKSANAAN</th>
      <th rowspan="1" colspan="1">TERDAKWA</th>
      <th rowspan="1" colspan="1">JAKSA</th>
    </tr>
	<tr>
	<?php
		for ($i=1; $i<=17 ; $i++) { 
			echo "<th>".$i."</th>";
		}
		echo "<th colspan='2'>18</th>";
		?>
	</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>".$i."</td>";
					echo "<td>".$row->nomor_perkara_pn."</td>";
					echo "<td>".$row->nomor_perkara_banding."</td>";
					echo "<td>".$row->majelis_hakim_banding."</td>";
					echo "<td>".$row->panitera_pengganti_banding."</td>";
					echo "<td>".$row->pemohon_banding."</td>";
					echo "<td>".parse_date($row->putusan_pn)."</td>";
					echo "<td>".parse_date($row->permohonan_banding)."</td>";
					echo "<td>".parse_date($row->pemberitahuan_permohonan_banding_terdakwa)."</td>";
					echo "<td>".parse_date($row->pemberitahuan_permohonan_banding_jaksa)."</td>";
					echo "<td>".parse_date($row->pemberitahuan_inzage)."</td>";
					echo "<td>".parse_date($row->pelaksanaan_inzage)."</td>";
					echo "<td>".parse_date($row->pengiriman_berkas_banding)."</td>";
					echo "<td>".parse_date($row->penerimaan_kembali_berkas_banding)."</td>";
					echo "<td>".parse_date($row->putusan_banding)."</td>";
					echo "<td>".parse_date($row->pemberitahuan_putusan_banding_terdakwa)."</td>";
					echo "<td>".parse_date($row->pemberitahuan_putusan_banding_jaksa)."</td>";
					echo "<td>".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 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></td>";
						echo "<td></td>";
						echo "<td style='width:170px;'>".parse_stat($x,1)."</td>";
						echo "<td style='width:170px;'>".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 Banding';}
		elseif($x==3 AND $y==1){return 'Pengiriman Berkas Banding';}
		elseif($x==4 AND $y==1){return 'Putus Banding';}
		elseif($x==5 AND $y==1){return 'Belum Putus Banding';}
		elseif($x==6 AND $y==1){return 'Penerimaan Kembali Berkas Banding';}
		elseif($x==7 AND $y==1){return 'Pemberitahuan Putusan Banding';}

		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-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>