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

        $("#theList tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });
</script>

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

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

echo "<div id='info'>
<table id='theList' width='100%'>
	<tr>
		<th>No.</th>
		<th>Kode</th>
		<th>Nama Barang</th>
		<th>Jml.Unit</th>
		<th>Satuan</th>
		<th>Keterangan</th>
	</tr>";
	
	if(!empty($cari)){
	    if(!empty($gdtjn))
		    $sql1= mysql_query("SELECT kode_mb,tanggal,gd_tujuan,petugas,batal FROM jurmbr WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND gd_tujuan='$gdtjn' AND (nama_st LIKE '%$cari%' OR kode_st LIKE '%$cari%') AND posting='P' GROUP BY kode_mb");
        else
            $sql1= mysql_query("SELECT kode_mb,tanggal,gd_tujuan,petugas,batal FROM jurmbr WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND (nama_st LIKE '%$cari%' OR kode_st LIKE '%$cari%') AND posting='P' GROUP BY kode_mb");
	}
	else{
		if(!empty($gdtjn))
			$sql1= mysql_query("SELECT kode_mb,tanggal,gd_tujuan,petugas,batal FROM jurmbr WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND gd_tujuan='$gdtjn' AND posting='P' GROUP BY kode_mb");
		else
			$sql1= mysql_query("SELECT kode_mb,tanggal,gd_tujuan,petugas,batal FROM jurmbr WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND posting='P' GROUP BY kode_mb");
	}
    
	while($r1=mysql_fetch_array($sql1)){
		$kodemb	= $r1['kode_mb'];
		$batal	= $r1['batal'];
		
		echo "<tr>
			<td></td>
			<td><b>No.Bukti :</b></td>
			<td><b>$r1[kode_mb] - ".jin_date_str($r1['tanggal'])."</b></td>
			<td><b>Gd. Tujuan : $r1[gd_tujuan]</b></td>
            <td><b>Petugas : $r1[petugas] </b></td>
			<td><b>-- $r1[batal]</b></td>
		</tr>";
		
		if($batal==''){
			if(!empty($cari))
				$sql = mysql_query("SELECT * FROM jurmbr WHERE kode_mb='$kodemb' AND (nama_st LIKE '%$cari%' OR kode_st LIKE '%$cari%') ORDER BY no_urut");
			else
				$sql = mysql_query("SELECT * FROM jurmbr WHERE kode_mb='$kodemb' ORDER BY no_urut");
			$no=1;
			$sjumlah=0;
			while($r=mysql_fetch_array($sql)){			
				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'],0)."</td>
				    <td>$r[satuan]</td>
				    <td>$r[keterangan]</td>
				</tr>";
				$no++;
			}
			echo "<tr></tr>";
		}
	}
echo "</table>

</div>";
?>