CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Customize ContributionAggregate.php search
Pages: [1]

Author Topic: Customize ContributionAggregate.php search  (Read 730 times)

thalemn

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.5.30-log
  • PHP version: 5.2.17
Customize ContributionAggregate.php search
April 11, 2013, 02:04:02 pm
I need to add a field to the ContributionAggregate.php form.  I have made a new form and it's working properly.  I need to add a custom field to the form results.

The name of my custom field is: Custom_Household_Sort_Name (I found it in the database in the civicrm_custom_field table).

I can add the field here and it works as expected, I can see the column added to the results page:

   * Define the columns for search result rows
         */
        $this->_columns = array( ts('Contact Id')   => 'contact_id'  ,
                                 ts('Name'      )   => 'sort_name',
                         ts('Last Name') => 'last_name',
                         ts('Household Name') => 'household_name',
                         ts('Custom Household Sort Name')=> 'Custom_Household_Sort_Name',
                                 ts('Donation Count') => 'donation_count',
                                 ts('Donation Amount') => 'donation_amount' );
    }

I also need it to populate the data in the field, but I am not an expert at SQL and PHP, so can someone help me code it into the form.  I think it needs to go here:

        // SELECT clause must include contact_id as an alias for civicrm_contact.id
        if ( $onlyIDs ) {
            $select  = "DISTINCT contact_a.id as contact_id";
        } else {
            $select  = "
DISTINCT contact_a.id as contact_id,
contact_a.sort_name as sort_name,
contact_a.last_name as last_name,
contact_a.household_name as household_name,
sum(contrib.total_amount) AS donation_amount,
count(contrib.id) AS donation_count
";

Thanks!

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Customize ContributionAggregate.php search
April 12, 2013, 06:05:50 am
Did you see the class variables?
Code: [Select]
  protected $_customGroupExtends = NULL;
  protected $_customGroupFilters = TRUE;
  protected $_customGroupGroupBy = FALSE;
That is the standard way to add all custom data to reports.  Might be the easiest approach if you just want to add data, unless you have a specific use case / more complicated query to write.

Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

thalemn

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.5.30-log
  • PHP version: 5.2.17
Re: Customize ContributionAggregate.php search
April 12, 2013, 11:15:50 am
Michael,

Thank you for the information - yes, I just want to add the data to my form from the custom field.

Do I simply add these custom classes to the form (where the original class is, example below)?  Or is there more to it?

Sorry, but I'll need a degree of guidance here since I'm not a SQL/PHP guru.

class CRM_Contact_Form_Search_Custom_CustomContributionAggregate
   implements CRM_Contact_Form_Search_Interface {

    protected $_formValues;
    protected $_customGroupExtends = NULL;
    protected $_customGroupFilters = TRUE;
    protected $_customGroupGroupBy = FALSE;

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Customize ContributionAggregate.php search
April 12, 2013, 02:59:29 pm
best thing to do is have a search around in other reports distributed with civicrm that do use custom data - have a search for how those variables are used and see if you can apply them to your use case.

of the top of my head you need to do something like

    protected $_customGroupExtends = array('Individual') to get custom data on any individual records, etc...
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

thalemn

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.5.30-log
  • PHP version: 5.2.17
Re: Customize ContributionAggregate.php search
April 12, 2013, 06:38:17 pm
Thank you - I will take a look

thalemn

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.5.30-log
  • PHP version: 5.2.17
Re: Customize ContributionAggregate.php search
April 13, 2013, 05:14:05 pm
I have tried several things to get this to work, but I really don't have the time and skills to dedicate to this.

How do I go about hiring someone to customize this?

Thanks

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Customize ContributionAggregate.php search
April 13, 2013, 09:17:07 pm

http://civicrm.org/what/experts

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Customize ContributionAggregate.php search

This forum was archived on 2017-11-26.