<!DOCTYPE html>
<html>
<head>
  <title>Users Logs</title>
<link rel="stylesheet" type="text/css" href="css/userprofile.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">

</head>
<body>
<?php 
	require_once('header.php');
	require_once("connectDB.php");

	$query = $conn->query("SELECT *,CASE status WHEN 1 THEN 'Enabled' ELSE 'Disabled' END AS status FROM data_users");
    $button='';
?>
<br>
<main class="container">

  <!-- <section> -->
  <!--User table-->
  <h1 class="slideInDown animated" style="margin-bottom: 25px !important;">LIST USERS</h1>

  <div class="tbl-header slideInRight animated">
    <table cellpadding="0" cellspacing="0" border="0">
      <thead>
        <tr>
          <th class="text-center" width="5%">No</th>
          <th class="text-center" width="20%">Nama</th>
          <th class="text-center" width="15%">NIK</th>
          <th class="text-center">Jabatan</th>
          <th class="text-center">Action</th>
        </tr>
      </thead>
    <!-- </table>
  </div>
  <div class="tbl-content slideInRight animated">
  <table cellpadding="0" cellspacing="0" border="0"> -->
      <tbody>
    <?php $no=1; while($row = $query->fetch_assoc()) { 
        if($row['status'] == "Enabled") {
            $button = "Disable";
            $buttonStyle = "btn-warning";
        } else {
            $button = "Enable";
            $buttonStyle = "btn-success";
        }
        
    ?>
      <TR>
        <TD class="text-center"><?php echo $no;?></TD>
        <TD class="text-center"><?php echo $row['nama'];?></TD>
        <TD class="text-center"><?php echo $row['nik'];?></TD>
        <TD class="text-center"><?php echo $row['jabatan'];?></TD>
        <TD>
          <a href="action.php?action=updateStatus&id=<?=$row['id'];?>"><button class="btn <?=$buttonStyle;?>"><?=$button;?></button></a>
          <a href="action.php?action=deleteUser&id=<?=$row['id'];?>" onclick="return confirm('Anda yakin akan menghapus user ini ?');"><button class="btn btn-danger">Delete</button></a>
        </TD>
      </TR>
    <?php $no++; } ?>
    </tbody>
    </table>
  </div>
<!-- </section> -->
</main>
</body>
</html>