<?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>
  <!-- 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">
  <!-- Ionicons -->
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.255.7.1">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css?versao=3.255.7.1">
  <!-- Daterange picker -->
  <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.255.7.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.255.7.1">
  <link rel="stylesheet" type="text/css" href="plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.255.7.1">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.255.7.1" />
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css?versao=3.255.7.1">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="dist/css/select.bootstrap.min.css?versao=3.255.7.1">
  <!-- Google Font: Source Sans Pro -->
  <!-- AutoComplete -->
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.255.7.1">

  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.255.7.1" />

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

    .content-wrapper {
      margin-left: 0px !important;
    }

    .main-header,
    .main-sidebar {
      display: none;
    }

    .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>
  <!-- Toastr -->
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css">

</head>

<body class="hold-transition sidebar-mini layout-fixed">
  <div class="wrapper">
    <?php
    include_once('../../menu.php');
    ?>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <div class="content-header">
        <div class="container-fluid">
          <div class="row mb-2">
            <div class="col-sm-6 row flex">
              <h4 class="m-0 text-dark">Envio e Impressão de NFS-e</h4>
              <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><!-- /.col -->
            <div class="col-sm-6">
              <!-- <ol class="breadcrumb float-sm-right">
                <li class="breadcrumb-item active">Loja</li>
                <li class="breadcrumb-item active">Impressão NFC-e</li>
              </ol> -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </div><!-- /.container-fluid -->
      </div>
      <!-- /.content-header -->

      <!-- Main content -->
      <section class="content">

        <div class="card">
          <div class="card-body">
            <div class="container-fluid p-2">
              <div class="row pb-2">
                <div class="col-sm-12">
                  <button id="btn-filtros" class="btn btn-success 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">
                  <h5>Notas Fiscais</h5>
                </div>
                <div class="col-sm-12 table-responsive pt-2">
                  <table id="tabelaNotas" class="table table-sm 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>
            <!-- <button id="btnExcluir" class="btn btn-secondary text-white btn-sisp botoesMenu"><span class="fas fa-trash pr-1"></span>Excluir NFS-e</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-select table-hover" width="100%">
                      <thead>
                      </thead>
                      <tbody>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              <div class="modal-footer justify-content-between">
                <button type="button" class="btn bg-gradient-danger btn-sisp" data-dismiss="modal">Fechar</button>
                <button id="confirmar_dados" type="button" class="btn bg-gradient-success btn-sisp">Confirmar</button>
              </div>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </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="Justificativa" class="input-default focus form-control validate" id="txtCancJustificativa" name="txtCancJustificativa" required="required" rows="3"></textarea>
                    </div>
                  </div>
                </div>
              </div>
              <div class="modal-footer justify-content-between">
                <button id="btn-confirmar-cancelamento" type="button" class="btn bg-gradient-success btn-sisp">Confirmar</button>
                <button type="button" class="btn bg-gradient-danger btn-sisp" data-dismiss="modal">Fechar</button>
              </div>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
      </section>
      <!-- /.content -->
    </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-3">
                    <div class="group-default form-group">
                      <label for="dtIni">Emissão De:</label>
                      <div class="relative">
                        <input type="date" max="2500-12-31" value="" class="input-default focus form-control validate" id="txtEmiDe" name="txtEmiDe">
                      </div>
                    </div>
                  </div>
                  <div class="col-3">
                    <div class="group-default form-group">
                      <label for="dtFim">Emissão Até:</label>
                      <div class="relative">
                        <input type="date" max="2500-12-31" value="" class="input-default focus form-control validate" id="txtEmiAte" name="txtEmiAte">
                      </div>
                    </div>
                  </div>
                  <div class="col-3">
                    <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">
                    <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">
                    <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">
                    <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">
                    <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-RPS" 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>
            </div>
          </div>
        </div>
      </div>
    </div>
    </footer>
    <?php include_once('../../modais.php'); ?>


    <!-- /.control-sidebar -->
  </div>
  <!-- ./wrapper -->

  <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 type="text/javascript" src="dist/js/loadingoverlay.min.js?versao=3.255.7.1"></script>

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

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

</body>

</html>