$query->_tables['civicrm_contribution'] = 1;
}
- // LCD 716
- $includeSoftCredits = self::isSoftCreditOptionEnabled($query->_params);
- if (!empty($query->_returnProperties['contribution_soft_credit_name'])) {
- if ($includeSoftCredits) {
- $query->_select['contribution_soft_credit_name'] = "civicrm_contact_d.sort_name as contribution_soft_credit_name";
- // also include contact id. Will help build hyperlinks
- $query->_select['contribution_soft_credit_contact_id'] = "civicrm_contact_d.id as contribution_soft_credit_contact_id";
- }
- $query->_element['contribution_soft_credit_name'] = 1;
- $query->_element['contribution_soft_credit_contact_id'] = 1;
-
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['civicrm_contribution_soft'] = 1;
- $query->_tables['civicrm_contribution_soft_contact'] = 1;
- }
-
- if (!empty($query->_returnProperties['contribution_soft_credit_contact_id'])) {
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['civicrm_contribution_soft'] = 1;
- $query->_tables['civicrm_contribution_soft_contact'] = 1;
- }
-
- if (!empty($query->_returnProperties['contribution_soft_credit_amount'])) {
- if ($includeSoftCredits) {
- $query->_select['contribution_soft_credit_amount'] = "civicrm_contribution_soft.amount as contribution_soft_credit_amount";
- }
- $query->_element['contribution_soft_credit_amount'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['civicrm_contribution_soft'] = 1;
- }
-
- if (!empty($query->_returnProperties['contribution_soft_credit_type'])) {
- if ($includeSoftCredits) {
- $query->_select['contribution_soft_credit_type'] = "contribution_softcredit_type.label as contribution_soft_credit_type";
- }
- $query->_element['contribution_soft_credit_type'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['contribution_softcredit_type'] = 1;
- }
-
- if (!empty($query->_returnProperties['contribution_soft_credit_contribution_id'])) {
- if ($includeSoftCredits) {
- $query->_select['contribution_soft_credit_contribution_id'] = "civicrm_contribution_soft.contribution_id as contribution_soft_credit_contribution_id";
- }
- $query->_element['contribution_soft_credit_contribution_id'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['civicrm_contribution_soft'] = 1;
- }
-
- if (!empty($query->_returnProperties['contribution_soft_credit_email'])) {
- $query->_select['contribution_soft_credit_email'] = "soft_email.email as contribution_soft_credit_email";
- $query->_element['contribution_soft_credit_email'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['civicrm_contribution_soft'] = 1;
- $query->_tables['civicrm_contribution_soft_contact'] = 1;
- $query->_tables['civicrm_contribution_soft_email'] = 1;
- }
-
- if (!empty($query->_returnProperties['contribution_soft_credit_phone'])) {
- $query->_select['contribution_soft_credit_email'] = "soft_phone.phone as contribution_soft_credit_phone";
- $query->_element['contribution_soft_credit_phone'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['civicrm_contribution_soft'] = 1;
- $query->_tables['civicrm_contribution_soft_contact'] = 1;
- $query->_tables['civicrm_contribution_soft_phone'] = 1;
- }
-
- if (!empty($query->_returnProperties['contribution_soft_credit_pcp_id'])) {
- $query->_select['contribution_soft_credit_pcp_id'] = "civicrm_contribution_soft.pcp_id as contribution_soft_credit_pcp_id";
- $query->_element['contribution_soft_credit_pcp_id'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['civicrm_contribution_soft'] = 1;
- }
-
if (!empty($query->_returnProperties['contribution_campaign_title'])) {
$query->_select['contribution_campaign_title'] = "civicrm_campaign.title as contribution_campaign_title";
$query->_element['contribution_campaign_title'] = $query->_tables['civicrm_campaign'] = 1;
$query->_element['financial_type_id'] = $query->_tables['civicrm_contribution'] = 1;
}
// LCD 716 END
+
+ self::addSoftCreditFields($query);
}
/**
return empty($errors) ? TRUE : $errors;
}
+ /**
+ * Add the soft credit fields to the select fields.
+ *
+ * Extracted into separate function to improve readability of main select function.
+ *
+ * @param $query
+ */
+ private static function addSoftCreditFields(&$query) {
+ $includeSoftCredits = self::isSoftCreditOptionEnabled($query->_params);
+ if (!empty($query->_returnProperties['contribution_soft_credit_name'])) {
+ if ($includeSoftCredits) {
+ $query->_select['contribution_soft_credit_name'] = "civicrm_contact_d.sort_name as contribution_soft_credit_name";
+ // also include contact id. Will help build hyperlinks
+ $query->_select['contribution_soft_credit_contact_id'] = "civicrm_contact_d.id as contribution_soft_credit_contact_id";
+ }
+ $query->_element['contribution_soft_credit_name'] = 1;
+ $query->_element['contribution_soft_credit_contact_id'] = 1;
+
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['civicrm_contribution_soft'] = 1;
+ $query->_tables['civicrm_contribution_soft_contact'] = 1;
+ }
+
+ if (!empty($query->_returnProperties['contribution_soft_credit_contact_id'])) {
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['civicrm_contribution_soft'] = 1;
+ $query->_tables['civicrm_contribution_soft_contact'] = 1;
+ }
+
+ if (!empty($query->_returnProperties['contribution_soft_credit_amount'])) {
+ if ($includeSoftCredits) {
+ $query->_select['contribution_soft_credit_amount'] = "civicrm_contribution_soft.amount as contribution_soft_credit_amount";
+ }
+ $query->_element['contribution_soft_credit_amount'] = 1;
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['civicrm_contribution_soft'] = 1;
+ }
+
+ if (!empty($query->_returnProperties['contribution_soft_credit_type'])) {
+ if ($includeSoftCredits) {
+ $query->_select['contribution_soft_credit_type'] = "contribution_softcredit_type.label as contribution_soft_credit_type";
+ }
+ $query->_element['contribution_soft_credit_type'] = 1;
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['contribution_softcredit_type'] = 1;
+ }
+
+ if (!empty($query->_returnProperties['contribution_soft_credit_contribution_id'])) {
+ if ($includeSoftCredits) {
+ $query->_select['contribution_soft_credit_contribution_id'] = "civicrm_contribution_soft.contribution_id as contribution_soft_credit_contribution_id";
+ }
+ $query->_element['contribution_soft_credit_contribution_id'] = 1;
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['civicrm_contribution_soft'] = 1;
+ }
+
+ if (!empty($query->_returnProperties['contribution_soft_credit_email'])) {
+ $query->_select['contribution_soft_credit_email'] = "soft_email.email as contribution_soft_credit_email";
+ $query->_element['contribution_soft_credit_email'] = 1;
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['civicrm_contribution_soft'] = 1;
+ $query->_tables['civicrm_contribution_soft_contact'] = 1;
+ $query->_tables['civicrm_contribution_soft_email'] = 1;
+ }
+
+ if (!empty($query->_returnProperties['contribution_soft_credit_phone'])) {
+ $query->_select['contribution_soft_credit_email'] = "soft_phone.phone as contribution_soft_credit_phone";
+ $query->_element['contribution_soft_credit_phone'] = 1;
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['civicrm_contribution_soft'] = 1;
+ $query->_tables['civicrm_contribution_soft_contact'] = 1;
+ $query->_tables['civicrm_contribution_soft_phone'] = 1;
+ }
+
+ if (!empty($query->_returnProperties['contribution_soft_credit_pcp_id'])) {
+ $query->_select['contribution_soft_credit_pcp_id'] = "civicrm_contribution_soft.pcp_id as contribution_soft_credit_pcp_id";
+ $query->_element['contribution_soft_credit_pcp_id'] = 1;
+ $query->_tables['civicrm_contribution'] = 1;
+ $query->_tables['civicrm_contribution_soft'] = 1;
+ }
+ }
+
}