<?php
session_start();
$activePage = 'Administration';
$activeSubPage = 'Authentication';
include("../elements/master.php");
include("./authentication_fuction.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>roles</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../css/roles.css">
    <link rel="stylesheet" href="../css/authentication.css">
</head>
<body>
    <div class="role_container">
    <div class="button">
    <select name="authentication" id="actions" onchange="handleRedirect()">
            <option value="#">-----------</option>
            <option value="create_auth.php">NULL</option>
    </select>
    </div>
    </div>

<div class="user_container">
<!-- Main content -->
<maincontent>
  <div class="usertable">
      <h3>Authentication</h3>
      <div class="userdetails">
      <table id="user_table">
                    <thead>
                        <tr>
                            <th>
                                <input type="checkbox" id="select_all"/>
                                <img id="bulk_delete_btn"  style="display: none;" src="../images/trash-can.png" alt="img">
                            </th>
                            <th data-column="pid" data-order="desc" class="sortable">NAME</th>
                            <th data-column="firstname" data-order="desc" class="sortable">TYPE</th>
                            <th data-column="lastname" data-order="desc" class="sortable">DESCRIPTION</th>
                            <th>Modify</th>
                            <th>Delete</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php if (is_array($auth_rules_list)): ?>
                      <?php foreach ($auth_rules_list as $rule): ?>
                            <tr data-pid="<?php echo htmlspecialchars($rule['id']); ?>">
                                <td><input type="checkbox" class="user_checkbox" data-pid="<?php echo htmlspecialchars($rule['id']); ?>" /></td>
                                <td><?php echo htmlspecialchars($rule['id']); ?></td>
                                <td><?php echo htmlspecialchars($rule['status']); ?></td>
                                <td><?php echo htmlspecialchars($rule['description']); ?></td>
                                <td><button class="btn_modify" id="btn1" data-pid="<?php echo htmlspecialchars($rule['id']); ?>">Modify</button></td>
                                <td><button class="btn_delete" id="btn2" data-pid="<?php echo htmlspecialchars($rule['id']); ?>">Delete</button></td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr><td colspan="7"><?php echo htmlspecialchars($auth_rules_list); ?></td></tr>
                    <?php endif; ?>
                    </tbody>   
                    </table> 


    <form id="pid_form" action="#" method="POST" style="display: none;">
                <input type="hidden" name="id" id="pid_input">
     </form>
      </div>
  </div>
</maincontent>

</div>
<div id="popup" class="popup">
  <div class="popup-content">
    <p id="popup-message"></p>
    <button id="confirm-button" class="confirm-button">Yes</button>
    <button id="cancel-button" class="confirm-button">No</button>
  </div>
</div>
<script src="../js/role_delete.js"></script>
<script src="../js/authentication.js"></script>
</body>
</html>