<?php
ini_set('display_errors', 0);
//error_reporting(E_ALL);
//ini_set('display_errors', 1);

session_start();
ob_start();

require_once('configuration/server_connect.php');
require_once('configuration/all_function.php');

$active_id=$_REQUEST['active_id'];
$menu_id=$_REQUEST['menu_id'];

// Common Information

$page_title="Employee Information";
$page="71_employee_02.php?active_id=".$active_id."&menu_id=".$menu_id."";
$table='employee_info';	
$unique='emp_code';

// End Common Information

?>


<!DOCTYPE html>
<html lang="en">

 <?php require_once('inc_files/inc_head.php'); ?>

<body>

  <!-- ======= Header ======= -->
  <?php 
  require_once('inc_files/inc_header.php');
  ?><!-- End Header -->

  <!-- ======= Sidebar ======= -->
  <?php  require_once('inc_files/inc_menu.php'); ?><!-- End Sidebar-->

  <main id="main" class="main">

    <div class="pagetitle">
      <h1><?php echo $page_title?></h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="home.php">Home</a></li>
          <li class="breadcrumb-item">Employee</li>
          <li class="breadcrumb-item active"><?php echo $page_title?></li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section">
      <div class="row">
        <div class="col-lg-12"> 

          <div class="card">
            <div class="card-body">
			<br>
            <form class="row g-3" action="" method="post" name="codz" id="codz">
   		       
			
	<table width="80%" border="0" align="center">
      
      
      <tr height="50">
        <td width="28%" align="right">EMP NAME:&nbsp;&nbsp;</td>
        <td colspan="3">
		 <?php
			 auto_complete_from_db_sql($conn,'SELECT concat(emp_code," :: ",emp_name), concat(emp_code," :: ",emp_name) FROM employee_info
			WHERE 1 order by emp_code','employee_name');
		?>
                  <input type="text" class="form-control" id="employee_name" name="employee_name" value="<?php echo $_REQUEST['employee_name']?>" >		</td>
        <td width="16%" rowspan="5" align="center" ><strong>
          &nbsp;&nbsp;&nbsp;
          <button type="submit" class="btn btn-success rounded-pill btn-sm">&nbsp;<i class="bi bi-filter me-1"></i> Run Report&nbsp;&nbsp;</button>
        </strong></td>
        <td width="17%" rowspan="5" align="center" ><a href="71_employee_02.php?active_id=704&menu_id=7"><button type="button" class="btn btn-primary btn-sm"><i class="bi bi-plus-lg me-1"></i> Add an Employee&nbsp;&nbsp;&nbsp;</button></a></td>
      </tr>
    </table>
               
  </form>
	
              <!-- Table with stripped rows -->
              <table width="490" class="table datatable" style="font-size:12px;">
                <thead>
                  <tr>
                    <th width="75" scope="col"><span class="card-title" style="font-size:14px; text-transform:uppercase;">EMP Code </span></th>
                    <th width="86" scope="col"><span class="card-title" style="font-size:14px; text-transform:uppercase;">EMP Name </span></th>
                    <th width="79" scope="col"><span class="card-title" style="font-size:14px; text-transform:uppercase;">Designation</span></th>
                    <th width="79" scope="col"><span class="card-title" style="font-size:14px; text-transform:uppercase;">Mobile No</span></th>
                    <th width="45" scope="col"><span class="card-title" style="font-size:14px; text-transform:uppercase;">Email</span></th>
                    <th width="86" scope="col"><span class="card-title" style="font-size:14px; text-transform:uppercase;">Job Status</span></th>
                  </tr>
                </thead>
                <tbody>
					<?php
					
					
 $employee_name = $_REQUEST['employee_name'];
  $employee=explode(' :: ',$employee_name);
   $employee_code=$employee[0];
  
if($employee_code!=''){
$employee_con=" and emp_code='".$employee_code."' ";
}

	
		 $sql = "select id, designation from designation where 1 group by id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $designation[$info->id]=$info->designation;
		}			
					
		 $sql = "select id, job_status from job_status where 1 group by id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $job_status[$info->id]=$info->job_status;
		}
					
					    $sql = 'select * from '.$table.' where 1 '.$employee_con.' ';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
				
      <tr>
      <td><a href="<?php echo $page;?>&<?php echo $unique;?>=<?php echo $data->emp_code;?>" style="color:#000000"><?php echo $data->emp_code;?></a></td>
      <td><a href="<?php echo $page;?>&<?php echo $unique;?>=<?php echo $data->emp_code;?>" style="color:#000000"><?php echo $data->emp_name;?></a></td>
      <td><a href="<?php echo $page;?>&<?php echo $unique;?>=<?php echo $data->emp_code;?>" style="color:#000000"><?php echo $designation[$data->designation]?></a></td>
      <td><a href="<?php echo $page;?>&<?php echo $unique;?>=<?php echo $data->emp_code;?>" style="color:#000000"><?php echo $data->mobile_no;?></a></td>
      <td><a href="<?php echo $page;?>&<?php echo $unique;?>=<?php echo $data->emp_code;?>" style="color:#000000"><?php echo $data->email;?></a></td>
      <td><a href="<?php echo $page;?>&<?php echo $unique;?>=<?php echo $data->emp_code;?>" style="color:#000000"><?php echo $job_status[$data->job_status]?></a></td>
      </tr>
				  <?php }?>
                </tbody>
              </table>
              <!-- End Table with stripped rows -->

            </div>
          </div>

        </div>

        
      </div>
    </section>

  </main><!-- End #main -->

  <!-- ======= Footer ======= -->
  <?php require_once('inc_files/inc_footer.php'); ?>
 <!-- ======= Footer ======= -->
</body>

</html>