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

 echo $desig=$_GET['q'];

   	$sqlCate = "select * from  www_users  where parentid=0 and  companyid='".$_SESSION['ACGCompanyId']."' and department='".$department."' and designation='".$desig."' " ;?> 
		
<?php 	function CategoryUsers_Permission($pcode, $PcateID, $dashVal,$d,$desig)
	{
	    global $db;
		$dashVal = $dashVal . "-";
		$s=new db_query();

	       $sqlCate = "select * from www_users  where  parentid = '".$PcateID."' and  companyid='".$_SESSION['ACGCompanyId']."' and  department ='".$d."' and designation='".$desig."'";
	 
 		$rsCate  = DB_query($sqlCate,$db);	
		 
 		if(DB_num_rows($rsCate)>0)
		{
			while($rowCate = DB_fetch_array($rsCate))
			{
 				$px='';
				 if($rowCate['id']==$pcode)
				 $px="selected";
 		?>
 				<option value="<?php echo $rowCate['id'];?>" <?php echo $px ?>><?php echo $dashVal;?>
				 <?php echo  $rowCate['realname'] . " " ;	 ?> </option>
	   <?php			
				   CategoryUsers_Permission($pcode,$rowCate['id'], $dashVal,$d,$desig);
			}
		}
	}   ?>	
<select name="www_users" id="www_users"  multiple="multiple" style="height:200px; width:400px">
    <option value="0" <?php echo $pcode==0?'selected':''; ?> >Root</option>
  <?php 
	$dashVal = "---";
	$sqlCate = "select * from  www_users  where parentid=0 and  companyid='".$_SESSION['ACGCompanyId']."' and department='".$department."'  and designation='".$desig."' ";
	$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['id'];?>"<?php echo $px ?>> 
<?php echo   $rowCate['realname'] ; ?>
</option>
<?php	CategoryUsers_Permission($pcode, $rowCate['id'], $dashVal,$department,$desig);
		}
	}
?></select>
