<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
    exit("unauthorized");
}

include "../../php/database.php";
?>


<div class="card-title mb-3">Giustificativi</div>
<hr style="margin:0">
<table id="justifications_list_tables" class="display" style="width: 100%;">
    <thead>
        <tr>
            <th>Nome</th>
            <th>Sigla</th>
            <th>Descrizione</th>
            <th>Applicazione</th>
            <th></th>
        </tr>
    </thead>
    <?php
    $sql    = "SELECT * FROM justifications 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["acronym"] . "</td>";
        echo "<td>" . $row["description"] . "</td>";
        echo "<td>" . $row["appliance"] . "</td>";
        echo "<td><i class='fa-solid fa-trash' aria-hidden='true' style='float: right; cursor: pointer' onclick='deleteJustificazion(" . $row["id"] . ")'></i><i class='fa-solid fa-magnifying-glass' aria-hidden='true' style='float: right; margin-right: 20px; cursor: pointer' onclick='editJustificazion(" . $row["id"] . ")'></i></td>";
        echo "</tr>";
    }
    ?>
    </tbody>
</table>