<?php
ob_start();
 session_start();
require_once('operations.php');
require_once('student.php');

$month = date("n");
$year = date("Y");

if($month == 19 || $month == 101 || $month == 11 || $month == 12){

$session1 = $year . "/". ($year + 1);
$term1 = "First";
}


else if($month == 1 || $month == 2 || $month == 3  || $month == 4 || $month == 5){
$session1 = ($year-1)."/".$year;
 $term1 = "Second";
//$term1 = "First";
}

 else if($month == 15 || $month == 6 || $month == 7 || $month == 8 || $month == 9  || $month == 10){
$session1 = ($year-1)."/".$year;
$term1 = "Third";
 //$term1 = "Second";
}

$db = new Operations();


if (!isset($_SESSION['user'])) {
   header( "Location: index.php" );
}





   
    



?>
<!--
=========================================================
* Argon Dashboard - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/argon-dashboard


* Copyright  Creative Tim (http://www.creative-tim.com)
* Coded by www.creative-tim.com



=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-->
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="Start your development with a Dashboard for Bootstrap 4.">
  <meta name="author" content="Creative Tim">
  <title>Exam App</title>
  <!-- Favicon 
  <link rel="icon" href="assets/img/brand/favicon.png" type="image/png">
  -->
  <!-- Fonts -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700">
  <!-- Icons -->
  <link rel="stylesheet" href="assets/vendor/nucleo/css/nucleo.css" type="text/css">
  <link rel="stylesheet" href="assets/vendor/@fortawesome/fontawesome-free/css/all.min.css" type="text/css">
  <!-- Page plugins -->
  <!-- Argon CSS -->
  <link rel="stylesheet" href="assets/css/argon.css?v=1.2.0" type="text/css">
</head>

<body>
  <!-- Sidenav -->
  <nav class="sidenav navbar navbar-vertical  fixed-left  navbar-expand-xs navbar-light bg-white" id="sidenav-main">
    <div class="scrollbar-inner">
      <!-- Brand -->
      <div class="sidenav-header  align-items-center">
        <a class="navbar-brand" href="javascript:void(0)">
          <h4>Exam App</h4>
        </a>
      </div>
      <div class="navbar-inner">
        <!-- Collapse -->
        <div class="collapse navbar-collapse" id="sidenav-collapse-main">
          <!-- Nav items -->
          <?php include('staffmenu.html')  ?>
          <!-- Divider -->
          <hr class="my-3">
          <!-- Heading -->
          
        </div>
      </div>
    </div>
  </nav>
  <!-- Main content -->
  <div class="main-content" id="panel">
    <!-- Topnav -->
    <nav class="navbar navbar-top navbar-expand navbar-dark bg-primary border-bottom">
      <div class="container-fluid">
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <!-- Search form -->
          <form class="navbar-search navbar-search-light form-inline mr-sm-3" id="navbar-search-main">
            <div class="form-group mb-0">
              <div class="input-group input-group-alternative input-group-merge">
                <div class="input-group-prepend">
                  <span class="input-group-text"><i class="fas fa-search"></i></span>
                </div>
                <input class="form-control" placeholder="Search" type="text">
              </div>
            </div>
            <button type="button" class="close" data-action="search-close" data-target="#navbar-search-main" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </form>
          <!-- Navbar links -->
          
            <ul class="navbar-nav align-items-center  ml-md-auto ">
            <li class="nav-item d-xl-none">
              <!-- Sidenav toggler -->
              <div class="pr-3 sidenav-toggler sidenav-toggler-dark" data-action="sidenav-pin" data-target="#sidenav-main">
                <div class="sidenav-toggler-inner">
                  <i class="sidenav-toggler-line"></i>
                  <i class="sidenav-toggler-line"></i>
                  <i class="sidenav-toggler-line"></i>
                </div>
              </div>
</li>
</ul>
          
          
        </div>
      </div>
    </nav>
    <!-- Header -->
    <!-- Header -->
    <div class="header bg-primary pb-6">
      <div class="container-fluid">
        <div class="header-body">
          <div class="row align-items-center py-4 text-white">
            
          
          </div>
          <!-- Card stats -->
         
          <!-- put content  -->




          
    <!-- Page content -->

    <div class="card text-center" >
    <div class="card-body">
   

    
        <div class="col-lg-5 col-md-10 text-center" >
          <div class="card bg-secondary border-0 mb-0">
            <div class="card-header bg-transparent pb-5">
             
            
              <form role="form" method = "post" action = "">
                <div class="form-group mb-3">
                  <div class="input-group input-group-merge input-group-alternative">
                  <label class="form-control-label" for="input-username">Enter Exam code</label>
                    <div class="input-group-prepend">
                      <span class="input-group-text"><i class="ni ni-single-02"></i></span>
                    </div>
                    <input class="form-control" placeholder="examcode" type="text" name = "username" required>
                  </div>
                </div>
                
                
                 <div class="form-group mb-3">
                  <div class="input-group input-group-merge input-group-alternative">
                  <label class="form-control-label" for="input-username">Select Class</label>
                    <div class="input-group-prepend">
                      <span class="input-group-text"><i class="ni ni-single-02"></i></span>
                    </div>
                    
                    
                     <select class="form-control inputstl" id="area"  name="class" required="required">
 
 <option value="">Select Class</option>

                   <option value="JSS1A">JSS1 A</option>
                   <option value="JSS1B">JSS1 B</option>
                    <option value="JSS1C">JSS1 C</option>
                     <option value="JSS1D">JSS1 D</option>
                    <option value="JSS2A">JSS2 A</option>
                    <option value="JSS2B">JSS2 B</option>
                    <option value="JSS2C">JSS2 C</option>
                    <option value="JSS2D">JSSD C</option>
                     <option value="JSS3A">JSS3 A</option>
                     <option value="JSS3B">JSS3 B</option>
                      <option value="JSS3C">JSS3 C</option>
                      <option value="JSS3D">JSS3 D</option>
               <option value="SS1A">SS1  A</option>
               <option value="SS1B">SS1  B</option>
               <option value="SS1C">SS1  C</option>
               <option value="SS1D">SS1  D</option>
                  
              
               
                    <option value="SS2A">SS2  A</option>
               <option value="SS2B">SS2  B</option>
               <option value="SS2C">SS2  C</option>
               <option value="SS2D">SS2  D</option>
                    
                    
                    
                     <option value="SS3A">SS3  A</option>
               <option value="SS3B">SS3  B</option>
               <option value="SS3C">SS3  C</option>
               <option value="SS3D">SS3  D</option>
                      
                  </select>
                    
                    
                    
                  </div>
                </div>
                
               
                <div class="text-center">
                  <button type="submit" name = "submit" class="btn btn-primary my-4">GET SCORES</button>
                </div>
              </form>
           
    </div>
  </div>

<?php

if (isset($_POST['submit'])){
	
  $examcode = strtoupper(trim($_POST['username']));
  
    $class = strtoupper(trim($_POST['class']));

  $count = $db->getCountScoresAndSubject($examcode);

  if($count < 1) {

    ?>

<script>
alert('no scores record found')
</script>
    <?php
  }

  else {
$statement = $db->getGeneralScoresAndSubject($examcode,$class);

?>

<div>
<h2>EXAM CODE <?php  echo " ".$examcode ?></h2>
    <table class="table align-items-center table-dark" id = "example" style = "width:100%">
        <thead class="thead-dark">
            <tr>
                <th scope="col" class="sort" data-sort="name">S/N</th>
                <th scope="col" class="sort" data-sort="name">subject</th>
                <th scope="col" class="sort" data-sort="budget">lname</th>
                <th scope="col" class="sort" data-sort="budget">fname</th>
                <th scope="col" class="sort" data-sort="budget">Class</th>
              <!--  <th scope="col" class="sort" data-sort="budget">Duration</th> -->
                <th scope="col" class="sort" data-sort="budget">scores</th>
                
                 <th scope="col" class="sort" data-sort="budget">Review</th>
               
                
               
                
            </tr>
        </thead>
        <tbody class="list">
<?php
$rowCount1 = 0;
        while ($row = $statement->fetch(PDO::FETCH_ASSOC)){
            extract($row);
        $rowCount1++;

        ?>

<tr>
                <td>
                   <?php  echo  $rowCount1;  ?> 
                </td>
                <td>
                <?php  echo $row['title'] ?>  
                </td>

                <td>
                <?php  echo $row['fname'] ?>  
                </td>

                <td>
                <?php  echo $row['lname'] ?>  
                </td>
            
                <td>
                <?php  echo $row['class2'] ?>  

                </td>
              

                <td>
                <?php  echo $row['score'] ?>  

                </td>
                
                  <td>

                <a href="audit.php?examcode=<?php echo $examcode ;?>&admissionno=<?php echo urlencode($row['admissionno']) ;?>&lname=<?php echo urlencode($row['lname']) ;?>&fname=<?php echo urlencode($row['fname']) ;?>&score=<?php echo urlencode($row['score']) ;?>"  class="">Review</a>
                </td>

                </tr>


<?php
        }


  }
  
?>
</tbody>
</table>
</div>
<?php


  }
?>

  

    <div class="container-fluid mt--6">
      
       
      
        </div>
      </div>
      <!-- Footer -->
      <footer class="footer pt-0">
        <div class="row align-items-center justify-content-lg-between">
          <div class="col-lg-6">
            
          </div>
          <div class="col-lg-6">
            
          </div>
        </div>
      </footer>
    </div>
  </div>
  <!-- Argon Scripts -->
  <!-- Core -->
   <script src="assets/vendor/jquery/dist/jquery.min.js"></script>
  <script src="assets/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/js-cookie/js.cookie.js"></script>
  <script src="assets/vendor/jquery.scrollbar/jquery.scrollbar.min.js"></script>
  <script src="assets/vendor/jquery-scroll-lock/dist/jquery-scrollLock.min.js"></script>
  <!-- Optional JS -->
  <script src="assets/vendor/chart.js/dist/Chart.min.js"></script>
  <script src="assets/vendor/chart.js/dist/Chart.extension.js"></script>
  <!-- Argon JS -->
<script src="assets/js/argon.js?v=1.2.0"></script>

  <script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
  <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
  <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.24/js/dataTables.bootstrap4.min.js"></script>
<script>
</body>

</html>