Skip to content

Commit

Permalink
PHP8.2 undefined property fix event summary report
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Oct 23, 2023
1 parent 5843344 commit d193bb6
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions CRM/Report/Form/Event/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,50 +132,48 @@ public function select() {
$this->_select = 'SELECT ' . implode(', ', $select);
}

public function from() {
public function from(): void {
$this->_from = " FROM civicrm_event {$this->_aliases['civicrm_event']} ";
}

public function where() {
public function where(): void {
$clauses = [];
$this->_participantWhere = "";
foreach ($this->_columns as $tableName => $table) {
foreach ($this->_columns as $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
$clause = NULL;
if (($field['type'] ?? 0) & 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']);
$clauses[] = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
}
}
else {
$op = $this->_params["{$fieldName}_op"] ?? NULL;
if ($op) {
$clause = $this->whereClause($field,
$clauses[] = $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)
$this->_params["{$fieldName}_value"] ?? NULL,
$this->_params["{$fieldName}_min"] ?? NULL,
$this->_params["{$fieldName}_max"] ?? NULL,
);
}
}
if (!empty($this->_params['id_value'])) {
$idValue = is_array($this->_params['id_value']) ? implode(',', $this->_params['id_value']) : $this->_params['id_value'];
$this->_participantWhere = " AND civicrm_participant.event_id IN ( $idValue ) ";
}

if (!empty($clause)) {
$clauses[] = $clause;
}
}
}
}
$clauses[] = "{$this->_aliases['civicrm_event']}.is_template = 0";
$this->_where = 'WHERE ' . implode(' AND ', $clauses);
$this->_where = 'WHERE ' . implode(' AND ', array_filter($clauses));
}

public function getEventFilter(): string {
$eventID = array_filter((array) $this->_params['id_value']);
if (empty($eventID)) {
return '';
}
return ' AND civicrm_participant.event_id IN ( ' . implode(',', $eventID) . ') ';
}

public function groupBy() {
Expand All @@ -192,7 +190,7 @@ public function participantInfo() {
$statusType1 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$statusType2 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0');

$sql = "
$sql = '
SELECT civicrm_participant.event_id AS event_id,
civicrm_participant.status_id AS statusId,
COUNT( civicrm_participant.id ) AS participant,
Expand All @@ -202,11 +200,11 @@ public function participantInfo() {
FROM civicrm_participant
WHERE civicrm_participant.is_test = 0
$this->_participantWhere
' . $this->getEventFilter() . '
GROUP BY civicrm_participant.event_id,
civicrm_participant.status_id,
civicrm_participant.fee_currency";
civicrm_participant.fee_currency';

$info = CRM_Core_DAO::executeQuery($sql);
$participant_data = $participant_info = $currency = [];
Expand Down Expand Up @@ -306,8 +304,8 @@ public function postProcess() {
while ($dao->fetch()) {
$row = [];
foreach ($this->_columnHeaders as $key => $value) {
if (($key == 'civicrm_event_start_date') ||
($key == 'civicrm_event_end_date')
if (($key === 'civicrm_event_start_date') ||
($key === 'civicrm_event_end_date')
) {
//get event start date and end date in custom datetime format
$row[$key] = CRM_Utils_Date::customFormat($dao->$key);
Expand Down

0 comments on commit d193bb6

Please sign in to comment.