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 (Moderator: Dave Greenberg) »
  • Thank You Letter for Contributions
Pages: [1]

Author Topic: Thank You Letter for Contributions  (Read 2879 times)

fmcooke

  • I’m new here
  • *
  • Posts: 18
  • Karma: 2
    • Beta Consulting
  • CiviCRM version: 4.3.5
  • CMS version: Joomla! 2.5.13
  • MySQL version: N/A
  • PHP version: PHP Version 5.3.10-1ubuntu3.1
Thank You Letter for Contributions
August 03, 2013, 01:14:26 pm
Hi All,

I have read the following post on how to add a contribution field in the thank you letter.

http://forum.civicrm.org/index.php/topic,25039.msg105638.html#msg105638

As It was missing financial_type_ id I included in crm/utils/tokens.php

as Dlobo explained.

The code looks like:

  static function getContributionTokenDetails($contributionIDs,
    $returnProperties = NULL,
    $extraParams      = NULL,
    $tokens           = array(),
    $className        = NULL
  ) {
    if (empty($contributionIDs)) {
      // putting a fatal here so we can track if/when this happens
      CRM_Core_Error::fatal();
    }


    $details = array();

    // no apiQuery helper yet, so do a loop and find contribution by id
    foreach ($contributionIDs as $contributionID) {

      $dao = new CRM_Contribute_DAO_Contribution();
      $dao->id = $contributionID;

      if ($dao->find(TRUE)) {

        $details[$dao->id] = array();
        CRM_Core_DAO::storeValues($dao, $details[$dao->id]);


        // Corrected (paymente_instrument_id)
        // do the necessary transformation
        if (CRM_Utils_Array::value('payment_instrument_id', $details[$dao->id])) {
          $piId = $details[$dao->id]['payment_instrument_id'];
          $pis = CRM_Contribute_PseudoConstant::paymentInstrument();
          $details[$dao->id]['payment_instrument_id'] = $pis[$piId];
        }

if (CRM_Utils_Array::value('campaign_id', $details[$dao->id])) {
          $campaignId = $details[$dao->id]['campaign_id'];
          $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
          $details[$dao->id]['campaign'] = $campaigns[$campaignId];
        }

      // Added in order to get contribution_type_id "PDF Letter Contribution Tokens Forum Ticket" for Financial_type_id

        if (CRM_Utils_Array::value('financial_type_id', $details[$dao->id])) {
          $financialtypeId = $details[$dao->id]['financial_type_id'];
          $ftis = CRM_Contribute_PseudoConstant::financialType();
          $details[$dao->id]['financial_type_id'] = $ftis[$financialtypeId];
        }


With this modification I have hardcoded the original token.php Is there any way that I can use an extension or something in order to allow the original code to live with my new code included? (I also corrected a small typing mistake in the 'payment_instrument_id' variable (As it was missing the id and was not showing the correct value)


Thanks for your advice.

Kind regards,
Federico



« Last Edit: August 03, 2013, 01:21:04 pm by fmcooke »
Kind Regards,
Federico Cooke

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Thank You Letter for Contributions
August 05, 2013, 04:48:29 pm
Federico - sounds like these changes are appropriate for core so best would be if you create an issue in the issue tracker and either attach a patch OR (even better) submit a pull request ("PR") to https://github.com/civicrm/civicrm-core (against the 'master' branch).
Protect your investment in CiviCRM by  becoming a Member!

fmcooke

  • I’m new here
  • *
  • Posts: 18
  • Karma: 2
    • Beta Consulting
  • CiviCRM version: 4.3.5
  • CMS version: Joomla! 2.5.13
  • MySQL version: N/A
  • PHP version: PHP Version 5.3.10-1ubuntu3.1
Re: Thank You Letter for Contributions
August 05, 2013, 06:09:36 pm
Dave,

I will try it, I have never done it before! (There is always a first time I!!!) I have been working on this and I made another improvement (That I would like someone who knows to review it) which is present the custom values as well!.

The code said to include a Hook (To convert custom fields acording to business rules) that I think it could be usefull to include! (I have no idea on how to do this call!!!) as it is 4 lines above (I end up needing it!)

Dave I am not a programmer that s why I would like someone to review the code!

Kind regards,
Federico



Kind Regards,
Federico Cooke

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Thank You Letter for Contributions
August 06, 2013, 12:50:08 pm
Federico - I reviewed your changes so go ahead and add an issue to the issue tracker with a 'diff' / patch file attached to it (i'll deal w/ GitHub etc.). One modification ... I think the Financial Type 'label' variable should not overwrite $details[$dao->id]['financial_type_id'], but rather add a new value to the array (as was done w/ campaigns):

Code: [Select]
$details[$dao->id]['financial_type'] = $ftis[$financialtypeId];

So now both the financial_type_id and the financial_type are available. We should probably do the same w/ payment instrument (which I guess won't mess up anyone since the existing code was evidently broken in any case).
Protect your investment in CiviCRM by  becoming a Member!

fmcooke

  • I’m new here
  • *
  • Posts: 18
  • Karma: 2
    • Beta Consulting
  • CiviCRM version: 4.3.5
  • CMS version: Joomla! 2.5.13
  • MySQL version: N/A
  • PHP version: PHP Version 5.3.10-1ubuntu3.1
Re: Thank You Letter for Contributions
August 18, 2013, 07:19:34 am
Dave,

I have created the issue CRM-13241 Thank You Letter for Contributions - Tokens details missing -getContributionTokenDetails. I have not included the code as I want to complete it with you coments and test it.

I hope I can do it during this week.

Thanks for your help.
Federico
Kind Regards,
Federico Cooke

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Thank You Letter for Contributions

This forum was archived on 2017-11-26.