<? include("si_confi.php"); ?>
<? include("ad_head.php"); ?>
  <div class="container">
<? include("mn_option.php");


if($_REQUEST['action']=='trsh') {
	$get_emp_id=base64_decode($_REQUEST['isd']);
	mysql_query("delete from `employee_mng` where `id`='$get_emp_id'");
?><script>window.location="viwe_empploe.php?del=suc";</script><? }



	?>
    

<? if($_REQUEST['ed']=='suc'){ ?>
<div class="success" style="width:92%;margin:0 auto;margin-top:9px;">One Employee Details Edited successfully.</div><? } ?>
<? if($_REQUEST['del']=='suc'){ ?>
<div class="error" style="width:92%;margin:0 auto;margin-top:9px;">One Employee Details Deleted successfully.</div><? } ?>
 

<?

 $depart=$_REQUEST['department'];

$get_emp_name12=$_REQUEST['search_employee'];

if($get_emp_name12!=NULL && $depart!=NULL ){
$select_count_emp=mysql_query("select count(*) as num from `employee_mng` where `name`='$get_emp_name12' and department='$depart' "); 
} 
elseif($get_emp_name12==NULL && $depart!=NULL ) 
{
$select_count_emp=mysql_query("select count(*) as num from `employee_mng` where  department='$depart' ");  
}
elseif($get_emp_name1!=NULL && $depart==NULL ) 
{
$select_count_emp=mysql_query("select count(*) as num from `employee_mng` where `name`='$get_emp_name12' ");  
}
else 
{
$select_count_emp=mysql_query("select count(*) as num from `employee_mng` ");	
}
$fetch_count_emp=mysql_fetch_array($select_count_emp);
$total_emp_result=$fetch_count_emp['num'];
?>

   <div style="border:groove;margin-top:10px;border-width:thin;padding:20px;border-radius:4px;border-color:#cccccc;box-shadow: 10px 9px 90px #000;">
   <h2>View Employee Details&nbsp;&nbsp;&nbsp;(Total&nbsp;:&nbsp;<? echo $total_emp_result; ?>)</h2>
   
   <link rel="stylesheet" type="text/css" media="all" href="ad_comple.css">
  <script type="text/javascript" src="jquery-1.9.1.min.js"></script>
  <script type="text/javascript" src="jquery.autocomplete.min.js"></script>  
  <script type="text/javascript">
  $(function(){
  var currencies = [
 <?php $qur="SELECT distinct `name` FROM `employee_mng`"; 
		$result = mysql_query($qur);
		while ($row_section = mysql_fetch_array($result)) {?>	  
    { value:'<?php echo $row_section['name']; ?>' },<?php } ?> ];
  $('#autocomplete').autocomplete({
    lookup: currencies,
  }); });
</script>
   
   <form method="post" enctype="multipart/form-data" action="viwe_empploe.php">
   <table>
   <tr>
   <td><input type="text" name="search_employee" id="autocomplete"></td>
   <td>
   
   <select name="department" class="validate-selection" style="width:160px; height:20px;" >
        
        <option value="" hidden="">Select Department</option>
        <? $seleect_employee3=mysql_query("select * from `department`");
		while($fetch_employee3=mysql_fetch_array($seleect_employee3)){ ?>
        <option value="<? echo $fetch_employee3['department']; ?>"><? echo ucwords($fetch_employee3['department']); ?></option>
		<? } ?>
        </select>
   </td>
   <td><input type="submit" name="search_emp" value="Search"></td>
   </tr>
   </table>
   </form>
  <br>
    <table width="100%" cellpadding="9" cellspacing="0" border="1">
  <tr bgcolor="#CCCCCC">
  <td>EMP ID</td>
  <td>Name</td>
  <td>Dept</td>
  <td>Office Email ID</td>
  <td>Password</td>
  <td>Mobile No</td>
  <td>Details</td>
  <td>Photo</td>
  <td>Edit</td>
  <td>Delete</td>
  </tr>
  <?
  
  
  if($get_emp_name12!=NULL && $depart!=NULL )
  {
	   $select_employee_details=mysql_query("select * from `employee_mng` where `name`='$get_emp_name12' and department='$depart'");
  } 
elseif($get_emp_name12==NULL && $depart!=NULL ) 
{
	 $select_employee_details=mysql_query("select * from `employee_mng` where  department='$depart'");
 }
elseif($get_emp_name12!=NULL && $depart==NULL ) 
{
	 $select_employee_details=mysql_query("select * from `employee_mng` where department='$depart' x");
}
else 
{
  $select_employee_details=mysql_query("select * from `employee_mng`");
}
  
	   
  while($fetch_employee_details=mysql_fetch_array($select_employee_details)){ ?>
  <tr bgcolor="#FFFFFF">
  <td><? echo ucwords($fetch_employee_details['emp_id']); ?></td>
  <td><? echo ucwords($fetch_employee_details['name']); ?></td>
  <td><? echo ucwords($fetch_employee_details['department']); ?></td>
  <td><? echo $fetch_employee_details['work_emailid']; ?></td>
  <td><? echo $fetch_employee_details['email_password']; ?></td>
  <td><? echo $fetch_employee_details['mobileno']; ?></td>
  <td><a href="JavaScript:newPopup('det_emp.php?isd=<? echo base64_encode($fetch_employee_details['id']); ?>');"><img src="ad_img/user-information-icon-31095.png" width="40"></a></td>
  
  
  
  <td align="center">
  <a href="JavaScript:newPopup('photoview.php?isd=<? echo base64_encode($fetch_employee_details['id']); ?>');">
  <img src="<? echo $fetch_employee_details['photo']; ?>" width="80"></a></td>
  
  
  <td><a href="edit_emp_dt.php?isd=<? echo base64_encode($fetch_employee_details['id']); ?>"><img src="ad_img/edit-male-user-icon.png" width="40"></a></td>
  <td><a href="viwe_empploe.php?isd=<? echo base64_encode($fetch_employee_details['id']); ?>&&action=trsh" onClick="return confirm('Are you sure you want to confirm delete?');"><img src="ad_img/Remove-Male-User.png" width="40"></a></td>
  </tr>
  <? } ?>
  <script type="text/javascript">
function newPopup(url) {
	popupWindow = window.open(
		url,'popUpWindow','height=580,width=700,left=140,top=60,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
  </table>  
  </div>
</div><!-- container -->
  </body>
</html>