<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        $("#theList tr:even").addClass("stripe1");
        $("#theList tr:odd").addClass("stripe2");

        $("#theList tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});

	function edit_data(ID){
		
		var kode = ID;
		$.ajax({
			type		: "POST",
			url		: "spv/teller/cari.php",
			data	: "kode="+kode,
			dataType	: "json",
			success	: function(data){
				$("#txt_kodetl").val(kode);				
				$("#txt_jenis").val(data.jenis);
				$("#txt_tanki").val(data.tanki);
				$("#txt_angkatl").val(data.angkatl);
			
				$("#info").html("Data sudah di tampung pada tab inputan, silahkan klik");
			}
		});
	}
	
	function hapus_data(ID){	
		var pilih = confirm('Hapus data teller nomor  '+ID+ '?');
		if (pilih==true) {
		var kode = ID;
		$.ajax({
			type	: "POST",
			url	: "spv/teller/hapus.php",
			data	: "kode="+kode,
			success	: function(data){
				$("#info").html(data);
				$("#tampil_data").load('spv/teller/tampil_data.php');
			}
		});
		}
	}

</script>
<?php
include '../../inc/inc.koneksi.php';

$cari	= $_GET['cari'];
echo "<table id='theList' width='100%'>
		<tr>
			<th>No. Teller</th>
			<th>Jenis BBM</th>
			<th>Tanki</th>
			<th>Angka Teller</th>
			<th>Last Update</th>
			<th>Aksi</th>
		</tr>";
		
		if (!empty($cari))
			$sql	= "SELECT * FROM teller WHERE (kode_tl LIKE '%$cari%' OR jenis LIKE '%$cari%') ORDER BY kode_tl";		
		else
			$sql	= "SELECT * FROM teller ORDER BY kode_tl";
	
		$query = mysql_query($sql);
		
		while($r_data=mysql_fetch_array($query)){
			echo "<tr>
					<td align='center'>$r_data[kode_tl]</td>
					<td>$r_data[jenis]</td>
					<td align='center'>$r_data[tanki]</td>
					<td align='right'>$r_data[angka_tl]</td>
					<td>$r_data[lastupdate]</td>
					<td align='center'>
						<a href='javascript:void(0)' onClick=\"edit_data('$r_data[kode_tl]')\">
							<img src='icon/thumb_up.png' border='0' id='edit' title='Edit' width='12' height='12' >
						</a>
						<a href='javascript:void(0)' onClick=\"hapus_data('$r_data[kode_tl]')\">
							<img src='icon/thumb_down.png' border='0' id='hapus' title='Hapus' width='12' height='12' >
						</a>					
					</td>
					</tr>";
		}
		
	echo "</table>";
?>