<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Sisplan Web | Editor SQL</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">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css?versao=3.255.7.1">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css?versao=3.255.7.1">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
  <link rel="stylesheet" href="dist/css/animate.min.css?versao=3.255.7.1">
  <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 href="dist/css/jquery.gridly.css?versao=3.255.7.1" rel="stylesheet" type="text/css" />
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.255.7.1">
</head>

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

    <!-- 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 flex">
              <h1 class="m-0 text-dark">Editor SQL</h1>
            </div>
            <div class="col-sm-6">
 
            </div>
          </div>
        </div>
      </div>
      <div class="col-lg-12">
        <div class="modal-body">
          <div class="row">
            <div class="col-sm-12">
              <div class="row">
                <div class="col-sm-12">
                  <div class="group-default form-group">
                    <label data-error="wrong" data-success="right">SQL</label>
                    <textarea id="txtSelect" class="autoExpand forumPost form-control" rows="10" placeholder="Monte o SQL aqui"></textarea>
                  </div>
                </div>
                <div class="col-sm-12">
                  <button id="btn-consultar" type="button" class="btn btn-danger btn-sisp float-right">Consultar</button>
                  <button id="btn-identar" type="button" class="btn btn-success btn-sisp float-right ml-2 mr-2">Identar</button>
                </div>
                <div class="col-sm-12">
                  <h5>
                    Resultado SQL
                  </h5>
                </div>
                <div id="resultados" class="col-sm-12 table-responsive">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- Main content -->
      <section class="content">
        <div class="container-fluid">
          <div class="row">
            <div class="col-sm-12 table-responsive">
              <table width="100%" style="width:100%;" id="tabela-dashboards" class="table table-sm"></table>
            </div>
          </div>
        </div>
      </section>
      <section class="content">
        <div class="modal fade" id="modal-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog modal-lg">
            <div class="modal-content modal-lg">
              <div class="modal-header">
                <h4 id="modal-titulo" class="modal-title">Editor SQL: </h4>
                <h4 class="modal-title" id="id-dash"></h4>
              </div>
              <div class="modal-body">
              </div>
            </div>
          </div>
      </section>
      <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <?php
    include_once('../../modais.php');
    ?>
    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
    </aside>
    <!-- /.control-sidebar -->
  </div>
  </div>
  <!-- ./wrapper -->
  <!-- jQuery -->
  <script src="plugins/jquery/jquery.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>
  <script type="text/javascript" src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="plugins/chart.js/Chart.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="plugins/sparklines/sparkline.js?versao=3.255.7.1"></script>
  <script type="text/javascript" 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>
  <script type="text/javascript" src="dist/js/adminlte.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/loadingoverlay.min.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/sum().js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/jquery.maskMoney.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.keyTable.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="utils/cookies.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="dist/js/requisicoes.js?versao=3.255.7.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.255.7.1"></script>
  <script type="text/javascript" src="config.js?versao=3.255.7.1"></script>
  <script src="dist/js/sql-formatter.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('EDITORSQL');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

      sArquivo = `${BASE_URI}/pages/editorsql/editorsql.js?versao=3.255.7.1`;
      insereJavaScriptPagina(sArquivo);
    });
  </script>
</body>

</html>