<?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 | Contagem de Caixa</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../dist/css/adminlte.min.css?versao=3.255.15.1">
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css?versao=3.255.15.1">
  <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">
  <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">
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
  <style>
    #divLancManuais {
      border-top: 2px solid #dddddd;
    }

    .principal {
      border-bottom: 2px solid #dddddd;
    }
  </style>
</head>

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


    <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="wrapper">
      <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">
        <div class="content-header">
          <div class="container-fluid">
            <div class="row mb-2">
              <div class="col-sm-6 flex">
                <h1 class="m-0 text-dark">Contagem de Caixa - Cadastro</h1>
              </div>
              <div class="col-sm-6">
                <!-- <ol class="breadcrumb float-sm-right">
                  
                  <li class="breadcrumb-item active"><a href="../contagem_caixa">Contagem de Caixa</a></li>
                  <li class="breadcrumb-item active">Cadastro de Contagem de Caixa</li>
                </ol> -->
              </div>
            </div>
          </div>
          <div class="row justify-content-center mt-0">
            <div class="col-10 text-center p-0 mt-3 mb-2">
              <div class="row">
                <div class="col-md-12 mx-0">
                  <form id="msform">
                    <div class="form-card" id="formcard1" style="min-height: 400px;">
                      <div class="row d-flex justify-content-center">
                        <div class="card col-10" id="campostour">
                          <div class="card-body">
                            <div class="row principal">
                              <div class="col-12 col-lg-4">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtPeriodo">Período</label>
                                <div class="input-group">
                                  <input type="date" max="2500-12-31" class="input-default focus form-control" required aria-describedby="ufError" id="txtPeriodo" name="txtPeriodo" class="form-control" placeholder="Período">
                                  <span id="ufError" class="error invalid-feedback" style="display: inline;"></span>
                                </div>
                              </div>
                              <div class="col-12 col-lg-4">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtCaixa">Caixa</label>
                                <div class="input-group">
                                  <input type="text" class="input-default focus form-control" required aria-describedby="ufError" 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="btn-Limpa-caixa" type="button">
                                      <i class="m-0 p-0 fas fa-trash"></i>
                                    </button>
                                  </div>
                                  <span id="ufError" class="error invalid-feedback" style="display: inline;"></span>
                                </div>
                              </div>
                              <div class="col-12 col-lg-4">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtUsuario">Usuário</label>
                                <div class="input-s">
                                  <input disabled type="text" class="input-default focus form-control" required aria-describedby="ufError" id="txtUsuario" name="txtUsuario" class="form-control" placeholder="Usuário">
                                  <span id="ufError" class="error invalid-feedback" style="display: inline;"></span>
                                </div>
                              </div>
                              <div class="col-12 pt-1">
                                <button type="button" class="btn btn-primary btn-sisp float-right" data-toggle="modal" id="btnSangria" data-target=".bd-sangria-modal-sm" disabled>Sangria</button>
                                <button type="button" class="btn btn-primary btn-sisp float-right" data-toggle="modal" id="btnSuprimento" data-target=".bd-suprimento-modal-sm" style="margin-right: 3px;" disabled>Suprimento</button>
                              </div>
                              <div class="col-sm-12 table-responsive card-body">
                                <h5>Lista de Moedas</h5>
                                <table id="tabelaMoedas" class="table table-sm table-select table-hover" width="100%">
                                  <thead>
                                    <tr>
                                      <th class="th-sm">Moeda</th>
                                      <th class="th-sm">Descricao</th>
                                      <th class="th-sm">Valor Contagem</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                  </tbody>
                                </table>
                              </div>

                              <div class="col-sm-12 table-responsive card-body" id="divLancManuais">
                                <h5>Lançamentos Manuais</h5>
                                <div class="card-body">
                                  <div class="row pt-2 escondeCampos">
                                    <div class="form-group col-sm-2">
                                      <label>Operação</label>
                                      <select id="rgOperacao" class="custom-select">
                                        <option value="E" selected>Entrada</option>
                                        <option value="S">Saída</option>
                                      </select>
                                    </div>
                                    <div class="form-group col-sm-4">
                                      <label>Observação</label>
                                      <input type="text" class="form-control" id="txtObs" maxlength="60">
                                    </div>
                                    <div class="form-group col-sm-4">
                                      <label>Valor</label>
                                      <input type="text" class="form-control" id="txtValor">
                                    </div>
                                    <div class="form-group col-sm-2">
                                      <label>Moeda</label>
                                      <select id="rgMoeda" class="custom-select">
                                      </select>
                                    </div>
                                  </div>
                                  <div class="row escondeCampos">
                                    <div class="form-group col-sm-12">
                                      <input id="btnIncluir" style="font-size:15px;" class="float-right btn btn-danger btn-lg action-button btn-sisp" value="Incluir">
                                    </div>
                                  </div>
                                  <div class="row pt-2">
                                    <div class="col-sm-12 table-responsive">
                                      <table id="tabelaManual" class="table table-sm table-select table-hover" width="100%">
                                        <thead>
                                          <tr>
                                            <th class="th-sm">Código
                                            </th>
                                            <th class="th-sm">Moeda
                                            </th>
                                            <th class="th-sm">Valor
                                            </th>
                                            <th class="th-sm">Juros
                                            </th>
                                            <th class="th-sm">Valor Orig
                                            </th>
                                            <th class="th-sm">Data Vencto
                                            </th>
                                            <th class="th-sm">Operação
                                            </th>
                                            <th class="th-sm">Duplicata
                                            </th>
                                            <th class="th-sm">Observação
                                            </th>
                                            <th class="th-sm">Ordem
                                            </th>
                                            <th class="th-sm">Opção
                                            </th>
                                          </tr>
                                        </thead>
                                      </table>
                                    </div>
                                  </div>
                                  <div hidden class="col-sm-12 table-responsive">
                                    <table id="tabelaVendas" class="table table-sm table-select table-hover shadow-sm  p-3 mb-5 bg-body rounded" width="100%">
                                      <thead>
                                        <tr>
                                          <th class="th-sm">Código
                                          </th>
                                          <th class="th-sm">Descrição
                                          </th>
                                          <th class="th-sm">Condição
                                          </th>
                                          <th class="th-sm">Saldo Anterior
                                          </th>
                                          <th class="th-sm">Entradas
                                          </th>
                                          <th class="th-sm">Saídas
                                          </th>
                                          <th class="th-sm">Saldo Atual
                                          </th>
                                          <th class="th-sm">Troco
                                          </th>
                                          <th id="th_conferido" class="th-sm d-none">Conferido
                                          </th>
                                          <th id="th_diferenca" class="th-sm d-none">Diferença
                                          </th>
                                          <th class="th-sm">A Retirar
                                          </th>
                                          <th class="th-sm">Saldo Final
                                          </th>
                                        </tr>
                                      </thead>
                                    </table>
                                  </div>
                                </div>
                              </div>
                              <div class="col-sm-12 table-responsive card-body" id="divTroco">
                                <h5>Troco</h5>
                                <div class="col-2">
                                  <label>Valor Troco</label>
                                  <input type="text" class="input-default focus form-control" id="txtTroco" class="form-control">
                                </div>
                              </div>
                            </div>
                            <input type="button" name="btnGravar" id="btnGravar" class="btn-sisp action-button" value="Gravar" />
                            <button type="button" id="btnVoltar" class="btn-sisp action-button-previous">Deixar Pendente</button>
                          </div>
                        </div>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </div>
        </section>
      </div>
    </div>
  </div>

  <div id="modalFinanceiroSaidaManual" class="modal" tabindex="-1" role="dialog" style="z-index: 999999">
    <div class="modal-dialog" role="document">
      <div class="modal-content" id="modalBody">
        <div class="modal-header">
          <h4 class="modal-title">Lançar Financeiro</h4>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">
          <form id="msformPagar">
            <div class="row">
              <div class="col-sm-12 col-lg-12 form-group">
                <label data-error="wrong" data-success="right" for="txtFornecedorPagar">Cliente/Fornecedor *</label>
                <div class="input-group">
                  <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtFornecedorPagar" name="txtFornecedorPagar" class="form-control" placeholder="Fornecedor" required>
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnFornecedorPagar" name="btnFornecedorPagar" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btnLimpaFornecedorPagar" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
              <div class="col-sm-12 col-lg-12 form-group">
                <label data-error="wrong" data-success="right" for="txtClasseGerencialPagar">Classe Gerencial *</label>
                <div class="input-group">
                  <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtClasseGerencialPagar" name="txtClasseGerencialPagar" class="form-control" placeholder="Classe Gerencial" required>
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnClasseGerencialPagar" name="btnClasseGerencialPagar" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btnLimpaClasseGerencialPagar" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
              <div class="col-sm-12 col-lg-12 form-group">
                <label data-error="wrong" data-success="right" for="txtHistoricoPagar">Histórico *</label>
                <div class="input-group">
                  <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtHistoricoPagar" name="txtHistoricoPagar" class="form-control" placeholder="Histórico" required>
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnHistoricoPagar" name="btnHistoricoPagar" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btnLimpaHistoricoPagar" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
              <div class="col-sm-12 col-lg-12 form-group">
                <label data-error="wrong" data-success="right" for="txtSituacaoPagar">Situação *</label>
                <div class="input-group">
                  <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtSituacaoPagar" name="txtSituacaoPagar" class="form-control" placeholder="Situação" required>
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnSituacaoPagar" name="btnSituacaoPagar" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btnLimpaSituacaoPagar" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
              <div class="col-sm-12 col-lg-12 form-group">
                <label data-error="wrong" data-success="right" for="txtBancoPagar">Banco *</label>
                <div class="input-group">
                  <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtBancoPagar" name="txtBancoPagar" class="form-control" placeholder="Banco" required>
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnBancoPagar" name="btnBancoPagar" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btnLimpaBancoPagar" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
              <div class="col-sm-12 col-lg-12 form-group">
                <label data-error="wrong" data-success="right" for="txtContaPagar">Conta *</label>
                <div class="input-group">
                  <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtContaPagar" name="txtContaPagar" class="form-control" placeholder="Conta" required>
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnContaPagar" name="btnContaPagar" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btnLimpaContaPagar" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <div class="row button-group">
            <button class="btn btn-primary btn-sisp" id="btnConfirmarPagar" style="background-color: #B22222; border-color: #B22222"><span class="fas fa-check"></span> Confirmar</button>     
            <button class="btn btn-secondary btn-sisp" id="btnDesistirPagar"><span class="fas fa-times"></span> Desistir</button>
          </div>

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

  <?php
  include_once('../../../modais.php');
  include_once('../../../modals/modal_lancRateio.html');
  ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  </div>
  <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"></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.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 src="../dist/js/jquery.inputmask.js"></script>
  <script type="text/javascript" src="../config.js?versao=3.255.15.1"></script>
  <script type="text/javascript" src="../modals/modal_lancRateio.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('CONTAGEM_CAIXA');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

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

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

</html>