<?php
	include_once('../../inc/inc.koneksi.php');	
	include '../../inc/fungsi_tanggal.php';	
	$cari	=$_GET['cari'];
	
	if (!empty($cari)){
		$sql= "SELECT * FROM karyawan WHERE (nik LIKE '%$cari%' OR nama LIKE '%$cari%') ORDER BY nik ";
	}
	else{
		$sql= "SELECT * FROM karyawan ORDER BY nik";
	}
		
	$query = mysql_query($sql);
	$tgl = date('d M Y');
	
	$content = "<h3><b>DAFTAR KARYAWAN</h3>
				<h3>PER TANGGAL  : $tgl</b></h3>

	<table width='390' border='1' style='border-collapse:collapse'>
	<tr>
		<th>No.</th>
		<th>NIK</th>
		<th>Nama Karyawan</th>
		<th>Tgl.Masuk</th>
		<th>Jabatan</th>
		<th>Alamat</th>
		<th>Tempat Lahir</th>
		<th>Tgl.Lahir</th>
		<th>Pendidikan</th>
		<th>Jns.Kelamin</th>
		<th>Status Kawin</th>
		<th>Jml.Anak</th>
		<th>Gaji Pokok</th>
		<th>Uang Makan</th>
		<th>Tunj. Jabatan</th>
	</tr>";
		
	$no=1;
	while($r_data=mysql_fetch_array($query)){		
		
		$content .="<tr>
			<td align='right'>$no</td>
			<td>$r_data[nik]</td>
			<td>$r_data[nama]</td>
			<td align='center'>".jin_date_str($r_data[tglmasuk])."</td>			
			<td>$r_data[jabatan]</td>					
			<td>$r_data[alamat]</td>
			<td>$r_data[tplahir]</td>
			<td align='center'>".jin_date_str($r_data[tglahir])."</td>
			<td>$r_data[pendidikan]</td>
			<td>$r_data[sex]</td>
			<td>$r_data[status_kwn]</td>
			<td>$r_data[jml_anak]</td>
			<td align='right'>".number_format($r_data[gapok],0)."</td>
			<td align='right'>".number_format($r_data[umak],0)."</td>
			<td align='right'>".number_format($r_data[tunj_jab],0)."</td>
			</tr>";
			$no++;
		}
	$content .= "</table>";
		
		//laporan ke excel
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=daftar_karyawan.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>