<?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 | Radar NFe</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.2310.23.2">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.2310.23.2">

  <!-- 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" href="dist/css/custom.css?versao=3.2310.23.2">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.2310.23.2">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.2310.23.2" />
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.2310.23.2">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.2310.23.2" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.2310.23.2">
  <style>
    .border-Field {
      border: 1px groove #ddd !important;
      padding: 0 1.4em 1.4em 1.4em !important;
      margin: 0 0 1.5em 0 !important;
      -webkit-box-shadow: 0px 0px 0px 0px #000;
      box-shadow: 0px 0px 0px 0px #000;
    }

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

    .quadrado {
      width: 25px;
      margin-right: 5px;
      height: 25px;
    }

    #legendas {
      flex-direction: row;
      flex-wrap: wrap;
    }
  </style>
</head>

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

  <main class="wrapper">
    <?php
    include_once('../../menu.php');
    ?>

    <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">Radar NFe</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">
              <ol class="breadcrumb float-sm-right">
                <li class="breadcrumb-item"><a href="./index">Início</a></li>
                <li class="breadcrumb-item active">Radar NFe</li>
              </ol>
            </div><!-- /.col -->
          </div><!-- /.row -->
        </div>
        <div class="container-fluid" id="tabelaPrecoForne">
          <div class="row card">
            <div class="col-sm-12 ">

              <div class="card-body d-flex align-items-center">
                <div class="d-flex col-4" style="flex-direction: column; gap: 10px" id="buttonsFiltros">
                  <button class="btn btn-success btn-sisp btn-lg" id="btnFiltros"><span class="fas fa-search"></span> Filtros</button>
                  <button class="btn btn-success btn-sisp btn-lg" id="btnAtualizarListaNFe" style="max-height: 50%!important;"><i class="fas fa-sync-alt"></i> Atualizar Lista de NFe</button>
                </div>

                <div class="col-8 ml-2" id="tipos">
                  <fieldset class="border-Field">
                    <legend class="textoBorda">Legendas</legend>
                    <div class="d-flex" id="legendas">
                      <div style="margin: 10px 10px 0px 0px" class="d-flex align-items-center">
                        <div class="quadrado" style="background: #6495ED;">
                        </div>
                        <span> Existe Manifestação </span>
                      </div>
                      <div style="margin: 10px 10px 0px 0px" class="d-flex align-items-center">
                        <div class="quadrado" style="background: #FF0000;">
                        </div>
                        <span> Cancelada </span>
                      </div>
                      <div style="margin: 10px 10px 0px 0px" class="d-flex align-items-center">
                        <div class="quadrado" style="background: #3CB371;">
                        </div>
                        <span> NF Entrada </span>
                      </div>
                      <div style="margin: 10px 10px 0px 0px" class="d-flex align-items-center">
                        <div class="quadrado" style="background: #FFFF00;">
                        </div>
                        <span> Sem Nota De Entrada </span>
                      </div>
                      <div style="margin: 10px 10px 0px 0px" class="d-flex align-items-center">
                        <div class="quadrado" style="background: #006400;">
                        </div>
                        <span> Nota Referenciada </span>
                      </div>
                      <div style="margin: 10px 10px 0px 0px" class="d-flex align-items-center">
                        <div class="quadrado" style="background: #BC8F8F;">
                        </div>
                        <span> Op. Não Realizada / Desconhecimento da Op </span>
                      </div>
                    </div>
                  </fieldset>
                </div>
              </div>
              <div class="card-body">

                <div class="container-principal">
                  <div class="col-sm-12 table-responsive card-body" id="tabelaTour">
                    <table id="tabelaNFe" class="table table-sm table-select table-hover" width="100%">
                      <thead>
                      </thead>
                      <tbody>
                      </tbody>
                    </table>
                  </div>
                  <!-- <div class="col-sm-12 table-responsive card-body" id="tabelaTour">
                    <table id="tabelaEventosNFe" class="table table-sm table-select table-hover" width="100%">
                      <thead>
                      </thead>
                      <tbody>
                      </tbody>
                    </table>
                  </div> -->
                </div>

                <div class="d-flex justify-content-end">
                  <div class="d-flex col-3" style="flex-direction: column; gap: 10px" id="buttonsFiltros">
                    <button class="btn btn-success btn-sisp btn-lg" id="btnDownloadXml"><span class="fas fa-download"></span> Download XML</button>
                  </div>
                </div>

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

  <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">
          <div class="row">
            <div class="col-5">

              <div class="row">

                <div class="form-group group-default col-md-6 col-6">
                  <label>Data de Emissão de:</label>
                  <div class="relative" id="DataEmissao">
                    <input type="date" class="input-default focus form-control validatel" id="txtDtEmissaoI">
                  </div>
                </div>
                <div class="form-group group-default col-md-6 col-6">
                  <label>Data de Emissão até:</label>
                  <div class="relative" id="DataEmissao">
                    <input type="date" class="input-default focus form-control validatel" id="txtDtEmissaoF">
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="form-group col-12 col-md-12" id="FornecInfoTour">
                  <label data-error="wrong" data-success="right" for="txtFornecedor">Fornecedor
                    *</label>
                  <div class="input-group">
                    <input type="text" autocomplete="off" class="input-default focus form-control validate" required="required" id="txtFornecedor" name="txtFornecedor" class="form-control" placeholder="Fornecedor">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btn-Fornecedor" name="btn-Fornecedor" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btn-limpa-Fornecedor" name="btn-limpa-Fornecedor" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>
              </div>

              <div class="row">
                <div class="form-group group-default col-md-6 col-6">
                  <label for="txtNumeroNFe">Numero NFe</label>
                  <div class="relative">
                    <input type="text" class="input-default focus form-control validate" id="txtNumeroNFe" placeholder="Numero NFe">
                  </div>
                </div>
                <div class="form-group group-default col-md-6 col-6">
                  <label for="txtSerieNFe">Série NFe</label>
                  <div class="relative">
                    <input type="text" class="input-default focus form-control validate" id="txtSerieNFe" placeholder="Série NFe">
                  </div>
                </div>
              </div>

              <div class="row">
                <div class="form-group group-default col-md-12 col-12">
                  <label for="txtBuscaNSUMaior">Busca NSU Maior que:</label>
                  <div class="relative">
                    <input type="text" class="input-default focus form-control validate" id="txtBuscaNSUMaior" placeholder="Busca NSU">
                  </div>
                </div>
              </div>
            </div>

            <div class="col-7">
              <div class="row" style="gap: 5px">
                <div class="col-6">
                  <fieldset class="border-Field">
                    <legend class="textoBorda">Tipo de Manifestação da NFe</legend>
                    <div class="d-flex" id="tipoManifestacao">
                      <div class="col-lg-12 col-12">
                        <div class="form-group clearfix">
                          <div class="icheck-primary">
                            <input type="radio" id="radioTodas" value="0" name="tp_manifestacao" checked>
                            <label for="radioTodas">Todas
                            </label>
                          </div>
                          <div class="icheck-primary">
                            <input type="radio" id="radioNenhuma" value="1" name="tp_manifestacao">
                            <label for="radioNenhuma">Nenhuma
                            </label>
                          </div>
                          <div class="icheck-primary">
                            <input type="radio" id="radioConfOp" value="2" name="tp_manifestacao">
                            <label for="radioConfOp">Confirmação da Operação</label>
                          </div>
                          <div class="icheck-primary">
                            <input type="radio" id="radioDescOp" value="3" name="tp_manifestacao">
                            <label for="radioDescOp">Desconhecimento da Operação
                            </label>
                          </div>
                          <div class="icheck-primary">
                            <input type="radio" id="radioOpNaoRealizada" value="4" name="tp_manifestacao">
                            <label for="radioOpNaoRealizada">Operação não Realizada
                            </label>
                          </div>
                          <div class="icheck-primary">
                            <input type="radio" id="radioCienciaOp" value="4" name="tp_manifestacao">
                            <label for="radioCienciaOp">Ciência da Operação
                            </label>
                          </div>
                        </div>
                      </div>
                    </div>
                  </fieldset>
                </div>
                <div class="col-4">
                  <fieldset class="border-Field">
                    <legend class="textoBorda">Arquivo XML</legend>
                    <div class="d-flex" id="arquivoXML">
                      <div class="col-lg-12 col-12">
                        <div class="form-group clearfix">
                          <div class="icheck-primary">
                            <input type="radio" id="radioTdsArq" value="0" name="arq_xml" checked>
                            <label for="radioTdsArq">Todos
                            </label>
                          </div>
                          <div class="icheck-primary">
                            <input type="radio" id="radioComXml" value="1" name="arq_xml">
                            <label for="radioComXml">Com XML
                            </label>
                          </div>
                          <div class="icheck-primary">
                            <input type="radio" id="radioSemXml" value="2" name="arq_xml">
                            <label for="radioSemXml">Sem XML</label>
                          </div>
                        </div>
                      </div>
                    </div>
                  </fieldset>
                </div>
                <div class="col-6">
                  <fieldset class="border-Field">
                    <legend class="textoBorda">Lançamento Compras</legend>
                    <div class="d-flex" id="lancaCompra">
                      <div class="form-group clearfix">
                        <div class="icheck-primary">
                          <input type="radio" id="radioTdsLanc" value="0" name="lanc_compras" checked>
                          <label for="radioTdsLanc">Todos
                          </label>
                        </div>
                        <div class="icheck-primary">
                          <input type="radio" id="radioSimLanc" value="1" name="lanc_compras">
                          <label for="radioSimLanc">Sim
                          </label>
                        </div>
                        <div class="icheck-primary">
                          <input type="radio" id="radioNaoLanc" value="2" name="lanc_compras">
                          <label for="radioNaoLanc">Não</label>
                        </div>
                      </div>
                    </div>
                  </fieldset>
                </div>
                <div class="col-4 d-none">
                  <fieldset class="border-Field">
                    <legend class="textoBorda">Exibir Eventos NFe</legend>
                    <div class="d-flex" id="exibirEventosNFe">
                      <div class="form-group clearfix">
                        <div class="icheck-primary">
                          <input type="radio" id="radioTdsEventos" value="0" name="exibir_eventos" checked>
                          <label for="radioTdsEventos">Todos
                          </label>
                        </div>
                        <div class="icheck-primary">
                          <input type="radio" id="radioNfePos" value="1" name="exibir_eventos">
                          <label for="radioNfePos">NF-e Posicionada
                          </label>
                        </div>
                        <div class="icheck-primary">
                          <input type="radio" id="radioNaoEventos" value="2" name="exibir_eventos">
                          <label for="radioNaoEventos">Não</label>
                        </div>
                      </div>
                    </div>
                  </fieldset>
                </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>

  <?php
  include_once('../../footer.php');
  ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  <script src="plugins/jquery/jquery.min.js?versao=3.2310.23.2"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.2310.23.2"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.2310.23.2"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.2310.23.2"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.2310.23.2"></script>
  <script src="dist/js/adminlte.min.js?versao=3.2310.23.2"></script>
  <script src="dist/js/sisplan.js?versao=3.2310.23.2"></script>
  <script src="utils/funcoes.js?versao=3.2310.23.2"></script>
  <script src="utils/cookies.js?versao=3.2310.23.2"></script>
  <script src="dist/js/requisicoes.js?versao=3.2310.23.2"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.2310.23.2"></script>
  <script src="dist/js/driver.min.js?versao=3.2310.23.2"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.2310.23.2"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.2310.23.2"></script>
  <script type="text/javascript" src="config.js?versao=3.2310.23.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('RADARNFE');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

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

    });
  </script>
</body>

</html>