 

<?php 

unset($_SESSION['listarr']);

 


//================================================
	function CategoryUsers_Show($pcode, $PcateID, $dashVal)
	{
	    global $db;
		$dashVal = $dashVal . "---";
		$s=new db_query();

   $sqlCate = "select * from deptmaster_hierarchy  where  parentid = '".$PcateID."' and  companyid='".$_SESSION['ACGCompanyId']."'";
 		$rsCate  = DB_query($sqlCate,$db);			 
 		if(DB_num_rows($rsCate)>0)
		{
			while($rowCate = DB_fetch_array($rsCate))
			{ 
			  
				if($rowCate['id']!='')
				{
				 $_SESSION['listarr'][]=$rowCate['id'];
 				$r= CategoryUsers_Show($pcode,$rowCate['id'], $dashVal);
				} 
			}
			
		}
		 
	}    
	
	if($_REQUEST['DASHBoardSearch']=='Go')
	{
	  $_SESSION['ACG_DashBoard_User']=$_REQUEST['dashboard_users'];
	}else{
	 $_SESSION['ACG_DashBoard_User']= $_SESSION['UserID'];
	}
?>
<form  action="" method="post">
<table width="30%" border="0" bgcolor="#e7e7e7">
  <tr>
    <td width="31%" style="padding-left:10px;">Search</td>
	<td width="53%"><?php //echo $Class_www_userst->Users('www_users','') 
 $listarr=array();;
 		 $pcode= $MainGroupId;?>
  <?php 
  
  $x= $s->GetFieldValue('www_users'," id='".$_SESSION['UserID'] ."' " ,'mst_dpt_heirarchy');
  
 	$dashVal = "---";
  	$sqlCate = "select * from  deptmaster_hierarchy  where   parentid='".$x."' and companyid='".$_SESSION['ACGCompanyId']."'";
	$rsCate  = DB_query($sqlCate,$db);
	if(DB_num_rows($rsCate)>0)
	{ 
		while($rowCate =DB_fetch_array($rsCate))
		{
 			 $_SESSION['listarr'][]=$rowCate['id'];
 			$r=CategoryUsers_Show($pcode, $rowCate['id'], $dashVal);
		}
	}
	//echo "<pre>";
	$_SESSION['listarr']=array_unique($_SESSION['listarr']);
$a=implode("' , '",$_SESSION['listarr']);
$a="'".$a."'";
 	


// and
		 $pcode= $MainGroupId;
//*********************************************************************************************************************************
      $deptid=  $s->GetFieldValue('www_users'," id='".$_SESSION['UserID']."' " ,'mst_dpt_heirarchy');		 
 		
		$LowerDeptList=GETLowerDeptUser($_SESSION['UserID'],$deptid,$_SESSION['ACGCompanyId']);
		 
		 $lowerlist=  UserDeptList($LowerDeptList);
		 if(count($lowerlist)>0)
		$lowerlist=implode(",",$lowerlist).",".$_SESSION['UserID'];
		else
		$lowerlist="'".$_SESSION['UserID']."'";
		 
  		$EmpSql="SELECT * FROM www_users where CompanyId='".$_SESSION['ACGCompanyId']."' and id in(".$lowerlist.")";
	 ?>
 	<select name="dashboard_users" id="dashboard_users" style="width:107px;">	  

    	    		<option  value="0">-All--</option>
    		<?php 
    		
			$EmpRes=DB_query($EmpSql,$db);
			while($EmpRow=DB_fetch_array($EmpRes))
			{
				$px='';
				 if($EmpRow['id']== $_SESSION['ACG_DashBoard_User'] || $EmpRow['id']== $_SESSION['UserID'])
				 $px="selected";
			echo $dashVal;	
    		?>
			<option value="<?php echo $EmpRow['id']?>" <?php echo  $px ?>><?php echo strtoupper ($EmpRow['realname'])?></option>
			<?php }?>
			
	
	</select>
  
	
</td>
    <td width="16%"><input name="DASHBoardSearch" type="submit" value="Go" /></td>
  </tr>
</table>
</form>