<?php
session_start();
include('./switch_function.php');
include('./switch_delete.php');
$activePage = 'configuration';
$activeSubPage = 'switch';
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Switch 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>Switch List</h3>
       <!-- <?php //echo $_SESSION['valid'];?> -->

            <!-- Search form -->
          

            <div class="connection_profile_btn">
               <button> <a href="./new_switch.php">New Switch</a></button> 
            </div>
            <div class="userdetails">
                <!-- User list table -->
                <?php if (!empty($user_list)): ?>
                    <table id="user_table">
                        <thead>
                            <tr>
                            <!--     <th class="check_box">
                                    <input type="checkbox" id="select_all" title="Delete selected users"/>
                                    <img id="bulk_delete_btn" style="display: none;" src="../images/trash-can.png" alt="img">
                                </th> -->
                                <th data-column="pid" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort"> IDENTIFIER</th>
                                <th data-column="firstname" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort">DESCRIPTION</th>
                                <th data-column="lastname" data-order="asc" class="sortable"><img src="../images/arrow.png" alt="image" class="sort">TYPE</th>
                               <!-- <th>Modify</th> -->
                                <th>Delete</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($user_list as $user): ?>
                                <tr data-pid="<?php echo htmlspecialchars($user['pid']); ?>">
                                 <!--   <td><input type="checkbox" class="user_checkbox" data-pid="<?php //echo htmlspecialchars($user['pid']); ?>" /></td> -->
                                    <td><?php echo htmlspecialchars($user['id']); ?></td>
                                    <td><?php echo htmlspecialchars($user['description']); ?></td>
                                    <td><?php echo htmlspecialchars($user['type']); ?></td>
                                <!--    <td><button class="btn_modify" data-pid="<?php echo htmlspecialchars($user['id']); ?>">Modify</button></td> -->
                                    <td><button class="btn_delete" data-pid="<?php echo htmlspecialchars($user['id']); ?>">Delete</button></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>
