<?php
header('Content-type: text/html; charset=utf-8');
?>
<!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>Colégio 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 rel="icon" href="../images/favicon.ico" ></link>
            <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"/>
            <link rel="stylesheet" href="../css/bootstrap-multiselect.css" />
            <script src="../js/bootstrap-multiselect.js"></script>
            <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 -->
            <link href="../css/jumbotron.css" rel="stylesheet"/>

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

        $sql = "select distinct i.inscricao,initcap(i.nome) nome, i.qtde_port port, i.qtde_mat mat, i.conhecimentos"
//                . ",i.redacao "
                . " from inscricoes i"
                . " where i.id_bolsao=" . $_GET["b"] . "  and i.unidade='" . $_GET["u"] . "' "
                . " and i.serie_ano='" . $_GET["s"] . "'"
                //. " and upper(i.horario)='" . $_GET["t"] . "'"
                . " order by trim(i.nome)";
        // echo $sql;
        $res = mysqli_query($conexao, $sql) or die("ERRO NA QUERY: " . mysqli_error());
        //   echo $_GET["s"];
        ?>
        <form action="gravacaoNotas.php" method="post">

            <div class="panel panel-default" >
                <div class="alert alert-success"><b>Notas</b></div>
                <div class="panel-body">


                    <?php if ($_GET["s"] == '1o ano' || $_GET["s"] == '2o ano' || $_GET["s"] == '3o ano' || $_GET["s"] == '4o ano' || $_GET["s"] == '5o ano') { ?>

                        <div class="table-responsive">
                            <table class="table  table-bordered table-striped table-hover table-sm">
                                <thead >
                                    <tr>
                                        <th style="width: 70%">Nome</th>
                                        <th style="width: 10%">Português</th>
                                        <th style="width: 10%">Matemática</th>
                                        <th style="width: 10%">Con.Gerais</th>                                       
                                    </tr>
                                </thead>
                                <tbody>
                                    
                                <?php } else { ?>

                                    <table class="table  table-bordered table-striped table-hover table-sm">
                                        <thead >
                                            <tr>
                                                <th style="width: 70%">Nome</th>
                                                <th style="width: 10%">Português</th>
                                                <th style="width: 10%">Matemática</th>
                                                <th style="width: 10%">Con.Gerais</th>                                      
                                            </tr>
                                        </thead>
                                        <tbody>
                                           
                                        <?php } ?>

                                        <?php
                                        while ($row = mysqli_fetch_array($res)) {
                                            ?>

                                            <?php if ($_GET["s"] == '1o ano' || $_GET["s"] == '2o ano' || $_GET["s"] == '3o ano' || $_GET["s"] == '4o ano' || $_GET["s"] == '5o ano') { ?>
                                                <tr>
                                                    <td style="width: 90%">
                                                        <?php echo "<spam class='label-' >" . $row["inscricao"] . " - " . $row["nome"] . "</spam><br>"; ?>
                                                    </td>

                                                    <td style="width: 10%">
                                                        <?php echo "<input onkeyup='validarNota()' step='any' type='number'  name='conhecimentos[]' id='conhecimentos' class='form-control' value='" . $row["conhecimentos"] . "'/>"; ?>
                                                    </td>
                                                    <div hidden>
                                                        <input hidden type="number" name="portugues[]" id="portugues" class="form-control" value="0" />
                                                    </div>
                                                    <div hidden>
                                                        <?php echo "<input  type='number'  name='matematica[]' id='matematica' class='form-control' value='0'/>"; ?>
                                                    </div>


                                                    <!--                            <div hidden>
                                                    <?php // echo "<input hidden step='any' type='number'  name='redacao[]' id='redacao' class='form-control' value='0'/>"; ?>
                                                                                </div>-->

                                                <?php } else { ?>
                                                    <td style="width: 70%">
                                                        <?php echo "<spam class='label-' >" . $row["inscricao"] . " - " . $row["nome"] . "</spam><br>"; ?>
                                                    </td>

                                                    <td style="width: 10%">
                                                        <input onkeyup="validarNota()" type="number" name="portugues[]" id="portugues" class="form-control" value="<?php echo $row['port']; ?>" />
                                                    </td>
                                                    <td style="width: 10%">
                                                        <?php echo "<input onkeyup='validarNota()' type='number'  name='matematica[]' id='matematica' class='form-control' value='" . $row["mat"] . "'/>"; ?>
                                                    </td>
                                                    <td style="width: 10%">
                                                        <?php echo "<input onkeyup='validarNota()' type='number'  name='conhecimentos[]' id='conhecimentos' class='form-control' value='" . $row["conhecimentos"] . "'/>"; ?>
                                                    </td>
                                                    <!--                            <div class="form-group col-md-2">
                                                    <?php //  echo "<input onkeyup='validarNota()' step='any' type='number'  name='redacao[]' id='redacao' class='form-control' value='" . $row["redacao"] . "'/>"; ?>
                                                                                </div>-->
                                                <?php } ?>


                                                <div hidden>
                                                    <?php echo "<input hidden  type='number'  name='ingles[]' id='ingles' class='form-control' value='0'/>"; ?>
                                                </div>
                                                <div  hidden>
                                                    <?php echo "<input type='text' name='inscricao[]' id='inscricao' value='" . $row["inscricao"] . "'/>"; ?>
                                                </div>


                                            </tr>
                                            <?php
                                            next($row);
                                        }
                                        ?>
                                    </tbody>
                                </table>
                                <center>
                                    <input type="submit" class="btn btn-primary btn-block" value="Gravar"/>
                                </center>
                                </div>



                                </div>
                                </form>
                                </div>
                                </body>
                                </html>

