<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");
            }
        );
    });
});
</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</th>
			<th>Nama Barang</th>
			<th>Satuan</th>
			<th>Harga Pokok</th>
			<th>Jml. Stok</th>			
			<th>Jml. Opname</th>
			<th>Selisih</th>
			<th>Nilai Selisih</th>
			<th>Posting</th>
		</tr>";
		
		$sql1 = "SELECT * FROM st_opname WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' GROUP BY kode_op";
		$query1 = mysql_query($sql1);
		
		$jml=0;
		$tnilai=0;
		
		while($data1=mysql_fetch_array($query1)){
			$kodeop = $data1[kode_op];
			echo "<tr>
				<td></td>
				<td></td>
				<td><b>Kode Opn.: $data1[kode_op] - ".jin_date_str($data1[tanggal])."</b></td>
			</tr>";
				
			$sql = "SELECT * FROM st_opname WHERE kode_op='$kodeop' ORDER BY kode_op,kode_st";
			$query = mysql_query($sql);
			$snilai = 0;
			$no=1;
			
			while($data=mysql_fetch_array($query)){
			
				echo "<tr>
					<td align='center'>$no</td>
					<td align='center'>$data[kode_st]</td>
					<td>$data[nama_st]</td>
					<td>$data[satuan]</td>
					<td align='right'>".number_format($data[hg_beli],2)."</td>
					<td align='right'>".number_format($data[jml_stok],2)."</td>
					<td align='right'>".number_format($data[jml_opn],2)."</td>
					<td align='right'>".number_format($data[jml_sls],2)."</td>					
					<td align='right'>".number_format($data[nilai_sls],2)."</td>
					<td align='center'>$data[posting]</td>
				</tr>";
				$no++;
				$jml++;
				$snilai=$snilai+$data[nilai_sls];
			}
			
			echo "<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Jumlah</td>
				<td align='right'>".number_format($snilai,2)."</td>
			</tr>";	
			$tnilai=$tnilai+$snilai;
		}
		
		echo "<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
			
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Total</td>
				<td align='right'>".number_format($tnilai,2)."</td>
			</tr>";
			
	echo "</table>";
?>