<script type="text/javascript">
$(document).ready(function() {		
	$("#tambah").click(function(){
		$(".input").val('');
		cari_nomor();
	});
	
	function cari_nomor(){
		var no = 1;
		
		$.ajax({
			type		: "POST",
			url		: "spv/teller/cari_nomor.php",
			data		: "no="+no,
			dataType: "json",
			success	: function(data){
				$("#txt_kodetl").val(data.nomor);
				$("#txt_jenis").focus();
			}
		});
	}
	
	$("#simpan").click(function(){
		simpan_data();
		return false;
	});

	function simpan_data(){
		var	kodetl	= $("#txt_kodetl").val();
		var	jenis	= $("#txt_jenis").val();
		var 	tanki	= $("#txt_tanki").val();
		var 	angkatl= $("#txt_angkatl").val();
		
		if(kodetl==''){
			alert("Maaf, Nomor teller masih kosong. Klik tombol 'Tambah' untuk mulai pengisian.");  
			return (false);
		}
		
		if(angkatl==''){
			alert("Maaf, Angka teller harus diisi.");
			$("#txt_angkatl").focus();
			return (false);
		}
		
		var error = false;
 
		if(error == false){
		$.ajax({
			type	: "POST",
			url		: "spv/teller/simpan.php",
			data	: "kodetl="+kodetl+
					"&jenis="+jenis+
					"&tanki="+tanki+
					"&angkatl="+angkatl,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#info").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info").html(data);
				$("#tampil_data").load('spv/teller/tampil_data.php');
			}
		});
		}
		return false; 			
	}
	
	$("#keluar").click(function(){
		document.location='?module=home';
	});
});
</script>

<?php
echo "<input type='hidden' id='akses'>";
echo "<table>
	<tr>
		<td>Nomor Teller</td>
		<td>:</td>
		<td><input type='text' name='txt_kodetl' id='txt_kodetl'  size='2' lenght='2' class='input' readonly /></td>
	</tr>
	<tr>
		<td>Jenis BBM</td>
		<td>:</td>
		<td><select name='txt_jenis' id='txt_jenis' >
			<option>Premium</option>
			<option>Bio Solar</option>
			<option>Pertamax</option>
			<option>Pertamax Turbo</option>
			<option>Pertalite</option>
			<option>Pertamina Dex</option>
			<option>Dexlite</option>
			<option>Solar Keekonomian</option>
			</select></td>
	</tr>
	<tr>
		<td>Tanki ke</td>
		<td>:</td>
		<td><select name='txt_tanki' id='txt_tanki' >
			<option>1</option>
			<option>2</option>
			<option>3</option>
			</select></td>
	</tr>	
	<tr>
		<td>Angka Teller</td>
		<td>:</td>
		<td><input type='text' name='txt_angkatl' id='txt_angkatl'  size='11' lenght='11' class='input'></td>
	</tr>
	</table>
	
	<table width='100%'
	<tr>
		<td colspan='3' align='center'>
		<button name='tambah' id='tambah'>Tambah</button>
		<button name='simpan' id='simpan'>Simpan</button>
		<button name='keluar' id='keluar'>Keluar</button>
		</td>
	</tr>
	</table>";
?>