<script type="text/javascript">
$(document).ready(function() {
    $(function(){
        $("#theList.detail tr:even").addClass("stripe1");
        $("#theList.detail tr:odd").addClass("stripe2");

        $("#theList.detail tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});

	function edit_data(ID){
		var kode = ID;
		
		$.ajax({
			type	: "POST",
			url	    : "md_gdg/mutasi_br/edit.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_nourut").val(data.nourut);
				$("#txt_kodest").val(data.kodest);
				$("#txt_namast").val(data.namast);
				$("#txt_jmlunit").val(data.jmlunit);
				$("#txt_satuan").val(data.satuan);
				$("#txt_hgbeli").val(data.hgbeli);
				$("#txt_expired").val(data.expired);
				$("#txt_keter").val(data.keter);
			}
		});		
	}

	function hapus_data(ID){
		var pilih = confirm('Hapus data mutasi barang kode '+ID+' ?');
		if (pilih==true){
		var kode = ID;
		$.ajax({
			type	: "POST",
			url	    : "md_gdg/mutasi_br/hapus.php",
			data	: "kode="+kode,
			success : function(data){
				$("#info").html(data);
				tampil_data_detail();
			}
		});
		}
	}
	
	function tampil_data_detail(){
		var kode = $("#txt_kode").val();
		$("#data_detail").load("md_gdg/mutasi_br/tampil_data_detail.php?kode="+kode);
	}
</script>
<?php
include '../../inc/inc.koneksi.php';
include '../../inc/fungsi_tanggal.php';

$kode= $_GET['kode'];

echo "<table id='theList' class='detail' width='100%'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Barang</th>
			<th>Jml.Unit</th>
			<th>Satuan</th>
			<th>Expired</th>
			<th>Keterangan</th>
			<th>Aksi</th>
		</tr>";
		$query = mysql_query("SELECT * FROM jurmbr WHERE kode_mb='$kode' ORDER BY no_urut desc");
		
		$no=1;
		while($r=mysql_fetch_array($query)){
			$kode= $r['kode_mb'].';'.$r['no_urut'];
			$urut= $r['no_urut'];

			echo "<tr>
				<td align='center'>$no</td>
				<td>$r[kode_st]</td>
				<td>$r[nama_st]</td>
				<td align='center'>".number_format($r['jml_unit'],2)."</td>
				<td>$r[satuan]</td>
				<td>".jin_date_str($r['expired'])."</td>
				<td>$r[keterangan]</td>
				<td align='center'>
					<a href='javascript:void(0)' onClick=\"edit_data('$kode')\">
					<img src='icon/thumb_up.png' border='0' id='edit' title='Edit' width='12' height='12' ></a>					
					<a href='javascript:void(0)' onClick=\"hapus_data('$kode')\">
					<img src='icon/thumb_down.png' border='0' id='hapus' title='Hapus' width='12' height='12' ></a>					
				</td>
			</tr>";
			$no++;			
		}
		echo "<tr></tr>
	</table>";
?>