<?php 
error_reporting(0);
$_SESSION['ACGloweruser']=array();
function getupperuser($uid,$company_id)
{
	global $db;
	$s=new db_query();
	
        $x= $s->GetFieldValue('www_users'," id='".$uid ."' " ,'mst_dpt_heirarchy');
	     $x1= $s->GetFieldValue('www_users'," id='".$uid ."' " ,'assigned_sites');

  	 $sql="Select id, mst_dpt_heirarchy from www_users where id='".$uid."' and  mst_dpt_heirarchy='".$x."' and companyid='".$company_id."'";
	$result=DB_query($sql,$db);
	while($row=DB_fetch_array($result))
	{		
	$_SESSION['ACGloweruser'][]=$row['id'];	
	if($row['mst_dep_heirarchy']=='0')
	{
	
	}
	else
	{		
		getdepthir($row['mst_dpt_heirarchy'],$_SESSION['ACGCompanyId']);
	}
	}
	


//print_r($_SESSION['ACGloweruser']);
	return($_SESSION['ACGUnderusers']);
}
function getdepthir($dir,$dir1)
{
global $db;
	$s=new db_query();
	 $sql="Select id from deptmaster_hierarchy where parentid='".$dir."'  and companyid='".$dir1."'";
	$result=DB_query($sql,$db);
	while($row=DB_fetch_array($result))
	{
	$_SESSION['ACGloweruser'][]=$row['id'];		
	getdepthir($row['id'],$_SESSION['ACGCompanyId']);
	}
	
}




?>