<?php include ("../core/kfunctions.php");

//include ("seredirect.php");

?>

<html>

<head>

<?php kheader(); ?>

<?php 

require_once("../core/connect.php");

$result=$dbh->query("select * from scrap");



?>

<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">



<script src="js/sorttable.js"></script>

<script src="js/printreport.js"></script>

</head>

<body>



    <div id="wrapper">



        <!-- Navigation -->

        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">

            <!-- Brand and toggle get grouped for better mobile display -->

            <?php ktopbar(); ?>

            <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->

            <?php kleftbar(); ?>

            <!-- /.navbar-collapse -->

        </nav>



        <div id="page-wrapper">



            <div class="container-fluid">



                <!-- Page Heading -->

                <div class="row">

                    <div class="col-lg-12">

                        <h1 class="page-header">

                           Missing marks

                        </h1>

                        

                    </div>

                </div>

                <!-- /.row -->



                <div class="row">

<form method='post'>

<div class='col-lg-2'>

<select class='form-control' name='examset' onchange='this.form.submit()'>

<option value=''>Set</option>

<?php 

include("../core/connect.php");

$result_exam=$dbh->prepare("select * from examsets where setid!=''");

$result_exam->execute();

$row_exam=$result_exam->fetchObject();

$count_exam=$result_exam->rowCount();



if($count_exam>0){

do{

echo "<option value='".$row_exam->setid."'>".$row_exam->setname."</option>";

}while($row_exam=$result_exam->fetchObject());

}else{

    echo "<option value=''>So far, there is NO set. </option>";

}

?>

</select>

</form>

</div>   

<div style="float:right;" class='col-lg-2'>

<input type="button" value="Print table" style="float:right;"  class="btn btn-sm btn-info" onclick="PrintDiv('myDiv')" />

</div>



<div id='myDiv'>

<div class='col-lg-12'><br></div>

<div class='col-lg-12'>                         

<div class="panel panel-yellow"><!--Initiative-->

<div class="panel-heading"><h3 class="panel-title">Missing marks - O level</h3></div>

<div class="panel-body">

<?php

if(isset($_POST["examset"])){

$examset=$_POST["examset"];





echo "<table class='table table-bordered table-hover table-striped sortable'>

<tr>

<th>No</th>

<th>Class</th>

<th>Subject</th>

<th>Student names</th>

</tr>";

include("../core/connect.php");

$result_scrapdis=$dbh->prepare("select distinct(item),item2 from scrap where type='secsub' or type='prisubp' or type='prisubps'");

$result_scrapdis->execute();

$row_scrapdis=$result_scrapdis->fetchObject();

$count_scrapdis=$result_scrapdis->rowCount();



if($count_scrapdis>0){

    $x=1;

do{

$gsub=$row_scrapdis->item."grade";

$fsub=$row_scrapdis->item."marks";



$result_rivex=$dbh->prepare("select distinct(schoolclass),stream from kingslanding_o where ($fsub='0' && $gsub='') && $fsub!='N' and setid='$examset' and active='1'");

$result_rivex->execute();

$row_rivex=$result_rivex->fetchObject();

$count_rivex=$result_rivex->rowCount();



if($count_rivex>0){

do{

$result_rivex2=$dbh->prepare("select * from kingslanding_o where ($fsub='0' && $gsub='') && $fsub!='N' and active='1' and schoolclass='$row_rivex->schoolclass' and stream='$row_rivex->stream'");

$result_rivex2->execute();

$row_rivex2=$result_rivex2->fetchObject();

$count_rivex2=$result_rivex2->rowCount();



$schoolclass=$row_rivex->schoolclass;   

include("class.php");



echo "<tr>

<td>".$x++."</td>

<td>".$daclass." ".$row_rivex->stream."</td>

<td>".$row_scrapdis->item2."</td>

<td>".$count_rivex2."</td>

</tr>";



    }while($row_rivex=$result_rivex->fetchObject());

}



}while($row_scrapdis=$result_scrapdis->fetchObject());

}





echo "</table>";

}



 ?>





</div></div>

</div>

</div>

</div>

                           

               



            </div>

            <!-- /.container-fluid -->



       

    <!-- jQuery -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>



    <!-- Bootstrap Core JavaScript -->

    <script src="js/bootstrap.min.js"></script>

</body>



</html>

