<script type="text/javascript">
	window.print();
</script>

<?php
	include '../../inc/inc.koneksi.php';	
	
	$cari = $_GET['cari'];
	$jml = 0;
	$tgllap =date('d-m-Y');
	if (!empty($cari)){
		$grup='KELOMPOK : '.$cari;
	}else{
		$grup='KESELURUHAN';
	}
		
	$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%' style='font:11px arial><b>
		<tr>
			<td>$kop1</td>
		</tr>
		<tr>
			<td>$kop2</td>
		</tr>
		<tr>
			<td>$kop3</td>
		</tr>
		</table>
		
		<table width='100%' align='center' style='font:14px arial'><b>
		<tr>
			<td>DAFTAR GOLONGAN AKUN</td>
		</tr>
		<tr>
			<td>$grup</td>
		</tr>
		<tr>
			<td>PER TANGGAL $tgllap</td>
		</tr>
		</b></table>
		<br>
	
		<table width='500' border='1' style='border-collapse:collapse;font:12px arial'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Golongan</th>
			<th>D/K</th>
		</tr>";
	
		if (!empty($cari)){
			$query1= "SELECT * FROM gol_akun WHERE (nagol LIKE '%$cari%' or nogol LIKE '%$cari%')";
		}
		else{
			$query1= "SELECT * FROM gol_akun";
		}
		$data1	= mysql_query($query1);
		$jml	= mysql_num_rows($data1);
		
		$query2= "SELECT * FROM gol_akun GROUP BY nokel";
		$data2	= mysql_query($query2);		
		while($r2=mysql_fetch_array($data2)){
			$nokel=$r2['nokel'];

			echo "<tr>
				<td></td>
				<td><b>$r2[nokel]</b></td>			
				<td><b>$r2[nakel]</b></td>
			</tr>";
		
			if (!empty($cari)){
				$sql	= "SELECT * FROM gol_akun WHERE (nagol LIKE '%$cari%' or nogol LIKE '%$cari%') AND nokel='$nokel'  ";
			}
			else{
				$sql	= "SELECT * FROM gol_akun WHERE nokel='$nokel' ORDER BY nogol";
			}
			$query = mysql_query($sql);
		
			$no=1;		
			while($r=mysql_fetch_array($query)){	
				echo "<tr>
					<td>$no</td>
					<td>$r[nogol]</td>
					<td>$r[nagol]</td>
					<td align='center'>$r[kode]</td>
				</tr>";
				$no++;
				$jml++;
			}	
		}
		
		echo "</table>
		<table>
			<tr>
				<td>Jumlah Data : $jml</td>
			</tr>
		</table>";
?>
<script type="text/javascript">
	history.back();
</script>