Skip to content

Instantly share code, notes, and snippets.

@mlutfy
Created March 13, 2012 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlutfy/2025727 to your computer and use it in GitHub Desktop.
Save mlutfy/2025727 to your computer and use it in GitHub Desktop.
Show the soft-credit for contributions details
// The soft-credit report shows contributions received from the point of view of the fundraiser (soft-credit)
// I just want to add a column to the contribution detail report
// For more info: http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviReport+structure+and+customization
<?php
// Based on CRM/Report/Form/Contribute/Detail.php
// modified to add the soft-credit column
require_once 'CRM/Report/Form/Contribute/Detail.php';
class CRM_Report_Form_Contribute_DetailWithSoft extends CRM_Report_Form_Contribute_Detail {
function __construct( ) {
parent::__construct( );
$this->_columns = $this->_columns + $this->getSoftCreditColumn();
}
function from( ) {
parent::from();
$this->_from .= $this->getSoftCreditJoin();
}
/**
* Add the columns required for soft-credit
*/
function getSoftCreditColumn(){
return array(
'civicrm_mysoftcredit' => array(
'dao' => 'CRM_Contact_DAO_Contact',
'fields' => array(
'display_name_creditor' => array(
'title' => ts( 'Soft-Credit' ),
'name' => 'sort_name',
'default' => true,
),
'filters' => array(
'display_name_creditor' => array(
'name' => 'sort_name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts( 'Soft-Credit' ),
'operator' => 'like',
),
),
),
),
'civicrm_contribution_soft' => array(
'dao' => 'CRM_Contribute_DAO_ContributionSoft',
'fields' => array(
'contribution_id' => array(
'title' => ts('Contribution ID'),
'no_display' => true,
'default' => true,
),
'id' => array(
'default' => true,
'no_display' => true,
),
),
),
);
}
/**
* Get the join required to add soft-credit columns
*/
function getSoftCreditJoin() {
$alias_constituent = 'mysoftcredit_civireport';
return
"LEFT JOIN civicrm_contribution_soft {$this->_aliases['civicrm_contribution_soft']}
ON {$this->_aliases['civicrm_contribution_soft']}.contribution_id =
{$this->_aliases['civicrm_contribution']}.id
LEFT JOIN civicrm_contact {$alias_constituent}
ON {$alias_constituent}.id =
{$this->_aliases['civicrm_contribution_soft']}.contact_id";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment