<div style="padding:5px;min-width:2000px">
<div style="padding:20px;"></div>
<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;">Bulan <?php echo fetch_montd($bulan);?> <?php echo $tahun;?></td>
		</tr>
	</tbody>
	<tr>
		<th rowspan="3">No.</th>
		<th rowspan="3" style='width:150px;'>NOMOR PERKARA</th>
		<th rowspan="3" colspan="1" style="border-left:0px;">Nama Majelis Hakim</th>
		<th rowspan="3">PP</th>
		<th rowspan="3" style='width:150px;'>KLASIFIKASI</th>
		<th colspan="5">TANGGAL</th>
		<th rowspan="3" style='width:100px;'>AMAR PUTUSAN</th>
		<th rowspan="3" style='width:150px;'>KETERANGAN</th>
	</tr>
	<tr>
		
		<th rowspan="2" style='width:100px;border-left: 0px none;'>Penerimaan</th>
		<th rowspan="2" style='width:100px;'>PMH</th>
		<th rowspan="2" style='width:100px;'>PHS</th>
		<th rowspan="2" style='width:100px;'>Sidang I</th>
		<th rowspan="2" style='width:100px;'>PUTUSAN</th>
	</tr>
	<tr>
	</tr>
	<tr>
		<?php
		for ($i=1; $i<=12 ; $i++) { 
			echo "<th style='width:20px;'>".$i."</th>";
		}
		?>
	</tr>
	<tr>
		<?php
		for ($i=1; $i<=12 ; $i++) { 
			echo "<td style='padding:10px;'></td>";
		}
		?>
	</tr>
	<?php
	$rekap = array();
	if($stat!=''){
		if($stat->num_rows>0){
			foreach ($stat->result() as $row) {
				array_push($rekap, $row);
				$total = $row->sisa + $row->putus_blm_minut + $row->med_blm_minut;
			}
		}
	}
	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."</td>";
					echo "<td style='width:130px;'>".$row->hakim1."</td>";
					echo "<td style='width:120px;'>".str_replace('Panitera Pengganti: ', '', $row->panitera_pengganti_text)."</td>";
					echo "<td style='width:90px;'>".$row->jenis_perkara_nama."</td>";
					echo "<td>".parse_date($row->tanggal_pendaftaran)."</td>";
					echo "<td>".parse_date($row->penetapan_majelis_hakim)."</td>";
					echo "<td>".parse_date($row->sidang_pertama)."</td>";
					echo "<td>".parse_date($row->tanggal_cabut)."</td>";
					echo "<td>".parse_date($row->tanggal_putusan)."</td>";
					echo "<td>".$row->amar_putusan."</td>";
					echo "<td></td>";
				echo "</tr>";
				
			}
			if($i<17){
				for ($x=$i+1; $x <=16; $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 "</tr>";
				}
			}
		}
	}

	
	function parse_stat($x,$y,$rekap=NULL){
		if($x==1 AND $y==1){return '1. Sisa Bulan Lalu';}
		elseif($x==2 AND $y==1){return '  a. Belum Putus';}
		elseif($x==3 AND $y==1){return '  b. Sudah Putus Belum Minutasi';}
		elseif($x==4 AND $y==1){return '  c. Mediasi Berhasil Belum Minutasi';}
		elseif($x==5 AND $y==1){return '2. Tambah Bulan Ini';}
		elseif($x==6 AND $y==1){return '3. Beban Bulan Ini';}
		elseif($x==7 AND $y==1){return '4. Belum Pembagian Majelis';}
		elseif($x==8 AND $y==1){return '6. Minutir Bulan Ini';}
		elseif($x==9 AND $y==1){return '7. Belum Minutir Bulan Ini';}
		elseif($x==10 AND $y==1){return '8. Cabut';}
		elseif($x==11 AND $y==1){return '9. Gugur';}
		elseif($x==14 AND $y==1){return 'Mediasi';}
		elseif($x==15 AND $y==1){return '1. Mediasi Oleh Hakim';}
		elseif($x==16 AND $y==1){return 'a. Berhasil';}
		elseif($x==17 AND $y==1){return 'b. Gagal';}

		elseif($x==1 AND $y==2){return $rekap[0]->sisa + $rekap[0]->putus_blm_minut + $rekap[0]->med_blm_minut;}
		elseif($x==2 AND $y==2){return $rekap[0]->sisa;}
		elseif($x==3 AND $y==2){return $rekap[0]->putus_blm_minut;}
		elseif($x==4 AND $y==2){return $rekap[0]->med_blm_minut;}
		elseif($x==5 AND $y==2){return $rekap[0]->masuk;}
		elseif($x==6 AND $y==2){return $rekap[0]->sisa + $rekap[0]->putus_blm_minut + $rekap[0]->med_blm_minut + $rekap[0]->masuk;}
		elseif($x==7 AND $y==2){return $rekap[0]->blm_majelis;}
		elseif($x==8 AND $y==2){return $rekap[0]->minut;}
		elseif($x==9 AND $y==2){return $rekap[0]->blm_minut;}
		elseif($x==10 AND $y==2){return $rekap[0]->cabut;}
		elseif($x==11 AND $y==2){return $rekap[0]->gugur;}
		elseif($x==16 AND $y==2){return $rekap[0]->mediator_hakim_berhasil;}
		elseif($x==17 AND $y==2){return $rekap[0]->mediator_hakim_gagal;}
	}
	?>
</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>