<?php
	include '../../inc/inc.koneksi.php';
	include '../../inc/fungsi_tanggal.php';
	
	$tglaw= $_GET['tgl_awal'];
	$tglak= $_GET['tgl_akhir'];
	
	$sql2 = mysql_query("SELECT nama1 FROM company");
	$r2	  = mysql_fetch_assoc($sql2);
	$kop1 = $r2[nama1];
	
	$content = "<b><h3>$kop1</h3><b>
	<b><li>DAFTAR HADIR KARYAWAN</li><b>
	<b><li>PERIODE ".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>NIK</th>
			<th>Nama Karyawan</th>
			<th>Jabatan</th>
			<th>Sakit</th>
			<th>Ijin</th>
			<th>Alpa</th>
		</tr>";
		
		$sql = "SELECT nik,nama,jabatan,sum(sakit) as jsakit,sum(ijin) as jijin,sum(alpa) as jalpa FROM gaji WHERE tanggal BETWEEN '$tglaw' AND '$tglak' GROUP BY nik";
		$query = mysql_query($sql);
		$no=0;
		
		while($r_data=mysql_fetch_array($query)){
			$no++;
			$content .="<tr>
					<td align='center'>$no</td>
					<td>$r_data[nik]</td>
					<td>$r_data[nama]</td>
					<td>$r_data[jabatan]</td>
					<td align='center'>$r_data[jsakit]</td>
					<td align='center'>$r_data[jijin]</td>
					<td align='center'>$r_data[jalpa]</td>
				</tr>";			
		}
		
		$content .= "</table>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=daftar_hadir.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>