<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/surat_jln/cari_sa.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nomorsa").val(kode);
				$("#txt_kodesp").val(data.kodesp);
				$("#txt_namasp").val(data.namasp);
				$("#txt_outstan").val(data.outstan);
				$("#form_cari_sa").dialog('close');
				$("#txt_kodedv").focus();
			}
		});
	}	
</script>

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

$tgl_awal = $_GET['tgl_awal'];
$tgl_akhir= $_GET['tgl_akhir'];

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Nomor SA</th>
			<th>Tanggal</th>
			<th>SPBE</th>
			<th>Outstanding</th>
			<th>Pilih</th>
		</tr>";
		
		$query = mysql_query("SELECT * FROM tebus_do	WHERE jml_real<jml_unit AND batal='' ORDER BY kode_tb");
		
		$no=1;
		$toutstan=0;
		while($r=mysql_fetch_array($query)){
			$outstan = $r[jml_unit]-$r[jml_real];
			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[nomor_sa]</td>
				<td align='center'>".jin_date_str($r[tanggal])."</td>
				<td>$r[nama_sp]</td>
				<td align='right'>$outstan</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"pilih('$r[nomor_sa]')\">
						<img src='images/view.png' border='0' id='edit' title='Ambil SA' width='12' height='12' >
					</a>
				</td>
			</tr>";
			$no++;
			$toutstan=$toutstan+$outstan;
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total</td>
			<td align='right'>$toutstan</td>
		</tr>
	</table>";
?>