diff --git a/civicrm.info b/civicrm.info index a146ec862..daf7a9543 100644 --- a/civicrm.info +++ b/civicrm.info @@ -89,6 +89,7 @@ files[] = modules/views/civicrm/views_handler_argument_civicrm_year_month.inc files[] = modules/views/civicrm/civicrm_handler_relationship.inc files[] = modules/views/civicrm/civicrm_handler_relationship_relationship.inc files[] = modules/views/civicrm/civicrm_handler_relationship_contact2users.inc +files[] = modules/views/civicrm/civicrm_handler_relationship_contacts_contributions.inc files[] = modules/views/civicrm/civicrm_handler_relationship_memberships_contributions.inc files[] = modules/views/civicrm/civicrm_handler_relationship_location.inc files[] = modules/views/civicrm/civicrm_handler_relationship_mail.inc diff --git a/modules/views/civicrm/civicrm_handler_relationship_contacts_contributions.inc b/modules/views/civicrm/civicrm_handler_relationship_contacts_contributions.inc new file mode 100644 index 000000000..79fd6bb74 --- /dev/null +++ b/modules/views/civicrm/civicrm_handler_relationship_contacts_contributions.inc @@ -0,0 +1,53 @@ +options['required']) ? 'LEFT' : 'INNER'; + $this->ensure_my_table(); + $join = new views_join(); + $join->definition = array( + 'table' => 'civicrm_contribution', + 'field' => 'contact_id', + 'left_table' => $this->table_alias, + 'left_field' => 'id', + 'type' => $join_type, + ); + $join->construct(); + $join->adjusted = TRUE; + $alias = $join->definition['table'] . '_' . $join->definition['left_table']; + $this->alias = $this->query->add_relationship($alias, $join, 'civicrm_contribution', $this->relationship); + } + +} diff --git a/modules/views/components/civicrm.core.inc b/modules/views/components/civicrm.core.inc index b82d8cfde..beac713e0 100644 --- a/modules/views/components/civicrm.core.inc +++ b/modules/views/components/civicrm.core.inc @@ -2454,6 +2454,20 @@ function _civicrm_core_data(&$data, $enabled) { ), ); + // Link to Contribution table + if (isset($enabled['CiviContribute'])) { + $data['civicrm_contact']['contribution_id'] = array( + 'title' => t('Contribution Records'), + 'help' => 'Contributions records for this Contact', + 'relationship' => array( + 'base' => 'civicrm_contribution', + 'base field' => 'id', + 'handler' => 'civicrm_handler_relationship_contacts_contributions', + 'label' => t('Contact -> Contribution'), + ), + ); + } + //---------------------------------------------------------------- // CIVICRM Relationships are here with all the connections, base tabling it up. //----------------------------------------------------------------