<?php 
include('includes/config.php');

?>


<?php
include('includes/user_data.php');



if(isset($_GET['del']))
{
$id=$_GET['del'];
$sql = "delete from end_term_report  WHERE id=:id";
$query = $dbh->prepare($sql);
$query -> bindParam(':id',$id, PDO::PARAM_STR);
$query -> execute();
$msg="recorde deleted  successfully";

}


?>

<?php
//error_reporting(0);
if(isset($_POST['store']))
{

$q=$_POST['Admission_no'];
$cono = mysqli_connect('localhost','stargold_staff','vEqcN.6$yF(T');
if (!$cono) {
  die('Could not connect: ' . mysqli_error($cono));
}
mysqli_select_db($cono,"stargold_staff");
$sql="SELECT * FROM students WHERE id = '".$q."'";
$result = mysqli_query($cono,$sql);

if($row = mysqli_fetch_array($result)) {
 $add_no=$row['Admission_num'];
// echo $add_no; 
}



$Teacher= $email;
//$class_id =$_POST['class_id'];
$Admission_no=$add_no; 
$mdclass=$_POST['class']; 
$session=$_POST['session'];
$term=$_POST['term']; 
$subject=$_POST['subject'];
$wk_test=$_POST['wk_test']; 
$mid_test=$_POST['mid_test'];
$total=$wk_test + $mid_test;
$comment=$_POST['comment'];





//----checking if email of user name has been used------
$query=mysqli_query($conn,"SELECT * FROM end_term_report WHERE Admission_no='$Admission_no' and classes='$mdclass' and session='$session' and term='$term' and subject='$subject'");
$num=mysqli_fetch_array($query);
if($num>0)
{
$extra="mid_term.php";
$emailform=$_POST['email'];
$host  = $_SERVER['HTTP_HOST'];
$uri  = rtrim(dirname($_SERVER['PHP_SELF']),'/\\');
echo "<script type='text/javascript'> document.location = 'https://$host$uri/$extra'; </script>";
  $_SESSION['errmsg']="this record had been saved before.";
    exit();
} 
//-- end of checking email and user name usage-----

   $query=mysqli_query($conn,"INSERT INTO `end_term_report` (`id`, `Teacher`, `Admission_no`, `classes`,`session`, `term`, `subject`, `ca_test`,`exam_score`,`total`, `comment`,`date`) VALUES (NULL, '$Teacher', '$Admission_no', '$mdclass', '$session', '$term', '$subject','$wk_test','$mid_test','$total','$comment', current_timestamp())");
        if($query)

      {$msg="succesfully Stored";
}
else {
$error="something is  wrong";  
}
}  
          ?>
<!doctype html>
<html lang="en">


<!-- Mirrored from codervent.com/rocker/demo/vertical/user-profile.html by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 26 Aug 2022 06:47:36 GMT -->
<head>
	<!-- Required meta tags -->
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!--favicon-->
	
	
	<link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet" />
	<link href="assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css" rel="stylesheet" />
	<link href="assets/plugins/metismenu/css/metisMenu.min.css" rel="stylesheet" />
	<link href="assets/plugins/datatable/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
	
	
	
	<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
	<!--plugins-->
	<link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet" />
	<link href="assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css" rel="stylesheet" />
	<link href="assets/plugins/metismenu/css/metisMenu.min.css" rel="stylesheet" />
	<!-- loader-->
	<link href="assets/css/pace.min.css" rel="stylesheet" />
	<script src="assets/js/pace.min.js"></script>
	<!-- Bootstrap CSS -->
	<link href="assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="assets/css/bootstrap-extended.css" rel="stylesheet">
	<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&amp;display=swap" rel="stylesheet">
	<link href="assets/css/app.css" rel="stylesheet">
	<link href="assets/css/icons.css" rel="stylesheet">
	<!-- Theme Style CSS -->
	<link rel="stylesheet" href="assets/css/dark-theme.css" />
	<link rel="stylesheet" href="assets/css/semi-dark.css" />
	<link rel="stylesheet" href="assets/css/header-colors.css" />
	
	<link href="assets/plugins/select2/css/select2.min.css" rel="stylesheet" />
	<link href="assets/plugins/select2/css/select2-bootstrap4.css" rel="stylesheet" />
	
	
	
	

	<title> Stargold College</title>
	
	
	
	<script>
	function showUser(str) {
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
    return;
  } else {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
        document.getElementById("txtHint").innerHTML = this.responseText;
      }
    };
    xmlhttp.open("GET","get_exam_sub.php?q="+str,true);
    xmlhttp.send();
  }
}
</script>
</head>

<body>
	<!--wrapper-->
	<div class="wrapper">
		<!--sidebar wrapper -->
		<?php include 'includes/side.php'; ?>
		<!--end sidebar wrapper -->
		<!--start header -->
		<?php include 'includes/head.php'; ?>
		<!--end header -->
		<!--start page wrapper -->
	
      
      
                
                <!--start page wrapper -->
		<div class="page-wrapper">
			<div class="page-content">
			    
			    <div class="row">
      <div class="col-md-3 col-sm-0">
        
      </div>
      
      <div class="col-md-6 col-sm-8">
        <div class="profile_wrap" style="  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
 border-radius: 20px; padding: 10px; margin-top:5%; ">
<!--<form name="chngpwd" method="post" >-->
        
            <div class="gray-bg field-title">
              <h6 class="text-center">     Record Exam and C.A</h6>
            </div>


								<div class="alert alert-success border-0 bg-success alert-dismissible fade show py-2">
									<div class="d-flex align-items-center">
										<div class="font-35 text-white"><i class='bx bxs-check-circle'></i>
										</div>
										<div class="ms-3">
											<h6 class="mb-0 text-white"> Info</h6>
											<div class="text-white"><?php if(($error !='') or ($_SESSION['errmsg']!='')){?><div class="errorWrap" style="color:red;"><strong>ERROR</strong>:<?php echo htmlentities($error); ?><?php echo $_SESSION['errmsg']; $_SESSION['errmsg']=''; ?> </div><?php } 
        else if($msg){?><div class="succWrap"><strong>SUCCESS</strong>:<?php echo htmlentities($msg); ?> </div><?php }?></div>
										</div>
									</div>
									<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
								</div>






             
           	<div class="form-body">
										<form class="row g-3" action="" method="post" enctype="multipart/form-data">
										    
										  
											<div class="col-12">
												<label for="inputSelectCountry" class="form-label">Admission No</label>
												<select class="single-select" name="Admission_no"  id="Admission_no" onchange="showUser(this.value)"> 
												<option value="" ></option>
												<option value="0" > yes</option>
												
												
					<?php $sql = "SELECT * from students ORDER BY id"; 
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{ 
foreach($results as $result)
{				?> 
												 <option value="<?php echo htmlentities($result->id);?>"><?php echo htmlentities($result->Admission_num);?> : <?php echo htmlentities($result->name);?></option>
												 
												 
										<?php $cnt=$cnt+1; }} ?>
										
										
                                    
												</select>
											</div>
											
										<br>
<div class="class-12" id="txtHint"><b>Person info will be listed here...</b></div>
	

											<div class="col-6">
												<label for="inputSelectCountry" class="form-label">Class</label>
												<select class="form-select" id="inputSelectCountry" aria-label="Default select example" name="class">  
					<?php $sql = "SELECT DISTINCT class_id from students"; 
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{				?>
												 <option value="<?php echo htmlentities($result->class_id);?>"><?php echo htmlentities($result->class_id);?></option>
												 
												 
										<?php $cnt=$cnt+1; }} ?>
										
										
                                    
												</select>
											</div>
											
											
											<div class="col-6">
												<label for="inputSelectCountry" class="form-label">Session</label>
												<select class="form-select" id="inputSelectCountry" aria-label="Default select example" name="session">  
					<?php $sql = "SELECT * from sessions"; 
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{				?>
												 <option value="<?php echo htmlentities($result->session_year);?>"><?php echo htmlentities($result->session_year);?></option>
												 
												 
										<?php $cnt=$cnt+1; }} ?>
										
										
                                    
												</select>
											</div>
											
											
											<div class="col-6">
												<label for="inputSelectCountry" class="form-label">Term</label>
												<select class="form-select" id="inputSelectCountry" aria-label="Default select example" name="term">  
					<?php $sql = "SELECT * from terms"; 
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{				?>
												 <option value="<?php echo htmlentities($result->term_name);?>"><?php echo htmlentities($result->term_name);?></option>
												 
												 
										<?php $cnt=$cnt+1; }} ?>
										
										
                                    
												</select>
											</div>
											
											
											<div class="col-6">
												<label for="inputSelectCountry" class="form-label">Subject</label>
												<select class="single-select" id="inputSelectCountry" aria-label="Default select example" name="subject">  
					<?php $sql = "SELECT * from Subjects"; 
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{				?>
												 <option value="<?php echo htmlentities($result->name);?>"><?php echo htmlentities($result->name);?></option>
												 
												 
										<?php $cnt=$cnt+1; }} ?>
										
										
                                    
												</select>
											</div>
											
											
											
											<div class="col-6">
												<label for="inputEmailAddress" class="form-label">Bonus (10) </label>
												<input type="text" name="wk_test" placeholder="Bonus " class="form-control">
											</div>
											
												<div class="col-6">
												<label for="inputEmailAddress" class="form-label">Exam Score (50) </label>
												<input type="text" name="mid_test" placeholder="exam score  " class="form-control">
											</div>
											
											
											<div class="col-12">
												<label for="inputEmailAddress" class="form-label">Teachers Comment </label>
												<input type="text" name="comment" placeholder="Teachers Comment " class="form-control">
											</div>
									
											<div class="col-12">
												<div class="form-check form-switch">
													<input class="form-check-input" type="checkbox" id="flexSwitchCheckChecked">
													<label class="form-check-label" for="flexSwitchCheckChecked">I read and agree to Terms & Conditions</label>
												</div>
											</div>
											<div class="col-12">
												<div class="d-grid">
													<button type="submit" name='store' class="btn btn-primary"><i class='bx bx-user'></i>Store</button>
												</div>
											</div>
										</form>
								 
									</div>
        </div>
      </div>
    </div>
</div>
			    
			    
			    
				<!--breadcrumb-->
				<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
					<div class="breadcrumb-title pe-3">Tables</div>
					<div class="ps-3">
						<nav aria-label="breadcrumb">
							<ol class="breadcrumb mb-0 p-0">
								<li class="breadcrumb-item"><a href="javascript:;"><i class="bx bx-home-alt"></i></a>
								</li>
								<li class="breadcrumb-item active" aria-current="page">Data Table</li>
							</ol>
						</nav>
					</div>
					<div class="ms-auto">
						<div class="btn-group">
							<button type="button" class="btn btn-primary">Settings</button>
							<button type="button" class="btn btn-primary split-bg-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown">	<span class="visually-hidden">Toggle Dropdown</span>
							</button>
							<div class="dropdown-menu dropdown-menu-right dropdown-menu-lg-end">	<a class="dropdown-item" href="javascript:;">Action</a>
								<a class="dropdown-item" href="javascript:;">Another action</a>
								<a class="dropdown-item" href="javascript:;">Something else here</a>
								<div class="dropdown-divider"></div>	<a class="dropdown-item" href="javascript:;">Separated link</a>
							</div>
						</div>
					</div>
				</div>
				<!--end breadcrumb-->
				<!--<h6 class="mb-0 text-uppercase">DataTable Example</h6>-->
				<hr/>
				
				<h6 class="mb-0 text-uppercase">Student list</h6>
				<hr/>
				<div class="card">
					<div class="card-body">
						<div class="table-responsive">
							<table id="example2" class="table table-striped table-bordered">
								<thead>
									<tr>
									    <th>#</th>
										<th>Admission No</th>
										<th>class</th>
										<th>session</th>
										<th>term</th>
										<th>subject</th>
										<th>wk test</th>
										<th>mid test</th>
										<th>Total</th>
										<th>Comment</th>
										<th>Action</th>
									</tr>
								</thead>
								
								<tbody>
								    
		<?php $sql = "SELECT * from end_term_report where Teacher='$email'";
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{				?>
									<tr>
										<td><?php echo htmlentities($cnt);?></td>
										<td><?php echo htmlentities($result->Admission_no);?></td>
										<td><?php echo htmlentities($result->classes);?></td>
										<td><?php echo htmlentities($result->session);?></td>
										<td><?php echo htmlentities($result->term);?></td>
										<td><?php echo htmlentities($result->subject);?></td>
										<td><?php echo htmlentities($result->ca_test);?></td>
										<td><?php echo htmlentities($result->exam_score);?></td>
										<td><?php echo htmlentities($result->total);?></td>
											<td><?php echo htmlentities($result->comment);?></td>
										
								
	
		    
	
		<td><a href="end_of_term.php?del=<?php echo $result->id;?>" onclick="return confirm('Do you want to delete');"><i class="text-primary" data-feather="trash-2"></i> Delete </a></td>
		    
		    
										</tr>
										<?php $cnt=$cnt+1; }} ?>
								</tbody>
								<tfoot>
									<tr>
										<th>#</th>
										<th>Admission No</th>
										<th>class</th>
										<th>session</th>
										<th>term</th>
										<th>subject</th>
										<th>wk test</th>
										<th>mid test</th>
										<th>Total</th>
										<th>Comment</th>
										<th>Action</th>
									</tr>
								</tfoot>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--end page wrapper -->
      
      
      
      
      
      
       
		<!--end page wrapper -->
		<!--start overlay-->
		<div class="overlay toggle-icon"></div>
		<!--end overlay-->
		<!--Start Back To Top Button--> <a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
		<!--End Back To Top Button-->
		<footer class="page-footer">
			<p class="mb-0">Copyright © 2021. All right reserved.</p>
		</footer>
	</div>
	<!--end wrapper-->
	<!--start switcher-->
	<?php include 'includes/customiser.php'; ?>

	<!--end switcher-->
	<!-- Bootstrap JS -->
	<script src="assets/js/bootstrap.bundle.min.js"></script>
	<!--plugins-->
	<script src="assets/js/jquery.min.js"></script>
	<script src="assets/plugins/simplebar/js/simplebar.min.js"></script>
	<script src="assets/plugins/metismenu/js/metisMenu.min.js"></script>
	<script src="assets/plugins/perfect-scrollbar/js/perfect-scrollbar.js"></script>
	<script src="assets/plugins/perfect-scrollbar/js/perfect-scrollbar.js"></script>
	<script src="assets/plugins/datatable/js/jquery.dataTables.min.js"></script>
	<script src="assets/plugins/datatable/js/dataTables.bootstrap5.min.js"></script>
	<!--app JS-->
	<script src="assets/js/app.js"></script>
	<script>
		$(document).ready(function() {
			$('#example').DataTable();
		  } );
	</script>
	<script>
		$(document).ready(function() {
			var table = $('#example2').DataTable( {
				lengthChange: false,
				buttons: [ 'copy', 'excel', 'pdf', 'print']
			} );
		 
			table.buttons().container()
				.appendTo( '#example2_wrapper .col-md-6:eq(0)' );
		} );
	</script>
	<script src="assets/plugins/select2/js/select2.min.js"></script>
	<script>
		$('.single-select').select2({
			theme: 'bootstrap4',
			width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style',
			placeholder: $(this).data('placeholder'),
			allowClear: Boolean($(this).data('allow-clear')),
		});
		$('.multiple-select').select2({
			theme: 'bootstrap4',
			width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style',
			placeholder: $(this).data('placeholder'),
			allowClear: Boolean($(this).data('allow-clear')),
		});
	</script>
</body>


<!-- Mirrored from codervent.com/rocker/demo/vertical/user-profile.html by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 26 Aug 2022 06:47:36 GMT -->
</html>
      