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 CiviReport (Moderator: Dave Greenberg) »
  • Need help finding values in db
Pages: [1]

Author Topic: Need help finding values in db  (Read 1899 times)

leapywca

  • Guest
Need help finding values in db
October 20, 2009, 12:36:36 pm
I am trying to create a custom report. It should report the number of people from each city that attended each program. So for example, ten people from orlando attended xyz program whereas 23 people from tampa attended xzy program. So what I was wondering is how are participants tied to an event – i.e. where in the database tables can I find which participants attended xyz event?

Then after that I’d have to probably do a join table with the participant’s addresses (i'm guessing based on participant_id or something like that) and then place in arrays based on city, reporting the sizeof() the city_arrays.

Any thoughts?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Need help finding values in db
October 20, 2009, 04:26:53 pm
Event participants are stored in civicrm_participant table. The table contains foreign keys to the civicrm_contact record (contact_id) and the civicrm_event record (event_id). You can then JOIN to the contacts' civicrm_address record(s) based on contact_id (FK in that table).

You'll probably want to filter by participant role and participant status (i.e. include registered and / or attended folks, but not cancelled or no-shows). Both of these are in the participant table.

You might want to check the existing Event and Participant Listing reports for sample queries etc.
HTH
« Last Edit: October 20, 2009, 04:32:02 pm by Dave Greenberg »
Protect your investment in CiviCRM by  becoming a Member!

leapywca

  • Guest
Re: Need help finding values in db
October 21, 2009, 06:45:30 am
Thanks Dave! That information will help us with a different portion of the report but I mistyped a word in my question. I meant to say program, not event. I am trying to create a custom report within civicase (I guess it’s vital to know that we translated civicase --> programs), so I’m guessing that information is in a different table. Currently the report (a grid) looks like this (with blank fields which will be filled by query):
Program   AP CR CL FV GA HS KD MV RA WF WE ZE OT
abc
ghi
xyz


The programs are listed along the left and the capital two-letter words across top represent cities. For example, the first blank would be filled in by the number of people from AP city who are enrolled in abc program (formerly civicase). Any help would be appreciated!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Need help finding values in db
October 21, 2009, 02:54:02 pm
Dave D at Physician Health Program has coded a Case Summary report which is probably a good starting point for your work. It's in their repository:
http://svn.civicrm.org/php/trunk/custom_php/CRM/Report/Form/Case/Summary.php

... and the corresponding smarty template at:
http://svn.civicrm.org/php/trunk/custom_templates/CRM/Report/Form/Case/Summary.tpl
(this currently just a pointer to the standard report tpl - so not needed if you modify the tpl assignment in php file)

Link from Case (program) to client (program participant) is in the aptly named civicrm_case_contact table :-)
Protect your investment in CiviCRM by  becoming a Member!

leapywca

  • Guest
Re: Need help finding values in db
October 26, 2009, 01:22:04 pm
Alright, so we're still having some troubles with this query. Although this time it's not so much with the query itself but rather what we're going to do with it. We are still trying to fill in the same values as described above. Right now our query returns values such as 'apex 5' where apex will correspond to AP and then 5 is the value associated with 'program abc' from the table. However the query only returns cities that have values. Therefore if there's nobody from city CR then the table will be off. Also, have to translate cities from the query to cities across top of table i.e. 'apex'='AP' and then fill in corresponding value, which is where the buildRows function comes in. We would like to override it in our custom report.

So what we need to know is where to find the buildRows function - i.e. which class is it defined in?

Any help would be greatly appreciated!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Need help finding values in db
October 26, 2009, 03:27:22 pm
CRM_Report_Form_Form::buildRows() - line 1151 (at least in trunk). Grep is definitely your friend when trying to find stuff. I did:

grep -rn buildRows . | grep -v svn

from CRM/Report directory :-)
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Need help finding values in db

This forum was archived on 2017-11-26.