<?php   
$table='securityroles';
		$pcode= $rolepid;
		function CategoryShow($companyid, $PcateID, $dashVal)
		{
			global $db;
			$dashVal = $dashVal . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			    $s=new db_query();
   		 $rurl="&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid'];

		  	$sqlCate = "select * from deptmaster_hierarchy  where  parentid  = '".$PcateID."' and companyid='".$companyid."'";
		 
			$rsCate  = DB_query($sqlCate,$db);	
 			if(DB_num_rows($rsCate)>0)
			{
				while($rowCate = DB_fetch_array($rsCate))
				{
  					 echo '<tr><td><b>'.$dashVal.'<img src="css/professional/images/user.png" border="0" align="absmiddle" style="cursor:pointer;">&nbsp;'.$rowCate['deptname'];
					  
					 echo  '</b>'.$dashVal.'<br>';
				 
 				 
					 
					  $k=1;
					 $Quser=DB_query("select * from www_users where mst_dpt_heirarchy ='".$rowCate['id']."'  and CompanyId='".$_SESSION['ACGCompanyId']."' order by  assigned_sites",$db);
					  while($Rusers=DB_fetch_array($Quser))
					  {
					  
					  		echo $dashVal. $Rusers['id']."  )  ".$Rusers['realname'].'('.$Rusers['userid'].')'.'&nbsp; 
							<a href="index.php?route=Setup/CompanyUsers&action=Edit&Id='.$Rusers['id'].$rurl.'" target="_blank"><img src="images/editfield.gif" /></a>
							&nbsp;&nbsp;							
							<img src="images/delete.gif" border="0" align="absmiddle" style="cursor:pointer;">';
							echo $Rusers['assigned_sites'];
							echo '<br>';
					  
					  }
				    echo ' </td></tr>'; 
					  CategoryShow($companyid,$rowCate['id'], $dashVal);
				}
			}
		} 
		
	 
		
		$dashVal = "&nbsp;&nbsp;&nbsp;";		
		?>
 


<link href="css/pagnation.css" rel="stylesheet" type="text/css">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>

<table width="70%" border="0" cellspacing="0" cellpadding="0" align="left">
   <tr>
    <td colspan="2"><h2>Dept User <strong>Hierarchy&nbsp;</strong> </h2></td>
	<td>
	<div align="right"> <a href="index.php?route=Setup/NDepartmentHierarchy&Application=<?php echo $_REQUEST['Application']?>&modid=<?php echo $_REQUEST['modid']?>">Add/Edit   </a></div>
	</td>
   </tr>
<tr><td colspan="3" >
<form action="" method="post" >
		<table width="100%" border="1" cellspacing="0" cellpadding="0">
 		<tr>
		<td colspan="2"> 
		
 		<?php 
		 "select * from companies where CompanyId='".$_SESSION['ACGCompanyId']."'";
		  $query=DB_query("select * from companies where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
		  while($row=DB_fetch_array($query))
		  {
 		    echo "<font face='Arial, Helvetica, sans-serif' size='+1'>".$row['CompanyName'].'</font><br>' ;
			$dashVal = "&nbsp;&nbsp;&nbsp;";
			?>
			<table width="100%" border="0" cellspacing="3" cellpadding="3">
 			<?php 
			
			 
			
			// echo "select * from deptmaster_hierarchy where parentid=0 and companyid='".$row['CompanyId']."'";
			 $query_comprole=DB_query("select * from deptmaster_hierarchy where parentid=0 and companyid='".$row['CompanyId']."'",$db);
 			  while($row_comprole=DB_fetch_array($query_comprole))
			  {
			  	 echo '<tr><td><img src="css/professional/images/menu_root.gif" border="0" align="absmiddle" style="cursor:pointer;"><b><font face="Arial, Helvetica, sans-serif">'.$row_comprole['deptname'].'</font> &nbsp;&nbsp; <br> ';
				  // echo $s->GetFieldValue('www_users',"mst_dpt_heirarchy='".$row_comprole['id']."'",'realname');
				  	 $k=1;
					 $Quser=DB_query("select * from www_users where mst_dpt_heirarchy ='".$row_comprole['id']."'  and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
					  while($Rusers=DB_fetch_array($Quser))
					  {
					  
					  		echo ' &nbsp;&nbsp; &nbsp;&nbsp;'.$k++."  )  ".$Rusers['realname'].'<br>';
					  
					  }
				      
				 echo '  </b></td></tr>';
  			  	  CategoryShow($row['CompanyId'], $row_comprole['id'], $dashVal);
				  
 			  }	
 		 ?>
		 </table>
		<?php echo "<br>";} ?>
		 	 </td>
		</tr>
		</table>
</form>
</td>
</tr>
</table>
 </td>
</table>
