<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/customer/cari.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#t_kode").val(kode);
				$("#t_nama").val(data.nama);
				$("#t_alamat").val(data.alamat);
				$("#t_umurpiut").val(data.umurpiut);
				$("#form_cari_plg").dialog('close');
				$("#t_umurpiut").focus();
			}
		});
	}
</script>
<?php
include '../../inc/inc.koneksi.php';

$cari= $_GET['cari'];

echo "<table id='theList' width='100%'>		
		<tr>
			<th width='2%'>No.</th>
			<th>Kode</th>
			<th>Nama Pelanggan</th>
			<th>Alamat</th>
			<th>Telepon</th>
			<th>Aksi</th>
		</tr>";
		if (!empty($cari)){
			$sql= "SELECT * FROM customer WHERE nama LIKE '%$cari%' ORDER BY kode_pl";
		}else{
			$sql= "SELECT * FROM customer ORDER BY kode_pl";
		}
		$query = mysql_query($sql);
		
		$no=1;
		while($r_data=mysql_fetch_array($query)){
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r_data[kode_pl]</td>
				<td>$r_data[nama]</td>
				<td>$r_data[alamat]</td>
				<td>$r_data[telepon]</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"edit_data('$r_data[kode_pl]')\">
						<img src='icon/thumb_up.png' border='0' id='edit' title='Edit' width='12' height='12'>
					</a>
				</td>
			</tr>";
			$no++;
		}
	echo "</table>";
?>