<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/returjual/cari_barang.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_jenisst").val(data.jenisst);
				$("#txt_kodest").val(data.kodest);
				$("#txt_namast").val(data.namast); 
				$("#txt_jmlkirim").val(data.jmlkirim);
				$("#txt_satuan").val(data.tsatuan);
				$("#txt_hgjual").val(data.hgjual);
				$("#txt_hgbeli").val(data.hgbeli);
				$("#form_cari_barang").dialog('close');
				$("#txt_jmlretur").focus();
			}
		});
	}

</script>
<?php
include '../../inc/inc.koneksi.php';
$kode	= $_POST['kode'];

echo "<table id='theList' class='barang' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode Barang</th>
			<th>Nama Barang</th>
			<th>Satuan</th>
			<th>Jml. Kirim</th>
			<th>Harga Jual</th>
			<th>Potongan</th>
			<th>Jumlah Harga</th>
			<th>Ambil</th>
		</tr>";
		$sql = "SELECT * FROM faktur_pj WHERE kode_pj='$kode' ";
				
		$query = mysql_query($sql);
		$jml_data = mysql_num_rows($query);
		$no=1;
		while($r_data=mysql_fetch_array($query)){
			$kode = $r_data[kode_pj].'.'.$r_data[kode_st];
			echo "<tr>
					<td align='center'>$no</td>
					<td>$r_data[kode_st]</td>
					<td>$r_data[nama_st]</td>
					<td>$r_data[satuan]</td>
					<td align='right'>$r_data[jml_unit]</td>
					<td align='right'>".number_format($r_data[hg_jual],0)."</td>
					<td align='right'>".number_format($r_data[potongan],0)."</td>
					<td align='right'>".number_format($r_data[jumlah],0)."</td>
					<td align='center'>
						<a href='javascript:void(0)' onClick=\"pilih('$kode')\">
						<img src='icon/download.gif' border='0' id='tambah_data' title='Pilih' width='12' height='12' >
					</a>					
					</td>
					</tr>";
			$no++;			
		}
		
echo "</table>";
?>