<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=cetak_form.xls");//ganti nama sesuai keperluan
header("Pragma: no-cache");
header("Expires: 0");
?>
<div id="konten">
<div class="cssTable">
	<table border="1">
	<?php if($jenis_cetak=='1') { #JurnalPerkara ?>
		<tr>
			<td style="width:5%;background:green;" align="center">No</td>
			<td style="width:5%;background:green;" align="center">Nomor Perkara</td>
			<td style="width:5%;background:green;" align="center">Klasifikasi Perkara</td>
			<td style="width:5%;background:green;" align="center">Penggugat</td>
			<td style="width:5%;background:green;" align="center">Tergugat</td>
			<td style="width:5%;background:green;" align="center">Proses Terakhir</td>
			<td style="width:5%;background:green;" align="center">Penerimaan</td>
			<td style="width:5%;background:green;" align="center">Pengeluaran</td>
			<td style="width:5%;background:green;" align="center">Sisa</td>
			<td style="width:5%;background:green;" align="center">Link</td>
		</tr>
	<?php } else if ($jenis_cetak=='2') { ?>
		<tr>
			<td style="width:5%;background:green;" align="center">No</td>
			<td style="width:5%;background:green;" align="center">Nomor Eksekusi</td>
			<td style="width:5%;background:green;" align="center">Jenis Eksekusi Hak Tanggungan</td>
			<td style="width:5%;background:green;" align="center">Pemohon</td>
			<td style="width:5%;background:green;" align="center">Penerimaan</td>
			<td style="width:5%;background:green;" align="center">Pengeluaran</td>
			<td style="width:5%;background:green;" align="center">Sisa</td>
			<td style="width:5%;background:green;" align="center">Link</td>
		</tr>

	<?php } ?>
		<?php
			if($list_jurnal_perkara!=''){
				if($list_jurnal_perkara->num_rows>0){
					$con = 1;
					foreach ($list_jurnal_perkara->result() as $row) {
						if($jenis_cetak=='1') {
			    			$date = new DateTime(str_replace("-","",$row->tanggal_pendaftaran));
			    			$status = '';
		    				if($tahapan_id == 10){
		    					if($row->pemasukan-$row->pengeluaran<0){
		    						$status = 'bgcolor="#e74c3c"';
			    				}
			    				
			    				if($row->proses_terakhir_id == 230 && ($row->pemasukan-$row->pengeluaran!=0)){
			    					$status = 'bgcolor="#f1c40f"';
			    				}
		    				}elseif($tahapan_id == 20){
		    					if($row->pemasukan-$row->pengeluaran<0){
		    						$status = 'bgcolor="#e74c3c"';
			    				}
			    				
			    				if($row->proses_terakhir_id == 400 && ($row->pemasukan-$row->pengeluaran>0)){
			    					$status = 'bgcolor="#f1c40f"';
			    				}

			    				if($row->proses_terakhir_id < 400 && ($row->pemasukan-$row->pengeluaran<=0)){
			    					$status = 'bgcolor="#e74c3c"';
			    				}
		    				}
		    				
		    				echo "<tr>";
			    				echo '<td '.$status.'>'.$con.'</td>';
			    				echo '<td '.$status.'>'.$row->nomor_perkara.'</td>';
			    				echo '<td '.$status.'>'.$row->jenis_perkara_nama.'</td>';
			    				echo '<td '.$status.'>'.$row->pihak1_text.'</td>';
			    				echo '<td '.$status.'>'.$row->pihak2_text.'</td>';
			    				echo '<td '.$status.'>'.$row->proses_terakhir_text.'</td>';
			    				echo '<td align="right" '.$status.'>'.$row->pemasukan.'</td>';
			    				echo '<td align="right" '.$status.'>'.$row->pengeluaran.'</td>';
			    				$sisa = $row->pemasukan - $row->pengeluaran;
			    				echo '<td align="right" '.$status.'>'.$sisa.'</td>';
			    				echo '<td '.$status.'>detil</td>';
		    				echo "</tr>";
			    	
			    		} else if($jenis_cetak=='2') {
			    			echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->nomor_eksekusi.'</td>';
			    				echo '<td>'.$row->jenis_ht.'</td>';
			    				echo '<td>'.$row->pemohon.'</td>';
			    				echo '<td align="right">'.$row->pemasukan.'</td>';
			    				echo '<td align="right">'.$row->pengeluaran.'</td>';
			    				echo '<td align="right">'.$row->sisa.'</td>';
			    				echo '<td>detil</td>';
		    				echo "</tr>";
			    		}
		    			$con++;
		    		}
			    }else{
		    		echo "<tr><td colspan='9' align='center'>Data Tidak diTemukan</td></tr>";
		    	}
			}else{
		    	echo "<tr><td colspan='9' align='center'>Data Tidak diTemukan</td></tr>";
			}
		?>
	</table>
</div>
</div>