<?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 | Permissões</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">
  <!-- 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.2310.23.2">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css?versao=3.2310.23.2">
  <!-- 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.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" />
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.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" />
  <!-- Google Font: Source Sans Pro -->
  <style>
    .info-box-text {
      font-size: 20px;
      font-weight: bold;
      color: grey;
    }
  </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 flex">
              <h1 class="m-0 text-dark">Permissões Tela</h1>
              <button class="btn btn-info btn-sm ml-2" 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"><a href="index.php">Início</a></li>
                <li class="breadcrumb-item active">Sistema</li>
                <li class="breadcrumb-item active">Permissões Tela</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-4">
              <div class="row pb-4">
                <div class="col-sm-6">
                  <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">

                  <div class="d-inline pb-2">
                    <h5>Selecionar todos: </h5>
                  </div>
                  <div class="icheck-primary">
                    <input class="form-check-input" type="checkbox" id="check_todos" value="option5">
                    <label class="form-check-label" for="check_todos" id="check_todosTour">Todos</label>
                  </div>
                </div>
              </div>

              <div style="background-color: var(--widget-color)" class="row">
                <div class="col-sm-12 pb-2" id="aplicarTodosTour">
                  <div class="d-inline pb-2">
                    <h5>Aplicar a todos selecionados: </h5>
                  </div>
                  <div class="icheck-primary d-inline pb-2">
                    <input class="form-check-input" type="checkbox" id="check_permissao" value="option1">
                    <label class="form-check-label" for="check_permissao">Permissão</label>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-12 table-responsive">
                  <table id="tabelaAcessos" class="table table-sm table-select table-hover" width="100%">
                    <thead>
                      <th>Sel</th>
                      <th>Cod. Usuário</th>
                      <th>Usuário</th>
                      <th>Tela</th>
                      <th>Ação</th>
                      <th>Permissão</th>
                    </thead>
                    <tbody>
                    </tbody>
                  </table>
                </div>
                <div class="col-sm-12">
                  <button id="btn-liberar" class="btn btn-danger btn-sisp">Confirmar</button>
                </div>
              </div>
            </div>
          </div>
        </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-6  col-12 form-group">
                <label data-error="wrong" class="labelGeral" data-success="right" for="txtUsuario">Usuário</label>
                <div class="input-group">
                  <input type="text" placeholder="Usuário" class="input-default focus form-control validate" id="txtUsuario" name="txtUsuario">
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnUsuario" name="btnUsuario" data-button="absolute" type="button">
                      <i class="m-0 p-0 fas fa-search"></i>
                    </button>
                    <button class="btn bg-danger" id="btnAUsuario" type="button">
                      <i class="m-0 p-0 fas fa-trash"></i>
                    </button>
                  </div>
                </div>
              </div>
              <div class="col-lg-6  col-12 form-group">
                <label data-error="wrong" class="labelGeral" data-success="right" for="txtTela">Tela</label>
                <div class="input-group">
                  <input type="text" placeholder="Tela" class="input-default focus form-control validate" id="txtTela" name="txtTela">
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnATela" type="button">
                      <i class="m-0 p-0 fas fa-trash"></i>
                    </button>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <div class="group-button">
              <button id="btn-fechar" class="btn btn-danger btn-sisp" type="button" data-dismiss="modal">Fechar</button>
              <button id="btn-consultar" class="btn btn-primary btn-sisp" type="button">Consultar</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
      <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.content-wrapper -->
    <?php
    include_once('../../../footer.php');
    ?>
    <!-- /.control-sidebar -->
  </div>
  <!-- ./wrapper -->

  <!-- jQuery -->
  <script src="plugins/jquery/jquery.min.js?versao=3.2310.23.2"></script>
  <!-- jQuery UI 1.11.4 -->
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.2310.23.2"></script>
  <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  <script>
    if ($('[type="date"]').prop('type') != 'date') {
      $('[type="date"]').datepicker();
    }
    $.widget.bridge('uibutton', $.ui.button);
  </script>

  <!-- Bootstrap 4 -->
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.2310.23.2"></script>
  <script src="dist/js/sisplan.js?versao=3.2310.23.2"></script>
  <script type="text/javascript" src="utils/funcoes.js?versao=3.2310.23.2"></script>
  <script src="dist/js/adminlte.min.js?versao=3.2310.23.2"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.min.js?versao=3.2310.23.2"></script>
  <script type="text/javascript" src="dist/js/loadingoverlay.min.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="dist/js/jquery.maskMoney.min.js?versao=3.2310.23.2"></script>
  <script src="dist/js/dataTables.keyTable.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>
  <!-- SweetAlert2 -->
  <script src="plugins/sweetalert2/sweetalert2.min.js?versao=3.2310.23.2"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.2310.23.2"></script>
  <script src="dist/js/driver.min.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('PERMISSOES_TELA');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

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

    });
  </script>
</body>

</html>