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 CiviContribute (Moderator: Donald Lobo) »
  • Getting Offline Contributions to be counted in the Campaign Widget
Pages: [1]

Author Topic: Getting Offline Contributions to be counted in the Campaign Widget  (Read 1501 times)

letapjar

  • Guest
Getting Offline Contributions to be counted in the Campaign Widget
October 19, 2010, 06:29:30 am
We have just started our first  civicontribute campaign with an online campaign page.  However, we also have people donating funds
for this cause via checks.

Is there a "correct" way to get the campaign widget to show the actual campaign total (including the offline contributions)?
I noticed that the civicrm/CRM/Widget.php has the following query:

SELECT count( id ) as count,
       sum( total_amount) as amount
FROM   civicrm_contribution
WHERE  is_test = 0
AND    contribution_status_id = 1
AND    contribution_page_id = %1";

Can I safely set the contribution_page_id field for the offline donation to match the page id of the online ones?  Will this break anything else in the system somewhere?


letapjar

  • Guest
Re: Getting Offline Contributions to be counted in the Campaign Widget
October 20, 2010, 01:58:09 pm
Ok - In case anyone else wants to have this feature.  Baiscally we wanted to have donations made offline be counted in the totals shown by the widget generated by a contribution page.

Here is how we accomplished this: 

1) define a new contribution type for the fund raising effort where you want both online and offline funds raised.
2) when making the online page choose the new contribution type you just defined in step 1.

The CRM/widget/widget.php file needs the following modification:

Code: [Select]
/* letapjar: 10/20/2010 added this in to find contribution type to add in non-online donations in the widget totals
* need to find the contribution type id to include it inthe query below
*/
$ctquery = "SELECT DISTINCT contribution_type_id as ct FROM civicrm_contribution_page WHERE id = %1";
$params = array(1 => array($contributionPageID, 'Integer') );
$dao = CRM_Core_DAO::executeQuery($ctquery, $params);
if ($dao->fetch()){
  $contributionTypeID = $dao->ct;
  }
else $contributionTypeID = 0;

 /** letapjar: 10/20/2010
 * modified this query to include the contribution type id in the wehre clause to add up offline donations as well
 */
        $query = "
SELECT count( id ) as count,
       sum( total_amount) as amount
FROM   civicrm_contribution
WHERE  is_test = 0
AND    contribution_status_id = 1
AND    (contribution_page_id = %1 OR contribution_type_id = %2)";
        $params = array( 1 => array( $contributionPageID, 'Integer' ), 2 => array($contributionTypeID, 'Integer') ) ;

What this does - is to query the contribution page table to find the contribution type (which should be distinct since you defined a new type when you created the online fundraising page)

then when the widget queries the database to get the donor count and the total donations raised - it chooses all completed donations that are either associated with the online fundraising page OR that have the same contribution type (the new one you defined in step 1).

3) When you have offline donations - enter the new contribution as usual and just choose the same contribution type that you defined in step 1  - all offline contributions will show up in the widget's totals.

letapjar

  • Guest
Re: Getting Offline Contributions to be counted in the Campaign Widget
October 20, 2010, 02:03:39 pm
Sorry - just to clarify - the code section in the last post - gets inserted into the CRM/Widget/Widget.php file.

I have attached a version of this file to this post (with a .txt extension). 

To use it simply rename your Widget.php file to Widget.old.php and paste in the attsached file into the directory and remove the .txt extension

Marty

  • I post occasionally
  • **
  • Posts: 67
  • Karma: 14
    • Boulder County Arts Alliance
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.37
  • PHP version: 5.4.27
Re: Getting Offline Contributions to be counted in the Campaign Widget
November 16, 2010, 11:45:02 am
Thanks for providing a solution.  I definitely need to allow offline contributions to be counted in the campaign widget.  It seems to me this should be the normal behavior and should be integrated into the base code.  Is there a real reason (use case?) why someone would want to exclude contributions of the same type from other sources?

bpayst

  • I’m new here
  • *
  • Posts: 16
  • Karma: 3
Re: Getting Offline Contributions to be counted in the Campaign Widget
December 03, 2010, 06:34:51 am
thanks for this, I've been looking for it for some time but hadn't thought to look in the Widget.php for some reason. I my opinion this is the way this feature should work.

tobiaseigen

  • I post frequently
  • ***
  • Posts: 151
  • Karma: 5
    • Kabissa - Space for Change in Africa
Re: Getting Offline Contributions to be counted in the Campaign Widget
December 09, 2010, 01:53:40 pm
I also need this. It seems to mejavascript:void(0); that the solution is to provide functionality to set contribution_page_id for each contribution.

I was able to edit contribution_page_id manually in phpmyadmin for a few contributions and it now displays those donations on the widget.

Places where it would be good to be able to set this via the interface:
* import contributions
* contributions search results
* edit contribution

I'd be willing to contribute to this - who else is game?

Cheers,

Tobias
Kabissa - Space for Change in Africa http://kabissa.org

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Getting Offline Contributions to be counted in the Campaign Widget
December 30, 2010, 10:59:04 am
Other than import, this functionality will be available in the upcoming 3.3.2 release:
http://issues.civicrm.org/jira/browse/CRM-7290

You can select Online Contribution Page from a drop-down when creating or editing a contribution record (from the "Additional Information" pane). Also the associated contribution page will be displayed when viewing a contribution record.
« Last Edit: December 30, 2010, 11:13:22 am by Donald Lobo »
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Getting Offline Contributions to be counted in the Campaign Widget

This forum was archived on 2017-11-26.