<?php
	require_once('source/session.php');
	require_once('source/error.php');
	require_once('source/dbconfig.php');
	require_once('source/function.php');
	require_once('source/restrict_user.php');
	
	if($_GET['msg'] == "refered"){
		$msg = "<h5 class='alert alert-success'>Refered successfully</h5>";
	}else if($_GET['msg'] == "failed"){
		$msg = "<h5 class='alert alert-warning'>Something went wrong, please try again</h5>";
	}
	
	if($_SESSION['msg'] == "update")
	{
		$msg = "<h5 class='alert alert-success text-center'>Order Update Succesful. Customer will receive email.<a 
		class='btn-sm' href='new_order.php'>Refresh</a></h5>";
	}       
	          
	      
                    $rows1 = sql($DBH, "SELECT * FROM tbl_student_results where csv_no = ?", 
            	array($_GET['val']), "rows");
		foreach($rows1 as $row1)
		{	
			$u_name	 		= $row1['name'];
			$u_registration_no 		= $row1['registration_no'];
			$u_test1 			= $row1['test1'];
			$u_test2 			= $row1['test2'];
			$u_project 			= $row1['project'];
			$u_exam			= $row1['exam'];
			
			$total = ($u_test1 + $u_test2 + $u_project + $u_exam);


			sql($DBH, "UPDATE tbl_student_results set total = ?, teacher_no = ? WHERE registration_no = ? AND year = ? AND term = ? AND class = ?", array($total,$SESS_HASH_USER,$u_registration_no,$u_test));
			
			
                    $rows2 = sql($DBH, "SELECT * FROM tbl_student_results where csv_no = ? ORDER by (total) desc", 
            	array($_GET['val']), "rows");
            	$sno = 0;
		foreach($rows2 as $row2)
		{	
			$sno++;
			$us_name	 		= $row2['name'];
			$us_registration_no 		= $row2['registration_no'];
			$us_test1 			= $row2['test1'];
			$us_test2 			= $row2['test2'];
			$us_project 			= $row2['project'];
			$us_exam			= $row2['exam'];
			$us_total			= $row2['total'];
			$us_class			= $row2['class'];
			$us_year			= $row2['year'];
			$us_term			= $row2['term'];
			
			if($us_total <=29){
			$grade = "Fail";
			}
			else if ($us_total >29 && $us_total<= 39)
			{
			$grade = "Fair";
			}
			else if ($us_total >39 && $us_total<= 49)
			{
			$grade = "Faily Good";
			}
			else if ($us_total >49 && $us_total<= 59)
			{
			$grade = "Good";
			}
			else if ($us_total >59 && $us_total<= 69)
			{
			$grade = "Very Good";
			}
			else if ($us_total >69 && $us_total<= 79)
			{
			$grade = "Excellent";
			}
			else if ($us_total >79 && $us_total<= 100)
			{
			$grade = "Very Excellent";
			}
			
			sql($DBH, "UPDATE tbl_student_results set grade = ?, position = ? WHERE registration_no = ? AND test = ?", array($grade,$sno,$us_registration_no,$us_test));
			}
			}
			
			//Overall
			
		$STH 			= $DBH->prepare("SELECT count(*) FROM tbl_overall WHERE class = ? AND year = ? AND term = ?");
        	$result 	   	= $STH->execute(array($_GET['myclass'],$_GET['examyear'],$_GET['term']));
        	$cnt_overall	  	= $STH->fetchColumn();
        	if($cnt_overall == 0){
        	
			
                    $rows1 = sql($DBH, "SELECT * FROM tbl_overall WHERE class = ? AND year = ? AND term = ?", array($_GET['stclass'],$_GET['examyear'],$_GET['term']), "rows");
		foreach($rows1 as $row1)
		{	
			$st_registration_no	=	$row1['reg_no'];
			$st_class	=	$row1['class'];
			$st_name	=	$row1['name'];
			
		                                 
		$b_in_s = sql($DBH, "SELECT SUM(total) FROM tbl_overall WHERE class = ? AND year = ? AND term = ? AND registration_no = ?", array($_GET['stclass'],$_GET['year'],$_GET['stterm'],$st_registration_no), "rows");			
		foreach($b_in_s as $b_in_row){	
			$b_ins	=	$b_in_row[0];
		}
			
		
		sql($DBH, "insert into  tbl_overall (name , reg_no , class , year , term, overall)values (?,?,?,?,?,?)", array($st_name,$st_registration_no,$_GET['stclass'],$_GET['year'],$_GET['stterm'],$b_ins));	
		
		
                    $rows2 = sql($DBH, "SELECT * FROM tbl_overall WHERE class = ? AND year = ? AND term = ? ORDER by (overall) desc", 
            	array($_GET['stclass'],$_GET['year'],$_GET['stterm']), "rows");
            	$snum = 0;
		foreach($rows2 as $row2)
		{	
			$snum++;
			$ust_name	 		= $row2['name'];
			$ust_reg_no 		= $row2['reg_no'];
			$ust_test 			= $row2['test'];	
		
			$rows1 = sql($DBH, "SELECT * FROM tbl_user where registration_no = ?", array($ust_reg_no), "rows");							
			foreach($rows1 as $row1)
			{	
				$dob   		= $row1['age'];
				
				//date in mm/dd/yyyy format; or it can be in other formats as well
  $birthDate = "$dob";
  //explode the date to get month, day and year
  $birthDate = explode("/", $birthDate);
  //get age from date or birthdate
  $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
    ? ((date("Y") - $birthDate[2]) - 1)
    : (date("Y") - $birthDate[2]));
    }
			sql($DBH, "UPDATE tbl_overall set position = ?, age = ? WHERE class = ? AND year = ? AND term = ? AND reg_no = ?", array($snum,$age,$_GET['stclass'],$_GET['year'],$_GET['stterm'],$ust_reg_no), "rows");
		}
	}	
}else if($cnt_overall > 0){
                    $rows2 = sql($DBH, "SELECT * FROM tbl_overall WHERE class = ? AND year = ? AND term = ? ORDER by (overall) desc", 
            	array($_GET['stclass'],$_GET['year'],$_GET['stterm']), "rows");
            	$snum = 0;
		foreach($rows2 as $row2)
		{	
			$snum++;
			$ust_name	 		= $row2['name'];
			$ust_reg_no 		= $row2['reg_no'];
			$ust_test 			= $row2['test'];	
			
			                                 
		$b_in_s = sql($DBH, "SELECT SUM(total) FROM tbl_student_results WHERE class = ? AND year = ? AND term = ? AND registration_no = ?", array($_GET['stclass'],$_GET['year'],$_GET['stterm'],$ust_reg_no), "rows");			
		foreach($b_in_s as $b_in_row){	
			$b_ins	=	$b_in_row[0];
          $STH 				= $DBH->prepare( "SELECT AVG(total) FROM tbl_student_results WHERE registration_no = ? AND class =? AND term = ? AND year = ?");
			$result 	   		= $STH->execute(array($_GET['myreg'],$_GET['myclass'],$_GET['term'],$_GET['examyear']));
			$AverageScore	  	= $STH->fetchColumn();   
		}
			
			
	sql($DBH, "UPDATE tbl_overall set overall = ? WHERE class = ? AND year = ? AND term = ? AND reg_no = ?", array($b_ins,$_GET['stclass'],$_GET['year'],$_GET['stterm'],$ust_reg_no), "rows");
			sql($DBH, "UPDATE tbl_overall set position = ? WHERE class = ? AND year = ? AND term = ? AND reg_no = ?", array($snum,$_GET['stclass'],$_GET['year'],$_GET['stterm'],$ust_reg_no), "rows");
	sql($DBH, "UPDATE tbl_overall set AverageScore = ? WHERE class = ? AND year = ? AND term = ? AND reg_no = ?", array($AverageScore,$_GET['stclass'],$_GET['year'],$_GET['stterm'],$ust_reg_no), "rows");
	}
}

?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>PASSION MODERN SCHOOLS: My Term Result!</title>
  <!-- Bootstrap core CSS-->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom fonts for this template-->
  <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <!-- Page level plugin CSS-->
  <link href="vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
  <!-- Custom styles for this template-->
  <link href="css/sb-admin.css" rel="stylesheet">
  <link href="css/folder.css" rel="stylesheet">
  <link href="css/user_profile.css" rel="stylesheet">
  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <!-- select-->
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  
 
<style> 
div.a {
    white-space: nowrap; 
    width: 100px; 
    overflow: hidden;
    text-overflow:ellipsis;
    border: 0px solid #000000;
    padding-left: 25px;
}

div.a:hover {
    overflow: visible;
}
.style1 {color: #FFFFFF}
</style>
  
</head>

<body class="fixed-nav sticky-footer bg-dark" id="page-top">
  <!-- Navigation-->
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
<?php
            	
            	$rows = sql($DBH, "SELECT * FROM tbl_admin where status = ?", 
            	array("Active"), "rows");							
            	foreach($rows as $row)
            	{
            		$admin_name 		= $row['username'];
            	}
		
      if (isset($_SESSION['SESS_HASH_ADMIN'])) {
		$user_true 			 = "<h4 style='color: #f9ecf9'><b>STUDENT RESULT SHEET </b></h4>";
		
}
		echo "$user_true ";
?>
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav navbar-sidenav" id="exampleAccordion">
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="My Dashboard">
          <a class="nav-link" href="main.php">
            <i class="fa fa-fw fa-dashboard" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: white">Dashboard</span>
          </a>
          <a class="nav-link" href="logout.php">
            <i class="fa fa-fw fa-sign-out" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: white">Logout</span>
          </a>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto">
        <li class="nav-item">
          <a class="nav-link" data-toggle="modal" href="logout.php" style="color: white">
            <i class="fa fa-fw fa-sign-out"></i>Logout</a>
        </li>
      </ul>
    </div>
  </nav>
  
  <div class="content-wrapper">
    <div class="container-fluid">
      <div align="left" vertical-align= "top" margin-top= "0px"><img src="sch_logo2.png" alt="PASSION MODERN SCHOOLS" width="1080" height="122"><br>
        <?php
          $STH 				= $DBH->prepare("SELECT count(*) FROM tbl_overall WHERE class =? AND term = ? AND year = ?");
			$result 	   		= $STH->execute(array($_GET['myclass'],$_GET['term'],$_GET['examyear']));
			$count_student	  	= $STH->fetchColumn();   
			
			                      
		$AverageScore = sql($DBH, "SELECT AVG(total) FROM tbl_student_results WHERE registration_no = ? AND class =? AND term = ? AND year = ?", array($_GET['myreg'],$_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($AverageScore as $b_in_row){	
			$AverageScore	= round($b_in_row[0],2);
		}
		if($AverageScore <=29){
			$htcomments = "Failure, sit up next term for a better result" AND $cgrade = "F";
			}
			else if ($AverageScore >29 && $AverageScore<= 39)
			{
			$htcomments = "Fair Result, put more effort as greater tasks await you." AND $cgrade = "E";
			}
			else if ($AverageScore >39 && $AverageScore<= 49)
			{
			$htcomments = "Fairly Good result, read harder as greater tasks await you." AND $cgrade = "D";
			}
			else if ($AverageScore >49 && $AverageScore<= 59)
			{
			$htcomments = "Good Result, read harder to improve me" AND $cgrade = "C";
			}
			else if ($AverageScore >59 && $AverageScore<= 69)
			{
			$htcomments = "Very Good commendable term's work. Keep the light glowing" AND $cgrade = "B";
			}
			else if ($AverageScore >69 && $AverageScore<= 79)
			{
			$htcomments = "Excellent Impressive Result. Don't relent in your effort" AND $cgrade = "A";
			}
			else if ($AverageScore >79 && $AverageScore<= 100)
			{
			$htcomments = "Very Excellent Result, Keep it up" AND $cgrade = "A+";
			}	
		                      
		$b_in_q = sql($DBH, "SELECT AVG(total) FROM tbl_student_results where class =? AND term = ? AND year = ?", array($_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($b_in_q as $b_in_row){	
			$b_in	= round($b_in_row[0],2);
		}	
		                      
		$b_in_qa = sql($DBH, "SELECT AVG(total) FROM tbl_student_results where class =? AND term = ? AND year = ?", array($_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($b_in_qa as $b_in_row){	
			$b_inqa	= $b_in_row[0];
		}
		                         
		$b_in_m = sql($DBH, "SELECT MIN(total) FROM tbl_student_results where  class =? AND term = ? AND year = ?", array($_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($b_in_m as $b_in_row){	
			$b_inm	= $b_in_row[0];
		}
		                         
		$b_in_mx = sql($DBH, "SELECT MAX(total) FROM tbl_student_results where class =? AND term = ? AND year = ?", array($_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($b_in_mx as $b_in_row){	
			$b_inmx	= $b_in_row[0];
		}
		
		$b_in_ag = sql($DBH, "SELECT AVG(age) FROM tbl_overall where class =? AND term = ? AND year = ?", array($_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($b_in_ag as $b_in_row){	
			$b_inag	= $b_in_row[0];
			
			$b_age = round(($b_inag),2);
		}
		
                    $rows1 = sql($DBH, "SELECT * FROM tbl_user where registration_no = ?", 
            	array($_GET['myreg']), "rows");
		foreach($rows1 as $row1)
		{	
			$user_name	 		= $row1['fullname'];
			$user_gender	 		= $row1['gender'];
			$user_age	 		= $row1['age'];
			$user_profile_pic	 	= $row1['profile_pic'];
		}
		
            		if($user_profile_pic == "default"){
            		$profile_pic = "<img width='100px' src='../admin/profile/profile.jpg'>";
			}else{						
			$profile_pic = "<img width='100px' src='../admin/profile_pic/$user_profile_pic'>";
			}
		
                    $rows1 = sql($DBH, "SELECT * FROM tbl_overall where class =? AND term = ? AND year = ? AND reg_no =?", array($_GET['myclass'],$_GET['term'],$_GET['examyear'],$_GET['myreg']), "rows");
		foreach($rows1 as $row1)
		{	
			$user_position	 		= $row1['position'];
			$overall	 		= $row1['overall'];
		}
		
		if($user_position == 1){
		$user_p = "$user_position st";
		} else if($user_position == 2){
		$user_p = "$user_position nd";
		} else if($user_position == 3){
		$user_p = "$user_position rd";
		}else{
		$user_p = "- - -";
		}
		
	?>
        <?php
$rows = sql($DBH, "SELECT * FROM skills_and_remarksNur where registration_no = ? AND class =? AND term =? AND year =?", array($_GET['myreg'],$_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($rows as $row)
		{	
                $SchOpen  		= $row['SchOpen'];
                $Present  		= $row['Present'];
                $Absent  		= $row['Absent'];
                $Punctual  		= $row['Punctual'];
                $Late  		= $row['Late'];
                $TermBegins   		= $row['TermBegins'];                
                $DateOfReport  		= $row['DateOfReport'];
                $hgrade 		= $row['CoordinatorsComment'];
                $TeachersRemarks  		= $row['TeachersRemarks'];
                $ReadAct  		= $row['ReadAct'];
                $NumAct  		= $row['NumAct'];
                $CreatAct  		= $row['CreatAct'];
                $NurRhymes  		= $row['NurRhymes'];
                $Music  		= $row['Music'];
                $PhyAct  		= $row['PhyAct'];
                $Games  		= $row['Games'];
                $SelfConf  		= $row['SelfConf'];
                $Sociability  		= $row['Sociability'];
                $Inteligence  		= $row['Inteligence'];
                $IntCurious  		= $row['IntCurious'];
                $Comprehension  		= $row['Comprehension'];
                $PersonalClean  		= $row['PersonalClean'];
                                         		                                           
                               }
?>
      </div>
      <div class='row'>
	  <div class='col-sm-4'> <small><b>Name of Pupil: </b> <u><?php echo $user_name ; ?></u></small><br>
	    <small><b>Registration No: </b> <u><?php echo $_GET['myreg'] ; ?></u></small><br>
	    <small><b>Sex: </b> <u><?php echo $user_gender ; ?></u></small><br>
	    <small><b>Term: </b> <u><?php echo $_GET['term']; ?></u></small><br>
	    <small><b>Session: </b> <u><?php echo $_GET['examyear']; ?></u></small><br>
	    <small><b>Age : </b>
	    <Big>
	    <?php
			
			$rows1 = sql($DBH, "SELECT * FROM tbl_user where hash = ?", array($SESS_HASH_USER), "rows");							
			foreach($rows1 as $row1)
			{	
				$dob   		= $row1['age'];
				$userst_registration_no   		= $row1['registration_no'];
				
				//date in mm/dd/yyyy format; or it can be in other formats as well
  $birthDate = "$dob";
  //explode the date to get month, day and year
  $birthDate = explode("/", $birthDate);
  //get age from date or birthdate
  $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
    ? ((date("Y") - $birthDate[2]) - 1)
    : (date("Y") - $birthDate[2]));
    }
    
              
		$rows = sql($DBH, "SELECT MIN(id) AS id, class FROM tbl_student_results  WHERE registration_no = ? GROUP BY class", 
            	array($userst_registration_no), "rows");
		foreach($rows as $row)
		{	
			$userst_class	 		= $row['class'];
		}
		
		$rows = sql($DBH, "SELECT MAX(id) AS id, subclass FROM tbl_student_results  WHERE registration_no = ? GROUP BY subclass", 
            	array($userst_registration_no), "rows");
		foreach($rows as $row)
		{	
			$userst_subclass	 		= $row['class'];
		}
		
			 echo $age; ?>
	    </Big>Yr(s)	    </small><strong>[</strong><small><b>DoB</b></small> is <small><u> <?php echo $user_age ; ?> </u></small><strong>]</strong><br>
      </div>
	  <div class='col-sm-3'> <small><b>Class: </b> <u><?php echo $_GET['myclass'] ; ?></u></small><br>
		  <small><b>No in Class: </b> <u><?php echo $count_student; ?></u></small><br>
	    <!-- <small><b>Position: </b> <u><medium><?php echo $user_p ; ?></medium></u></small><br><br>-->
		  <small><b>Total Score: </b> <u><medium><?php echo $overall ; ?></medium></u></small><br>
		  <small><b>Position: </b> <u><medium><?php echo $user_p ; ?></medium></u> &nbsp; &nbsp;<b>Grade: </b> <u><medium><?php echo $cgrade ; ?></medium></u></small><br>
		  <small><b> Average Score: </b> <u><?php echo $AverageScore ; ?></u></small><br>
		  <small><b>Class Average Score: </b> <u><?php echo $b_in ; ?></u></small><br>
		  <br>
	  </div>
		<div class='col-sm-3'><small><b>Times Sch. Opened: </b><small><big><big><u><?php echo $SchOpen; ?></u></big></big></small></small><br>
		  <small><b>Times Present: </b> <u><?php echo $Present; ?></u></small><br>
		  <small><b>Times Absent: </b> <u><?php echo $Absent; ?></u></small>
		  <br>
		  <small><b>Times Punctual: </b> <u><?php echo $Punctual; ?></u></small><br>
		  <br>
		  <Small><b>Term Ending: </b> <u><?php echo $DateOfReport; ?></u></Small><br>
		  <small><b>Next Term Begins : </b> <?php echo $TermBegins; ?></small>
		  <br>
	  </div>
		<div class='col-sm-2'>
			<?php echo $profile_pic ; ?><br/>
	</div>
      </div>
      <div class="row">
      <div class="col-sm-5"> <BR />
            <b><u>PUPIL'S CONT. ASSESSMENT REPORT</u></b>
    </div>
       <div class="col-sm-7"> <BR />
       <b><u><CENTER>ACTIVITIES</CENTER></u></b>
    </div>
      <div class="row">
      <div class="col-sm-5">
                            <table width="98%" border="2" class='table table-bordered'>
                                <tr style='font-size: 12px'>
                                    <th width="60%" class='text-left' colspan='2' valign="baseline" rowspan='3'>Subject</th>
                                    <th width="4%" colspan='1'  class='text-center'>Cumm. Total</th>
                                    <th width="4%" colspan='1'  class='text-center'>Grade</th>
                                </tr>
                                <tr style='font-size: 10px'>
    								
                                </tr>
                                <tr style='font-size: 10px'>

<?php
                                
	$rows = sql($DBH, "SELECT * FROM tbl_student_results where registration_no = ? AND class =? AND term =? AND year =?", array($_GET['myreg'],$_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($rows as $row)
		{	
                $subject 	 	= $row['subject'];
                $test1 		= $row['test1'];
                $test2 		= $row['test2'];
                $project 		= $row['project'];
                $exam 		= $row['exam'];
                $total 		= $row['total'];
                $position 		= $row['position'];
                $remark 		= $row['grade'];
                $hremark 		= $row['hgrade'];
		if($position == 1){
		$position = "$position st";
		} else if($position == 2){
		$position = "$position nd";
		} else if($position == 3){
		$position = "$position rd";
		} else if($position == 21){
		$position = "$position st";
		} else if($position == 22){
		$position = "$position nd";
		} else if($user_position == 23){
		$position = "$position rd";
		} else if($position == 31){
		$position = "$position st";
		} else if($user_position == 32){
		$position = "$position nd";
		} else if($position == 33){
		$position = "$position rd";
		} else if($position == 41){
		$position = "$position st";
		} else if($position == 42){
		$position = "$position nd";
		} else if($position == 43){
		$position = "$position rd";
		}else{
		$position = "$position th";
		}
                
                                        
		$b_in_mn = sql($DBH, "SELECT MIN(total) FROM tbl_student_results where class =? AND year = ? AND term =? AND subject =?", array($_GET['myclass'],$_GET['examyear'],$_GET['term'],$subject), "rows");							
		foreach($b_in_mn as $b_in_row){	
			$b_inmn	= $b_in_row[0];
		}
		                            
		$b_in_mnx = sql($DBH, "SELECT MAX(total) FROM tbl_student_results where class =? AND year = ? AND term =? AND subject =?", array($_GET['myclass'],$_GET['examyear'],$_GET['term'],$subject), "rows");							
		foreach($b_in_mnx as $b_in_row){	
			$b_inmnx	= $b_in_row[0];
		}
		                               
		$b_in_mav = sql($DBH, "SELECT AVG(total) FROM tbl_student_results where class =? AND term = ? AND year = ? AND subject =?", array($_GET['myclass'],$_GET['term'],$_GET['examyear'],$subject), "rows");							
		foreach($b_in_mav as $b_in_row){	
			$b_inmav = round($b_in_row[0],2);
		}
		  
			if($total <=29){
			$grade = "F";
			}
			else if ($total >29 && $total<= 39)
			{
			$grade = "E";
			}
			else if ($total >39 && $total<= 49)
			{
			$grade = "D";
			}
			else if ($total >49 && $total<= 59)
			{
			$grade = "C";
			}
			else if ($total >59 && $total<= 69)
			{
			$grade = "B";
			}
			else if ($total >69 && $total<= 79)
			{
			$grade = "A";
			}
			else if ($total >79 && $total<= 100)
			{
			$grade = "A+";
			}
			 
                
                echo"
                                <tr>
                                <td colspan='2'>$subject</td>
                                <td>$total</td>
                                <td>$grade</td>
                                </tr>";
                               }
?>
	          <?php
$rows = sql($DBH, "SELECT * FROM skills_and_remarksNur where registration_no = ? AND class =? AND term =? AND year =?", array($_GET['myreg'],$_GET['myclass'],$_GET['term'],$_GET['examyear']), "rows");							
		foreach($rows as $row)
		{	
                $Attendance  		= $row['Attendance'];
                $Present  		= $row['Present'];
                $Absent  		= $row['Absent '];
                $NextTermBegins   		= $row['NextTermBegins'];                
                $DateOfReport  		= $row['DateOfReport'];
                $ListenSkill 			= $row['ListenSkill'];
			$ReadsLetters 			= $row['ReadsLetters'];
			$ExpressesWell 			= $row['ExpressesWell'];
			$ReadsSimpleWords 			= $row['ReadsSimpleWords'];
			$ReadCopySentences 			= $row['ReadCopySentences'];
			$FollowsInst 			= $row['FollowsInst'];
			$PrintedWords 			= $row['PrintedWords'];
			$ColourTemplates 			= $row['ColourTemplates'];
			$SpeakingVoc 			= $row['SpeakingVoc'];
			$GroupDiscLetter 			= $row['GroupDiscLetter'];
			$IntBooks 			= $row['IntBooks'];
			$LikenessDiffLetter 			= $row['LikenessDiffLetter'];
			$GeometricShapes 			= $row['GeometricShapes'];
			$CanTrace 			= $row['CanTrace'];
            $SolveSimpleNumber 			= $row['SolveSimpleNumber'];
            $LikenessDiffNum 			= $row['LikenessDiffNum'];
			$HowMany 			= $row['HowMany'];
			$SimpleMeasure 			= $row['SimpleMeasure'];			
			$PartGroupDiscCRK 			= $row['PartGroupDiscCRK'];			
			$CanReadBible 			= $row['CanReadBible'];			
			$MoralInst 			= $row['MoralInst'];			
			$AnswerBibleQ 			= $row['AnswerBibleQ'];			
			$GoodMoral 			= $row['GoodMoral'];
			$ClassRoutine 			= $row['ClassRoutine'];
			$SelfControl 			= $row['SelfControl'];
			$ShowsRespect 			= $row['ShowsRespect'];
			$ThankYou 			= $row['ThankYou'];
			$SkillWorkingOthers 		= $row['SkillWorkingOthers'];
			$Permission 			= $row['Permission'];
			$OnHisOwn 			= $row['OnHisOwn'];
			$ProperCare 			= $row['ProperCare'];
			$CanButton 			= $row['CanButton'];
			$CanLace 			= $row['CanLace'];
			$GoesToilet 			= $row['GoesToilet'];
			$HandKerchief 			= $row['HandKerchief'];
			$AppearsNeat 			= $row['AppearsNeat'];
			$TidyUniform 			= $row['TidyUniform'];
			$WashesHand			= $row['WashesHand'];
			$ScienceAct 			= $row['ScienceAct'];
			$NewIdeasWillingly 			= $row['NewIdeasWillingly'];
			$ThingsOfNature 			= $row['ThingsOfNature'];
			$ClassPractical_Science 			= $row['ClassPractical_Science'];
			$SkillsInObservation 			= $row['SkillsInObservation'];
			$ReadsIgbo 			= $row['ReadsIgbo'];
			$WritesIgbo 			= $row['WritesIgbo'];
			$InterestDuringLesson_Igbo 			= $row['InterestDuringLesson_Igbo'];
			$LikenessDiff_Igbo 			= $row['LikenessDiff_Igbo'];
			$ReadSimpSent_Reading 			= $row['ReadSimpSent_Reading'];
			$ReadShortSt			= $row['ReadShortSt'];
			$TellsStory 			= $row['TellsStory'];
			$OralReading 			= $row['OralReading'];
			$RecitesOralReading 			= $row['RecitesOralReading'];
			$ShowsIntPoem 			= $row['ShowsIntPoem'];
			$ActivePartRhyme			= $row['ActivePartRhyme'];
			$RecitesRhymes 			= $row['RecitesRhymes'];
			$ShowsIntRhyme 			= $row['ShowsIntRhyme'];
			$IdeasCreatively_Craft 			= $row['IdeasCreatively_Craft'];
			$UsesMaterialsWell 			= $row['UsesMaterialsWell'];
			$CanWriteLetNum			= $row['CanWriteLetNum'];
			$ScienceAct 			= $row['ScienceAct'];
			$CanCopy_Craft			= $row['CanCopy_Craft'];
			$CanCopyWords_Writing 			= $row['CanCopyWords_Writing'];
			$CopySent_Writing 			= $row['CopySent_Writing'];
			$FillColours_Writing			= $row['FillColours_Writing'];
			$TraceTemplates_Writing 			= $row['TraceTemplates_Writing'];
			$CompletesHomework 			= $row['CompletesHomework'];
                               }
?>
        </table>
        </div>
    <div class="col-sm-7"><BR />
	          <table width="96%" height="6%" border="2" cellspacing="5">
	            <tr style='font-size: 14px'>
	              <td><small><strong><span class="text-center">Reading Activities</span></strong></small></td>
	              <td><?php echo $ReadAct; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong><span class="text-center">Number Activities</span></strong></small></td>
	              <td><?php echo $NumAct; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong>Creative Activities</strong></small></td>
	              <td><?php echo $CreatAct; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong><span class="text-center">Nursery Rhymes</span></strong></small></td>
	              <td><?php echo $NurRhymes; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td height="11"><small><strong><span class="text-center">Music</span></strong></small></td>
	              <td><?php echo $Music; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong><span class="text-center">Physical Activities</span></strong></small></td>
	              <td><?php echo $PhyAct; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong><span>Games</span></strong></small></td>
	              <td><?php echo $Games; ?></td>
                </tr>
	            
	            
	           </table> <BR /><U><STRONG><CENTER>PERSONAL QUALITIES</CENTER></STRONG></U><br />
	           <table width="98%" height="6%" border="2" cellspacing="5">
	            <tr style='font-size: 14px'>
	              <td width="30%"><small><strong><span class="text-center">Self  Confidence</span></strong></small></td>
	              <td width="70%"><?php echo $SelfConf; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong><span class="text-center">Sociability</span></strong></small></td>
	              <td><?php echo $Sociability; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong>Inteligence</strong></small></td>
	              <td><?php echo $Inteligence; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong><span class="text-center">Interest & Curiousity</span></strong></small></td>
	              <td><?php echo $IntCurious; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td height="11"><small><strong><span class="text-center">Comprehension</span></strong></small></td>
	              <td><?php echo $Comprehension; ?></td>
                </tr>
	            <tr style='font-size: 14px'>
	              <td><small><strong><span class="text-center">Personal Cleanliness</span></strong></small></td>
	              <td><?php echo $PersonalClean; ?></td>
                </tr>
                
                <table width="96%" height="6%" border="1" cellspacing="5">
	            <tr style='font-size: 11px'>
	                <BR />
	                <BR />
                      <strong><center><button onclick="myFunction()">|||| PRINT THIS RESULT ||||</button></center></strong>
        </tr>
	           </table>
	           
    </div>


<TABLE>
    <div class="col-sm-1"></div>
	  <div class="col-sm-11"><small><b>Class Teacher's Remarks: </b></small><medium><u><?php echo $TeachersRemarks; ?></u></medium>
	    <br>
	    <small><b>Co-ordinator's Comment: </b></small><medium><u><STRONG><?php echo $htcomments; ?></STRONG></u></medium><br></P>
	  </div>
</TABLE>
<script>
function myFunction() {
    window.print();
}
</script>
    </div>
</div>
          </div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
    <footer class="sticky-footer" style="background: #ac39ac">
      <div class="container">
        <div class="text-center"> <small><strong><span class="style1">Copyright © 2020-2021 PASSION MODERN SCHOOLS: All Rights Reserved!</span></strong></small> </div>
      </div>
    </footer>
    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fa fa-angle-up"></i>
    </a>
    <!-- Logout Modal-->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="Sign_in.php">Logout</a>
          </div>
        </div>
      </div>
    </div>
    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    <!-- Page level plugin JavaScript-->
    <script src="vendor/chart.js/Chart.min.js"></script>
    <script src="vendor/datatables/jquery.dataTables.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>
    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin.min.js"></script>
    <!-- Custom scripts for this page-->
    <script src="js/sb-admin-datatables.min.js"></script>
    <script src="js/sb-admin-charts.min.js"></script>
  </div>
</body>

</html>
