<?php include_once('../../../config.php') ?>

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Sisplan Web | Cadastro de Cheque</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Theme style -->
    <link rel="stylesheet" href="../dist/css/adminlte.min.css?versao=3.255.15.1">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css?versao=3.255.15.1">
    <!-- Google Font: Source Sans Pro -->
    <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,600,700,400italic' rel='stylesheet' type='text/css'>

    <link rel="stylesheet" type="text/css" href="../dist/css/dataTables.bootstrap4.min.css?versao=3.255.15.1" />

    <link href='../dist/css/bootstrap.min.css?versao=3.255.15.1'>
    <link rel="stylesheet" href="../dist/css/custom.css?versao=3.255.15.1">
    <link rel="stylesheet" href="../dist/css/sisplan.css?versao=3.255.15.1">
    <link rel="stylesheet" type="text/css" href="../plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.255.15.1">
    <link rel="stylesheet" type="text/css" href="../dist/css/responsive.bootstrap.min.css?versao=3.255.15.1">
    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" href="../dist/css/cadastro.css?versao=3.255.15.1">

    <!-- Toastr -->
    <link rel="stylesheet" href="../plugins/toastr/toastr.min.css?versao=3.255.15.1">
    <link rel="stylesheet" type="text/css" href="../dist/css/driver.min.css?versao=3.255.15.1" />
    <link rel="stylesheet" href="../dist/css/jquery-ui.css?versao=3.255.15.1">
    <!-- Google Font: Source Sans Pro -->
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
    <style>
        .labelGeral {
            margin-top: 7px;
            margin-bottom: 3px;
        }

        #tabelaCheque_length {
            display: none;
        }

        #tabelaCheque_filter {
            display: none;
        }

        #tabelaCheque_info {
            display: none;
        }

        #tabelaCheque_empty {
            display: none;
        }

        .table.dataTable thead th,
        .table.dataTable tbody td {
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .border-Field .textoBorda {
            font-size: 1.1em !important;
            text-align: left !important;
            width: auto;
            padding: 0 10px;
            border-bottom: none;
        }

        .border-Field {
            border: 1px solid var(--font-color) !important;
            padding: 0 1.0em 0 1.0em !important;
            margin: 0 0 0 0 !important;
            -webkit-box-shadow: 0px 0px 0px 0px #000;
            box-shadow: 0px 0px 0px 0px #000;
        }

        .abrirModalParcelas {
            width: 100%;
            height: 40px;
            background: #007bff;
            font-weight: bold;
            color: white;
            border: 0 none;
            border-radius: 0;
            cursor: pointer;
            padding: 0;
            margin: 0;
            float: right;
        }

        .abrirModalParcelas:hover {
            box-shadow: 0 0 0 2px white, 0 0 0 3px #616161;
            background: #0a59ae;
        }
    </style>
</head>

<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">
        <?php

        ?>

        <div id="myModal" class="modal" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 id="myModalLabel" class="modal-title"></h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <p id="myModalText"></p>
                    </div>
                    <div class="modal-footer">
                        <button id="btnYes" type="button" class="btn btn-primary">Sim</button>
                        <button id="btnNo" type="button" class="btn btn-secondary" data-dismiss="modal">Não</button>
                    </div>
                </div>
            </div>
        </div>

        <div class="content-wrapper">
            <section class="content">
                <div class="content-header">
                    <div class="container-fluid">
                        <div class="row mb-2">
                            <div class="col-sm-6 flex">
                            </div>
                            <div class="col-sm-6">
                                <!-- <ol class="breadcrumb float-sm-right">
                                    
                                    <li class="breadcrumb-item"><a href="../cheque">Acesso Cheque</a></li>
                                    <li class="breadcrumb-item active">Cadastro de Cheque</li>
                                </ol> -->
                            </div>
                        </div>
                    </div>
                    <div class="row justify-content-center mt-0">
                        <div class="col-11 text-center p-0 ml-4 mr-4">
                            <div class="card px-0 pb-0 mb-3">
                                <div class="card-header text-center flex mb-0" style="border: none!important;box-shadow:none!important;">
                                    <h2>Cadastro de Cheque
                                        <button type="button" class="btn btn-info btn-sm ml-2" title="Tutorial" style="color: white;" id="tutorial">
                                            <i class="fas fa-question-circle"></i>
                                        </button>
                                    </h2>
                                </div>
                                <div class="row">
                                    <div class="col-md-12 mx-0">
                                        <form id="msform" class="mt-0">
                                            <ul id="progressbar" class="mt-0 mb-0">
                                                <li class="active mt-0" id="account" style="font-size: 100%; width:100%;"><strong>Geral</strong></li>
                                            </ul>
                                            <p class="mb-0">Preencha os dados para realizar o cadastro do Cheque</p>
                                            <fieldset>

                                                <div class="form-card pt-0 mt-0 mb-0" id="formcard1">


                                                    <div class="row justify-content-sm-start justify-content-center mb-2" id="divLancAnte">
                                                        <div class="col-12 col-md-auto">
                                                            <fieldset class="form border-Field mb-0 pb-0">
                                                                <legend class="textoBorda mb-0 pb-0">Opções</legend>
                                                                <div class="m-1"><input type="checkbox" id="cbLancarAnte"> <label for="cbLancarAnte">  Lançar Antecipação</label></div>
                                                            </fieldset>
                                                        </div>
                                                    </div>

                                                    <div class="row justify-content-sm-start justify-content-center">
                                                        <div class="col-12 col-md-4 mb-2">
                                                            <label data-error="wrong" data-success="right" for="txtCliente">Cliente: *</label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtCliente" name="txtCliente" class="form-control" placeholder="Cliente">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnCliente" name="btnCliente" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaCliente" name="btnLimpaCliente" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-12 col-md-4 mb-2">
                                                            <label data-error="wrong" data-success="right" for="txtRepresentante">Representante: *</label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtRepresentante" name="txtRepresentante" class="form-control" placeholder="Representante">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnRepresentante" name="btnRepresentante" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaRepresentante" name="btnLimpaRepresentante" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div id="moeda" class="col-12 col-md-4 mb-2 form-group mb-0 d-none">
                                                            <label data-error="wrong" data-success="right" for="txtMoeda">Moeda: </label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtMoeda" name="txtMoeda" class="form-control" placeholder="Moeda:">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnMoeda" name="btnMoeda" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaMoeda" name="btnLimpaMoeda" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div id="Conta" class="col-12 col-md-6 mb-2 form-group mb-0">
                                                            <label data-error="wrong" data-success="right" for="txtConta">Conta: </label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtConta" name="txtConta" class="form-control" placeholder="Conta:">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnConta" name="btnConta" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaConta" name="btnLimpaConta" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div id="Banco" class="col-12 col-md-6 mb-2 form-group mb-0">
                                                            <label data-error="wrong" data-success="right" for="txtBanco">Banco: </label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtBanco" name="txtBanco" class="form-control" placeholder="Banco:">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnBanco" name="btnBanco" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaBanco" name="btnLimpaBanco" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="col-4 col-md-4 mb-2">
                                                            <label data-error="wrong" data-success="right" for="txtClasse">Classe: *</label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtClasse" name="txtClasse" class="form-control" placeholder="Classe Gerencial">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnClasse" name="btnCliente" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaClasse" name="btnLimpaClasse" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-4 col-md-4">
                                                            <label data-error="wrong" data-success="right" for="txtSituacao">Situação: *</label>
                                                            <div class="input-group mb-2">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtSituacao" name="txtSituacao" class="form-control" placeholder="Situação">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnSituacao" name="btnSituacao" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaSituacao" name="btnLimpaSituacao" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-12 col-md-4 mb-2">
                                                            <label data-error="wrong" data-success="right" for="txtHistorico">Histórico: *</label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtHistorico" name="txtHistorico" class="form-control" placeholder="Histórico">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnHistorico" name="btnHistorico" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaHistorico" name="btnLimpaHistorico" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div id="caixa" class="col-12 col-md-5 mb-2 form-group mb-0 d-none">
                                                            <label data-error="wrong" data-success="right" for="txtCaixa">Caixa: </label>
                                                            <div class="input-group">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtCaixa" name="txtCaixa" class="form-control" placeholder="Caixa:">
                                                                <div class="input-group-append">
                                                                    <button class="btn bg-danger" id="btnCaixa" name="btnCaixa" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn bg-danger" id="btnLimpaCaixa" name="btnLimpaCaixa" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-5 col-md-5">
                                                            <label data-error="wrong" data-success="right" for="txtObservacao">Observação: *</label>
                                                            <div class="input-group mb-2">
                                                                <input type="text" autocomplete="off" class="input-default focus form-control" id="txtObservacao" name="txtObservacao" class="form-control" placeholder="Observação">
                                                            </div>
                                                        </div>
                                                        <div class="col-12 col-md-2 mb-2 form-group mb-0">
                                                            <label>   </label>
                                                            <div class="input-group">
                                                                <input type="button" name="gravar" class="abrirModalParcelas col-12" value="Adicionar  Cheque" id="btnIncluirCheque">
                                                            </div>
                                                        </div>



                                                        <div class="col-12">
                                                            <table id="tabelaCheques" class="table table-sm table-hover table-select table-condensed">
                                                                <thead>
                                                                    <tr>
                                                                        <th>Nome</th>
                                                                        <th>CPF_CNPJ</th>
                                                                        <th>BancoCH (F4)</th>
                                                                        <th style="max-width: 70px">AgênciaCH</th>
                                                                        <th>ContaCH</th>
                                                                        <th>NúmeroCH</th>
                                                                        <th>Vencimento</th>
                                                                        <th>Valor</th>
                                                                        <th>Pedido</th>
                                                                        <th>Ações</th>
                                                                        <th>Ler</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                        <!-- Modal leitura cheque -->

                                                    </div>
                                                </div>

                                                <input type="number" data-selecionado="false" class="input-default form-control" id="txtLimiteCreditoConsignado" name="txtLimiteCreditoConsignado" hidden>
                                                <input type="number" data-selecionado="false" class="input-default form-control" id="txtLimiteCreditoCli" name="txtLimiteCreditoCli" class="form-control" hidden>

                                                <input type="button" name="gravar" class="action-button" value="Gravar" id="gravar">
                                                <input type="button" name="voltar" class="previous action-button-previous" value="Voltar" id="btnVoltar">
                                            </fieldset>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
    </div>

    <?php
    include_once('../../../modais.php');
    ?>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->
    </div>

    <!-- jQuery -->
    <script src="../plugins/jquery/jquery.min.js?versao=3.255.15.1"></script>
    <script src="../plugins/jquery-ui/jquery-ui.min.js?versao=3.255.15.1"></script>
    <script type="text/javascript" src="../dist/js/jquery.dataTables.js?versao=3.255.15.1"></script>
    <script type="text/javascript" src="../dist/js/dataTables.bootstrap4.min.js?versao=3.255.15.1"></script>
    <script src="../plugins/sweetalert2/sweetalert2.min.js?versao=3.255.15.1"></script>
    <script src="../plugins/toastr/toastr.min.js?versao=3.255.15.1"></script>
    <script>
        $.widget.bridge('uibutton', $.ui.button);
    </script>
    <script src="../plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.255.15.1"></script>
    <script src="../dist/js/adminlte.min.js?versao=3.255.15.1"></script>
    <script src="../dist/js/requisicoes.js?versao=3.255.15.1"></script>
    <script src="../dist/js/cliente/entidade.js?versao=3.255.15.1"></script>
    <script src="../dist/js/loadingoverlay.min.js?versao=3.255.15.1"></script>
    <script src="../dist/js/valida_cpf_cnpj.js?versao=3.255.15.1"></script>
    <script src="../dist/js/jquery.mask.min.js?versao=3.255.15.1"></script>
    <script src="../dist/js/jquery.maskMoney.min.js?versao=3.255.15.1"></script>
    <script src="../plugins/jquery-validation/jquery.validate.min.js?versao=3.255.15.1"></script>
    <script src="../dist/js/sisplan.js?versao=3.255.15.1"></script>
    <script src="../utils/funcoes.js?versao=3.255.15.1"></script>
    <script src="../utils/cookies.js?versao=3.255.15.1"></script>
    <script src="../dist/js/jquery.inputmask.js"></script>
    <script src="../dist/js/jquery.maskMoney.min.js?versao=3.255.15.1"></script>
    <script src="../dist/js/driver.min.js?versao=3.255.15.1"></script>
    <script src="../dist/js/dataTables.keyTable2.js?versao=3.255.15.1"></script>
    <script type="text/javascript" src="../config.js?versao=3.255.15.1"></script>
    <script>
        $(document).ready(async function() {
            if (getCookie('usuario') == "") {
                window.location.href = `${BASE_URI}/login`;
                return;
            }

            let usuario = getCookie('usuario');
            let empresa = getCookie('empresa');

            ipInterno = IP_INTERNO;
            ipExterno = IP_EXTERNO;
            basicAuth = BASIC_AUTH;

            const temAcesso = await temAcessoTela('CHEQUE');
            if (!temAcesso.resultado) {
                toastrAcesso(temAcesso, BASE_URI);
                return;
            }

            const permissaoUsuarioLogado = await permissaoAcessos("CHEQUE");

            if (permissaoUsuarioLogado.INCLUI == 'N') {
                await criaMensagemErro("Sem permissão para incluir!", () => {
                    window.location.href = `${BASE_URI}/cheque`
                });
                return;
            }

            //código para liberar registro ao sair da tela clicando no menu, breadcrumb
            const queryString = window.location.href;
            const parametros = queryString.split('/');
            const historico = parametros[parametros.length - 1];

            $(window).on("beforeunload", function(e) {
                // e.preventDefault();
                e.stopPropagation();
                deletaRegistro('CHEQUE', getCookie('usuario'), historico);
                return undefined;
            });

            sArquivo = `${BASE_URI}/pages/cheque/cadastro_cheque/cheque.js?versao=3.255.15.1`;
            insereJavaScriptPagina(sArquivo);

            const nomeTela = ('<?php echo basename(__FILE__) ?>').replace('.php', '');
            habilitaCamposObrigatoriosTela(nomeTela);
        });
    </script>
</body>

</html>