<? ini_set("display_errors",0);session_start();
ini_set("display_errors",0);

if($_SESSION[user]=='') {
	header("location: login.php");
}else{
	include("comun/conexion3.php");
	include("comun/conex_ver.php");
	include("comun/funciones.php");
	
$link_impo= con_impo();	
$link = con_ver();
	$rDat = data($link_impo,"select U.tipoe,U.id,U.nombre as nom,U.rol,U.perfil,A.area,U.email,U.gafete   from usuarioslpv U,areaslpv A where U.usuario = '".$_SESSION[user]."' and U.tipoe=A.abreviatura");
 
	$_SESSION[area] = $rDat[tipoe];
	$_SESSION[idusuario] = $rDat[id];
	$_SESSION[area_long] = $rDat[area];
	$_SESSION[rol] = $rDat[rol]; // admin o ejecutivo
	$_SESSION[tipo] = $rDat[tipoe]; // comercial expo o impo
	$_SESSION[perfil] = $rDat[perfil]; // superadmin consulta general o personalizado
    $_SESSION[email] = $rDat[email];
 $_SESSION["gafete"]=$rDat[gafete];
 
	$tipo = $rDat[tipoe];
	$nombre = $rDat[nom];
	$rol = $rDat[rol];
	
	$_SESSION[nombre_usuario] = $nombre;
	
	//echo $_SESSION[idusuario].' 1';
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
	<!--[if IE 7]>
	<link rel="stylesheet" type="text/css" href="style-ie.css" />
	<![endif]-->
<!-- estilos para popup-->
 <!--<link rel="stylesheet" type="text/css" media="screen" title="basic" href="css/basic/grid.css" />

 <link rel="alternate stylesheet" type="text/css" href="css/basic/grid.css" title="coffee" media="screen" />

 <link rel="stylesheet" type="text/css" media="screen" href="css/jqModal.css" />

 <link rel="stylesheet" type="text/css" media="screen" href="css/ui.datepicker.css" />-->

<!-- estilos para popup-->
    
<title>ALTAMIRA</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/validator.js"></script>
<script type="text/javascript" src="js/funciones.js"></script>
<script type="text/javascript" src="js/autocomplete/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="js/autocomplete/jquery.autocomplete.css" media="all" />
<script src="js/windowfiles/dhtmlwindow.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="js/windowfiles/dhtmlwindow.css" media="all" />
<SCRIPT type="text/javascript" src="../../../js/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<link type="text/css" rel="stylesheet" href="../../../js/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" media="screen"></LINK>

<script type="text/javascript">
/*var theObj="";
function toolTip(text,me) {
       theObj=me;
       theObj.onmousemove=updatePos;
       document.getElementById('toolTipBox').innerHTML=text;
       document.getElementById('toolTipBox').style.display="block";
       window.onscroll=updatePos;
}
function updatePos() {
       var ev=arguments[0]?arguments[0]:event;
       var x=ev.clientX;
       var y=ev.clientY;
       diffX=24;
       diffY=0;
       document.getElementById('toolTipBox').style.top  = y-2+diffY+document.body.scrollTop+ "px";
       document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";
       theObj.onmouseout=hideMe;
}
function hideMe() {
       document.getElementById('toolTipBox').style.display="none";
}*/
</script>

</head>

<body>

 <style>
 	tr.yellow td {
	border-top: 1px solid #333;
	border-bottom: 1px solid #333;
	background: #FFC;
	font-weight:bold;  
	}
	
	tr.comun td {
	border-top: 1px solid #333;
	border-bottom: 1px solid #333;
	border-right: 1px solid #333;
	border-left: 1px solid #333;
	text-align:center;
	
	/*background: #FFC;*/
	}
	
	table.tablas_con_bordes{
		border:1PX solid #333; border-collapse:collapse
	}
	</style>
<div id="header">
<div id="social">Bienvenido usuario: <?=strtoupper($_SESSION[user])?><br>
 <?=$nombre?><br /> Area: <?=$_SESSION[area_long]?> Rol: <?=$_SESSION[rol]?>
</div>
</div>

<?  
$query=mysqli_query($link,"select * from menu where (tipoe = '$tipo' or tipoe='All') and (rol = 'All' or rol = '$rol') and visible=1 order by posicion");

?>

<ul class="dropdown"><!-- menu -->
<? while ($r=mysqli_fetch_array($query)){
	
	 
	?>
<li>

                <a <? if($r[programa]!='#' or $r[titulo]=='Salir'){?>href="<?="https://".$_SERVER["SERVER_NAME"]?>/ATM/<?=$r[programa]?>" <? } ?> ><?=utf8_encode($r[titulo])?></a>
 

        <? $queryS=mysqli_query($link,"select * from submenu where idmenu = '".$r[id]."' and (tipoe = '$tipo' or tipoe='All' ) and (rol = 'All' or rol = '$rol') and visible=1 order by posicion");
        //echo "select * from submenu where idmenu = '".$r[id]."' and (tipo = '$tipo' or tipo='All' or tipo like '%$tipo%') and (rol = 'All' or rol = '$rol')  order by posicion";
        if(mysqli_num_rows($queryS)>0){
        ?>
        <ul >
                <? while($rS=mysqli_fetch_array($queryS)){?>
                <li><a href="<?="https://".$_SERVER["SERVER_NAME"]?>/ATM/<?=$rS[programa]?>"><?=utf8_encode($rS[titulo])?></a>
                
                             <? $querySub=mysqli_query($link,"select * from sub_submenu where idmenu = '".$rS[id]."' and visible=1 order by titulo");
                    
                            if(mysqli_num_rows($querySub)>0){
                            ?>
                            <ul><!-- class="sub_menu"-->
                              <? while($rSub=mysqli_fetch_array($querySub)){?>
                                <li><a href="<?="https://".$_SERVER["SERVER_NAME"]?>/ATM/<?=$rSub[programa]?>"><?=$rSub[titulo]?></a></li>
                              <? } ?>  
                            </ul>
                            <? } ?>
                
                </li>
                <? } ?>
        </ul>
        <? } ?>
</li>
<? } ?>

</ul><!-- close menu -->