
<?php

// session_start();
// $codusr = isset($_SESSION['codusr']) ? $_SESSION['codusr'] : null;
// if (!isset($_SESSION['codusr'])) {
//     header("Location: login.php");
//     exit();
// }
// // Verifica se o usuário está autenticado
// // Se não estiver autenticado, redireciona para a página de login
// // Se estiver autenticado, continua com o carregamento da página
// // Define o cabeçalho para evitar cache
// header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1
// header("Pragma: no-cache"); // HTTP 1.0
// header("Expires: 0"); // Data no passado      

?>

<!doctype html>

<html
  lang="en"
  class="layout-navbar-fixed layout-menu-fixed layout-wide"
  dir="ltr"
  data-skin="default"
  data-assets-path="assets/"
  data-template="vertical-menu-template"
  data-bs-theme="light">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
    <title>JPS - Consultoria e Serviços</title>
    <meta name="description" content="" />
    <link rel="icon" type="image/x-icon" href="assets/img/ico2.png" />
    
    <link rel="stylesheet" href="assets/vendor/fonts/iconify-icons.css" />
    <link rel="stylesheet" href="assets/vendor/libs/pickr/pickr-themes.css" />
    <link rel="stylesheet" href="assets/vendor/css/core.css" />
    <link rel="stylesheet" href="assets/css/demo.css" />
    <link rel="stylesheet" href="assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="assets/vendor/js/helpers.js"></script>
    <script src="assets/vendor/js/template-customizer.js"></script>
    <script src="assets/js/config.js"></script>
    
  </head>

  <body>
    <div class="layout-wrapper layout-content-navbar">
      <div class="layout-container">

      <?php require("sidebar.php"); ?>

        <div class="layout-page">
          
          <?php require("navbar.php"); ?>


            <div class="content-wrapper">
                <?php 
                if (isset($_GET['page'])) {
                    $page = $_GET['page'];
                    
                    $allowedPages = [
                        'dashboard'                       => 'modules/dashboard/dashboard.php', 
                        'produtos'                        => 'modules/cadastros/produtos.php',
                        'ncm'                             => 'modules/cadastros/produto_ncm.php',
                        'eqp_tipos'                       => 'modules/cadastros/eqp_tipos.php',
                        'eqp_fabricantes'                 => 'modules/cadastros/eqp_fabricantes.php',
                        'eqp_modelos'                     => 'modules/cadastros/eqp_modelos.php',
                        'eqp_tamanho'                     => 'modules/cadastros/eqp_tamanho.php',
                        'area'                            => 'modules/cadastros/area.php',
                        'saidas'                          => 'modules/estoque/produto_saida.php',
                        'servicos'                        => 'modules/servicos/servico.php',
                        'especialistas'                   => 'modules/servicos/servico_especialistas.php',
                        'tipos'                           => 'modules/servicos/servico_tipo.php',
                        'sla'                             => 'modules/servicos/sla_prioridades.php',
                        'solucao'                         => 'modules/servicos/solucao.php',
                        'status'                          => 'modules/servicos/status.php',
                        'clientes'                        => 'modules/participantes/cliente.php',
                        'fornecedores'                    => 'modules/participantes/fornecedor.php',
                        'contratos_tipo'                  => 'modules/contratos/contratos_tipo.php',
                        'contrato'                        => 'modules/contratos/contrato.php',
                        'contrato_maquina'                => 'modules/contratos/contrato_maquina.php',
                        'contrato_maquina_leituras'       => 'modules/contratos/contrato_maquina_leituras.php',
                        'usuarios'                        => 'modules/acesso/usuarios.php',
                        'chamadosAdd'                     => 'modules/os/chamadosAdd.php',
                        'chamados'                        => 'modules/os/chamados.php',
                        'chamadosReport'                  => 'modules/relatorios/consulta_chamado.php',
                    ];
                    
                    if (array_key_exists($page, $allowedPages)) {
                        include $allowedPages[$page];
                    } else {
                        include 'modules/dashboard/dashboard.php';
                    }
                } else {
                    include 'modules/dashboard/dashboard.php';
                }
                ?>
            </div>

            <!-- Footer -->
            <?php require("footer.php"); ?>
            <!-- / Footer -->

            <div class="content-backdrop fade"></div>

          </div>

        </div>
      </div>
      <div class="layout-overlay layout-menu-toggle"></div>
      <div class="drag-target"></div>
    </div>

    <!-- <script src="assets/vendor/libs/jquery/jquery.js"></script> -->

    <script src="assets/vendor/js/bootstrap.js"></script>
    <script src="assets/vendor/libs/@algolia/autocomplete-js.js"></script>
    <script src="assets/vendor/libs/pickr/pickr.js"></script>
    <script src="assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="assets/vendor/libs/hammer/hammer.js"></script>
    <script src="assets/vendor/libs/i18n/i18n.js"></script>
    <script src="assets/vendor/js/menu.js"></script>
    <script src="assets/js/main.js"></script>
  </body>
</html>
