<?php
$actionName = "configuration";
if($this->session->userdata('is_logged_in')){
	if($this->session->userdata('idgroup')>2){
		redirect('login');
	}
}else{
	redirect('login');
}

$kode_pn = '';
$nama_pn = '';
$alamat_pn = '';
$ketua = '';
$nip_ketua = '';
$wakil = '';
$nip_wakil = '';
$pansek = '';
$nip_pansek = '';
$wapan = '';
$nip_wapan = '';
$wasek = '';
$nip_wasek = '';
$pangkat_ketua='';
$pangkat_wakil_ketua='';
$pangkat_panitera='';
$pangkat_wakil_panitera='';
$user_dirput=''; 
$pwd_dirput='';
$pengadilan_id='';
$user_sippma=''; 
$pwd_sippma='';
$ketua_plh = '';
$nip_ketua_plh = '';
$ketua_plt = '';
$nip_ketua_plt = '';
$panitera_plh = '';
$nip_panitera_plh = '';
$panitera_plt = '';
$nip_panitera_plt = '';

if($info_pn!=''){
	if($info_pn->num_rows>0){
		foreach ($info_pn->result() as $row) {
			if($row->id==61)
				$kode_pn = $row->value;
			if($row->id==62)
				$nama_pn = $row->value;
			if($row->id==63)
				$alamat_pn = $row->value;
			if($row->id==64)
				$ketua = $row->value;
			if($row->id==65)
				$nip_ketua = str_replace(' ', '', $row->value);
			if($row->id==66)
				$wakil = $row->value;
			if($row->id==67)
				$nip_wakil = str_replace(' ', '', $row->value);
			if($row->id==68)
				$pansek = $row->value;
			if($row->id==69)
				$nip_pansek = str_replace(' ', '', $row->value);
			if($row->id==70)
				$wapan = $row->value;
			if($row->id==71)
				$nip_wapan = str_replace(' ', '', $row->value);
			if($row->id==72)
				$wasek = $row->value;
			if($row->id==73)
				$nip_wasek = str_replace(' ', '', $row->value);
			if($row->id==75)
				$zona = $row->value;
			if($row->id==82)
				$idpn = $row->value;
			if($row->id==83)
				$iddirjen = $row->value;
			if($row->id==84)
				$pangkat_ketua = $row->value;
			if($row->id==85)
				$pangkat_wakil_ketua = $row->value;
			if($row->id==86)
				$pangkat_panitera = $row->value;
			if($row->id==87)
				$pangkat_wakil_panitera = $row->value;
			if($row->id==88)
				$user_dirput = $row->value;
			if($row->id==89)
				$pwd_dirput = $row->value;
			if($row->id==90)
				$pengadilan_id = $row->value;
			if($row->id==93)
				$ketua_plh = $row->value;
			if($row->id==94)
				$nip_ketua_plh = str_replace(' ', '', $row->value);
			if($row->id==97)
				$ketua_plt = $row->value;
			if($row->id==98)
				$nip_ketua_plt = str_replace(' ', '', $row->value);
			if($row->id==95)
				$panitera_plh = $row->value;
			if($row->id==96)
				$nip_panitera_plh = str_replace(' ', '', $row->value);
			if($row->id==99)
				$panitera_plt = $row->value;
			if($row->id==100)
				$nip_panitera_plt = str_replace(' ', '', $row->value);
			}
	}
}
?>


<hr class="thick-line" style="clear:both;">
<div id=''>
	<div style="padding:20px;"></div>
	<div class="detil" style="font-size:14px;margin-top:25px;width: 55%;margin: 0 auto;border-color: #FFFFFF;">
		
		<form id="frm_config" style="background:white;margin:0;" method="post" action="<?php echo base_url().'configuration/validate_input';?>">
			<table id="tableDetilPerkara" style="font-size:14px;">
				<col width="30%">
				<col width="34%">
				<col width="30%">
				<tbody>
					<tr>
						<td>Lingkungan Peradilan <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<span class="custom-dropdown custom-dropdown--emerald" style='width:245px'>
								<select style='width:245px' name="dirjen" id="dirjen" onchange="" class="custom-dropdown__select custom-dropdown__select--white">
									<option id="main-dirjen" value="-1"> Pilih Lingkungan Peradilan</option>
									<option id="main-dirjen" value="4" <?php echo ($iddirjen==4)? 'selected':''; ?>> Peradilan Agama</option>
									<option id="main-dirjen" value="2" <?php echo ($iddirjen==2)? 'selected':''; ?>> Peradilan Militer</option>
									<option id="main-dirjen" value="3" <?php echo ($iddirjen==3)? 'selected':''; ?>> Peradilan Tata Usaha Negara</option>
									<option id="main-dirjen" value="1" <?php echo ($iddirjen==1)? 'selected':''; ?> > Peradilan Umum</option>
									
								</select>
							</span>
						</td>
					</tr>
					<tr>
						<td>Nama Pengadilan Tinggi <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<span class="custom-dropdown custom-dropdown--emerald" style='width:245px'>
								<select style='width:245px' name="pt" id="pt" onchange="" class="custom-dropdown__select custom-dropdown__select--white" <?php echo (!empty($id_pt) OR $id_pt !=-1)? '':'disabled';?>>
									<option id="main-pt" value="-1" selected> Pilih Pengadilan Banding</option>
									<?php
										if($list_pt!=''){
											if($list_pt->num_rows>0){
								    			foreach ($list_pt->result() as $row) {
								    				echo '<option class= "pros_pt" id="'.$row->jenis_pengadilan.'" value="'.$row->id.'" ';echo ($row->id == $id_pt) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
								    			}
								    		}
								    	}
									?>
								</select>
							</span>
						</td>
					</tr>
					<tr>
						<td>Nama Pengadilan <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<span class="custom-dropdown custom-dropdown--emerald" style='width:245px'>
								<select style='width:245px' name="pn" id="pn" onchange="" class="custom-dropdown__select custom-dropdown__select--white" <?php echo (!empty($idpn) OR $idpn!=-1)? '':'disabled';?>>
									<option id="main-pn" value="-1"> Pilih Nama Pengadilan</option>
									<?php
										if($list_pn!=''){
											if($list_pn->num_rows>0){
								    			foreach ($list_pn->result() as $row) {
								    				echo '<option class= "pros" id="'.$row->pt_id.'" value="'.$row->kode.'##'.$row->id.'" ';echo ($row->kode == $idpn) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
								    			}
								    		}
								    	}
									?>
								</select>
							</span>
						</td>
					</tr>
					<tr>
						<td>Alamat Pengadilan <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='almt' name='almt' value="<?php echo $alamat_pn;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td>Kode SATKER <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input readonly="readonly" type="text" id='kode_satker' name='kode_satker' value="<?php echo $idpn;?>" class="standard-input" maxlength="6">
						</td>
					</tr>
					<tr>
						<td>Kode Pengadilan <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='kode_pn' name='kode_pn' value="<?php echo $kode_pn;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td>Zona Waktu <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<span class="custom-dropdown custom-dropdown--emerald" style='width:100px'>
								<select style='width:100px' name="zona" id="zona" class="custom-dropdown__select custom-dropdown__select--white">
									<option value="WIB" <?php echo ($zona=='WIB') ? 'selected' : '';?>> WIB</option>
									<option value="WITA" <?php echo ($zona=='WITA') ? 'selected' : '';?>> WITA</option>
									<option value="WIT" <?php echo ($zona=='WIT') ? 'selected' : '';?>> WIT</option>
								</select>
							</span>
						</td>
					</tr>
					<tr>
						<td>Nama Ketua Pengadilan <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='ketua' name='ketua' value="<?php echo $ketua;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_ketua' name='nip_ketua' value="<?php echo $nip_ketua;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr class="tr_pangkat_ketua" style="display:none;">
                    	<td>Pangkat/Korp Ketua <font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pangkat_ketua' name='pangkat_ketua' value="<?php echo $pangkat_ketua;?>" class="standard-input" maxlength="255">
						</td>
                    </tr>
					<tr>
						<td>Nama Wakil Ketua <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='wakil_ketua' name='wakil_ketua' value="<?php echo $wakil;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_wakil_ketua' name='nip_wakil_ketua' value="<?php echo $nip_wakil;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr class="tr_pangkat_wakil" style="display:none;">
                    	<td>Pangkat/Korp Wakil Ketua<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pangkat_wakil_ketua' name='pangkat_wakil_ketua' value="<?php echo $pangkat_wakil_ketua;?>" class="standard-input" maxlength="255">
						</td>
                    </tr>
					<tr>
						<td>Nama Panitera <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pansek' name='pansek' value="<?php echo $pansek;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_pansek' name='nip_pansek' value="<?php echo $nip_pansek;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr class="tr_pangkat_panitera" style="display:none;">
                    	<td>Pangkat/Korp Panitera<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pangkat_panitera' name='pangkat_panitera' value="<?php echo $pangkat_panitera;?>" class="standard-input" maxlength="255">
						</td>
                    </tr>
					<tr>
						<td>Nama Wakil Panitera <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='wapan' name='wapan' value="<?php echo $wapan;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_wapan' name='nip_wapan' value="<?php echo $nip_wapan;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr class="tr_pangkat_wakil_panitera" style="display:none;">
                    	<td>Pangkat/Korp Wakil Panitera<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pangkat_wakil_panitera' name='pangkat_wakil_panitera' value="<?php echo $pangkat_wakil_panitera;?>" class="standard-input" maxlength="255">
						</td>
                    </tr>
					<?php
						if($list_pn!=''){
							if($list_pn->num_rows>0){
								foreach ($list_pn->result() as $row) {
									echo '<input type="hidden" disabled id="kode_'.$row->kode.'" value="'.$row->kode_pn.'">';
									echo '<input type="hidden" disabled id="almt_'.$row->kode.'" value="'.$row->alamat.'">';
								}
							}
						}
					?>
					<tr>
						<td>Sekretaris <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='wasek' name='wasek' value="<?php echo $wasek;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td>NIP <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_wasek' name='nip_wasek' value="<?php echo $nip_wasek;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr>
                    	<td>Username Direktori Putusan<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='user_dirput' name='user_dirput' value="<?php echo $user_dirput;?>" class="standard-input" maxlength="25">
						</td>
                    </tr>
					<tr>
                    	<td>Password Direktori Putusan<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pwd_dirput' name='pwd_dirput' value="<?php echo $pwd_dirput;?>" class="standard-input" maxlength="25">
						</td>
                    </tr>					
					<tr>
                    	<td>Pengadilan ID<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pengadilan_id' name='pengadilan_id' value="<?php echo $pengadilan_id;?>" class="standard-input" maxlength="32">
						</td>
						<td>
										<?php 
                                        echo "<a href=".base_url('api/Putusan/get_satker')." id=noLoading target=_self>[Dapatkan Pengadilan ID]</a>";
                                        ?>
						</td>
                    </tr>
                    <tr>
                    	<td>Username SIPP MA<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="text" id='index_perkara_no' name='index_perkara_no' value="" class="standard-input" maxlength="25">
						</td>
                    </tr>
					<tr>
                    	<td>Password SIPP MA<font color=red>*</font></td>
                    	<td style="padding:0px;padding-left:5px;">
							<input type="password" id='index_perkara_text' name='index_perkara_text' value="" class="standard-input" maxlength="25">
						</td>
                    </tr>
					<tr>
						<td>Nama Plh Ketua <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='ketua_plh' name='ketua_plh' value="<?php echo $ketua_plh;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_ketua_plh' name='nip_ketua_plh' value="<?php echo $nip_ketua_plh;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr>
						<td>Nama Plh Panitera <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='panitera_plh' name='panitera_plh' value="<?php echo $panitera_plh;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_panitera_plh' name='nip_panitera_plh' value="<?php echo $nip_panitera_plh;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr>
						<td>Nama Plt Ketua <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='ketua_plt' name='ketua_plt' value="<?php echo $ketua_plt;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_ketua_plt' name='nip_ketua_plt' value="<?php echo $nip_ketua_plt;?>" class="standard-input" maxlength="18">
						</td>
					</tr>
					<tr>
						<td>Nama Plt Panitera <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='panitera_plt' name='panitera_plt' value="<?php echo $panitera_plt;?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td><?php echo $this->nativesession->getLangguage('nip');?> <font color="red"></font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='nip_panitera_plt' name='nip_panitera_plt' value="<?php echo $nip_panitera_plt;?>" class="standard-input" maxlength="18">
						</td>
					</tr>

					<tr>
						<td colspan="2" style="background:white;" align="center">
							<input type="button" onClick='kembali();' value="Kembali" class="btn">
							<input type="submit" value="Simpan" class="btn">
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
<script type="text/javascript">
function kembali(){
	javascript:window.history.go(-1);
}

$("#dirjen").change(function(){
    if(($(this).val()==2)){
	    $("tr.tr_pangkat_ketua").show();
		$("tr.tr_pangkat_wakil").show();
		$("tr.tr_pangkat_panitera").show();
		$("tr.tr_pangkat_wakil_panitera").show();		
	}else{ 
	    $("tr.tr_pangkat_ketua").hide();
	    $("tr.tr_pangkat_wakil").hide();
	    $("tr.tr_pangkat_panitera").hide();
		$("tr.tr_pangkat_wakil_panitera").hide();
	}
})

$(this).change(function(e) {
    var val = $('#'+e.target.id).val()
    if(e.target.id=='dirjen'){
    	$("#pt").val('-1');
    	$("#pn").val('-1');
    	var dirjen = $('#dirjen').val();
    	$('#pt').prop('disabled', false);
    	$('#pn').prop('disabled', true);
    	$('.pros_pt').show();
    	$('.pros_pt').not('#'+dirjen).hide();
    	$('#kode_satker').val('');
    	$('#kode_pn').val('');
    	$('#almt').val('');
    	//$('#main-pt').hide();
    }
    if(e.target.id=='pt'){
    	$("#pn").val('-1');
    	var pt = $('#pt').val();
    	$('#pn').prop('disabled', false);
    	$('.pros').show();
    	$('.pros').not('#'+pt).hide();
    	$('#main-pt').hide();
    	$('#kode_satker').val('');
    	$('#kode_pn').val('');
    	$('#almt').val('');
    }

    if(e.target.id=='pn'){
    	var kode_satker = $("#pn").val().split("##");
    	var kode_pn = $("#kode_"+kode_satker).val();
    	var almt_pn = $("#almt_"+kode_satker).val();
    	$('#kode_satker').val(kode_satker[0]);
    	$('#kode_pn').val(kode_pn);
    	$('#almt').val(almt_pn);
    	$('#main-pn').hide();
    }
});

$('#frm_config').SubmitHandling();

<?php
if(!empty($id_pt) OR $id_pt!=-1){
	echo "var pt = $('#pt').val();";
	echo "var dirjen = $('#dirjen').val();";
	echo "$('.pros').not('#'+pt).hide();";
	echo "$('.pros_pt').not('#'+dirjen).hide();";
}
?>
</script>
</div>