<?php
	include '../../inc/inc.koneksi.php';
	include '../../inc/fungsi_tanggal.php';
	
	$tglawal = $_GET[tglawal];
	$tglakhir = $_GET[tglakhir];	
	$kode = $_GET[kode];
	
	$sql = "SELECT * FROM departemen WHERE kode_dep='$kode' ORDER BY kode_dep";
	$query = mysql_query($sql);
	$r=mysql_fetch_array($query);
	$nadep = $r[nama_dep];
	
	$sql1 = "SELECT * FROM tambah_fas inner join ambil_fas on ambil_fas.kode_tf=tambah_fas.kode_tf WHERE tanggal BETWEEN '$tglawal' AND '$tglakhir' AND kode_dep='$kode' ORDER BY kode_tf";
	$query1 = mysql_query($sql1);
	
	$content = "<b><li>DAFTAR PENGAMBILAN FASILITAS</li>
	<li>DEPARTEMEN $nadep</li>
	<li>TANGGAL ".jin_date_str($tglawal)." S/D ".jin_date_str($tglakhir)."</li></b>
	<br>
	
	<table width='390' border='1' style='border-collapse:collapse'>
	<tr>
			<th>No.</th>
			<th>Tanggal</th>
			<th>NIK</th>
			<th>Nama Karyawan</th>
			<th>Tgl.Penambahan</th>
			<th>Kode</th>
			<th>Nama Fasilitas</th>
			<th>Jumlah Sisa</th>
			<th>Jumlah Ambil</th>
		</tr>";
		
		$no=1;	
		while($r_data=mysql_fetch_array($query1)){
			
		$content .="<tr>
					<td>$no</td>
					<td align='center'>".jin_date_str($r_data[tanggal])."</td>
					<td>$r_data[kode_kar]</td>
					<td>$r_data[nama_kar]</td>
					<td>$r_data[nama_kar]</td>
					<td>$r_data[kode_fas]</td>
					<td>$r_data[nama_fas]</td>
					<td align='right'>".number_format($r_data[jml_sisa],0)."</td>
					<td align='right'>".number_format($r_data[jml_ambil],0)."</td>
					</tr>";
			$no++;
		}
		
		$content .= "</table>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=daftar_tbfs.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>