Skip to content

Commit

Permalink
Merge pull request #13963 from eileenmcnaughton/event_report
Browse files Browse the repository at this point in the history
Readability cleanup on EventIncome report (towards bringing it under testing)
  • Loading branch information
seamuslee001 authored Apr 20, 2019
2 parents 43c7186 + 27f4227 commit 2617d84
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions CRM/Report/Form/Event/Income.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function buildEventReport($eventIDs) {

$eventID = implode(',', $eventIDs);

$participantStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label");
$participantRole = CRM_Event_PseudoConstant::participantRole();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();

Expand All @@ -90,15 +89,8 @@ public function buildEventReport($eventIDs) {
if ($optionGroupDAO->find(TRUE)) {
$optionGroupId = $optionGroupDAO->id;
}
//show the income of active participant status (Counted = filter = 1)
$activeParticipantStatusIDArray = $activeParticipantStatusLabelArray = [];
foreach ($participantStatus as $id => $label) {
$activeParticipantStatusIDArray[] = $id;
$activeParticipantStatusLabelArray[] = $label;
}
$activeParticipantStatus = implode(',', $activeParticipantStatusIDArray);
$activeparticipnatStutusLabel = implode(', ', $activeParticipantStatusLabelArray);
$activeParticipantClause = " AND civicrm_participant.status_id IN ( $activeParticipantStatus ) ";

$activeParticipantClause = " AND civicrm_participant.status_id IN ( " . implode(',', array_keys($this->getActiveParticipantStatuses())) . " ) ";
$select = [
"civicrm_event.id as event_id",
"civicrm_event.title as event_title",
Expand Down Expand Up @@ -133,7 +125,7 @@ public function buildEventReport($eventIDs) {
$eventSummary[$eventDAO->event_id][ts('End Date')] = CRM_Utils_Date::customFormat($eventDAO->end_date);
$eventSummary[$eventDAO->event_id][ts('Event Type')] = $eventDAO->event_type;
$eventSummary[$eventDAO->event_id][ts('Event Income')] = CRM_Utils_Money::format($eventDAO->total, $eventDAO->currency);
$eventSummary[$eventDAO->event_id][ts('Registered Participant')] = "{$eventDAO->participant} ({$activeparticipnatStutusLabel})";
$eventSummary[$eventDAO->event_id][ts('Registered Participant')] = "{$eventDAO->participant} ({" . implode(', ', $this->getActiveParticipantStatuses()) . ")";
$currency[$eventDAO->event_id] = $eventDAO->currency;
}
$this->assign_by_ref('summary', $eventSummary);
Expand Down Expand Up @@ -216,6 +208,7 @@ public function buildEventReport($eventIDs) {

$statusDAO = $this->executeReportQuery($status);

$participantStatus = $this->getActiveParticipantStatuses();
while ($statusDAO->fetch()) {
$statusRows[$statusDAO->event_id][$participantStatus[$statusDAO->STATUSID]]['total'] = $statusDAO->participant;
$statusRows[$statusDAO->event_id][$participantStatus[$statusDAO->STATUSID]]['round'] = round(($statusDAO->participant / $count[$statusDAO->event_id]) * 100, 2);
Expand Down Expand Up @@ -382,4 +375,13 @@ public function postProcess() {
parent::endPostProcess();
}

/**
* Get statuses with the counted filter set to TRUE.
*
* @return array
*/
protected function getActiveParticipantStatuses() {
return CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label");
}

}

0 comments on commit 2617d84

Please sign in to comment.