<?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;
	$tdiskon=0;

	$content = "<b><li>JURNAL PENGELUARAN KAS</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>Diskon</th>
			<th>Posting</th>
		</tr>";
		
		$query2 = "SELECT kode_kk,tanggal,nokas,namakas,penerima FROM jurkk WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' GROUP BY kode_kk";
		$data2	= mysql_query($query2);
		while($r_data2=mysql_fetch_array($data2)){
			$kodekk=$r_data2[kode_kk];
		
		$content .= "<tr>	
				<td></td>
				<td><b>No. Bkk :</b></td>
				<td><b>$r_data2[kode_kk]</b></td>
				<td><b>Tanggal : ".jin_date_str($r_data2[tanggal])."</b></td>
				<td><b>Akun Kas : $r_data2[nokas] - $r_data2[namakas]</b>
				<td><b>$r_data2[penerima]</b></td>
				<td></td>
			</tr>";
			
		$sql = "SELECT * FROM jurkk WHERE kode_kk='$kodekk' ";		
		$query = mysql_query($sql);
		
		$no=1+$hal;
		$sjumlah=0;
		$sdiskon=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 align='right'>".number_format($r_data[diskon],2)."</td>
				<td></td>
				</tr>";
			$sjumlah=$sjumlah+$r_data[jumlah];
			$sdiskon=$sdiskon+$r_data[diskon];
			$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 align='right'>".number_format($sdiskon,2)."</td>
				<td></td>
			</tr>";
			$tjumlah=$tjumlah+$sjumlah;
			$tdiskon=$tdiskon+$sdiskon;
		}
		
		$content .= "<tr>				
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td align='right'>Total </td>
				<td align='right'>".number_format($tjumlah,2)."</td>
				<td align='right'>".number_format($tdiskon,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_kk.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>
