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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Serializing Receipts
Pages: [1]

Author Topic: Serializing Receipts  (Read 1035 times)

zlex

  • Guest
Serializing Receipts
April 02, 2009, 10:04:56 pm
I am undertaking the task of modifying CiviCRM 2.0.7 to serialize receipts for Canadian donations. I have some php programming ability, but I am not a programmer by any measure.

I've managed to work out a lot for one day, and really, I can't believe I made it this far at all, but now I am totally stumped  ???

I have managed to get the serializing working for the addition of offline contributions, and the editing of already existing contributions, but I'm missing something somewhere for online contributions.

I think I need to modify the CRM_Contribute_BAO_Contribution object to include my new receipt_id parameter, but this whole DAO/BAO object business is a little confusing to me. I've edited the DAO contribution object to include the reciept_id parameter, I've created the appropriate column inside the contributions table, and I am populating that parameter logically inside CRM/Contribute/Form/Contribution.php in the postProcess function where it checks for if_email_receipt. Maybe I need to move that somewhere else?

That all works fine. I am not using any SQL queries to force anything into the database, it is updating the dao object and storing itself in the db. The receipt pulls the param and dumps it into the tpl file.

I had a feeling that it wouldn't work for online contributions, since it's clear that postProcess adds receipt_date to the DAO object and that is not stored for online donations.

I don't even know where to start. Can anyone point me in any kind of direction? I realize that CiviCRM 2.0.7 is no longer supported....but any help would be greatly appreciated.

Below is my code.  :'(


Code: [Select]
        if ( $formValues['is_email_receipt'] ) {
            $params['receipt_date'] = date("Y-m-d");

+ //Check if a reciept has been issued, leave it alone if it has
+ if (isset($this->_id)) {
+ $query = "SELECT id, receipt_id FROM civicrm_contribution WHERE id = {$this->_id} LIMIT 1";
+ $dao = CRM_Core_DAO::executeQuery( $query, CRM_Core_DAO::$_nullArray );
+ $dao->fetch();
+ if (!is_null($dao->receipt_id)) {
+ $newReceipt_id = $dao->receipt_id;
+ }
+ }
+ //If receipt not issued, issue new reciept
+ if ( (!isset($this->_id)) || (is_null($dao->receipt_id)) ) {
+ //Query db to find last receipt#
+ $query = "SELECT receipt_id FROM civicrm_contribution WHERE receipt_id IS NOT NULL ORDER BY receipt_id DESC LIMIT 1";
+ $dao = CRM_Core_DAO::executeQuery( $query, CRM_Core_DAO::$_nullArray );
+ $dao->fetch();
+ $newReceipt_id = $dao->receipt_id + 1;
+ }

+ //Store in params
+          $params['receipt_id'] = $newReceipt_id;
        }

I have also edited the DAO class to include reciept_id, and message.tpl, but I don't think the problem is there.
« Last Edit: April 02, 2009, 10:37:53 pm by zlex »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Serializing Receipts
April 03, 2009, 07:19:43 am

a few questions:

1. whats the payment processor u r using? since paypal standard etc send a receipt only after we get the confirmation

2. any idea why you dont use the contribution id as the receipt id? both are sequentially increasing numbers (but one of them is nicely managed and maintained by the db :)

3. u really should move to 2.2 :)

4. jump on irc, and might be easier/quicker to help u there

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

zlex

  • Guest
Re: Serializing Receipts
April 03, 2009, 10:35:25 am
1] The payment processor being used is Ticketmaster's IATS service. Looking at the code there is a check on error codes returned. I'm not 100% sure how that is handled by the rest of the CiviCRM system, but I would assume CiviCRM is not sending out receipts for transactions that produce error codes. If it is still sending out receipts then that is something I will have to remedy.

2] This was my initial thought, contribution_id + offset. And it's how I initially figured out how to put a field into the message.tpl file. But there are a few reasons why I can't use the contribution id. One of which includes the fact that my client wants the ability to set pending status's for offline donations received via checks, which will cause a gap in the serials if a check bounces. But, the major reason is that eventually they want to use this system to manage multiple branches of their charity, which will require separate serial sequences for contributions.

3. I know :) But, I picked up this project after the previous designers did an awful job with their Drupal 5.x system, never having worked with Drupal before I was weary about upgrading to 6.x off the bat. Which turned out to be a good thing as many of the critical modules they use are still in heavy development for 6.x. If I had known initially that CiviCRM had stopped support for 5.x I would have probably made a different design decision, and patched up those modules myself. I suspect that in the near future they will want to upgrade.


4] Thanks, I will!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Serializing Receipts

This forum was archived on 2017-11-26.