<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;
		var kodeppi = $("#txt_kode").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pener_piut/cari_pd.php",
			data	: "kode="+kode+
					"&kodeppi="+kodeppi,
			dataType: "json",
			success	: function(data){
				$("#txt_nofak").val(kode);
				$("#txt_jmlpiut").val(data.jumlah);
				$("#txt_tglfak").val(data.tglfak);
				$("#form_cari_pd").dialog('close');
				$("#txt_tunai").focus();
			}
		});		
	}
</script>

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

$cari = $_GET['cari'];
$kodepl=$_GET['kodepl'];

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_pl,nofak,tanggal,jumlah,tanggal_jt FROM piutang WHERE nofak LIKE '%$cari%' AND kode_pl='$kodepl' AND !(jumlah=0) ORDER BY nofak ";
		else
			$query = "SELECT kode_pl,nofak,tanggal,jumlah,tanggal_jt FROM piutang WHERE kode_pl='$kodepl' AND !(jumlah=0) ORDER BY nofak ";
		$sql= mysql_query($query);
						
		while($r=mysql_fetch_array($sql)){
			echo "<tr>					
				<td align='center'>$r[nofak]</td>
				<td align='center'>".jin_date_str($r['tanggal'])."</td>
				<td align='right'>".number_format($r['jumlah'],2)."</td>
				<td align='center'>".jin_date_str($r['tanggal_jt'])."</td>
				<td align='center'><a href='javascript:void(0)' onClick=\"pilih('$r[nofak]')\">
					<img src='images/view.png' border='0' id='edit' title='Pilih Nomor Faktur' width='12' height='12' ></a>
				</td>
			</tr>";
			$no++;								
		}
	echo "</table>";
?>