<?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 | Consignado</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.255.7.1">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.255.7.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 href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">


  <link rel="stylesheet" href="dist/css/custom.css?versao=3.255.7.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.255.7.1">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.255.7.1" />
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.255.7.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.255.7.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.255.7.1">
  <link rel="stylesheet" href="dist/css/PesquisaVariosSelect2.css?versao=3.255.7.1">
  <link rel="stylesheet" href="plugins/select2/css/select2.min.css?versao=3.255.7.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.255.7.1">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.255.7.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.255.7.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.255.7.1">
  <style>
    #tabelaConsignado,
    #tabelaItens,
    #tabelaAcerto {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    .bordinha {
      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;
    }
  </style>
</head>

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

    <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">Consignado</h1>
              <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>
            </div>
            <div class="col-sm-6">
            </div>
          </div>
        </div>
        <div class="container-fluid" id="divTabelaConsignado">
          <div class="row card">
            <div class="col-sm-12 mt-3">
              <button class="btn btn-success btn-sisp" id="btnFiltros"><span class="fas fa-search"></span> Filtros</button>
              <button class="btn btn-danger btn-sisp" id="btnIncluir"><span class="fas fa-plus"></span> Incluir</button>
            </div>
            <div class="col-sm-12 table-responsive card-body">
              <h5>Lista de Consignados</h5>
              <table id="tabelaConsignado" class="table table-sm table-select table-hover" width="100%">
                <thead>
                </thead>
                <tbody>
                </tbody>
              </table>
            </div>
            <div class="col-12 row justify-content-between my-2" style="margin-left: 1px;" id="valoresTotais">
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtQuantidadeSaida">Quantidade Saída:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" value="0" id="txtQuantidadeSaida" name="txtQuantidadeSaida" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtValorSaida">Valor Saída:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtValorSaida" name="txtValorSaida" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtQuantidadeDevolvida">Quantidade Devolvida:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtQuantidadeDevolvida" name="txtQuantidadeDevolvida" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtValorDevolvido">Valor Devolvido:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtValorDevolvido" name="txtValorDevolvido" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtQuantidadePendente">Quantidade Pendente:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtQuantidadePendente" name="txtQuantidadePendente" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtValorPendente">Valor Pendente:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtValorPendente" name="txtValorPendente" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtQuantidadeAcerto">Quantidade Acerto:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtQuantidadeAcerto" name="txtQuantidadeAcerto" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtTotalAcerto">Total Acerto:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtTotalAcerto" name="txtTotalAcerto" class="form-control" placeholder="0">
                </div>
              </div>
              <div style="width: 10%">
                <label data-error="wrong" data-success="right" style="white-space: nowrap; text-overflow: hidden !important;" for="txtPercAcerto">% Acerto:</label>
                <div class="input-group">
                  <input type="text" disabled class="input-default focus form-control text-right" id="txtPercAcerto" name="txtPercAcerto" class="form-control" placeholder="0">
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-7 table-responsive card-body pt-0">
              <h5 class="mb-0">Lista de Itens</h5>
              <table id="tabelaItens" class="table table-sm table-select table-hover" width="100%">
                <thead>
                </thead>
                <tbody>
                </tbody>
              </table>
              <div class="col-12 row mt-2" id="valoresTotais">
                <div class="col-4">
                  <label data-error="wrong" data-success="right" for="txtQuantidadeTotal">Quantidade Total:</label>
                  <div class="input-group">
                    <input type="text" disabled class="input-default focus form-control text-right" id="txtQuantidadeTotal" name="txtQuantidadeTotal" class="form-control" placeholder="0">
                  </div>
                </div>
                <div class="col-4">
                  <label data-error="wrong" data-success="right" for="txtValorTotal">Valor Total:</label>
                  <div class="input-group">
                    <input type="text" disabled class="input-default focus form-control text-right" id="txtValorTotal" name="txtValorTotal" class="form-control" placeholder="0">
                  </div>
                </div>
              </div>
            </div>
            <div class="col-sm-5 table-responsive card-body pt-0">
              <h5 class="mb-0">Lista Acertos (Cliente x Data de Acerto)</h5>
              <table id="tabelaAcerto" class="table table-sm table-select table-hover" width="100%">
                <thead>
                </thead>
                <tbody>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>

      <div class="modal fade" id="modalNFE" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 id="modalNFCE-titulo" class="modal-title">Faturar Venda</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <div class="row">
                <input type="text" data-selecionado="false" class="input-default focus form-control d-none" id="txtConsignadoID" name="txtConsignadoID" class="form-control" placeholder="Cliente">
                <div class="col-12">
                  <label style="margin-bottom: .1rem!important;" data-error="wrong" data-success="right" for="txtClienteNFE">Cliente</label>
                  <div class="input-group">
                    <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtClienteNFE" name="txtClienteNFE" class="form-control" placeholder="Cliente">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnClienteNFE" name="btnClienteNFE" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaClienteNFE" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
                <div class="col-12" style="margin-top: 2%">
                  <label style="margin-bottom: .1rem!important;" data-error="wrong" data-success="right" for="txtNaturezaNFE">Natureza</label>
                  <div class="input-group">
                    <input type="text" data-selecionado="false" class="input-default focus form-control" id="txtNaturezaNFE" name="txtNaturezaNFE" class="form-control" placeholder="Natureza">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnNaturezaNFE" name="btnNaturezaNFE" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaNaturezaNFE" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12" style="margin-top: 2%">
                  <label data-error="wrong" data-success="right" for="txtOperacaoNFE">Operação</label>
                  <div class="input-group">
                    <input type="text" class="input-default focus form-control" id="txtOperacaoNFE" name="txtOperacaoNFE" placeholder="Operação">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnOperacaoNFE" name="btnOperacaoNFE" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaOperacaoNFE" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <div class="row">
                <div class="col-sm-12">
                  <button type="button" id="btn_confirmar_nfe" class="btn btn-danger"> Confirmar</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div id="modal-filtros" class="modal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-xl" role="document">
          <div class="modal-content" id="modalBody">
            <div class="modal-header">
              <h4 class="modal-title">Filtros</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <fieldset class="form border-Field p-0" style="margin-top: 16px !important;">
                <legend class="textoBorda pb-0 mb-0">Opções</legend>
                <div class="form-group">
                  <div class="icheck-primary d-inline"><input type="radio" checked id="rdTodos" name="rdListar" value="0"><label for="rdTodos">Todos</label></div>
                  <div class="icheck-primary d-inline"><input type="radio" id="rdPendente" name="rdListar" value="1"><label for="rdPendente">Pendente</label></div>
                  <div class="icheck-primary d-inline"><input type="radio" id="rdEmitido" name="rdListar" value="2"><label for="rdEmitido">Emitido</label></div>
                  <div class="icheck-primary d-inline"><input type="radio" id="rdCancelado" name="rdListar" value="3"><label for="rdCancelado">Cancelado</label></div>
                </div>
              </fieldset>
              <div class="row" style="margin-top: 1.4%;">
                <div class="group-default form-group col-6">
                  <label for="dtIni">Data De/ Até: </label>
                  <div class="input-group">
                    <input type="date" max="2500-12-31" value="1200-01-01" class="input-default focus form-control validate" id="dtIni" name="diIni">
                    <input type="date" max="2500-12-31" value="2500-12-01" class="input-default focus form-control validate" id="dtFim" name="dtFim">
                  </div>
                </div>
                <div class="group-default form-group col-6">
                  <label for="dtAcerto">Data Acerto De/ Até: </label>
                  <div class="input-group">
                    <input type="date" max="2500-12-31" value="1200-01-01" class="input-default focus form-control validate" id="dtAcertoIni" name="dtAcertoIni">
                    <input type="date" max="2500-12-31" value="2500-12-01" class="input-default focus form-control validate" id="dtAcertoFim" name="dtAcertoFim">
                  </div>
                </div>
              </div>

              <div class="row">
                <div class="col-12" id="DocId">
                  <label data-error="wrong" data-success="right" for="txtConsignado">ID Documento </label>
                  <div class="input-group">
                    <input type="text" autocomplete="off" class="input-default focus form-control" id="txtConsignado" name="txtConsignado" class="form-control" placeholder="ID Documento">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnConsignado" name="btnConsignado" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaConsignado" name="btnLimpaConsignado" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-6" id="Cliente">
                  <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-6" id="Vendedor">
                  <label data-error="wrong" data-success="right" for="txtVendedor">Vendedor </label>
                  <div class="input-group">
                    <input type="text" autocomplete="off" class="input-default focus form-control" id="txtVendedor" name="txtVendedor" class="form-control" placeholder="Vendedor">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnVendedor" name="btnVendedor" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaVendedor" name="btnLimpaVendedor" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-6" id="Status">
                  <label data-error="wrong" data-success="right" for="txtStatus">Status </label>
                  <div class="input-group">
                    <input type="text" autocomplete="off" class="input-default focus form-control" id="txtStatus" name="txtStatus" class="form-control" placeholder="Status">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnStatus" name="btnStatus" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaStatus" name="btnLimpaStatus" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
                <div class="col-lg-6 form-group">
                  <label data-error="wrong" data-success="right" for="txtTabPreco">Tabela de Preço: </label>
                  <div class="input-group">
                    <input type="text" class="input-default focus form-control" id="txtTabPreco" name="txtTabPreco" placeholder="Tabela de Preço">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnTabPreco" name="btnTabPreco" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaTabPreco" name="btnLimpaTabPreco" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <div class="modal-footer">
              <div class="row">
                <button class="btn btn-primary btn-sisp" id="btnLimparFiltros" style="background-color: #B22222; border-color: #B22222"><span class="fas fa-trash"></span> Limpar Filtros</button>     
                <button class="btn btn-primary btn-sisp" id="btnConsultar"><span class="fas fa-search"></span> Consultar</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <?php
  include_once('../../../modais.php');
  include_once('../../../modals/modal_anexos.html');
  ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  </div>
  <script src="plugins/jquery/jquery.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.255.7.1"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.255.7.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.255.7.1"></script>
  <script src="dist/js/adminlte.min.js?versao=3.255.7.1"></script>
  <script src="dist/js/sisplan.js?versao=3.255.7.1"></script>
  <script src="utils/funcoes.js?versao=3.255.7.1"></script>
  <script src="utils/cookies.js?versao=3.255.7.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.255.7.1"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.255.7.1"></script>
  <script src="dist/js/driver.min.js?versao=3.255.7.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.255.7.1"></script>
  <script src="plugins/select2/js/select2.full.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="modals/modal_anexos.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="config.js?versao=3.255.7.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('CONSIGNADO');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

      sArquivo = `${BASE_URI}/pages/consignado/acesso_consignado/acesso_consignado.js?versao=3.255.7.1`;
      insereJavaScriptPagina(sArquivo);

    });
  </script>
</body>

</html>