<nav class="main-header navbar navbar-expand-md navbar-light navbar-white" style="padding-bottom: .2rem;">
  <a href="main.php" class="navbar-brand" style="padding-top: 0;">
    <img src="images/logo/logologin.svg" alt="AdminLTE Logo" class="brand-image" style="/*opacity: .8*/height: auto; width: 2rem; margin-top: .1rem;">
  </a>

  <button class="navbar-toggler order-1" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse order-3" id="navbarCollapse" style="justify-content: center; color: #560085;">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <!--<li class="nav-item">
            <a href="dashboard.php" class="nav-link">Dashboard</a>
          </li>-->
      <li class="nav-item dropdown">
        <a id="dropdownParametros" style="display: flex; align-items: center; height: 2.1rem; color:#ffffff;padding-left: 19px;background-color:#55127c; padding-right: 19px;border: 1px solid #55127c;border-radius:5px;" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Parametros</a>
        <ul aria-labelledby="dropdownParametros" class="dropdown-menu border-0 shadow">
          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownUserParams" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Param. Usuário</a>
            <ul aria-labelledby="dropdownUserParams" class="dropdown-menu border-0 shadow">
              <li><a href="formParametroUsuario.php" class="dropdown-item">Usuário</a></li>
              <li><a href="formParametroEntidade.php?idEntidade=entidade" class="dropdown-item">Entidade</a></li>
              <li><a href="formParametroEntidade.php?idEntidade=cliente" class="dropdown-item">Cliente</a></li>
              <li><a href="formParametroEntidade.php?idEntidade=fornecedor" class="dropdown-item">Fornecedor</a></li>
              <li><a href="formParametroTipoUsuario.php" class="dropdown-item">Tipo de Usuário</a></li>
              <li><a href="formParametroTipoEntidade.php" class="dropdown-item">Tipo de Entidade</a></li>
            </ul>
          </li>

          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownArtigoParams" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Param. Artigos</a>
            <ul aria-labelledby="dropdownArtigoParams" class="dropdown-menu border-0 shadow">
              <li><a href="formParametroArtigo.php" class="dropdown-item">Artigos</a></li>
              <li><a href="formParametroFamilia.php" class="dropdown-item">Famílias</a></li>
              <li><a href="formParametroArmazem.php" class="dropdown-item">Armazém</a></li>
            </ul>
          </li>

          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownMoedaParams" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Param. Moeda</a>
            <ul aria-labelledby="dropdownMoedaParams" class="dropdown-menu border-0 shadow">
              <li><a href="formParametroMoeda.php" class="dropdown-item">Moedas</a></li>
              <li><a href="formParametroCambio.php" class="dropdown-item">Câmbios</a></li>
              <li><a href="formParametroUnidadeMedida.php" class="dropdown-item">Unidades de Medida</a></li>
            </ul>
          </li>

          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownTesourParams" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Param. Tesouraria</a>
            <ul aria-labelledby="dropdownTesourParams" class="dropdown-menu border-0 shadow">
              <li><a href="formParametroCaixaBanco.php" class="dropdown-item">Caixa/Bancos</a></li>
              <li><a href="formParametroClasseMovimento.php" class="dropdown-item">Classe de Movimentos</a></li>
            </ul>
          </li>

          <li class="">
            <a href="formParametroPatrimonio.php" class="nav-link">Param. Patrimonio</a>
          </li>


        </ul>
      </li>
      <li class="nav-item dropdown">
        <a id="dropdownVendas" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Vendas</a>
        <ul aria-labelledby="dropdownVendas" class="dropdown-menu border-0 shadow">
          <li><a href="formFacturaRecibo.php?tipoDocumento=venda&natureza=facturaRecibo&operacaoStock=saida" class="dropdown-item">Factura Recibo</a></li>
          <li><a href="formFactura.php?tipoDocumento=venda&natureza=factura&operacaoStock=saida" class="dropdown-item">Factura</a></li>
          <li><a href="formRecibo.php?tipoDocumento=contaCorrente&natureza=recibo&operacaoStock=0" class="dropdown-item">Recibo</a></li>
          <li><a href="formProforma.php?tipoDocumento=venda&natureza=facturaProforma&operacaoStock=semAccao" class="dropdown-item">Factura Proforma</a></li>
          <li><a href="formAdiantamento.php?tipoDocumento=contaCorrente&natureza=documentoInterno&operacaoStock=semAccao" class="dropdown-item ">Adiantamento</a></li>
          <li><a href="formOrcamento.php?tipoDocumento=venda&natureza=orcamento&operacaoStock=semAccao" class="dropdown-item">Orçamento</a></li>
          <li><a href="formGuiaRemessa.php?tipoDocumento=venda&natureza=remessa&operacaoStock=semAccao" class="dropdown-item ">Guia de Remessa</a></li>
          <li><a href="formNotaCredito.php?tipoDocumento=venda&natureza=notaCredito&operacaoStock=entrada" class="dropdown-item">Nota de Crédito</a></li>
          <li><a href="formNotaDebito.php?tipoDocumento=venda&natureza=notaDebito&operacaoStock=entrada" class="dropdown-item">Nota de Débito</a></li><li><a href="converterdoc.php?tipoDocumento=venda&operacaoStock=saida" class="dropdown-item">Converter Documento</a></li>
        </ul>
      </li>
      <li class="nav-item dropdown">
        <a id="dropdownCompras" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Compras</a>
        <ul aria-labelledby="dropdownCompras" class="dropdown-menu border-0 shadow">
          <li><a href="formFacturaRecibo.php?tipoDocumento=compra&natureza=facturaRecibo&operacaoStock=entrada" class="dropdown-item">Factura Recibo (C)</a></li>
          <li><a href="formFactura.php?tipoDocumento=compra&natureza=factura&operacaoStock=entrada" class="dropdown-item">Factura (C)</a></li>
          <li><a href="formRecibo.php?tipoDocumento=contaCorrente&natureza=pagamentoFornecedor&operacaoStock=0" class="dropdown-item">Recibo (C)</a></li>
          <li><a href="formProforma.php?tipoDocumento=compra&natureza=facturaProforma&operacaoStock=semAccao" class="dropdown-item">Factura Proforma (C)</a></li>

          <li><a href="formFacturaInternacional.php?tipoDocumento=compra&natureza=facturaInternacional&operacaoStock=semAccao" class="dropdown-item">Factura Internacional (C)</a></li>

          <li><a href="formOrcamento.php?tipoDocumento=compra&natureza=orcamento&operacaoStock=semAccao" class="dropdown-item">Orçamento (C)</a></li>
          <li><a href="#" class="dropdown-item">Nota de Encomenda</a></li>
          <li><a href="formNotaCredito.php?tipoDocumento=compra&natureza=notaCredito&operacaoStock=saida" class="dropdown-item ">Nota de Crédito</a></li>
          <li><a href="formNotaDebito.php?tipoDocumento=compra&natureza=notaDebito&operacaoStock=saida" class="dropdown-item ">Nota de Débito</a></li>
        </ul>
      </li>
      <li class="nav-item dropdown">
        <a id="dropdownStock" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Stock</a>
        <ul aria-labelledby="dropdownStock" class="dropdown-menu border-0 shadow">
          <li><a href="formStockEntrada.php?tipoDocumento=stock&natureza=documentoInterno&operacaoStock=entrada" class="dropdown-item">Entrada de Stock</a></li>
          <li><a href="formStockSaida.php?tipoDocumento=stock&natureza=documentoInterno&operacaoStock=saida" class="dropdown-item">Saída de Stock</a></li>
          <li><a href="formTransferenciaArmazem.php?tipoDocumento=stock&natureza=documentoInterno&operacaoStock=inventario" class="dropdown-item ">Transferência de Armazém</a></li>
          <li><a href="formStockInventario.php?tipoDocumento=stock&natureza=documentoInterno&operacaoStock=inventario" class="dropdown-item">Inventário</a></li>
        </ul>
      </li>

      <!-- <li class="nav-item"><a href="#" class="nav-link">Patrimonio</a></li> -->

      <li class="nav-item dropdown">
        <a id="dropdownContas" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Tesouraria</a>
        <ul aria-labelledby="dropdownContas" class="dropdown-menu border-0 shadow">
          <li><a href="#" class="dropdown-item">Contas</a></li>
          <li><a href="#" class="dropdown-item">Rubricas</a></li>
          <li><a href="#" class="dropdown-item">Configuração</a></li>
          <li><a href="#" class="dropdown-item">Saldos Caixa/Bancos</a></li>
          <li><a href="#" class="dropdown-item">Requisição/Aprovação</a></li>
          <li><a href="#" class="dropdown-item">Lançamento de Tesouraria</a></li>
          <li><a href="#" class="dropdown-item">Reconcilhação Bancária</a></li>
          <li><a href="#" class="dropdown-item">Patrimonio/Asset</a></li>
        </ul>
      </li>

      <li class="nav-item dropdown">
        <a id="dropdownRelac" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Relatórios</a>
        <ul aria-labelledby="dropdownRelac" class="dropdown-menu border-0 shadow">
          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownSubMenu2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Vendas</a>
            <ul aria-labelledby="dropdownSubMenu2" class="dropdown-menu border-0 shadow">
              <li><a href="reportDocumentoEmitido.php?tipoDocumento=venda" class="dropdown-item">Documentos Emitidos</a></li>
              <li><a href="reportTotalMensal.php?tipoDocumento=venda" class="dropdown-item">Total de Vendas Mensais</a></li>
              <li><a href="reportTotalEntidade.php?tipoDocumento=venda" class="dropdown-item">Total de Vendas Por Entidade</a></li>
              <li><a href="reportTotalArtigoEntidade.php?tipoDocumento=venda" class="dropdown-item">Total Por Artigo/Cliente</a></li>
              <li><a href="reportTotalVendaDia.php" class="dropdown-item">Total de Vendas Diarias</a></li>
              <li><a href="reportTotalVendaFamilia.php" class="dropdown-item">Total de Vendas Por Família</a></li>
              <li><a href="reportTotalVendaArtigo.php" class="dropdown-item">Total de Vendas Por Artigo</a></li>
              <li><a href="reportTotalVendaTipoPagamento.php" class="dropdown-item">Total de Vendas Tipo Pagamento</a></li>
              <li><a href="reportTotalVendaVendedor.php" class="dropdown-item">Total de Vendas Por Vendedor</a></li>
            </ul>
          </li>
          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownSubMenu2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Compras</a>
            <ul aria-labelledby="dropdownSubMenu2" class="dropdown-menu border-0 shadow">
              <li><a href="reportDocumentoEmitido.php?tipoDocumento=compra" class="dropdown-item">Documentos Emitidos</a></li>
              <li><a href="reportTotalMensal.php?tipoDocumento=compra" class="dropdown-item">Total de Compras Mensais</a></li>
              <li><a href="reportTotalEntidade.php?tipoDocumento=compra" class="dropdown-item">Total de Compras Por Entidade</a></li>
              <li><a href="reportTotalArtigoEntidade.php?tipoDocumento=compra" class="dropdown-item">Total Por Artigo/Fornecedor</a></li>
            </ul>
          </li>
          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownSubMenu2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Stock</a>
            <ul aria-labelledby="dropdownSubMenu2" class="dropdown-menu border-0 shadow">
              <li><a href="reportDocumentoEmitido.php?tipoDocumento=stock" class="dropdown-item">Documentos Emitidos</a></li>
              <li><a href="reportTotalMensal.php?tipoDocumento=compra" class="dropdown-item disabled">Total de Compras Mensais</a></li>
              <li><a href="reportTotalEntidade.php?tipoDocumento=compra" class="dropdown-item disabled">Total de Compras Por Entidade</a></li>
              <li><a href="reportTotalArtigoEntidade.php?tipoDocumento=compra" class="dropdown-item disabled">Total Por Artigo/Fornecedor</a></li>
            </ul>
          </li>
          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownTes" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Tesouraria</a>
            <ul aria-labelledby="dropdownTes" class="dropdown-menu border-0 shadow">
              <li><a href="reportDocumentoEmitido.php?tipoDocumento=stock" class="dropdown-item">Demonstrativos Financeiros</a></li>
            </ul>
          </li>
          <li><a href="#" class="dropdown-item disabled">Conta Corrente</a></li>
          <li><a href="#" class="dropdown-item disabled">Recursos Humanos</a></li>

        </ul>
      </li>


      <li class="nav-item dropdown">
        <a id="dropdownMais" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Mais</a>
        <ul aria-labelledby="dropdownMais" class="dropdown-menu border-0 shadow">
          <li class=""><a href="formPatrimonio.php" class="dropdown-item">Patrimonio</a></li>

          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownFisc" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Fiscalidade</a>
            <ul aria-labelledby="dropdownFisc" class="dropdown-menu border-0 shadow">
              <li><a href="#" class="dropdown-item">Impostos</a></li>
              <li><a href="#" class="dropdown-item">DLs</a></li>
              <li><a href="#" class="dropdown-item">Modelos</a></li>
            </ul>
          </li>
          
          <li class="dropdown-submenu">
            <a id="dropdownRH" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle disabled">Recursos Humanos</a>
            <ul aria-labelledby="dropdownRH" class="dropdown-menu border-0 shadow">
              <li><a href="#" class="dropdown-item">Departamentos</a></li>
              <li><a href="#" class="dropdown-item">Trabalhadores</a></li>
              <li><a href="#" class="dropdown-item">Banco de Horas</a></li>
              <li><a href="#" class="dropdown-item">Ocorrências</a></li>

              <div class="dropdown-divider"></div>

              <li><a href="#" class="dropdown-item">Controle de EPI</a></li>
              <li><a href="#" class="dropdown-item">Controle de Férias</a></li>
              <li><a href="#" class="dropdown-item">Controle de Exames</a></li>

              <div class="dropdown-divider"></div>
              <li><a href="#" class="dropdown-item">Folha de Pagamento</a></li>
              <li><a href="#" class="dropdown-item">Folha de Salários/Recibos</a></li>

              <div class="dropdown-divider"></div>
              <li><a href="#" class="dropdown-item">Relógio Biométrico</a></li>
            </ul>
          </li>
        </ul>
      </li>






      <li class="nav-item dropdown">
        <a id="dropdownConfiguracao" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">Configurações</a>
        <ul aria-labelledby="dropdownConfiguracao" class="dropdown-menu border-0 shadow">
          <li><a href="formEmpresa.php" class="dropdown-item">Empresa</a></li>
          <li><a href="formConfiguracaoTerminal.php" class="dropdown-item">Terminais</a></li>
          <li><a href="#" id="btn-licenciamento" class="dropdown-item">Licenciamento</a></li>

          <li><a href="formBanco.php" class="dropdown-item">Bancos/Caixas</a></li>
          <li><a href="formDefinicao.php" class="dropdown-item">Definições</a></li>
          <li><a href="formSistema.php" class="dropdown-item">Sistema</a></li>
          <li><a href="#" class="dropdown-item">Biométrico e RH</a></li>

          <li class="dropdown-divider"></li>
          
          <li><a href="formConfiguracaoNivelAcesso.php" class="dropdown-item">Níveis de Acesso</a></li>

          <li class="dropdown-divider"></li>
          
          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownDocParams" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Documentos</a>
            <ul aria-labelledby="dropdownDocParams" class="dropdown-menu border-0 shadow">
              <li><a href="formDocumento.php" class="dropdown-item">Documentos</a></li>
              <li><a href="#" class="dropdown-item">Tipo de Documento</a></li>
            </ul>
          </li>

          <li class="dropdown-divider"></li>

          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownPagamentoParams" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">Pagamentos</a>
            <ul aria-labelledby="dropdownPagamentoParams" class="dropdown-menu border-0 shadow">
              <li><a href="formConfiguracaoModoPagamento.php" class="dropdown-item">Modo de Pagamento</a></li>
              <li><a href="#" class="dropdown-item">Método de Pagamento</a></li>
              <li><a href="formConfiguracaoPrazoPagamento.php" class="dropdown-item">Prazo de Pagamento</a></li>
            </ul>
          </li>

          <li class="dropdown-divider"></li>

          <li class="dropdown-submenu dropdown-hover">
            <a id="dropdownSubMenu2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-item dropdown-toggle">SAFT</a>
            <ul aria-labelledby="dropdownSubMenu2" class="dropdown-menu border-0 shadow">
              <li><a href="#" class="dropdown-item" id="saftVendaMensal">Vendas Mensal</a></li>
              <li><a href="#" class="dropdown-item" id="saftVendaGlobal">Vendas Global</a></li>
              <li><a href="#" class="dropdown-item" id="saftCompraMensal">Compras Mensal</a></li>
              <li><a href="#" class="dropdown-item" id="saftCompraGlobal">Compras Global</a></li>
            </ul>
            
          </li>
        </ul>
      </li>
    </ul>
  </div>


  <!-- Right navbar links -->
  <ul class="order-1 order-md-3 navbar-nav navbar-no-expand ml-auto">
    <!-- Notifications Dropdown Menu -->
    <!--<li class="nav-item dropdown">
          <a class="nav-link" data-toggle="dropdown" href="#">
            <i class="far fa-bell"></i>
            <span class="badge badge-warning navbar-badge">15</span>
          </a>
          <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
            <span class="dropdown-header">15 Notifications</span>
            <div class="dropdown-divider"></div>
            <a href="#" class="dropdown-item">
              <i class="fas fa-envelope mr-2"></i> 4 new messages
              <span class="float-right text-muted text-sm">3 mins</span>
            </a>
            <div class="dropdown-divider"></div>
            <a href="#" class="dropdown-item">
              <i class="fas fa-users mr-2"></i> 8 friend requests
              <span class="float-right text-muted text-sm">12 hours</span>
            </a>
            <div class="dropdown-divider"></div>
            <a href="#" class="dropdown-item">
              <i class="fas fa-file mr-2"></i> 3 new reports
              <span class="float-right text-muted text-sm">2 days</span>
            </a>
            <div class="dropdown-divider"></div>
            <a href="#" class="dropdown-item dropdown-footer">See All Notifications</a>
          </div>
        </li>-->
    <li class="nav-item dropdown user-menu">
      <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">

        <div class="user-image img-circle elevation-1 user-little" style="margin-top: -4px; float: left; background-image: url(images/usuario/<?php echo $_SESSION["usuarioImagem"]; ?>);"></div>
        <span class="d-none d-md-inline"><?php echo $_SESSION["usuarioNome"]; ?></span>
      </a>
      <ul class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
        <!-- User image -->
        <li class="user-header bg-primary">
          <div class="img-circle elevation-2 user-little" style="border-color: transparent; border-color: rgba(255,255,255,.2) !important; border: 3px solid; height:90px; width: 90px; background-image: url(images/usuario/<?php echo $_SESSION["usuarioImagem"]; ?>);"></div>
          <p>
            <?php echo $_SESSION["usuarioNome"]; ?> - <?php echo $_SESSION["usuarioTipoUsuario"]; ?>
            <small>Membro desde <?php echo $_SESSION["usuarioDataAdesao"]; ?></small>
          </p>
        </li>
        <!-- Menu Footer-->
        <li class="user-footer">
          <a href="formPerfil.php" class="btn btn-default btn-flat nav-link" style="display: inline-block;">Perfil</a>
          <a href="#" class="btn btn-default btn-flat float-right" id="btn-logout">Terminar Sessão</a>
        </li>
      </ul>
    </li>
    <li class="nav-item">
      <a class="nav-link" data-widget="fullscreen" href="#" role="button">
        <i class="fas fa-expand-arrows-alt"></i>
      </a>
    </li>
    <li class="nav-item">
      <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#" role="button">
        <i class="fas fa-th-large"></i>
      </a>
    </li>
  </ul>
</nav>

<script src="../pos/javascript/function.js"></script>

<script>
    
    $(document).ready(function() {
      let user_id = <?php echo $_SESSION["usuarioId"]; ?>;

      // Adiciona classes treeviewItem-<key+1> a cada link de menu
      $.each($('.navbar-collapse li a'), (key, value) => {
        $(value).addClass(`treeviewItem-${key+1}`);
      });

      // Pega todos os users e compara o idUsuario com o da Sessao
      funcaoSelect("../pos/includes/select.inc.php", "post", "json", "usuario", function success(data) {
        console.log(data);
        data.forEach(user => {
          if (user.idUsuario == user_id) {
            let userTypeId = user.idTipoUsuario;

            // Pega os menus restrictos onde tipoUsuarioId corresponde
            funcaoSelect("../pos/includes/select.inc.php", "post", "json", "user_access", function success(accesses) {
              accesses.forEach(access => {
                if (access.user_id == userTypeId) {

                  // Pega todos os menus e em fim remove os restrictos
                  funcaoSelect("../pos/includes/select.inc.php", "post", "json", "menus", function success(menus) {
                    menus.forEach(menu => {
                      if (menu.menu_id == access.menu_item_id) {
                        let menuItem = $(`.treeviewItem-${access.menu_item_id}`);
                        if (menuItem.length) {
                          // Adiciona a classe 'disabled' ao elemento pai
                          menuItem.parent().remove(); //css('display', 'none');
                          // Remove eventos de hover e clique do elemento
                          // menuItem.off('mouseenter mouseleave click');
                          console.log('Desabilitado: ', menuItem.text());
                        }
                      }
                    });
                  }, function error(_) {}, function done(_) {});
                }
              });
            }, function error(d) {}, function done(d) {});
          }
        });
      }, function error(data) {}, function done(data) {});
    });



  // $(document).ready(function() {
  //   let user_id = <?php echo $_SESSION["usuarioId"]; ?>;

  //   // Adiciona classes treeviewItem-<key+1> a cada link de menu
  //   $.each($('.navbar-collapse li a'), (key, value) => {
  //     $(value).addClass(`treeviewItem-${key+1}`);
  //   });

  //   // Pega todos os users e compara o idUsuario com o da Sessao
  //   funcaoSelect("../pos/includes/select.inc.php", "post", "json", "usuario", function success(data) {
  //     console.log(data);
  //     data.forEach(user => {
  //       if (user.idUsuario == user_id) {
  //         let userTypeId = user.idTipoUsuario;

  //         // Pega os menus restrictos onde tipoUsuarioId corresponde
  //         funcaoSelect("../pos/includes/select.inc.php", "post", "json", "user_access", function success(accesses) {
  //           accesses.forEach(access => {
  //             if (access.user_id == userTypeId) {

  //               // Pega todos os menus e em fim remove os restrictos
  //               funcaoSelect("../pos/includes/select.inc.php", "post", "json", "menus", function success(menus) {
  //                 menus.forEach(menu => {
  //                   if (menu.menu_id == access.menu_item_id) {
  //                     let menuItem = $(`.treeviewItem-${access.menu_item_id}`);
  //                     if (menuItem.length) {
  //                       // Adiciona a classe 'disabled' ao elemento pai
  //                       menuItem.parent().remove(); //css('display', 'none');
  //                       // Remove eventos de hover e clique do elemento
  //                       // menuItem.off('mouseenter mouseleave click');
  //                       console.log('Desabilitado: ', menuItem.text());
  //                     }
  //                   }
  //                 });
  //               }, function error(_) {}, function done(_) {});
  //             }
  //           });
  //         }, function error(d) {}, function done(d) {});
  //       }
  //     });
  //   }, function error(data) {}, function done(data) {});
  // });

  // const links = document.querySelectorAll('ul > li a');

  // links.forEach(link => {
  //   const activator = document.querySelector('.activator'); // Get the activator after the link
  //   link.addEventListener('click', (event) => {
  //     var parent = event.target;
  //     var next = hasChild(parent);
  //     if (next) {
  //       var allLinks = next.querySelectorAll('a');
  //       allLinks.forEach((link, index) => {
  //         link.addEventListener('click', function(e) {
  //           $('a').removeClass('selected');
  //           parent.classList.add('selected');
  //         });
  //       })
  //     }
  //   });
  // });

  // function hasChild(parent) {
  //   return parent.nextElementSibling;
  // }

</script>