<?php
	require_once('source/session.php');
	require_once('source/error.php');
	require_once('source/dbconfig.php');
	require_once('source/function.php');
	require_once('source/restrict_user.php');
	
	if($_GET['msg'] == "refered"){
		$msg = "<h5 class='alert alert-success'>Refered successfully</h5>";
	}else if($_GET['msg'] == "failed"){
		$msg = "<h5 class='alert alert-warning'>Something went wrong, please try again</h5>";
	}
	
	if($_SESSION['msg'] == "update")
	{
		$msg = "<h5 class='alert alert-success text-center'>Order Update Succesful. Customer will receive email.<a 
		class='btn-sm' href='new_order.php'>Refresh</a></h5>";
	}       
	          
	      
                    $rows1 = sql($DBH, "SELECT * FROM attendance where csv_no = ?", 
            	array($_GET['val']), "rows");
		foreach($rows1 as $row1)
		{	
			$u_name	 		= $row1['name'];
			$u_registration_no 		= $row1['registration_no'];
			$Handwriting 			= $row1['Handwriting'];
			$Fluency 			= $row1['Fluency'];
			$Games 			= $row1['Games'];
			$HandlingTools 			= $row1['HandlingTools'];
			$Drawing 			= $row1['Drawing'];
			$Creativity 			= $row1['Creativity'];
			$Musicalattendance 			= $row1['Musicalattendance'];			
			$Punctuality 			= $row1['Punctuality'];			
			$AttentivenessToClass 			= $row1['AttentivenessToClass'];			
			$Reliability 			= $row1['Reliability'];			
			$Neatness 			= $row1['Neatness'];			
			$Politeness 			= $row1['Politeness'];			
			$Honesty 			= $row1['Honesty'];			
			$Obedience 			= $row1['Obedience'];			
			$RelationshipWithOthers 			= $row1['RelationshipWithOthers'];			
			$SelfControl 			= $row1['SelfControl'];			
			$Attentiveness 			= $row1['Attentiveness'];			
			$Initiative 			= $row1['Initiative'];			
			$OrganizationalAbility 			= $row1['OrganizationalAbility'];			
			$Perseverance 			= $row1['Perseverance'];			
			$us_class			= $row1['class'];
			$us_year			= $row1['year'];
			$us_term			= $row1['term'];			




			sql($DBH, "UPDATE attendance set total = ?, teacher_no = ? WHERE registration_no =? AND csv_no = ?", array($total,$_GET['hsh'],$u_registration_no,$_GET['val']));
			
			
                    $rows2 = sql($DBH, "SELECT * FROM attendance where csv_no = ? ORDER by (total) desc", 
            	array($_GET['val']), "rows");
            	$sno = 0;
		foreach($rows2 as $row2)
		{	
			$sno++; 
			$u_name	 		= $row2['name'];
			$u_registration_no 		= $row2['registration_no'];
			$Handwriting 			= $row2['Handwriting'];
			$Fluency 			= $row2['Fluency'];
			$Games 			= $row2['Games'];
			$HandlingTools 			= $row2['HandlingTools'];
			$Drawing 			= $row2['Drawing'];
			$Creativity 			= $row2['Creativity'];
			$Musicalattendance 			= $row2['Musicalattendance'];			
			$Punctuality 			= $row2['Punctuality'];			
			$AttentivenessToClass 			= $row['AttentivenessToClass'];			
			$Reliability 			= $row2['Reliability'];			
			$Neatness 			= $row2['Neatness'];			
			$Politeness 			= $row2['Politeness'];			
			$Honesty 			= $row2['Honesty'];			
			$Obedience 			= $row2['Obedience'];			
			$RelationshipWithOthers 			= $row2['RelationshipWithOthers'];			
			$SelfControl 			= $row2['SelfControl'];			
			$Attentiveness 			= $row2['Attentiveness'];			
			$Initiative 			= $row2['Initiative'];			
			$OrganizationalAbility 			= $row2['OrganizationalAbility'];			
			$Perseverance 			= $row2['Perseverance'];			
			$us_class			= $row2['class'];
			$us_year			= $row2['year'];
			$us_term			= $row2['term'];			
			
			if($us_total <=49){
			$grade = "Fail";
			}
			else if ($us_total >49 && $us_total<= 59)
			{
			$grade = "Fair";
			}
			else if ($us_total >59 && $us_total<= 69)
			{
			$grade = "Faily Good";
			}
			else if ($us_total >69 && $us_total<= 79)
			{
			$grade = "Good";
			}
			else if ($us_total >79 && $us_total<= 89)
			{
			$grade = "Very Good";
			}
			else if ($us_total >89 && $us_total<= 100)
			{
			$grade = "Excellent";
			}
			
			}
			}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>BRITISH LEARNERS COLLEGE, OWERRI: Upload attendance, Remarks, and Others</title>
  <!-- Bootstrap core CSS-->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom fonts for this template-->
  <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <!-- Page level plugin CSS-->
  <link href="vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
  <!-- Custom styles for this template-->
  <link href="css/sb-admin.css" rel="stylesheet">
  <link href="css/folder.css" rel="stylesheet">
  <link href="css/user_profile.css" rel="stylesheet">
  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <!-- select-->
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  
  <style type="text/css">
<!--
.style1 {color: #e6f7ff}
-->
  </style>
</head>

<body class="fixed-nav sticky-footer bg-dark" id="page-top">
  <!-- Navigation-->
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
  
<?php
            	
            	$rows = sql($DBH, "SELECT * FROM tbl_admin where status = ?", 
            	array("Active"), "rows");							
            	foreach($rows as $row)
            	{
            		$admin_name 		= $row['username'];
            	}
		
      if (isset($_SESSION['SESS_HASH_ADMIN'])) {
		$user_true 			 = "<h4 style='color: LIME'><b>BRITISH LEARNERS COLLEGE, OWERRI: Teacher Dashboard</b></h4>";
		
}
		echo "$user_true ";
?>
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
     <div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav navbar-sidenav" id="exampleAccordion">
  <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Dashboard">
    <a class="nav-link" href="main.php">
      <i class="fa fa-dashboard" style="color: #3498db"></i>
      <span class="nav-link-text" style="color: white">Teacher Dashboard</span>
    </a>
  </li>
  <!--<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Generate Score Sheet">
    <a class="nav-link" href="students.php">
      <i class="fa fa-clock-o" style="color: #3498db"></i>
      <span class="nav-link-text" style="color: white">Generate Score Sheet</span>
    </a>
  </li> -->
  <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Download Broadsheet">
    <a class="nav-link" href="download_broadsheet.php">
      <i class="fa fa-download" style="color: blue"></i>
      <span class="nav-link-text" style="color: white">Download Broadsheet</span>
    </a>
  </li>
  <!--<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Fill Attendance Sheet">
    <a class="nav-link" href="fill_attendance_sheet.php">
      <i class="fa fa-download" style="color: red"></i>
      <span class="nav-link-text" style="color: white">Download Specimen Excel Sheets</span>
    </a>
  </li> -->
  <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Upload Tests (CA 1, C.A.2, EXAM)">
    <a class="nav-link" href="upload_ca1.php">
      <i class="fa fa-upload" style="color: orange"></i>
      <span class="nav-link-text" style="color: white">Upload Tests (CA 1, CA 2, EXAM)</span>
    </a>
  </li>
    <!--<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Upload Tests (CA 2)">
    <a class="nav-link" href="upload_ca2.php">
      <i class="fa fa-upload" style="color: orange"></i>
      <span class="nav-link-text" style="color: white">Upload Tests (CA 2)</span>
    </a>
  </li>
    <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Upload Tests (CA 3)">
    <a class="nav-link" href="upload_ca3.php">
      <i class="fa fa-upload" style="color: orange"></i>
      <span class="nav-link-text" style="color: white">Upload Tests (CA 3)</span>
    </a>
  
    <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Upload Exams">
    <a class="nav-link" href="upload_exam.php">
      <i class="fa fa-upload" style="color: orange"></i>
      <span class="nav-link-text" style="color: white">Upload Exam Scores</span>
    </a></li>-->
  </li>
  <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Fill Attendance Sheet">
    <a class="nav-link" href="post_attendance.php">
      <i class="fa fa-upload" style="color: red"></i>
      <span class="nav-link-text" style="color: white">Upload Attendance Scores</span>
    </a>
  </li>
  <!--<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Fill Attendance Sheet">
    <a class="nav-link" href="fill_attendance_sheet.php">
      <i class="fa fa-upload" style="color: red"></i>
      <span class="nav-link-text" style="color: white">Upload Exam Scores</span>
    </a>
  </li> -->
  <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Upload Skills, Psychomotor, and others">
    <a class="nav-link" href="post_skills.php">
      <i class="fa fa-upload" style="color: purple"></i>
      <span class="nav-link-text" style="color: white">Upload Skills, Psychomotor, and others</span>
    </a>
  </li>
  <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Logout">
    <a class="nav-link" href="logout.php">
      <i class="fa fa-sign-out" style="color: #3498db"></i>
      <span class="nav-link-text" style="color: white">Logout</span>
    </a>
  </li>
</ul>
    </div>
  </nav>
  
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumbs-->
      <ol class="breadcrumb" style="background: #D8807D">
        <li class="breadcrumb-item">
          <a href="main.php" style="color: black; font-weight: bold">Back to Dashboard</a>
          
        </li>
        <li class="breadcrumb-item active" style="color: black">Admin Dashboard</li>
      </ol>
    <?php if(!empty($statusMsg)){
        echo '<div class="alert '.$statusMsgClass.'">'.$statusMsg.'</div>';
    } ?>
      <div class="row">
        <div class="col-lg-12">
          <!-- Example Bar Chart Card-->
      <ol class="breadcrumb"style="background: #3498db">
                                    
            <h4 style="color: white">Upload Student's Attendance, Closing Date, Resumption Date, Etc | 
            <a href="javascript:void(0);" onclick="$('#importFrm').slideToggle();">Import Data</a></h4>
                                    </ol>
            <form action="importAttendance.php" method="post" enctype="multipart/form-data" id="importFrm">
                <input type="file" name="file" /><br/><br/>
                
			<div class='row'>
			  <div class='col-sm-2'>
			<select name='term' class='form-control'>
				<option value='1st Term'>1st Term</option>";
				<option value='2nd Term'>2nd Term</option>";
				<option value='3rd Term'>3rd Term</option>";
			?>
			</select>
		</div>
			<div class='col-sm-2'>
			<select name='year' class='form-control'>
<?php
			$rows1 = sql($DBH, "SELECT * FROM tbl_session where id >= ?", array(1), "rows");							
			foreach($rows1 as $row1)
			{	
				$sch_session   		= $row1['session'];
				
				echo "
				<option value='$sch_session'>$sch_session</option>";
				}
			?>
			</select>
		</div>
			<div class='col-sm-3'>
			<select name='teacher_no' class='form-control'>
<?php
			$rows1 = sql($DBH, "SELECT * FROM tbl_user where teacher = ?", array("true"), "rows");							
			foreach($rows1 as $row1)
			{	
				$sch_hash   		= $row1['hash'];
				$sch_name   		= $row1['fullname'];
				$sc_class   		= $row1['class'];
				
				echo "
				<option value='$sch_hash'>$sc_class - $sch_name</option>";
				}
			?>
			</select>
		</div>
		<div class='col-sm-2'>
                <input type="submit" class="btn btn-primary" name="importSubmit" value="UPLOAD RECORD">
		</div>
		</div>
            </form>
           <br><br><a href="https://bkms.com.ng/portal/coll_admin/SAMPLE_ATTENDANCE_SHEET.csv" title="FORMAT FOR ATTENDANCE SHEET" STYLE="COLOR:RED"><BIG>DOWNLOAD SAMPLE FOR ATTENDANCE & TEACHER'S COMMENTS</BIG></a><BR>
This is where you can upload students data on:<br>
Attendance,<br>
Closing Date,<br>
Dats School Open,<br>
Next term information, and <br>
Teacher's Comment
 <br/><br/> 
      <div class="row">
                <?php
                    //get records from database
                      
            	//AND status = ? "DONATED",
                $STH 			= $DBH->prepare("SELECT count(*) FROM attendance WHERE id >= ?");
            	$result 	   	= $STH->execute(array(1));
            	$count		  	= $STH->fetchColumn();
            	
            	if($count >= 1){
                           
		$rows = sql($DBH, "SELECT MIN(id) AS id, year FROM attendance  WHERE id >= ? GROUP BY year", 
            	array(1), "rows");
		foreach($rows as $row)
		{	
			$u_name	 		= $row['name'];
			$u_registration_no 		= $row['registration_no'];
			$Handwriting 			= $row['Handwriting'];
			$Fluency 			= $row['Fluency'];
			$Games 			= $row['Games'];
			$HandlingTools 			= $row['HandlingTools'];
			$Drawing 			= $row['Drawing'];
			$Creativity 			= $row['Creativity'];
			$Musicalattendance 			= $row['Musicalattendance'];			
			$Punctuality 			= $row['Punctuality'];			
			$AttentivenessToClass 			= $row['AttentivenessToClass'];			
			$Reliability 			= $row['Reliability'];			
			$Neatness 			= $row['Neatness'];			
			$Politeness 			= $row['Politeness'];			
			$Honesty 			= $row['Honesty'];			
			$Obedience 			= $row['Obedience'];			
			$RelationshipWithOthers 			= $row['RelationshipWithOthers'];			
			$SelfControl 			= $row['SelfControl'];			
			$Attentiveness 			= $row['Attentiveness'];			
			$Initiative 			= $row['Initiative'];			
			$OrganizationalAbility 			= $row['OrganizationalAbility'];			
			$Perseverance 			= $row['Perseverance'];			
			$us_class			= $row['class'];
			$us_year			= $row['year'];
			$us_term			= $row['term'];			
			
		
			echo"
			
                    <div1><a href='main_term.php?id=$t_year' target='blank'>$t_year</a></div1>";
                    }
                    }else{
                    echo "
                    No Result(s) found Now.....";
                    }
                   
                    ?>
          </div>
           </div>
          </div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
    <footer class="sticky-footer" style="background: #D8807D">
      <div class="container">
        <div class="text-center"> <small><strong><span class="style1">Copyright © 2024 BRITISH LEARNERS COLLEGE, OWERRI: All Rights Reserved!</span></strong></small> </div>
      </div>
    </footer>
    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fa fa-angle-up"></i>
    </a>
    <!-- Logout Modal-->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="Sign_in.php">Logout</a>
          </div>
        </div>
      </div>
    </div>
    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    <!-- Page level plugin JavaScript-->
    <script src="vendor/chart.js/Chart.min.js"></script>
    <script src="vendor/datatables/jquery.dataTables.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>
    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin.min.js"></script>
    <!-- Custom scripts for this page-->
    <script src="js/sb-admin-datatables.min.js"></script>
    <script src="js/sb-admin-charts.min.js"></script>
  </div>
</body>

</html>
