<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
    exit("unauthorized");
}

include "../../php/database.php";
?>
<table id="stempers_list_table" class="display" style="width: 100%;">
    <thead>
        <tr>
            <th>Nome</th>
            <th>Indirizzo IP</th>
            <th>Descrizione</th>
            <th>Ubicazione</th>
            <th>Nome file import</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <?php
        $sql    = "SELECT * FROM stampers ORDER BY name ASC";
        $result = mysqli_query($con, $sql);
        while ($row = mysqli_fetch_assoc($result)) {
            echo "<tr>";
            echo "<td>" . $row["name"] . "</td>";
            echo "<td>" . $row["ip_address"] . "</td>";
            echo "<td>" . $row["description"] . "</td>";
            echo "<td>" . $row["location"] . "</td>";
            echo "<td>" . $row["file_name"] . "</td>";
            echo "<td>
                    <a onclick='editStamper(" . $row["id"] . ")' style='cursor: pointer; margin-right:10px'><i class='fa-solid fa-magnifying-glass'></i></a>
                    <a onclick='deleteStamper(" . $row["id"] . ")' style='cursor: pointer'><i class='fa-solid fa-trash'></i></a>
                </td>";
            echo "</tr>";
        }
        ?>
    </tbody>
</table>