<hr class="thick-line" style="clear:both;">
<div id="left">
	<?php
	$this->nativesession->set_flash_session('url_requested', base_url(uri_string()));
	echo form_open(base_url().'jurnal_perkara_list/search');
	$attributes = array('name' => 'search', 'id' => 'search-box', 'type' => 'text','size' => '50','placeholder'=>"  Ketik kata kunci  ");
	echo form_input($attributes);
	$data = array(
		'enc' => $enc
	);
	echo form_hidden($data);
	echo "<span>  </span>";
	$attributes = array('value' => 'Search', 'id' => 'search-btn1', 'type' => 'submit');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>
<div id="left">
<input type="submit" onClick="popup_form('<?php echo base_url();?>search/<?php echo $enc; ?>');" value="Search Detil" id="search-btn1"></input>
</div>
<div id="left" style="margin-left:30px;">
	<input id="cetak_jurnal_list" type="submit" value="Excel" class="btn"></input>
</div>
<div id="left" style="margin-left:50px;"> 
	<input type="submit" onClick="popup_form('<?php echo base_url();?>jurnal_cetak/popup_cetak_jurnal_harian');" value="Cetak Jurnal Harian" id="cetak_reg_mediasi" class="btn"></input>
</div>
<?php
if($this->session->userdata('is_logged_in') AND $this->authorization->HasRuleAddPendaftaran($idalurperkara)){
	if($tahapan_id==10 AND $idalurperkara==1){
		$title = 'Gugatan';
	}else{
		$title = 'Perkara';
	}
	
	echo '<div id="left" style="margin-left:30px;">';
		echo '<input type="submit" id="tambah_pekara" value="Tambah '.$title.'" class="btn"></input>';
	echo '</div>';
	if(($idalurperkara==1 OR $idalurperkara==7) AND $tahapan_id==10){
		echo '<div id="left" style="margin-left:10px;">';
			echo '<input type="submit" id="tambah_perlawanan" value="Tambah Bantahan" class="btn"></input>';
		echo '</div>';
	}
}
?>
<div id="pages" style="margin-top:10px">
    <div id="selector"></div>
</div>
<div class="cssTable">
	
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="14%" />
        <?php 
        if($idalurperkara<>2 && $idalurperkara!=16){
        	echo "<col  width='12%'/>";
        }
        ?>
        
        <col  width="11%" />
        <col  width="11%" />
        <col  width="11%" />
        <col  width="8%" />
        <col  width="8%" />
        <col  width="8%" />
        <col  width="4%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Nomor Perkara</td>
				<td onclick="sorting(3)">Klasifikasi Perkara</td>
				<td onclick="sorting(7)">
					<?php
					if($idalurperkara==2 || $idalurperkara==3 || $idalurperkara==4 || $idalurperkara==10 || $idalurperkara==11 ||$idalurperkara==16){
						echo "Pemohon";
					}else{
						echo "Penggugat";
					}
					?>
				</td>
				<?php 
				$label_kolom='';
				if($idalurperkara==2 || $idalurperkara==3 || $idalurperkara==4 || $idalurperkara==10 || $idalurperkara==11 || $idalurperkara==16){
					$label_kolom='Termohon';
				}else{
					$label_kolom='Tergugat';
				}

				if($idalurperkara<>2 && $idalurperkara!=16){
					echo "<td onclick='sorting(8)'>".$label_kolom."</td>";
				}
				?>
				
				<td onclick="sorting(6)">Proses Terakhir</td>
				<td style="border-left: 1px solid white;">Penerimaan</td>
				<td>Pengeluaran</td>
				<td>Sisa</td>
				<td>Link</td>
			</tr>
			<input type="hidden" id='alur_perkara' value="<?php echo $idalurperkara;?>">
			<?php
				if($list_jurnal_perkara!=''){
					if($list_jurnal_perkara->num_rows>0){
						if($page_active<1){
							$con = 1;
						}else{
							$con = $page_active;
						}
		    			foreach ($list_jurnal_perkara->result() as $row) {
		    				$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 = '';
			    				}
		    				}
		    				
		    				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>';
			    				if($idalurperkara<>2 && $idalurperkara!=16){
			    					echo '<td '.$status.'>'.$row->pihak2_text.'</td>';	
			    				}			    				
			    				echo '<td '.$status.'>'.$row->proses_terakhir_text.'</td>';
			    				echo '<td align="right" '.$status.'>'.number_format($row->pemasukan, 0, ',', '.').'</td>';
			    				echo '<td align="right" '.$status.'>'.number_format($row->pengeluaran, 0, ',', '.').'</td>';
			    				echo '<td align="right" '.$status.'>'.number_format(($row->pemasukan-$row->pengeluaran), 0, ',', '.').'</td>';
			    				echo '<td '.$status.'>[<a href="'.base_url('biaya_detil/'.base64_encode($this->encrypt->encode($row->perkara_id)).'/'.base64_encode($this->encrypt->encode($tahapan_id))).'">detil</a>]</td>';
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='10' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='10' align='center'>Data Tidak diTemukan</td></tr>";
		    	}
			?>
		</tbody>
	</table>
</div>
<?php
if($keyword!==''){
	$keyword=$keyword;
} else {
	$keyword="0";
}
?>
<div id="pages_bottom" style="width:100%;padding-left:5px;padding-top:5px;">
    <div id="selector_bottom"></div>
</div>
<?php $url = base_url().$page_url.'/sort/';?>
<script type="text/javascript">
	function sorting(col){
		window.open('<?php echo $url;?>'+col+'/<?php echo $enc; ?>','_self')
	}
	$('#cetak_jurnal_list').click(function(){
		window.open('<?php echo base_url(); echo "jurnal_cetak/cetak/1/".$enc."/".$keyword; ?>','_self')
	});

	$('#tambah_pekara').click(function(event){
		window.open('<?php echo base_url();echo "new_perdata/".$enc; ?>/','_self')
	});
</script>
<?php 
if($idalurperkara==1 OR $idalurperkara==7){
	$enc_perlawanan = base64_encode($this->encrypt->encode('varlist_alur_perkara_id=7;var_tahapan_id=10'));
?>
<script type="text/javascript">
	$('#tambah_perlawanan').click(function(event){
		window.open('<?php echo base_url();echo "new_perdata/".$enc_perlawanan; ?>/','_self');
	});
</script>
<?php
}
?>

