<?php
if(isset($aktif)){
	if(!empty($aktif)){
		$aktif = $aktif;
	}else{
		$aktif = '';
	}
}else{
	$aktif = '';
}

if(isset($aktif_mulai)){
	if(!empty($aktif_mulai)){
		$aktif_mulai = $aktif_mulai;
	}else{
		$aktif_mulai = '';
	}
}else{
	$aktif_mulai = '';
}

if(isset($aktif_sampai)){
	if(!empty($aktif_sampai)){
		$aktif_sampai = $aktif_sampai;
	}else{
		$aktif_sampai = '';
	}
}else{
	$aktif_sampai = '';
}
?>	
	<div class="centering" style="width:460px;margin-top: 1%;">
		<div id='pihak_pilih' style="border: 1px solid #ffffff;">
			<div class="detil" style="padding: 2px;background-color: white;">
		<form id="frm_user" style="background:white;margin:0;" method="post" action="<?php echo base_url().'addPengacara/validateInput';?>">
			<table id="tableDetilPerkara" style="font-size:14px;">
				<col width="38%">
				<col width="62%">
				<tbody>
					<tr>
						<td colspan="2" style='text-align:center;background:#fff;color:#5fb85c;border:2px solid #fff;margin-bottom:10px;font-size: 20px;'><?php echo $title;?></td>
					</tr>

					<tr>
						<td>Para Pihak <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="checkbox" name="all" id="all" /> <label for='all'>Pilih Semua</label><br>
							<?php
							if($para_pihak!=''){
								if($para_pihak->num_rows>0){
									foreach ($para_pihak->result() as $row) {
										$enc_ids = base64_encode($this->encrypt->encode($row->pihak_id));
										$chck = ($act=='edit')? 'checked':'';
										echo '<input type="checkbox" name="para_pihak[]" value="'.$enc_ids.'" '.$chck.'> '.$row->nama.'<br>';
									}
								}
							}
							?>
						</td>
						<input type="hidden" id='pihak_ke' name="pihak_ke" value="<?php echo $pihak_ke;?>">
					</tr>
					<tr>
						<td>No Urut<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='no_urut' name='no_urut' value="<?php echo $urutan;?>" class="standard-input" maxlength="10" readonly="readonly" style="width:50px;">
						</td>
					</tr>	
					<tr>
						<td>Nama <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='fullname' name='fullname' value="<?php echo (!empty($nama) ? $nama : '');?>" class="standard-input" maxlength="255" style="width:150px;" readonly="readonly">
							<input type="button" onClick="popup_form2nd('<?php echo base_url('pengacara_list');?>')" value="Cari" style="padding: 7px 0;color:white;background: #7f8c8d;border: 0 none;  -webkit-border-radius: 0 0 0 0;width: 90px;">
						</td>
					</tr>
					<tr>
						<td>Tempat Lahir <?php echo ($this->session->userdata('jenis_pengadilan')!=3)? '<font color="red">*</font>':'';?></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='tempat_lahir' name='tempat_lahir' value="<?php echo (!empty($tempatLahir) ? $tempatLahir : '');?>" class="standard-input" maxlength="255" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td>Tanggal Lahir <?php echo ($this->session->userdata('jenis_pengadilan')!=3)? '<font color="red">*</font>':'';?></td>
						<td style="padding:0px;padding-left:5px;">
							<input id="tgl_lahir" name="tgl_lahir" value="<?php echo (!empty($tglLahir) ? $tglLahir : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td>Umur <?php echo ($this->session->userdata('jenis_pengadilan')!=3)? '<font color="red">*</font>':'';?></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='umur' name='umur' value="<?php echo (!empty($umur) ? $umur : '');?>" class="standard-input" maxlength="2" readonly="readonly" style="width:50px;" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td>Jenis Kelamin <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='jenis_kelamin' name='jenis_kelamin' value="<?php echo (!empty($sex) ? $sex : '');?>" class="standard-input" maxlength="255" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td>Warga Negara <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='warga_negara' name='warga_negara' value="<?php echo (!empty($wargaNegara) ? $wargaNegara : '');?>" class="standard-input" maxlength="255" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td>Alamat <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<textarea class="standard-input" id="alamat" name = "alamat"  style="width: 280px; height: 80px;resize: none;" readonly><?php echo (!empty($alamat) ? $alamat : '');?></textarea>
						</td>
					</tr>
					<tr>
					<?php
						if($this->session->userdata('jenis_pengadilan')!=2){
					?>
						<td>Pekerjaan <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pekerjaan' name='pekerjaan' value="<?php echo (!empty($pekerjaan) ? $pekerjaan : '');?>" class="standard-input" maxlength="255" readonly="readonly">
						</td>
					</tr>
					<?php
						}
					?>
					<tr>
						<td>Status Kawin <?php echo ($this->session->userdata('jenis_pengadilan')!=3)? '<font color="red">*</font>':'';?></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='statusKawin' name='statusKawin' value="<?php echo (!empty($kawin) ? $kawin : '');?>" class="standard-input" maxlength="255" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td>Pendidikan <?php echo ($this->session->userdata('jenis_pengadilan')!=3)? '<font color="red">*</font>':'';?></td>
						<td style="padding:0px;padding-left:5px;">
							<input type="text" id='pendidikan' name='pendidikan' value="<?php echo (!empty($pendidikan) ? $pendidikan : '');?>" class="standard-input" maxlength="255" readonly="readonly">
						</td>
						<input type="hidden" id='enc_pengacara' name="enc_pengacara" value="<?php echo (!empty($enc_pengacaraid) ? $enc_pengacaraid : '');?>">
						<input type="hidden" id='enc' name="enc" value="<?php echo $enc;?>">
						<input type="hidden" id='act' name="act" value="<?php echo $enc_act;?>">
						<input type="hidden" id='enc_id' name="enc_id" value="<?php echo $enc_id;?>">
						<input type="hidden" id='enc_idpengacara' name="enc_idpengacara" value="<?php echo $enc_pengacaraid;?>">

					</tr>
					<tr>
						<td>Aktif <font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<span class="custom-dropdown custom-dropdown--emerald" style="width:80px">
								<select style="width:80px" name="aktif" id="aktif" class="custom-dropdown__select custom-dropdown__select--white">
									<option value="Y" <?php echo ($aktif=='Y')?  'selected':'';?> > Ya</option>
									<option value="T" <?php echo ($aktif=='T')?  'selected':'';?> > Tidak</option>
								</select>
							</span>
						</td>
					</tr>
					<tr>
						<td>Aktif Mulai <?php echo ($this->session->userdata('jenis_pengadilan')!=3)? '<font color="red">*</font>':'';?></td>
						<td style="padding:0px;padding-left:5px;">
							<input id="begin_aktif" name="begin_aktif" value="<?php echo (!empty($aktif_mulai) ? $this->tanggalhelper->convertToInputDate($aktif_mulai) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
						</td>
					</tr>
					
					<?php if ($this->session->userdata('jenis_pengadilan')!=2){ ?> 
					<tr>
						<td>Aktif Sampai <?php echo ($this->session->userdata('jenis_pengadilan')!=3)? '<font color="red">*</font>':'';?></td>
						<td style="padding:0px;padding-left:5px;">
							<input id="end_aktif" name="end_aktif" value="<?php echo (!empty($aktif_sampai) ? $this->tanggalhelper->convertToInputDate($aktif_sampai) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
						</td>
					</tr>
					<?php } ?>
					<tr>
						<td>Nomor Surat Kuasa<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input id="nmr_kuasa" name="nmr_kuasa" value="<?php echo (!empty($nomor_kuasa) ? $nomor_kuasa : '');?>" class="standard-input" maxlength="255">
						</td>
					</tr>
					<tr>
						<td>Tanggal Surat Kuasa<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input id="tgl_kuasa" name="tgl_kuasa" value="<?php echo (!empty($tanggal_kuasa) ? $this->tanggalhelper->convertToInputDate($tanggal_kuasa) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
						</td>
					</tr>
					<tr>
						<td>Keterangan</td>
						<td style="padding:0px;padding-left:5px;border:0px;">
							<textarea class="standard-input" id="keterangan" name ="keterangan" style="width: 280px; height: 80px;resize: none;"><?php echo (!empty($keterangan) ? $keterangan : '');?></textarea>
						</td>
					</tr>
					<tr>
						<td colspan="2" style="background:white;border:0px;" align="center">
							<input type="button" id='close_form_add_pihak' value="Kembali" class="btn">
							<?php
							$act = $this->encrypt->decode(base64_decode($enc_act));
							if($act=="edit"){
								echo '<input type="submit" id="hapus" value="Hapus" class="btn btn-danger" onclick="return false;">';
							}
							?>
							<input type="submit" id="simpan" value="Simpan" class="btn">
							<input type="hidden" id="refresh" class='detil_perkara_refresh' value="0">
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
</div>
</div>
<script type="text/javascript">
$('#close_form_add_pihak').closingFormWin();

$(".detil #refresh").change(function(){
	refreshPengacaraList()
});

function refreshPengacaraList(){
	$("#popup_form_2nd").remove();
	popup_form2nd('<?php echo base_url("pengacara_list");?>');
}
$('#frm_user').SubmitHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_form_add_pihak',
	whenStatus:1
});

$('#hapus').ButtonClickHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_form_add_pihak',
	whenStatus:1,
	actions:'<?php echo base_url()?>addPengacara/validateDelete',
	formName:'#frm_user',
	actionName:'Hapus Data'
});

$('#begin_aktif').datepicker({
	inline: true,
	showOtherMonths: true,
	dateFormat: 'dd/mm/yy',
	dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
	beforeShowDay: $.datepicker.noWeekends,
	onSelect: function(dateText, inst) {
	}
});

$('#end_aktif').datepicker({
	inline: true,
	showOtherMonths: true,
	dateFormat: 'dd/mm/yy',
	dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
	beforeShowDay: $.datepicker.noWeekends,
	onSelect: function(dateText, inst) {
	}
});
$('#tgl_kuasa').datepicker({
	inline: true,
	showOtherMonths: true,
	dateFormat: 'dd/mm/yy',
	dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
	beforeShowDay: $.datepicker.noWeekends,
	onSelect: function(dateText, inst) {
	}
});

$(document).ready(function(){
	$('input[name="all"],input[name="title"]').bind('click', function(){
	var status = $(this).is(':checked');
	$('input[type="checkbox"]').attr('checked', status);
	});

});
</script>