<?php $PageSecurity = 2;
include('includes/DefineSuppTransClass.php');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');

$data1='';
$data2='';
$data3='';
$arrayItem=explode(",",$_REQUEST['q']);
$newString=implode("','",$arrayItem);
//echo "SELECT id , realname FROM  www_users where rolepid in ('".$newString."')";
$item_sql=DB_query("SELECT id, realname, department, designation FROM  www_users where rolepid in ('".$newString."')",$db);

if(!$item_sql)
{
die('Error.'.DB_error_msg($db));
}
$deptArray=array();
$desigArray=array();
$data1.="<div style='width:auto;'>";
while($row=DB_fetch_array($item_sql))
{
$deptArray[]=$row['department'];
$desigArray[]=$row['designation'];
$data1.="<input name='userid[]' type='checkbox' value='".$row['id']."' />".$row['realname']."<br />";
} 
 	 $data1.="</div>";
   	
	  foreach($deptArray as $depat)
	  {
	  	if($depat!="0")
	  	{
			$dept_sql=DB_query("SELECT deptname FROM  deptmaster where id ='".$depat."'",$db);
			$row_dept=DB_fetch_array($dept_sql);
			$data2.=$row_dept['deptname']."<br/>";
		}
	  }
	  
	   foreach($desigArray as $desig)
	  {
	  	if($desig!="0")
	  	{
			$desig_sql=DB_query("SELECT designame FROM desigmaster WHERE id ='".$desig."'",$db);
			$row_desig=DB_fetch_array($desig_sql);
			$data3.=$row_desig['designame']."<br/>";
		}
	  }
 
 echo $data=$data1."__".$data2."__".$data3;
 