<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 tampil_rm(ID){
		var kode = ID;	
		$.ajax({
			type	: "POST",
			url		: "md_gdg/retur_mbr/cari_kode.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_kode").val(kode);
				$("#txt_tanggal").val(data.tanggal);
				$("#txt_petugas").val(data.petugas);
				$("#txt_gdasal").val(data.gdasal);
				$("#txt_cabang").val(data.cabang);
				$('#form_cari_koderm').dialog('close');
				$("#info_koderm").hide();
				$("#input_rmb").show();
				$("#data_detail").show();
				$("#data_detail").load('md_gdg/retur_mbr/tampil_data_detail.php?kode='+kode);
				cari_nourut();
			}
		});		
	}
	
	function cari_nourut(){
		var kode = $("#txt_kode").val();
				
		$.ajax({
			type	: "POST",
			url		: "md_gdg/retur_mbr/cari_nourut.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nourut").val(data.nourut);		
			}
		});
	}
</script>

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

$cari=$_GET['cari'];

echo "<table id='theList' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode Mutasi</th>
			<th>Tanggal</th>
			<th>Gd. Asal</th>
			<th>Petugas</th>
			<th>Total Item</th>
			<th>Total Unit</th>
			<th>Pilih</th>
		</tr>";
		if(!empty($cari))
		    $query = mysql_query("SELECT kode_rm,tanggal,cabang,petugas,count(kode_st) as totitem,sum(jml_unit) as totunit FROM retur_mbr WHERE kode_rm LIKE '%$cari%' posting='' AND batal='' GROUP BY kode_rm");
		else
		    $query = mysql_query("SELECT kode_rm,tanggal,cabang,petugas,count(kode_st) as totitem,sum(jml_unit) as totunit FROM retur_mbr WHERE posting='' AND batal='' GROUP BY kode_rm");
		$no=1;
		while($r=mysql_fetch_array($query)){
			
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r[kode_rm]</td>
				<td align='center'>".jin_date_str($r['tanggal'])."</td>
				<td align='center'>$r[cabang]</td>
				<td align='center'>$r[petugas]</td>
				<td>$r[totitem]</td>
				<td align='right'>$r[totunit]</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"tampil_rm('$r[kode_rm]')\">
						<img src='images/view.png' border='0' id='edit' title='Lihat detail' width='12' height='12' >
					</a>
				</td>
			</tr>";
			$no++;
		}
	echo "</table>";
?>