<?php $PageSecurity = 11; 
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
       $q = $_GET['q']; 
	//echo $q;
	 $pcode= $rolepid;
		function CategoryShow($pcode, $PcateID, $dashVal)
		{
			global $db;
			$dashVal = $dashVal . "&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";
			?>
					<option value="<?php echo $rowCate['secroleid'];?>" <?php echo $px ?>><?php echo $dashVal;?>
					 <?php echo $rowCate['role_name'];?> </option>
		   <?php			
					   CategoryShow( $pcode,$rowCate['secroleid'], $dashVal);
				}
			}
		} 
		
		$dashVal = "&nbsp;&nbsp;&nbsp;";
?><!--onclick="Function_ajax(this.value,'txtfiles','ViewProfile.php',document.getElementById('hidcompanyid').value)"-->
	<input name="hidcompanyid"  id='hidcompanyid' type="hidden" value="<?php echo $q;?>" />
 		<select name="rolepid" multiple="multiple" id="rolepid" style="width:200px; height:200px">
		<option value="0">Primary</option>
 		<?php
		  $query=DB_query("select * from securityroles where rolepid=0 and companyid  ='".$q."'",$db);
		  while($row=DB_fetch_array($query))
		  {		  
		  	$p='';
			if($row['secroleid']==$rolepid)
			{
			   $p="selected";
			}
		 ?>
		<option value="<?php echo $row['secroleid'] ?>" <?php echo $p; ?>><?php echo $row['role_name'] ?></option>
		<?php 
		   CategoryShow($rolepid, $row['secroleid'], $dashVal);
		} ?>
		</select>