Backport 31732 - Fix incorrect address count when searching organisations (#8117)

This commit is contained in:
Nathan Gray 2010-08-19 16:22:10 +00:00
parent c07bbde11d
commit 30c1634b9c

View File

@ -143,7 +143,7 @@ class addressbook_sql extends so_sql
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",
);
@ -158,7 +158,7 @@ class addressbook_sql extends so_sql
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);
@ -167,7 +167,7 @@ class addressbook_sql extends so_sql
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);