<?php
include "../database.php";
session_start();
$user_id = $_GET["id"];

?>
<div class="pt-3 pb-3" style="color: black;">
                <?php
$sql = "SELECT * FROM stamps WHERE user_id = '" . $user_id . "' ORDER BY id DESC";

$result = mysqli_query($con, $sql);
if ($result->num_rows > 0) {
 ?>
    <table id="person_stamp_table" class="display">
        <thead class="text-dark fs-4" style="background-color: lightgray;">
            <tr style="font-size: 12px;">
                <th class="border-bottom-0">
                    <h6 class="fw-semibold mb-0" style="font-size: 12px;">ID</h6>
                </th>
                <th class="border-bottom-0">
                    <h6 class="fw-semibold mb-0" style="font-size: 12px;">Tipo</h6>
                </th>
                <th class="border-bottom-0">
                    <h6 class="fw-semibold mb-0" style="font-size: 12px;">Data</h6>
                </th>
                <th class="border-bottom-0">
                    <h6 class="fw-semibold mb-0" style="font-size: 12px;">Ora</h6>
                </th>
                <th class="border-bottom-0">
                    <h6 class="fw-semibold mb-0" style="font-size: 12px;">Trasferta</h6>
                </th>
                <th class="border-bottom-0">
                    <h6 class="fw-semibold mb-0" style="font-size: 12px;">Note</h6>
                </th>
            </tr>
        </thead>
        <tbody>
    <?php
while ($row = mysqli_fetch_assoc($result)) {
  ?>
    <tr>
        <td class='border-bottom-0'>
            <h6 class='fw-semibold mb-0' style="font-size: 12px;"><?php echo $row["id"]; ?></h6>
        </td>
        <td class='border-bottom-0'>
            <h6 class='fw-semibold mb-0' style="font-size: 12px;"><?php echo $row["type"]; ?></h6>
        </td>
        <td class='border-bottom-0'>
            <p class='mb-0 fw-normal' style="font-size: 12px;"><?php echo date("d/m/Y", strtotime($row["date"])); ?></p>
        </td>
        <td class='border-bottom-0'>
            <p class='mb-0 fw-normal' style="font-size: 12px;"><?php echo date("H:i", strtotime($row["time"])); ?></p>
        </td>
        <td class='border-bottom-0'>
            <p class='mb-0 fw-normal' style="font-size: 12px;"><?php if ($row["in_transfer"] == 0) {echo "NO";} else {echo "SI";}?></p>
        </td>
        <td class='border-bottom-0'>
            <p class='mb-0 fw-normal' style="font-size: 12px;"><?php echo $row["note"]; ?></p>
        </td>
    </tr>
    <?php
}
 ?>
</tbody>
</table>
<?php
} else {
 echo "<h5 style='color:black;text-align: center; font-size: 20px'>Non ci sono timbrature</h5>";
}
?>

                </div>