<script type="text/javascript">
$(document).ready(function() {
	cari_nomor();
	$("#txt_nama").focus();
			
	function cari_nomor(){
		var no = 1;
		$.ajax({
			type	: "POST",
			url 	: "modul/customer/cari_nomor.php",
			data	: "no="+no,
			dataType: "json",
			success	: function(data){
				$("#txt_kode").val(data.nomor);
			}
		});
	}
	
	$("#simpan").click(function(){
		var	kode	= $("#txt_kode").val();
		var	nama	= $("#txt_nama").val();
		var	alamat  = $("#txt_alamat").val();
		var	telepon = $("#txt_telepon").val();
		var	kategori= $("#txt_kategori").val();
		var	gudang= $("#txt_gudang").val();
		
		if(nama.length == 0){
			alert("Maaf, Nama paramedis tidak boleh kosong");
			$("#txt_nama").focus();
			return (false);
        }	 
		
		$.ajax({
			type	: "POST",
			url	    : "modul/customer/simpan.php",
			data	: "kode="+kode+
					"&nama="+nama+
					"&alamat="+alamat+
					"&kategori="+kategori+
					"&gudang="+gudang+
					"&telepon="+telepon,
			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
include "../../inc/inc.koneksi.php";

echo "<table>
	<tr>
		<td>Kode Pelanggan</td>
		<td>: <input type='text' id='txt_kode' size='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>Kategori</td>
		<td>: <select id='txt_kategori'>
		        <option>DOKTER</option>
		        <option>BIDAN</option>
		        <option>PERAWAT</option>
		        <option>APOTIK</option>
		    </select>
		</td>
	</tr>
	<tr>
	    <td>Gudang</td>
	    <td>: <select id='txt_gudang'>
		    		<option value='Gudang'>Gudang Pusat</option>";
			    	$sql=mysql_query("SELECT * FROM cabang WHERE 1 ORDER BY kode_cab");
				    while($r=mysql_fetch_array($sql)){
				        $kodecab=$r[kode_cab];
				        echo "<option value='$kodecab'>$r[nama_cab]</option>";
				    }
			    echo "</select>
		</td>
	</tr>
	<tr>
		<td>Alamat</td>
		<td>: <input type='text' id='txt_alamat' size='60' class='input'></td>
	</tr>
	<tr>
		<td>Telepon</td>
		<td>: <input type='text' id='txt_telepon' size='25'' 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>";
?>