<?php session_start() ?>

<!DOCTYPE html>

<!--[if IE 8]>			<html class="ie ie8"> <![endif]-->

<!--[if IE 9]>			<html class="ie ie9"> <![endif]-->

<!--[if gt IE 9]><!-->	<html><!--<![endif]-->



<!-- Specific Page Data -->



<!-- End of Data -->



<?php include('hhead.html'); ?>

  

  

  

  <?php

    function do_alert($msg) 

    {

        echo '<script type="text/javascript">alert("' . $msg . '") 

           parent.location="portal.html";



</script>';

       

    }

?>

<?php

$tyr=$_SESSION['num'];



//make the database connection

include('config.php');

$sql = "select * from access where userid = '$tyr' ";

 $data = mysqli_query($conn,$sql);



$rows = mysqli_num_rows($data);



if($rows <= 0){

   do_alert("user does not exist contact system admin");

}

else{



while($row= mysqli_fetch_array($data))

{



$serial=  $row['name'];

 $input= $row['userid'];

$class=  $row['class'];

 $arm= $row['arm'];

 $email= $row['date'];

$clay="$class$arm";

$dfrd="subjects";

$sdc="$clay$dfrd";

$_SESSION['name']=$serial;

$claff=$clay;

$_SESSION['num']=$input;

$_SESSION['clay']=$clay;

$_SESSION['email']=$email;

$_SESSION['sdz']=$sdc;



}



}



$ubjects="subjects";

$sdc="$clay$ubjects";



$sdc=strtolower($sdc);

$_SESSION['subb']=$sdc;

$sql = "select subjects,class,type

 from `subjects` where staffid='$tyr' ";

 $data = mysqli_query($conn,$sql);







$rows4 = mysqli_num_rows($data);



$lcclass=strtolower($clay);

$_SESSION['lclay']=$lcclass;



$sql = "select * from `beva1` where password='$lcclass' ";

 $data = mysqli_query($conn,$sql);







$rows44 = mysqli_num_rows($data);



// Above will output ---- > testValue 











$sql = "SELECT MAX(serialno) AS maxid FROM subjects ";

          

          $data = mysqli_query($conn,$sql);

    $result = mysqli_fetch_assoc($data);



          





$pe=  $result['maxid'];





$se= $pe + 1;



$eer=$_SESSION['num'];

$obo10=$eer;



$sql = "SELECT MAX(extime) AS maxidi FROM `t_$obo10`";

          

 $result1i = mysqli_query($conn,$sql);

$resulto = mysqli_fetch_assoc($result1i);



          









          

$rows1=  $resulto['maxidi'];



$tpe=  $rows1 + 1;













	



$sct="TERM EXAMINATION";

$aas="$class$arm";

$asut="subjects";

















?>



  

  

  <style>



h1 {

  line-height:0.7em;

}

img.alignleft {

	

	float: left;

margin: 0px 320px;

border:4px solid #1fae66;

}



img.alignleft1 {

	

	float: right;

margin: -450px 20px;

border:4px solid black;

}



</style>

  

  <?php

$stu=$_POST['idty'];

$tyr=$_SESSION['num'];

$_SESSION['numi']=$stu;



echo $stu;



//make the database connection

include('config.php');

$sql = "select * from `$sdc` where subjects = '$stu'  ";

$data = $conn->query($sql); 



$rows = mysqli_num_rows($data);

while($row = $data->fetch_assoc())

{



$ssubj=  $row['subjects'];

 

 

$clafg="$class$arm";





$clafg=strtolower($clafg);

$_SESSION['class']=$clafg;

$_SESSION['sub']=$ssubj;

}



$sql = "select * from `beva1` where regno= '$stu'";

$data = $conn->query($sql); 



$rows = mysqli_num_rows($data);













$sql = "UPDATE `$clafg` set tot=(code+d2+d3+ex)";

					$data = $conn->query($sql);



?>

<script>

	function showEdit(editableObj) {

		$(editableObj).css("background","#FF0");

	} 

	

	function saveToDatabase(editableObj,column,id) {

		$(editableObj).css("background","#009933 url(loaderIcon.gif) no-repeat right");

		$.ajax({

			url: "saveedit.php",

			type: "POST",

			data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,

			success: function(data){

				$(editableObj).css("background","#DDD");

			}        

	   });

	}

	</script>



  

  	<link rel="stylesheet" type="text/css" href="datatables.min.css">

  

  

  

  

  

  

  

<div class="content">

  <div class="container">

   <?php include('nav.html'); ?>  

    <!-- Middle Content Start -->

    

	

	

	

	

	

	

    <div class="vd_content-wrapper">

      <div class="vd_container">

        <div class="vd_content clearfix">

          <div class="vd_head-section clearfix">

            <div class="vd_panel-header">

              <ul class="breadcrumb">

                <li><a href="index.html">Home</a> </li>

                <li class="active">Add Scores</li>

              </ul>

              <div class="vd_panel-menu hidden-sm hidden-xs" data-intro="<strong>Expand Control</strong><br/>To expand content page horizontally, vertically, or Both. If you just need one button just simply remove the other button code." data-step=5  data-position="left">

    <div data-action="remove-navbar" data-original-title="Remove Navigation Bar Toggle" data-toggle="tooltip" data-placement="bottom" class="remove-navbar-button menu"> <i class="fa fa-arrows-h"></i> </div>

      <div data-action="remove-header" data-original-title="Remove Top Menu Toggle" data-toggle="tooltip" data-placement="bottom" class="remove-header-button menu"> <i class="fa fa-arrows-v"></i> </div>

      <div data-action="fullscreen" data-original-title="Remove Navigation Bar and Top Menu Toggle" data-toggle="tooltip" data-placement="bottom" class="fullscreen-button menu"> <i class="glyphicon glyphicon-fullscreen"></i> </div>

      

</div>

 

            </div>

          </div>

          <!-- vd_head-section -->

          

         

          <!-- vd_title-section -->

          

          <div class="vd_content-section clearfix">

            

            

              <!-- .col-md-4 --> 

            </div>

			

			<div class="row" id="form-basic">

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

                <div class="panel widget">

                  <div class="panel-heading vd_bg-grey">

                    <h3 class="panel-title"> <span class="menu-icon"> <i class="fa fa-bar-chart-o"></i> </span> Enter Scores</h3>

                  </div>

                  <div class="panel-body">

                    <form class="form-horizontal"  action="caai.php" method="POST" role="form">

                     

                     

                      

                      <div class="form-group">

                        <label class="col-sm-4 control-label">Select Subjects</label>

                        <div class="col-sm-7 controls">

                        

						  

									  

						 <?php

$sql = ("select * from `$sdc` ") ;

$result = $conn->query($sql);// Run your query



echo '<select name="idty" >'; // Open your drop down box



// Loop through the query results, outputing the options one by one

while($row = $result->fetch_assoc()) {

  echo '<option value="'.$row['subjects'].'">'.$row['subjects'].'</option>';

}



echo '</select>';// 



?>              </div>

                      </div>

					  

                    

                      <div class="form-group form-actions">

                        <div class="col-sm-4"> </div>

                        <div class="col-sm-8">

                          <button class="btn vd_btn vd_bg-green vd_white" type="submit"><i class="icon-ok"></i> Search</button>

                     

                        </div>

                      </div>

					  

					  <div class="row">

			<div class="panel widget">

					 <div class="col-md-6">

					<b>CLASS : <h4><font color=#1fae66 ><b><? echo $class; ?>   <?php echo $arm; ?></b></h4></b></font></BR>



</div>

 <div class="col-md-6 ">

<h4><font color=#111>SUBJECT :</FONT><b><font color=#1fae66 green><?php echo  $ssubj; ?></b></font></h4>

</div>

</br></div></div>

                    </form>

					

					 <form class="form-horizontal"  action="downn.php" method="POST" role="form">

                     

                     

                      

                    

                      <div class="form-group form-actions">

                        

                        <div class="col-sm-8">

                          <button class="btn vd_btn vd_bg-green vd_white" type="submit"><i class="icon-ok"></i> Download Sheet</button>

                     

                        </div>

						<div class="col-sm-4"> </div>

                      </div>

					  

				

                    </form>

					 

                  </div>

                </div>

				

                <!-- Panel Widget --> 

              </div>

              <!-- col-md-12 --> 

            </div>

			

			

            <div class="row">

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

                <div class="panel widget">

                  <div class="panel-body-list  table-responsive">

                    <table class="table no-head-border table-striped">

                      <thead class="vd_bg-blue vd_white">

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

		

		

					<?php

					$ass1="code";

					$ass2="weeklytest";

					$ass3="subject1";

					$ass4="cod";

					$ass5="week1";

					$ass6="d1";

					$ass7="d2";

					$ass8="d3";

						$ass9="d4";

					$ass10="ex";

				

		$subj="";

					

							

					

						require_once("dbcontroller.php");

						$db_handle = new DBController();

						$sql = "SELECT REGNO,Name,Subjects,code,weeklytest,subject1,cod,week1,d1,d2,d3,d4,ex,tot as total from $clafg WHERE Subjects='$ssubj' order by Name";

						$faq = $db_handle->runQuery($sql);

						

			

						

						echo "

						<div id='ajaxDiv'><H3>".$subj." ".$subj.'</H3></div>

						<table align="center" class="table table-striped table-bordered">

								  <thead>

									  <tr>

										<th class="table-header"  width="20%">NAME </th>

										<th class="table-header"  width="20%">SUBJECT</th>

										<th class="table-header" width="10%">HOMEWORK</th>

											<th class="table-header" width="10%">CLASSWORK</th>

										<th class="table-header" width="10%">TEST</th>

										<th class="table-header" width="10%">EXAM</th>

										<th class="table-header" width="10%">TOTAL </th>

									

									

									

							

									  </tr>

								  </thead>

								  <tbody>';

								 

								  foreach($faq as $k=>$v) {

								 echo '

									  <tr class="table-row">

										<td><b>'.$faq[$k]["Name"].'</b></td>

										<td>'.$faq[$k]["Subjects"].'</td>

										<td align="center" contenteditable="true" onBlur=';

										echo '"saveToDatabase(this,'."'".$ass1."','".$faq[$k]["REGNO"]."'".');"  onClick="showEdit(this);">'.$faq[$k][$ass1].'</td> 

										

										<td align="center" contenteditable="true" onBlur=';

										echo '"saveToDatabase(this,'."'".$ass7."','".$faq[$k]["REGNO"]."'".');"  onClick="showEdit(this);">'.$faq[$k][$ass7].'</td> 

										

										<td align="center" contenteditable="true" onBlur=';

										echo '"saveToDatabase(this,'."'".$ass8."','".$faq[$k]["REGNO"]."'".');"  onClick="showEdit(this);">'.$faq[$k][$ass8].'</td> 

										

										<td align="center" contenteditable="true" onBlur=';

										echo '"saveToDatabase(this,'."'".$ass10."','".$faq[$k]["REGNO"]."'".');"  onClick="showEdit(this);">'.$faq[$k][$ass10].'</td> 

										

											<td>'.$faq[$k]["total"].'</td>

									 

								</tr>';

								}

						 

								?>

								  </tbody>

								</table>   

				</div>

			</div>

                <div class="panel widget">

                  <div class="panel-body-list  table-responsive">

                    

                  </div>

                </div>

              </div>

              <!-- col-md-6 --> 

            

              <!-- col-md-6 -->

              

            </div>

            <!-- .row --> 

          </div>

          <!-- .vd_content-section --> 

          

        </div>

        <!-- .vd_content --> 

      </div>



























</div>









<?php include('footer2.php'); ?>





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

<script src="js/js/jquery-3.1.1.js"></script>

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

<script src="js/js/jquery.easing.1.3.js"></script>

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

<script src="js/js/jquery.fancybox.pack.js"></script>

<script src="js/js/jquery.fancybox-media.js"></script>  

<script src="js/js/jquery.flexslider.js"></script>

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

<!-- Vendor Scripts -->

<script src="js/js/modernizr.custom.js"></script>

<script src="js/js/jquery.isotope.min.js"></script>

<script src="js/js/jquery.magnific-popup.min.js"></script>

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

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