From dd54552881d1d432cddfac543198597696f787b3 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 19 Aug 2010 16:15:10 +0000 Subject: [PATCH] Fix incorrect address count when searching organisations (#8117) --- addressbook/inc/class.addressbook_sql.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index 4a8cb91622..7356122db8 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -146,7 +146,7 @@ class addressbook_sql extends so_sql_cf if (!$by) { $extra = array( - 'COUNT(org_name) AS org_count', + 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", ); @@ -161,7 +161,7 @@ class addressbook_sql extends so_sql_cf parent::search($param['search'],array('org_name'),$append,array( "NULL AS $by", '1 AS is_main', - 'COUNT(org_name) AS org_count', + 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", ),'%',false,'OR','UNION',$filter); @@ -170,7 +170,7 @@ class addressbook_sql extends so_sql_cf parent::search($param['search'],array('org_name'),$append,array( "CASE WHEN $by IS NULL THEN '' ELSE $by END AS $by", '0 AS is_main', - 'COUNT(org_name) AS org_count', + 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", ),'%',false,'OR','UNION',$filter);