<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){
				$("#t_kodemb").val(kode);
				$("#t_tanggal").val(data.tanggal);
				$("#t_gdtujuan").val(data.gdtujuan);
				$("#t_cabang").val(data.cabang);
				$("#t_petugas").val(data.petugas);
				$("#pencarian_pmb").hide();
				$("#tampil_data").hide();
				$("#info_pmb").show();
				$("#tampil_detail").show();
				$("#tampil_detail").load('md_gdg/mutasi_br/tampil_data_mb.php?kode='+kode);
			}
		});		
	}
</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>Kode Mutasi</th>
			<th>Tanggal</th>
			<th>Gudang Tujuan</th>
			<th>Petugas</th>
			<th>Total Item</th>
			<th>Total Unit</th>
			<th>Lihat</th>
		</tr>";
		$query=mysql_query("SELECT kode_mb,tanggal,cabang,petugas,count(kode_st) as totitem,sum(jml_unit) as totunit FROM jurmbr WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND batal='' GROUP BY kode_mb");
		
		$no=1;
		while($r=mysql_fetch_array($query)){
			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 align='center'>$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>";
?>