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

  $date=date("Y-m");
  $branch_id=$_SESSION['branch'];

      
$qr="SELECT count(*) as absents,emp_id FROM eduportal_hrm_emp_attendance WHERE attendance='A' and date like '$date%' and branch_id='$branch_id' GROUP BY emp_id order by absents desc limit 0,50";
  //echo $qr;
  $WorkAssignListings = $m->query($qr);

   // getting branch details

  $m->where("branch_id", $_SESSION['branch']);
  $branch=$m->get("edu_branch_config");
  
     ?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Print Most Absent Staff</title>
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<script type="text/javascript">
 // window.print();
</script>
<style type="text/css">



.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}

tr th {border:1px solid black;text-align:center;background-color:lightgray;font-size:14px;}
tr td {border-bottom:1px solid black;border-left:1px solid black;font-size:14px;padding:3px;}
  

@media print {
    #Header, #Footer { display: none !important; }
}
@media screen
   {
      p.bodyText {font-family:verdana, arial, sans-serif;}
   }

   @media print
   {
      p.bodyText {font-family:georgia, times, serif;}
   }
   @media screen, print
   {
      p.bodyText {font-size:10pt}
   }
   @media print {
  a[href]:after {
    content: none !important;
  }
}
</style>
</head>
<body>



<div style="text-align:center;font-size:25px;font-weight:bold;margin:0 auto;"><?php echo $branch[0]['Branch_Name'];?> </div> <br>


<div style="text-align:center;font-size:14px;"><?php echo $branch[0]['Branch_Location']." Cell: ".$branch[0]['Owner_no'];?> </div>

<hr style="width:100%;">

<div style="width:33%; float:left; "> <b> Date:</b> <?php echo date("M-Y");?> </div>

<div style="width:33%; float:left; "> <b> Total Staff:</b> <?php echo count($WorkAssignListings);?> </div>



<br>


  <table width="100%" class="table"  cellspacing="0" >
  
    
  <thead>
    <tr>
      <th width="5%" class=""><strong>S.No</strong></th>
      <th width="15%" class=" alignment"><strong>Name</strong></th> 
      <th width="5%" ><strong>Absents</strong></th>
      <th width="30%" class=" alignment"><strong>Absents Dates</strong></th>
      <th width="5%"   style="border-right:1px solid black;" ><strong>Cell No</strong></th>
      
    </tr>
   
    </thead>
       <tbody>
    
<?php 

$count=1;
foreach($WorkAssignListings as $WorkAssignListVal)
{ 
 
      $date=date("Y-m");
       
       $m->where("branch_id", $_SESSION['branch']);
       $m->where("user_id", $WorkAssignListVal['emp_id']);
       $student = $m->get("edu_user_config");

       if($student[0]['user_fname']==NULL || $student[0]['user_fname']==""){continue;}

        $m->where("class_id", $student[0]['class_id']);
        $class=$m->get("edu_class_config");

        $m->where("section_id", $student[0]['section_id']);
        $section=$m->get("edu_adm_section_detail");

        // gettings absents dates 

        $qr1="SELECT * FROM eduportal_hrm_emp_attendance WHERE attendance='A' and date like '$date%' and branch_id='$branch_id' and emp_id=".$WorkAssignListVal['emp_id'];
       // echo $qr1;
        $dates = $m->query($qr1);
       // echo $qr;
    
//print_r($dates);
?>
    <tr>
      <td  class="center"><?php echo  $count; ?> </td>
      <td  class="alignment"><?php echo  $student[0]['user_fname']; ?></td>    
      
      <td  class="center"><?php echo $WorkAssignListVal['absents']; ?></td>
      <td  class="alignment">
<?php 

  foreach($dates as $date){ echo date("d-M",strtotime($date['date'])).","; }

?>
      </td>
      <td  class="center"  style="border-right:1px solid black;"> <?php echo  $student[0]['cell_no']; ?></td>
      
    </tr>
   
<?php $count++; 
    }
?>

      </tbody>

  </table>

</body>
</html>
