<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php

        $m->where("branch_id", $_SESSION['branch']);
        $branch=$m->get("edu_branch_config");

  if(isset($_REQUEST['emp'])){

     
          $data = array('status' => '1');
          $m->where("branch_id", $_SESSION['branch']);
          $m->where("user_id", $_REQUEST['emp']);

          $result =  $m->update ('edu_user_config', $data);
   
   
      header("location:view_emp.php?".session_id().session_id().session_id());


 }
   
     

     $branch=$_SESSION['branch'];

   $m->where("status", '0');
   $m->where("branch_id", $_SESSION['branch']);
   $m->where("designation_id!=14");
   $m->orderBy("user_id", 'desc');
   $WorkAssignListings = $m->get("edu_user_config");
 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>View Employees | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
 
<style>

.tdStyle{border-bottom:1px solid lightgray;}
.thStyle{background-color:#00AFEF;color:white;}

</style>  
  </head>
  
  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">

            <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
             View Staff Security Fee
          <br><br>
          
          <div class="" style="background-color: white;">
           
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
 
    </div>
    <br>

     
          
          <?php  if(isset($_SESSION['Updated'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student record is updated successfully...
            </div>


          <?php  unset($_SESSION['Updated']); }?>

      

          
          <?php  if(isset($_SESSION['Added'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Record is Added successfully...
            </div>

          <?php  unset($_SESSION['Added']); } ?>


           <?php  if(isset($_SESSION['already'])){?>


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Warning!</strong> You cannot add duplicated record, Please change name or password!
            </div>

          <?php  unset($_SESSION['already']); } ?>

 
 
  <h3>List View Employee</h3>


<input type="hidden" value="<?php echo $_REQUEST['class_id']; ?>" name="class_id" />
<input type="hidden" value="<?php echo $_REQUEST['section']; ?>" name="section" />


<div style="overflow-x:auto;">

<table id="listofstudents" class="table table-striped table-bordered" style="width:100%">
        <thead>
            <tr>

                <th width="5%">S.No</th>
                <th width="20%">Name</th>
                <th width="12%">Department </th>
                <th width="12%">Designation</th>
                <th width="11%">Cell </th>
                <th width="10%">Security </th>
                <th width="5%">Details</th>
               
                
                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 

     $count=1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $m->where("designation_id", $WorkAssignListVal['designation_id']);
        $designation=$m->get("eduportal_designation_config");

        $m->where("department_id", $WorkAssignListVal['department_id']);
        $department=$m->get("eduportal_hrm_department_config");

        

      ?>

  <tr>
        
     <td style="text-align:center;"> <?php echo $count; $count++; ?>  </td>

<td>

  <!-- making a link   -->
<a style="padding: 0px 5px; font-size:14px;"  href="emp_details.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&emp=<?php echo $WorkAssignListVal['user_id'];?>" style="cursor:pointer;">

      <?php if($WorkAssignListVal['attach_image']!=NULL){?>

        <img style="border-radius:50%;height:35px;with:35px;" src="<?php echo DOMAIN;?>Production/staff_pics/<?php echo $WorkAssignListVal['attach_image'];?>"  />
      <?php }else {?>

        <img style="border-radius:50%;height:35px;with:35px;" src="images/student.png" />

      <?php }?>
      
       &nbsp;&nbsp; <?php echo $WorkAssignListVal['user_fname'];?>
</a>
                   
                   
</td>

      
      <td> <?php echo $department[0]['department_name'];?> </td>
      <td> <?php echo $designation[0]['designation_name'];?> </td>
      <td style="text-align:center;"> <?php echo $WorkAssignListVal['cell_no'];?> </td>
      <td> <?php echo $WorkAssignListVal['user_security'];?> </td>
        


    <td>


<a style="padding: 0px 5px; font-size:14px;"  data-toggle="modal" data-target="#Security<?php echo $WorkAssignListVal['user_id'];?>" style="cursor:pointer;"  class="btn btn-success">

      View
</a>


<!-- Modal -->
      <div id="Security<?php echo $WorkAssignListVal['user_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content" style="width: 600px;margin-left: 0%;">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title"> Security Histroy  </h4>
            </div>


            <div class="modal-body">

              <h3> <?php echo $WorkAssignListVal['user_fname'];?> <?php echo $WorkAssignListVal['user_lname'];?>             
              </h3>
            </div>
       
          <div class="col-md-12" >
            
            <table border="1" width="100%">  

              <tr>  

                <th class="thStyle" style="font-size: 18px;font-weight: bold;text-align: center;"> Month  </th>
                <th class="thStyle" style="font-size: 18px;font-weight: bold;text-align: center;"> Security  </th>
                
              </tr>


<?php 

$m->where("user_id", $WorkAssignListVal['user_id']);
$history = $m->get("employee_payroll");

foreach($history as $details){

  
         // getting students details 

        $m->where("student_id", $details['student_id']);
        $m->where("status", 0);
        $student=$m->get("edu_student_details");

        $totalDeduction+=$details['security_deductions'];

?>            


              <tr>  

               
                <td style="font-size: 16px;color: black;text-align: center;background-color: white;"> <?php echo getMonthName($m,$details['month_id']);?> </td>
                <td style="font-size: 16px;color: black;text-align: center;background-color: white;"> <?php echo $details['security_deductions']." Rs";?> </td>
                
              </tr>


<?php 

}
?>            
      <tr>
        
          <td style="background-color: lightgray;color: black;font-size: 18px;font-weight: bold;text-align: center;">Total</td>
          <td style="background-color: lightgray;color: black;font-weight: bold;font-size: 18px;text-align: center;"><?php echo $totalDeduction." RS";?></td>

      </tr>



            
             </table>
<?php $totalDeduction="";?>
          </div>

          <br><br>


            <div class="modal-footer">

             <button type="button" style="margin-top:2%;" class="btn btn-default" data-dismiss="modal">Close</button>


            </div>



          </div>

        </div>
      </div>

      <!-- ending modal -->


      </td>




              </tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>

  </div>

  

    <br><br>


  </div>
  <div class="clearfix"></div>
</section>          
    

           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  

    
  <?php include('RootMe/js_linksscript.php');?>

  <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
  <script src="https://cdn.ckeditor.com/4.12.1/standard/ckeditor.js"></script>
   <!-- jQuery -->
    <script src="js/ajax_functions.js"></script> 
  </body>
</html>
