<?php
include 'db.php';
include 'layout.php';
include 'linkrel.php';
?>

<div class="page-wrapper">
  <div class="content container-fluid">
    <div class="page-header">
      <div class="row align-items-center">
        <div class="col">
          <h4 class="page-title">User Roles</h4>
        </div>
        <div class="col-auto float-end ms-auto">
          <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addRoleModal">
            <i class="fa fa-plus"></i> Add Role
          </button>
        </div>
      </div>
    </div>

    <div class="row">
      <div class="col-md-12">
        <div class="card">
          <div class="card-body">
            <div class="table-responsive">
              <table class="table table-bordered">
                <thead>
                  <tr>
                    <th>#</th>
                    <th>Role Name</th>
                  
                  </tr>
                </thead>
                <tbody>
                  <?php
                  $i = 1;
                  $roles = $conn->query("SELECT * FROM roles");
                  while ($role = $roles->fetch_assoc()):
                  ?>
                  <tr>
                    <td><?= $i++ ?></td>
                    <td><?= htmlspecialchars($role['name']) ?></td>
                
                  </tr>
                  <?php endwhile; ?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>

    <?php include 'modals/add_role_modal.php'; ?>
  </div>
</div>