<?php
    include('php/configbd.php');
?>
<!DOCTYPE html>
<html>
<head>
    <title>Torneos Actuales</title>
    <meta charset="utf-8">
    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Acme" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Questrial" rel="stylesheet">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="CSS/normalize.css">
    <link rel="stylesheet" href="CSS/styles.css">
    <link rel="stylesheet" type="text/css" href="CSS/css2.css">
    <link rel="stylesheet" type="text/css" href="CSS/tabla.css">
</head>
<style>

</style>

<body>
    <header class="site-header">
        <div class="contenedor contenido-header">
            <div class="barra bar2">
                <a href="../index.html">
                    TorneosFut25
                </a>
  
                <div class="mobile-menu">
                    <a href="#navegacion">
                        <img src="img/barras.svg" alt="Icono Menu">
                    </a>
                </div>
  
                <nav id="navegacion" class="navegacion">
                  <ul>
                    <li><a href="index.html">Inicio</a></li>
                    <li><a href="about.html">Sobre nosotros</a></li>
                    <li><a class="drop" href="#">Torneos</a>
                      <ul class="submenu">
                        <li><a href="torneos.php">Actual</a></li>
                        <li><a href="torneosAnteriores.php">Anteriores</a></li>
                      </ul>
                    </li>
                    <li><a href="#">Ingresar</a>
                    <ul class="submenu">
                        <li><a href="loginAdmin.html">Administrador</a></li>
                        <li><a href="loginArbitro.html">Arbitro</a></li>
                    </ul>
                  </li>
                  </ul>
                </nav>
            </div>
        </div>
    </header>

    <main class="contenedor contenedor-opciones">
        <h2>Torneos en Curso: </h2>
<center>
        <table id="torneos">
          <tr>
            <th>Nombre</th>
            <th>Tipo</th>
            <th>Fecha Inicio (A-M-D)</th>
            <th>Fecha Fin (A-M-D)</th>
            <th>Selecciona</th>
          </tr>
            
            <?php

                $sql2 = "SELECT * FROM torneo WHERE fechaFinal>=now();";

                $result = mysqli_query($db, $sql2);

                if ($result->num_rows > 0) {
                  // output data of each row
                  while($row = $result->fetch_assoc()) {
                    echo "<tr>";
                    echo "<td>".$row["Nombre"]."</td>";
                    echo "<td>".$row["Tipo"]."</td>";
                    echo "<td>".$row["fechaInicial"]."</td>";
                    echo "<td>".$row["fechaFinal"]."</td>";
                    echo "<td><a href='verTorneo.php?idTorneo=".$row["idTorneo"]."'>Ver Detalle</a></td>";
                    echo "</tr>";
                  }
                } else {
                  echo "No tienes partidos asignados";
                }
            ?> 
            
        </table>

        <br><br><br>
        <h2>Equipos registrados actualmente: </h2>
        <table id="torneos">
          <tr>
            <th>Nombre</th>
            <th>Fecha Creacion</th>
            <th>Seleccionar</th>
          </tr>
            
            <?php

                $sql3 = "SELECT * FROM equipo; ";

                $result = mysqli_query($db, $sql3);

                if ($result->num_rows > 0) {
                  // output data of each row
                  while($row = $result->fetch_assoc()) {
                    echo "<tr>";
                    echo "<td>".$row["Nombre"]."</td>";
                    echo "<td>".$row["fechaCreacion"]."</td>";
                    echo "<td><a href='verEquipo.php?idEquipo=".$row["idEquipo"]."&nombreEquipo=".$row["Nombre"]."'>Ver Detalle</a></td>";
                    echo "</tr>";
                  }
                } else {
                  echo "No tienes partidos asignados";
                }
            ?> 
            
        </table>
</center>

    </main>	

<footer class="site-footer seccion">
  <div class="contenedor contenedor-footer">
      <nav class="navegacion">
        <a href="index.html">Inicio</a>
        <a href="about.html">Sobre nosotros</a>
        <a href="help.html">Ayuda</a>
      </nav>
      <p class="equipo">Memije A. Alfredo Raymundo | Jesus F. Cabañas Baxcajay | Aldo Flores Aguilar</p>
  </div>
</footer>
</body>

</html>
