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

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

	function pilih(ID){
		var kode = ID;
		$.ajax({
			type	: "POST",
			url	: "modul/penjualan/cari_plg.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_kodeplg").val(kode);
				$("#txt_namaplg").val(data.namaplg);
				$("#form_cari_plg").dialog('close');
				cari_faktur();
			}
		});
	}
	
	function cari_faktur(){
		$('#form_cari_faktur').dialog('open');
		var kodeplg = $("#txt_kodeplg").val();
		$.ajax({
			type	: "POST",
			url	: "modul/returjual/tampil_data_faktur.php",
			data	: "kodeplg="+kodeplg,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#info_faktur").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info_faktur").html(data);
			}
		});
	}
</script>
<?php
include '../../inc/inc.koneksi.php';
$cari	= $_POST['cari'];

echo "<table id='theList' class='barang' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Pelanggan</th>
			<th>Alamat</th>			
			<th>Ambil</th>
		</tr>";
		
		if (!empty($cari))
			$sql = "SELECT * FROM customer WHERE kode_pl LIKE '%$cari%' OR nama LIKE '%$cari%' ORDER BY kode_pl";
		else
			$sql = "SELECT * FROM customer ORDER BY kode_pl";
		
		$query = mysql_query($sql);
		$jml_data = mysql_num_rows($query);
		$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 align='center'>
						<a href='javascript:void(0)' onClick=\"pilih('$r_data[kode_pl]')\">
						<img src='icon/download.gif' border='0' id='tambah_data' title='Tambah' width='12' height='12' >
					</a>					
					</td>
					</tr>";
			$no++;			
		}
		
	echo "</table>";
?>