<hr class="thick-line" style="clear:both;">
<div id="left">
	<?php
	echo form_open(base_url().$page_url.'/search');
	$attributes = array('name' => 'search', 'id' => 'search-box', 'type' => 'text','size' => '50','placeholder'=>"  Ketik kata kunci  ");
	echo form_input($attributes);
	echo "<span>  </span>";
	$attributes = array('value' => 'Search', 'id' => 'search-btn1','class' => 'btn', 'type' => 'submit');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>
<?php
$page_name = "register_diversi_list";
$action = base64_encode($this->encrypt->encode("add"));
/*if($this->session->userdata('is_logged_in')){
	$AuthorizationForm = $this->nativesession->get('AuthorizationForm');
	if($this->authorization->isAuthorized($page_name,$AuthorizationForm)==FALSE){
		redirect('login');
	}
	$AuthorizationAction = $this->nativesession->get('getAuthorizationAction');
	if($this->authorization->isAuthorized('BiayaPerkaraManage',$AuthorizationAction)){*/
?>

<?php
echo '<div id="left" style="margin-left:30px;">';
	echo '<input type="submit" id="tambah_diversi" value="Tambah Data Diversi" class="btn"></input>';

echo '</div>';
?>
&nbsp;<input type="submit" onClick="popup_form('<?php echo base_url();?>register_diversi/118');" value="Cetak Register" id="cetak_reg" class="btn btn-warning"></input>


<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
		<col  width="17%" />
        <col  width="9%" />
        <col  width="10%" />
        <col  width="15%" />
        <col  width="20%" />
        <col  width="9%" />
        <col  width="9%" />
        <col  width="10%" />
        <col  width="5%" />
		<tbody>
			<tr>
				<td style="align:left;">No Urut</td>
				<td align="left" >No Diversi</td>
				<td align="left" >Tanggal diterima Permohonan</td>
				<td align="left" >Nama Pemohon</td>
				<td style="cursor:pointer;text-align:left !important" >a. Nomor Register Penyidik<br>b. Nomor Register PU<br>c. Nomor Perkara PN</td>				
				<td >Anak<br>
				<td >Tanggal Kesepakatan</td>
				<td >Tanggal Pelaksanaan Diversi</td>
				<td >Template Kesepakatan Diversi</td>
				<td>Link</td>
			</tr>
			<?php
				if($diversi_list!=''){
					if($diversi_list->num_rows()>0){
						if($page_active<1){
							$con = 1;
						}else{
							$con = $page_active+1;
						}
							
						$this->nativesession->set_flash_session('history', current_url());
		    			foreach ($diversi_list->result() as $row) {
		    				$pemohon = $row->pemohon_diversi;
		    				if($pemohon==1){
		    					$pemohon_diversi='Penyidik';
		    					$noreg=$row->no_reg_penyidik;
		    					$nama = $row->nama_penyidik;
		    					$no_diversi = $row->no_diversi;
		    				}else if($pemohon==2){
		    					$pemohon_diversi='Penuntut Umum';
		    					$noreg=$row->no_reg_penuntut;
		    					$nama = $row->nama_penuntut;
		    					$no_diversi = $row->no_diversi;
		    				}else{
		    					$pemohon_diversi='Hakim';
		    					$noreg=$row->no_perkara;
		    					$nama = $row->nama_hakim;
		    					$no_diversi = $row->no_diversi." <br>jo".$row->no_perkara;
		    				};

		    				if($row->pemohon_diversi==1 OR $row->pemohon_diversi==2){
		    					$segment = '';
		    				}elseif($row->pemohon_diversi==3){
		    					$segment = '/'.base64_encode($this->encrypt->encode($row->perkara_id));
		    				}
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$no_diversi.'</td>';
			    				echo '<td align="center">'.$this->tanggalhelper->convertDate($row->tgl_permohonan_diversi).'</td>';
			    				echo '<td>'.$pemohon_diversi.': <br><strong>'.$nama.'</strong></td>';
			    				echo '<td>'.$noreg.'</td>';
			    				echo '<td>'.$row->nama_anak.'</td>';
			    				echo '<td align="center">'.$this->tanggalhelper->convertDate($row->tgl_kesepakatan).'</td>';
			    				echo '<td align="center">'.$this->tanggalhelper->convertDate($row->tgl_pelaksanaan).'</td>';
			    				echo '<td align="center">';
			    					echo '<a href="#" style="color:white;margin-bottom:15px" class="btn btn-warning btn-sm" onClick="popup_form(\''.base_url('c_template_diversi/popup_penetapan_ketua/'.base64_encode($this->encrypt->encode($row->id))).'/'.base64_encode($this->encrypt->encode($row->pemohon_diversi)).$segment.'\')"><i class="fa fa-print" aria-hidden="true"></i> Cetak</a>';
			    				echo '</td>';
			    				echo '<td style="cursor:pointer;" align="center" onclick="detil_diversi(\''.base64_encode($this->encrypt->encode($row->id)).'\')">[<a href="#">detil</a>]</td>';
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='6' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='6' align='center'>Data Tidak diTemukan</td></tr>";
		    	}
			?>
		</tbody>
	</table>
</div>
<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/';
$keyword = (!empty($keyword))?'/'.$keyword : '';
?>
<script type="text/javascript">
	function sorting(col){
		window.open('<?php echo $url;?>'+col+'/<?php echo $enc; ?><?php echo $keyword; ?>','_self')
	}
	<?php $enc = (!empty($enc)) ? "/".$enc : $enc;?>
	function searchDetilShow(){
		window.open('<?php echo base_url();?>search','_self')
	}

	function detil_diversi(diversi_id){
		var ef=diversi_id;
		window.open('<?php echo base_url();echo "detil_diversi"; ?>/'+ef,'_self')
	}
	$('#tambah_diversi').click(function(event){
		window.open('<?php echo base_url();echo "new_diversi"; ?>/','_self')
	});
</script>
