<div class="well">

    <div class="page-header">
        <h1>Listar usuários</h1>
    </div>
    <?php
    if (isset($_SESSION['msg'])):
        echo $_SESSION['msg'];
        unset($_SESSION['msg']);
    endif;
    if (isset($_SESSION['msgcad'])):
        echo $_SESSION['msgcad'];
        unset($_SESSION['msgcad']);
    endif;
    
    $paginacao = $this->Dados[1];
    $this->Dados = $this->Dados[0];
    ?>

    <div class="pull-right">
        <a href="<?php echo URL; ?>controle-usuario/cadastrar"><button type="button" class="btn btn-sm btn-success">Cadastrar</button></a>
    </div>

    <?php
    if (!empty($this->Dados)):
        ?>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Nome</th>
                    <th class="hidden-xs">E-mail</th>
                    <th>ID Cliente</th>                    
                    <th>Cnpj</th>
                    <th>Ações</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($this->Dados as $user) {
                    extract($user);
                    // 
                    $mostra="";
                     if ($_SESSION['niveis_acesso_id'] == "1") :
                        $mostra = "sim";
                     endif;    
                     if ($niveis_acesso_id == "2") :
                        $mostra = "sim";
                     endif;    
                     if ($niveis_acesso_id == "3") :
                        $mostra = "sim";
                     endif;    
                     if ($niveis_acesso_id == "4") :
                        $mostra = "sim";
                     endif;    
                     
                     
                    if ($mostra == "sim") :      
                    ?>               
                    <tr>
                        <!--<td><?php echo $niveis_acesso_id; ?></td>-->
                        <td><?php echo $id; ?></td>
                        <td><?php echo $name; ?></td>
                        <td class="hidden-xs"><?php echo $email; ?></td>
                        <td><?php echo $customercode; ?></td>
                        <td><?php echo $cnpj; ?></td>
                        <td>
                            <a href="<?php echo URL; ?>controle-usuario/visualizar/<?php echo $id; ?>"><button type="button" class="btn btn-primary">Visualizar</button></a>

                            <a href="<?php echo URL; ?>controle-usuario/Editar/<?php echo $id; ?>"><button type="button" class="btn btn-warning">Alterar</button></a>

                            <a href="<?php echo URL; ?>controle-usuario/apagar/<?php echo $id; ?>"><button type="button" class="btn btn-danger">Apagar</button></a>
                        </td>
                    </tr>

                    <?php
                    
                    endif;
                }
                
                ?>
            </tbody>
        </table>
        <?php
    endif;
    echo $paginacao;
    ?>
</div>

