<?php
session_start();
include('./interfaces_function.php');

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Interfaces List</title>
    <link rel="stylesheet" href="../css/style.css" type="text/css">
    <link rel="stylesheet" href="../css/userstyle.css" type="text/css">
    <link rel="stylesheet" href="../css/connection_profile.css" type="text/css">
</head>
<body>
<<?php if (isset($_SESSION['messages'])): ?>
<div id="popup_bulk" class="popup_bulk">
    <div class="popup-user-create-meg">
        <p id="popup-message_bulk"><?php echo $_SESSION['messages']; ?></p>
    </div>
</div>
<?php endif; ?>


<div id="div_userlist">
<div class="user_container">

  <!-- Main content -->
  <maincontent>
    <div class="usertable">
        <h3>Interfaces & Networks List</h3>
   <!--     <?php //echo $_SESSION['valid'];?> -->

            <!-- Search form -->
         <!--   <div>
                <form action="userlist.php" method="GET" class="search">
                    <input type="text" name="search" id="search" placeholder="search here" />
                    <button type="submit" name="submit" class="btn_search" id="search_btn"><img src="../images/search.png" alt="search" class="search_logo"></button>
                    <button type="button" class="clear_btn" id="clear_btn">clear</button>
                </form>
            </div> -->


            <div class="userdetails">
                <!-- User list table -->
                <?php if (!empty($user_list)): ?>
                    <table id="user_table">
                        <thead>
                            <tr>
                                
                                <th data-column="pid" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort"> Status</th>
                                <th data-column="firstname" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort">Name</th>
                                <th data-column="lastname" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort">IP Address</th>
                                <th data-column="lastname" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort">Netmask</th>
                                <th data-column="lastname" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort">Default Network</th>
                                <th data-column="lastname" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort">Type</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($user_list as $user): ?>
                                    <td> <input type="checkbox" value="<?php echo $user['is_running']; ?>" <?php echo $user['is_running'] == 'true' ? 'checked' : ''; ?>  class="status"></td>
                                    <td><?php echo htmlspecialchars($user['name']); ?></td>
                                    <td><?php echo htmlspecialchars($user['ipaddress']); ?></td>
                                    <td><?php echo htmlspecialchars($user['netmask']); ?></td>
                                    <td><?php echo htmlspecialchars($user['network']); ?></td>
                                    <td><?php echo htmlspecialchars($user['type']); ?></td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                <?php endif; ?>
        </div>
    </div>


                <!-- Debugging info -->
            <!--    <p>total pages: <?php // echo $total_search_pages ?></p> -->
             <!---   <p>total users: <?php // echo $total_search_users ?></p>
                <p>search result page: <?php // echo $search_page_no ?></p>
                <p>search query: <?php //echo htmlspecialchars($search) ?></p>      -->          
                                        

 <!------------------PAGINATION ENDS ------------------------------------>


  </maincontent>
  <!---main end-->
</div>
</div>

<!-- Popup -->
<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>

<div id="confirmation_popup" style="display: none;">
    <div class="popup_cont">
        <p>Do you really wanna delete the selected users?</p>
        <button id="confirm_yes">Yes</button>
        <button id="confirm_no">No</button>
    </div>
</div>


<script src="../js/switch.js"></script>
<script src="../js/bulk_delete.js"></script>
</body>
</html>
