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


       $m->where("student_id", $_REQUEST['std']);
       $m->where("branch_id", $_SESSION['branch']);


       $WorkAssignListings = $m->get("edu_student_details");

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

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

        $m->where("session_id", $WorkAssignListings[0]['session_id']);
        $session=$m->get("edu_session_config");
 
 
       // getting branch details

        $m->where("branch_id", $_SESSION['branch']);
        $branch=$m->get("edu_branch_config");
   
     $session1;
      if($_REQUEST['session']!=NULL){

       $session1=$_REQUEST['session'];
     }else {
       $session1=$_SESSION['current_session'];
     }
    $default;
    
    if($_GET["month"]!=NULL ){
      $default= $_GET["month"];
    }
    else{
      $default= date("m");
    }
  

        $m->where("Month_Id", $default);
        $month_name=$m->get("eduportal_month_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">
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<title> Student Report Card</title>
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />

<script type="text/javascript">
   //window.print();
</script>

<style>

.tdStyle{border-bottom:1px solid lightgray;}
.thStyle{background-color:white;color:;}


.section{width:100%; height:1400px;float:left;border: 1px solid black;margin:0 auto;padding:2%;margin-left:1%;}
 
 tr td {
    
    padding:0.7%;
 }

  tr th {
    
    padding:2%;
 }
.tdalign{text-align:center;border:1px solid black;}
  

</style>

  <style>

      body {
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
        background-color: white;
        font: 12pt "Tahoma";
    }
    * {
        box-sizing: border-box;
        -moz-box-sizing: border-box;
    }
    .page {
        width: 297mm;
        height:auto;        
        padding: 20mm;
        margin: 10mm auto;
        /*border: 1px #D3D3D3 solid;*/
        border-radius: 5px;
        background: white;
        /*box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);*/
    }
    .subpage {
        width: 257mm;
        height:auto;
        
    }
    
    @page {
        size: A4 portrait; 
        margin: 0;
    }
    @media print {
        html, body {
            width:297mm;
            height:auto;        
        }
        .page {
            margin: 0;
            border: initial;
            border-radius: initial;
            width: initial;
            min-height: initial;
            box-shadow: initial;
            background: initial;
            page-break-after: blue;
        }
    }


  </style>


</head>
<body>



  <div class="book">
    <div class="page">
        <div class="subpage">






 <!-- Vouchere Fist -->
<div class="section">
   

   <div style="width:100%; text-align:center; height:80px;float:left;">




      <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 style="width:60%; float:left;">

         <span style="font-size:22px; text-align:center;font-family:impact;">  <?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="font-size:15px;text-align:center;float:right;width:120px;height:120px;">

           <?php if($WorkAssignListings[0]['image']!=NULL){ ?>
      
      <img src="<?php echo DOMAIN;?>Production/students_pics/<?php echo $WorkAssignListings[0]['image'];?>" id="preview" class="img-thumbnail" style="width:120px;height:120px;"   />

       <?php }else { ?>   

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


       <?php } ?> 

      </div>

     


            
  
   <div style="font-size:20px; text-align:center;margin-top:10%;">  

   <strong> <u> Student Performance Report </u>  </strong> </div>

   <br><br>


   <table width="100%"  style="font-size:14px;" >  
   
   
      <tr>  
         <td width="15%"> First Name   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;">  <?php echo $WorkAssignListings[0]['first_name'];?></td>

         <td width="15%"> Father Name   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;">  <?php echo $WorkAssignListings[0]['last_name'];?></td>


      </tr>
   
      <tr>  
         <td width="15%"> Class/Section   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;"> 
         <?php echo $class[0]['Class_Name'];?> (<?php echo $section[0]['section_name'];?>) </td>

         <td width="15%"> Roll No   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;">  <?php echo $WorkAssignListings[0]['candidate_roll_no'];?></td>


      </tr>


       <tr>  
         <td width="15%"> Session   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;"> 
         <?php echo $session[0]['session_year'];?></td>

         <td width="15%"> Printed   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;">   <?php echo date("d-M-Y");?> </td>


      </tr>

    
 
   
   </table>

      

   <div style="width:100%;font-size:15px; text-align:center; height:25px; float:left;">

     <h3>  Attendance Report <!--of (<?php echo $month_name[0]['Month_Name']; ?>)-->  </h3>

   </div>
<br>

   <?php
for($mm=date('m')-1; $mm<=date('m'); ++$mm){
    
?>
    <table  border=""  width="100%"  class="responsive" style="margin-top:2%;font-size:12px; border-collapse: collapse;">  


    <tr>  
<div   style="float:left;font-weight: bold;"><?php echo date('F', mktime(0, 0, 0, $mm, 1));?></div>
<?php 
 
$days=date('t', mktime(0, 0, 0, $default, 1, date("Y")));
for($i=1;$i<$days+1;$i++){     

?>

 <th class="thStyle" style="padding:3px 5px;"> <?php echo $i;?>  </th>

<?php } ?>

  </tr>


    <tr>  
<?php 

$days=date('t', mktime(0, 0, 0, $default, 1, date("Y")));
for($i=1;$i<$days+1;$i++){

   $date=date("Y")."-".str_pad($mm, 2, '0', STR_PAD_LEFT)."-".str_pad($i, 2, '0', STR_PAD_LEFT);
   $id=$_GET['std'];  
   $qr="select * from eduportal_attendance_detail where date='$date' and student_id='$id' and branch_Id=".$_SESSION['branch'];
   $att = $m->query($qr);
?>

 <th class="" style="padding:3px 5px;"> <?php  if($att[0]['attendance']!=NULL){echo $att[0]['attendance'];}else {echo "-";};?> </th>

<?php } 

}
?>

  </tr>



</table>

<br/>

   <div style="width:100%;font-size:15px; text-align:center; height:25px; float:left;">

     <strong>  MARKS DETAILS OF ALL TESTS & TERMS  </strong>

   </div>



      <table width="100%" style="font-size:14px;">



          <tr>
            
            <th class="thStyle" width="25%"> Test/Term   </th>
            <th class="thStyle" width="15%"> Total Marks </th>
            <th class="thStyle" width="15%"> Obt Marks   </th>
            <th class="thStyle" width="10%"> %           </th>
            <th class="thStyle" width="10%"> Grade       </th>
            <th class="thStyle" width="10%">  SMS  </th>
            <!-- <th class="thStyle" width="10%"> Class Position </th> -->
              
          </tr>

     <?php 

     $sql = "select * from  eduportal_exam_terms where branch_id=".$_SESSION['branch']." and session_id='$session1' order by term_title asc";

     $terms = $m->query($sql);
     $count=1;
      foreach($terms as $term)
      { 

       $b=$_SESSION['branch'];
       $trm=$term['term_id'];
       
       $query="select SUM(obtained_marks)as obt,SUM(total_marks) as tm,sms_status from eduportal_exam_marksheet where branch_id='$b' and session_id='$session1' AND term_id='$trm' AND student_id=".$_GET['std'];
       
       $marks = $m->query($query);

       

       $avg=0+intVal($marks[0]['obt'])/intVal($marks[0]['tm'])*100;
      
        if($marks[0]['tm']==NULL){
         continue;
        }
  

      $gqr="SELECT grade_id,grade_title FROM eduportal_exam_school_grades WHERE percantage_start_range <=".round($avg)." and percantage_end_range >=".round($avg)." and branch_id=".$_SESSION['branch'];
  
        $average =  $m->query($gqr); 
         
          
        
      ?>
          <tr>
          
          <td class="tdStyle" width=""> <?php echo $term['term_title'];?>   </td>
          <td class="tdStyle" width=""> <?php  if($marks[0]['tm']!=NULL){echo $marks[0]['tm'];}else {echo "--";};?> </td>
          <td class="tdStyle" width=""> <?php  if($marks[0]['obt']!=NULL){echo $marks[0]['obt'];}else {echo "--";};?>   </td>
          <td class="tdStyle" width=""> <?php  if($avg!="NULL"){echo number_format($avg,1)."%";}else {echo "--";};?>            </td>
          <td class="tdStyle" width=""><?php  if($average[0]['grade_title']!=NULL){echo $average[0]['grade_title'];}else {echo "--";};?></td>
          <td class="tdStyle" width=""> <?php  if($marks[0]['sms_status']==1){ ?> 
          
          <a data-toggle="modal" style="padding: 0px 5px; font-size:14px;" class="btn btn-success">

          SENT <i class="fa fa-check" aria-hidden="true"></i>

          </a>
          
            <?php }else {echo "NOT";};?>  </td>
          <!-- <td class="tdStyle" width=""> 4th </td> -->
          
          </tr>



    <?php }  ?>                       




  </table>


   <table width="100%" style="position:fixed;bottom: 20px;width: 71%;color: black;text-align: center;">  
   
   

         <tr>  
            
            <td width="30%" colspan="3"  style="text-align:center;"> 

            <br>
            
               <span style="font-size:10px;"> Software Developed By: Aqib Majeed (Software Engineer) 03016138728  </span>
            
            </td> 
         
         </tr>


   </table>


    </div>



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



</body>
</html>
