<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_mb(ID){
		var kode = ID;	
		$.ajax({
			type	: "POST",
			url		: "md_gdg/mutasi_br/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_gdtujuan").val(data.gdtujuan);
				$('#form_cari_kodemb').dialog('close');
				$("#info_mbr").hide();
				$('#input_mbr').show();
				$("#data_detail").show();
				$("#data_detail").load('md_gdg/mutasi_br/tampil_data_detail.php?kode='+kode);
				cari_nourut();
			}
		});		
	}
	
	function cari_nourut(){
		var kode = $("#txt_kode").val();
				
		$.ajax({
			type	: "POST",
			url		: "md_gdg/mutasi_br/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. Tujuan</th>
			<th>Petugas</th>
			<th>Total Item</th>
			<th>Total Unit</th>
			<th>Pilih</th>
		</tr>";
		if(!empty($cari))
		    $query = mysql_query("SELECT kode_mb,tanggal,cabang,petugas,count(kode_st) as totitem,sum(jml_unit) as totunit FROM jurmbr WHERE kode_mb LIKE '%$cari%' AND posting='' AND batal='' GROUP BY kode_mb");
		else
		    $query = mysql_query("SELECT kode_mb,tanggal,cabang,petugas,count(kode_st) as totitem,sum(jml_unit) as totunit FROM jurmbr WHERE posting='' AND batal='' GROUP BY kode_mb");
		
		$no=1;
		while($r=mysql_fetch_array($query)){
			$total = $r['total'];
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r[kode_mb]</td>
				<td align='center'>".jin_date_str($r['tanggal'])."</td>
				<td>$r[cabang]</td>
				<td>$r[petugas]</td>
				<td>$r[totitem]</td>
				<td align='right'>$r[totunit]</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"tampil_mb('$r[kode_mb]')\">
						<img src='images/view.png' border='0' id='edit' title='Lihat detail' width='12' height='12'>
					</a>
				</td>
			</tr>";
			$no++;
		}
	echo "</table>";
?>