<?php 
$this->nativesession->set_flash_session('url_from_dataumum', $history);
$canCetakPutusan=$this->authorization->HasRuleHakimCetakPutusan($perkaraid);
$canCetakPutusan = TRUE;
$keepshow=false;
if(($idProses==21 || $idProses==31 || $idProses==41) && $ada_jadwal_sidang){
	$keepshow=true;
}
?>
<script src="<?php echo base_url();?>resources/js/jquery.idTabs.min.js"></script>
<hr class="thick-line" style="clear:both;">
<style type="text/css">
	#submenus td{font-size:13px;}
	#submenus a {font-size:13px;color:#3598db;text-decoration: none;}
	#submenus a:visited {color:#3598db;text-decoration: none;}  /* visited link */
	#submenus a:hover {font-size:13px;color:#3598db;text-decoration: none;}  /* mouse over link */
	#submenus a:active {color:#3598db;text-decoration: none;}
</style>
<?php $canEditHakimPanitera = $this->authorization->HasRuleFormHakimPanitera($perkaraid);?>
<table width="100%" id="submenus" style="font-size:13px;" >
	<tr>
		<td>
			<table>
				<tr>
					<td id="backlist"><a href="<?php echo $main_history;?>" class="btn btn-default btn-sm"><i class="fa fa-reply-all"></i> Kembali</a></td>
					<?php
					if (($canEditHakimPanitera || $this->authorization->HasRuleEditPendaftaran($idalurperkara, $perkaraid)) && $ada_data_saksi==0)
					{
					?>
					<td><a href="#" onClick="popup_form('<?php echo base_url('add_saksi/'.$enc.'/add');?>')" style="margin-left:3px" class="btn btn-default btn-sm">Saksi Yang Dihadirkan</a></td>
					<?php
					}
						if ($this->authorization->HasRuleAddPenetapan() && $idProses==10 && $ada_data_umum==1)
						{
					?>
					<td><a href="#" onClick="popup_form('<?php echo base_url('add_majelis/'.$enc);?>')" style="margin-left:3px" class="btn btn-default btn-sm">Penetapan Majelis Hakim</a></td>
						<?php
						}
						if($canEditHakimPanitera && $idalurperkara>100 && $idProses>=81 && $ada_data_penuntutan==0 && $idalurperkara!=119 && $idalurperkara!=114)
						{
					?>
							<td><a href="#" onClick="popup_form('<?php echo base_url('add_info_penuntutan/'.$enc);?>')" style="margin-left:3px" class="btn btn-default btn-sm">Tambah Data Tuntutan</a></td>
					<?php
						}
					?>
					<?php

					if ($canEditHakimPanitera && $ada_data_putusan_sela==0 && $idProses>=80 && $idProses<210 && $idalurperkara!=119 && $idalurperkara!=114 && $idalurperkara!=121 && $idalurperkara!=8){
					?>
					<td><a href="#" onClick="popup_form('<?php echo base_url("add_putusan_sela/".$enc."/add");?>')" style="margin-left:3px" class="btn btn-default btn-sm">Tambah Putusan Sela</a></td>
					<?php
					}
					if (($canEditHakimPanitera && (($idProses>=80 && $alur_perkara_id=120) || ($idProses>=80 && $alur_perkara_id=121)))){
						if ($sudah_putusan!=1 AND $ada_data_penuntutan==1){
					?>
							<td><a href="#" onClick="popup_form('<?php echo base_url("add_putusan_akhir/".$enc."/tambah");?>')" style="margin-left:3px" class="btn btn-default btn-sm">Tambah Putusan Akhir</a></td>
					<?php
					}
					}
					
					if ($canEditHakimPanitera && $idalurperkara==8 && $idProses>=81 && $idProses<=200 && $terdakwa_tidak_hadir>=2){
					?>
					 	<td id="backlist"><a href="#" onClick="popup_form('<?php echo base_url('add_pen_gugur/'.$enc);?>')">|Penetapan Gugur</a></td>
					<?php
					}
					//if ($canEditHakimPanitera && $idalurperkara==8 && $idProses>=81 && $idProses<=200 && $terdakwa_tidak_hadir>=2){
					if ($idalurperkara=='120' || $idalurperkara=='121'){
					?>
						<td id="backlist"><a href="#" onClick="popup_form('<?php echo base_url('c_template_pen_mil/akta_pengembalian_berkas/'.$enc);?>')" style="margin-left:3px" class="btn btn-default btn-sm">Akta Pengembalian Berkas</a></td>
					<?php }?>
					
				</tr>
			</table>
		</td>
		<td align="right">
			<table  style="font-size:13px;color:#3598db;text-decoration: none;">
				<tr>
					<?php
					if($sudah_putusan==0){
						echo '<td>';
						echo '<span class="custom-dropdown custom-dropdown--emerald" style="margin-right:3px">';
		                    echo '<select style="width:200px;z-index:99999" class="custom-dropdown__select custom-dropdown__select--white" id="selectCabut" onChange="selectCabut(this)">';
		                    	echo '<option>Pilih Tautan</option>';
		                    	if ($this->authorization->HasRuleCabutPerkara(intval($perkaraid)) && intval($idalurperkara)!=121 && intval($idProses)<203){
		                    		echo '<option value="1">Cabut Perkara</option>';
		                    	}
								if($canEditHakimPanitera && intval($idalurperkara)!=15 && (intval($idProses)>=80 || $keepshow) && intval($idProses)<210){
									echo '<option value="2">Tidak Berwenang</option>';
								}
								if($this->authorization->HasRuleCabutPerkara(intval($perkaraid)) && intval($idalurperkara)!=121 && intval($idProses)<=81){
									echo '<option value="3">Pengembalian Berkas</option>';
								}
								if($this->authorization->HasRuleCabutPerkara(intval($perkaraid)) && intval($idProses)<210){
									echo '<option value="4">Terdakwa Meninggal</option>';
								}
		                    echo '</select>';
	                    echo '</span>';
	                    echo '</td>';
                	}
					if ($this->authorization->HasRuleHapusPerkara($perkaraid)){
						echo '<td><a style="text-decoration: none;color:white;" href="#" onclick="popup_form(\''.base_url("hapus_perkara/".$enc."/".base64_encode($this->encrypt->encode($idalurperkara))).'\')" class="btn btn-danger btn-sm">Hapus</a></td>';
					} ?>
				</tr>
			</table>
		</td>
	</tr>
</table>

<hr class="thick-line" style="clear:both;">
<div class="cssTable" style="margin-top:5px;">
	<table id="tableinfo">
		<col  width="15%" />
        <col  width="20%" />
        <col  width="30%" />
        <col  width="15%" />
        <?php
		if ($sudah_putusan==1){
			echo "<col  width='150px' />";
			echo "<col  width='100px' />";
		}
		?>
		<tbody>
			<tr>
				<td>Nomor Perkara</td>
				<td><?php echo $this->nativesession->getStatusPihak(10,$idalurperkara,1); ?></td>
				<td><?php echo $this->nativesession->getStatusPihak(10,$idalurperkara,2); ?></td>
				<td>Status Perkara</td>
				<?php
				if ($sudah_putusan==1){
					echo "<td>Tanggal BHT</td>";
					echo "<td>Cetak BHT</td>";
				}
				?>
			</tr>
			<tr>
				<td><?php echo $noPerkara;?></td>
				<td><?php if($idalurperkara==114){} else { echo $pihak1; } ?></td>
				<td><?php echo $pihak2;?></td>
				<td><?php echo $statuTerakhir;?></td>
				<?php
				if ($sudah_putusan==1){ 
					if ($this->authorization->HasRuleAddBHT($perkaraid,$idalurperkara)){
					?>
				<td style="text-align:center">
					<a href="#" onClick="popup_form('<?php echo base_url('detil_perkara_mil/manage_bht/'.$enc);?>')"><?php echo $tgl_bht;?></a>
				</td>
				<td style="text-align:center">
				<?php if (!empty($isbht) && $isbht==1){ ?>
					<a href="#" onClick="popup_form('<?php echo base_url('c_template_mil_akta_bht/popup_akta_bht/'.$enc);?>')">
					<img src="<?php echo base_url();?>resources/img/nm_icon_doc.gif">
				<?php }else{ ?>
					<span style="color:red">Belum BHT</span>
				<?php }
				?>
					</a>
				</td>
				<?php
					}else{ ?>
				<td>
					<label><?php echo $tgl_bht;?></label>
				</td>
				<?php
					}
				}
				?>
			</tr>
		</tbody>
	</table>
</div>
<input type="hidden" id="ref_dataumum" value="0">
<div id='content' style="margin: 5px;margin-top:10px;">
	<div id="usual2" class="usual"> 
		<ul>
			<?php
			
				echo "<li class='tab'><a href=\"#tabs1\" id= 'tabInfo' class=\"selected\">Data Umum</a></li>";
									
			if ($idProses>=20){
					echo "<li class='tab'><a class='tabs2' href=\"#tabs2\" id= 'tabInfo'>Penetapan</a></li>";
				
			}
			if ($idProses>=80 && intval($idProses)!=214){ 
				echo "<li class='tab'><a class='tabs4' href=\"#tabs4\" id= 'tabInfo'>Jadwal Sidang</a></li>";
				
			}
			if ($ada_data_saksi>0){
				echo "<li class='tab'><a class='tabs23' href=\"#tabs23\" id= 'tabInfo'>Saksi</a></li>";
			
			}
			if($idalurperkara>=111 && $ada_data_penuntutan==1 && $idalurperkara!=119){
				echo "<li class='tab'><a class='tabs8' href=\"#tabs8\" id= 'tabInfo'>Tuntutan</a></li>";
				
			}
			if ($ada_data_putusan_sela==1 && $idalurperkara!=119){
				echo "<li class='tab'><a class='tabs9' href=\"#tabs9\" id= 'tabInfo'>Putusan Sela</a></li>";
				
			}
			if ($idProses>=210 AND $idProses!=214){
				// if ($ada_data_gugur==0 AND $sudah_putusan==1){
				if ($sudah_putusan==1){
					
						echo "<li class='tab'><a class='tabs10' href=\"#tabs10\" id= 'tabInfo'>";
							echo ($idalurperkara==2)? 'Penetapan (Putusan Akhir)':'Putusan Akhir';
							echo "</a></li>";
					
				}
			}
			
			if ($idProses>=300 AND $ada_data_banding>0){
				
					echo "<li class='tab'><a href=\"#tabs13\" id= 'tabInfo'>Banding</a></li>";
				
			}
			if ($idProses>=410 AND $ada_data_kasasi>0){
				
					echo "<li class='tab'><a href=\"#tabs14\" id= 'tabInfo'>Kasasi</a></li>";
				
			}
			if ($idProses>=510 AND $ada_data_PK>0){
				
					echo "<li class='tab'><a href=\"#tabs15\" id= 'tabInfo'>Peninjauan Kembali</a></li>";
				
			}
			if ($idalurperkara>100 && $idProses>=650 AND $ada_data_grasi>0){
				
					echo "<li class='tab'><a href=\"#tabs16\" id= 'tabInfo'>Grasi</a></li>";
				
			}
			if($idalurperkara>=111 && $idalurperkara!=119 && $idalurperkara!=114 && $ada_barang_bukti){
				echo "<li class='tab'><a href=\"#tabs18\" id= 'tabInfo'>Barang Bukti</a></li>";	
			}
				echo "<li class='tab'><a href=\"#tabs12\" id= 'tabInfo'>Riwayat Perkara</a></li>";
			?>
		</ul>
		<input type="hidden" id="refresh_dest" value="<?php echo $history;?>">
		<div id="tabs1">
		<?php 
			$this->load->view('perkara_tab/data_umum');
		?>
		</div>
		<?php 
		if ($ada_data_saksi>0){
		echo '<div id="tabs23"></div>';
		}
		if ($idProses>=20){ 
			echo '<div id="tabs2"></div>';
		}
		if ($idProses>=80 && intval($idProses)!=214){
			echo '<div id="tabs4"></div>';
		}
		
		if($idalurperkara>=111 && $ada_data_penuntutan==1){
			echo '<div id="tabs8"></div>';
		}
		if($idalurperkara>=111){
			echo '<div id="tabs18"></div>';
		}
		if ($ada_data_putusan_sela==1){
			echo '<div id="tabs9"></div>';
		}
		if ($idProses>=210 AND $idProses!=214){
			//if ($ada_data_gugur==0)
			{
				echo '<div id="tabs10"></div>';
			}
		}
		if ($idProses>=300 AND $ada_data_banding>0){ 
			echo '<div id="tabs13"></div>';
		}
		if ($idProses>=410 AND $ada_data_kasasi>0){
			echo '<div id="tabs14"></div>';
		}
		if ($idProses>=510 AND $ada_data_PK>0){
			echo '<div id="tabs15"></div>';
		}
		if ($idalurperkara>100 && $idProses>=650 AND $ada_data_grasi>0){
			echo '<div id="tabs16"></div>';
		}
		if($idalurperkara<100){
			echo '<div id="tabs11"></div>';
		}
		?>
		<div id="tabs12"></div>
	</div>
</div>
<script type="text/javascript"> 
function cabutPerkara(){
	popup_form('<?php echo base_url("add_info_cabut/".$enc);?>');
}
function tidakBerwenang(){
	popup_form('<?php echo base_url("add_putusan_akhir/".$enc."/tambah/tidakberwenang");?>');
}
function dikembalikan(){
	popup_form('<?php echo base_url("add_putusan_akhir/".$enc."/tambah/dikembalikan");?>');
}
function terdakwaMeninggal(){
	popup_form('<?php echo base_url("add_putusan_akhir/".$enc."/tambah/meninggal");?>');
}
function selectCabut(anu){
	var theLink=anu.value;
	if (anu.value=='1'){
		cabutPerkara()
		}
	else if(anu.value=='2'){
		tidakBerwenang();
	}
	else if(anu.value=='3'){
		dikembalikan();
	}
	else if(anu.value=='4'){
		terdakwaMeninggal();
	}
}
$("#usual2 ul").idTabs("tabs2");
$( document ).ready(function() {
	$('a#tabInfo').click(function(event){
		if (!$(this).hasClass('loaded')){
			if($(this).attr('href')=='#tabs1'){
				if($('#ref_dataumum').val()==1){
					openLoadingDialog();
					$('#tabs1').load('')
					$('#tabs1').load('<?php echo base_url("open_dataumum/".$enc);?>');
				}
			}else if($(this).attr('href')=='#tabs2'){
				openLoadingDialog();
				$('#tabs2').load('<?php echo base_url("add_info_penetapan/".$enc);?>');
				$('a[href=#tabs2]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs4'){
				openLoadingDialog();
				$('#tabs4').load('<?php echo base_url("view_info_jadwal_sidang/".$enc);?>');
				$('a[href=#tabs4]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs8'){
				openLoadingDialog();
				$('#tabs8').load('<?php echo base_url("view_info_penuntutan/".$enc);?>');
				$('a[href=#tabs8]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs9'){
				openLoadingDialog();
				$('#tabs9').load('<?php echo base_url("add_info_putusan_sela/".$enc);?>');
				$('a[href=#tabs9]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs10'){
				openLoadingDialog();
				$('#tabs10').load('<?php echo base_url("add_info_putusan_akhir/".$enc);?>');
				$('a[href=#tabs10]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs12'){
				openLoadingDialog();
				$('#tabs12').load('<?php echo base_url("view_info_riwayat_perkara/".$enc);?>');
				$('a[href=#tabs12]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs13'){
				openLoadingDialog();
				$('#tabs13').load('<?php echo base_url("open_banding/".$enc);?>');
				$('a[href=#tabs13]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs14'){
				openLoadingDialog();
				$('#tabs14').load('<?php echo base_url("open_kasasi/".$enc);?>');
				$('a[href=#tabs14]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs15'){
				openLoadingDialog();
				$('#tabs15').load('<?php echo base_url("open_pk/".$enc);?>');
				$('a[href=#tabs15]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs16'){
				openLoadingDialog();
				$('#tabs16').load('<?php echo base_url("perkara_tab_grasi/".$enc);?>');
				$('a[href=#tabs16]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs18'){
				//openLoadingDialog();
				$('#tabs18').load('<?php echo base_url("perkara_tab_barang_bukti/".$enc);?>');
				$('a[href=#tabs18]').addClass('loaded');
			}else if($(this).attr('href')=='#tabs23'){
				openLoadingDialog();
				$('#tabs23').load('<?php echo base_url("view_info_saksi/".$enc);?>');
				$('a[href=#tabs23]').addClass('loaded');
			}
		}
	});
	<?php
	if($tabs_no!= ''){
		echo "var tab_no ='';";
		echo "tab_no ='.tabs".$tabs_no."';";
		echo "$(tab_no).click();";
		echo "tab_no = '';";
	}
	?>
});

$('#backlist').click(function(){
    window.open("<?php echo $main_history;?>","_self");
});
</script>