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

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

  $branch=getBranch($m);

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

$m->where("session_id", $_REQUEST['session']);
$session=$m->get("edu_session_config");

$yr=explode("-", $session[0]['session_year']);

 ?>
<!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>Attendance History</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:4px;}
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="float: left; width: 100%;">


<div class="profile_img" style="width: 20%;float: left;" >
        <div id="crop-avatar">
          <!-- Current avatar -->
           <?php if($student[0]['image']!=NULL){ ?>

      <img src="<?php echo DOMAIN;?>Production/students_pics/<?php echo $student[0]['image'];?>" id="preview" class="img-thumbnail" style="width:100px;height:100px;"   />

   <?php }else { ?>   

       <img src="<?php echo DOMAIN;?>Production/images/upload.png" id="preview" height="100px" class="img-thumbnail" width="100px"  />


   <?php } ?>
    </div>
  </div>

  <div style="width:60%;font-size:24px;text-align:center;float: left;"><span style="font-size:30px; text-align:center;font-family:times new roman;font-weight: bolder;"><br>  <?php echo $branch[0]['Branch_Name'];?> </span>

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

  <div style="width:20%;font-size:13px;text-align:center;float:left;height:80px;">

         <img src="<?php echo DOMAIN;?>Production/img/<?php echo $branch[0]['logo']; ?>" style="height:100px;width:100px;" />

  </div>

</div>




<div style="font-size: 16px;text-align: center;font-weight: bold;">

 <u> Student Attendance History of Year (<?php echo $yr[0];?>) </u>

</div>



<div style="font-size: 16px;text-align: left;margin-top:10px;">


	<div style="width:35%;float: left;">Class/Sec:  <?php echo getClassName($m,$student[0]['class_id'])." / ".getSectionName($m,$student[0]['section_id']);?>
		
	</div>

	
	<div style="width: 25%;float: left;">Name:  <?php echo $student[0]['first_name'];?></div>
	<div style="width: 25%;float: left;">Father:  <?php echo $student[0]['last_name'];?></div>
	<div style="width: 15%;float: left;">Roll/Adm: No  
		<?php echo $student[0]['candidate_roll_no']." / ".$student[0]['ref_no'];?></div>

		

</div>

<br>

   
<table  style="width:100%;border-collapse: collapse;margin-top:10px;">
  
  <thead>
    <tr>
        
		<th width="7%"  style="border: 1px solid black;padding:0px;">Month</th>


		<th  width="93%"  style="padding:0px;">

    
      <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 style="width:16px; padding:4px;text-align: center;background-color: lightgray;"> <?php  echo $i;?> </th>

          <?php } ?>


                
      </table>
      
      </th>
    

            </tr>
      
        </thead>
        <tbody>
     
     <?php
     
     $count=1; 
    
      for ($mm=1; $mm<=12; $mm++) { ?>

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

      <td  width="7%"  style="border: 1px solid black;"><?php echo $monthss;?></td>

      <td  width="93%"  style="padding:0px;">
 


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

  <tr>  
<?php

$monthID =date('m', strtotime($monthss));
$days=date("t");
/*for($i=1;$i<$days+1;$i++){*/
for($i=1;$i<=31;$i++){ 
    $date=$yr[0]."-".str_pad($monthID, 2, '0', STR_PAD_LEFT)."-".str_pad($i, 2, '0', STR_PAD_LEFT);
   
   $id=$_REQUEST['student'];  
   $qr="select * from eduportal_attendance_detail where date='$date' and student_id='$id' and branch_Id=".$_SESSION['branch'];
   $att = $m->query($qr);

   //echo $qr;
?>

 <th style="width:16px;text-align: center;">

 <?php  if($att[0]['attendance']!=NULL){echo $att[0]['attendance']; }else {echo "--";};?> </th>

<?php } ?>

  </tr>

</table>


   

      </td>
</tr>

        <?php } ?>



           
            
           
        </tbody>
        
    </table><br>



 <div style="font-size: 16px;text-align: center;font-weight: bold;">

 Summarize Attendance Report of Session (<?php echo $session[0]['session_year'];?>)

</div>




    <table  style="width:100%;border-collapse: collapse;margin-top: 20px;" border="1">
          
          <thead>
            <tr>
                
			    <th width="15%" style="background-color:lightgray;">Month</th>
			    
			    <th width="15%" style="background-color:lightgray;">Presents</th>
			    <th width="15%" style="background-color:lightgray;">Absentes</th>
			    <th width="15%" style="background-color:lightgray;">Leaves</th>
			    <th width="15%" style="background-color:lightgray;">Short Leaves</th>
			    <th width="15%" style="background-color:lightgray;">Late Arrivals</th>
			    <!-- <th width="15%" style="background-color:lightgray;">Attendance % </th> -->

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

  for ($mm=1; $mm<=12; $mm++) {

   $date=$yr[0]."-".str_pad($mm, 2, '0', STR_PAD_LEFT)."-";
   
   $id=$_REQUEST['student'];  
   
   // GETTING RECORD OF TOTAL PRESENTS
	$qr="select COUNT(*) as presents from eduportal_attendance_detail where  student_id='".$id."' and
	 branch_Id='".$_SESSION['branch']."' and date like '".$date."%' and attendance='P'";
	$presents = $m->query($qr);


// GETTING RECORD OF TOTAL ABSENTS
	$qr="select COUNT(*) as absents from eduportal_attendance_detail where  student_id='".$id."' and
	 branch_Id='".$_SESSION['branch']."' and date like '".$date."%' and attendance='A'";
	$absents = $m->query($qr);


// GETTING RECORD OF TOTAL LEAVES
	$qr="select COUNT(*) as leaves from eduportal_attendance_detail where  student_id='".$id."' and
	 branch_Id='".$_SESSION['branch']."' and date like '".$date."%' and attendance='L'";
	$leaves = $m->query($qr);

// GETTING RECORD OF TOTAL SHORT LEAVES
	$qr="select COUNT(*) as shleaves from eduportal_attendance_detail where  student_id='".$id."' and
	 branch_Id='".$_SESSION['branch']."' and date like '".$date."%' and attendance='SL'";
	$shleaves = $m->query($qr);


// GETTING RECORD OF TOTAL LATE ARRIVALS
	$qr="select COUNT(*) as LA from eduportal_attendance_detail where  student_id='".$id."' and
	 branch_Id='".$_SESSION['branch']."' and date like '".$date."%' and attendance='LA'";
	$LA = $m->query($qr);

       ?>

	<tr>        

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

      <td style="padding-left: 1%;"><?php echo $monthss;?></td>

      <td style="text-align: center;"> <?php if($presents[0]['presents']!=0  ){ echo $presents[0]['presents']; }?> </td>
      <td style="text-align: center;"> <?php if($absents[0]['absents']!=0 ){ echo $absents[0]['absents']; }?> </td>
      <td style="text-align: center;"> <?php if($leaves[0]['leaves']!=0){ echo $leaves[0]['leaves']; }?> </td>
      <td style="text-align: center;"> <?php if($shleaves[0]['shleaves']!=0){ echo $shleaves[0]['shleaves']; }?> </td>
      <td style="text-align: center;"> <?php if($LA[0]['LA']!=0){ echo $LA[0]['LA']; }?> </td>
      <!-- <td style="text-align: center;"> </td> -->

	   

</tr>

        <?php } ?>



           
            
           
        </tbody>
        
    </table>
     
      
      

</body>
</html>
