<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Sisplan Web | Regra Promoção</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.263.17.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/adminlte.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="dist/css/custom.css?versao=3.263.17.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.263.17.1">
  <link rel="stylesheet" type="text/css" href="plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.263.17.1">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.263.17.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.263.17.1">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.263.17.1" />
  <link rel="stylesheet" href="dist/css/sisplan.newColorsButtons.css?versao=3.263.17.1" type="text/css" />
  <link rel="stylesheet" href="dist/css/sisplan.adjustDataTableButtons.css?versao=3.263.17.1" type="text/css" />
  <link rel="stylesheet" href="dist/css/PesquisaVariosSelect2.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/select2/css/select2.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.263.17.1">

  <style>
    #tabelaRegras td div button {
      padding: .0rem .5rem;
      margin: .0rem;
    }

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

    .table.dataTable tbody td,
    th {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    #tabelaRegras_length {
      margin-top: 15px;
    }

    .dataTables_scroll {
      margin-top: -5px !important;
    }
  </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">Regra Promoção</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 class="container-fluid">
            <div class="row card">
              <div class="col-sm-12 d-flex justify-content-between" style="margin-top: 8px; padding-left: 20px; padding-right: 20px; z-index: 9999;">
                <div class="d-flex align-items-center mt-2">
                  <button class="btn btnFiltros btn-sisp" id="btnFiltros" type="button"><span class="fas fa-filter"></span> Filtros</button>
                  <button class="btn btn-danger btn-sisp marginBtnH" id="btnNovaRegraPromocao"><span class="fas fa-plus"></span> Incluir</button>
                  <button type="button" id="btnImportar" name="btnImportar" class="btn btn-danger btn-sisp marginBtnH" value="Importar"> <span class="fas fa-file"></span> Importar</button>
                </div>
              </div>
              <div class="col-sm-12 table-responsive card-body" style="margin-top: -15px; height: 80vh">
                <table id="tabelaRegras" class="table table-sm table-sm-sisp table-select table-hover" width="100%">
                  <thead>
                  </thead>
                  <tbody>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div id="modal-importar" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
      <div class="modal-content" id="modalBody">
        <div class="modal-header">
          <h4 class="modal-title">Importar Preços</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-6 col-12 mt-3 mb-3">
              <label for="dtEmiIni">Data inicial de/até: *</label>
              <div class="input-group">
                <input type="date" max="2500-12-31" class="input-default focus form-control" id="dataIni" name="dataIni" class="form-control">  
                <input type="date" max="2500-12-31" class="input-default focus form-control" id="dataFim" name="dataFim" class="form-control">
              </div>
            </div>
            <div class="col-lg-6 col-12 mt-3 mb-3">
              <label for="txtTabelaPreco">Tabela de Preço: *</label>
              <div class="input-group">
                <input type="text" class="input-default focus form-control" aria-describedby="ufError" id="txtTabelaPreco" name="txtTabelaPreco" class="form-control" placeholder="Tabela de preço">
                <div class="input-group-append">
                  <button class="btn bg-danger" id="btnTabelaPreco" name="btnTabelaPreco" data-button="absolute" type="button">
                    <i class="m-0 p-0 fas fa-search"></i>
                  </button>
                  <button class="btn bg-danger" id="btnATabelaPreco" type="button">
                    <i class="m-0 p-0 fas fa-trash"></i>
                  </button>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-6 col-12 form-group">
              <label data-error="wrong" data-success="right" for="txtImportarEmpresa">Empresa: </label>
              <div class="input-group">
                <select class="js-example-programmatic js-states form-control" id="txtImportarEmpresa" name="txtImportarEmpresa" multiple="multiple"></select>
                <div class="input-group-append">
                  <button class="btn bg-danger" id="btnImportarEmpresa" name="btnImportarEmpresa" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                  <button class="btn bg-danger" id="btnLimpaImportarEmpresa" name="btnLimpaImportarEmpresa" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                </div>
              </div>
            </div>
            <div class="form-group col-lg-4 col-12">
              <label data-error="wrong" data-success="right" for="txtArquivoImportar">Arquivo </label>
              <div class="input-group">
                <input type="text" class="input-default focus form-control" id="txtArquivoImportar" name="txtArquivoImportar" placeholder="Arquivo" disabled>
                <input type="file" id="mdModalUpload" class="d-none">
                <div class="input-group-append">
                  <button class="btn bg-danger" id="btnArquivoImportar" name="btnArquivoImportar" title="arquivo deve ser um .csv de barras únicas (barra_log)" type="file" for="txtArquivoImportar"><i class="m-0 p-0 fas fa-folder-plus"></i> </button>
                </div>
              </div>
            </div>
            <div class="form-group align-content-end col-2">
              <button class="btn btn-primary btn-sisp" id="btnCarregarImportarArquivo"> Ler Arquivo</button>
            </div>
            <div class="col-xl-12 col-12">
              <div class="table-responsive">
                <table id="tabelaImportarArquivo" class="table table-sm table-select table-hover" width="100%">
                  <thead>
                  </thead>
                  <tbody>
                  </tbody>
                </table>
              </div>
            </div>
            <div class="d-none">
              <pre id="fileContent"></pre>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <div class="row">
            <button id="btnImpConfirmar" class='btn btn-danger btn-sisp' type='button'><span class="fas fa-check"></span> Confirmar</button>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div id="modal-filtros" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" 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="d-flex align-items-end col-12 p-0">
              <div class="col-lg-8 form-group">
                <label for="dtEmiIni">Data inicial de/até: *</label>
                <div class="input-group">
                  <input type="date" max="2500-12-31" class="input-default focus form-control" id="dataIni" name="dataIni" class="form-control">
                  <input type="date" max="2500-12-31" class="input-default focus form-control" id="dataFim" name="dataFim" class="form-control">
                </div>
              </div>
              <div class="col-lg-4 form-group">
                <button class="btn btn-danger btn-sisp" type='button' id="btnSelecionarEmpresas">Selecionar Empresas</button>
              </div>
            </div>
            <div class="col-12 col-lg-6" id="tabelaPrecoTuto">
              <label for="txtTabelaPreco">Tabela de Preço: *</label>
              <div class="input-group">
                <input type="text" class="input-default focus form-control" aria-describedby="ufError" id="txtTabelaPreco" name="txtTabelaPreco" class="form-control" placeholder="Tabela de preço">
                <div class="input-group-append">
                  <button class="btn bg-danger" id="btnTabelaPreco" name="btnTabelaPreco" data-button="absolute" type="button">
                    <i class="m-0 p-0 fas fa-search"></i>
                  </button>
                  <button class="btn bg-danger" id="btnATabelaPreco" type="button">
                    <i class="m-0 p-0 fas fa-trash"></i>
                  </button>
                </div>
              </div>
            </div>
            <div class="col-12 col-lg-6" id="produtotuto">
              <label data-error="wrong" class="labelGeral" data-success="right" for="txtRegra">Regra:</label>
              <div class="input-group">
                <input type="text" class="input-default focus form-control" id="txtRegra" name="txtRegra" class="form-control" placeholder="Regra">
                <div class="input-group-append">
                  <button class="btn bg-danger" id="btnRegra" name="btnRegra" data-button="absolute" type="button">
                    <i class="m-0 p-0 fas fa-search"></i>
                  </button>
                  <button class="btn bg-danger" id="btnARegra" 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>
        </div>
        <div class="modal-footer">
          <div class="row">
            <button id="btnConsultar" 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>
  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside><!-- /.control-sidebar -->
  <?php include_once('../../../modais.php'); ?>
  </div><!-- /.wrapper -->

  <script src="plugins/jquery/jquery.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/jquery.maskMoney.min.js?versao=3.263.17.1"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.263.17.1"></script>
  <script src="plugins/sweetalert2/sweetalert2.min.js?versao=3.263.17.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.263.17.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/adminlte.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.263.17.1"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/valida_cpf_cnpj.js?versao=3.263.17.1"></script>
  <script src="plugins/jquery-validation/jquery.validate.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/dataTables.keyTable.js?versao=3.263.17.1"></script>
  <script src="dist/js/sisplan.js?versao=3.263.17.1"></script>
  <script src="utils/funcoes.js?versao=3.263.17.1"></script>
  <script src="utils/cookies.js?versao=3.263.17.1"></script>
  <script src="dist/js/driver.min.js?versao=3.263.17.1"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
  <script src="config.js"></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;
      sArquivo = `${BASE_URI}/pages/regrapromocao/acesso_regrapromocao/acesso_regrapromocao.js?versao=3.263.17.1`;
      const nomeTela = ('<?php echo basename(__FILE__) ?>').replace('.php', '');
      // nomeTela
      const temAcesso = await temAcessoTela('REGRA_PROMOCAO');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

      await insereJavaScriptPagina(sArquivo);

      habilitaCamposObrigatoriosTela(nomeTela);
    });
  </script>

</body>

</html>