custom reports for civicrm · extending crm_report_form: ... improved styles for printing reports:...

Post on 15-May-2018

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Custom Reports for CiviCRM:

Not as hard as you might think.

Anything

CiviReport does, you can do.

Grouping

Charts

Filters

Displaycolumns

Customdata

Linked text

Textmanipulation

Defaultsettings

Ordering

Anything.

What you'll need

Good grasp of SQL.

Basic understanding of

Object-Oriented Programming.

Decent IDE.

Patience.

Getting started

Documentation:

http://bit.ly/civireport_customize

Getting started

Directories

for custom

templates and

PHP files.

Getting started

Extending CRM_Report_Form:

● Override an existing report; OR

● Create a completely new one.

Simple example:Add a column to an existing report.

Simple example:Add a column to an existing report.

$civicrm_root/CRM/Report/Form/Contact/Summary.php

[custom_dir]/CRM/Report/Form/Contact/Summary.php

Simple example:Add a column to an existing report.

Simple example:Add a column to an existing report.

Creating a new report

“A report showing the name

and phone number of everyone

who came to more than

one event last year.”

Creating a new report

Creating a new report

$civicrm_root/CRM/Report/Form/Event/ParticipantListing.php

[custom_dir]/CRM/Report/Form/Event/ParticipantAggregate.php

Creating a new report

Creating a new report

$civicrm_root/templates/CRM/Report/Form/Event/ParticipantListing.tpl

[custom_dir]/templates/CRM/Report/Form/Event/ParticipantAggregate.tpl

Creating a new report

Register the

new report

template.

Creating a new report

Register the

new report

template.

Creating a new report

$_columns array: 'fields': existing

$_columns array: 'fields': count

$_columns array: 'fields': phone

$_columns array: 'fields': phone

from( ) method: phone table

Quick debugging tip:

Print the actual report SQL to a

status message, near the end of

CRM_Report_Form::buildQuery( ) :

CRM_Core_Session::setStatus("<pre>$sql</pre>"

);

$_columns array: 'group_bys':Contact ID

$_columns array: 'filters': count

where( ) method

where( ) method

$_columns array: 'order_bys':postal code

alterDisplay( ) method:

Useful thing #1Improved styles for printing reports:

http://bit.ly/civireport_printstyle

Useful thing #2User-private reports:

http://drupal.org/project/civicrm_private_report

Last thing, lots o' fun: Charts

Last thing, lots o' fun: Charts

Last thing, lots o' fun: Charts

Last thing, lots o' fun: Charts

CRM_Report_Form_Contribute_Summary

CRM_Report_Form_Contribute_Sybunt

CRM_Report_Form_Contribute_Lybunt

Examples in core reports:

Grouping

Charts

Filters

Displaycolumns

Customdata

Linked text

Textmanipulation

Defaultsettings

Ordering

top related