<script type="text/javascript">	
	window.print();
</script>
<?php
	include '../../inc/inc.koneksi.php';	
	include '../../inc/fungsi_tanggal.php';

	$cari	= $_GET['cari'];
	$tanggal= date('d-m-Y');
	
	if(!empty($cari)){
	    $sql2= mysql_query("SELECT * FROM st_group WHERE kode_gr='$cari'");
	    $r2  = mysql_fetch_assoc($sql2);
	    $namagr=$r2['nama_gr'];
	}
	
	$sql2= mysql_query("SELECT * FROM company");
	$r2  = mysql_fetch_assoc($sql2);
	$kop1 = $r2['nama1'];
	$kop2 = $r2['nama2'];
	$kop3 = $r2['alamat'];
	
	echo "<table width='100%'>
		<tr>
			<td style='font:12px arial;line-height:80%'><b>$kop1</b></td>
		</tr>
		<tr>
			<td style='font:12px arial;line-height:80%'>$kop2</td>
		</tr>
		<tr>
			<td style='font:12px arial;line-height:80%'>$kop3</td>
		</tr>
	</table>

	<table width='100%'>
		<tr>
			<td style='font:13px arial;line-height:75%' align='center'><b>BLANGKO STOK OPNAME</td>
		</tr>
		<tr>
			<td style='font:13px arial;line-height:75%' align='center'><b>TANGGAL : $tanggal</b></td>
		</tr>";
		if(!empty($cari)){
		    echo "<tr>
			    <td style='font:13px arial;line-height:75%' align='center'><b>KELOMPOK : $namagr</b></td>
		    </tr>";
		}
	echo "</table>
		
	<table width='100%'>
		<tr>
			<th style='font:12px arial;border-top:double 1px;border-bottom:double 1px'>No.</th>
			<th style='font:12px arial;border-top:double 1px;border-bottom:double 1px'>Kode</th>
			<th style='font:12px arial;border-top:double 1px;border-bottom:double 1px'>Jumlah SO</th>
			<th style='font:12px arial;border-top:double 1px;border-bottom:double 1px'>Nama Barang</th>
			<th style='font:12px arial;border-top:double 1px;border-bottom:double 1px'>Barcode</th>
			<th style='font:12px arial;border-top:double 1px;border-bottom:double 1px'>Satuan</th>
		</tr>";
		if(!empty($cari))
			$query = mysql_query("SELECT * FROM stock WHERE concat(substr(kode_st,1,2))='$cari' GROUP BY kode_st");
		else
			$query = mysql_query("SELECT * FROM stock WHERE 1 GROUP BY kode_st");
		
		$no=1;
		while($r=mysql_fetch_array($query)){
			$nilai = $r['jml_stok']*$r['hg_beli'];
			echo "<tr>
				<td style='font:12px arial'>$no</td>
				<td style='font:12px arial'>$r[kode_st]</td>
				<td align='center' style='font:12px arial'> __________ </td>
				<td style='font:12px arial'>$r[nama_st]</td>
				<td style='font:12px arial'>$r[barcode]</td>
				<td style='font:12px arial'>$r[satuan]</td>
			</tr>";
			$no++;
			$jml++;
		}
		echo "<tr>
			<td style='font:12px arial;border-top:double 1px;border-bottom:double 1px'></td>
			<td style='font:12px arial;border-top:double 1px;border-bottom:double 1px'></td>
			<td style='font:12px arial;border-top:double 1px;border-bottom:double 1px' align='center'></td>
			<td style='font:12px arial;border-top:double 1px;border-bottom:double 1px'></td>
			<td style='font:12px arial;border-top:double 1px;border-bottom:double 1px'></td>
			<td style='font:12px arial;border-top:double 1px;border-bottom:double 1px'></td>
		</tr>
	</table>";
?>