| 
 id;
$groupName = fetchUserGroups($userid);
$query = "select leaddetails.leadid as id,leaddetails.lastname as name,leadgrouprelation.groupname as groupname, 'Leads     ' as Type from leaddetails inner join leadgrouprelation on leaddetails.leadid=leadgrouprelation.leadid inner join crmentity on crmentity.crmid = leaddetails.leadid where  crmentity.deleted=0  and leadgrouprelation.groupname is not null and leadgrouprelation.groupname='".$groupName."' union all select activity.activityid,activity.subject,activitygrouprelation.groupname,'Activities' as Type from activity inner join activitygrouprelation on activitygrouprelation.activityid=activity.activityid inner join crmentity on crmentity.crmid = activity.activityid where  crmentity.deleted=0 and activitygrouprelation.groupname is not null and groupname ='".$groupName."' union all select troubletickets.ticketid,troubletickets.title,ticketgrouprelation.groupname,'Tickets   ' as Type from troubletickets inner join ticketgrouprelation on ticketgrouprelation.ticketid=troubletickets.ticketid inner join crmentity on crmentity.crmid = troubletickets.ticketid and crmentity.deleted=0 and ticketgrouprelation.groupname is not null and ticketgrouprelation.groupname='".$groupName."'";
//$query = "select leaddetails.lastname,leadgrouprelation.groupname, 'Leads' as Type from leaddetails inner join leadgrouprelation on leaddetails.leadid=leadgrouprelation.leadid inner join crmentity on crmentity.crmid = leaddetails.leadid where  crmentity.deleted=0 union all select activity.subject,activitygrouprelation.groupname,'Activities' as Type from activity inner join activitygrouprelation on activitygrouprelation.activityid=activity.activityid inner join crmentity on crmentity.crmid = activity.activityid where  crmentity.deleted=0 union all select troubletickets.ticketid,troubletickets.groupname,'Tickets' as Type from troubletickets inner join seticketsrel on seticketsrel.ticketid = troubletickets.ticketid inner join crmentity on crmentity.crmid = seticketsrel.ticketid where troubletickets.groupname is not null and crmentity.deleted=0";
  $log->info("Here is the where clause for the list view: $query");
	$result = $adb->limitquery($query,0,5) or die("Couldn't get the group listing");
echo get_form_header($app_strings['LBL_GROUP_ALLOCATION_TITLE'], "", false);
$list = '
 ';
echo $list;
function getActivityType($id)
{
	global $adb;
	$quer = "select activitytype from activity where activityid=".$id;
	$res = $adb->query($quer);
	$acti_type = $adb->query_result($res,0,"activitytype");
	return $acti_type;
}
echo '';
$list .= '';
$list .= ' ';
$i=1;
while($row = $adb->fetch_array($result))
{
  if ($i%2==0)
    $trowclass = 'evenListRow';
  else
    $trowclass = 'oddListRow';
  $list .= '| ';
$list .= ' | ';
$list .= $app_strings['LBL_ENTITY_NAME'].'';
$list .= ' | ';
$list .= ' | ';
$list .= $app_strings['LBL_GROUP_NAME'].'';
$list .= ' | ';
$list .= ' | ';
$list .= $app_strings['LBL_ENTITY_TYPE'].'';
$list .= ' |  |  ';
  $list .= '';
  $i++;
}
        $list .= '| ';
  if($row["type"] == "Tickets")
  {
    $list .= ' | ';
  $list .= ' | ';
  $list .= $row["groupname"];
  $list .= '';
  $list .= ' | ';
  $list .= ' | ';
  $list .= $row["type"];
  $list .= '';
  $list .= ' |  |  | 
 ';
$list='';
if($tab_per_Data[13] == 0)
{
        if($permissionData[13][3] == 0)
        {
		require_once('modules/HelpDesk/ListTickets.php');
	}
}
echo '
 
 ';
include("modules/CustomView/ListViewTop.php");
echo '
 ';
if($tab_per_Data[20] == 0)
{
        if($permissionData[20][3] == 0)
        {
		require_once('modules/Quotes/ListTopQuotes.php');
	}
}
echo '
 ';
if($tab_per_Data[22] == 0)
{
        if($permissionData[22][3] == 0)
        {
		require_once('modules/Orders/ListTopSalesOrder.php');
	}
}
echo '
 ';
if($tab_per_Data[23] == 0)
{
        if($permissionData[23][3] == 0)
        {
		require_once('modules/Invoice/ListTopInvoice.php');
	}
}
global $current_language;
$current_module_strings = return_module_language($current_language, 'Calendar');
$t=Date("Ymd");
?>
 |  |