<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'];
	$kodest   	= $_GET['kodest'];
	$namast    	= $_GET ['namast'];
	$user		= $_GET['user'];
	$nafile 	= 'historypj_'.$user;
	
	$sql2= mysql_query("SELECT * FROM company");
	while($r2=mysql_fetch_array($sql2)){
		$kop1 = $r2['nama1'];
		$kop2 = $r2['nama2'];
		$kop3 = $r2['alamat'];
	}
	
	echo "<table width='100%'>
		<tr>
			<td style='font:11px arial;line-height:80%'><b>$kop1</b></td>
		</tr>
		<tr>
			<td style='font:11px arial;line-height:80%'>$kop2</td>
		</tr>
		<tr>
			<td style='font:11px arial;line-height:80%'>$kop3</td>
		</tr>
	</table>

	<table width='100%' >
		<tr>
			<td align='center' style='font:15px arial'><b>DAFTAR HISTORY PENJUALAN</td>
		</tr>
		<tr>
			<td align='center' style='font:15px arial'><b>TANGGAL : ".jin_date_str($tgl_awal)." S/D ".jin_date_str($tgl_akhir)."</b></td>
		</tr>
		<tr>
			<td align='center' style='font:15px arial'><b>NAMA BARANG : $namast</td>
		</tr>
	</table>
	<br>
	
<table width='100%' border='1' style='border-collapse:collapse;font:11px arial'>
	<tr>
			<th>No.</th>
			<th>Tanggal</th>
			<th>Nomor Faktur</th>			
			<th>Kode</th>
			<th>Nama Pelanggan</th>
			<th>Jumlah Unit</th>
			<th>Satuan</th>
			<th>Harga Jual</th>
			<th>Jumlah Harga</th>
		</tr>";
		$sql= mysql_query("SELECT * FROM $nafile WHERE 1 ORDER BY tanggal");
		
		$no=1;
		$tunit=0;
		$tjumlah=0;
		while($r=mysql_fetch_array($sql)){
			echo "<tr>
				<td align='center'>$no</td>
				<td>".jin_date_str($r['tanggal'])."</td>
				<td>$r[kode_pj]</td>
				<td>$r[kode_pl]</td>
				<td>$r[nama_pl]</td>
				<td align='right'>".number_format($r['jml_unit'],0)."</td>
				<td>$r[satuan]</td>
				<td align='right'>".number_format($r['hg_jual'])."</td>
				<td align='right'>".number_format($r['jumlah'])."</td>
			</tr>";
			$tjumlah=$tjumlah+$r['jumlah'];
			$tunit	=$tunit+$r['jml_unit'];
			$no++;
		}
		echo "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total</td>
			<td align='right'>".number_format($tunit)."</td>
			<td align='right'></td>
			<td align='right'></td>
			<td align='right'>".number_format($tjumlah)."</td>
		</tr>
</table>";
?>