Skip to content

Commit

Permalink
Reporting civicrm#18: Fix sorting with > 10 participant roles
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaphoneJon committed Nov 4, 2021
1 parent 0000c6d commit 5bdf992
Showing 1 changed file with 6 additions and 61 deletions.
67 changes: 6 additions & 61 deletions CRM/Report/Form/Event/ParticipantListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function __construct() {
'rid' => array(
'name' => 'role_id',
'title' => ts('Participant Role'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Event_PseudoConstant::participantRole(),
),
Expand All @@ -207,6 +208,11 @@ public function __construct() {
'type' => CRM_Utils_Type::T_STRING,
'operator' => 'like',
),
'is_test' => [
'title' => ts('Is Test'),
'type' => CRM_Utils_Type::T_BOOLEAN,
'default' => 0,
],
),
'order_bys' => array(
'participant_register_date' => array(
Expand Down Expand Up @@ -529,67 +535,6 @@ public function from() {
}
}

public function where() {
$clauses = [];
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('type', $field) & CRM_Utils_Type::T_DATE) {
$relative = $this->_params["{$fieldName}_relative"] ?? NULL;
$from = $this->_params["{$fieldName}_from"] ?? NULL;
$to = $this->_params["{$fieldName}_to"] ?? NULL;

if ($relative || $from || $to) {
$clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
}
}
else {
$op = $this->_params["{$fieldName}_op"] ?? NULL;

if ($fieldName == 'rid') {
$value = $this->_params["{$fieldName}_value"] ?? NULL;
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 {$this->_aliases['civicrm_participant']}.is_test = 0 ";
}
else {
$this->_where = "WHERE {$this->_aliases['civicrm_participant']}.is_test = 0 AND " .
implode(' AND ', $clauses);
}
if ($this->_aclWhere) {
$this->_where .= " AND {$this->_aclWhere} ";
}
}

public function groupBy() {
$this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, "{$this->_aliases['civicrm_participant']}.id");
}
Expand Down

0 comments on commit 5bdf992

Please sign in to comment.