<?php
$jenispengadilan=$this->session->userdata('jenis_pengadilan');
?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>resources/css/autocomplete.css">
<div class="centering" style="width:500px;margin-top: 2%;">
    <div id='pihak_pilih' style="border: 1px solid #ffffff;">
          <div class="detil" style="padding: 2px;background-color: white;">
            <div style="font-size:14px;">
                  <form id="frm_add_penahanan" name="frm_add_penahanan" style="background:white;margin:0;" method="post" action="<?php echo base_url().'addPenahanan_c/input_data_penangguhan';?>">
                        <table id='tableDetilPerkara' style="font-size:14px;">
                              <col width="40%">
                              <col width="65%">
                              <tr>
                                <td colspan="2" style="background:white;border:0px;font-size: 20px;color: #648C03;" align="center">
                                  <?php if ($cek_bantar<0){ echo "TAMBAH";}else{echo "EDIT";};?> - DATA PENAHANAN (PENANGGUHAN)
                                </td>
                              </tr>
                              <tr>
                                  <td id="first-child">Jenis Jaminan<font color=red>*</font></td>
                                  <td>
                                      <span class="custom-dropdown custom-dropdown--emerald">
                                          <select style='width:250px;'  name="jaminan" id="jaminan"  class="custom-dropdown__select custom-dropdown__select--white">                                                                                        
                                              <option value='1' <?php echo ($jenis_jaminan==1)? "selected":''; ?> >Penangguhan Jaminan Orang</option>
                                              <option value='2' <?php echo ($jenis_jaminan==2)? "selected":''; ?> >Penangguhan Jaminan Uang</option>
                                              <option value='3' <?php echo ($jenis_jaminan==3)? "selected":''; ?> >Penangguhan Tanpa Jaminan</option>
                                          </select>
                                      </span>
                                  </td> 
                              </tr>
                              <tr>
                                   <td id="first-child">Tanggal Permohonan<font color=red>*</font></td>
                                   <td>
                                        <input id="tanggal_permohonan" name="tanggal_permohonan" value="<?php echo !empty($tanggal_permohonan)?$this->tanggalhelper->convertToInputDate($tanggal_permohonan):date('d/m/Y'); ?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                                   </td>     
                              </tr>                              
                              <tr>
                                   <td id="first-child">Nomor Permohonan<font color=red>*</font></td>
                                   <td>
                                        <input class="standard-input" type='text' name='nomor_permohonan' id='nomor_permohonan' value='<?php echo !empty($nomor_permohonan)?$nomor_permohonan:"";?>'>                                        
                                   </td>     
                              </tr>                              
                              <tr class="row_jaminan">
                                   <td id="first-child">Tanggal Perjanjian<font color=red>*</font></td>
                                   <td>
                                        <input id="tanggal_perjanjian" name="tanggal_perjanjian" value="<?php echo !empty($tanggal_perjanjian)?$this->tanggalhelper->convertToInputDate($tanggal_perjanjian):date('d/m/Y'); ?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                                   </td>     
                              </tr>                                 
                              <tr class="row_jaminan">
                                   <td id="first-child">Nomor Perjanjian<font color=red>*</font></td>
                                   <td>
                                        <input class="standard-input" type='text' name='nomor_perjanjian' id='nomor_perjanjian' value='<?php echo !empty($nomor_perjanjian)?$nomor_perjanjian:"";?>'>                                        
                                   </td>     
                              </tr>
                              <tr class="tr_perorangan">
                                <td>Nama <font color="red">*</font></td>
                                <td style="padding:0px;padding-left:5px;">
                                  <?php $url = base_url('pihak_list/');?>
                                  <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="<?php echo $popup==5?'popup_form5th':'popup_form2nd'; ?>('<?php echo $url;?>')" 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 class="tr_perorangan">
                              <td>Tempat Lahir <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 class="tr_perorangan">
                              <td>Tanggal Lahir <font color=red>*</font></td>
                              <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_lahir" name="tgl_lahir" value="<?php echo (!empty($tglLahir) ? $this->tanggalhelper->convertToInputDate($tglLahir) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun" readonly="readonly">
                              </td>
                            </tr>
                            <tr class="tr_perorangan">
                              <td>Umur <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 class="tr_perorangan">
                              <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 class="tr_perorangan">
                              <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 class="tr_perorangan">
                              <td class="tr_perorangan">Alamat <font color="red">*</font></td>
                              <td style="padding:0px;padding-left:5px;">
                                <textarea class="standard-input" id="alamat" name = "alamat" maxlength="500" style="width: 245px; height: 70px;resize: none;" readonly><?php echo (!empty($alamat) ? $alamat : '');?></textarea>
                              </td>
                            </tr>
                            <tr class="tr_perorangan">
                              <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>
                            <tr class="row_jaminan">
                                 <td id="first-child">Uang Jaminan<font color=red>*</font></td>
                                 <td>
                                    <input class="standard-input" type='text' name='uang_jaminan' id='uang_jaminan' value='<?php echo !empty($uang_jaminan)?$uang_jaminan:"";?>'>                                        
                                 </td>     
                            </tr>
                            <tr class="row_setoran">
                                 <td id="first-child">Nomor Bukti Setoran<font color=red>*</font></td>
                                 <td>
                                    <input class="standard-input" type='text' name='nomor_bukti_setoran' id='nomor_bukti_setoran' value='<?php echo !empty($nomor_bukti_setoran)?$nomor_bukti_setoran:"";?>'>                                        
                                 </td>     
                            </tr>
                            <tr class="row_setoran">
                                 <td id="first-child">Tanggal Bukti Setoran<font color=red>*</font></td>
                                 <td>
                                      <input id="tanggal_bukti_setoran" name="tanggal_bukti_setoran" value="<?php echo !empty($tanggal_bukti_setoran)?$this->tanggalhelper->convertToInputDate($tanggal_bukti_setoran):date('d/m/Y'); ?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                                 </td>     
                            </tr>
                            <tr class="row_pertimbangan">
                                 <td id="first-child">Pertimbangan<font color=red>*</font></td>
                                 <td>
                                    <textarea class="standard-input" id="pertimbangan" name = "pertimbangan" maxlength="255" style="width: 245px; height: 90px;resize: none;" placeholder="Menimbang, bahwa berdasarkan ...."><?php echo (!empty($pertimbangan) ? $pertimbangan : '');?></textarea>                                    
                                 </td>     
                            </tr>
                              <tr>
                                <td colspan='2' style='background:white;text-align:center;'>
                                  <input type='hidden' value='<?php echo $perkara_id;?>' name='perkara_id' id='perkara_id'/>
                                  <input type="hidden" id='enc_pihak' name="enc_pihak" value="<?php echo (!empty($enc_pihak) ? $enc_pihak : '');?>">
                                  <input type='hidden' value='<?php echo $pihak_id;?>' name='pihak_id' id='pihak_id'/>
                                  <input type='hidden' value='<?php echo $penahanan_id;?>' name='penahanan_id' id='penahanan_id'/>
                                  <input type='hidden' value='<?php echo $jenis_jaminan;?>' name='jenis_jaminan' id='jenis_jaminan'/>
                                  <input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
                                  <input type="button" id='close_form_perpanjangan_penahanan' value="Kembali" class="btn">
                                  
								  <?php if($cek_bantar>0){?>
								  <input type="button" id="hapus" value="Hapus" style="text-decoration:none" class="btn btn-danger">
								  <?php }?>
								  <input type="submit" id="simpan" value="Simpan" class="btn">
                                  
                                </td>
                              </tr>
                         </table>
					</form>
				</div>
			</div>     
		</div>
</div>
<script type="text/javascript">
$("#close_form_perpanjangan_penahanan").closingFormWin();
$('.datepicker').ValidateDateInput();

/* === penambahan alert jika tdk menggunakan json === */
$("#hapus").click(function(){
	var konfirmasi=confirm('Apakah Anda Yakin Akan Hapus Data?');
	if (konfirmasi){
	location.href="<?php echo base_url().'addPenahanan_c/hapus_template_bantar/'.$perkara_id.'/'.$pihak_id.'/'.$id_template_bantar;?>";
	}
});
var jaminan_id = "<?php echo $jenis_jaminan; ?>";
if(jaminan_id==1){
  $("tr.row_jaminan").show();
  $("tr.tr_perorangan").show();
  $("tr.row_setoran").hide();
  $("tr.row_pertimbangan").hide();
}else if(jaminan_id==2){
  $("tr.row_jaminan").show();
  $("tr.row_setoran").show();
  $("tr.tr_perorangan").hide();
  $("tr.row_pertimbangan").hide();
}else if(jaminan_id==3){
  $("tr.row_pertimbangan").show();
  $("tr.tr_perorangan").hide();
  $("tr.row_jaminan").hide();
  $("tr.row_setoran").hide();
}else{
  $("tr.row_jaminan").show();
  $("tr.tr_perorangan").show();
}


$("#jaminan").change(function(){
    if($(this).val()==1){
      $("tr.row_jaminan").show();
      $("tr.tr_perorangan").show();
      $("tr.row_setoran").hide();
      $("tr.row_pertimbangan").hide();
    }else if($(this).val()==2){
      $("tr.row_jaminan").show();
      $("tr.row_setoran").show();
      $("tr.tr_perorangan").hide();
      $("tr.row_pertimbangan").hide();
    }else{
      $("tr.row_pertimbangan").show();
      $("tr.tr_perorangan").hide();
      $("tr.row_jaminan").hide();
      $("tr.row_setoran").hide();
    }
})


  
$('#tanggal_permohonan').datepicker({
	inline: true,
	showOtherMonths: true,
	dateFormat: 'dd/mm/yy',
	dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
	onSelect: function(dateText, inst) {
		var error = 0;
		var tmp = $(this).val().split("/");
		var tmp2 = $('#curr_date').val().split("/");
		if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() > new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00").getTime())){
			message = 'Tidak Dapat Memilih Melebihi Hari ini. Sekarang Tanggal '+$('#curr_date').val();
			error = 1
		}
		if(error==1){
			message_error_show(message);
			$(this).css("background-color", "red");
		}else{
			$(this).css("background-color", "#dedbdb");
		}
		error = 0;
	}
});
	 
$('#tanggal_perjanjian').datepicker({
  inline: true,
  showOtherMonths: true,
  dateFormat: 'dd/mm/yy',
  dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
  onSelect: function(dateText, inst) {
    var error = 0;
    var tmp = $(this).val().split("/");
    var tmp2 = $('#curr_date').val().split("/");
    if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() > new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00").getTime())){
      message = 'Tidak Dapat Memilih Melebihi Hari ini. Sekarang Tanggal '+$('#curr_date').val();
      error = 1
    }
    if(error==1){
      message_error_show(message);
      $(this).css("background-color", "red");
    }else{
      $(this).css("background-color", "#dedbdb");
    }
    error = 0;
  }
});
$('#tanggal_bukti_setoran').datepicker({
  inline: true,
  showOtherMonths: true,
  dateFormat: 'dd/mm/yy',
  dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
  onSelect: function(dateText, inst) {
    var error = 0;
    var tmp = $(this).val().split("/");
    var tmp2 = $('#curr_date').val().split("/");
    if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() > new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00").getTime())){
      message = 'Tidak Dapat Memilih Melebihi Hari ini. Sekarang Tanggal '+$('#curr_date').val();
      error = 1
    }
    if(error==1){
      message_error_show(message);
      $(this).css("background-color", "red");
    }else{
      $(this).css("background-color", "#dedbdb");
    }
    error = 0;
  }
});
</script>