<div class="tab-pane p-20" id="tabcheques" role="tabpanel">
    <div class="col-lg-12">
        <div class="card-block">
            <form action="<?php echo base_url(); ?>manutencao/adicionarChequeAPagamento" method="post"
                  name="formAddPreventiva" id="formAddPreventiva"
                  class="floating-labels m-t-40">
                <div class="form-body">
                    <input type="hidden" id="peca_id" name="peca_id">
                    <input type="hidden" id="pagamento_id" name="pagamento_id"
                           value="<?php echo $pagamento->ID_PAGAMENTO ?>"
                    >
                    <div class="row p-t-20 ">

                        <div class="form-group col-lg-3">
                            <input type="text" class="form-control" id="chequeemitente" name="chequeemitente"
                                   required>

                            <span class="">Emitente</span>
                            <!--                            <span class="bar"></span>-->
                            <!--                            <label for="input1">Emitente</label>-->
                        </div>

                        <div class="form-group col-lg-2">
                            <input type="text" class="form-control text-center"
                                   id="chequebanco"
                                   name="chequebanco"
                                   required
                            >
                            <span class="">Banco</span>
                        </div>


                        <div class="form-group col-lg-1">
                            <input type="text" class="form-control text-center"
                                   id="chequeagencia"
                                   name="chequeagencia"
                                   maxlength="5"
                                   required
                            >
                            <span class="">Agencia</span>
                        </div>

                        <div class="form-group col-lg-1">
                            <input type="text" class="form-control text-center"
                                   id="chequeconta"
                                   name="chequeconta"
                                   maxlength="8"
                                   required
                            >
                            <span class="">Conta</span>
                        </div>


                        <div class="form-group col-lg-2">
                            <input type="text" class="form-control text-left inputmask" id="chequevalor"
                                   name="chequevalor" required
                                   data-inputmask="'alias': 'numeric', 'groupSeparator': '', 'autoGroup': true, 'digits': 2, 'digitsOptional': false, 'prefix': '', 'placeholder': '0'"

                            >
                            <span class="">Valor</span>
                        </div>

                        <div class="form-group col-lg-2">
                            <input type="date" class="form-control text-center" id="chequedatavencimento"
                                   name="chequedatavencimento" required

                            >
                            <span class="">Vencimento</span>
                        </div>


                        <div class="form-group col-lg-1 ">
                            <button type="submit" id="botaoPecaServico" class="btn btn-info"
                            ><i
                                        class="fa fa-save"></i> Adicionar
                            </button>
                        </div>


                    </div>


                </div>

            </form>
        </div>
    </div>
    <hr>

    <div class="col-12">
        <div class="card">
            <div class="card-block">
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>Emitente</th>
                            <th>Banco</th>
                            <th>Agencia</th>
                            <th>Conta</th>
                            <th>Valor</th>
                            <th>Vencimento</th>
                            <th>Status</th>
                            <th class="text-nowrap">Ações</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($chequesPorPagamento as $r) { ?>
                            <tr>
                                <td><?php echo $r->ID_CHEQUE ?></td>
                                <td><?php echo $r->DS_EMITENTE ?></td>
                                <td><?php echo $r->DS_BANCO ?></td>
                                <td><?php echo $r->DS_AGENCIA ?></td>
                                <td><?php echo $r->DS_CONTA ?></td>
                                <td><?php echo $r->VL_CHEQUE ?></td>
                                <td><?php echo date('d/m/Y', strtotime($r->DT_VENCIMENTO)) ?></td>
                                <td>
                                    <span class="label label-table label-<?php echo is_null($r->DT_QUITACAO)? 'warning' : 'success' ?>"><?php echo is_null($r->DT_QUITACAO)? 'Pedente' : 'Quitado' ?></span>
                                </td>
                                <td class="text-nowrap">
                                    <a href="#" class="btn btn-default <?php echo is_null($r->DT_QUITACAO)?'':'disabled';?>"
                                       chequeItemExcluir="<?php echo $r->ID_CHEQUE ?>"

                                       data-toggle="modal" data-target="#modalExluirItem"
                                    > <i
                                                class="fa fa-trash-o text-danger"></i>
                                    </a>

                                    <a class="btn btn-default <?php echo is_null($r->DT_QUITACAO)?'':'disabled';?>"
                                       href="#"
                                       chequeAQuitar="<?php echo $r->ID_CHEQUE ?>"
                                       data-toggle="modal" data-target="#quitarPagamentoModal"
                                    >
                                        <i class="fa fa-money"></i>
                                    </a>
                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>


    <div class="modal-footer">
        <a href="<?php echo base_url() ?>manutencao" class="btn btn-default"><i
                    class="icon-arrow-left"></i> Voltar</a>
    </div>
</div>

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


<script type="text/javascript">
    $(document).on('click', 'a', function (event) {
        if ($(this).attr('chequeItemExcluir')) {
            $('#idItemExcluir').val($(this).attr('chequeItemExcluir'));
            $("#excluirItem").attr("action", "<?php echo base_url() ?>manutencao/excluirCheque/<?php echo $pagamento->ID_PAGAMENTO?>");
        }
    });
</script>

<script type="text/javascript">
    $(document).on('click', 'a', function (event) {
        if ($(this).attr('chequeAQuitar')) {
            $('#idItemQuitar').val($(this).attr('chequeAQuitar'));
            $("#formQuitarNota").attr("action", "<?php echo base_url() ?>manutencao/QuitarCheque/<?php echo $pagamento->ID_PAGAMENTO?>");
        }
    });
</script>