<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-block">
                <h2 class="card-title">Listagem de Usuários</h2>
                <div align="right">
                    <a href="<?php echo base_url() ?>usuarios/adicionar/" class="btn btn-s-md btn-success"><i class="fa fa-user-plus fa-2x"></i> Adicionar</a>
                </div>
                <div class="table-responsive m-t-40">
                    <table id="example23" class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>Nome</th>
                            <th>CPF</th>
                            <th>Celular</th>
                            <th>Nível</th>
                            <th></th>
                            <th></th>
                        </tr>
                        </thead>
                        <tfoot>
                        <tr>
                            <th>#</th>
                            <th>Nome</th>
                            <th>CPF</th>
                            <th>Celular</th>
                            <th>Nível</th>
                            <th></th>
                            <th></th>
                        </tr>
                        </tfoot>
                        <tbody>
                        <?php foreach ($results as $r) {
                            if ($r->nivel == 1) {
                                $nivel = "Administrador";
                            } else if ($r->nivel == 2) {
                                $nivel = "Operacional";
                            } else if ($r->nivel == 3) {
                                $nivel = "Administrativo";
                            } else if ($r->nivel == 4) {
                                $nivel = "Portaria";
                            }
                            ?>
                            <tr>
                                <td><?php echo $r->idUsuarios ?></td>
                                <td><?php echo $r->nome ?></td>
                                <td><?php echo $r->cpf ?></td>
                                <td><?php echo $r->celular ?></td>
                                <td><?php echo $nivel ?></td>
                                <td><a href="<?php echo base_url()?>usuarios/editar/<?php echo $r->idUsuarios ?>" class="" title="Editar Usuário"><i class="fa fa-pencil-square-o color-btn-edit"></i></a></td>
                                <td><a href="#modalExcluirAtestado" role="button" data-toggle="modal" idUsu=" <?php echo $r->idUsuarios ?>"  title="Excluir Morador"><i class="fa fa-trash-o" style="color:red"></i></a></td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $('#example23').DataTable({
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    });
</script>
<!--Excluir Atestado Médico-->
<div class="modal fade" id="modalExcluirAtestado">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="<?php echo base_url() ?>usuarios/excluir" method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h5 id="myModalLabel">Excluir Usuário</h5>
                </div>
                <div class="modal-body">
                    <input type="hidden" id="idUsuario" name="id" value=""/>
                    <h5 style="text-align: center">Deseja realmente excluir este usuário?</h5>
                </div>
                <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
                    <button class="btn btn-danger">Excluir</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<script type="text/javascript">
    $(document).on('click', 'a', function (event) {
        var atestadoid = $(this).attr('idUsu');
        $('#idUsuario').val(atestadoid);

    });
</script>    