<?php
session_start();
error_reporting(0);
include('../within/linkme.php');
if(strlen($_SESSION['alogin'])==0)
	{	
header('location:index.php');
}
else{
date_default_timezone_set('Africa/Lagos');// change according timezone
$currentTime = date( 'd-m-Y h:i:s A', time () );

//id	department username AdminName EmailId ContactNumber password updationDate

if(isset($_POST['update']))
{
$uid=$_SESSION['id'];
$staffName=$_POST['staffName'];
$Department="Finance";
$IsActive="1";
$EmailId=$_POST['EmailId'];
$ContactNumber=$_POST['ContactNumber'];
$UserName=$_POST['UserName'];
$Password=md5($_POST['Password']); // Password is encrypted using MD5
$query=mysqli_query($con,"update admin set password='$Password'");
if($query)
{
$successmsg="Staff details updated successfully !!";
echo "<script type='text/javascript'> document.location = 'staff.php'; </script>";

}
}
?>

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="favicon.ico">
    <title>Finance Staff - POMS</title>
    <!-- Simple bar CSS -->
    <link rel="stylesheet" href="../css/simplebar.css">
    <!-- Fonts CSS -->
    <link href="https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,100;0,200;0,300;0,400;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
    <!-- Icons CSS -->
    <link rel="stylesheet" href="../css/feather.css">
    <link rel="stylesheet" href="../css/dataTables.bootstrap4.css">
    <!-- Date Range Picker CSS -->
    <link rel="stylesheet" href="../css/daterangepicker.css">
    <!-- App CSS -->
    <link rel="stylesheet" href="../css/app-light.css" id="lightTheme" disabled>
    <link rel="stylesheet" href="../css/app-dark.css" id="darkTheme">
  <script>
    function autoRefresh() {
        window.location = window.location.href;
    }
    setInterval('autoRefresh()', 50000);
</script>
</head>
  </head>
  <body class="vertical  light  ">
    <div class="wrapper">
      
        <?php include("../include/topnav_fin.php");?>		
	  <!--Insert NAV Here-->
      <aside class="sidebar-left border-right bg-white shadow" id="leftSidebar" data-simplebar>
        
        <?php include("../include/nav_fin.php");?>      
	  </aside>
	  <!--End Insert NAV Here-->
	  
      <main role="main" class="main-content">
        <div class="container-fluid">
          <div class="row justify-content-center">
            <div class="col-12">
              <h2 class="page-title">Finance Staff</h2>
              <p class="text-muted">ENL Finance Staff Management.</p>
              <div class="row">
			  
				
				
                <div class="col-md-6">
                  <div class="card shadow mb-4">
                    <div class="card-body">
                      
					  
					  
					  <table class="table datatables" id="dataTable-1">
                        <thead>
                          <tr>							
						  <th>Name</th>
							<th>Email</th>
							<th>Username</th>
							<th>Action</th>
                           </tr>
                        </thead>
                        <tbody>
						<?php 
$query=mysqli_query($con,"select * from finance ORDER BY id DESC");
while($row=mysqli_fetch_array($query))
{
?>	  
                          <tr>
									<td><?php echo htmlentities($row['staffName']);?></td>
									<td><?php echo htmlentities($row['EmailId']);?></td>
									<td><?php echo htmlentities($row['UserName']);?></td>
                         <td>
								<div class="dropdown">
                                <button class="btn btn-sm dropdown-toggle" type="button" id="dr1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                  <span class="text-muted sr-only">Manage</span>
                                </button>
                                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dr1">
                                  <a class="dropdown-item" href="staff_detail.php?cid=<?php echo htmlentities($row['id']);?>">Edit</a>
                                  <a class="dropdown-item" href="staff_delete.php?cid=<?php echo htmlentities($row['id']);?>">Delete</a>
                                  <a class="dropdown-item" href="staff_password.php?cid=<?php echo htmlentities($row['id']);?>">Change Password</a>
                                </div>
                              </div>
							  </td>
                          </tr>
						  
						  <?php } ?>
							  
							
							</tbody>
                      </table>
					  
					  
					  
                    </div> <!-- /.card-body -->
                  </div> <!-- /.card -->
                </div> <!-- /.col -->
                
				<div class="col-md-6">
                  <div class="card shadow mb-4">
                    <div class="card-body">
                      <p class="mb-2"><strong>Update Staff Registration</strong></p>
					  
					 	<form class="needs-validation" novalidate method="post" name="finance" enctype="multipart/form-data" >
 		
						<?php $st='closed';
						$query=mysqli_query($con,"select * from finance where id ='".$_GET['cid']."'");
						while($row=mysqli_fetch_array($query))
						{
						?>	
                      <div class="form-group mb-3">
                        <label for="custom-placeholder">Staff Name</label>
                        <input class="form-control input-placeholder" disabled value="<?php echo htmlentities($row['staffName']);?>" id="custom-placeholder" type="text" name="Enter Staff Name">
                      </div>
                      <div class="form-group mb-3">
                        <label for="custom-money">Email</label>
                        <input class="form-control input-money" disabled value="<?php echo htmlentities($row['EmailId']);?>" id="custom-money" type="email" placeholder="Enter Staff Email">
                      </div>
                      <div class="form-group mb-3">
                        <label for="custom-mixed">Username</label>
                        <input class="form-control input-mixed" disabled value="<?php echo htmlentities($row['UserName']);?>" id="custom-mixed" type="text" placeholder="Enter Login User Name ">
                      </div>
                      <div class="form-group mb-3">
                        <label for="custom-ipadd">Password</label>
                        <input class="form-control input-mixed" id="custom-mixed" name="Password" type="password" placeholder="Enter New Password">
                      </div>
					  <?php } ?>
					  
					 <a href="commercial_staff" class="btn btn-info shadow btn-xs sharp me-1"><i class="fa fa-eye"></i>Back</a>

                      <button type="submit" name="update" class="btn btn-primary">Submit</button>
					  
                    </div> <!-- /.card-body -->
                  </div> <!-- /.card -->
                </div> <!-- /.col -->
              </div> <!-- end section -->
              
			   <!-- Begin Content managment  -->
			  <div class="row mb-4">
                <div class="col-md-12">
                  <div class="card shadow">
                    <div class="card-body">
                      <h5 class="card-title">Content Management </h5>
                      <!-- Create the editor container -->
                      <div id="editor" style="min-height:100px;">
                        <p>Content Management. Content Management. Content Management </p>
                      </div>
                    </div>
                  </div>
                </div>
              </div> <!-- end Content managment  -->
			  
			  
            </div> <!-- .col-12 -->
          </div> <!-- .row -->
        </div> <!-- .container-fluid -->
        
		
		
        
      </main> <!-- main -->
	  
    </div> <!-- .wrapper -->
    <script src="../js/jquery.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/moment.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script src="../js/simplebar.min.js"></script>
    <script src='../js/daterangepicker.js'></script>
    <script src='../js/jquery.stickOnScroll.js'></script>
    <script src="../js/tinycolor-min.js"></script>
    <script src="../js/config.js"></script>
    <script src='../js/jquery.dataTables.min.js'></script>
    <script src='../js/dataTables.bootstrap4.min.js'></script>
    <script>
      $('#dataTable-1').DataTable(
      {
        autoWidth: true,
        "lengthMenu": [
          [16, 32, 64, -1],
          [16, 32, 64, "All"]
        ]
      });
    </script>
   
  </body>
</html>
<?php } ?>