<?php
$PageSecurity = 11;
 //echo $_SERVER['QUERY_STRING'];exit;
 include('includes/SQL_CommonFunctions.inc');
 include('includes/function_lib.php');
 include('includes/session.inc');
 global $db;
  $department=$_GET['department'];

   $desig=$_GET['q'];
function CategoryShow($pcode, $PcateID, $dashVal,$department,$desig) 
{
global $db;
$dashVal=$dashVal . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 $sqlCate="select * from securityroles  where  rolepid  = '".$PcateID."' and  CompanyId='".$_SESSION['ACGCompanyId']."' and  department='".$department."'  ";
$rsCate=DB_query($sqlCate,$db);	

if(DB_num_rows($rsCate)>0)
{
while($rowCate = DB_fetch_array($rsCate))
{
 $px='';
 if($rowCate['secroleid']==$pcode)
 $px="selected";
?>
<option value="<?php echo $rowCate['secroleid'];?>" <?php echo $px ?>><?php echo $dashVal;?>
 <?php echo "-".$rowCate['role_name'];?> </option>
<?php			
   CategoryShow($pcode,$rowCate['secroleid'], $dashVal,$department,$desig);
}
}
} 



 ?><select name="rolepid" id="rolepid"  multiple="multiple" style="height:200px; width:400px">
    <option value="0" <?php echo $pcode==0?'selected':''; ?> >Root</option>
  <?php 
	$dashVal = "&nbsp;&nbsp;&nbsp;";
	$sqlCate = "select * from  securityroles   where rolepid=0 and CompanyId='".$_SESSION['ACGCompanyId']."' and department='".$department."'   ";
	$rsCate  = DB_query($sqlCate,$db);
	if(DB_num_rows($rsCate)>0)
	{
		while($rowCate =DB_fetch_array($rsCate))
		{
 				 
				$px='';
				 if($rowCate['id']==$pcode)
				 $px="selected";
			    echo $dashVal;	
		  ?>
		<option value="<?php echo  $rowCate['secroleid'];?>"<?php echo $px ?>> 
		<?php echo   $rowCate['secrolename'] . "  " ;
		     // echo $s->GetFieldValue('deptmaster_hierarchy'," id='". $rowCate['rolepid']."' and CompanyId='".$companyid."'" ,'deptname')." )";?></option>
 		<?php			
			CategoryShow($rolepid, $row['secroleid'], $dashVal,$department,$desig);
 		}
	}
?></select>
