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

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Page Title -->
  <title>Web Infra Reports IT</title>
  <link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">

  <!-- JQuery -->
  <script src="/js/jquery-3.6.1.min.js"></script>
  <!-- Bootstrap -->
  <link rel="stylesheet" href="/css/bootstrap.min.css">
  <link rel="stylesheet" href="/css/bootstrap-icons/bootstrap-icons.css">
  <link rel="stylesheet" href="/css/preloader.css">
  <script src="/js/bootstrap.bundle.min.js"></script>
  <!-- Bootstrap-tables -->
  <link rel="stylesheet" href="/css/bootstrap-table.min.css">
  <script src="/js/bootstrap-table.min.js"></script>
  <script src="/js/bootstrap-table-fr-FR.min.js"></script>
  <script src="/js/tableExport.min.js"></script>
  <script src="/js/bootstrap-table-export.min.js"></script>
  <script src="/js/libs/js-xlsx/xlsx.core.min.js"></script>


</head>

<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<!-- HTML -->
<div class="container-fluid" id="content">
  <div class="row flex-nowrap">
    <!-- Left NAVBAR -->
    <div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
      <?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
    </div>
    <!-- Display -->
    <div class="col py-3">
      <!-- Page Title -->
      <h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">Script Execution Follow-up</span></h1>

      <!-- Main content -->
      <div class="container-fluid">
        <!-- MODAL WAIT -->
        <div class="modal fade bs-example-modal-sm" id="wait" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" style="padding-top: 15%;">
          <div class="modal-dialog modal-sm">
            <div class="modal-content">
              <div class="modal-header">
                <h4 class="modal-title mb-1 text-dark text-uppercase text-center" style="font-size: 1.5rem;">
                  <i class="bi bi-hourglass-split"></i><br> Work in progress ...
                </h4>
              </div>
              <div class="modal-body">
                <div class="progress">
                  <div class="progress-bar progress-bar-secondary progress-bar-striped progress-bar-animated" style="width: 100%"></div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- TABLE -->
        <div>
          <?php
            $sql = "SELECT cmd, MIN(ts) AS debut, MAX(ts) AS fin FROM x_stdout GROUP BY cmd ORDER BY fin DESC";
            $results = Invoke_infra($sql);
            echo "<div class='row'>";
            if (is_array($results)) {
              foreach ($results as $script) {
                $scriptName = $script['cmd'];
                $startTime = $script['debut'];
                $endTime = $script['fin'];
                echo "<div class='col-3 mb-3'>";
                echo "<a href='StdOut-detail.php?s=$scriptName&AIX=1&linux=1&DUN=1' class='btn btn-primary btn-lg' role='button'>";
                echo "<b>$scriptName</b><br><small>$startTime --> $endTime</small>";
                echo "</a>";
                echo "</div>";
              }
            }
            echo "</div>";
          ?>
        </div>
      </div>
      <!-- End of main content -->
    </div>
  </div>
</div>
</body>
<script src="/js/switch.js"></script>
</HTML>