<?php
function F_Programa()
{	include "seguridad.php" ;
	$sql_contar=mysqli_query($conseg,"select Id from programa where nombre = 'SAGA'");
	 while($datos= mysqli_fetch_row($sql_contar)){  $vl_programa=$datos[0]; } 
	return $vl_programa;
}

function validar_permiso($vg_login,$modulo,$vg_perfil,$vg_programa)
{ include "seguridad.php" ;
    $sql_codfor=mysqli_query($conseg,"SELECT codigo FROM modulo where nombre='".trim($modulo)."'");
	 while($datos= mysqli_fetch_row($sql_codfor)){ $vr_codfor=$datos[0]; } 

      $sql_contar=mysqli_query($conseg,"SELECT count(*) as cantidad FROM modulo_perfil
 					           where programa=".$vg_programa."  and perfil=".$vg_perfil." and modulo=".$vr_codfor." and sn='S'");
	   while($datos= mysqli_fetch_row($sql_contar)){ $vr_contar=$datos[0]; } 
			  if($vr_contar>=1)
			     { $permiso[0]=1;
				   
				   $sql_contar=mysqli_query($conseg,"SELECT count(*) as cantidad FROM perfil_boton
									 		   where perfil=".$vg_perfil." and formulario=".$vr_codfor." and sn='S'");
	   			   while($datos= mysqli_fetch_row($sql_contar)){ $vr_contar1=$datos[0]; } 
						   $permiso[1]=$vr_contar1;
						   if($vr_contar1>=1)
						      {
							   $sql_datbot=mysqli_query($conseg, "SELECT boton.nombre FROM perfil_boton,boton
									                    where perfil=".$vg_perfil." and formulario=".$vr_codfor." and sn='S'
											            and perfil_boton.boton=boton.codigo");
									$cp=2;
									while($dato= mysqli_fetch_row($sql_datbot))//01
											 { $vr_nombot=$dato[0];
											   $vr_nombot;
											   $permiso[$cp]=$vr_nombot;
											   $cp=$cp+1;											 
											 }
							  }
						   else	  
						     {$permiso[1]=0;}
				 }
			  else
			     {
				   $permiso[0]=0;
				   $permiso[1]=0;
				 } 	 

 return $permiso;
}

?>