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

	$tgl_awal	= $_GET['tgl_awal'];
	$tgl_akhir	= $_GET['tgl_akhir'];
	$user		= $_GET['user'];
	$nafile 	= 'rekappj_'.$user;

	$sql2	= mysql_query("SELECT * FROM company");
	$r2		= mysql_fetch_assoc($sql2);
	$kop1 	= $r2['nama1'];
	$kop2 	= $r2['nama2'];
	$kop3 	= $r2['alamat'];

	echo "<table width='100%' style='font:11px arial'><b>
		<tr>
			<td>$kop1</td>
		</tr>
		<tr>
			<td>$kop2</td>
		</tr>
		<tr>
			<td>$kop3</td>
		</tr>
	</table>
		
	<table width='100%'>
		<tr>
			<td align='center' style='font:14px arial'><b>REKAPITULASI PENJUALAN KESELURUHAN</b></td>
		</tr>
		<tr>
			<td align='center' style='font:14px arial'><b>TANGGAL : ".jin_date_str($tgl_awal)." S/D ".jin_date_str($tgl_akhir)."</b></td>
		</tr>
	</table>
	<br>
	
	<table width='100%' border='1' style='border-collapse:collapse;font:11px arial'>
		<tr>
			<th>No.</th>
			<th>Kode Barang</th>
			<th>Nama Barang</th>
			<th>Barcode</th>
			<th>Satuan</th>
			<th>Jumlah Unit</th>
			<th>Total Harga</th>
		</tr>";		
		$sql= mysql_query("SELECT * FROM $nafile ORDER BY kode_st ");
		
		$no=1;
		$tjumlah=0;
		while($r=mysql_fetch_array($sql)){
			$jumlah=$r['jumlah']+$r['jumlah1']+$r['jumlah2']+$r['jumlah3'];
			
			echo "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r[kode_st]</td>
				<td>$r[nama_st]</td>
				<td>$r[barcode]</td>
				<td>$r[satuan]</td>
				<td align='right'>$r[jml_unit]</td>			
				<td align='right'>".number_format($jumlah)."</td>
			</tr>";
			$tjumlah=$tjumlah+$jumlah;
			$no++;
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total</td>
			<td align='right'>".number_format($tjumlah)."</td>
		</tr>
	</table>";
?>