<?php
#   SGT - The SGT for Internet - http://sgt.eti.br
#   Copyright (c) 2016-2018, Jean Azevedo. All rights reserved.

#   This file is part of SGT.

#   SGT is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   any later version.

#   SGT is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

    include("../seguranca_adm_av.php");
    protegePagina();
    include "../var.php";
    include "../conectar.php";
?>
<!DOCTYPE HTML>
<html>
    <head>
        <?php
            include '../css.html';
        ?>
        <meta charset="UTF-8">
        <title>Lista de Tabelas - SGT</title>
    </head>
    <body>
        <div class="main_sgt">
            <?php
                include '../menu.html';
            ?>
            <div class="container-fluid">
                <div class="table-responsive-sm tab_sgt content_tb_sgt">
                    <table class="table-responsive-xl table-striped table-hover table-condensed table-bordered">
                        <thead>
                            <tr align="center" bgcolor=#B8DAFF>
                                <th scope="col">
                                    <div class="mx-sm-1">
                                        Tabela
                                    </div>
                                </th>
                                <th scope="col">
                                    <div class="mx-sm-1">
                                        Campo
                                    </div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php
                        $buscar_tb = 'SHOW TABLES';
                        $buscar_tb_ = $pdo_sgt->query($buscar_tb);
                        while ($nome = $buscar_tb_->fetch(PDO::FETCH_NUM)) {
                            $nome_tb = $nome[0];
                            $buscar_desc = "DESC $nome_tb";
                            $buscar_desc_ = $pdo_sgt->query($buscar_desc);
                            while ($camp = $buscar_desc_->fetch(PDO::FETCH_NUM)) {
                                echo'<tr align="center">'
                                    . '<td class="align-middle" scope="row" title="Tabela">'
                                        . '<div class="mx-sm-1">'
                                            .$nome[0]
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="Tabela">'
                                        . '<div class="mx-sm-1">'
                                            .$camp[0]
                                        . '</div>'
                                    .'</td>'
                                . '</tr>';
                            }
                        }
                        ?>
                        </tbody>
                        <tfoot></tfoot>
                    </table>    
                </div>
            </div>
            <?php
                include '../roda_pe.html';
            ?>
        </div>
    </body>
</html>