<div class="centering" style="width:1024px;margin-top: 1%;">
    <div id='add_penahanan' style="border: 1px solid #ffffff;">
     <div class="detil" style="padding: 2px;background-color: white;">
        <div style="font-size:14px;">
               <form id="frm_penahanan" method="post" action="<?php echo base_url().'tampil_detail';?>">
     			<table id='tableDetilPerkara' style="font-size:14px;">
                         <col width="50%">
                         <col width="60%">
                    	<tr>
     					<td id="first-child">Nomor Perkaras</td>
     					<td>
     						<input type='text' name='no_perkara' id='no_perkara' class="standard-input"/>
                                   <input type='button' value='generate' id='generate_no_perkara' style="padding: 7px 0;color:white;background: #7f8c8d;border: 0 none;  -webkit-border-radius: 0 0 0 0;width: 90px;"/>
     						<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">
     							<select id='sl_nama' name='sl_nama'>
     								<option value='0'>&nbsp&nbsp&nbsp&nbsp&nbsp</option>
     							</select>
     						</span>
     					</td>
     			</tr>
      		<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>
     						<input type="submit" id="simpan" value="OK" class="btn">
                            <input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
     					</td>
     					<td>
     						<input type="button" id='close_form_add_penahanan' onClick='kembali()' value="Kembali" class="btn">
     					</td>
     				</tr>
     			</table>
     			<!--</form>-->
     		</div>
     	</div>
     </div>
</div>
<script type="text/javascript">
	function kembali(){
		window.open('<?php echo $main_history; ?>','_self');
	}
	$('#generate_no_perkara').click(function(){
          $("#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);
		    $("#perkara_id").val(data[0].perkara_id);
		    $('#sl_nama').html('');
		    $("#sl_nama").append("<option value='0'></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_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(){
		
		
		//$('#no_perkara').autocomplete({
		//	source:"<?php echo base_url('addPenahanan_c/search/?'); ?>"
		//});	
	});
	
</script>