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



 $branch=$_SESSION['branch'];
 $m->where("status", '0');
 $m->where("branch_id", $_SESSION['branch']);
 $m->where("class_id", $_REQUEST['class_id']);
 $m->where("section_id", $_REQUEST['section']); 
 $m->where("session_id", $_SESSION['current_session']);

 if ($_REQUEST['orderBy']=="Name") {
    $m->orderBy("first_name","asc");    
 }

 if ($_REQUEST['orderBy']=="RollNoWise") {
    $m->orderBy("candidate_roll_no","asc");
     }

 if ($_REQUEST['orderBy']=="RegNoWise") {   
    $m->orderBy("ref_no","asc");
 }

 $param = array('student_id','first_name','last_name','cell_no','candidate_roll_no','ref_no');

 $WorkAssignListings = $m->get("edu_student_details",null,$param);
 
//print_r($WorkAssignListings);

    $default;

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

 $m->where("Month_Id", $default);
 $monthName = $m->get("eduportal_month_config");

// getting branch details

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

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




 ?>
<!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 {border-top:1px solid gray;border-left:1px solid black;border-bottom:1px solid black;text-align:center;font-size:10px; padding:3px;}
tr td {border-bottom:1px solid gray;border-left:1px solid black;font-size:10px; 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;">



<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 Attendance Sheets

 </div>



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


<br><br>
   
    <table style="width:100%">
          
      <thead>
        <tr>
        <th width="2%" style="background-color:lightgray;">Sr</th> 
        <th width="8%" style="background-color:lightgray;">Name</th>
        <th width="8%" style="background-color:lightgray;">F.Name</th>
        <?php if ($_REQUEST['display_cell']=="YES") { ?>
          <th width="5%" style="background-color:lightgray;">Cell#</th>
        <?php } ?>
        
        <th width="5%" style="background-color:lightgray;">Roll.No</th>
        <th width="5%" style="background-color:lightgray;">Reg.No</th>
        
        
       <th width="85%">
        
      <table border="1" width="100%"  class="responsive" style="border:none;border-collapse: collapse;">
              <?php 
          $month=date("m");
          //$days=date("t");
          $days=cal_days_in_month(CAL_GREGORIAN, $default, $_GET["year"]);
          for($i=1;$i<$days+1;$i++){ 
         $day=  date( 'l', strtotime( $month . '/' . $i ) );   

          ?>

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

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

            </tr>
      
        </thead>
        <tbody>
     
     <?php
     
     $count=1; 

    foreach($WorkAssignListings as $WorkAssignListVal)
      { 
      
      ?>
<tr>
  
  <td style="text-align:center;padding: 0px;"><?php echo $count++;?></td>

  <td>
    
    <?php echo $WorkAssignListVal['first_name'].' '. $WorkAssignListVal['user_lname'];?>
    <input name="attendance[]" id="attendance[]" type="hidden" value="<?php echo $WorkAssignListVal['student_id'];?>">
                             
  </td>

 <td style="text-align:left;">
    
    <?php echo $WorkAssignListVal['last_name']; ?>
  </td>
 <?php if ($_REQUEST['display_cell']=="YES") { ?>
  <td style="text-align:left;">
    
    <?php echo $WorkAssignListVal['cell_no']; ?>
  </td>
<?php } ?>
  <td style="text-align:center;">
    
    <?php echo $WorkAssignListVal['candidate_roll_no']; ?>
  </td>

  <td style="text-align:center;">
    
    <?php echo $WorkAssignListVal['ref_no']; ?>
  </td>
      

      <td>

    <div style="">


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

    <tr>  
<?php 

//$days=date("t");
$days=cal_days_in_month(CAL_GREGORIAN, $default, $_GET["year"]);
for($i=1;$i<$days+1;$i++){

   $date=$_GET["year"]."-".str_pad($default, 2, '0', STR_PAD_LEFT)."-".str_pad($i, 2, '0', STR_PAD_LEFT);
 //echo $date;  
   $id=$WorkAssignListVal['student_id'];  
   $qr="select attendance from eduportal_attendance_detail where date='$date' and student_id='$id' and branch_Id=".$_SESSION['branch'];
   $att = $m->query($qr);
?>

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

<?php } ?>

  </tr>

</table>

  </div>

   

      </td>
</tr>

        <?php } ?>



           
            
           
        </tbody>
        
    </table><br>
     
      
      

</body>
</html>
