<hr class="thick-line" style="clear:both;">
<div id="left">
	<?php
	echo form_open(base_url().'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:50px;">
	<?php if ($idalurperkara=='114') { ?>
		<input onClick="popup_form('<?php echo base_url();?>cetak_tilang');" type="submit" value="Cetak" class="btn"></input>
	<?php } else { ?>
		<input id="cetak_perkara_list" type="submit" value="Cetak" class="btn"></input>
		<?php if($idalurperkara=='118'){ ?>
		<input type="submit" onClick="popup_form('<?php echo base_url();?>cetak_register/popup/<?php echo $idalurperkara; ?>');" value="Cetak Register" id="cetak_reg" class="btn btn-warning"></input>
		<?php } ?>
	<?php } ?>
	<?php 
		if($this->authorization->HasRuleAddPendaftaran($idalurperkara)){
			if($idalurperkara==1 or  $idalurperkara==7 or $idalurperkara==15){ ?>
			<input type="submit" onClick="popup_form('<?php echo base_url();?>cetak_register_mediasi');" value="Cetak Register Mediasi" id="cetak_reg_mediasi" class="btn"></input>
	<?php } } ?>
</div>
<?php
if($this->session->userdata('is_logged_in')){
	if($this->authorization->HasRuleAddPendaftaran($idalurperkara)){
?>
			<div id="left" style="margin-left:50px;">
			    <?php if ($idalurperkara=='114') { ?>
           		  	<input type="submit" id="cetak_form_lalulintas" title="Form File Excel yang digunakan untuk import perkara tilang" value="Unduh Formulir" class="btn"></input>
           			<input type="submit" id="tambah_perkara_ll" value="Tambah Perkara" class="btn"></input>
           		<?php }  else {
           				if($idalurperkara>100){
							?>
							<input id="tambah_pidana"type="submit" value="Tambah Perkara" class="btn"></input>
							<script type="text/javascript">
								$('#tambah_pidana').click(function(event){
									window.open('<?php echo base_url();echo "new_pidana/".$enc; ?>/','_self')
								});
							</script>
							<?php
						}
				} ?>
			</div>
<?php
	}
}
?>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="15%" />
        <col  width="7%" />
        <col  width="15%" />
        <col  width="17%" />
        <col  width="11%" />
        <col  width="13%" />
        <col  width="5%" />
        <col  width="4%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Nomor Perkara</td>
				<td onclick="sorting(2)">Tanggal Register</td>
				<td onclick="sorting(3)">Klasifikasi Perkara</td>
				<td onclick="sorting(4)">Para Pihak</td>
				<td onclick="sorting(5)">Tahapan</td>
				<td onclick="sorting(6)">Status Perkara</td>
				<td onclick="sorting(7)">Lama Proses</td>
				<td>Link</td>
			</tr>
			<?php
				if($list_perkara!=''){
					if($list_perkara->num_rows>0){
						if($page_active<1){
							$con = 1;
						}else{
							$con = $page_active+1;
						}
		    			foreach ($list_perkara->result() as $row) {
		    				//$date = new DateTime(str_replace("-","",$row->tanggal_pendaftaran));
		    				echo "<tr>";
		    					$lamaproses = ($row->durasi<1)? ($row->durasi+1):$row->durasi;
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->nomor_perkara.'</td>';
			    				echo '<td align="center">'.$this->tanggalhelper->convertDate($row->tanggal_pendaftaran).'</td>';
			    				echo '<td>'.$row->jenis_perkara_nama.'</td>';
			    				echo '<td>'.$row->para_pihak.'</td>';
			    				echo '<td>'.$row->tahapan_terakhir_text.'</td>';
			    				echo '<td>'.$row->proses_terakhir_text.'</td>';
			    				echo '<td style = "text-align:right;">'.$lamaproses.' Hari</td>';
			    				if($this->session->userdata('jenis_pengadilan')==1){
			    					echo '<td align="center">[<a href="'.base_url('perkara_detil/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					} else if ($this->session->userdata('jenis_pengadilan')==2){
		    						echo '<td align="center">[<a href="'.base_url('perkara_detil_mil/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					} else if ($this->session->userdata('jenis_pengadilan')==3){
		    						echo '<td align="center">[<a href="'.base_url('perkara_detil_tun/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					} else if ($this->session->userdata('jenis_pengadilan')==4){
		    						echo '<td align="center">[<a href="'.base_url('perkara_detil_agama/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					} else {
		    						echo '<td align="center">[<a href="'.base_url('perkara_detil/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</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>";
		    	}
			?>
		</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>
<script type="text/javascript">
	function sorting(col){
		window.open('<?php echo base_url();?>perkara_list/sort/'+col+'/<?php echo $enc; ?>/<?php echo $keyword; ?>','_self')
	}
	<?php $enc = (!empty($enc)) ? "/".$enc : $enc;?>

	function searchDetilShow(){
		popup_form('<?php echo base_url();?>search<?php echo $enc; ?>')
	}

	$('#tambah_perkara_ll').click(function(){
		window.open('<?php echo base_url(); echo "new_lalulintas/".$enc; ?>/','_self')
	});
	$('#cetak_form_lalulintas').click(function(){
		window.open('<?php echo base_url(); echo "resources/template/format_form_lalulintas.xlsx"; ?>','_self')
	});
	$('#cetak_perkara_list').click(function(){
		window.open('<?php echo base_url(); echo "perkara_list_cetak/cetak/1".$enc."/".$keyword; ?>','_self')
	});

	$( function() {
        $('#tanggal_persidangan').datepicker({
            inline: true,
            showOtherMonths: true,
            dateFormat: 'dd/mm/yy',
            dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
            onSelect: function(dateText, inst) {
            	var date = $(this).datepicker('getDate');
            	var dayOfWeek = weekday[date.getDay()];
            	var error = 0;
            	var message ='';
            	if(dayOfWeek=='Sunday' || dayOfWeek=='Saturday'){
            		message ='Tidak Dapat Memilih diluar Hari Kerja.';
            		error = 1;
            	}
            }
        })
            	
    });
</script>
