<?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'];
$page_title="Employee Contact List";
$page="71_employee_02.php";	
$table='employee_info';	
$unique='emp_code';


?>


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


<!-- ======= <head> ======= -->
 <?php require_once('inc_files/inc_head.php'); ?>
<!-- ======= </head> ======= -->

<?php
  do_calander('#fdate');
  do_calander('#tdate');

  ?>
  

<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"> Reports</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">
			<p class="card-title" style="font-size:14px; margin-bottom:0; padding-bottom:0;"><a href="61_reports_all.php?active_id=901&menu_id=9">< Back To Report List </a></p>
			
            <form class="row g-3" action="" method="post" name="codz" id="codz">
   		       
			
	<table width="80%" border="0" align="center">
      
      
        <tr height="50">
          <td align="right">Department:&nbsp;&nbsp;</td>
          <td align="left">
		  <select id="department" name="department"  class="form-select"    >
		  <option></option>
			
			<?php foreign_relation($conn,'department','id','department',$_POST['department'],'1 order by id');?>
        	</select>		  </td>
          <td align="right">Gender:&nbsp;&nbsp;</td>
          <td width="16%">
	
			<select id="gender" name="gender"  class="form-select"    >
			<option></option>
			<?php foreign_relation($conn,'gender','id','gender',$_POST['gender'],'1 order by id');?>
		
        	</select>		  </td>
          <td width="11%" align="right">Job Status:&nbsp;&nbsp;</td>
          <td width="17%">
		  <select id="job_status" name="job_status"  class="form-select" >
		  <option></option>
			<?php foreign_relation($conn,'job_status','id','job_status',$_POST['job_status'],'1 order by id');?>
        	</select></td>
          <td width="16%" rowspan="6" align="center" ><strong>
            &nbsp;&nbsp;&nbsp;
            <button type="submit" name="run_data" id="run_data" class="btn btn-success rounded-pill btn-sm">&nbsp;<i class="bi bi-filter me-1"></i> Run Report&nbsp;&nbsp;</button>
          </strong></td>
        </tr>
        <tr height="50">
        <td width="11%" align="right">Designation:&nbsp;&nbsp;</td>
        <td width="19%" align="left">
		<select id="designation" name="designation"  class="form-select"    >
		  <option></option>
			
			<?php foreign_relation($conn,'designation','id','designation',$_POST['designation'],'1 order by id');?>
        	</select>		</td>
        <td width="10%" align="right">Religion:&nbsp;&nbsp;</td>
        <td>
	
			<select id="religion" name="religion"  class="form-select"    >
			<option></option>
			<?php foreign_relation($conn,'religion','id','religion',$_POST['religion'],'1 order by id');?>
		
        	</select>
			</td>
        <td align="right">EMP Name:&nbsp;&nbsp;</td>
        <td>
		 <?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>
        </tr>
    </table>
               
  </form>
  <br>
	
              <!-- Table with stripped rows -->
             <table width="100%" class="table table-sm" style="font-size:12px;">
                <thead>
                  <tr style="text-transform:uppercase; color:#012970; background:#f6f9ff;  border-top: 1px solid #CCCCCC;">
                    <th width="117" scope="col"><span class="card-title" style="font-size:12px; text-transform:uppercase;">EMP Code </span></th>
                    <th width="319" scope="col"><span class="card-title" style="font-size:12px; text-transform:uppercase;">EMP Name </span></th>
                    <th width="326" scope="col"><span class="card-title" style="font-size:12px; text-transform:uppercase;">Designation</span></th>
                    <th width="175" scope="col"><span class="card-title" style="font-size:12px; text-transform:uppercase;">Mobile No</span></th>
                    <th width="222" scope="col"><span class="card-title" style="font-size:12px; text-transform:uppercase;">Email</span></th>
                    <th width="96" scope="col"><span class="card-title" style="font-size:12px; text-transform:uppercase;">Gender</span></th>
                    <th width="183" scope="col"><span class="card-title" style="font-size:12px; 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."' ";
}


if($_POST['department']!=''){
$department_con=" and department='".$_POST['department']."' ";
}

if($_POST['designation']!=''){
$designation_con=" and designation='".$_POST['designation']."' ";
}

if($_POST['gender']!=''){
$gender_con=" and gender='".$_POST['gender']."' ";
}

if($_POST['religion']!=''){
$religion_con=" and religion='".$_POST['religion']."' ";
}


if($_POST['job_status']!=''){
$job_status_con=" and job_status='".$_POST['job_status']."' ";
}
	
		 $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, gender from gender where 1 group by id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $gender[$info->id]=$info->gender;
		}		
					
		 $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.$designation_con.$department_con.$job_status_con.$gender_con.$religion_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 $gender[$data->gender];?></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'); ?>
<!-- ======= End Footer ======= -->

</body>

</html>