<?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;

	$content = "<b><li>JURNAL PENGELUARAN BANK</li>
		<li>TANGGAL : ".jin_date_str($tgl_awal)." S/D ".jin_date_str($tgl_akhir)."</li></b>
		<br>
	
		<table width='390' border='1' style='border-collapse:collapse'>
		<tr>
			<th>No.</th>
			<th>Kode Akun</th>
			<th>Kode BP</th>
			<th>Nama Akun</th>
			<th>Keterangan</th>			
			<th>Jumlah</th>
			<th>Posting</th>
		</tr>";
		
		$query2 = "SELECT kode_bk,tanggal,nobank,namabank FROM jurbk WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' GROUP BY kode_bk ORDER BY tanggal";
		$data2	= mysql_query($query2);
		while($r_data2=mysql_fetch_array($data2)){
			$kodebk=$r_data2[kode_bk];
		
		$content .= "<tr>	
				<td></td>
				<td><b>No. BKM :</b></td>
				<td><b>$r_data2[kode_bk]</b></td>
				<td><b>Tanggal : ".jin_date_str($r_data2[tanggal])."</b></td>
				<td><b>Rekening Bank : $r_data2[nobank] - $r_data2[namabank]</b>
				<td></td>
				<td></td>
			</tr>";
			
		$sql = "SELECT * FROM jurbk WHERE kode_bk='$kodebk' ";		
		$query = mysql_query($sql);
		
		$no=1+$hal;
		$sjumlah=0;
		while($r_data=mysql_fetch_array($query)){
				
		$content .= "<tr>
				<td align='center'>$no</td>
				<td align='center'>$r_data[noakun]</td>
				<td align='center'>$r_data[nobp]</td>
				<td>$r_data[naakun]</td>
				<td>$r_data[keterangan]</td>				
				<td align='right'>".number_format($r_data[jumlah],2)."</td>
				<td></td>
				</tr>";
			$sjumlah=$sjumlah+$r_data[jumlah];
			$no++;
			$jml++;			
		}
		$content .= "<tr>
				<td></td>
				<td></td>
				<td></td>				
				<td></td>
				<td align='right'>Jumlah</td>
				<td align='right'>".number_format($sjumlah,2)."</td>
				<td></td>
			</tr>";
			$tjumlah=$tjumlah+$sjumlah;
		}
		
		$content .= "<tr>				
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Total </td>
				<td align='right'>".number_format($tjumlah,2)."</td>
				<td></td>
			</tr>";
		$content .= "</table>";
		
		$content .= "<li>Jumlah data : $jml</li>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=jurnal_bk.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>
