From 1d6f9f23a26ca5e2938fc9ef7c1837c6c1f0aeb0 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Mon, 8 Jul 2019 17:51:48 -0400 Subject: [PATCH] apply reporting#15 fix against master --- CRM/Report/Form.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index b1e0a06d3f..eff1db9aef 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -2129,12 +2129,30 @@ class CRM_Report_Form extends CRM_Core_Form { * @return string */ public function whereSubtypeClause($field, $value, $op) { + // Get the correct SQL operator. + switch ($op) { + case 'notin': + $op = 'nhas'; + $clauseSeparator = 'AND'; + break; + + case 'in': + $op = 'has'; + $clauseSeparator = 'OR'; + break; + } + $sqlOp = $this->getSQLOperator($op); $clause = '( '; $subtypeFilters = count($value); - for ($i = 0; $i < $subtypeFilters; $i++) { - $clause .= "{$field['dbAlias']} LIKE '%$value[$i]%'"; - if ($i !== ($subtypeFilters - 1)) { - $clause .= " OR "; + if ($sqlOp == 'IS NULL' || $sqlOp == 'IS NOT NULL') { + $clause .= "{$field['dbAlias']} $sqlOp"; + } + else { + for ($i = 0; $i < $subtypeFilters; $i++) { + $clause .= "{$field['dbAlias']} $sqlOp '%$value[$i]%'"; + if ($i !== ($subtypeFilters - 1)) { + $clause .= " $clauseSeparator "; + } } } $clause .= ' )'; -- 2.25.1