<div class="m-b-md"><h3 class="m-b-none">Funcionários Cadastrados</h3></div>
<section class="panel panel-default">
    <header class="panel-heading">Listagem de Funcionários Cadastrados</header>
    <div class="row wrapper">
        <form action="<?php echo base_url() . 'funcionario/gerenciar'; ?>" method="GET">
            <div class="form-group">
                <div class="col-sm-6">
                    <div class="row">
                        <div class="col-md-5">
                            <input type="text" class="input-sm form-control" name="nomeFuncionario"
                                   placeholder="Nome Funcionário">
                        </div>
                        <div class="col-md-5">
                            <input type="text" class="input-sm form-control" name="cpfFuncionario" placeholder="CPF"
                                   maxlength="14" onKeyDown="Mascara(this, Cpf);" onKeyPress="Mascara(this, Cpf);"
                                   onKeyUp="Mascara(this, Cpf);">
                        </div>
                        <div class="col-md-2">
                            <button class="btn btn-sm btn-s-md" type="submit"><i class="fa fa-search"></i> Filtrar!</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <!--</div>-->

        <div align="center">
            <a href="<?php echo base_url(); ?>funcionario/adicionar" class="btn btn-s-md btn-success"><i class="fa fa-plus"></i> Adicionar</a>
        </div>

    </div>

    <div class="table-responsive">
        <table class="table table-striped b-t b-light">
            <thead>
            <tr>
                <th width="20"><label class="checkbox m-l m-t-none m-b-none i-checks"><input
                            type="checkbox"><i></i></label></th>
                <th width="30">#</th>
                <th width="50">#</th>
                <th>Nome</th>
                <th>Função</th>
                <th>Celular</th>
                <th width="30"></th>
                <th width="30"></th>
                <th width="30"></th>


            </tr>
            </thead>


            <tbody>

            <?php
            //var_dump($results);
            foreach ($results as $r) {
                if (!empty($r->foto_url)) {
                    $imagem = base_url() . 'imagensFuncionario/' . $r->foto_url;
                } else {
                    $imagem = base_url() . 'assets/site/images/semImagem.jpg';
                }

                echo '<tr>';
                echo '<td><label class="checkbox m-l m-t-none m-b-none i-checks"><input type="checkbox" name="post[]"><i></i></label></td>';
                echo '<td>' . $r->idFuncionario . '</td>';
                echo '<td>  <span class="thumb avatar pull-left m-r">
                                                    <img src="' . $imagem . '" class="dker" style=" max-width: 50px;height: 47px;" alt="...">
                                                   
                                                </span> </td>';
                echo '<td>' . $r->nomeFuncionario . '</td>';
                echo '<td>' . $r->funcao . '</td>';
                echo '<td>' . $r->telCelular . '</td>';


                echo '<td>
                                           <a href="' . base_url() . 'funcionario/visualizar/' . $r->idFuncionario . '" title="Ver mais detalhes"><i class="fa fa-eye"></i></a></td>';
                echo '<td>
                                           <a href="' . base_url() . 'funcionario/editar/' . $r->idFuncionario . '" title="Editar"><i class="fa fa-pencil-square-o color-btn-edit"></i></a></td>';
                echo '<td>
                                           
                                        <a href="#modal-form" role="button" data-toggle="modal" urlarquivo="' . $r->foto_url . '" funcionario="' . $r->idFuncionario . '"  title="Excluir Funcionario"><i class="fa fa-trash-o" style="color:red"></i></a>
                                        
</td>';
                echo '</tr>';
            }
            ?>


            </tr>
            </tbody>
        </table>
    </div>
    <footer class="footer hidden-xs no-padder text-center-nav-xs">
        <a href="../../../../index.php" data-toggle="ajaxModal"
           class="btn btn-icon icon-muted btn-inactive pull-right m-l-xs m-r-xs hidden-nav-xs">
            <i class="i i-logout"></i>
        </a>
        <a href="#nav" data-toggle="class:nav-xs" class="btn btn-icon icon-muted btn-inactive m-l-xs m-r-xs">
            <i class="i i-circleleft text"></i>
            <i class="i i-circleright text-active"></i>
        </a>
        <?php echo $this->pagination->create_links(); ?>
    </footer>
</section>


<div class="modal fade" id="modal-form">
    <div class="modal-dialog">
        <div class="modal-content">


            <form action="<?php echo base_url() ?>funcionario/excluir" method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h5 id="myModalLabel">Excluir Funcionario</h5>
                </div>
                <div class="modal-body">
                    <input type="hidden" id="idFuncionario" name="id" value=""/>
                    <input type="hidden" id="urlarquivos" name="arquivo" value=""/>
                    <h5 style="text-align: center">Deseja realmente excluir este Funcionario?</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 funcionario = $(this).attr('funcionario');
        $('#idFuncionario').val(funcionario);

        var urlarq = $(this).attr('urlarquivo');
        $('#urlarquivos').val(urlarq);

    });

</script>


<!-- Modal -->
