<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 pilih(ID){
		var kode = ID;	
		$.ajax({
			type	: "POST",
			url		: "modul/pengel_kas/cari_ud.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nofak").val(kode);
				$("#txt_jumlah").val(data.jumlah);
				$("#form_cari_ud").dialog('close');
				$("#txt_diskon").focus();
			}
		});		
	}
</script>

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

$cari = $_POST['cari'];
$nobp = $_POST['nobp'];
$kodesp=substr($nobp,5,4);

echo "<table id='theList' width='100%'>
		<tr>			
			<th>No. Faktur</th>
			<th>Tanggal</th>
			<th>Saldo Rp</th>
			<th>Jatuh Tempo</th>
			<th>Pilih</th>
		</tr>";
		
		if(!empty($cari))
			$query = "SELECT kode_sp,nofak,tanggal,jumlah,tanggal_jt FROM hutang WHERE nofak LIKE '%$cari%' AND kode_sp='$kodesp' ORDER BY nofak ";
		else
			$query = "SELECT kode_sp,nofak,tanggal,jumlah,tanggal_jt FROM hutang WHERE kode_sp='$kodesp' ORDER BY nofak ";
		$sql= mysql_query($query);
						
		while($r_data=mysql_fetch_array($sql)){
			echo "<tr>					
					<td align='center'>$r_data[nofak]</td>
					<td align='center'>".jin_date_str($r_data1[tanggal])."</td>
					<td align='right'>".number_format($r_data[jumlah],2)."</td>
					<td align='center'>".jin_date_str($r_data1[tanggal_jt])."</td>
					<td align='center'><a href='javascript:void(0)' onClick=\"pilih('$r_data[nofak]')\">
						<img src='images/view.png' border='0' id='edit' title='Pilih Nomor Faktur' width='12' height='12' ></a>
					</td>
				</tr>";
			$no++;								
		}

	echo "</table>";
?>
