
<div style="border: 1px solid #ffffff;width: 35%;margin: 0 auto;">
<div class="detil" style="padding: 2px;background-color: white;">
	<form id="frm_ref_pihak" style="background:white;margin:0;" method="post" action="<?php echo base_url().'addOrtu/validateInput';?>">
		<table id="tableDetilPerkara" class="pihak_list" style="font-size:14px;">
		<col width="40%">
		<col width="60%">
			<tbody>
				<tr>
					<td colspan="2" style='text-align:center;background:white;border:0px;font-size: 20px;color: #648C03;'>TAMBAH ORANG TUA/WALI SAKSI</td>
				</tr>						
				<tr>
					<td>Nama <font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<input type="text" id='pihak_fullname' name='pihak_fullname' value="<?php echo $nama; ?>" class="standard-input" maxlength="500">
					</td>
				</tr>
				<tr>
					<td>Tempat Lahir</td>
					<td style="padding:0px;padding-left:5px;">
						<input type="text" id='pihak_tempat_lahir' name='pihak_tempat_lahir' value="<?php echo $tempat_lahir; ?>" class="standard-input" maxlength="50">
					</td>
				</tr>
				<tr >
					<td>Tanggal Lahir</td>
					<td style="padding:0px;padding-left:5px;">
						<input id="pihak_tgl_lahir" name="pihak_tgl_lahir" value="<?php echo $tgl_lahir; ?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
					</td>
				</tr>
				<tr >
					<td>Umur </td>
					<td style="padding:0px;padding-left:5px;">
						<input type="text" id='pihak_umur' name='pihak_umur' value="" class="standard-input" maxlength="2" style="width:50px;">
					</td>
				</tr>
				<tr>
					<td>Jenis Identitas</td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style='width:200px;'>
							<select name="pihak_jenis_identitas" id="pihak_jenis_identitas" style='width:200px;' class="custom-dropdown__select custom-dropdown__select--white">
								<option value="">Pilih Identitas</option>
								<?php
								if($identitas!=''){
									if($identitas->num_rows()>0){
										foreach ($identitas->result() as $row) {
											$select = ($row->nama==$jenis_identitas)? 'selected':'';
											echo '<option value="'.$row->id.'" '.$select.'>'.$row->nama.'</option>';
										}
									}
								}
								?>								
							</select>
						</span>
					</td>
				</tr>
				<tr >
					<td>No Identitas</td>
					<td style="padding:0px;padding-left:5px;">
						<input type="text" id='pihak_no_identitas' name='pihak_no_identitas' value="<?php echo $nomor_identitas; ?>" class="standard-input" maxlength="50">
					</td>
				</tr>
				<tr>
					<td>No Telepon</td>
					<td style="padding:0px;padding-left:5px;">
						<input type="text" id='pihak_no_tlp' name='pihak_no_tlp' value="<?php echo $telepon; ?>" class="standard-input" maxlength="50">
					</td>
				</tr>
				<tr>
					<td>Alamat Email</td>
					<td style="padding:0px;padding-left:5px;">
						<input type="text" id='pihak_email' name='pihak_email' value="<?php echo $email; ?>" class="standard-input" maxlength="50">
					</td>
				</tr>
				<tr>
					<td>Alamat <font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<textarea id="pihak_alamat" name="pihak_alamat" class="standard-input" maxlength="500" style="width: 245px; height: 70px;resize: none;"><?php echo $alamat; ?></textarea>
					</td>
				</tr>
				<tr >
					<td>Jenis Kelamin <font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style='width:200px;'>
							<select name="pihak_jenis_kelamin" id="pihak_jenis_kelamin" style='width:200px;' class="custom-dropdown__select custom-dropdown__select--white">
								<option value="">Pilih Jenis Kelamin</option>
								<option value="1" <?php if($jenis_kelamin=='L'){echo "selected";}?> >Laki Laki</option>
								<option value="2" <?php if($jenis_kelamin=='P'){echo "selected";}?> >Perempuan</option>
							</select>
						</span>
					</td>
				</tr>
				<tr >
					<td>Agama</td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style='width:200px;'>
							<select name="pihak_agama" id="pihak_agama" style='width:200px;' class="custom-dropdown__select custom-dropdown__select--white">
								<option value="">Pilih Agama</option>
								<?php
								if($agama!=''){
									if($agama->num_rows()>0){
										foreach ($agama->result() as $row) {
											$select = ($row->nama==$agama)? 'selected':'';
											echo '<option value="'.$row->id.'" '.$select.'>'.$row->nama.'</option>';
										}
									}
								}
								?>
							</select>
						</span>
					</td>
				</tr>
				<tr >
					<td>Warga Negara <font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style='width:200px;'>
							<select name="pihak_warga_negara" id="pihak_warga_negara" style='width:200px;' class="custom-dropdown__select custom-dropdown__select--white">
								<?php
								if($country!=''){
									if($country->num_rows()>0){
										foreach ($country->result() as $row) {
											$select = ($row->nama==$warga_negara)? 'selected':'';
											echo '<option value="'.$row->id.'" '.$select.'>'.$row->nama.'</option>';
										}
									}
								}
								?>
							</select>
						</span>
					</td>
				</tr>						
				<tr>
					<td>Pekerjaan<font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">								
						<input type="text"  id='pihak_pekerjaan' name='pihak_pekerjaan' value="<?php echo $pekerjaan; ?>" class="standard-input" maxlength="255" placeholder="Isikan Pekerjaan Di Sini">
					</td>
				</tr>																	
				<tr>
					<td colspan="2" style="background:white;" align="center">
						<input type="hidden" id='act' name="act" value="<?php echo $act;?>">
						<input type="hidden" id='enc_pihak' name="enc_pihak" value="<?php echo $enc_pihak;?>">
						<input type="hidden" id='enc' name="enc" value="<?php echo $enc;?>">
						<input type="hidden" id='enc_ortu' name="enc_ortu" value="<?php echo $enc_ortu;?>">
						<input type="hidden" id='jenis_pihak' name="jenis_pihak" value="<?php echo $jenis_pihak;?>">
						<input type="hidden" id="curr_date" value="<?php echo $current_date;?>">								
						<input type="button" id='back_pihak' value="Kembali" class="btn">
						<input type="submit" id="simpan_btn" value="Simpan" class="btn">
					</td>
				</tr>
			</tbody>
		</table>
	</form>
</div>
</div>
<script type="text/javascript">
$('#back_pihak').closingFormWin();
$("#pihak_tgl_lahir").change(function() {
	var error = 0;
	var tmp = $(this).val().split("/");
	var tmp2 = $('#curr_date').val().split("/");
	dob = new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00");
	var today = new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00");
	var age = Math.floor((today-dob) / (365.25 * 24 * 60 * 60 * 1000));
	if(age<5 || age >100){
		message = 'Tanggal Lahir Tidak Valid. Silahkan Periksa Kembali';
		error = 1
	}
	if(error==1){
		message_error_show(message);
		$(this).css("background-color", "red");
	}else{
		$('#pihak_umur').val(age);
		$(this).css("background-color", "#dedbdb");
	}
	error = 0;
});

$("#pihak_umur").change(function() {
	var age = $('#pihak_umur').val();
	var error = 0;
	var tmp2 = $('#curr_date').val().split("/");
	var year = tmp2[2]-age;
	if(age<5 || age >100){
		message_error_show('Tanggal Lahir Tidak Valid. Silahkan Periksa Kembali');
		$(this).css("background-color", "red");
	}else{
		var tglLahir = tmp2[0]+'/'+tmp2[1]+'/'+year;
		$("#pihak_tgl_lahir").val(tglLahir)
		$(this).css("background-color", "#dedbdb");
	}
});


$('#frm_ref_pihak').SubmitHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#pihak_pilih',
	clicked:1,
	btnClicked:'#back_pihak',
	whenStatus:1
});

$('.datepicker').ValidateDateInput();
</script>