<?php
$empresasDao = new \Dao\Empresas();
$empresasDao->getEmpresaPorId($conecta, base64_decode(filter_input(INPUT_GET, 'id')));
?>
<div class="breadcrumb-holder">
    <div class="container-fluid">
        <ul class="breadcrumb">
            <li class="breadcrumb-item"><a href="./">Home</a></li>
            <li class="breadcrumb-item active">Acessos Empresa | <?php echo $empresasDao->nome; ?></li>
        </ul><!--/.breadcrumb -->
    </div><!---/.container-fluid -->
</div><!--/.breadcrumb-holder -->
<section class="dashboard-counts section-padding">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header d-flex align-items-center">
                        <h2 class="h5 display">Lista Acessos Empresas</h2>
                    </div><!--/.card-header -->
                    <div class="card-footer">
                        <a href="?p=usuario&empresa=<?php echo base64_encode($empresasDao->id); ?>" class="btn btn-sm btn-success">
                            <i class="fa fa-plus"></i> Adicionar
                        </a>
                    </div>
                    <div class="card-body">
                        <table class="table table-striped" id="dataTables">
                            <thead>
                                <tr>
                                    <th>Nome</th>
                                    <th>Usuário</th>
                                    <th>Email</th>
                                    <th>Empresa</th>
                                    <th class="no-sort col-30"></th>
                                    <th class="no-sort col-30"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $acessosDao = new \Dao\Acessos();
                                $lst_acessos = $acessosDao->getLista($conecta, "AND fk_id_empresa = '" . $empresasDao->id . "'");
                                foreach ($lst_acessos as $acesso) {
                                    echo '
                                        <tr style="' . ($acesso->situacao != 'A' ? 'color: #f00 !important;' : '') . '">
                                            <td>' . $acesso->nome . '</td>
                                            <td>' . $acesso->usuario . '</td>
                                            <td>' . $acesso->email . '</td>
                                            <td>' . $empresasDao->nome . '</td>
                                            <td><a href="?p=usuario&empresa=' . base64_encode($acesso->fk_id_empresa) . '&id=' . base64_encode($acesso->id) . '" class="btn btn-sm btn-warning"><i class="fa fa-pencil"></i></a></td>
                                            <td><a href="?p=excluir-acesso&id=' . base64_encode($acesso->id) . '" class="btn btn-sm btn-danger btn-delete"><i class="fa fa-trash"></i></a></td>
                                        </tr>
                                    ';
                                }
//                                ?>
                            </tbody>
                        </table>
                    </div><!--/.card-body -->
                </div><!--/.card -->
            </div><!--/.col-lg-12 -->
        </div><!--/.row -->
    </div><!--/.container-fluid -->
</section><!--/.dashboard-counts -->