<?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");






// this code is to get the old class name & section for the student 

  $m->where("session_id", $_REQUEST['session']);
  $m->where("term_id", $_REQUEST['term_id']);
  $m->where("student_id", $_REQUEST['student_id']);
  $old_data = $m->get("eduportal_exam_marksheet"); 



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

  $m->where("section_id", $old_data[0]['section_id']);
  $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");

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



?>
 <!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%;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:78%; float:left;text-align:center;">

         <span style="font-size:25px;font-family: Times New Roman;font-weight: bold;">  <?php echo $branch[0]['Branch_Name'];?> </span>
         <p style="text-align:center;margin-top: 2px;"><?php echo $branch[0]['Branch_Location'];?></p>
         <p style="text-align:center;margin-top: -19px;"><?php echo $branch[0]['branch_contact'];?></p>


      </div>
  </div>

      
     


            
  
 

   <br><br><br><br>
  
   <hr style="border:2px solid black;margin-bottom: 1px;">
        <div style="background: lightgray; border-bottom:2px solid black;">
            <div style="width:100%;float: left;background: lightgray; padding: 8px;"><b style="font-size:17px;">RESULT CARD</b> <b>(<?php echo $terms[0]['term_title'];?>)</b></div> 

        </div>   
        <br>   
   <hr style="border:2px solid black;margin-top: 16px;">

   <div>

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

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

         <td width="15%" style="text-align:left;"> Father:   </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%" style="text-align:left;"> Class/Sec:   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;"> 
         <?php echo $class[0]['Class_Name']." / ".getSectionName($m,$WorkAssignListings[0]['section_id']);?> </td>

         <td width="15%" style="text-align:left;"> Session:   </td>
          <td width="35%" style="border-bottom: 1px solid black;text-align:center;">
            <?php echo getSessionName($m,$WorkAssignListings[0]['session_id']);?> </td>



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

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


      </tr>
   
  
    
   
   </table>

    </div>


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

      <?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="margin-top: -41px;width: 125px;height: 130px; border: 2px solid black;"   />

       <?php }else { ?>   

           <img src="https://image.flaticon.com/icons/png/512/67/67902.png" id="preview"  class="img-thumbnail" style="margin-top: -41px;width: 125px;height: 130px;"  />


       <?php } ?>

    </div>
   </div>

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

<div style="">

   <table width="100%" style="font-size:16px;margin-top: 170px;" 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>
            <th width=""  class="tdalign" style="border-top-right-radius:15px;">Grade</th>
            
                       
         </tr>



<?php 

              // printing all the relevant subjects of each class
     
 
          if($_REQUEST['session']!=NULL){
                  $session1=$_REQUEST['session'];
                  }else { $session1=$_SESSION['current_session']; }

          $m->where("session_id", $session1);
          $m->where("term_id", $_REQUEST['term_id']);
          $m->where("student_id", $_REQUEST['student_id']);
          $teacher_sbj = $m->get("eduportal_exam_marksheet");

          //echo $qrr;


       $count=1;
        

      $status;

              foreach($teacher_sbj as $Termmarks) {


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

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

                if($Termmarks['obtained_marks'] !=NULL || $Termmarks['obtained_marks'] !="" ){
                
                $percentage = ($Termmarks['obtained_marks']/$Termmarks['total_marks'])*100;
                
                }
           
            //$avg=number_format(($total_obt/$total_marks)*100,2);

           
            $grade=getGrade($percentage,$m);

            if ($grade == "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 $Termmarks['total_marks']; ?> </td>
            <td  class="tdalign"> <?php echo $Termmarks['obtained_marks']; ?> </td>
            <td  class="tdalign"> 
               
              <?php 
              if($Termmarks['obtained_marks'] !=NULL || $Termmarks['obtained_marks'] !="" ){
              echo number_format($percentage,1)."%";}  ?>
            </td> 

              <td class="tdalign"> 

                <?php  if($Termmarks['obtained_marks'] !=NULL || $Termmarks['obtained_marks'] !="" ){
              
                      echo $grade; 

                    }  ?>       
              </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 $total_obt; ?>
            <th colspan="2" width="20%"  class="tdalign" style="border-bottom-right-radius:15px;">
           
            <?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;">
        
        <!-- <b>Position </b>
        <?php echo $_GET['pos']; ?>  -->
        </td> 
        
        <td style="text-align:center;border:1px solid black;">
               <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);
        	
        	//print_r($average);

                  echo $average[0]['grade_title'];
           ?>
        </td>
            
        <td style="text-align:center;border:1px solid black;">
   
        <b>Remarks</b><br>
        <?php echo $average[0]['remarks']; ?>
        </td>
      
      <td style="text-align:center;border:1px solid black;border-top-right-radius:15px;">
   
      <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>
     
 
    <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>
  
   </table>
						
</div>

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

<!-- <table  class="table table-striped table-bordered"style="width:100%;float: left;">
                      <thead>
                        <tr>
                          <th colspan="5">Absent/Leaves Detail</th>
                        </tr>
                        <tr>
                          <th width="1%">S.No</th>
                          <th width="24%">Date</th>
                          <th width="6%">Attendance</th>
                          <th width="32%">Leave </th>
                          <th width="32%">Short Leave</th>
                          
                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;
$date= date("Y-m-d");

$dateAtt=date('Y-m');
$branchID=$_SESSION['branch'];
$STDid=$_REQUEST['student_id'];

$qr="SELECT * FROM eduportal_attendance_detail WHERE student_id='$STDid' and attendance!='P' and branch_Id='$branchID' and date like '$dateAtt-%'"; 
//print_r($qr);
$Datas=$m->query($qr);

foreach($Datas as $Data){

  $m->where("branch_id", $_SESSION['branch']);
  $m->where("student_id", $_REQUEST['student_id']);
  $m->where("attendance_id", $Data['attendance_id']);
  $ShortLeave=$m->get("eduportal_students_leave_reasons");

  $m->where("subcategory_id", $category['subcategory_id']);
  $sbctgry=$m->get("eduportal_expanse_subcategory");

  $m->where("Month_Id", $category['month_id']);
  $months=$m->get("eduportal_month_config");


?>
                        <tr>
                          <td style="text-align:center;"><?php echo $count; $count++;?></td>
                         

                          <td><?php echo date("d-M-Y",strtotime($Data['date']));?></td>
                          <td><?php echo $Data['attendance'];?></td>
                          <td><?php echo $Data['leave_reasons'];?></td>
                          <td style="border-right: 1px solid lightgray;"><?php echo $ShortLeave[0]['shortleave_reason'];?></td>
                         
                                                                           

                         

                        </tr>
<?php } ?>
                      

                      </tbody>
                    </table> -->

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

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

         <?php } ?>

         </td>

         <td   >   </td>

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

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

         <?php } ?>

        </td>
         
         
         </tr>

         <tr>  
         <?php if ($signatures[0]['signature_type']=='Teacher') { ?>

           <td width="30%"  style="text-align:center;font-weight:bold;"> Teacher's Signature </td> 
         <?php } else { ?>

          <td width="30%"  style="text-align:center;font-weight:bold;"> Exam Controller Signature </td>

         <?php } ?> 
         <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>
