<div class="portlet">

    <div class="portlet-header">

        <h3>
            <i class="fa fa-table"></i>Cadastro de Moradores

            <div align="right">
                <div class="dt-buttons btn-group">
                    <a class="btn btn-default" id=""
                       href="<?php echo base_url().'morador/gerenciar'?>" title="Entries"><span><i
                                class="fa fa-bars"></i></span>
                    </a>

                    <a class="btn btn-default"
<!--                       href="--><?php //echo base_url(); ?><!--morador/listarMorador/--><?php //echo $sitMoradores == 1 ? "Inativos" : "" ?><!--"-->
                    >
<!--                    <i class="fa fa-search">--><?php //echo $sitMoradores == 1 ? " Inativos" : " Ativos" ?><!--</i>-->
                    </a>


                </div>
            </div>
        </h3>



    </div>
    <!-- /.portlet-header -->

    <div class="portlet-content">

        <div class="table-responsive">
            <div align="right">
                <a href="<?php echo base_url(); ?>morador/adicionar" class="btn btn-s-md btn-success"><i
                        class="fa fa-user-plus fa-2x"></i> Adicionar</a>

            </div>

            <table
                class="table table-striped table-bordered table-hover table-highlight table-checkable"
                data-provide="datatable"
                data-display-rows="10"
                data-info="true"
                data-search="true"
                data-length-change="true"
                data-paginate="true"
            >
                <thead>
                <tr>
                    <th data-sortable="true" data-direction="desc"><input type="checkbox" class="icheck-input"></th>
                    <th class="checkbox-column"><input type="checkbox" class="icheck-input"></th>
                    <th data-filterable="true" data-sortable="true" data-direction="desc">Nome Morador</th>
                    <th data-filterable="false" class="hidden-xs hidden-sm">Relação</th>
                    <th data-filterable="true" data-sortable="true">Unidade</th>
                    <th data-filterable="true" data-sortable="true">CPF</th>
                    <th data-filterable="false" class="hidden-xs hidden-sm">Email Morador</th>
                    <th data-filterable="true" class="hidden-xs hidden-sm">Celular</th>
                    <th></th>
                    <th></th>
                    <th></th>
                </tr>
                </thead>
                <tbody>

                <?php
                foreach ($results as $r) {
                    $situacaoMorador = $r->ID_NOTA == 1 ? 'event-success' : 'event-warning';
                    echo '<tr>';
                    echo '<td class="checkbox-column">' . $r->ID_NOTA . '</td>';
                    echo '<td class="checkbox-column"><a href="#modalInativarMorador" data-toggle="modal" morador="' . $r->ID_NOTA . '"  situacaoMorador="' . $r->ID_NOTA . '"><span class="compromisso ' . $situacaoMorador . '"></span></a></td>';
                    echo '<td>' . $r->ID_NOTA . ' ' . $r->ID_NOTA . '</td>';
                    echo '<td>' . $r->ID_NOTA . '</td>';
                    echo '<td>' . $r->ID_NOTA . '-' . $r->ID_NOTA . '</td>';
                    echo '<td>' . $r->ID_NOTA . '</td>';
                    echo '<td>' . $r->ID_NOTA . '</td>';
                    echo '<td class="hidden-xs hidden-sm">' . $r->ID_NOTA . '</td>';

                    echo '<td>
                                           <a href="' . base_url() . 'morador/visualizar/' . $r->ID_NOTA . '" title="Ver mais detalhes"><i class="fa fa-eye"></i></a></td>';
                    echo '<td>
                                           <a href="' . base_url() . 'morador/editar/' . $r->ID_NOTA . '" 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" morador="' . $r->ID_NOTA . '"  title="Excluir Morador"><i class="fa fa-trash-o" style="color:red"></i></a>

                                        </td>';
                    echo '</tr>';
                }
                ?>
                </tbody>
            </table>
        </div>
        <!-- /.table-responsive -->


    </div>
    <!-- /.portlet-content -->

</div>
<!-- /.portlet -->


<div class="modal fade" id="modal-form">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="<?php echo base_url() ?>morador/excluir" method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h5 id="myModalLabel">Excluir Morador</h5>
                </div>
                <div class="modal-body">
                    <input type="hidden" id="idMorador" name="id" value=""/>
                    <h5 style="text-align: center">Deseja realmente excluir este morador?</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>


<div class="modal fade" id="modalInativarMorador">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="<?php echo base_url() ?>morador/alterarSituacaoMorador" method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h5 id="myModalLabel">Adimplencia do Morador</h5>
                </div>
                <div class="modal-body">
                    <input type="hidden" id="idMoradorInativo" name="id" value=""/>
                    <input type="hidden" id="situacaoMoradorAtual" name="situacaoMoradorAtual" value=""/>
                    <h5 style="text-align: center">Deseja realmente modificar a Situação desse morador?</h5>
                </div>
                <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
                    <button class="btn btn-danger"><i class="fa fa-save"></i> Alterar</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

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

        var situacaoMoradorMor = $(this).attr('situacaoMorador');
        $('#situacaoMoradorAtual').val(situacaoMoradorMor);
        $('#idMoradorInativo').val(moradorid);


    });
</script>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/sweetalert2/6.1.1/sweetalert2.min.css">
<script src="https://cdn.jsdelivr.net/sweetalert2/6.1.1/sweetalert2.min.js"></script>

<!--<span style="font-size: larger">Maria</span>-->



<style>
    .text-center {
        margin-top: 140px;
    }
</style>


<style>
    .compromisso {
        display: inline-block;
        width: 15px;
        height: 15px;
        border-radius: 8px;
        margin-right: 5px;
    }

    .event-success {
        background-color: #70ba63;
    }

    .event-warning {
        background-color: #f2b635;
    }
</style>




