<style type="text/css">
td {
     border:1px solid #ddd;
}
</style>
<div class="centering" style="width:500px;margin-top: 1%;">
<div id='edit_penahanan' style="border: 1px solid #ffffff;">
     <div class="detil" style="padding: 2px;background-color: white;">
          <form id="frm_penahanan" style="background:white;margin:0;" method="post" action="">
               <table id="tableDetilPerkara" style="font-size:14px;;">
                    <col width="30%">
                    <col width="70%">
                    <tbody>
                         <tr><td colspan="2" style="background:white;border:0px;font-size: 20px;color: #648C03;" align="center">Tambah Penahanan Terdakwa</td></tr>
     				<tr>
     					<td id="first-child">Nomor Perkara</td>
     					<td>
     						<input type='text' name='no_perkara' id='no_perkara' style="width:70%;" class="standard-input"/>
                                   <input type='button' value='Cari' id='cari' class="btn"/>
     						<input type='hidden' name='perkara_id' id='perkara_id'value=''/>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Nama</td>
     					<td>
     						<span class="custom-dropdown custom-dropdown--emerald" style="width:100%;height: 26px;">
     							<select id='sl_nama' name='sl_nama' style="width:100%" class="custom-dropdown__select custom-dropdown__select--white">
     								<option value='0'></option>
     							</select>
     						</span>
     					</td>
     				</tr>
     				<tr>
                         <?php if ($this->session->userdata('jenis_pengadilan')=='2'){ ?>
                         <tr>
                              <td id="first-child">NRP</td>
                              <td>
                                   <span id='sp_nrp'></span>
                              </td>   
                         </tr>     
                         <tr>
                              <td id="first-child">Pangkat</td>
                              <td>
                                   <span id='sp_pangkat'></span>
                              </td>   
                         </tr>
                         <tr>
                              <td id="first-child">Jabatan</td>
                              <td>
                                   <span id='sp_jabatan'></span>
                              </td>   
                         </tr>
                         <tr>
                              <td id="first-child">Kesatuan</td>
                              <td>
                                   <span id='sp_kesatuan'></span>
                              </td>   
                         </tr>
                         <?php
                              }
                         ?>                           
     			     <tr>
                        	     <td id="first-child">Tempat Lahir</td>
     				     <td>
     			  	         <span id='sp_tempat_lahir'></span>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Tanggal Lahir</td>
     					<td>
     						<span id='sp_tanggal_lahir'></span>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Umur</td>
     					<td>
     						<span id='sp_umur'></span>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Jenis Kelamin</td>
     					<td>
     						<span id='sp_jenis_kelamin'></span>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Warga Negara</td>
     					<td>
     						<span id='sp_warga_negara'></span>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Alamat</td>
     					<td>
     						<span id='sp_alamat'></span>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Agama</td>
     					<td>
     						<span id='sp_agama'></span>
     					</td>
     				</tr>
     				<tr>
     					<td id="first-child">Pekerjaan</td>
     					<td>
     						<span id='sp_pekerjaan'></span>
     					</td>
     				</tr>
     				<tr>
     					<td colspan="3" style="background:white;" align="center">
     					<input type="submit" id="simpan" value="OK" class="btn">
                              <input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
     					<input type="button" id='close_form_add_penahanan' onClick='kembali()' value="Kembali" class="btn">
     					</td>
     				</tr>
     			</table>
     			</form>
     		</div>
     	</div>
     </div>
</div>
</div>
</div>
<script type="text/javascript">
     var base = "<?php echo base_url('tampil_detail_penahanan'); ?>";
	function kembali(){
		window.open('<?php echo $main_history; ?>','_self');
	}
	$('#cari').click(function(){
          $("#sp_nrp").text('');
          $("#sp_pangkat").text('');
          $("#sp_jabatan").text('');
          $("#sp_kesatuan").text('');

		$("#sp_tempat_lahir").text('');
          $("#sp_tanggal_lahir").text('');
          $("#sp_umur").text('');
          $("#sp_jenis_kelamin").text('');
          $("#sp_warga_negara").text('');
          $("#sp_alamat").text('');
          $("#sp_agama").text('');
          $("#sp_pekerjaan").text('');
		$.post( "<?php echo base_url().'addPenahanan_c/load';?>", { no_perkara: $('#no_perkara').val()})
		  .done(function(json) {
			data = JSON.parse(json);
               if(data.st==0){
                    message_error_show_parent(data.msg);
                    return;
               }
               $("#perkara_id").val(data[0].perkara_id);
		     $('#sl_nama').html('');
               //base_url('tampil_detail_penahanan/'.base64_encode($this->encrypt->encode($row->pihak_id)).'/'.base64_encode($this->encrypt->encode($row->perkara_id)))
               $("#frm_penahanan").attr("action", base+'/'+data[0].pihak_id+'/'+data[0].perkara_id);
               $("#sl_nama").append("<option value='0'>Pilih Nama Terdakwa</option>");
               $.each(data, function(key, val){
		    	$("#sl_nama").append("<option value='"+val.pihak_id+"'>"+val.nama+"</option>");
		    }); 
		});
	});

	$("#sl_nama").change(function () {
        $.post("<?php echo base_url().'addPenahanan_c/names';?>", {pihak_id: $('#sl_nama').val()})
          .done(function(json){
          	data = JSON.parse(json);
               $("#sp_nrp").text(data[0].nrp);
               $("#sp_pangkat").text(data[0].pangkat);
               $("#sp_jabatan").text(data[0].jabatan);
               $("#sp_kesatuan").text(data[0].kesatuan);

          	$("#sp_tempat_lahir").text(data[0].tempat_lahir);
          	$("#sp_tanggal_lahir").text(data[0].tanggal_lahir);
          	$("#sp_umur").text(data[0].umur);
          	$("#sp_jenis_kelamin").text(data[0].jenis_kelamin);
          	$("#sp_warga_negara").text(data[0].warga_negara);
          	$("#sp_alamat").text(data[0].alamat);
          	$("#sp_agama").text(data[0].agama);
          	$("#sp_pekerjaan").text(data[0].pekerjaan);
        });
    });
	$(document).ready(function(){
	});
	
</script>