<?php
	include '../../inc/inc.koneksi.php';
	include '../../inc/fungsi_tanggal.php';
	
	$kode = $_GET[kode];
	$jml = 0;
	$tgllap =date('d-m-Y');
	
	$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];
	
	$content = "<b><li>DAFTAR INVENTARIS KARYAWAN</li>
		<li>DEPARTEMEN $nadep</li>
		<li>PER TANGGAL $tgllap</li></b>
		<br>
	
		<table width='390' border='1' style='border-collapse:collapse'>
		<tr>
			<th>No.</th>
			<th>Kode Inv.</th>
			<th>Nama Inventaris</th>
			<th>Jumlah Jatah</th>
			<th>Jumlah Ambil</th>
			<th>Tgl.Pengambilan</th>			
		</tr>";
	
		$query2	= "SELECT * FROM data_fas WHERE kode_dep='$kode' GROUP BY kode_kar";
		$data2	= mysql_query($query2);
		while($r_data2=mysql_fetch_array($data2)){
		
		$content .= "<tr>	
			<td><b>$r_data2[kode_kar]</b></td>
			<td align='center'><b> - </b></td>
			<td><b>$r_data2[nama_kar]</b></td>
			</tr>";
		
		$sql = "SELECT * FROM data_fas WHERE kode_dep='$kode' ORDER BY kode_kar ";		
		$query = mysql_query($sql);
		
		$no=1;
		while($r_data=mysql_fetch_array($query)){
		
		$content .= "<tr>	
			<td align='center'>$no</td>
			<td align='center'>$r_data[kode_fas]</td>
			<td>$r_data[nama_fas]</td>
			<td align='center'>$r_data[jatah]</td>
			<td align='center'>$r_data[jumlah]</td>
			<td align='center'>".jin_date_str($r_data[tanggal_amb])."</td>	
			</tr>";
			$no++;
			$jml++;
		}
		}
		$content .= "</table>";
		
		$content .= "<table>
			<tr>
				<td>Jumlah Data : $jml</td>
			</tr>
			</table>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=daftar_inv.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>
