$this->setRowCount(10);
}
- public function preProcess() {
+ public function preProcess(): void {
$this->_csvSupported = FALSE;
parent::preProcess();
}
- public function select() {
+ public function select(): void {
$select = [];
$this->_columnHeaders = [];
- $this->_component = [
- 'contribution_civireport',
- 'membership_civireport',
- 'participant_civireport',
- 'relationship_civireport',
- 'activity_civireport',
- ];
+
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $fieldName => $field) {
if (!empty($field['required']) ||
!empty($this->_params['fields'][$fieldName])
) {
- //isolate the select clause compoenent wise
- if (in_array($table['alias'], $this->_component)) {
+ //isolate the select clause component wise
+ if (in_array($table['alias'], $this->getAvailableComponents())) {
$select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
$this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL;
$this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL;
}
}
- foreach ($this->_component as $val) {
+ foreach ($this->getAvailableComponents() as $val) {
if (!empty($select[$val])) {
$this->_selectComponent[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
unset($select[$val]);
$this->joinEmailFromContact();
// only include tables that are in from clause
- $componentTables = array_intersect($this->_aliases, $this->_component);
+ $componentTables = array_intersect($this->_aliases, $this->getAvailableComponents());
$componentTables = array_flip($componentTables);
$this->_selectedTables = array_diff($this->_selectedTables, $componentTables);
*/
public function clauseComponent() {
$selectedContacts = implode(',', $this->_contactSelected);
- $contribution = $membership = $participant = NULL;
$eligibleResult = $rows = $tempArray = [];
- foreach ($this->_component as $val) {
+ foreach ($this->getAvailableComponents() as $val) {
if (!empty($this->_selectComponent[$val]) &&
- ($val != 'activity_civireport' && $val != 'relationship_civireport')
+ ($val !== 'activity_civireport' && $val !== 'relationship_civireport')
) {
$sql = <<<HERESQL
{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
foreach ($this->_columnHeadersComponent[$val] as $key => $value) {
- if ($key == 'civicrm_relationship_contact_id_b') {
+ if ($key === 'civicrm_relationship_contact_id_b') {
$row[$key] = $dao->contact_b_name;
continue;
}
$rows[$dao->contact_a_id][$val][] = $row;
$row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name;
- $relTitle = "" . $dao->civicrm_relationship_relationship_type_id .
+ $relTitle = '' . $dao->civicrm_relationship_relationship_type_id .
'_b_a';
if (isset($relTypes[$relTitle])) {
$row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
// target, assignee, source, or the client on a case. Since the vast
// majority of activities will not involve the client, it's impractical to
// retrieve all activities and use OR clauses in the WHERE. Instead, we
- // use a union of subqueries for each of the four ways activities might
+ // use a union of sub-queries for each of the four ways activities might
// join to the contact.
$unionParts = [];
foreach ($this->activityContactJoin as $activityContactJoinClauses) {
}
//unset the component header if data is not present
- foreach ($this->_component as $val) {
+ foreach ($this->getAvailableComponents() as $val) {
if (!in_array($val, $eligibleResult)) {
unset($this->_columnHeadersComponent[$val]);
$componentRows = $this->clauseComponent();
$this->alterComponentDisplay($componentRows);
- //unset Conmponent id and contact id from display
+ //unset Component id and contact id from display
foreach ($this->_columnHeadersComponent as $componentTitle => $headers) {
$id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' .
substr_replace($componentTitle, '', -11, 11) . '_id';
$contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) .
'_contact_id';
- if ($componentTitle == 'activity_civireport') {
+ if ($componentTitle === 'activity_civireport') {
$id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
}
- unset($this->_columnHeadersComponent[$componentTitle][$id_header]);
- unset($this->_columnHeadersComponent[$componentTitle][$contact_header]);
+ unset($this->_columnHeadersComponent[$componentTitle][$id_header], $this->_columnHeadersComponent[$componentTitle][$contact_header]);
}
$this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent);
$entryFound = TRUE;
}
- if ($component == 'membership_civireport') {
+ if ($component === 'membership_civireport') {
if ($val = CRM_Utils_Array::value('civicrm_membership_membership_type_id', $row)) {
$componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant::membershipType($val, FALSE);
}
}
}
+ protected function getAvailableComponents(): array {
+ return [
+ 'contribution_civireport',
+ 'membership_civireport',
+ 'participant_civireport',
+ 'relationship_civireport',
+ 'activity_civireport',
+ ];
+ }
+
}