Skip to content

Commit

Permalink
Merge pull request #13158 from elisseck/dev/core/544
Browse files Browse the repository at this point in the history
dev/core/544 Add report support for filter on multiple contact subtypes
  • Loading branch information
eileenmcnaughton authored Mar 28, 2019
2 parents b55599c + 0816f78 commit 558bcc4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CRM/Report/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,10 @@ public function whereClause(&$field, $op, $value, $min, $max) {
break;
}

//dev/core/544 Add report support for multiple contact subTypes
if ($field['name'] == 'contact_sub_type' && $clause) {
$clause = $this->whereSubtypeClause($field, $value, $op);
}
if (!empty($field['group']) && $clause) {
$clause = $this->whereGroupClause($field, $value, $op);
}
Expand All @@ -2088,6 +2092,27 @@ public function whereClause(&$field, $op, $value, $min, $max) {
return $clause;
}

/**
* Get SQL where clause for contact subtypes
* @param string $field
* @param mixed $value
* @param string $op SQL Operator
*
* @return string
*/
public function whereSubtypeClause($field, $value, $op) {
$clause = '( ';
$subtypeFilters = count($value);
for ($i = 0; $i < $subtypeFilters; $i++) {
$clause .= "{$field['dbAlias']} LIKE '%$value[$i]%'";
if ($i !== ($subtypeFilters - 1)) {
$clause .= " OR ";
}
}
$clause .= ' )';
return $clause;
}

/**
* Get SQL where clause for a date field.
*
Expand Down

0 comments on commit 558bcc4

Please sign in to comment.