<?php
$PageSecurity = 11;
 include('includes/function_lib.php');
 include('includes/session.inc');
 if(($_REQUEST['emp']!="") && ($_REQUEST['type']=="dept"))
 {
 $sql=DB_query("Select empid,id from www_users where mst_dpt_heirarchy=".$_REQUEST['emp']." and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
 $data='<select name="employee" id="employee" >';
 $data.='<option value="">--Select--</option>';
 while($row=DB_fetch_array($sql))
 {
     $emp=DB_fetch_assoc(DB_query("Select * from empmaster where id=".$row['empid']." and CompanyId='".$_SESSION['ACGCompanyId']."'",$db));
     
 	$data.='<option value="'.$emp['id'].'" >'.$emp['emp_name'].'</option>';
 }
 $data.='</select>';
 echo $data;
 }
 
 if(($_REQUEST['team']!="") && ($_REQUEST['dept']!=""))
 {
     
         $emp=DB_query("SELECT b.id FROM www_users a , empmaster b WHERE a.mst_dpt_heirarchy='".$_REQUEST['dept']."' AND b.id=a.empid",$db);
     while($empres1=DB_fetch_assoc($emp)){
         $empres[$empres1['id']]=$empres1;
     }
    // echo "<pre>";
    // var_dump($empres);
    // print_r($empres);
  $data='<select name="employee" id="employee" >';
 $data.='<option value="">--Select--</option>';
 $sql=DB_query("Select b.empid from perf_team_master a ,perf_team_master_details b where a.id=b.masterid and  a.id='".$_REQUEST['team']."'",$db);
 while($row=DB_fetch_array($sql))
 {
        if(array_key_exists($row['empid'],$empres))
        {
           $emp=DB_fetch_assoc(DB_query("Select * from empmaster where id=".$row['empid']." and CompanyId='".$_SESSION['ACGCompanyId']."'",$db));
     
 	$data.='<option value="'.$emp['id'].'" >'.$emp['emp_name'].'</option>';
        }
    }
 
 $data.='</select>';
 echo $data;
 }
 
 if(($_REQUEST['team']!="") && ($_REQUEST['dept']==""))
 {
        
  $data='<select name="employee" id="employee" >';
 $data.='<option value="">--Select--</option>';
 $sql=DB_query("Select b.empid from perf_team_master a ,perf_team_master_details b where a.id=b.masterid and  a.id='".$_REQUEST['team']."'",$db);
 while($row=DB_fetch_array($sql))
 {
        
           $emp=DB_fetch_assoc(DB_query("Select * from empmaster where id=".$row['empid']." and CompanyId='".$_SESSION['ACGCompanyId']."'",$db));
     
 	$data.='<option value="'.$emp['id'].'" >'.$emp['emp_name'].'</option>';
        
    }
 
 $data.='</select>';
 echo $data;
      
 }
 
 
 ?>