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

 $branch=$_SESSION['branch'];

if (isset($_REQUEST['designation'])) {
  $m->where("designation_id", $_REQUEST['designation']);
}
 $m->where("status", '0');
 $m->where("branch_id", $_SESSION['branch']); 
 $m->orderBy("user_id", 'desc');
 $WorkAssignListings = $m->get("edu_user_config");
 
?>
<input type="hidden" name="" value="<?php print_r($WorkAssignListings);?>">
<!DOCTYPE html>
<html lang="en">
<head>
  
<title>Mark Employees Attendance | EduPortal</title>
<?php include('RootMe/css_links.php');?>

<style>
/* The container */
.btn_style {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 12px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Hide the browser's default radio button */
.btn_style input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

/* Create a custom radio button */
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #eee;
    border-radius: 50%;
}

/* On mouse-over, add a grey background color */
.btn_style:hover input ~ .checkmark {
    background-color: #ccc;
}

/* When the radio button is checked, add a blue background */
.btn_style input:checked ~ .checkmark {
    background-color: #2196F3;
}

/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

/* Show the indicator (dot/circle) when checked */
.btn_style input:checked ~ .checkmark:after {
    display: block;
}

/* Style the indicator (dot/circle) */
.btn_style .checkmark:after {
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}

 @media only screen and (max-width: 768px) {

    /* For mobile phones: */

    .margin{
        margin-top: 0px;
    }
    
}

@media (min-width:801px)  { /* tablet, landscape iPad, lo-res laptops ands desktops */ 

    .margin{

        
        margin-top: 34px;
       
    }
  
  
}
</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'];?>" style="margin-left: 33px;">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;

          <a href="view_emp_attendance.php">View Staff Attendance </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;  

          Mark Staff Attendance

          <div class="" style="background-color: white;padding:2%;">
           
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
      <form class="" action="mark_emp_attendance.php" enctype="multipart/form-data" method="get">
        <div class="">
          <h3 style="float: left;"> <?php if($_GET['edit']=="yes"){echo 'Edit';}else{echo "Mark";} ?> Employee Attendance <small>(<?php echo count($WorkAssignListings);?> Employees Records)</small> </h3>

    
          </span> </div>
         
        </div>
      </form>
      <div class="clearfix"></div>
    </div>

<div style="overflow-x:auto;">
 
<form class="form-style-7" action="mark_emp_attendance.php" method="Get">

  
              
   

                 <div class="col-md-3 col-sm-12 col-xs-12" >
                          <div class="form-group" >
                            
                            <label>  Designation </label>
                              <select name="designation" class="form-control"  >
                                <option value="">Select</option>

                  <?php
                  $query="select * from eduportal_designation_config where designation_id!='14' and designation_id!='15'";
                  $WorkAssignList = $m->query($query);
                  foreach($WorkAssignList as $WorkAssignListVal)
                  { ?>

                         <option <?php if($_REQUEST['designation']==$WorkAssignListVal['designation_id']){echo "selected";} ?>  value="<?php echo $WorkAssignListVal['designation_id']; ?>"><?php echo $WorkAssignListVal['designation_name']; ?></option>


                  <?php } ?>

                            </select>
                          </div>
                      </div>         



              <div class="col-md-4 " style="padding:2px;">
    
        
                <div class="form-group ">
                   
                <button id="month"  type="submit" class="btn btn-primary" style="margin-top: 20px;">Search</button>
              
                </div>
       
              </div>
             
</form>



<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post"  onSubmit="return student_check();"  enctype="multipart/form-data">


  <input type="hidden" name="action" value="MarkEmpAttendance">
  <input type="hidden" id="session"  name="session" value="<?php echo $_GET['session']; ?>" />
  <input type="hidden" id="date"  name="date" value="<?php echo $_GET['date']; ?>" />


<?php 

 if(isset($_SESSION['emp_error_msg'])){
?>
<div class="col-md-12">

  <div  style="display:block;" class="alert alert-danger alert-dismissible">
      <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
       <strong>Warning !</strong> Attendance has already saved of this date!!!
  </div>

</div>
<?php 
  unset($_SESSION['emp_error_msg']);
   }
?> 
      
              
              <div class="col-md-3 col-sm-12 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
                    <select name="session" class="form-control"  style="height:40px;">

                              
                        <?php

                       $match;
                        if(!isset($_REQUEST['session'])){
                          $match=$_SESSION['current_session'];
                        }else { $match=$_REQUEST['session']; }
                       
                                 
                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($match==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></option>


                                <?php
                        } ?>

                    </select>
                </div>
              </div>


              <div class="col-md-3 col-sm-12 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Date</label>
                  <?php 

                  $date1;
                  if($_REQUEST['date']!=NULL){
                    $date1=$_REQUEST['date'];
                  }else {
                    
                    $date1=date("Y-m-d");
                  }
                  
                  ?>
                  <input class="form-control" type="date" name="date"  id="date" style="height:40px;"  value="<?php echo $date1;?>" required>
                </div>
              </div>
 

              <div class="col-md-3 col-sm-12 col-xs-12 " style="padding:2px;">
    
           <?php    if(count($WorkAssignListings)>0){?>

                <div class="form-group ">
                   
                <button type="submit" class="btn btn-primary margin">Save Attendance</button>

                <input type="submit" name="holiday" class="btn btn-danger pull-right margin"  value="Mark as holiday" style="margin-right: 15px;"  />
                </div>



         <?php    }?>

              </div>


    <table id="listofstudents" data-page-length='100' class="table table-striped table-bordered" style="width:100%">
          
          <thead>
            <tr>
                <th width="5%">S.No</th>
                <th width="20%">Name</th>
                <th width="11%">Department </th>
                <th width="11%">Designation</th>                
                <th width="8%" style="text-align:center;"> Date </th>
                <th width="34%">Attendance</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");

        $att=getEmployeeAttendance($_GET['date'],$WorkAssignListVal['user_id'],$m);
      ?>


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

  <td>

    <?php echo $WorkAssignListVal['user_fname'];?>
    <input name="attendance[]" id="attendance[]" type="hidden" value="<?php echo $WorkAssignListVal['user_id'];?>">
            
                     
  </td>

      
      <td> <?php echo $department[0]['department_name'];?> </td>
      <td> <?php echo $designation[0]['designation_name'];?> </td>
      <td style="text-align:center;"> <?php echo date("d-M-Y");?> </td>

      <td>

      <div style="float:left;">
        
        <label class="btn_style">Present
          <input type="radio" <?php if($att=="P"){echo 'checked="checked"';} else if(!isset($_GET['edit'])){echo 'checked="checked"';} ?>  name="<?php echo $WorkAssignListVal['user_id'];?>" value="P" />
          <span class="checkmark"></span>
        </label>

      </div>

      <div style="float:left;margin-left:2%">
        
        <label class="btn_style">Absent
          <input type="radio" <?php if($att=="A"){echo 'checked="checked"';} ?> name="<?php echo $WorkAssignListVal['user_id'];?>" value="A" />
          <span class="checkmark"></span>
        </label>

      </div>

      <div style="float:left;margin-left:2%">
        
        <label class="btn_style">Leave
          <input type="radio" <?php if($att=="L"){echo 'checked="checked"';} ?> name="<?php echo $WorkAssignListVal['user_id'];?>" value="L" />
          <span class="checkmark"></span>
        </label>

      </div>

      <div style="float:left;margin-left:2%">
        
        <label class="btn_style">Short Leave
          <input type="radio" <?php if($att=="SL"){echo 'checked="checked"';} ?> name="<?php echo $WorkAssignListVal['user_id'];?>" value="SL" />
          <span class="checkmark"></span>
        </label>

      </div>

      <div style="float:left;margin-left:2%">
        
        <label class="btn_style">Late
          <input type="radio" <?php if($att=="LA"){echo 'checked="checked"';} ?> name="<?php echo $WorkAssignListVal['user_id'];?>" value="LA" />
          <span class="checkmark"></span>
        </label>

      </div>


       <div style="float:left;margin-left:2%">
        
        <label class="btn_style">Holiday
          <input type="radio" <?php if($att=="H"){echo 'checked="checked"';} ?> name="<?php echo $WorkAssignListVal['user_id'];?>" value="H" />
          <span class="checkmark"></span>
        </label>

      </div>


      </td>
</tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>

</form>
</div>

    <br><br>


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

           
          </div>
        </div>

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

    
  <?php include('RootMe/js_linksscript.php');?>
  <link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />   

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
    <script>
        $(document).ready(function() {
        $('#listofstudents').DataTable();
        } 
        );
    </script>
  </body>
</html>
