From fb8e7fece87249fc70bba438ee1e30e664c7e106 Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Mon, 15 Jul 2019 12:31:03 +0100 Subject: [PATCH 1/2] dev/core#1118 correct filteration by case type, re-use parent where() --- CRM/Report/Form/Case/Summary.php | 61 ++------------------------------ 1 file changed, 3 insertions(+), 58 deletions(-) diff --git a/CRM/Report/Form/Case/Summary.php b/CRM/Report/Form/Case/Summary.php index 286fe3b2332b..b1c3b633daa4 100644 --- a/CRM/Report/Form/Case/Summary.php +++ b/CRM/Report/Form/Case/Summary.php @@ -309,66 +309,11 @@ public function from() { } } - public function where() { - $clauses = []; + public function storeWhereHavingClauseArray() { if (!empty($this->_params['fields']['label_b_a']) && $this->_params['fields']['label_b_a'] == 1) { - $clauses[] = 'contact_civireport.sort_name != c2_civireport.sort_name'; - } - $this->_having = ''; - foreach ($this->_columns as $tableName => $table) { - if (array_key_exists('filters', $table)) { - foreach ($table['filters'] as $fieldName => $field) { - $clause = NULL; - if (CRM_Utils_Array::value("operatorType", $field) & CRM_Report_Form::OP_DATE - ) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); - - $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, - CRM_Utils_Array::value('type', $field) - ); - } - else { - - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); - if ($fieldName == 'case_type_id') { - $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); - if (!empty($value)) { - $operator = ''; - if ($op == 'notin') { - $operator = 'NOT'; - } - - $regexp = "[[:cntrl:]]*" . implode('[[:>:]]*|[[:<:]]*', $value) . "[[:cntrl:]]*"; - $clause = "{$field['dbAlias']} {$operator} REGEXP '{$regexp}'"; - } - $op = NULL; - } - - if ($op) { - $clause = $this->whereClause($field, - $op, - CRM_Utils_Array::value("{$fieldName}_value", $this->_params), - CRM_Utils_Array::value("{$fieldName}_min", $this->_params), - CRM_Utils_Array::value("{$fieldName}_max", $this->_params) - ); - } - } - - if (!empty($clause)) { - $clauses[] = $clause; - } - } - } - } - - if (empty($clauses)) { - $this->_where = "WHERE ( 1 ) "; - } - else { - $this->_where = "WHERE " . implode(' AND ', $clauses); + $this->_whereClauses[] = '(contact_civireport.sort_name != c2_civireport.sort_name)'; } + parent::storeWhereHavingClauseArray(); } public function groupBy() { From d18a96027f040e40b96bb4cfaa9a64520abae7ac Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Sat, 20 Jul 2019 16:33:34 +0100 Subject: [PATCH 2/2] dev/core#1118 define filter type for case_type_id --- CRM/Report/Form/Case/Summary.php | 1 + 1 file changed, 1 insertion(+) diff --git a/CRM/Report/Form/Case/Summary.php b/CRM/Report/Form/Case/Summary.php index b1c3b633daa4..ae8613ca7b19 100644 --- a/CRM/Report/Form/Case/Summary.php +++ b/CRM/Report/Form/Case/Summary.php @@ -131,6 +131,7 @@ public function __construct() { 'title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Case_BAO_Case::buildOptions('case_type_id', 'search'), + 'type' => CRM_Utils_Type::T_INT, ], 'status_id' => [ 'title' => ts('Status'),