Skip to content

Commit

Permalink
Merge pull request #14827 from deepak-srivastava/case-summary-report-…
Browse files Browse the repository at this point in the history
…case-type-filter

dev/core#1118 correct filteration by case type, re-use parent where()
  • Loading branch information
eileenmcnaughton authored Jul 21, 2019
2 parents 2bb6bb8 + d18a960 commit 851aa40
Showing 1 changed file with 4 additions and 58 deletions.
62 changes: 4 additions & 58 deletions CRM/Report/Form/Case/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -309,66 +310,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() {
Expand Down

0 comments on commit 851aa40

Please sign in to comment.