<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/returbeli/cari_faktur.php",
			data	: "kode="+kode,
			dataType	: "json",
			success	: function(data){
				$("#txt_nomorfk").val(kode);
				$("#txt_tanggalfk").val(data.tanggalfk);
				$("#form_cari_faktur").dialog('close');				
				$("#txt_kodest").focus();
			}
		});
	}

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

$kodesup	= $_POST['kodesup'];

echo "<table id='theList' class='barang' width='100%'>
		<tr>
			<th>No.</th>
			<th>Nomor Faktur</th>
			<th>Tanggal</th>
			<th>Total Item</th>
			<th>Total Unit</th>
			<th>Total Harga</th>
			<th>Ambil</th>
		</tr>";
		
		$sql = "SELECT nomor_fk,tanggal,count(kode_st) as totitem,sum(jml_unit) as totunit,sum(jumlah) as totjml FROM faktur_pb WHERE kode_sup='$kodesup' GROUP BY nomor_fk"; 
		
		$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[nomor_fk]</td>					
					<td align='center'>".jin_date_str($r_data[tanggal])."</td>
					<td align='right'>$r_data[totitem]</td>
					<td align='right'>$r_data[totunit]</td>
					<td align='right'>".number_format($r_data[totjml],0)."</td>
					<td align='center'>
						<a href='javascript:void(0)' onClick=\"pilih('$r_data[nomor_fk]')\">
						<img src='icon/download.gif' border='0' id='tambah_data' title='Tambah' width='12' height='12' >
					</a>
					</td>
					</tr>";
			$no++;			
		} 
		
echo "</table>";
?>