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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom report: display start date in filter section of report
Pages: [1]

Author Topic: Custom report: display start date in filter section of report  (Read 1734 times)

ffwd

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.4.5
Custom report: display start date in filter section of report
December 16, 2011, 05:17:45 pm
I've been trying to create a custom version of the 'Event Participant Report' in CiviReports. I removed some columns and changed some filter input options. Everything went well, so far.

I've set the filter operator type for 'event_id' to: 'operatorType' => CRM_Report_Form::OP_SELECT
This means it is possible to select only one event now.

I have two questions:
- I would like to know how I would go about showing the start date of the selected event at the top of the generated report (underneath or in the 'filter' section). I do not want the filter criteria to include a input for the date.

Is there any way to do this? I have searched the forums, but not found anything like this.

- Is it possible to hide the filter's condition ('Is equal to') for the Event? It doesn't make sense to show this when only one event can be selected.

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: Custom report: display start date in filter section of report
December 18, 2011, 09:28:03 pm
# To display event start date as report title
You will need to put the code, something like following into the function alterDisplay( )
Code: [Select]
if ( ($eventId = $this->_params['event_id_value']) &&
     !empty($eventId) ) {
        if ( is_array($eventId) ) {
          $eventId = end($eventId);
        }
        $startDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'start_date');
        if ( $startDate ) {
          CRM_Utils_System::setTitle( CRM_Utils_Date::customFormat($startDate) );
        }
}

# To remove the filter criteria to include a input for the date.
You will need to modify '$this->_columns' in function __construct( ), and remove that filter ( from array key 'filters')

Quote
Is it possible to hide the filter's condition ('Is equal to') for the Event? It doesn't make sense to show this when only one event can be selected.
It will be very easy to hide the '<tr>' element displaying that filter using css?

Rajan

ffwd

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.4.5
Re: Custom report: display start date in filter section of report
December 20, 2011, 07:14:04 pm
Thanks for pointing me in the right direction.

I can indeed set the title to contain the start date in the way you suggested. But I was looking for a way to create something like:
_____________
Report title

- Event name
- Event start date

-- report rows --
_____________

I can't find any function that will allow me to modify the 'filter' section of the report or 'group header' maybe?

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: Custom report: display start date in filter section of report
December 21, 2011, 01:43:14 am
For this you might need to customize your report's tpl file,
By default it includes CRM/Report/Form.tpl, you can customize this by coping code from CRM/Report/Form.tpl, and change it accordingly.
To use any variable from php to .tpl file,
First you need to assign it
eg:
on php side: $this->assign('testVar', 'testVarValue' );
To use this in smarty: {$testVar}

I hope this will help you!

Rajan

ffwd

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.4.5
Re: Custom report: display start date in filter section of report
December 21, 2011, 04:44:03 pm
Yes, this helps a lot. Thank you.
I think I'll get the hang of this.
« Last Edit: December 23, 2011, 05:12:08 pm by ffwd »

ffwd

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.4.5
Re: Custom report: display start date in filter section of report
December 26, 2011, 04:42:10 pm
I have successfully added some custom information at the top of my report in the way you described. Can you give me some clue as to how I add these on the printed / pdf report? I have looked inside form.php and I noticed how in the endPostProcess method the reports seem to be processed for printing, but I can figure out where to add my custom vars.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom report: display start date in filter section of report

This forum was archived on 2017-11-26.