<?php include "../include/config.php"; ?>
<html>
<head>
<link rel='stylesheet' type='text/css' href="../include/css/popup_styles.css" />	
<script language='javascript'>
	function select_go(name)
	{			
		eval("opener.document.form.username2").value = name;	
		window.close();
		self.close();	
	}
</script>
</head>
<?php $idcat = isset($_REQUEST['idcat']) ? $_REQUEST['idcat'] :''; ?>
<body>
<div id="popup">
<form action="popup_empl.php" method="post" enctype="multipart/form-data">
<table width="100%">
	<tr>
		<th colspan="2">
		Cari :<input type="text" name="cari" size="20">
			  <input type="hidden" name="idcat" value="<?=$idcat;?>" size="20">
		      <input type="submit" name="proses" value="CARI">
		</th>
	</tr>
	<tr>
		<th>Nama Karyawan</th>
		<th>Alamat</th>
	</tr>
    <?php
	$idcat = isset($_REQUEST['idcat']) ? $_REQUEST['idcat'] :'';
	$cari  = isset($_REQUEST['cari']) ? $_REQUEST['cari'] :'';
	if (isset($_REQUEST['proses'])=="CARI"){
		$list = "WHERE empl_category='$idcat' AND empl_name LIKE '%$cari%'";
	}else{
		$list = "WHERE empl_category='$idcat'";
	}
	$query = mysql_query("SELECT empl_name,empl_address FROM employee $list ORDER BY empl_name ASC ");
	while($data=mysql_fetch_object($query)){
	?>
	 <tr>
		<td><a href="#" onClick="select_go('<?=$data->empl_name;?>')"><?=$data->empl_name;?></a></td>
		<td><?=$data->empl_address;?></td>
	</tr>	
	<?php } ?>
</table>
</form>
</div>
</body>
</html>
