<?php 
session_start();
if (!isset($_SESSION["nome"])) {
    header("location:index.php");
} else {
    
}

$seqUnidade=0;
if (isset($_GET["u"])){
    $seqUnidade=$_GET["u"];
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Bolsão Força Máxima</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
        <link href="../style.css" rel="stylesheet" type="text/css" />
        <link href="../css/bootstrap.css" rel="stylesheet"/>
        <link href="../css/bootstrap-theme.min.css" rel="stylesheet"/>
        <link href="../css/bootstrap.min.css" rel="stylesheet"/>
        <script src="../js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
        <script src="../js/prefixfree-1.0.7.js" type="text/javascript"></script>
        <script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="js/mainAdm.js" type="text/javascript"></script>

        <!-- IE10 viewport hack for Surface/desktop Windows 8 bug 
        <link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">-->

        <!-- Custom styles for this template -->
        
        

    </head>
    <?php
    include 'conexao.php';
    ?>
    <body>


        <div class="panel panel-default" >
            <div class="alert alert-primary"><b>CONSULTAS | Lista de Inscrições</b></div>
            <div class="panel-body">


                <div class=" form-group col-md-2">
                    <?php
                    $sql = "select * from bolsao where id > 17 order by id desc";
                    $res = mysqli_query($conexao, $sql);
                    ?>
                    <select class="form-control form-control-lg" name="bolsao" id="bolsao"  required>
                        <option value="0">Selecione o Bolsão</option>
                        <?php while ($row = mysqli_fetch_array($res)) { ?>
                            <option  value="<?php echo $row["id"]; ?>"/><?php echo $row["descricao"]; ?> 
                            <?php
                            next($row);
                        }
                        ?>
                    </select>
                </div>
                <div class=" form-group col-md-3">
                    <?php
                    if ($seqUnidade == 0) {
                        $sql = "select * from unidade where id not in(5,6,12,13) order by nome";
                    } else {
                        $sql = "select * from unidade where id in($seqUnidade) order by nome";
                    }
                    $res = mysqli_query($conexao, $sql);
                    ?>
                    <select class="form-control form-control-lg" onchange="filtrarSerie()" name="unidade" id="unidade"  required>                       
                        <?php while ($row = mysqli_fetch_array($res)) { ?>
                            <option  value="<?php echo $row["id"]; ?>"/><?php echo $row["nome"]; ?> 
                            <?php
                            next($row);
                        }
                        ?>
                    </select>
                </div>
                <div class=" form-group col-md-3">
                    <?php                  
                    $sql = "select distinct serie_ano as serie_ano from serie_ano_mensalidade where id_unidade = $seqUnidade order by serie_ano";
                    $res = mysqli_query($conexao, $sql);
                    ?>
                    <select class="form-control form-control-lg" name="serie" id="serie">
                        <option value="">Selecione a Série</option>
                        <?php while ($row = mysqli_fetch_array($res)) { ?>
                            <option  value="<?php echo $row["serie_ano"]; ?>"/><?php echo $row["serie_ano"]; ?> 
                            <?php
                            next($row);
                        }
                        ?>
                    </select>
                </div>
                <!--
                <div class="form-group col-md-2">
                                    <select name="turno" id="turno" class="form-control">
                                        <option value="">Selecione o turno</option>
                                        <option value="M">Manhã</option>
                                        <option value="T">Tarde</option>
                                    </select>
                                    
                                </div>
                -->
                <div class="form-group col-md-2">
                    <select class="form-control form-control-lg" name="dataProva" id="dataProva">
                        <?php
                        $sqlDiaHoraProva = "select * from dia_horario_prova where data_prova > curdate()"
                                . " and data_prova < '2020-12-31' order by data_prova";
                        $res = mysqli_query($conexao, $sqlDiaHoraProva);
                        ?>    

                        <option value="">Selecione a Data</option>
                        <?php
                        while ($value = mysqli_fetch_array($res)) {
                            echo "<option value=" . '"' . $value["data_prova"] . " - " . $value["horario_prova"] . '"' . ">" . date('d/m/Y', strtotime($value["data_prova"])) . " - " . $value["horario_prova"] . "</option>";
                            next($value);
                        }
                        ?>
                    </select>

                </div>

                <div class=" form-group col-md-2">
                    <a href="" id="btnBuscarInscritos"  target="lista"  class="btn btn-default" onclick="this.href = 'inscritos.php?b=' + document.getElementById('bolsao').value + '&u=' + document.getElementById('unidade').value + '&s=' + document.getElementById('serie').value + '&t=' + document.getElementById('dataProva').value">Buscar</a>
                </div>

            </div>



        </div>
        <div class="pcoded-content">
            <iframe width="100%" height="700" name="lista" frameborder="0"></iframe>
        </div>

    </body>
</html>



