<?php
$PageSecurity = 11;
//echo $_SERVER['QUERY_STRING'];exit;
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
include('includes/Class_www_users.php');
include('includes/Class_Emp.php');
include('includes/session.inc');
	 $q=$_GET['q']; 
	 
		 $pcode= $rolepid;
		
		function CategoryShow1($pcode, $PcateID, $dashVal)
		{
		   $data12='';
		    $data14='';
		   $v='';
		   
			global $db;
			 $dashVal = $dashVal . "&nbsp;&nbsp;&nbsp;&nbsp;";
			    $sqlCate = "select * from securityroles  where  rolepid  = '".$PcateID."'";
			$rsCate  = DB_query($sqlCate,$db);	
			 
			if(DB_num_rows($rsCate)>0)
			{
				while($rowCate = DB_fetch_array($rsCate))
				{
					  $sqlCateSel = "select * from securityroles where rolepid =".$rowCate['rolepid']." ";
					$rsCateSel	= DB_query($sqlCateSel,$db);
					$px='';
					 if($rowCate['secroleid']==$pcode)
					 $px="selected";			
				     $data12.="<option value=".$rowCate['secroleid'].">".$dashVal.".".$rowCate['role_name']."</option>";
				      $data12.=CategoryShow1($pcode,$rowCate['secroleid'], $dashVal);					 
				} 
				
				return  $data12;	
			}
			
		 	
		} 
		
		$dashVal = "&nbsp;&nbsp;&nbsp;";
		 $data1='';
		$data9='';
		$query=DB_query("select * from securityroles where rolepid=0 and companyid ='".$q."'",$db);
		?> 
            <?php
			
			$data2='';
			$data3='';
		
		if(DB_num_rows($query)>0)
		{
		
		  $data1="<option value='0'>Primary</option>";
		  while($row=DB_fetch_array($query))
		  {		  
		  	$p='';
			if($row['secroleid']==$rolepid)
			{
			   $p="selected";
			}
		 
           $data1.="<option value=".$row['secroleid']." ".$p." >".$row['role_name']."</option>";            
		    $data1.= CategoryShow1($rolepid,$row['secroleid'], $dashVal);
		}
		
		} 
		else
		{
		 $data1="<option value='0'>Primary</option>";
		}
		$sql=DB_query("select * from companies where CompanyId='".$q."'",$db);
		$row1=DB_fetch_array($sql);
		$moduleallowed=$row1['modules_allowed'];
		$moduledata1=explode(",",$moduleallowed);
				
		
		  $data2.="<option value=''>Select</option>";
          for($i=0;$i<count($moduledata1);$i++)
		  {
		  $data2.="<option value=".$moduledata1[$i]." ".($module==$moduledata1[$i]?'selected':'').">".$s->getField('modules','id',$moduledata1[$i],'modulename')."</option>";
		
	     } 
		 
		
	 
	 
	    echo $data=$data1."__".$data2; 
	
	 
	 ?>
	
	
	
	
		
		
		
		
		
		
		
		
		
		
       
		