<?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 | Retorno Escritural</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.238.10.2">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.238.10.2">
  <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.238.10.2" />
  <link href='dist/css/bootstrap.min.css?versao=3.238.10.2'>
  <link rel="stylesheet" href="dist/css/custom.css?versao=3.238.10.2">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.238.10.2">
  <link rel="stylesheet" type="text/css" href="plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.238.10.2">
  <link rel="stylesheet" type="text/css" href="dist/css/responsive.bootstrap.min.css?versao=3.238.10.2">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="dist/css/cadastro.css?versao=3.238.10.2">
  <!-- Toastr -->
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.238.10.2">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.238.10.2" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.238.10.2">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
  <style>
    #progressbar li {
      list-style-type: none;
      font-size: 12px;
      width: 50%;
      float: left;
      position: relative
    }

    .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;
    }

    .square {
      height: 25px;
      width: 25px;
    }

    .square-container {
      display: flex;
      align-items: center;
      white-space: nowrap;
    }

    .square-label {
      padding-left: 2%;
      padding-top: 4%;
    }

    #tabelaRetorno tbody,
    #tabelaRetorno thead {
      white-space: nowrap !important;
      text-overflow: ellipsis !important;
      overflow: hidden !important;
    }
  </style>
</head>

<body class="hold-transition sidebar-mini layout-fixed">
  <div class="wrapper">
    <?php
    include_once('../../menu.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="../index">Início</a></li>
                  <li class="breadcrumb-item active">Retorno Escritural</li>
                </ol>
              </div><!-- /.col -->
            </div><!-- /.row -->
          </div>
          <div class="row justify-content-center mt-0">
            <div class="col-10 text-center p-0 mt-3 mb-2">
              <div class="card px-0 pt-4 pb-0 mt-3 mb-3">
                <div class="card-header text-center flex" style="border: none!important;box-shadow:none!important;">
                  <h2>Retorno Escritural
                    <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">
                      <!-- progressbar -->
                      <ul id="progressbar">
                        <li class="active" id="account" style="font-size: 100%;"><strong>Geral</strong></li>
                        <li id="confirm" style="font-size: 100%;"><strong>Baixas</strong></li>
                      </ul> <!-- fieldsets -->
                      <fieldset class="abas" id="fieldset1">
                        <p>Preencha os dados e clique em avançar para realizar a consulta</p>
                        <div class="form-card" id="formcard1" style="height: 500px;">
                          <h2 class="fs-title">Dados Gerais</h2>
                          <div class="form-row col-lg-8 col-md-12 col-sm-12">
                            <div class="form-group col-lg-6 col-md-12">
                              <label for="txtBanco">Banco:</label>
                              <div class="input-group">
                                <input type="text" class="input-default focus form-control validate" id="txtBanco" name="txtBanco" placeholder="Banco">
                                <div class="input-group-append">
                                  <button class="btn bg-danger create" id="btnBanco" name="btnBanco" type="button">
                                    <i class="m-0 p-0 fas fa-search"></i>
                                  </button>
                                  <button class="btn bg-danger create" id="btnLimpaBanco" type="button">
                                    <i class="m-0 p-0 fas fa-trash"></i>
                                  </button>
                                </div>
                              </div>
                            </div>
                            <div class="form-group col-lg-6 col-md-12">
                              <label for="txtCarteira">Carteira:</label>
                              <div class="input-group">
                                <input type="text" class="input-default focus form-control validate" id="txtCarteira" name="txtCarteira" placeholder="Carteira">
                                <div class="input-group-append">
                                  <button class="btn bg-danger create" id="btnCarteira" name="btnCarteira" type="button">
                                    <i class="m-0 p-0 fas fa-search"></i>
                                  </button>
                                  <button class="btn bg-danger create" id="btnLimpaCarteira" type="button">
                                    <i class="m-0 p-0 fas fa-trash"></i>
                                  </button>
                                </div>
                              </div>
                            </div>
                            <div class="form-group col-lg-6 col-md-12">
                              <label for="txtClasseBaixa">Classe - Baixa:</label>
                              <div class="input-group">
                                <input type="text" class="input-default focus form-control validate" id="txtClasseBaixa" name="txtClasseBaixa" placeholder="Classe">
                                <div class="input-group-append">
                                  <button class="btn bg-danger create" id="btnClasseBaixa" name="btnClasseBaixa" type="button">
                                    <i class="m-0 p-0 fas fa-search"></i>
                                  </button>
                                  <button class="btn bg-danger create" id="btnLimpaClasseBaixa" type="button">
                                    <i class="m-0 p-0 fas fa-trash"></i>
                                  </button>
                                </div>
                              </div>
                            </div>
                            <div class="form-group col-lg-6 col-md-12">
                              <label for="txtClasseJuros">Classe - Juros:</label>
                              <div class="input-group">
                                <input type="text" class="input-default focus form-control validate" id="txtClasseJuros" name="txtClasseJuros" placeholder="Classe">
                                <div class="input-group-append">
                                  <button class="btn bg-danger create" id="btnClasseJuros" name="btnClasseJuros" type="button">
                                    <i class="m-0 p-0 fas fa-search"></i>
                                  </button>
                                  <button class="btn bg-danger create" id="btnLimpaClasseJuros" type="button">
                                    <i class="m-0 p-0 fas fa-trash"></i>
                                  </button>
                                </div>
                              </div>
                            </div>
                            <div class="form-group col-lg-6 col-md-12">
                              <label for="txtClasseDesconto">Classe - Desconto:</label>
                              <div class="input-group">
                                <input type="text" class="input-default focus form-control validate" id="txtClasseDesconto" name="txtClasseDesconto" placeholder="Classe">
                                <div class="input-group-append">
                                  <button class="btn bg-danger create" id="btnClasseDesconto" name="btnClasseDesconto" type="button">
                                    <i class="m-0 p-0 fas fa-search"></i>
                                  </button>
                                  <button class="btn bg-danger create" id="btnLimpaClasseDesconto" type="button">
                                    <i class="m-0 p-0 fas fa-trash"></i>
                                  </button>
                                </div>
                              </div>
                            </div>
                            <div class="form-group col-lg-6 col-md-12">
                              <label for="txtHistorico">Histórico:</label>
                              <div class="input-group">
                                <input type="text" class="input-default focus form-control validate" id="txtHistorico" name="txtHistorico" placeholder="Histórico">
                                <div class="input-group-append">
                                  <button class="btn bg-danger create" id="btnHistorico" name="btnHistorico" type="button">
                                    <i class="m-0 p-0 fas fa-search"></i>
                                  </button>
                                  <button class="btn bg-danger create" id="btnLimpaHistorico" type="button">
                                    <i class="m-0 p-0 fas fa-trash"></i>
                                  </button>
                                </div>
                              </div>
                            </div>
                            <div class="form-group col-lg-6 col-md-12">
                              <label for="txtConta">Conta:</label>
                              <div class="input-group">
                                <input type="text" class="input-default focus form-control validate" id="txtConta" name="txtConta" placeholder="Conta">
                                <div class="input-group-append">
                                  <button class="btn bg-danger create" id="btnConta" name="btnConta" type="button">
                                    <i class="m-0 p-0 fas fa-search"></i>
                                  </button>
                                  <button class="btn bg-danger create" id="btnLimpaConta" type="button">
                                    <i class="m-0 p-0 fas fa-trash"></i>
                                  </button>
                                </div>
                              </div>
                            </div>
                            <div class="form-group col-lg-3 col-md-12">
                              <label for="txtJuros">Juros a partir de:</label>
                              <input type="number" class="input-default focus form-control validate" id="txtJuros" name="txtJuros" placeholder="0.00">
                            </div>
                            <div class="form-group col-lg-3 col-md-12">
                              <label for="txtContabilizacao">Contabilização:</label>
                              <input type="date" class="input-default focus form-control validate" id="txtContabilizacao" name="txtContabilizacao" placeholder="Contabilização">
                            </div>
                            <div class="form-row col-lg-12 col-md-12">
                              <div class="form-group col-10">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtCaminho">Arquivo:</label>
                                <div class="input-group">
                                  <input type="text" class="input-default focus form-control" id="txtCaminho" name="txtCaminho" placeholder="Arquivo" disabled>
                                  <input type="file" id="mdModalUpload" class="d-none">
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnCaminho" name="btnCaminho" type="file" for="txtCaminho"><i class="m-0 p-0 fas fa-folder-plus"></i> </button>
                                  </div>
                                </div>
                              </div>
                              <div class="form-group col-2 pt-4 mt-3 pl-4">
                                <label for="cbForcar"><input type="checkbox" id="cbForcar"> Forçar</label>
                              </div>
                              <div class="form-group col-12 d-none">
                                <pre id="fileContent"></pre>
                              </div>
                            </div>
                            <div class="form-group col-lg-12 col-md-12">
                              <label for="txtCaminhoLido">Caminho Arquivo Lido:</label>
                              <input type="text" class="input-default focus form-control validate" id="txtCaminhoLido" name="txtCaminhoLido" placeholder="Caminho">
                            </div>
                          </div>
                          <div class="form-group col-lg-4 col-md-12 col-sm-12">
                            <div class="col-12" id="tutOpcoes">
                              <fieldset class="form border-Field mb-0 pb-0">
                                <legend class="textoBorda mb-0 pb-0">Opções</legend>
                                <div id="tipoDep" class="row">
                                  <div class="pl-2">
                                    <label for="cbTodasEmpresas"><input type="checkbox" id="cbTodasEmpresas"> Todas empresas</label> <br>
                                    <label for="cbValidarCampos"><input type="checkbox" id="cbValidarCampos"> Validar campos</label> <br>
                                    <label for="cbSomarTarifa"><input type="checkbox" id="cbSomarTarifa"> Somar tarifa no valor pago</label> <br>
                                    <label for="cbCarteiraRegistro"><input type="checkbox" id="cbCarteiraRegistro"> Carteira tem registro</label> <br>
                                    <label for="cbLancarValorCC"><input type="checkbox" id="cbLancarValorCC"> Lançar valor de tarifa no CC</label> <br>
                                    <label for="cbMsgCC"><input type="checkbox" id="cbMsgCC"> Mensagem conta corrente</label> <br>
                                    <label for="cbPossuiIntegracao"><input type="checkbox" id="cbPossuiIntegracao"> Possui integração</label> <br>
                                    <label for="cbUsarClasse"><input type="checkbox" id="cbUsarClasse"> Usar classe gerencial da capa</label> <br>
                                  </div>
                                </div>
                              </fieldset>
                            </div>
                            <div class="form-row col-lg-12 col-md-12" style="margin-top: 78px;">
                              <div class="col-9">
                                <label for="txtInstrucao">Buscar Informações:</label>
                                <select class="drilldown-item form-control select2 select2-danger focus" style="border-color: #a9a9a9" data-dropdown-css-class="select2-danger" name="txtInstrucao" id="txtInstrucao">
                                  <option value="D" selected>Duplicata</option>
                                  <option value="N">Nr. Banco</option>
                                </select>
                              </div>
                              <div class="col-3 mt-4 pt-2 pl-2">
                                <input type="button" class="btn btn-sm btn-danger ml-2" id="btnAjustes" value="Ajustes">
                              </div>
                            </div>
                          </div>
                        </div>
                        <input type="button" name="verBaixas" id="verBaixas" class="btn-sisp next action-button" style="background-color: #3ca2d3" value="Ver Baixas" />
                        <button type="button" name="voltar1" id="voltar1" style="font-size:15px;" class="btn-sisp action-button-previous" data-dismiss="modal">Voltar</button>
                      </fieldset>
                      <fieldset class="abas" id="fieldset2">
                        <div class="form-card mx-4" style="width: 96%!important">
                          <fieldset class="form border-Field">
                            <legend class="textoBorda mb-0 pb-0">Duplicatas</legend>
                            <!-- <h2 class="fs-title">Resultados</h2> -->
                            <div class="form-row col-lg-12 col-md-12 col-sm-12 d-flex justify-content-around mb-2">
                              <div class="square-container">
                                <div id="quadDuplDesconto" class="square" style="background-color: yellow"></div>
                                <label for="quadDuplDesconto" class="square-label">Com desconto</label>
                              </div>
                              <div class="square-container">
                                <div id="quadDuplRejeitadas" class="square" style="background-color: red"></div>
                                <label for="quadDuplRejeitadas" class="square-label">Rejeitadas</label>
                              </div>
                              <div class="square-container">
                                <div id="quadDuplCanceladas" class="square" style="background-color: blue"></div>
                                <label for="quadDuplCanceladas" class="square-label">Canceladas</label>
                              </div>
                              <div class="square-container">
                                <div id="quadDuplDiferenca" class="square" style="background-color: lightgreen"></div>
                                <label for="quadDuplDiferenca" class="square-label">Diferença de valor</label>
                              </div>
                              <div class="square-container">
                                <div id="quadDuplDesAgr" class="square" style="background-color: lightgray"></div>
                                <label for="quadDuplDesAgr" class="square-label">Desdobradas/Agrupadas</label>
                              </div>
                              <div class="square-container pl-4">
                                <div id="quadDuplRegDuplicado" class="square" style="background-color: cyan"></div>
                                <label for="quadDuplRegDuplicado" class="square-label">Registro duplicado</label>
                              </div>
                            </div>
                          </fieldset>
                        </div>
                        <div class="col-sm-12 table-responsive card-body">
                          <table id="tabelaRetorno" class="table table-sm table-select table-hover" width="100%">
                            <thead>
                              <tr>
                                <th class="th-sm">Sel
                                </th>
                                <th class="th-sm">Nota_F
                                </th>
                                <th class="th-sm">Número
                                </th>
                                <th class="th-sm">Data Vencimento
                                </th>
                                <th class="th-sm">Data Contabilização
                                </th>
                                <th class="th-sm">Valor
                                </th>
                                <th class="th-sm">Valor Pago
                                </th>
                                <th class="th-sm">Juro
                                </th>
                                <th class="th-sm">Acréscimo
                                </th>
                                <th class="th-sm">Desconto
                                </th>
                                <th class="th-sm">Desconto Programado
                                </th>
                                <th class="th-sm">Status
                                </th>
                                <th class="th-sm">Cliente
                                </th>
                                <th class="th-sm">Codcli
                                </th>
                                <th class="th-sm">Código Ocorrência
                                </th>
                                <th class="th-sm">Nr. Banco
                                </th>
                                <th class="th-sm">Nome Banco
                                </th>
                                <th class="th-sm">Altera Vencimento
                                </th>
                                <th class="th-sm">Juro_calc
                                </th>
                                <th class="th-sm">Juro_desc
                                </th>
                                <th class="th-sm">Taxa
                                </th>
                                <th class="th-sm">Tarifa
                                </th>
                                <th class="th-sm">Despesa
                                </th>
                                <th class="th-sm">IOF
                                </th>
                                <th class="th-sm">Data
                                </th>
                                <th class="th-sm">Banco
                                </th>
                                <th class="th-sm">Conta
                                </th>
                                <th class="th-sm">ContaCont_Juros
                                </th>
                                <th class="th-sm">Carteira
                                </th>
                                <th class="th-sm">Comp_Cart
                                </th>
                                <th class="th-sm">Situação
                                </th>
                                <th class="th-sm">Classe
                                </th>
                                <th class="th-sm">Arquivo
                                </th>
                                <th class="th-sm">Ordem
                                </th>
                                <th class="th-sm">Emp
                                </th>
                                <th class="th-sm">Rej
                                </th>
                                <th class="th-sm">Código Rejeição
                                </th>
                                <th class="th-sm">Desc. Rejeição
                                </th>
                                <th class="th-sm">Baixada
                                </th>
                                <th class="th-sm">Valida
                                </th>
                                <th class="th-sm">Código Liquidação
                                </th>
                                <th class="th-sm">Situação Duplicata
                                </th>
                                <th class="th-sm">Desc. Situação Duplicata
                                </th>
                                <th class="th-sm">Gera ContaCor
                                </th>
                                <th class="th-sm">Emp_id
                                </th>
                                <th class="th-sm">Duplicado
                                </th>
                                <th class="th-sm">Credita_CC
                                </th>
                                <th class="th-sm">Debita_CC
                                </th>
                                <th class="th-sm">Obs
                                </th>
                                <th class="th-sm">Classe_capa
                                </th>
                                <th class="th-sm">Valor Antec.
                                </th>
                                <th class="th-sm">Colecode
                                </th>
                              </tr>
                            </thead>
                            <tbody>
                            </tbody>
                          </table>
                        </div>
                        <input type="button" name="gravar" class="action-button" value="Gravar" id="btnGravar">
                        <input type="button" name="voltar2" class="previous action-button-previous" value="Voltar" id="voltar2" />
                      </fieldset>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>
  </div>

  <?php
  include_once('../../footer.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.238.10.2"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.238.10.2"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.238.10.2"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.238.10.2"></script>
  <!-- SweetAlert2 -->
  <script src="plugins/sweetalert2/sweetalert2.min.js?versao=3.238.10.2"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.238.10.2"></script>

  <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>

  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.238.10.2"></script>
  <script src="dist/js/adminlte.min.js?versao=3.238.10.2"></script>
  <script src="dist/js/requisicoes.js?versao=3.238.10.2"></script>
  <script src="dist/js/cliente/entidade.js?versao=3.238.10.2"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.238.10.2"></script>
  <script src="dist/js/valida_cpf_cnpj.js?versao=3.238.10.2"></script>
  <script src="plugins/jquery-validation/jquery.validate.min.js?versao=3.238.10.2"></script>
  <script src="dist/js/sisplan.js?versao=3.238.10.2"></script>
  <script src="utils/funcoes.js?versao=3.238.10.2"></script>
  <script src="utils/cookies.js?versao=3.238.10.2"></script>
  <script src="dist/js/driver.min.js?versao=3.238.10.2"></script>
  <script src="dist/js/jquery.maskMoney.min.js?versao=3.238.10.2"></script>
  <script src="dist/js/jquery.mask.min.js?versao=3.238.10.2"></script>
  <script src="dist/js/dataTables.keyTable2.js?versao=3.238.10.2"></script>
  <script type="text/javascript" src="config.js?versao=3.238.10.2"></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('DEPOSITO');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

      const permissaoUsuarioLogado = await permissaoAcessos("DEPOSITO");

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

      const queryString = window.location.href;
      const parametros = queryString.split("/");
      const deposito = parametros[parametros.length - 1];

      $(window).on("beforeunload", function(e) {
        e.preventDefault();
        deletaRegistro("DEPOSITO", getCookie("usuario"), deposito);
        return undefined;
      });

      sArquivo = `${BASE_URI}/pages/escretorno/escretorno.js?versao=3.238.10.2`;
      insereJavaScriptPagina(sArquivo);

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

</html>