<?php   
//echo $_SESSION['UserID']."<br>";
//echo $_SESSION['ACGRoleId']."<br>";
global $db;
// Chk Module Permission 

$_permCacheKey = $_SESSION['UserID'].'|'.$_SESSION['ACGRoleId'];
if (isset($_SESSION['ACG_PERMISSION_CACHE_KEY']) && $_SESSION['ACG_PERMISSION_CACHE_KEY'] === $_permCacheKey
    && isset($_SESSION['ACG_ModulePermission']) && isset($_SESSION['ACG_FRMPermission'])) {
    return;
}

$empSql=DB_query("select id from empmaster where mst_www_userid='".$_SESSION['UserID']."' limit 1",$db);
$empRow=DB_fetch_array($empSql);
$_SESSION['empcode']= $empRow['id'];
$_SESSION['mst_www_userid']= $empRow['id'];
$query="select modules_allowed from securityroles where secroleid='".$_SESSION['ACGRoleId']."' and rolestatus='Y' ";
//echo "<br>".$query."<br>";
$chk_permission_query=DB_query($query,$db);
$row=DB_fetch_array($chk_permission_query);

  $Permission_module=$row['modules_allowed'];
if(trim($Permission_module)!=''){
$_SESSION['ACG_ModulePermission']=explode(",",$Permission_module);
$TG="'".implode("','",$_SESSION['ACG_ModulePermission'])."'";
}
else{
$_SESSION['ACG_ModulePermission']=$Permission_module;
$TG="'".$_SESSION['ACG_ModulePermission']."'";
}



//$TG="'".implode("','",$_SESSION['ACG_ModulePermission'])."'";
 //echo "<br>";print_r($_SESSION['ACG_ModulePermission']);

//echo $q=explode(",",$_SESSION['UserSites']);
//
//
//if($_SESSION['UserSites']!='0'){
//$_SESSION['AssignedSites']=implode(",",$q);
//}
//else
//{
//$_SESSION['AssignedSites']=$_SESSION['UserSites'];
//}
//echo $_SESSION['AssignedSites'];



$ACG_FRMPermission=array();
$getfrmpermission="select frm_moduleid from company_profile where moduleid in( $TG ) and roll_id='".$_SESSION['ACGRoleId']."' ";  
 
$chk_frm_permission=DB_query($getfrmpermission,$db);
  while($rowfrm_permission=DB_fetch_array($chk_frm_permission))
 {
	$ACG_FRMPermission[]=$rowfrm_permission['frm_moduleid'];
	
 } 
 if(count($ACG_FRMPermission)>0)
 {
   $_SESSION['ACG_FRMPermission']=implode("','",$ACG_FRMPermission);
  }
 else
 {
   $_SESSION['ACG_FRMPermission']='';
  }
$_SESSION['ACG_PERMISSION_CACHE_KEY'] = $_permCacheKey;

 
//echo  $_SESSION['ACG_Dashboard_Assign'];
//echo $_SESSION['AssignedSites'];









 
 
?>
