<?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.php");
    protegePagina();
    include "../var_sub.php";
    include "../conectar.php";
?>
<!DOCTYPE HTML>
<html>
<head>
    <?php
        include '../css.html';
    ?>
    <meta charset="UTF-8">
    <title>Gestão de Unidades - SGT</title>
</head>
<body>
    <div class="main_sgt">
        <?php
            include '../menu.html';
        ?>
        <div class="container-fluid content_sgt">
            <div class="tb_div_unid_comp_f">
                <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">
                                    Editar
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    ID
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    Unidade
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    Domínio
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    DDD
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    Descrição
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    Nome Patrimonio 1
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    e-mail Patrimonio 1
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    Nome Patrimonio 2
                                </div>
                            </th>
                            <th scope="col">
                                <div class="mx-sm-1">
                                    e-mail Patrimonio 2
                                </div>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php
                        $buscar = $pdo_sgt->query("SELECT * FROM tb_unidades ORDER BY id");
                        if($buscar->rowCount() > 0){
                            while($ver = $buscar->fetch(PDO::FETCH_ASSOC)){
                                echo'<tr align="center">'
                                    . '<td class="align-middle" scope="row" title="Editar">'
                                        . '<div class="mx-sm-1">'
                                            . '<a href="alt_unid.php?id='.$ver['id'].'">'
                                                . '<img title="Editar" src="../img/editar.png" height="15" width="15">'
                                            . '</a>'
                                        . '</div>'
                                    . '</td>'
                                    . '<td class="align-middle" title="ID">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['id']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="Unidade">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['unidade']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="Domínio">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['dominio']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="DDD">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['ddd']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="Descrição">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['des_unid']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="Nome Patrimonio 1">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['nome_pt1']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="e-mail Patrimonio 1">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['email_pt1']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="Nome Patrimonio 2">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['nome_pt2']
                                        . '</div>'
                                    .'</td>'
                                    . '<td class="align-middle" title="e-mail Patrimonio 2">'
                                        . '<div class="mx-sm-1">'
                                            .$ver['email_pt2']
                                        . '</div>'
                                    .'</td>'
                                . '</tr>';
                            }
                        }else{
                            echo'Sem dados cadastrais<br>';
                        }
                        echo'</tbody>';
                        echo'<tfoot>Contagem de unidades '.$buscar->rowCount().'</table>';
                    ?>
                </table>
            </div>
        </div>
        <?php
            include '../roda_pe.html';
        ?>
    </div>
</body>
</html>