<?php
	include '../../inc/inc.koneksi.php';	
	include '../../inc/fungsi_tanggal.php';
	include "../../inc/fungsi_indotgl.php";

	$tanggal= tgl_indo(date("Y m d")); 
	
	$content = "<b><li>DAFTAR OUTSTANDING DO</li>
		<li>PER TANGGAL $tanggal</li>		
		<br>
	
		<table width='390' border='1' style='border-collapse:collapse'>
		<tr>
			<th>No.</th>
			<th>Kode DO</th>
			<th>Tanggal</th>
			<th>Nomor DO</th>
			<th>Jenis BBM</th>
			<th>Jumlah Liter</th>
			<th>Harga Beli</th>
			<th>Jumlah Harga</th>
		</tr>";
		
		$sql = "SELECT * FROM stock_do WHERE !(jml_liter='0') ORDER BY kode_do";
						
		$query = mysql_query($sql);
		$no=1;
		$total=0;
		while($r_data=mysql_fetch_array($query)){
			$total	= $total+$r_data[jumlah];

			$content .= "<tr>	
				<td align='center'>$no</td>
				<td>$r_data[kode_do]</td>
				<td align='center'>".jin_date_str($r_data[tanggal])."</td>
				<td>$r_data[nobukti]</td>
				<td>$r_data[jenis]</td>
				<td align='right'>$r_data[jml_liter]</td>
				<td align='right'>".number_format($r_data[hg_beli],2)."</td>
				<td align='right'>".number_format($r_data[jumlah],0)."</td>
			</tr>";
			$no++;
		}
		
		$content .= "<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Total </td>
			<td align='right'>".number_format($total,0)."</td>
		</tr>";
			
		$content .= "</table>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=daftar_osdo.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>
