<?php 
if(!isset($_SESSION)) { 
  session_start(); 
  include('../includes/dbcon.php');
}
if(empty($_SESSION['hrm_id'])):
header('Location:../index.php');
endif;




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


<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>saleshub |Employee Management </title>
  <!-- plugins:css -->
  <?php include('../includes/commonheader.php');?>



</head>
<body>
 <?php include('../includes/header.php');?>
 <?php include('../includes/leftsidebar.php');?>
           <!-- partial -->
 <div class="main-panel">        
        <div class="content-wrapper">

          <div class="page-header">
            <h3 class="page-title">
                Employee Registration
            </h3>
           
          </div>
          <div class="col-12 grid-margin">
              <div class="card">
                <div class="card-body">

              
         
                 
    <form class="needs-validation" novalidate method="post" action="admin_emp_route1.php" enctype="multipart/form-data" onsubmit="return validateForm()"> 
                  
                    <div class="row">
                      <div class="col-md-6">
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Employee Name <span style="color:red;font-size: 15px;font-weight:bold;">*</span> </label>
                          <div class="col-sm-9">
                            <select class="form-control select2" style="width: 100%;" name="e_id" id="e_id" required >
           <option value="0">~~~Select ~~~~</option>  
          <?php            
          $querydoc=mysqli_query($con,"select * from employee_types  ")or die(mysqli_error());
          
          while($rowd=mysqli_fetch_array($querydoc)){
          ?>
          <option value="<?php echo $rowd['e_id'];?>"><?php echo $rowd['e_des'];?></option>        
          <?php }?>
          </select> 
                          </div>
                        </div>
                      </div>
             
                    </div>

            
                    <div class="row">
           
   

</div>



    <div class="row">
                  






                    </div>                                     
                 
                     <button type="submit" class="btn btn-primary">Next</button>
                    <button class="btn btn-light">Cancel</button>
                  </form>
                </div>
              </div>
            </div>


    <div class="col-12 grid-margin">
              <div class="card">
                <div class="card-body">

                  <h4 >Employee Listing</h4>
                  <p class="card-description">
                    <button type="button" onclick="document.location='home.php'" class="btn btn-warning "><i class="fas fa-arrow-left"></i> Go Back
                    
                  </button>
                  </p>
                  <div class="table-responsive">
                    <table class="table table-hover">
                      <thead>
                        <tr>
                          <th>#</th>
                          <th>Employee</th>
                          <th>Address</th>
                          <th>Mobile</th>
                           <th>Email</th>                          
                          <th>Location</th>
                          <th>Type</th>
                          <th>Active</th>
                          <th>Edit</th> 
                        </tr>
                      </thead>
                      <tbody>
<?php
$rcount=0;
$query=mysqli_query($con,"SELECT * FROM employee_master
LEFT JOIN stock_locations ON employee_master.loc_id=stock_locations.loc_id
LEFT JOIN employee_types ON employee_master.emp_type=employee_types.e_id
")or die(mysqli_error()); 
 while($row=mysqli_fetch_array($query)){   $rcount=$rcount+1;
             
                $emp_id=$row['emp_id'];
                $emp_name=$row['emp_name']; 
                $emp_active=$row['emp_Active'];
                $loc_id=$row['loc_id'];
                $e_des=$row['e_des'];

                if ($emp_active==1) {
                    $empactive="Yes";
                }
             
                if ($emp_active==0) {
                    $empactive="No";
                }

 ?>
   <tr>
                         <td><?php echo $rcount;  ?></td>
                         <td><?php echo $row['emp_name'];?></td>
                         <td><?php echo $row['Address1'];?></td>
                         <td><?php echo $row['mobile'];?></td>
                         <td><?php echo $row['email'];?></td>
                          <td><?php echo $row['loc_name'];?></td>
                            <td><?php echo $row['e_des'];?></td>

                         <td><?php if ($row['emp_Active']>0) { ?> &#10004;<?php } else { ?> &#10006; <?php } ?><a href="admin_location_view.php?emp_id=<?php echo $row['emp_id'];echo "*";echo $empactive;?>"> Change</a></td>


                 
</td>  

<td>
              <form method="post" action="#" enctype="multipart/form-data">
                  
                  <input type="hidden" class="form-control pull-right" id="tid" name="tid"  value=" <?php echo $emp_id; ?>">   
                   <input type="hidden" name="fname" id="fname" class="form-control todo-list-input" placeholder="Add To-do" value="<?php echo basename($_SERVER['PHP_SELF']);  ?>">
                    <input type="hidden" class="form-control" id="s1_remarks" name="s1_remarks" placeholder="Remarks">

                  

                       <button type="button" class="btn btn-outline-info btn-rounded btn-icon"  data-toggle="modal" data-target="#addvoucher_edit<?php echo $loc_id;?>">
                          <i class="fa fa-edit"></i>
                        </button>

                  
              </form>
              </td> 

 <?php }  ?>
</tr>
                      </tbody>
                    </table>



        </div>  <!----- <div class="content-wrapper">------>
                </div>
              </div>
    </div>



        </div>  <!----- <div class="content-wrapper">------>
  </div> 
</div>


</div>  <!----- <div class="content-wrapper">------>
  

 </div><!-----End of main panel--~~~~~~~~~~~~~~~~~~~~~~~--------------->
 </div><!-----Dont Delete this DIV--~~~~~~~~~~~~~~~~~~~~~~~--------------->
  <!-- container-scroller -->
<?php include('../includes/footer.php');?>
<?php include('../includes/commonjs.php');?>
 
</body>


</html>

<script>
    $( document ).ready(function() {
         // alert("Please Select Order Type");

    });

function validateForm() { 

    //````````route````````````````````````````````````
    if($('#vroute').val().trim().length == 0) {
           alert("Please enter the route you visited !!!");               
            return false;
    } ////``````````````````````````````````````````

     //````````start mileage````````````````````````````````````
    if ($('#sm').val() == 0){
           alert("Please enter the start mileage !!!");               
            return false;
    } ////``````````````````````````````````````````


 //````````end mileage````````````````````````````````````
    if ($('#em').val() == 0){
           alert("Please enter the end mileage !!!");               
            return false;
    } ////``````````````````


//````````fuel charge````````````````````````````````````
    if ($('#fg').val() == 0){
           alert("Please enter the fuel charge !!!");               
            return false;
    } ////``````````````````


//````````bata````````````````````````````````````
    if ($('#bata').val() == 0){
           alert("Please enter the bata !!!");               
            return false;
    } ////``````````````````

//````````Customer````````````````````````````````````
    if($('#cus').val().trim().length == 0) {
           alert("Please enter visited customer code and name");               
            return false;
      }///``````````````````



 } ///validateForm() { 

</script>

 <!-- End custom js for this page-->
  <script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
  })

</script>



