<?php
require_once '../auth/auth.php';
require_once '../models/db_connection.php';
require_once '../models/user_model.php';
$user = new User($conn);
$userData = $user->getUsers();
?>
<!DOCTYPE html>
<html lang="en">

<head>
 <title>Exam | Add Examiniation </title>
 <?php include("../templates/header.php"); ?>
</head>
<body>
    <?php
      if(isset($_GET["message"])){
        $message = $_GET["message"];
        echo "<script>alert('".$message."')</script>";
      }
  ?>
  <div class="container-scroller">
    <!-- partial:partials/_navbar.html -->
    <?php include("../templates/nav.php"); ?>
    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
      <!-- partial:partials/_sidebar.html -->
      <?php include("../templates/sidenav.php"); ?>
      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">
        <div class="col-sm-12 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
                  <p class="card-description">All Users</p>
                    <table class="table table-responsive table-bordered display"  id="example">
                      <thead>
                        <tr>
                          <th> # </th>
                          <th>Username</th>
                          <th>Email</th>
                          <th>Role</th>
                          <th>Actions</th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php 
                          $x = 1;
                            foreach ($userData as $userDatas) {?>
                        <tr>
                          <td> <?= $x ?></td>
                          <td><?= $userDatas['username'] ?></td>
                          <td><?= $userDatas['email'] ?></td>
                          <td><?= $userDatas['role'] ?></td>                          
                          <td>
                            <a href="user_profile.php?id=<?= $userDatas['id'] ?>"><button   type="button" class="btn btn-outline-primary btn-icon-text">
                            <i class="mdi mdi-file-check btn-icon-prepend"></i> </button></a>
                            <a href="delete_user.php?id=<?= $userDatas['id'] ?>"><button   type="button" class="btn btn-danger btn-icon-text">
                            <i class="mdi mdi-file-check btn-icon-prepend"></i></button></a>
                          </td>
                        </tr>
                           <?php 
                           $x++;
                           }?>
                      </tbody>
                    </table>
                </div>
              </div>
            </div>
            
            <div>
                   <a href="../auth/register.php"><button   type="button" class="btn btn-primary btn-icon-text">
                          <i class="mdi mdi-file-check btn-icon-prepend"></i>Add New User</button></a>
            </div>
        
        </div>
        <!-- content-wrapper ends -->
        <!-- partial:partials/_footer.html -->
        <?php include("../templates/footer.php"); ?>
        
        <!-- partial -->
      </div>
      <!-- main-panel ends -->
    </div>
    <!-- page-body-wrapper ends -->
  </div>
    <?php include("../templates/inc_scripts.php"); ?>
</body>

</html>

