<?php include ("kfunctions.php");
//role("dos,hmp");
?>
<html>
<head>
<?php kheader(); ?>
<?php 
require_once("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"];
 $result_scrap=$dbh->query("select * from scrap where type='prisubps' or type='secsub' or type='prisubp'");
               $row_scrap=$result_scrap->fetchObject();
               $count_scrap=$result_scrap->rowCount();
do{ 
if(isset($_POST["sub".$row_scrap->item])){
  $subject=$_POST["sub".$row_scrap->item];
  $value_out="0";
}else{
  $subject=$row_scrap->item;
  $value_out="N";
}
$rolenumber=$_SESSION["rolenumber"];
$sub_out=$subject."marks";
$update_citadel=$dbh->query("update citadel set $sub_out='$value_out',lastedittedby='$rolenumber' where cid='$cid'");
}while( $row_scrap=$result_scrap->fetchObject()); 

echo "<div class='alert alert-success'>Success: Subjects have been successfully updated. </div>";   
}
    ?>

<form method='post'>
<div class='panel panel-green'><!--Initiative-->
<div class='panel-heading'><h3 class='panel-title'>List of subjects</h3></div>
<div class='panel-body'>

                              <?php
include("connect.php");  
$cid=$_GET["cid"];                      
$result_scrap=$dbh->query("select * from scrap where type='prisubps' or type='secsub' or type='prisubp'");
               $row_scrap=$result_scrap->fetchObject();
               $count_scrap=$result_scrap->rowCount();                               

if($count_scrap>0){
echo "<input type='hidden' name='cid' value='".$cid."'>";
  do{
$fsub=$row_scrap->item."marks";
$result_citadel=$dbh->query("select * from citadel where $fsub='0' 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."</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>
