<?php include('parent/callMe.php');?>
<?php include('Sessioncheck.php');?>
<?php   
   
$m->where("student_id", $_REQUEST['student_id']);
$m->where("branch_id", $_SESSION['branch']);

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

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

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

$m->where("term_id", $_REQUEST['term_id']);
$terms=$m->get("eduportal_exam_terms");


// 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">
<!-- 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> 


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

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

      table {font-size:18px;}
      body {
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
        background-color: white;
        font: 18pt "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.AgentDirectory;?>img/<?php echo $branch[0]['logo']; ?>" style="height:120px;width:120px;" />

      </div>


      
      <div style="width:60%; float:left;">

         <span style="font-size:30px; text-align:center;font-family:impact;">  <?php echo $branch[0]['Branch_Name'];?> </span>



      </div>


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

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

       <?php }else { ?>   

           <img src="https://image.flaticon.com/icons/png/512/67/67902.png" id="preview" height="110px" class="img-thumbnail" width="110px"  />


       <?php } ?> 
      </div>

     


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

   <strong> <u> Student Result Card of (<?php echo $terms[0]['term_title'];?>) </u>  </strong> </div>

   <br>


   <table width="100%" style="border: 2px solid black; border-radius: 15px; padding:2%;"  >  
   
   
      <tr>  
         <td width="20%" style="text-align:left;"> Student Name:   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;">  <?php echo $WorkAssignListings[0]['first_name'];?></td>

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


      </tr>
   
      <tr>  
         <td width="20%" style="text-align:left;"> Class:   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;"> 
         <?php echo $class[0]['Class_Name'];?> </td>

         <td width="20%" style="text-align:left;"> Section:   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;"><?php echo $section[0]['section_name'];?> </td>


      </tr>

        <td width="20%"  style="text-align:left;">  Adm No:  </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;">  <?php echo $WorkAssignListings[0]['ref_no'];?> </td>
   
  
         <td width="20%"  style="text-align:left;">  Reg No:  </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;">  <?php echo $WorkAssignListings[0]['candidate_roll_no'];?> </td>


      </tr>
   
  
    
   
   </table>

   <br>

<!-- making a div for transparent logo  -->

<div style="<!-- background: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,.5)), url(<?php echo DOMAIN;?>AgentPanel/img/<?php echo $branch[0]['logo']; ?>);background-size:100%; -->">

   <table width="100%" style="font-size:16px;" cellspacing="0" >  
   
   
         <tr>  
         
            <th width="8%"  class="tdalign" style="border-top-left-radius:15px;">S.NO </th>
            <th width="20%"  class="tdalign"> SUBJECTS </th>
            <th width=""  class="tdalign"> TOTAL MARKS</th>
            <th width=""  class="tdalign"> OBTAINED MARKS</th>
            <th width=""  class="tdalign"> Percentage </th>
            <?php if($_GET['grade']==1){?>
            <th width=""  class="tdalign" style="border-top-right-radius:15px;">Grade</th>
            <?php } ?>
                       
         </tr>



<?php 

              // printing all the relevant subjects of each class
                         
          

      $qrr="SELECT csb.*,sb.* FROM eduportal_class_subjects as csb,eduportal_subject_config as sb WHERE csb.session_id=".$_REQUEST['session']." and csb.class_id=".$_REQUEST['class_id']." and csb.section_id=".$_REQUEST['section']." and csb.branch_id=".$_SESSION['branch']." and csb.subject_id=sb.subject_id";

        //echo $qrr;
       
        $teacher_sbj = $m->query($qrr);

         //print_r($teacher_sbj);

        $count=1;
        $status;

              foreach($teacher_sbj as $teacher_sb) {


                $m->where("subject_id", $teacher_sb['subject_id']);
                $subjects = $m->get("eduportal_subject_config"); 

                $m->where("session_id", $_REQUEST['session']);
                $m->where("term_id", $_REQUEST['term_id']);
                $m->where("subject_id", $teacher_sb['subject_id']);
                $m->where("student_id", $_REQUEST['student_id']);
                $m->where("class_id", $WorkAssignListings[0]['class_id']);
                $m->where("section_id", $WorkAssignListings[0]['section_id']);
                $marks = $m->get("eduportal_exam_marksheet"); 

                $total_marks+=$marks[0]['total_marks']+0;
                $total_obt+=$marks[0]['obtained_marks']+0;

                if($marks[0]['obtained_marks'] !=NULL || $marks[0]['obtained_marks'] !="" ){
                
                $percentage = ($marks[0]['obtained_marks']/$marks[0]['total_marks'])*100;
                
                }
           
                 
                
                      if (getGrade($percentage,$m) == "F") {
                        $status = 1;
                     }


                ?>

   
         <tr>  
         
            <td  class="tdalign"> <?php echo $count; $count++; ?> </td>
            <td  style="border:1px solid black; padding-left:3%;text-align:left;"> <?php echo $subjects[0]['subject']; ?> </td>
            <td  class="tdalign"> <?php echo $marks[0]['total_marks']; ?> </td>
            <td  class="tdalign"> <?php echo $marks[0]['obtained_marks']; ?> </td>
            <td  class="tdalign"> 
              <?php 

              if($_GET['percantage']==1){

                  if($marks[0]['obtained_marks'] !=NULL || $marks[0]['obtained_marks'] !="" ){
                              
                        if(is_nan($percentage)!=1){
                            echo number_format($percentage,1)."%";
                          } 
                    } 
              }

                 ?>
            </td> 

              <td class="tdalign"> 

                <?php  if($marks[0]['obtained_marks'] !=NULL || $marks[0]['obtained_marks'] !="" ){
              
                      if($_GET['grade']==1){  echo getGrade($percentage,$m); }
                         
                    }  ?>       
              </td>  
            
    

         </tr>



   <?php } ?>

      <tr>  
         
            <th width="10%"  colspan="2" style="text-align:right;font-weight:bold;border:1px solid black;border-bottom-left-radius:15px;">TOTAL </th>
            <th width="20%"  class="tdalign"><?php echo $total_marks; ?> </th>
            <th width="20%"  class="tdalign"><?php echo ceil($total_obt); ?>
            <th colspan="2" width="20%"  class="tdalign" style="border-bottom-right-radius:15px;">
            <?php if($_GET['percantage']==1){?>
            <?php 
            echo number_format($total_obt/$total_marks*100,1)."%"; 
            }?> </th>

            
      </tr>


   </table>
  
  <br>

   <table width="100%" style="font-size:15px;" cellspacing="0" >  
    <tr>  
         
        <td colspan="" style="text-align:center;border:1px solid black;border-top-left-radius:15px;">
        <?php if($_GET['position']==1){?>
        <b>Position </b> 
        

        <?php echo $_GET['pos']; ?> <?php }?>


        </td>
        
        <td style="text-align:center;border:1px solid black;">
        <?php if($_GET['over_all']==1){?>
        <b>Grade</b> <br>
        <?php $avg=number_format(($total_obt/$total_marks)*100,2);
            $query="SELECT * 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($query);
            if ($status == 1) {
              
           }else {

                  echo $average[0]['grade_title'];
           } } ?>
        </td>
            
        <td style="text-align:center;border:1px solid black;">
        <?php if($_GET['remarks']==1){?>
        <b>Remarks</b><br>
        <?php echo $average[0]['remarks']; }?>
        </td>
      
      <td style="text-align:center;border:1px solid black;border-top-right-radius:15px;">
      <?php if($_GET['issuing_date']==1){?>
      <b>Issuing Date</b> <br> <?php echo date("d-M-Y"); } ?>  </td>
           
            
            
         </tr>


         <tr>  
         
           <?php //echo $avg; ?><!--%--> </th>
            
         </tr>

         <tr>  
         
            <?php //echo $_GET['pos']; ?> </th>
            
         </tr>
     
    <?php if($_GET['teacher_remarks']==1){?> 
    <tr>  
         <td class="tdalign"style="border-bottom-left-radius:15px;"><b>Teacher Remarks</b> </td>
      <td colspan="5" style="text-align:center;border:1px solid black;border-bottom-right-radius:15px;"><?php echo $average[0]['teacher_remarks'];?> </td>
    </tr>
    <?php } ?> 
   </table>
            
</div>

<!-- div closing of transparent logo -->


   <table width="100%" style="font-size:16px;margin-top:13%;">  
   
   
         <tr>  
         <td  style="text-align:center;border-bottom:1px solid black;"> </td>

         <td   >   </td>

         <td  style="text-align:center;border-bottom:1px solid black;color:white;">   </td>
         
         
         </tr>

         <tr>  
         <td width="30%"  style="text-align:center;font-weight:bold;"> Teacher's Signature </td> 
         <td width="30%"  style="text-align:center;">  </td> 
         <td width="30%"  style="text-align:center;font-weight:bold;">  Principal's Signature </td> 

         
         </tr>

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

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


   </table>





    </div>






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




</body>
</html>
