<?php
session_start();
$ex=$_SESSION['eexam'];
$pid=$_SESSION['ppupil'];

include('../include/config.php');

    $date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
    $timenow=$date->format('Y-m-d H:i:s');
    $timenow2=$date->format('Y-m-d');
    $month=$date->format('M');

    $y=$yr;
    if($y=='' || $y==null)
    {$yr=$date->format('Y');}
    else
    {
     $yr=$y;
    }
    
    if($tr=='' || $tr==null)
    {
        $tr='Term One'; 
    }else
    {
    }
    
    if($pid=='' || $pid==null)
    {
      $pid='0';
    }else
    {
    }
    
    $result = mysqli_query($con,"SELECT * from pupils where count='$pid'");
    while($row = $result->fetch_assoc()) 
    {
    $nam=$row["Names"];
    $admno=$row["AdmNo"];
    $claz=$row["Claz"];
    }
    
    $result = mysqli_query($con,"SELECT * from Exam where id='$ex'");
    while($row = $result->fetch_assoc()) 
    {
    $tit=strtoupper($row["Title"]);
    $pe=$row["Period"];
    $year=$row["Year"];
    }
    
    //$query = mysqli_query($con,"SELECT Classteachers.Teacher as tea, Staffs.Name as tnam from Classteachers left join Staffs ON Staffs.id=Classteachers.Teacher where Classteachers.Clazzz='$claz'");
   // while($row = $query->fetch_assoc()) 
    //{
    //$teaname=$row["tnam"];
    //}

    
    $result = mysqli_query($con,"SELECT * FROM pupils where Claz='$claz' AND  Status='Active'");
    $num_rows1 = mysqli_num_rows($result);
    {
    $allpupils=htmlentities($num_rows1); 
    }
   
    $sql = "select * from Fees2 where count='$autono' AND pid='$pid'";
    $result = $con->query($sql);
    if ($result->num_rows > 0) 
    {
   
    }else
    {
     $feebala='0';
    }

  //CBC

$RM='';
$RE='';
$RK='';
$RI='';  
$RC='';

$RMP='';
$REP='';
$RKP='';
$RIP='';  
$RCP='';


$ex=$_SESSION['eexam'];
$pid=$_SESSION['ppupil'];

$query=mysqli_query($con,"select CBC2.*,pupils.Names as nm from CBC2 left join pupils ON pupils.count=CBC2.PID where CBC2.EID='$ex' AND CBC2.PID='$pid'");
$cnt=1;
$pos=1;
$lastscore='';
while($row=mysqli_fetch_array($query))
{
$ma=$row["Math"]; 
$eng=$row["Eng"]; 
$kis=$row["Kis"]; 
$in=$row["ST"]; 
$cre=$row["CRE"]; 
$cra=$row["CA"]; 
$ss=$row["SS"];
$an=$row["AN"];

$uma=$row["MA1"]; 
$ueng=$row["EN1"]; 
$ukis=$row["KS1"]; 
$uin=$row["ST1"]; 
$ucre=$row["CR1"]; 
$ucra=$row["CA1"]; 
$uss=$row["SS1"];
$uan=$row["AN1"];
$grade=$row["Grad"];



$trubb=$row["TRub"];
$tmks=$row["TMks"];
}

$resultt = mysqli_query($con,"SELECT * from examsetting where Grad='$grade' AND examid='$ex'");
while($row = $resultt->fetch_assoc()) 
{
$sma=$row["MA"];
$seng=$row["EN"]; 
$skis=$row["KS"]; 
$sin=$row["ST"]; 
$scre=$row["CRE"]; 
$scra=$row["CA"]; 
$sss=$row["SS"];
$san=$row["AN"];
$tt=$row["TT"];
}

$sma = (int)$sma;
$skis= (int)$skis;
$sin= (int)$sin;
$seng= (int)$seng;
$scre= (int)$scre;
$scra= (int)$scra;
$sss= (int)$sss;
$san= (int)$san;

$tto=$sma+$seng+$san+$sss+$scra+$scre+$sin+$skis;


 //require_once 'dompdf/vendor/autoload.php';
// use Dompdf\Dompdf;
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title><?php echo 'Exam Result: '.$nam; ?></title>
  <meta content="" name="description">
  <meta content="" name="keywords">
  
  <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Vendor CSS Files -->
 
   <link rel="stylesheet" href="data/css/bootstrap.min.css">
  <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="assets/vendor/quill/quill.snow.css" rel="stylesheet">
  <link rel="shortcut icon" href="../images/logo.ico">
</head>
<body style="border:1px solid #004d1a;border-radius:5px;padding:5px;border-style: double;outline-offset: -5px;">
    <div>
     <center> <h6 style="margin-top:5px;color:#0099cc" class="text-red" >CATHOLIC DIOCESE OF MURANGA </h6> </center>
   <center> <h3 style="margin-top:-20px" class="text-red" >BISHOP KAIRO EDUCATION CENTRE </h3> </center>
   <center> <h4 style="margin-top:-20px" class="text-red" >EXCELLENCE IS IN GODLINESS </h4> </center>
  
<img style="position:absolute;margin-top:-80px;margin-bottom:10px;max-height:90px" src="https://bishopkairoeducationcentre.sc.ke/QB-Beta/data/logo.png" alt="" class="" />
<br />
   <label style="margin-top:-20px" class="text-red" ><strong>Telephone:</strong> 0728 966 221, 0714 647 708 </label>
   <br />
  <label style="margin-top:-20px" class="text-red" ><strong>Email:</strong> cdmbishopkairo@gmail.com </label>
  
  <label style="position:absolute;margin-left:220px" class="text-red" ><strong>P.O. Box:</strong> 747- 10200 Murang'a </label>
  <hr />

<div style="">
 NAME: <strong> <u><?php echo $nam; ?></u></strong> <br /> CLASS:   <strong><u><?php echo $claz; ?></u></strong> <br /> ADM NO:  <strong><u><?php echo $admno; ?></u>  <br /> CLASS TEACHER:  <strong>____________________________________</strong> 
 
       <center><h4><u>REPORT FORM </u></h4></center>
        <u><h4 style="position:absolute;margin-top:-5px"><strong style="color:#00661a;"><?php echo $tit; ?>  </strong> <strong style="margin-left:50px">Year:  <span><?php echo $year; ?> </span></strong></h4></u>
    
    <table style="border:1px solid gray;position:relative;margin-top:20px;font-size:12px">
       <thead>
        <tr style="background-color:#000;color:#FFF">
             <th>#</th>
             <th>SUBJECT </th> 
             <th>MARKS</th>
             <th>OUT OF</th>
             <th>RUBRIC</th>
        </tr>
       </thead>
        <tbody>
         <tr style="border:1px solid gray">
            <td  style="border:1px solid gray">1</td>
            <td  style="border:1px solid gray">MATH </td>
            <td  style="border:1px solid gray"><strong><?php echo $ma; ?>  </strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $sma; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $uma; ?></strong></td>
         </tr> 
         
        <tr style="border:1px solid gray">
             <td  style="border:1px solid gray">2</td>
            <td  style="border:1px solid gray"> ENGLISH </td>
            <td  style="border:1px solid gray"> <strong> <?php echo $eng; ?></strong></td>
            <td  style="border:1px solid gray"><strong> <?php echo $seng; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $ueng; ?></strong></td>
        </tr>
        
          <tr style="border:1px solid gray">
               <td  style="border:1px solid gray">3</td>
            <td  style="border:1px solid gray"> KISWAHILI</td>
            <td  style="border:1px solid gray"> <strong> <?php echo $kis; ?></strong></td>
            <td  style="border:1px solid gray"><strong> <?php echo $skis; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $ukis; ?></strong></td>
        </tr>
        
        <tr style="border:1px solid gray">
             <td  style="border:1px solid gray">4</td>
            <td  style="border:1px solid gray"> CRE </td>
            <td  style="border:1px solid gray"> <strong> <?php echo $cre; ?></strong></td>
            <td  style="border:1px solid gray"><strong> <?php echo $scre; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $ucre; ?></strong></td>
        </tr>
        <tr style="border:1px solid gray">
             <td  style="border:1px solid gray">5</td>
            <td  style="border:1px solid gray"> SOCIAL STUDIES</td>
            <td  style="border:1px solid gray"> <strong> <?php echo $ss; ?></strong></td>
            <td  style="border:1px solid gray"><strong> <?php echo $sss; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $uss; ?></strong></td>
        </tr>
        <tr style="border:1px solid gray">
             <td  style="border:1px solid gray">6</td>
            <td  style="border:1px solid gray"> SCIENCE & TECHNOLOGY </td>
            <td  style="border:1px solid gray"> <strong> <?php echo $in; ?></strong></td>
            <td  style="border:1px solid gray"><strong> <?php echo $sin; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $uin; ?></strong></td>
        </tr>
        <tr style="border:1px solid gray">
             <td  style="border:1px solid gray">7</td>
            <td  style="border:1px solid gray"> CREATIVE ARTS</td>
            <td  style="border:1px solid gray"> <strong> <?php echo $cra; ?></strong></td>
            <td  style="border:1px solid gray"><strong> <?php echo $scra; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $ucra; ?></strong></td>
        </tr>
        <tr style="border:1px solid gray">
             <td  style="border:1px solid gray">8</td>
            <td  style="border:1px solid gray"> AGRICULTURE & NUTRITION </td>
            <td  style="border:1px solid gray"> <strong> <?php echo $an; ?></strong></td>
            <td  style="border:1px solid gray"><strong> <?php echo $san; ?></strong></td>
            <td  style="border:1px solid gray"><strong><?php echo $uan; ?></strong></td>
        </tr>
         
         <tr>
         <td colspan="5">
            <hr />
        </td>
        </tr>
         <tr>
            <td  style="border:1px solid gray" colspan="2"> OVERALL PERFORMANCE </td>
            <td  style="border:1px solid gray"><strong style="color:green"> <?php echo $tmks; ?></strong></td>
            <td  style="border:1px solid gray"><strong style="color:green"><?php echo $tto; ?></strong></td>
            <td  style="border:1px solid gray"><strong style="color:green"><?php echo $trubb; ?></strong></td>
          
         </tr>
        <tr>
         <td colspan="5"><hr /></td>
        </tr>
        </tbody>
         <hr />
     </table>
</div>

<p>Class Teacher Remarks :</p> 
<p>.............................................................................................................................................................................</p>
<p>.............................................................................................................................................................................</p>
<br />
<p>SIGN .......................................................................                </p>

<h4>Grading System </h4>

<h5><u>Rubrics System</u></h5>
<table style="font-size:11px">
<tr>
 <th>Rubrics</th>
 <th>Points</th>
</tr>
<tr>
 <td>Exceeding expectations (E.E) <td>
 <td><strong>4</strong></td>
</tr>

<tr>
 <td>Meeting Expectations (M.E) <td>
 <td><strong>3</strong></td>
</tr>

<tr>
 <td>Approaching Expectations (A.E) <td>
 <td><strong>2</strong></td>
</tr>

<tr>
 <td>Below Expectations (B.E) <td>
 <td><strong>1</strong></td>
</tr>
</table>

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

<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/quill/quill.min.js"></script>
<script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
<script src="assets/js/jQuery-2.1.4.min.js"></script>
</body>
</html>'; 
