2

Using the standard relationships report under Contact Reports, I would like to be able to add another column under Contact B. That column would pull the supplemental 1 address field.

Using the current template what do i need to add in order for that to work? Do i need to modify any other php files as well?

1
  • I get this error when adding the code? Parse error: syntax error, unexpected 'INNER' (T_STRING) in /home/gazzafm/public_html/crm/sites/all/modules/civicrm/CRM/Report/Form/Contact/Relationship.php on line 362 Commented Jun 3, 2016 at 14:07

2 Answers 2

3

As ErikH stated it is always good practice to create a new extension or create a custom folder to override core files

So In order to add a supplement address in the report you need to add a new column to the report first

 'civicrm_address' => array(
    'dao' => 'CRM_Core_DAO_Address',
      'fields' => array(
      'supplemental_address_1' => array(
        'title' => ts('supplemental address 1'),
        'default' => TRUE,

      ),
    ),

The above code will add a column to the report and next you need to add address table to the from function

if ($this->_params['fields']['supplemental_address_1']){
    $this->_from .= "
        INNER  JOIN civicrm_address {$this->_aliases['civicrm_address']}
                     ON (( {$this->_aliases['civicrm_address']}.contact_id =
                           {$this->_aliases['civicrm_contact']}.id  OR
                           {$this->_aliases['civicrm_address']}.contact_id =
                           {$this->_aliases['civicrm_contact_b']}.id ) AND
                           {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";

} else if (!empty($this->_params['country_id_value']) ||
  !empty($this->_params['state_province_id_value'] )
) {
  $this->_from .= "
        INNER  JOIN civicrm_address {$this->_aliases['civicrm_address']}
                     ON (( {$this->_aliases['civicrm_address']}.contact_id =
                           {$this->_aliases['civicrm_contact']}.id  OR
                           {$this->_aliases['civicrm_address']}.contact_id =
                           {$this->_aliases['civicrm_contact_b']}.id ) AND
                           {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
}

By doing the above you can achieve what you wanted

But still you need to add condition to your address table based on the location type or select only primary flag

I guess this helps !!!

3
  • Thanks for the answer. I did what you advised but then got syntax errors. Im a novice and tried to add the code you supplied, however I am probably putting it in the wrong area of the php code. Im sorta giving up on the idea as its just too confusing for novices. Thanks for your contribution though. Commented Jun 3, 2016 at 14:47
  • hi Gray - please send me your file which you have altered to [email protected] let me see what you have done and if i can let me fix the syntax error too Commented Jun 3, 2016 at 15:04
  • Ramesh did a great job on the coding. After much hair pulling and screaming, I finally(or so I thought) registered the template, created the custom directories. So now when i go to reports my custom report shows a link to access it....thats where it stops by telling me that Template not Found. Its clear that i should stick to Law and let others program. This is the toughest thing to comprehend or even understand the user manual. And people say lawyers speak in jibberish. Commented Jun 4, 2016 at 7:30
1

Perhaps it will help you to read the documentation on CiviCRM Reports: https://wiki.civicrm.org/confluence/display/CRMDOC/CiviReport+Reference. It is not complete but it should help you on your way?

I would not recommend just changing the template, I would recommend creating an extension with your customized report. And then you would need to update the php files as well, check https://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension#CreateaModuleExtension-Addareport

Or am I stating something which you already know by heart :-)

2
  • Thanks for the answer, im still a novice, but giving it a go. now ive run into a Inner (T STRING) error on line 362.....me thinks im just going to pay someone to do the coding of the report. A small failure in Civi that it cant customise reports from a wysiwyg editor. Commented Jun 3, 2016 at 14:22
  • There are lots of other open source tools that can do that. IMO it is therefore correct that it should not be part of CiviCRM, we should not create what is there for the sake of having it in CiviCRM :-) Check a toolset like Pentaho or Jaspersoft for reporting on several data sources? Commented Jun 5, 2016 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.