<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;
	$tjumlah=0;
	
	$query2 = mysql_query("SELECT * FROM company");
	$r2		= mysql_fetch_assoc($query2);
	$kop1 	= $r2['nama1'];
	$kop2 	= $r2['nama2'];
	$kop3 	= $r2['alamat'];

	echo "<table width='100%'>
		<tr>
			<td style='font:12px 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>
	<hr style='border-bottom:double 1px'>";

	echo "<table width='100%'>
		<tr>
			<td align='center' style='font:14px arial'><b>JURNAL PENERIMAAN KAS</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:12px arial'>
		<tr>
			<th>No.</th>
			<th>Kode Akun</th>
			<th>Kode BP</th>
			<th>Nama Akun</th>
			<th>Nama BP</th>
			<th>No.Faktur</th>
			<th>Cabang</th>
			<th>Keterangan</th>			
			<th>Jumlah</th>
			<th>Posting</th>
		</tr>";
		$data2= mysql_query("SELECT kode_km,tanggal,nokas,namakas,pembayar FROM jurkm WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' GROUP BY kode_km");
		
		while($r2=mysql_fetch_array($data2)){
			$kodekm=$r2['kode_km'];
		
			echo "<tr>	
				<td></td>
				<td><b>No. BKM :</b></td>
				<td><b>$r2[kode_km]</b></td>
				<td><b>Tanggal : ".jin_date_str($r2['tanggal'])."</b></td>
				<td><b>Akun Kas : $r2[nokas] - $r2[namakas]</b>
				<td>Terima dari :</td>
				<td><b>$r2[pembayar]</b></td>
				<td></td>
			</tr>";			
			$query = mysql_query("SELECT * FROM jurkm WHERE kode_km='$kodekm' ");
		    
			$no=1;
			$sjumlah=0;
			while($r=mysql_fetch_array($query)){
				
				echo "<tr>
					<td align='center'>$no</td>
					<td align='center'>$r[noakun]</td>
					<td align='center'>$r[nobp]</td>
					<td>$r[naakun]</td>
					<td>$r[namabp]</td>
					<td>$r[nofak]</td>
					<td>$r[kode_cab]</td>
					<td>$r[keterangan]</td>
					<td align='right'>".number_format($r['jumlah'])."</td>
					<td align='center'>$r[posting]</td>
				</tr>";
				$sjumlah=$sjumlah+$r['jumlah'];
				$no++;
				$jml++;
			}
			echo "<tr>
				<td></td>
				<td></td>
				<td></td>				
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Jumlah</td>
				<td align='right'>".number_format($sjumlah)."</td>
				<td></td>
			</tr>";
			$tjumlah=$tjumlah+$sjumlah;
		}	
		echo "<tr>				
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total </td>
			<td align='right'>".number_format($tjumlah)."</td>
			<td></td>
		</tr>
	</table>
	<table>
		<tr>
			<td>Jumlah data : $jml</td>
		</tr>
	</table>";
?>