<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'];
	
	$jml = 0;
	$tdebet=0;
	$tkredit=0;

	$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'>
		<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>DAFTAR JURNAL UMUM</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 Akun</th>
			<th>Nama Akun</th>
			<th>Kode BP</th>
			<th>Nama BP</th>
			<th>No.Faktur</th>
			<th>Cabang</th>
			<th>Keterangan</th>
			<th>Debet</th>
			<th>Kredit</th>
			<th>Posting</th>
		</tr>";
		$data1	= mysql_query("SELECT kode_ju,tanggal FROM jurnalum WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' GROUP BY kode_ju");
		
		$tdebet=0;
		$tkredit=0;
		$jdata=1;
		while($r1=mysql_fetch_array($data1)){
			$kodeju = $r1['kode_ju'];
			
			echo "<tr>
				<td></td>
				<td>No. Bukti :</td>
				<td>$r1[kode_ju]</td>
				<td>Tanggal : ".jin_date_str($r1['tanggal'])."</td>
			</tr>";			
			$query = mysql_query("SELECT * FROM jurnalum WHERE kode_ju='$kodeju' ");
		
			$no=1;
			$sdebet=0;
			$skredit=0;
			while($r=mysql_fetch_array($query)){
				$sdebet=$sdebet+$r['debet'];
				$skredit=$skredit+$r['kredit'];
				
				echo "<tr>
					<td align='center'>$no</td>
					<td align='center'>$r[noakun]</td>
					<td>$r[naakun]</td>
					<td align='center'>$r[nobp]</td>
					<td>$r[namabp]</td>
					<td align='center'>$r[nofak]</td>
					<td>$r[kode_cab]</td>
					<td>$r[keterangan]</td>
					<td align='right'>".number_format($r['debet'],2)."</td>
					<td align='right'>".number_format($r['kredit'],2)."</td>
					<td align='center'>$r[posting]</td>
				</tr>";
				$no++;
				$jdata++;
			}
			
			echo "<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>				
				<td align='right'>Jumlah</td>
				<td align='right'>".number_format($sdebet,2)."</td>
				<td align='right'>".number_format($skredit,2)."</td>
			</tr>";
			$tdebet=$tdebet+$sdebet;
			$tkredit=$tkredit+$skredit;
		}
		echo "<tr></tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total</td>
			<td align='right'>".number_format($tdebet,2)."</td>
			<td align='right'>".number_format($tkredit,2)."</td>
		</tr>
	</table>
	<table style='font:11px arial'>
		<tr>
			<td>Jumlah data : $jmldata</td>
		</tr>
	</table>";
?>