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

	$userid	 = $_GET['userid'];
	$username= $_GET['username'];
	$level 	 = $_GET['level'];
	$tglawal = $_GET['tglawal'];
	$tglakhir= $_GET['tglakhir'];

	$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: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>HISTORY PELANGGAN $namapl ($kodepl)</td>
		</tr>
		<tr>
			<td align='center' style='font:15px arial'><b>PER TANGGAL : ".jin_date_str($tanggal)."</b></td>
		</tr>";
		if(!empty($userid)){
			echo "<tr>
				<td align='center' style='font:15px arial'><b>PENGGUNA : $userid</b></td>				
			</tr>
			<tr>
				<td align='center' style='font:15px arial'><b>LEVEL : $level</b></td>				
			</tr>";
		}
	echo "</table>
	<br>
	
	<table width='100%' border='1' style='border-collapse:collapse;font:12px arial'>
		<tr>
			<th>No.</th>
			<th>Tanggal</th>
			<th>Jam</th>
			<th>User</th>
			<th>Aktivitas</th>
			<th>Nomor Bukti</th>
			<th>Nama Barang</th>
			<th>Keterangan</th>
		</tr>";
		if(!empty($cari))
			$sql= "SELECT * FROM faktur_pj WHERE kode_pl='$userid' AND (nama_st LIKE '%$cari%' OR kode_st LIKE '%$cari%') ORDER BY tanggal";
		else
			$sql= "SELECT * FROM faktur_pj WHERE kode_pl='$userid' ORDER BY tanggal";
		$query = mysql_query($sql);
		
		$no=1;
		while($r=mysql_fetch_array($query)){
			echo "<tr>
				<td align='center'>$no</td>
				<td>".jin_date_str($r['tanggal'])."</td>
				<td align='center'>$r[jam]</td>
				<td>$r[user]</td>
				<td>$r[aktivitas]</td>
				<td>$r[no_bukti]</td>
				<td>$r[nama_st]</td>
				<td>$r[keterangan]</td>
			</tr>";
			$no++;
		}
	echo "</table>";
?>