This documentation refers to an older version of CiviCRM (3.4 / 4.0). The current stable version is 4.1. Please introduce all documentation changes and new material here.

Skip to end of metadata
Go to start of metadata
This page refers to CiviCRM 3.4 and 4.0, current STABLE version.

Documentation Search


CiviCRM 3.4 and 4.0 Documentation

Support and Participation

Developer Resources


CiviCRM books!

Make sure to check out the FLOSS Manual Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

Or support us by buying an eBook or hard copy of Using CiviCRM from Packt Publishing.

Individual Group Membership

The following short tutorial/example demonstrates adding a custom report to CiviReport. This is based on the tutorial given here: CiviReport structure and customization

Columns for Display

First, work out which columns you want displayed on resulting report. In this case these are:

  • Organisation (Organization)
  • Individual Sort Name
  • Email Address
  • Groups - Only include groups containing the text: "Clinics"

How should the columns be sorted?

Next, to help build the SQL, decide which columns should be sorted alphabetically. In this case:

  • Organisation (Organization)
  • Sort Name
  • Group

Sort by Organisation Name first, then by Sort Name for Individual, and finally, Group

Build the SQL

Using phpMyAdmin (or your tool of choice) build and test the SQL to return the above criteria:

Create the Report File(s)

Rather than creating a custom directory structure, I placed the required php and tpl files in the same place as the CiviCRM files (this is backed up periodically anyways)

In <civicrm_root>/CRM/Report/Form/Contact, I created ContactClinics.php containing the following:

In <civicrm_root>/templates/CRM/Report/Form/Contact, I created ContactClinics.tpl containing the following:

Add the report and Preview

Using Administer, CiviReport, Register new template with the following:

Title *

Contact Clinics

Description *

Contact Clinics

URL *

contact/ContactClinics

Class *

CRM_Report_Form_Contact_ContactClinics

Weight *

??

Component

Contact

Using Report, Manage Templates; select the new 'Contact Clinics' template and preview

Considerations

  • Modify the php/template somehow to take input criteria for Organisation Name
  • Modify the width of the columns
  • Modify the outputted PDF for landscape orientation.
Labels
  • None