

<div class="topbar">



<!-- LOGO -->

<div class="topbar-left"> <a href="dashboard.php" class="logo"> <span> <img src="../images/CIMAC-logo-white-1024x259-1.png" alt="logo-small" class="logo-sm"> </span> <span> 

  <!--    <img src="../images/CIMAC-logo-white-1024x259-1.png" alt="logo-large" class="logo-lg logo-light">

                        <img src="../images/CIMAC-logo-white-1024x259-1.png" alt="logo-large" class="logo-lg"> -->

</span> </a> </div>

<!--end logo-->

<!-- Navbar -->

<?php

// Inizializza le variabili prima di qualsiasi output HTML

$currentLangName = "English"; // Valore di default

$currentLangFlag = "en.png";  // Valore di default



// Se la sessione ha già una lingua selezionata, aggiorna le variabili

if (isset($_SESSION['langselect'])) {

    // Cicla attraverso le lingue per trovare quella attiva

    while (!$languageselection->atEnd()) {

        $currentLangAcronym = $languageselection->getColumnVal("acronym_languages");

        if ($_SESSION['langselect'] == $currentLangAcronym) {

            $currentLangName = $languageselection->getColumnVal("name_languages");

            $currentLangFlag = $languageselection->getColumnVal("flag_languages");

            break; // Uscire dal ciclo una volta trovata la lingua attiva

        }

        $languageselection->moveNext();

    }

    $languageselection->moveFirst(); // Resettare il recordset

}

?>



<nav class="navbar-custom">

  <ul class="list-unstyled topbar-nav float-right mb-0">

   <li class="hidden-sm">

    <a class="nav-link dropdown-toggle waves-effect waves-light" data-toggle="dropdown" href="javascript: void(0);" role="button"

       aria-haspopup="false" aria-expanded="false">

        <?php echo $currentLangName; ?>

        <img src="assets/images/flags/<?php echo $currentLangFlag; ?>" class="ml-2" height="16" alt=""/>

        <i class="mdi mdi-chevron-down"></i>

    </a>



    <div class="dropdown-menu dropdown-menu-right">

        <?php

        while (!$languageselection->atEnd()) {

            $currentLangAcronym = $languageselection->getColumnVal("acronym_languages");

            $isActive = (isset($_SESSION['langselect']) && $_SESSION['langselect'] == $currentLangAcronym) ? 'active' : '';

            

            // Il link punta direttamente a dashboard.php con il parametro di selezione della lingua

            $href = 'dashboard.php?languageselect=' . $currentLangAcronym;

            ?>

            <a class="dropdown-item <?php echo $isActive; ?>" href="<?php echo $href; ?>">

                <span> <?php echo $languageselection->getColumnVal("name_languages"); ?></span>

                <img src="assets/images/flags/<?php echo $languageselection->getColumnVal("flag_languages"); ?>" alt="" class="ml-2 float-right" height="14"/>

            </a>

            <?php

            $languageselection->moveNext();

        }

        $languageselection->moveFirst(); // Reset del recordset per un altro uso futuro

        ?>

    </div>

</li>







     

   

<li class="dropdown"> 

	<a class="nav-link dropdown-toggle waves-effect waves-light nav-user" data-toggle="dropdown" href="#" role="button" aria-haspopup="false" aria-expanded="false"> <img src="upload/users/<?php echo $avatarname; ?>" alt="profile-user" class="rounded-circle" /> <span class="ml-1 nav-user-name hidden-sm"><?php echo $nameuser; ?> <i class="mdi mdi-chevron-down"></i></span> </a>

      <div class="dropdown-menu dropdown-menu-right"> 

		  <a class="dropdown-item" href="profile"><i class="ti-user text-muted mr-2"></i> <?php echo $profile; ?></a> 

		  <a class="dropdown-item" href="companyprofile.php"><i class="ti-wallet text-muted mr-2"></i> <?php echo $mycompany; ?></a> 

          <a class="dropdown-item" href="signaturetok.php"><i class="ti-wallet text-muted mr-2"></i> <?php echo $signaturetokentitle; ?></a> 

          <a class="dropdown-item" href="newusercolleague2.php"><i class="ti-wallet text-muted mr-2"></i> Aggiungi Utente</a> 

		  <a class="dropdown-item" href="#"><i class="ti-settings text-muted mr-2"></i> <?php echo $settings; ?></a> 

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

        <a class="dropdown-item" href="logout"><i class="ti-power-off text-muted mr-2"></i> <?php echo $logoutst; ?></a> </div>

    </li>

  </ul>

  <!--end topbar-nav-->

  <ul class="list-unstyled topbar-nav mb-0">

    <li>

      <button class="nav-link button-menu-mobile waves-effect waves-light"> <i class="ti-menu nav-icon"></i> </button>

    </li>

    <li class="hide-phone app-search">

      <form role="search" class="">

        <input type="text" id="AllCompo" placeholder="Search..." class="form-control">

        <a href=""><i class="fas fa-search"></i></a>

      </form>

    </li>

  </ul>

</nav>

<!-- end navbar-->

</div>

