<?php
function GEN_MENU($MNU_USU_ID){
	$M="<div id='header'>
		<ul class='nav'>
		<li >
			<a href='menu.php'>
			<div style='width:100px; '> 
				<marquee loop='1' behavior='alternate' scrollamount='12'>
				<b>GESTION</b>
				</marquee>
			</div>
			</a>
    	</li>" ;
	 //
	 if($MNU_USU_ID==0){
        $s="SELECT id_menu,nombre FROM menu 
			GROUP BY id_menu,nombre                
            ORDER BY col,ord";
        $rs = grs($s);
        while ($r =$rs->fetch_assoc()){
			$MID=$r['id_menu'];
            $MNU=$r['nombre'];
			$M=$M."<li><a href=''>".$MNU."</a><ul>";
			$z="SELECT sm,url FROM menus
                WHERE id_menu='$MID'
				GROUP BY sm,url 
				ORDER BY orden";
			$rz = grs($z);
            while ($f =$rz->fetch_assoc()){
                $SM=$f['sm'];
                $UR=$f['url'];
				//
				$M=$M."<li>";
                $M=$M."<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
                $M=$M."<tr>";                       
                $M=$M."<td style='padding: 0px 0px'><a href='".$UR."' style='padding-top:5px; padding-bottom:5px' target='_blank'><img src='run23.png'></a></td>";
                $M=$M."<td style='width:300px;padding: 0px 0px'><a href='".$UR."' >".$SM."</a></td>";
                $M=$M."</tr>";
                $M=$M."</table>";
                $M=$M."</li>";				
			}
			$M=$M."</ul>";
           	$M=$M."</li>";
		}
	 }else{
		  $s="SELECT ME FROM vusu_men
			  WHERE IDU=$MNU_USU_ID AND VA>0
			  GROUP BY ME
			  ORDER BY ME";			
			$rs = grs($s);
			while ($r = $rs->fetch_assoc()){
				$MNU=$r['ME'];
				$M=$M."<li><a href=''>".$MNU."</a><ul>";
				//
				$z="SELECT SM,UR FROM vusu_men 
					WHERE ME='$MNU' AND IDU=$MNU_USU_ID AND VA>0
					ORDER BY SO ";
				$rz = grs($z);
				while ($f = $rz->fetch_assoc()){
					$SM=$f['SM'];
					$UR=$f['UR'];
					//
					$M=$M."<li>";
					$M=$M."<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
					$M=$M."<tr>";                      
					$M=$M."<td style='padding: 0px 0px'><a href='".$UR."' style='padding-top:5px; padding-bottom:5px' target='_blank'><img src='run23.png'></a></td>";
					$M=$M."<td style='width:300px;padding: 0px 0px'><a href='".$UR."' >".$SM."</a></td>";
					$M=$M."</tr>";
					$M=$M."</table>";
					$M=$M."</li>";					
				}
				$M=$M."</ul>";
           		$M=$M."</li>"; 
			}
	 }
	 //
	$M=$M."<li style='padding-top:0px; padding-bottom:0px'>";
	$M=$M."<a href='cerrar.php' style='padding-top:7px; padding-bottom:7px'>";
	$M=$M."<img src='exit.png' style='width:20px; height:20px'  title='SALIR'>";
	$M=$M."</a>";
	$M=$M."</li>";			
	$M=$M."</ul>";
	$M=$M."</div>";
	//
	return $M;		
}
?>

