<script type="text/javascript">
$(document).ready(function() {
	cari_nomor();
	$("#txt_nama").focus();
			
	function cari_nomor(){
		var no = 1;
		$.ajax({
			type	: "POST",
			url	    : "modul/dokter/cari_nomor.php",
			data	: "no="+no,
			dataType: "json",
			success	: function(data){
				$("#txt_kode").val(data.nomor);
				tampil_data_detail();
			}
		});
	}
	
	$("#simpan").click(function(){
		var	kode   = $("#txt_kode").val();
		var	nama   = $("#txt_nama").val();
		var	alamat = $("#txt_alamat").val();
		var	nohp   = $("#txt_nohp").val();
		var	spesialis= $("#txt_spesialis").val();
		var	prosenkom= $("#txt_prosenkom").val();
		
		if(nama.length == 0){
			alert("Maaf, Nama kabupaten tidak boleh kosong");
			$("#txt_nama").focus();
			return (false);
        }	 
		 
		$.ajax({
			type	: "POST",
			url	    : "modul/dokter/simpan.php",
			data	: "kode="+kode+
					"&nama="+nama+
					"&alamat="+alamat+
					"&nohp="+nohp+
					"&spesialis="+spesialis+
					"&prosenkom="+prosenkom,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#info").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info").html(data);
				$(".input").val('');		
				$("#txt_nama").focus();
				cari_nomor();
			}
		});
	});
	
	$("#keluar").click(function(){
		document.location='?module=home';
	});
});
</script>

<?php
echo "<input type='hidden' id='akses'>";
echo "<table>
	<tr>
		<td>Kode Dokter</td>
		<td>: <input type='text' id='txt_kode' size='4' lenght='4' value='$kode' class='input' readonly/></td>
	</tr>
	<tr>
		<td>Nama Pelanggan</td>
		<td>: <input type='text' id='txt_nama' size='30' class='input'></td>
	</tr>
	<tr>
		<td>Spesialis</td>
		<td>: <input type='text' id='txt_spesialis' size='30' class='input'></td>
	</tr>	
	<tr>
		<td>Alamat</td>
		<td>: <input type='text' id='txt_alamat' size='60' class='input'></td>
	</tr>
	<tr>
		<td>Nomor HP</td>
		<td>: <input type='text' id='txt_nohp' size='30' class='input'></td>
	</tr>
	<tr>
		<td>Prosentase Komisi</td>
		<td>: <input type='text' id='txt_prosenkom' size='5' class='input'> %</td>
	</tr>
</table>

<table width='100%'>
	<tr>
		<td align='center'>		
		    <button id='simpan'>Simpan</button>
		    <button id='keluar'>Keluar</button>
		</td>
	</tr>
</table>";
?>