<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/pener_kas/cari_pd.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nofak").val(kode);
				$("#txt_jumlah").val(data.jumlah);
				$("#form_cari_pd").dialog('close');				
				$("#radio_dk").focus();
			}
		});		
	}
</script>

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

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