<?php

require 'functions.php';

$cursos = listarCursos();
$encontrou = count($cursos) > 0;

?>
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ivprog_log_analysis</title>
    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <link href="css/style.css" rel="stylesheet" />
  </head>

  <body>
    <nav class="navbar navbar-expand-md navbar-dark fixed-top" style="background-color: #03396c;">
      <b><a class="navbar-brand" href="./">ivprog_log_analysis - Ambiente de análise dos logs do iVProgH</a></b>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
            <a class="nav-link" href="./" title=""></a>
          </li>
          </ul>
      </div>
    </nav>

    <main role="main">
      <div class="jumbotron ivprogh-desc">
        <div class="container">
          <?= instrucoes() ?>
        </div>
      </div>


      <div class="container ivprog-container" style="padding: 3em; margin-top: 3em;">
        <form action="process.php" method="get" novalidate>
          <div class="form-group row">
            <label for="inputname" class="col-sm-2 col-form-label">Curso:</label>
            <div class="col-sm-10">
              <select class="form-control" id="inputname" name="curso" <?= ($encontrou?"":"disabled") ?> >
                <?php

                  if ($encontrou) {
                    for ($i = 0; $i < count($cursos); $i++) {
                      echo "<option>" . $cursos[$i] . "</option>";
                    }
                  } else {
                    echo "<option> Nenhum curso foi encontrado </option>";
                  }
                ?>
              </select>
            </div>
        </div>
      
      <div class="form-group row">
          <div class="offset-sm-2 col-sm-10">
            <button type="button" class="btn btn-secondary" disabled="">Voltar</b utton>
            <button type="submit" class="btn btn-primary" <?= ($encontrou?"":"disabled") ?>>Continuar</button>
            <span class="reported" style="color: green; font-size: 120%;"></span>
            <span class="error" style="color: red; font-size: 120%;"></span>
          </div>
        </div>

        </form>
      </div>


      <div>
        
      </div>
    </main>
    <footer class="container text-center">
      <a href="http://www.ime.usp.br/line">iVProgH</a> | 
      <a href="http://www.ime.usp.br/line">LInE</a> |
      <a href="http://www.matematica.br">iM&aacute;tica</a>
    </footer>

    <script src="./js/jquery.min.js"></script>
    <script src="./js/bootstrap.bundle.min.js"></script>


    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css">
  </body>
</html>
