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) »
  • I am so close! Activity Reports with Group filtering
Pages: [1]

Author Topic: I am so close! Activity Reports with Group filtering  (Read 1223 times)

matthewboh

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 2
I am so close! Activity Reports with Group filtering
September 05, 2011, 12:48:58 pm
Alright - I've got it about 95% there.  I've updated the report, so you can select the Contact, Assignee or Target Name - here's that code

Code: [Select]
                                'civicrm_contact'      =>
                                array( 'dao'     => 'CRM_Contact_DAO_Contact',
                                       'fields'  =>
                                       array(
                                             'source_contact_id' =>
                                             array( 'name'       => 'id',
                                                    'alias'      => 'contact_civireport',
                                                    'no_display' => true,
                                                    ),
                                             'contact_source'    =>
                                              array( 'name'      => 'sort_name' ,
                                                     'title'     => ts( 'Source Contact Name' ),
                                                     'alias'     => 'contact_civireport',
                                                     'no_repeat' => true ),
                                             'contact_assignee' =>
                                             array( 'name'      => 'sort_name' ,
                                                     'title'     => ts( 'Assignee Contact Name' ),
                                                     'alias'     => 'civicrm_contact_assignee',
                                                     'default'   => true ),
                                              'contact_target'   =>
                                              array( 'name'      => 'sort_name' ,
                                                     'title'     => ts( 'Target Contact Name' ),
                                                     'alias'     => 'civicrm_contact_target',
                                                     'default'   => true ),
                                              ),
                                       
                                       'filters' =>             
                                       array( 'contact_source'   =>
                                              array('name'       => 'sort_name' ,
                                                    'alias'      => 'contact_civireport',
                                                    'title'      => ts( 'Source Contact Name' ),
                                                    'operator'   => 'like',
                                                    'type'       => CRM_Report_Form::OP_STRING ),
                                              'contact_assignee' =>
                                              array( 'name'      => 'sort_name' ,
                                                     'alias'     => 'civicrm_contact_assignee',
                                                     'title'     => ts( 'Assignee Contact Name' ),
                                                     'operator'  => 'like',
                                                     'type'      => CRM_Report_Form::OP_STRING ),
                                              'contact_target'   =>
                                              array( 'name'      => 'sort_name' ,
                                                     'alias'     => 'civicrm_contact_target',
                                                     'title'     => ts( 'Target Contact Name' ),
                                                     'operator'  => 'like',
                                                     'type'      => CRM_Report_Form::OP_STRING  ),
),
                                       ),
                              'civicrm_group' =>
                                    array( 'dao'    => 'CRM_Contact_DAO_GroupContact',
                                       'alias'  => 'cgroup',
                                        'filters' =>             
                                             array( 'gid' =>
                                                 array( 'name'          => 'group_id',
                                                    'title'         => ts( 'Group' ),
                                                    'operatorType' => CRM_Report_Form::OP_MULTISELECT,
                                                    'group'         => true,
                                                    'options'       => CRM_Core_PseudoConstant::group( ) ),
                                                 ),
                                             'grouping' => 'activity-names',
                                         ),
 

It builds the SQL Statement correctly EXCEPT for the where section that addresses the group.  It looks like this

Code: [Select]
contact_civireport.id IN (

SELECT DISTINCT cgroup_civireport.contact_id

FROM civicrm_group_contact cgroup_civireport

WHERE cgroup_civireport.group_id IN (7) AND cgroup_civireport.status = 'Added'
)

I want that value to change when I select different people - for example it should be the Assignee when I select that, or the Target ID when I select that.  It could even just do an OR between the fields - I've tested that and it works.

It looks like it gets generated here:

Code: [Select]
        $clauses = array( );
        foreach ( $this->_columns as $tableName => $table ) {
            if ( array_key_exists('filters', $table) ) {
               
                foreach ( $table['filters'] as $fieldName => $field ) {
                    $clause = null;
                    if ( $field['type'] & CRM_Utils_Type::T_DATE ) {
                        $relative = CRM_Utils_Array::value( "{$fieldName}_relative", $this->_params );
                        $from     = CRM_Utils_Array::value( "{$fieldName}_from"    , $this->_params );
                        $to       = CRM_Utils_Array::value( "{$fieldName}_to"      , $this->_params );
                       
                        $clause = $this->dateClause( $field['name'], $relative, $from, $to, $field['type'] );
                    } else {
                        $op = CRM_Utils_Array::value( "{$fieldName}_op", $this->_params );
                        if ( $op ) {
                            $clause =
                                $this->whereClause( $field,
                                                    $op,
                                                    CRM_Utils_Array::value( "{$fieldName}_value", $this->_params ),
                                                    CRM_Utils_Array::value( "{$fieldName}_min", $this->_params ),
                                                    CRM_Utils_Array::value( "{$fieldName}_max", $this->_params ) );
                        }
                    }
                   
                    if ( ! empty( $clause ) ) {
                        $clauses[] = $clause;
                    }
                }
            }
        }

Where is this decided?  How can I trace this?  Is this part of the Core functionality?  How can I make this work?

Thanks!

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: I am so close! Activity Reports with Group filtering
September 05, 2011, 03:17:35 pm
I'm pretty sure I added group filtering to the activity report - version for 3.4.6 - you could try replacing your 3.4.5 reports directory with the one in SVN (I think more than one file was affected)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

matthewboh

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 2
Re: I am so close! Activity Reports with Group filtering
September 06, 2011, 03:56:15 am
Hi Eileen - I'll take a look at it - but I had two big issues with the original report.  First, you couldn't do a summary report or even a detail report that included the duration.  That's an important capability for my users.  But that's easy to add back in.

The second biggest issue is the fact that the summary report sums up no matter if a person is listed as the one who entered the activity, was assigned the activity or is the target of the activity.  They really need to split that apart.

Since I'm doing this on a pro bono basis, it might take me a few days.  However, I do have to say they absolutely love CiviCRM - they came off a very expensive proprietary system and they're just amazed by this software.  Thanks for your contributions!

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: I am so close! Activity Reports with Group filtering
September 06, 2011, 12:28:37 pm
From memory I may have only changed one line in the report itself but more in Form.php in that folder
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

matthewboh

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 2
Re: I am so close! Activity Reports with Group filtering
September 18, 2011, 06:08:58 am
Finally got around to looking at this.  I need to be able to select Activities based on the different people associated with the Activity.  For example, I may just want to see what non-Administrators have entered or just the time that Trainers have completed, so I need to be able to get just those activities.

This builds the where clause so that the group filter is only applied to the person who entered the Activity.  I'm trying to figure out how to change this.  I think I'm going to add 3 different filters, one for each of the different people that can be associated with an Activity.  It seems as if the value in Query.php isn't set up to be changed, so going to try and power through that today.  Any suggestions gratefully received.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: I am so close! Activity Reports with Group filtering
September 18, 2011, 01:55:24 pm
I can't recommend anything obvious to help you today but will just flag that in 4.1 the activity_assignee, activity_target & source_contact_id are likely to be considated into a new activity_contact table. Something to keep on your radar when you upgrade
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • I am so close! Activity Reports with Group filtering

This forum was archived on 2017-11-26.