<?php
session_start();
error_reporting(0);
include('phpaccess/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 () );

//!--sn  name  type  title  body  picture  dating  

if(isset($_POST['update']))
{
$cid=$_SESSION['sn'];
$sn=$_GET['cid'];
$name=$_POST['name'];
$title=$_POST['title'];
$body=$_POST['body'];
$dating=date("d-M-Y:h:i:sa");

$imgfile=$_FILES["image"]["name"];

// get the image extension
$extension = substr($imgfile,strlen($imgfile)-4,strlen($imgfile));
// allowed extensions
$allowed_extensions = array(".jpg","jpeg",".png",".gif");
//$allowed_extensions = array(".jpg","jpeg",".png",".gif");

// Validation for allowed extensions .in_array() function searches an array for a specific value.
if(!in_array($extension,$allowed_extensions))
{
echo "<script>alert('Invalid format. Only .jpg,jpeg,.png, .gif format allowed');</script>";
}
else
{
//rename the image file
$docnewfile=md5($imgfile).$extension;
// Code for move image into directory
move_uploaded_file($_FILES["image"]["tmp_name"],"../assets/img/team/".$docnewfile);

$query=mysqli_query($con,"update staff set picture='$docnewfile' where sn=$sn ");
//$sql1=mysqli_query($con,"update provisional set pbpayment='$pbPaymentStatus' where requestNumber='$requestNumber'");

if($query)
{
$successmsg="Staff details updated successfully !!";
echo "<script type='text/javascript'> document.location = 'managements.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>Board of Director - ENL Consortium Limited</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("phpaccess/nav_fin.php");?>		
	  <!--Insert NAV Here-->
      <aside class="sidebar-left border-right bg-white shadow" id="leftSidebar" data-simplebar>
        
        <?php include("phpaccess/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">Management Team</h2>
              <p class="text-muted">Staff Details.</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>Title</th>				
						    <th>Name</th>
							<th>Category</th>
							<th>Date</th>
							<th>Action</th>
                           </tr>
                        </thead>
                        <tbody>
						<?php 
$query=mysqli_query($con,"select * from staff WHERE type='Management' ORDER BY sn ASC");
while($row=mysqli_fetch_array($query))
{
?>	  
                          <tr>
									<td><?php echo htmlentities($row['title']);?></td>
									<td><?php echo htmlentities($row['name']);?></td>
									<td><?php echo htmlentities($row['type']);?></td>
									<td><?php echo htmlentities($row['dating']);?></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="Management_detail.php?cid=<?php echo htmlentities($row['sn']);?>">Edit</a>
								 <a class="dropdown-item" href="Management_picture.php?cid=<?php echo htmlentities($row['sn']);?>">Change Picture</a>

<a class="dropdown-item"  href="managements.php?cid=<?php echo $row['sn']?>&del=delete" onClick="return confirm('Are you sure you want to delete?')">Delete </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 Board Of Director 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 staff where sn ='".$_GET['cid']."'");
						while($row=mysqli_fetch_array($query))
						{
						?>	
                      <div class="form-group mb-3">
						<img src="../assets/img/team/<?php echo htmlentities($row['picture']);?>" alt="ENL Consortium Limited" width="250" height="300">
                      </div>
                      <div class="form-group mb-3">
                        <label for="custom-placeholder">Full Name</label>
                        <input class="form-control input-placeholder" name="name" disabled value="<?php echo htmlentities($row['name']);?>" id="custom-placeholder" type="text" name="Enter Staff Name">
                      </div>
                      <div class="form-group mb-3">
                        <label for="custom-mixed">Picture</label>
						 <input type="file" class="form-control" required="required" name="image" id="formFile" placeholder="Only jpg is accepted"  value="<?php echo htmlentities($row['picture']);?>"  />

                      </div>
					  
					  
					  <?php } ?>
					  
					 <a href="directors" 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 -->
              
	
            </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 } ?>