$group) { if($group['clienttypegroupid'] === '0') { $other = $group; unset($groups[$key]); } } $groups[] = $other; $count = 0; foreach($groups as $key => $group) { if($clienttypegroupid) if($group['clienttypegroupid'] == $clienttypegroupid) $active = $count; if($group['clienttypegroupcontacttypeonly'] == '0') { $sql = "select *, (select count(*) from tblclient where clienttypeid = tblclienttype.clienttypeid "; if(($_SERVER['PHP_SELF']=='/client.php' || $_SERVER['PHP_SELF']=='/contacts.php') && !has_access('viewallcompanycontacts')) $sql.=" and clientcreatedby = ".loginid()." "; if(($_SERVER['PHP_SELF']=='/client.php' || $_SERVER['PHP_SELF']=='/contacts.php') && has_access('viewallcompanycontacts') && officelocationid()) $sql.=" and clientcreatedby in ( select loginid from tblstaff join tbllogin using(staffid) where companyid=".companyid()." and officelocationid=".officelocationid()." )"; $sql.=" and (companyid = " . companyid() . ") and clientinactive is null) as clientcount from tblclienttype where clienttypegroupid = " . $group['clienttypegroupid'] . " and (companyid = " . companyid() . " or companyid = 0) order by clienttypename"; $clienttypes = db_query($sql,'','','clienttypeid'); $groups[$key]['clienttypes'] = $clienttypes; if(is_array($clienttypes)) if(array_key_exists($clienttypeid,$clienttypes)) $active = $count; } else if($group['clienttypegroupcontacttypeonly'] == '1') { $sql = "select *, (select count(*) from tblcontact_contacttype join ( select * from tblcontact where contactinactive is null and ( clientid > -1 or clientid is null) ) as tblcontact using (contactid) where contacttypeid = tblcontacttype.contacttypeid "; if($_SERVER['PHP_SELF']=='/contacts.php' && !has_access('viewallcompanycontacts')) $sql.=" and contactcreatedby = ".loginid()." "; if($_SERVER['PHP_SELF']=='/contacts.php' && has_access('viewallcompanycontacts') && officelocationid()) $sql .= " and contactcreatedby in ( select loginid from tblstaff join tbllogin using(staffid) where companyid=".companyid()." and officelocationid=".officelocationid()." )"; $sql.=" and (companyid = " . companyid() . ") --or companyid = 0) ) as contactcount from tblcontacttype where clienttypegroupid = " . $group['clienttypegroupid'] . " and (companyid = " . companyid() . " or companyid = 0) order by contacttypename"; $contacttypes = db_query($sql,'','','contacttypeid'); $groups[$key]['contacttypes'] = $contacttypes; if(array_key_exists($contacttypeid,$contacttypes)) $active = $count; } if($group['clienttypegroupdefaultclienttype']) $groups[$key]['clienttypes'][] = array(clienttypename=>'Unset Company Type', clienttypeid=>0); $count++; } $sql = "select * from tblassetmanager left join tblclient using(clientid) where assetmanagerinactive is null and tblassetmanager.companyid = ".companyid(); if(($_SERVER['PHP_SELF']=='/client.php' || $_SERVER['PHP_SELF']=='/contacts.php') && !has_access('viewallcompanycontacts')) $sql.=" and clientcreatedby = ".loginid(); if(($_SERVER['PHP_SELF']=='/client.php' || $_SERVER['PHP_SELF']=='/contacts.php') && has_access('viewallcompanycontacts') && officelocationid()) $sql .= " and clientcreatedby in ( select loginid from tblstaff join tbllogin using(staffid) where companyid=".companyid()." and officelocationid=".officelocationid()." )"; $sql.=" order by assetmanagername"; $assetmanagers = db_query($sql); $am_count = count($assetmanagers); ?>
All Contacts
$group){ ?>

' data-clienttypegroupid='' data-contacttypecount=''> ' title='View All ' data-href='' /> ' title='Remove Group: ' data-groupid="" /> */?>