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

//role("dos,hmp");

?>

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

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

   <?php

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

$cid=$_POST["cid"];

$schoolclass=$_POST["schoolclass"];

$schoolyear=$_POST["schoolyear"];

$schoolterm=$_POST["schoolterm"]; 

$result_scrap=$dbh->query("select * from scrap where type='secsuba'");

$row_scrap=$result_scrap->fetchObject();

$count_scrap=$result_scrap->rowCount();



do{ 

if(isset($_POST["sub".$row_scrap->item])){$value_out="0"; $gval="x";}else{$value_out="N"; $gval="";}

$rolenumber=$_SESSION["rolenumber"];

$sub_out=$row_scrap->item."m";

$gsub=$row_scrap->item."g";



$update_citadel=$dbh->prepare("update citadel_a set $sub_out='$value_out', lastedittedby='$rolenumber' where cid='$cid'");

$update_citadel->execute();



$update_rivendell=$dbh->prepare("update rivendell set $sub_out='$value_out', $gsub='$gval' where cid='$cid' and schoolclass='$schoolclass' and term='$schoolterm' and schoolyear='$schoolyear' and ($sub_out='N' or $sub_out='0')");

$update_rivendell->execute();



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



header("location:studentlist_a.php");

}

    ?>



<form method='post'>

<div class='panel panel-green'><!--Initiative-->

<div class='panel-heading'><h3 class='panel-title'>A-Level subjects</h3></div>

<div class='panel-body'>



                              <?php

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

$cid=$_GET["cid"];     

$schoolclass=$_GET["sc"];

$schoolyear=$_GET["sy"];

$schoolterm=$_GET["st"];                  

$result_scrap=$dbh->query("select * from scrap where type='secsuba'");

$row_scrap=$result_scrap->fetchObject();

$count_scrap=$result_scrap->rowCount();                               



if($count_scrap>0){

echo "

<input type='hidden' name='cid' value='".$cid."'>

<input type='hidden' name='schoolclass' value='".$schoolclass."'>

<input type='hidden' name='schoolyear' value='".$schoolyear."'>

<input type='hidden' name='schoolterm' value='".$schoolterm."'>";



  do{

$fsub=$row_scrap->item."m";



$result_citadel=$dbh->query("select * from citadel_a where $fsub!='N' and cid='$cid'");

$count_citadel=$result_citadel->rowCount();



if($count_citadel>0){$checker="checked";}else{$checker="";}



echo "<div class='col-lg-2'><input type='checkbox' name='sub".$row_scrap->item."' value='".$row_scrap->item."' ".$checker."> ".$row_scrap->item2." ".substr($row_scrap->item,6,1)."</div>";

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

}else{

  echo "Please contact your IT department.";

}

?>



</div></div>

</div>

<div style='float:right;' class='col-lg-1'><input type='submit' class='btn btn-sm btn-primary' name='submit_subjects' value='Submit'></div>

</form>



</div>



</form>



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

