<?php include_once('../../config.php') ?>
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
?>


<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Sisplan Web | NFS-e</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.2512.9.1">
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.2512.9.1">
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css?versao=3.2512.9.1">
  <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.2512.9.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.2512.9.1">
  <link rel="stylesheet" type="text/css" href="plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.2512.9.1">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.2512.9.1" />
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css?versao=3.2512.9.1">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="dist/css/select.bootstrap.min.css?versao=3.2512.9.1">
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.2512.9.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.2512.9.1" />
  <link rel="stylesheet" href="dist/css/sisplan.newColorsButtons.css?versao=3.2512.9.1" type="text/css" />
  <link rel="stylesheet" href="dist/css/sisplan.adjustDataTableButtons.css?versao=3.2512.9.1" type="text/css" />
  <style>
    #tabelaNotas td div button {
      padding: .0rem .5rem;
      margin: .0rem;
    }

    #tabelaNotas td {
      padding: 5px 8px !important;
    }

    #tabelaNotas_length {
      margin-top: 15px;
    }

    .dataTables_scroll {
      margin-top: -5px !important;
    }

    .ui-autocomplete-loading {
      background: white url("dist/img/ui-anim_basic_16x16.gif") center center no-repeat;
    }

    .input-group button,
    .input-group input {
      height: 40px;
    }

    .input-group button {
      min-width: 45px;
    }

    .btn.bg-danger {
      border: 1px solid white;
    }

    .info-box-text {
      font-size: 20px;
      font-weight: bold;
      color: grey;
    }

    .botoesMenu {
      height: 100%;
      padding-left: auto;
      padding-right: auto;
      color: white !important;
      min-width: 150px;
      font-weight: bold;
      margin-left: -4px !important;
      font-size: 1rem !important;
      background-color: #343a40;
      cursor: pointer !important;
    }

    .select2-container--default .select2-selection--single {
      height: 38px !important;
    }

    .opcoesImpressao {
      border-top: 0px;
      background-color: transparent !important;
      color: #869099;
      padding: 1rem;
    }
  </style>
</head>

<body class="hold-transition sidebar-mini layout-fixed">
  <div 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 row flex">
              <h1 class="m-0 text-dark">Envio e Impressão de NFS-e</h1>
              <button title="Tutorial" type="button" class="btn btn-info btn-sm ml-2" style="color: white;" id="tutorial">
                <i class="fas fa-question-circle"></i>
              </button>
            </div>
          </div>
        </div>
      </div>

      <section class="content">
        <div class="card">
          <div class="card-body pt-0">
            <div class="container-fluid p-2">
              <div class="row pb-2">
                <div class="col-sm-12 mb-2" style="margin-top: 8px; padding-right: 20px; z-index: 9999;">
                  <button id="btn-filtros" class="btn btnFiltros btn-sisp" type="button" data-toggle="modal" data-target="#modal-filtros">
                    <span class="fas fa-filter"></span> Filtros
                  </button>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-12 table-responsive" style="margin-top: -15px; height: 50vh">
                  <table id="tabelaNotas" class="table table-sm table-sm-sisp table-select table-hover" width="100%">
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="opcoesImpressao">
          <div class="row">
            <div class="col-12">
              <div id="dadosnota" class="row justify-content-center">
                <div class="col-sm-3">
                  <div class="group-default form-group">
                    <label data-error="wrong" data-success="right" for="txtNumeroNFSe">Número NFS-e: </label>
                    <div class="relative">
                      <input type="text" placeholder="Numero NF" class="input-default focus form-control validate" id="txtNumeroNFSe" name="txtNumeroNFSe" readonly>
                    </div>
                  </div>
                </div>
                <div class="col-sm-3">
                  <div class="group-default form-group">
                    <label data-error="wrong" data-success="right" for="txtEmissaoNFSe">Emissão NFS-e: </label>
                    <div class="relative">
                      <input type="text" placeholder="Emissão" class="input-default focus form-control validate" id="txtEmissaoNFSe" name="txtEmissaoNFSe" readonly>
                    </div>
                  </div>
                </div>
                <div class="col-sm-3">
                  <div class="group-default form-group">
                    <label data-error="wrong" data-success="right" for="txtCodigoVerificacao">Código Verificação: </label>
                    <div class="relative">
                      <input type="text" placeholder="Recibo" class="input-default focus form-control validate" id="txtCodigoVerificacao" name="txtCodigoVerificacao" readonly>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-12 text-center">
              <div class="btn-group flex-wrap btn-group-justified btn-group-lg" role="group" aria-label="Basic example">
                <button id="btnGerar" class="btn btn-secondary text-white btn-sisp botoesMenu"><span class="fas fa-cogs pr-1"></span>Gerar NFS-e</button>
                <button id="btnConsultar" class="btn btn-secondary text-white btn-sisp botoesMenu"><span class="fas fa-search pr-1"></span>Consultar NFS-e</button>
                <div class="btn-group dropup">
                  <button type="button" class="btn btn-secondary dropdown-toggle botoesMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <i class="fas fa-print pr-1"></i> Visualizar
                  </button>
                  <div class="dropdown-menu">
                    <button id="btnVisualizarXML" class="dropdown-item" href="">Visualizar XML</button>
                    <button id="btnBaixarXML" class="dropdown-item" href="">Baixar XML</button>
                  </div>
                </div>
                <button id="btnImprimir" class="btn btn-secondary text-white btn-sisp botoesMenu"><span class="fas fa-print pr-1" style="color: white!important"></span>Imprimir NFS-e</button>
                <button id="btnCancelar" class="btn btn-secondary text-white btn-sisp botoesMenu"><span class="fas fa-ban pr-1"></span>Cancelar NFS-e</button>
                <button id="btnExcluir" class="btn btn-secondary text-white btn-sisp botoesMenu"><span class="fas fa-trash pr-1"></span>Excluir NFS-e</button>
                <button id="btnEnviarEmail" class="btn btn-secondary text-white btn-sisp botoesMenu"><span class="fas fa-envelope pr-1"></span>Enviar E-mail</button>
              </div>
            </div>
          </div>
        </div>
      </section>
      <section class="content">
        <div class="modal fade" id="modal-itens">
          <div class="modal-dialog modal-xl">
            <div class="modal-content">
              <div class="modal-header">
                <h4 id="modal-itens-title" class="modal-title">Itens da Nota</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-sm-12">
                    <input type="text" placeholder="Nota" class="d-none" id="txtNotaItens" name="txtNotaItens" readonly>
                    <input type="text" placeholder="Serie" class="d-none" id="txtSerieItens" name="txtSerieItens" readonly>
                  </div>
                  <div class="col-sm-12 table-responsive">
                    <table id="tabelaItens" style="width:100%" class="table table-sm table-sm-sisp table-select table-hover" width="100%">
                      <thead>
                      </thead>
                      <tbody>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              <div class="modal-footer">
                <div class="row">
                  <button id="confirmar_dados" type="button" class="btn btnVerde btn-sisp"><span class="fas fa-check"></span> Confirmar</button>
                  <button type="button" class="btn btn-danger btn-sisp marginBtnH" data-dismiss="modal"><span class="fas fa-times"></span> Fechar</button>
                </div>
              </div>
            </div>
          </div>
        </div>

        <div class="modal fade" id="modal-cancelamento">
          <div class="modal-dialog modal-xl">
            <div class="modal-content">
              <div class="modal-header">
                <h4 id="modal-cancelamento-title" class="modal-title">Cancelar NFS-e</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-sm-6">
                    <div class="group-default form-group">
                      <label for="txtCancFatura">Fatura:</label>
                      <div class="relative">
                        <input type="number" class="input-default focus form-control validate" id="txtCancFatura" name="txtCancFatura" readonly>
                      </div>
                    </div>
                  </div>
                  <div class="col-sm-6">
                    <div class="group-default form-group">
                      <label for="txtCancSerie">Série:</label>
                      <div class="relative">
                        <input type="number" class="input-default focus form-control validate" id="txtCancSerie" name="txtCancSerie" readonly>
                      </div>
                    </div>
                  </div>
                  <div class="col-sm-12">
                    <div class="group-default form-group">
                      <label data-error="wrong" data-success="right" for="txtCancJustificativa">Justificativa:</label>
                      <textarea type="textarea" style="resize: none" placeholder="" class="input-default focus form-control validate" id="txtCancJustificativa" name="txtCancJustificativa" required="required" rows="3"></textarea>
                    </div>
                  </div>
                </div>
              </div>
              <div class="modal-footer">
                <div class="row">
                  <button id="btn-confirmar-cancelamento" type="button" class="btn btnVerde btn-sisp"><span class="fas fa-check"></span> Confirmar</button>
                  <button type="button" class="btn btn-danger btn-sisp marginBtnH" data-dismiss="modal"><span class="fas fa-times"></span> Fechar</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </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">
            <div class="row">
              <div class="col-lg-9 col-12">
                <div class="row">
                  <div class="col-6 form-group">
                    <label>Emissão de/até:</label>
                    <div class="input-group">
                      <input type="date" max="2500-12-31" value="" class="input-default focus form-control validate" id="txtEmiDe" name="txtEmiDe">
                      <input type="date" max="2500-12-31" value="" class="input-default focus form-control validate" id="txtEmiAte" name="txtEmiAte">
                    </div>
                  </div>
                  <div class="col-3 form-group">
                    <label data-error="wrong" data-success="right" for="txtNFSe">NFS-e: </label>
                    <div class="input-group">
                      <input type="text" class="input-default focus form-control" id="txtNFSe" name="txtNFSe" class="form-control" placeholder="NFS-e">
                      <div class="input-group-append">
                        <button class="btn bg-danger" id="btn-Nfse" name="btn-cliente" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                        <button class="btn bg-danger" id="btn-limpa-Nfse" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                      </div>
                    </div>
                  </div>
                  <div class="col-3 form-group">
                    <label data-error="wrong" data-success="right" for="txtRPS">RPS: </label>
                    <div class="input-group">
                      <input type="text" class="input-default focus form-control" id="txtRPS" name="txtRPS" class="form-control" placeholder="RPS">
                      <div class="input-group-append">
                        <button class="btn bg-danger" id="btn-limpa-RPS" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                      </div>
                    </div>
                  </div>
                  <div class="col-6 form-group">
                    <label data-error="wrong" data-success="right" for="txtCliente">Cliente: </label>
                    <div class="input-group">
                      <input type="text" 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="btn-cliente" name="btn-cliente" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                        <button class="btn bg-danger" id="btn-limpa-cliente" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                      </div>
                    </div>
                  </div>
                  <div class="col-6 form-group">
                    <label data-error="wrong" data-success="right" for="txtStatusPed">Status Ped.: </label>
                    <div class="input-group">
                      <input type="text" class="input-default focus form-control" id="txtStatusPed" name="txtStatusPed" class="form-control" placeholder="Status Ped.:">
                      <div class="input-group-append">
                        <button class="btn bg-danger" id="btn-StatusPed" name="btn-StatusPed" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                        <button class="btn bg-danger" id="btn-limpa-StatusPed" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                      </div>
                    </div>
                  </div>
                  <div class="col-12 form-group">
                    <label data-error="wrong" data-success="right" for="txtCodObra">Cód. Obra: </label>
                    <div class="input-group">
                      <input type="text" class="input-default focus form-control" id="txtCodObra" name="txtCodObra" class="form-control" placeholder="Cód. Obra">
                      <div class="input-group-append">
                        <button class="btn bg-danger" id="btn-limpa-CodObra" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-lg-3 col-12">
                <div class="form-group clearfix ml-4">
                  <h6>Notas Fiscais: </h6>
                  <div class="icheck-primary">
                    <input type="radio" id="radioPrimary1" value="0" name="rg_status" checked>
                    <label for="radioPrimary1">Todas
                    </label>
                  </div>
                  <div class="icheck-primary">
                    <input type="radio" id="radioPrimary2" value="1" name="rg_status">
                    <label for="radioPrimary2">Impressa
                    </label>
                  </div>
                  <div class="icheck-primary">
                    <input type="radio" id="radioPrimary3" value="2" name="rg_status">
                    <label for="radioPrimary3">Não Impressa</label>
                  </div>
                  <div class="icheck-primary">
                    <input type="radio" id="radioPrimary4" value="3" name="rg_status">
                    <label for="radioPrimary4">Canceladas
                    </label>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <div class="row">
              <button id="btn-consultar" class="btn btn-primary btn-sisp" type="button"><span class="fas fa-search"></span> Consultar</button>
              <button class="btn btn-danger btn-sisp marginBtnH" id="btnLimparFiltros"><span class="fas fa-trash"></span> Limpar Filtros</button>
            </div>
          </div>
        </div>
      </div>
    </div>
    </footer>
    <?php
    include_once('../../modais.php');
    ?>
  </div>

  <script src="plugins/jquery/jquery.min.js?versao=3.2512.9.1"></script>

  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.2512.9.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.2512.9.1"></script>
  <script type="text/javascript" src="dist/js/loadingoverlay.min.js?versao=3.2512.9.1"></script>

  <!-- jQuery UI 1.11.4 -->
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.2512.9.1"></script>
  <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  <script>
    $.widget.bridge('uibutton', $.ui.button)
  </script>
  <!-- Bootstrap 4 -->
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.2512.9.1"></script>
  <!-- AdminLTE App -->
  <script src="dist/js/adminlte.min.js?versao=3.2512.9.1"></script>

  <script src="dist/js/sisplan.js?versao=3.2512.9.1"></script>
  <script type="text/javascript" src="utils/funcoes.js?versao=3.2512.9.1"></script>
  <!-- SweetAlert2 -->
  <script src="plugins/sweetalert2/sweetalert2.min.js?versao=3.2512.9.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.2512.9.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.2512.9.1"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.2512.9.1"></script>
  <script src="utils/cookies.js?versao=3.2512.9.1"></script>
  <script src="dist/js/jquery.maskMoney.min.js?versao=3.2512.9.1"></script>
  <script src="pages/loja/js/rotinas.js?versao=3.2512.9.1"></script>
  <script src="dist/js/dataTables.keyTable.js?versao=3.2512.9.1"></script>
  <script src="dist/js/driver.min.js?versao=3.2512.9.1"></script>
  <script type="text/javascript" src="config.js?versao=3.2512.9.1"></script>
  <script src="<?php echo BASE_URI; ?>/dist/js/FileSaver.min.js?versao=3.2512.9.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('IMPRESSAO_NFSE');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

    });
  </script>
  <script type=" text/javascript" src="pages/nfse/js/nfse.js?versao=3.2512.9.1"></script>

</body>

</html>