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) »
  • How to add the date a person has been added to a group as filter
Pages: [1]

Author Topic: How to add the date a person has been added to a group as filter  (Read 694 times)

sushil

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 0
    • Art of Living
  • CiviCRM version: 3.2
  • CMS version: Drupal
  • MySQL version: 5.1
  • PHP version: 5.2
How to add the date a person has been added to a group as filter
March 21, 2011, 08:11:17 am
Can someone help me please on how to add the date a person has been added to a group as filter in a report?

Also how we can add the same date as a display column

I believe this date is in the civicrm_subscription_history table but don't know how to specify it as a filter and a display column.

Thanks

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: How to add the date a person has been added to a group as filter
March 21, 2011, 09:18:00 pm
Hi,

Here is an simple example for you. This will add Group Subscription date as a field and a filter for Constituent Report (Summary).
Patch is against 3.4.aplha3 code base.
Code: [Select]
Index: CRM/Report/Form/Contact/Summary.php
===================================================================
--- CRM/Report/Form/Contact/Summary.php (revision 33248)
+++ CRM/Report/Form/Contact/Summary.php (working copy)
@@ -128,6 +128,25 @@
                                         ),
                                  ),
                           ),
+                   
+                   'civicrm_subscription_history' =>
+                   array( 'dao'    => 'CRM_Contact_DAO_SubscriptionHistory',
+                          'fields' =>
+                          array(
+                                'subscription_date' =>
+                                array( 'name'  => 'date',
+                                       'type'  => CRM_Utils_Type::T_DATE,
+                                       'title' => ts('Subscription Date') )
+                                 ),
+                          'filters' =>             
+                          array( 'subscription_date' =>
+                                 array( 'name'    => 'date',
+                                        'title'   => ts( 'Subscription Date' ),
+                                        'operatorType' => CRM_Report_Form::OP_DATE,
+                                        'type'         => CRM_Utils_Type::T_DATE
+                                        ),
+                                 ),
+                          ),
                    );
 
         $this->_tagFilter = true;
@@ -175,6 +194,8 @@
                    ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
                       {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
         
+        $this->_from .= " LEFT JOIN civicrm_subscription_history {$this->_aliases['civicrm_subscription_history']}
+                                 ON {$this->_aliases['civicrm_subscription_history']}.contact_id = {$this->_aliases['civicrm_contact']}.id ";
         if ( $this->_emailField ) {
             $this->_from .= "
             LEFT JOIN  civicrm_email {$this->_aliases['civicrm_email']}

Rajan

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • How to add the date a person has been added to a group as filter

This forum was archived on 2017-11-26.