    <?php
	/*
	* copyright (c) 2013-2022 Heliac Technologies
	* license http://opensource.org/licenses/gpl-license.php GNU GPL v3 
	*
	* linee guida per l'utilizzo del logo http://www.geecom.org/articolo.php?id=34&alias=linee-guida-per-l%27uso-del-logo-geecom
	*/
    
        $numeroNotifiche = $geecomDb->contaRigheTabella("geec_notifiche",array("prodotto"=>"Doc","idUtente"=>0,"letta"=>"no"));
    ?>
    <nav class="menu-principale navbar navbar-expand-lg fixed-top p-0 extraspace bg-secondary" id="barraMenuAdmin">
        <div id="menu-toggle" class="navbar-toggler border-0" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Apri menu">
                <i class="fas fa-bars"></i> <span class="font-weight-light">MENU</span>
        </div>
        <div class="collapse navbar-collapse" id="navbarCollapse">
            <?php 
                creaMenuAdmin($geecomDb,$percorsoBase,$_SESSION["geecomAdmin_ruolo"]); 
            ?>
        </div>

        <?php 
        
            /*
             * Le notifiche possono essere viste solo dai super admin e dagli amministratori
             */
            if($_SESSION["geecomAdmin_ruolo"]=="super admin" || $_SESSION["geecomAdmin_ruolo"]=="amministratore") {
                
                ?>
                <div class="notifiche">
                    <a class="btn py-0" id="campanellaNotifiche" onclick="mostraDivNotifiche()">
                      <i class="fas fa-bell"></i> <span class="badge badge-light"><?php echo $numeroNotifiche ?></span>
                    </a>          

                    <!-- Dropdown notifiche -->
                    <div id="dropdown-notifiche" class="d-none">
                        <?php 

                            $queryNotifiche = "SELECT * FROM geec_notifiche WHERE prodotto LIKE 'Doc' AND letta LIKE 'no' AND idUtente=0  ORDER BY id DESC LIMIT 5";
                            $risNotifiche = $geecomDb->eseguiQueryLettura($queryNotifiche);

                            if($risNotifiche->num_rows>0) {
                                while($notifica = $risNotifiche->fetch_assoc()) {
                                    $linkNotifica = ($notifica["link"]!="") ? "<a href=\"javascript:void\" onclick=\"segnaNotificaComeLettaConRedirect('../$percorsoBase',{$notifica["id"]},'{$notifica["link"]}')\"><i class=\"fas fa-external-link-alt ml-2\"></i></a>" : "";

                                    echo"<div class=\"alert alert-info\" role=\"alert\" id=\"divNotifica{$notifica["id"]}\">
                                            {$notifica["testo"]} $linkCliente
                                            <a href=\"#\" onclick=\"segnaNotificaComeLetta('../$percorsoBase',{$notifica["id"]})\" class=\"close\">
                                                <span aria-hidden=\"true\">&times;</span>
                                            </a>
                                        </div>";
                                }
                            }
                            else {
                                echo"<div class=\"alert\" role=\"alert\">
                                        Nessuna nuova notifica
                                      </div>";
                            }
                        ?>
                        <a href="notifiche.php" class="btn btn-secondary btn-sm btn-block leggi-tutto p-2 sharp">Tutte le notifiche</a>
                    </div>
                </div>
                <?php
                
            }
        ?>
    </nav>