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

	$content = "<b><li>JURNAL UMUM</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>Debet</th>
			<th>Kredit</th>
			<th>Posting</th>
		</tr>";
		
		$query2 = "SELECT kode_ju,tanggal FROM jurnalum WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' GROUP BY kode_ju ORDER BY tanggal";
		$data2	= mysql_query($query2);
		while($r_data2=mysql_fetch_array($data2)){
			$kodeju=$r_data2[kode_ju];
		
		$content .= "<tr>	
				<td></td>
				<td><b>No. BKM :</b></td>
				<td><b>$r_data2[kode_ju]</b></td>
				<td><b>Tanggal : ".jin_date_str($r_data2[tanggal])."</b></td>				
			</tr>";
			
		$sql = "SELECT * FROM jurnalum WHERE kode_ju='$kodeju' ";		
		$query = mysql_query($sql);
		
		$no=1+$hal;
		$sdebet=0;
		$skredit=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[debet],2)."</td>
				<td align='right'>".number_format($r_data[kredit],2)."</td>
				<td></td>
				</tr>";
			$sdebet=$sdebet+$r_data[debet];
			$skredit=$skredit+$r_data[kredit];
			$no++;
			$jml++;			
		}
		$content .= "<tr>
				<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>
				<td></td>
			</tr>";
			$tdebet=$tdebet+$sdebet;
			$tkredit=$tkredit+$skredit;
		}
		
		$content .= "<tr>				
				<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>
				<td></td>
			</tr>";
		$content .= "</table>";
		
		$content .= "<li>Jumlah data : $jml</li>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=jurnal_bm.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>
