<div class="row">
    <div class="col-12">
        <div class="card">

            <div class="card-block">
                <div class="btn-group float-right" role="group" aria-label="Basic mixed styles example">
                    <a href="<?php echo base_url();?>manutencao/listarTodosChequesPorFiltro" class="btn btn-danger">Cheque</a>
                    <button type="button" class="btn btn-warning">Boleto</button>
<!--                    <button type="button" class="btn btn-success">Right</button>-->
                </div>

                <h2 class="card-title">Listagem de Pagamentos</h2>
                <div align="right">
                </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 width="10">#</th>
                            <th width="20">Data</th>
                            <th>Cliente</th>
                            <th>Forma PGTO</th>
                            <th width="30">Situação</th>
                            <th width="50">Ações</th>
                        </tr>
                        </thead>
                        <tfoot>
                        <tr>
                            <th width="10">#</th>
                            <th width="20">Data</th>
                            <th>Cliente</th>
                            <th>Forma PGTO</th>
                            <th width="30">Situação</th>
                            <th width="50">Ações</th>
                        </tr>
                        </tfoot>
                        <tbody>
                        <?php foreach ($pagamentos as $r) { ?>
                            <tr>
                                <td><?php echo $r->ID_PAGAMENTO ?></td>
                                <td><?php echo date('d/m/Y', strtotime($r->DT_PAGAMENTO)) ?></td>
                                <td><?php echo $r->NM_CLIENTE ?></td>
                                <td><?php echo $r->DS_FORMA_PAGAMENTO ?></td>
                                <td><?php echo $r->DS_SITUACAO ? "Quitado" : "Em Aberto" ?></td>
<!--                                <td>--><?php //echo $r->CLIENTE_ID ?><!--</td>-->
<!--                                <td>--><?php //echo number_format($r->VL_PEDIDO, 2, ',', '.') ?><!--</td>-->
<!--                                <td>--><?php //echo $r->NM_PRODUTO ?><!--</td>-->
<!--                                <td>--><?php //echo $r->NM_VENDEDOR ?><!--</td>-->
<!--                                <td style="color: red">--><?php //echo is_null($r->DT_PREVISAO_PAGAMENTO) ? "" : date('d/m/Y', strtotime($r->DT_PREVISAO_PAGAMENTO)) ?><!--</td>-->
                                <td>

<!--                                    <a href="#" class=" --><?php //echo is_null($r->DT_QUITADO) ? '' : 'isDisabled'; ?><!--"-->
<!--                                       notaAQuitar="--><?php //echo $r->ID_NOTA ?><!--"-->
<!--                                       data-toggle="modal" data-target="#quitarNotaModal"-->
<!--                                    > <i class="fa fa-money"> </i>-->
<!--                                    </a>-->
                                    <a
                                       href="<?php echo base_url().'manutencao/visualizarPagamento/'.$r->ID_PAGAMENTO ?>"
                                       class="btn btn-default  <?php echo is_null($r->DS_SITUACAO) ? '' : 'isDisabled'; ?>"

                                    >
                                        <i class="fa fa-pencil-square-o"></i>
                                    </a>
<!--                                    <a href="#" class="waves-effect waves-light "-->
<!--                                       imprimirNota="--><?php //echo $r->ID_NOTA ?><!--"-->
<!---->
<!--                                       data-toggle=""-->
<!--                                       data-target=""-->
<!--                                    > <i class="fa fa-print"></i>-->
<!--                                    </a>-->
<!--                                    <a href="-->
<!--                                    --><?php //echo base_url().'manutencao/editarNotasDetalhado/'.$r->ID_NOTA ?>
<!---->
<!--                                            "-->
<!--                                       title="Editar"><i-->
<!--                                                class="fa fa-pencil-square-o color-btn-edit"></i>-->
<!--                                    </a>-->


                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $('#example23').DataTable({
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    });
</script>

<script>
    $('a').on('click', function (e) {
        if ($(this).attr('imprimirNota')) {
            var preventiva = $(this).attr('imprimirNota')
            abreImpressaoPreventiva(preventiva);
            return false;
        }
    });


    function abreImpressaoPreventiva(preventiva) {
        var url = "<?php echo base_url() ?>relatorios/visualizarNotaPorID/" + preventiva;
        var win = window.open(url, target = "_blank", "left=400,top=300,width=700,height=500,location=no,menubar=no,toolbar=no");
        win.print();
    }
    ;
</script>

<?php $this->load->view("sistema/modais/notas/quitarNotaModal"); ?>
<?php $this->load->view("sistema/modais/notas/editarNotaModal"); ?>

