<?php
require_once '../auth/auth.php';
require_once '../models/db_connection.php';
require_once '../models/log_model.php';
$log = new Log($conn);
$logs = $log->getAllLogs();


?>

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Courses </title>
  <?php include("../templates/header.php"); ?>
  <script type='text/javascript'>
    function ConfirmDelete() {
      if (confirm("Are you sure you want to delete this course?"))
        return true;
      else
        return false;
    }
  </script>
</head>

<body>
  <?php
  if (isset($_GET["message"])) {
    $message = $_GET["message"];
    echo "<script>alert('" . $message . "')</script>";
  }
  ?>
  <div class="container-scroller">
    <!-- partial:partials/_navbar.html -->
    <?php include("../templates/nav.php"); ?>
    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
      <!-- partial:partials/_sidebar.html -->
      <?php include("../templates/sidenav.php"); ?>
      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">

          <div class="col-lg-12 grid-margin stretch-card">
            <div class="card">
              <div class="card-body">
                <h4 class="card-title">View All Course</h4>
                <p class="card-description">
                  Course Table <code></code>
                </p>
                <div class="table-responsive pt-3">
                  <table class="table table-bordered display" id="example" style="width:100%">
                    <thead>
                      <tr>
                        <th> # </th>
                        <th>User</th>
                        <th>Activity</th>
                        <th>User Role</th>
                        <th> Datetime</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                      $x = 0;

                      foreach ($logs  as $log) { ?>
                        <tr>
                          <td><?= ++$x ?></td>
                          <td><?= $log['username'] ?></td>
                          <td><?= $log['activity'] ?></td>
                          <td><?= $log['role'] ?></td>
                          <td><?= $log['activity_date'] ?></td>
                         
                          }
                          ?>
                        </tr>
                      <?php } ?>


                    </tbody>
                  </table>
                </div>
                <div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- content-wrapper ends -->
        <!-- partial:partials/_footer.html -->
        <?php include("../templates/footer.php"); ?>

        <!-- partial -->
      </div>
      <!-- main-panel ends -->
    </div>
    <!-- page-body-wrapper ends -->
  </div>
  <?php include("../templates/inc_scripts.php"); ?>
  <script>
    new DataTable('#example');
  </script>
</body>

</html>