
<?php
// Initialize the session
session_start();
 
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
    header("location: index.php");
    exit;
}


include('navbar.php');

?>

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div id="tableHolder"></div>


<script type="text/javascript">
$(document).ready(function(){
  refreshTable();
});
var text = document.getElementById("tableHolder").textContent;


var statusFilter = "<?= $statusFilter !== null ? $statusFilter : '' ?>";

function refreshTable(){
    let url = "getTermine.php";
    if (statusFilter !== "") {
        url += "?status=" + statusFilter;
    }

    $.get(url, function(data) {
        if (data !== text) {
            text = data;
            $('#tableHolder').html(data);
        }
    });

    setTimeout(refreshTable, 1000);
}
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>