$this->_pseudoConstantsSelect[$tName]['select'] = "{$field['where']} as `$name`";
$this->_pseudoConstantsSelect[$tName]['element'] = $name;
}
+ elseif (strpos($name, 'contribution_soft_credit') !== FALSE ) {
+ if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_params)) {
+ $this->_select[$name] = "{$field['where']} as `$name`";
+ }
+ }
else {
$this->_select[$name] = "{$field['where']} as `$name`";
}
}
// LCD 716
+ $includeSoftCredits = self::isSoftCreditOptionEnabled($query->_params);
if (!empty($query->_returnProperties['contribution_soft_credit_name'])) {
- $query->_select['contribution_soft_credit_name'] = "civicrm_contact_d.sort_name as 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;
-
- // 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_contact_id'] = 1;
$query->_tables['civicrm_contribution'] = 1;
}
if (!empty($query->_returnProperties['contribution_soft_credit_amount'])) {
- $query->_select['contribution_soft_credit_amount'] = "civicrm_contribution_soft.amount as 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'])) {
- $query->_select['contribution_soft_credit_type'] = "contribution_softcredit_type.label as 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'])) {
- $query->_select['contribution_soft_credit_contribution_id'] = "civicrm_contribution_soft.contribution_id as 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;