<?php include('parent/callMe.php');?>
<?php include('Sessioncheck.php');?>
<?php   
 

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

    $default;
    
    if($_GET["month"]!=NULL ){
      $default= $_GET["month"];
    }
    else{
      $default= date("m");
    }
  
  // getting branch details

  $branch=getBranch($m);

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


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

$m->where("Month_Id", $_REQUEST['month']);
$monthName=$m->get("eduportal_month_config");

$attendanceMode;

if ($_REQUEST['attendance']=='A') {
	$attendanceMode="Absent";
} elseif ($_REQUEST['attendance']=='L') {
	$attendanceMode="Leave";
} elseif ($_REQUEST['attendance']=='LA') {
	$attendanceMode="Late";
} elseif ($_REQUEST['attendance']=='SL') {
	$attendanceMode="Short Leave";
} elseif ($_REQUEST['attendance']=='P') {
	$attendanceMode="Present";
}


 ?>
<!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 PayRoll Sheet</title>
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<script type="text/javascript">
// window.print();
</script>
<style type="text/css">

tr th {text-align:center;font-size:14px; padding:3px;}
tr td {font-size:14px; padding:3px;}
  
.border{border:1px solid black;}
.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}
.borderTop{
  border-top: none;
}
</style>
</head>
<body style="font-size:12px;padding:1%;">

<div style="text-align:center;font-size:24px;font-weight:bold;"><?php echo $branchName[0]['Branch_Name'];?>

 </div>

<br>

<div style="text-align:center;font-size:24px;font-weight:bold;">Students Class Wise Attendance Sheets

 </div>



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

<div style="width:30%; float:left;font-size:18px; margin-left:10px; "> <b> Month:</b> <?php echo $monthName[0]['Month_Name'];?> </div>

<div style="width:30%; float:left;font-size:18px; margin-left:10px; "> <b> Attendance Mode:</b> <?php echo $attendanceMode;?> </div>


<br><br>
   
    <table  style="width:100%;border-collapse: collapse;margin-top: 20px;">
          
          <thead>
            <tr>
                
      <th width="10%" style="background-color:lightgray;">Classes</th>
        
        
       <th width="90%">
        
      <table border="1" width="100%"  class="responsive" style="border-collapse: collapse;margin-top: -3px;">
              <?php 

          $days=date("t");
          for($i=1;$i<=31;$i++){     

          ?>

           <th  width="2%" style="padding:4px;text-align: center;background-color: lightgray;"> <?php  echo $i;?> </th>

          <?php } ?>
                
      </table>
      
      </th>
    

            </tr>
      
        </thead>
        <tbody>
     
     <?php
     
  $branch=$_SESSION['branch'];
  $WorkAssignListings = $m->query("SELECT sec.*, cls.* FROM edu_adm_section_detail as sec LEFT JOIN edu_class_config as cls ON sec.class_id = cls.class_id where cls.class_id!='' and cls.branch_id='$branch' and sec.branch_id='$branch' ORDER BY cls.class_id asc"); 
    
      foreach($WorkAssignListings as $class) { ?>

<tr>        
     
    <?php $monthss = date('F', mktime(0,0,0,$mm, 1, date('Y'))); ?>

      <td style="background-color: lightgray;border: 1px solid black;"><?php echo $class['Class_Name']." - ".$class['section_name'];?></td>

      <td>

    <div style="">


    <table border="1" width="100%"  class="responsive" style="border-collapse: collapse;">  

  <tr>  
<?php 
$monthID =$_GET['month'];
$days=date("t");
for($i=1;$i<$days+1;$i++){

    $date=date("Y")."-".str_pad($monthID, 2, '0', STR_PAD_LEFT)."-".str_pad($i, 2, '0', STR_PAD_LEFT);   
  
   $branch_id=$_SESSION['branch'];
   $classID=$class['class_id'];
   $sectionID=$class['section_id'];
   //$qr="SELECT count(*) as absents FROM eduportal_attendance_detail WHERE date='$date' and attendance='A' and class_id='$classID' and section_id='$sectionID' and branch_id='$branch_id' ";
   //print_r($qr);
   //$att = $m->query($qr);

   

   //echo $qr;
?>

 <th  width="2%" style="padding:4px;text-align: center;"> <?php  if($att[0]['absents']!=NULL){echo $att[0]['absents'];}else {echo "--";};?> </th>

<?php } ?>

  </tr>

</table>

  </div>

   

      </td>
</tr>

        <?php } ?>



           
            
           
        </tbody>
        
    </table><br>
     
      
      

</body>
</html>
