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

<html>

<head>

<?php kheader(); ?>

<?php 

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



?>

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

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

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

<style>

.reptit{

color:#0066cc;

border: 2px solid black;

border-collapse: collapse;



}





</style>

</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">

                    

                           <form method='post'>



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

<select class='form-control' name='setid' required>

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

  <?php

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

$rolenumber=$_SESSION["rolenumber"];

$result_setname = $dbh->query("select * from examsets where ouruser like '%$role%'");

$row_setname = $result_setname->fetchObject();

$count_setname = $result_setname->rowCount();

if($count_setname>0){

do{

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

}while($row_setname = $result_setname->fetchObject());

}else{

echo "<option value=''>There is no data here so far. </option>";

}

?>

</select>

    </div>



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

<select class='form-control' name='schoolclass' required>

<option value="">Class</option>

<?php

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

$result_scrap = $dbh->query("select * from scrap where item>=25 and type='secclas'");

$row_scrap = $result_scrap->fetchObject();

$count_scrap = $result_scrap->rowCount();

if($count_scrap>0){

do{

echo "<option value='".$row_scrap->item."'>".$row_scrap->item2."</option>";

}while($row_scrap = $result_scrap->fetchObject());

}else{

echo "<option value=''>Please contact your IT department. </option>";

}

?>

</select>

</div>





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

<select class='form-control' name='astream' required>

<option value=''>Stream</option>

<option value='arts'>Arts</option>

<option value='sciences'>Sciences</option>

</select>

</div>

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

<input type='submit' name="class_filter" class='btn btn-md btn-primary' value='Filter'>

</div>



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

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

</div>

</form>

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





<?php

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

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

$schoolclass=$_POST["schoolclass"];

$setid=$_POST["setid"];







$result_kingslanding = $dbh->query("select * from kingslanding_o where setid='$setid' and schoolclass='$schoolclass' ");

$row_kingslanding = $result_kingslanding->fetchObject();

$count_kingslanding = $result_kingslanding->rowCount();



if($count_kingslanding>0){

//$result_scrap = $dbh->query("select * from scrap where item='$subjectid'");

//$row_scrap = $result_scrap->fetchObject();



$result_examsets = $dbh->query("select * from examsets where setid='$setid'");

$row_examsets = $result_examsets->fetchObject();



$result_scrapsec = $dbh->query("select * from scrap where item='$schoolclass' and (type='secclas' or type='priclas')");

$row_scrapsec = $result_scrapsec->fetchObject();



include("class.php");



}

}







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

$schoolclass=$_POST["schoolclass"];

$setid=$_POST["setid"];

$astream=$_POST["astream"];



$result_scrapsec = $dbh->query("select * from scrap where item='$schoolclass' and (type='secclas' or type='priclas')");

$row_scrapsec = $result_scrapsec->fetchObject();





//for sciences, math or physics or chemistry else its arts



if ($astream=='sciences'){

$streamselector="and (sub19_1m!='N' or sub19_2m!='N' or sub16_1m!='N' or sub17_1m!='N')";}

else{

$streamselector="and (sub19_1m='N' and sub19_2m='N' and sub16_1m='N' and sub17_1m='N')";}



//$result_scrap = $dbh->query("select * from scrap where item='$subjectid'");

//$row_scrap = $result_scrap->fetchObject();





echo "</div>



<div id='myDiv'>

<center><p style='text-align:center; font-size:40px;'><strong>CODE HIGH SCHOOL <p style='text-align:center; font-size:40px;'>EXAM MARKS SHEET for <u>".$row_scrapsec->item2." ".$astream." </strong></u><p></center>



<table border='2'>

<thead>

<tr>

<th class='reptit' style='font-size:40px !important;' rowspan='2'>No</th>

<th class='reptit' style='font-size:40px !important;' rowspan='2'>Name</th>

<th class='reptit' style='font-size:40px !important;' rowspan='2' width='3px'>GP</th>

<th class='reptit' style='font-size:40px !important;' rowspan='2' width='3px'>S/ICT</th>

<th class='reptit' style='font-size:40px !important;' rowspan='2' width='3px'>S/Math</th>

<th class='reptit' style='font-size:40px !important;' colspan='2'>Econ</th>

<th class='reptit' style='font-size:40px !important;' colspan='3'>Ent</th>

<th class='reptit' style='font-size:40px !important;' colspan='3'>Geography</th>

<th class='reptit' style='font-size:40px !important;' colspan='5'>Fine Art</th>";



if($astream=="arts"){

echo "

<th class='reptit' style='font-size:40px !important;' colspan='4'>History</th>

<th class='reptit' style='font-size:40px !important;' colspan='3'>Luganda</th>

<th class='reptit' style='font-size:40px !important;' colspan='3'>Literature</th>

<th class='reptit' style='font-size:40px !important;' colspan='4'>Divinity</th>";

}elseif($astream=="sciences"){

echo "

<th class='reptit' style='font-size:40px !important;' colspan='3'>Physics</th>

<th class='reptit' style='font-size:40px !important;' colspan='3'>Chemistry</th>

<th class='reptit' style='font-size:40px !important;' colspan='3'>Biology</th>

<th class='reptit' style='font-size:40px !important;' colspan='3'>Math</th>";}



echo "

</tr>

<tr>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th class='reptit' style='font-size:40px !important;' class='table-t'>2</th>

<th class='reptit'  style='font-size:40px !important;' class='table-t'>1</th><th class='reptit' style='font-size:40px !important;' class='table-t'>2</th><th class='reptit' style='font-size:40px !important;' class='table-t'>3</th>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th style='font-size:40px !important;' class='reptit' class='table-t'>2</th><th class='reptit' style='font-size:40px !important;' class='table-t'>3</th>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th style='font-size:40px !important;' class='reptit' class='table-t'>2</th><th class='reptit' style='font-size:40px !important;'class='table-t'>3</th><th class='reptit' style='font-size:40px !important;' class='table-t'>4</th><th class='reptit' style='font-size:40px !important;' class='table-t'>5</th>";



if($astream=="arts"){

echo "

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th class='reptit' style='font-size:40px !important;' class='table-t'>2</th><th style='font-size:40px !important;' class='reptit' class='table-t'>3</th><th class='reptit' style='font-size:40px !important;' class='table-t'>6</th>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th style='font-size:40px !important;' class='reptit' class='table-t'>2</th><th style='font-size:40px !important;' class='reptit' class='table-t'>3</th>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th style='font-size:40px !important;' class='reptit' class='table-t'>2</th><th  style='font-size:40px !important;'class='reptit' class='table-t'>3</th>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th class='reptit' style='font-size:40px !important;' class='table-t'>2</th><th class='reptit' style='font-size:40px !important;' class='table-t'>3</th><th class='reptit' style='font-size:40px !important;'class='table-t'>4</th>";

}elseif($astream=="sciences"){

echo "

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th class='reptit' style='font-size:40px !important;' class='table-t'>2</th><th class='reptit' style='font-size:40px !important;'class='table-t'>3</th>

<th class='reptit' style='font-size:40px !important;'  class='table-t'>1</th><th style='font-size:40px !important;' class='reptit' class='table-t'>2</th><th class='reptit' style='font-size:40px !important;' class='table-t'>3</th>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th style='font-size:40px !important;' class='reptit' class='table-t'>2</th><th class='reptit' style='font-size:40px !important;' class='table-t'>3</th>

<th class='reptit' style='font-size:40px !important;' class='table-t'>1</th><th style='font-size:40px !important;' class='reptit' class='table-t'>2</th>";}



echo "

</tr>

</thead>

<tbody>";



$result_kingslanding = $dbh->query("select * from rivendell where setid='$setid' and schoolclass='$schoolclass' $streamselector and active='1' order by cid asc");

$row_kingslanding = $result_kingslanding->fetchObject();

$count_kingslanding = $result_kingslanding->rowCount();



if($count_kingslanding>0){

    $y=1;

do{



$result_child = $dbh->query("select * from children where cid='$row_kingslanding->cid'");

$row_child = $result_child->fetchObject();



echo "

<tr style='border-style:solid;'>

<td  style='font-size:30px !important;' class='reptit'>".$y++."</td>

<td style='font-size:40px !important;'>".$row_kingslanding->cid." -<br> ".ucwords(strtolower($row_child->fname))." ".ucwords(strtolower($row_child->sname))."</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>";



if($astream=="arts"){

echo "

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>";

}elseif($astream=="sciences"){

    echo "

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>

<td class='reptit' style='padding-top:80px;'>..................</td>";}



echo "</tr>";

}while($row_kingslanding = $result_kingslanding->fetchObject());

}else{

    echo "

<tr>

<td colspan='30' align='center'><i><b>There is NO data in the table so far.</b></i> </td>

</tr>";

}



echo "

</tbody>

</table>

</div>";

}else{

    echo "<div class='col-lg-12'><div class='alert alert-success'>Select the fields above</div></div>";

}

?>

</div></div>

</div>

                </div>

                <!-- /.row -->



               



            </div>

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

<?php useractivity("on page", "56"); ?>

        </div>

        <!-- /#page-wrapper -->



    </div>

    <!-- /#wrapper -->



    <!-- 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>

    <script type="text/javascript" src="../js/jquery-1.8.3.min.js" charset="UTF-8"></script>

</body>



</html>

