From 67788963c739243d236f7f59ff2b8888e0211e29 Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Mon, 3 Mar 2014 13:23:15 +0000 Subject: [PATCH] CRM-14301 Add 'is not one of' to report filtering on multiple select fields --- CRM/Report/Form.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 9f3a2beec8..68b524b379 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -1186,6 +1186,7 @@ class CRM_Report_Form extends CRM_Core_Form { // multiple options for a column is stored as ^A{val1}^A{val2}^A return array( 'mhas' => ts('Is one of'), + 'mnot' => ts('Is not one of'), ); default: @@ -1377,6 +1378,14 @@ class CRM_Report_Form extends CRM_Core_Form { $clause = "{$field['dbAlias']} REGEXP '[[:<:]]" . implode('|', $value) . "[[:>:]]'"; } break; + + case 'mnot': + // mnot == multiple is not one of + if ($value !== NULL && count($value) > 0) { + $sqlOP = $this->getSQLOperator($op); + $clause = "( {$field['dbAlias']} NOT REGEXP '[[:<:]]" . implode('|', $value) . "[[:>:]]' OR {$field['dbAlias']} IS NULL )"; + } + break; case 'sw': case 'ew': @@ -2488,7 +2497,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $val[$key] = $options[$valIds]; } } - $pair[$op] = (count($val) == 1) ? (($op == 'notin') ? ts('Is Not') : ts('Is')) : CRM_Utils_Array::value($op, $pair); + $pair[$op] = (count($val) == 1) ? (($op == 'notin' || $op == 'mnot') ? ts('Is Not') : ts('Is')) : CRM_Utils_Array::value($op, $pair); $val = implode(', ', $val); $value = "{$pair[$op]} " . $val; } -- 2.25.1