<?php
 session_start();
require_once('operations.php');
require_once('login.php');

$db = new Operations();
$db1 = new Login();

if (!isset($_SESSION['staffno'])) {
   header( "Location: index.php" );
}

$month = date("n");
$year = date("Y");

if($month == 19 || $month == 10 || $month == 11 || $month == 12){

$session1 = $year . "/". ($year + 1);
$term1 = "First";
//$term1 = "Third";
}


else if($month == 1 || $month == 2 || $month == 3 || $month == 4){
$session1 = ($year-1)."/".$year;
$term1 = "Second";

//$term1 = "First";
}

else if($month == 5 || $month == 6 || $month == 7 || $month == 9){
$session1 = ($year-1)."/".$year;
$term1 = "Third";
//$term1 = "Second";
//$term1 = "First";
}	

$statement = $db->getAllSubject();
//$last_id = "";





if(isset($_GET['username'])  ) {
    $param =  $_GET['username'];
   
    
    
    
   // $db->findExamsById($param);
    
    // $db2->
    
    
    }

$db1->getUserDetails($param);

if(isset($_POST['submit'])){

  //$examcode = $code1;
  $name = $_POST['name'];
  
   $role = $_POST['role'];
  // $date = date("Y-m-d");
  // $date = $_POST['datepicker-13'];
   
  // $time1 = $date." ".$time;


 	
  

  
//c
  if(!$db1->updateUser($param,$role,$name)) {
      
      ?>
      <script>alert('staff updated Successfully'); 
      //window.location.href='allSchedule.php';
      
   </script>
       <?php 
  }

  else {

      ?>
      <script>alert('Error updating staff');</script>    
          <?php 
  }

   }  

  


?>
<!--
=========================================================
* Argon Dashboard - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/argon-dashboard


* Copyright  Creative Tim (http://www.creative-tim.com)
* Coded by www.creative-tim.com



=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-->
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="Start your development with a Dashboard for Bootstrap 4.">
  <meta name="author" content="Creative Tim">
  <title>Exam App</title>
  <!-- Favicon 
  <link rel="icon" href="assets/img/brand/favicon.png" type="image/png">
  -->
  <!-- Fonts -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700">
  <!-- Icons -->
  <link rel="stylesheet" href="assets/vendor/nucleo/css/nucleo.css" type="text/css">
  <link rel="stylesheet" href="assets/vendor/@fortawesome/fontawesome-free/css/all.min.css" type="text/css">
  <!-- Page plugins -->
  <!-- Argon CSS -->
  <link rel="stylesheet" href="assets/css/argon.css?v=1.2.0" type="text/css">
 
  <!-- date picker -->

  
  

  


  <link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"
         rel = "stylesheet">

</head>

<body>
  <!-- Sidenav -->
  <nav class="sidenav navbar navbar-vertical  fixed-left  navbar-expand-xs navbar-light bg-white" id="sidenav-main">
    <div class="scrollbar-inner">
      <!-- Brand -->
      <div class="sidenav-header  align-items-center">
        <a class="navbar-brand" href="javascript:void(0)">
          <h4>Exam App</h4>
        </a>
      </div>
      <div class="navbar-inner">
        <!-- Collapse -->
        <div class="collapse navbar-collapse" id="sidenav-collapse-main">
          <!-- Nav items -->
          <?php include('menu.html')  ?>
          <!-- Divider -->
          <hr class="my-3">
          <!-- Heading -->
          
        </div>
      </div>
    </div>
  </nav>
  <!-- Main content -->
  <div class="main-content" id="panel">
    <!-- Topnav -->
    <nav class="navbar navbar-top navbar-expand navbar-dark bg-primary border-bottom">
      <div class="container-fluid">
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <!-- Search form -->
          <form class="navbar-search navbar-search-light form-inline mr-sm-3" id="navbar-search-main">
            <div class="form-group mb-0">
              <div class="input-group input-group-alternative input-group-merge">
                <div class="input-group-prepend">
                  <span class="input-group-text"><i class="fas fa-search"></i></span>
                </div>
                <input class="form-control" placeholder="Search" type="text">
              </div>
            </div>
            <button type="button" class="close" data-action="search-close" data-target="#navbar-search-main" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </form>
          <!-- Navbar links -->
          
          <ul class="navbar-nav align-items-center  ml-md-auto ">
            <li class="nav-item d-xl-none">
              <!-- Sidenav toggler -->
              <div class="pr-3 sidenav-toggler sidenav-toggler-dark" data-action="sidenav-pin" data-target="#sidenav-main">
                <div class="sidenav-toggler-inner">
                  <i class="sidenav-toggler-line"></i>
                  <i class="sidenav-toggler-line"></i>
                  <i class="sidenav-toggler-line"></i>
                </div>
              </div>
</li>
</ul>
          
          
        </div>
      </div>
    </nav>
    <!-- Header -->
    <!-- Header -->
    <div class="header bg-primary pb-6">
      <div class="container-fluid">
        <div class="header-body">
          <div class="row align-items-center py-4">
            
          
          </div>
          <!-- Card stats -->
         
          <!-- put content  -->




         



          <div class="container-fluid mt--6">
      
       
      <div class="row">
        <div class="col-xl-8">
          <div class="card">
            <div class="card-header border-0">
              <div class="row align-items-center">
                <div class="col">
                  <h3 class="mb-0">Add Staff</h3>
                </div>
                <div class="col text-right">
                  
                </div>
              </div>
            </div>
            <div class="table-responsive">
              <!-- Projects table -->
              <div class="card-body">
              <form method = "post" action = "">
                

              <div class="row">
                    <div class="col-lg-12">
                      <div class="form-group">
                        <label class="form-control-label" for="input-username">Username</label>
                        <input type="text" id="input-username"  class="form-control" placeholder="username" name = "username" value="<?php echo $param  ?>" required
                        readonly>
                      </div>
                    </div>
                    </div>  
            
              <div class="row">
                    <div class="col-lg-12">
                      <div class="form-group">
                        <label class="form-control-label" for="input-username">Name</label>
                        <input type="text" id="input-username"  class="form-control" placeholder="Nam of staff" name = "name" value="<?php echo $db1->name ?>" required>
                      </div>
                    </div>
                    </div>

                 
                   


                   
               

                 


                    <div class="row">
                    <div class="col-lg-12">
                      <div class="form-group">
                        <label class="form-control-label" for="input-username">Role</label>
                        <select class="form-control" name = "role" required>
  <option><?php  echo $db1->role; ?></option>
  <option>staff</option>
  <option>Moderator</option>
  <option>admin</option>
  <option>none</option>
  
</select>
                      </div>
                    </div>
                    </div>
                 

                   



                    <div class="row">
                    <div class="col-lg-12">
                      <div class="form-group">
                        <label class="form-control-label" for="input-username">Date added</label>
                       <!-- <input type="text" id="input-username" class="form-control" placeholder="subject" name = "subject" value="" required> -->

                       <input type="text" class="form-control" id="datepicker-13" name="datepicker-13" placeholder="" required readonly> 
  
          
      
                      </div>
                    </div>
                    </div>


                    


                   


                   

                
                  <div class="text-center">
                  <button type="submit" name = "submit" class="btn btn-primary my-4">Edit Staff</button>
                </div>
                  </form>
              <!-- end -->
            </div>
          </div>
        </div>
        
            </div>
          </div>
        </div>
      </div>


          <!-- put content --->
          
        </div>
      </div>
    </div>
    <!-- Page content -->
    <div class="container-fluid mt--6">
    
       
      
        </div>
      </div>
      <!-- Footer -->
      <footer class="footer pt-0">
        <div class="row align-items-center justify-content-lg-between">
          <div class="col-lg-6">
            
          </div>
          <div class="col-lg-6">
            
          </div>
        </div>
      </footer>
    </div>
  </div>
  <!-- Argon Scripts -->
  <!-- Core -->

   <script src="assets/vendor/jquery/dist/jquery.min.js"></script> 
  <script src="assets/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/js-cookie/js.cookie.js"></script>
  <script src="assets/vendor/jquery.scrollbar/jquery.scrollbar.min.js"></script>
  <script src="assets/vendor/jquery-scroll-lock/dist/jquery-scrollLock.min.js"></script>
  <script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

  <script src ="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>  

<script src ="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>  
  <!-- Optional JS -->
  <script src="assets/vendor/chart.js/dist/Chart.min.js"></script>
  <script src="assets/vendor/chart.js/dist/Chart.extension.js"></script>
  <!-- Argon JS -->
 <script src="assets/js/argon.js?v=1.2.0"></script>

  <script>
    // WRITE THE VALIDATION SCRIPT.
    function isNumber(evt) {
        var iKeyCode = (evt.which) ? evt.which : evt.keyCode
        if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57))
            return false;

        return true;
    }    
</script>

<script>
         $(function() {
			  
            $( "#datepicker-13" ).datepicker(
			{dateFormat: 'yy-mm-dd',minDate:0}).datepicker("setDate", new Date());
           
			
			
         });
      </script>
</body>

</html>