


<?php
	include_once ("core.php");
	$rs_profilo = $dbo->fetchArray("SELECT immagine02 , profilo_skin  FROM zz_utenti  WHERE idutente=\"".$_SESSION['idutente']."\"");	
	$logo_avatar=$rs_profilo[0]['immagine02'];
	if ($logo_avatar != '' ) {
		$logo_avatar=$rootdir."/files/utenti/".$rs_profilo[0]['immagine02'];
	}
	else{
		$logo_avatar=$img."/logo.png";
	}

	$profilo_skin=$rs_profilo[0]['profilo_skin'];

	

	?><!DOCTYPE html>


<html>
    <head>
        <meta charset="UTF-8">
        <title><?php echo $pageTitle ?> - <?php echo _("GEST366") ?></title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="shortcut icon" href="assets/img/favicon.ico">

        <?php loadCSSModules($css_modules); ?>
		
		<script>
			globals = { rootdir: '<?php echo $rootdir ?>', id_module: '<?php echo $id_module ?>' };
		</script>
		<?php loadJscriptModules($jscript_modules); ?>
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="<?php echo $js ?>/html5shiv.min.js?v=<?php echo $version ?>"></script>
          <script src="<?php echo $js ?>/respond.min.js?v=<?php echo $version ?>"></script>
        <![endif]-->
		
    </head>

	<body class="skin-<?php echo $profilo_skin; ?> fixed">

		<div class="wrapper">

			<div id="main_loading">
				<div>
					<i class="fa fa-cog fa-spin text-danger"></i>
				</div>
			</div>
			
			<!-- header logo: style can be found in header.less -->
			<header class="main-header">
				<a href="https://www.gest366.it" class="logo">
					<!-- mini logo for sidebar mini 50x50 pixels -->
					<span class="logo-mini"><?php echo _("GEST366") ?></span>
					<!-- logo for regular state and mobile devices -->
					<!-- <span class="logo-lg"><?php echo _("Gestionale360111") ?></span> -->
					<span class="logo-lg"><?php echo $_SESSION['nome_gestonale360'] ?></span>
				</a>
				<!-- Header Navbar: style can be found in header.less -->
			

				
				<nav class="navbar navbar-static-top" role="navigation">
					<!-- Sidebar toggle button-->
					<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
						<span class="sr-only"><?php echo _("Mostra/nascondi menu") ?></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</a>
					
					<div class="input-group btn-calendar pull-left">
						<button id="daterange" class="btn"><i class="fa fa-calendar"></i> <i class="fa fa-caret-down"></i></button>
					</div>
					<div class="input-group btn-calendar pull-left">					
						<?php 
						if (file_exists($docroot . "/include/notifiche_task.php")) {
							include ("notifiche_task.php");
						}
						?>	
						<?php 
						if (file_exists($docroot . "/include/notifiche_hp.php")) {
							include ("notifiche_hp.php");
						}
						?>	
						<?php 
						if (file_exists($docroot . "/include/notifiche_lab.php")) {
							include ("notifiche_lab.php");
						}
						?>
						<?php 
						if (file_exists($docroot . "/include/notifiche_varie.php")) {
							include ("notifiche_varie.php");
						}
						?>	
						<?php 
						if (file_exists($docroot . "/include/notifiche_nolo.php")) {
							include ("notifiche_nolo.php");
						}
						?>	

					
			</div>
								
					
					<div id="right-menu" class="pull-right">
						
						<?php if( $_SESSION['gruppo'] == 'Amministratori' ){ ?>
							<a href="<?php echo $rootdir ?>/settings.php" class="btn btn-sm btn-github tip" title="<?php echo _("Impostazioni") ?>"><i class="fa fa-th-list"></i></a>					
							<a href="<?php echo $rootdir ?>/log.php" class="btn btn-sm btn-github tip" title="<?php echo _("Log accessi") ?>"><i class="fa fa-book"></i></a>
						<?php } ?>
						<a href="<?php echo $rootdir ?>/info.php" class="btn btn-sm btn-github tip" title="<?php echo _("Informazioni") ?>"><i class="fa fa-info"></i></a>
						<a href="https://www.gest366.it/doc.html" class="btn btn-sm btn-github tip" title="<?php echo _("Documentazione") ?>"><i class="fa fa-question-circle-o"></i></a>
						<a href="<?php echo $rootdir ?>/index.php?op=logout" class="tip" title="<?php echo _("Esci") ?>"><i class="fa fa-power-off btn btn-danger"></i></a>
					
					
				
					</div>
				</nav>
			</header>

            <aside class="main-sidebar">                
                <section class="sidebar">
                
                    <!-- Sidebar user panel -->
                    <div class="user-panel">
                        <div class="pull-left image">
                            <img src="<?php echo $logo_avatar ?>" class="img-circle" alt="<?php echo _("Foto profilo") ?>" />
                        </div>
                        
                        <div class="pull-left info">
                            <p><?php echo $_SESSION['username'] ?></p>
                            <a href="javascript:;"><i class="fa fa-circle text-success"></i> <?php echo _("Online") ?></a>
                        </div>
                        <div class="clearfix"></div>
	                    <div class="text-center" id="datetime">...</div>						
                    </div>
					
                    
                    <!-- search form -->
                    
					<style>ul#ui-id-1 {
					left: 232px !important;
					top: 151px !important;
					padding-left: 20px;
					padding-top: 10px;
					padding-bottom: 17px;
					position: fixed;
					}</style>

					<div class="sidebar-form">
                        <div class="input-group">
                            <input type="text" name="q" class="form-control" id="supersearch" placeholder="<?php echo _("Cerca") ?>..."/>
                        </div>
                    </div>
                    <!-- /.search form -->
                    
                    <!-- sidebar menu: : style can be found in sidebar.less -->
                    <ul class="sidebar-menu">
<?php
// Se l'utente è admin mostro tutti i moduli, altrimenti solo quelli con accesso in r o rw
$menus = $dbo->fetchArray("SELECT * FROM zz_modules WHERE parent='0' AND enabled='1' AND `type`='menu' ORDER BY `order` ASC");
$perm = $dbo->fetchRows("SELECT idmodule FROM zz_permessi WHERE idgruppo=(SELECT idgruppo FROM zz_utenti WHERE idutente='" . $_SESSION['idutente'] . "') AND (permessi='r' OR permessi='rw')");

if ($menus != null) {
	foreach ($menus as $menu) {
		echo sidebarMenu($menu, $perm, isset($module_name) ? $module_name : "")[0];
	}
}
echo '
?>
                    </ul>
                </section>
                <!-- /.sidebar -->
            </aside>

            <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="content-wrapper">         
                   
                <!-- Main content -->
                <section class="content">
                    <div class="row">';

if (strpos($_SERVER["SCRIPT_FILENAME"], "editor.php") !== false) $location = "editor_right";
else if (strpos($_SERVER["SCRIPT_FILENAME"], "controller.php") !== false) $location = "controller_right";

echo '
						<div class="col-md-12">';

for($i = 0; $i < sizeof($_SESSION["infos"]); $i ++) {
	echo '
							<div class="alert alert-success"><i class="fa fa-check"></i> ' . $_SESSION["infos"][$i] . '</div>';
}

for($i = 0; $i < sizeof($_SESSION["errors"]); $i ++) {
	echo '
							<div class="alert alert-danger"><i class="fa fa-times"></i> '. $_SESSION["errors"][$i] . '</div>';
}

for($i = 0; $i < sizeof($_SESSION["warnings"]); $i ++) {
	echo '
							<div class="alert alert-warning"><i class="fa fa-warning"></i> ' . $_SESSION["warnings"][$i] . '</div>';
}
?>