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) »
  • Creating Invoice post-transaction
Pages: [1]

Author Topic: Creating Invoice post-transaction  (Read 7580 times)

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Creating Invoice post-transaction
April 19, 2008, 07:12:56 am
I need to create a way for an admin to view and print an invoice for a contribution after the transaction has taken place. Preferably, I would like to be able to do this in batches. There's no obvious way to achieve this, and I'm wondering if others have found an effective workaround. Here are the three ideas I've played with:

1) Expand the "view contribution" page: When reviewing contributions in CiviContribute, you can "view" a contribution, which gives you a page with all the contribution details. However it doesn't include general information about the user (contact details, address) that would be necessary for an invoice. Those fields are not available to the template by default, and based on a quick review of their generating pages, it would take a little work to make the address, etc. fields available. While this would give me a printer-friendly version of the page, it would not enable batch printing.

2) Create a profile: I tried creating a profile with individual details + contribution details, but mixing field types in a profile form is generally problematic. In this case, it recognizes there are multiple contributions for a single indiv, but it doesn't let you select a different contrib.

3) The thank you page given at the end of a contribution transaction basically includes all the pieces required for an invoice. So I played with whether I can "call" that page post-transaction, thinking the url variables would enable me to specify the contact_id and contribution id. But that page uses session variables, so it can't be called at a later point. Does anyone know if that page will accept different url variables such that I can reference the contact and contribution ids? I *think* that would be the cleanest and easiest way to accomplish what I need (except for the batch printing).

-Brian
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Creating Invoice post-transaction
April 20, 2008, 05:11:03 am
Unfortunately I don't think there's a quick and easy way to accomplish this. If you want to avoid any hacks to core code, you might consider writing a standalone PHP script which grabs the info you want using the CiviCRM APIs (check out civicrm_contact_search and civicrm_contribution_get to confirm that you can grab data for a contact and a contribution given their id's) - and renders a printable html page w/ the data. Then you can use a custom template to add links to that external script.

Another alternative is to create a new class under Contribute/Form - based on ContributionView.php, etc.
Protect your investment in CiviCRM by  becoming a Member!

prickeke

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 4
Re: Creating Invoice post-transaction
May 20, 2008, 11:16:51 pm
I have some PHP scripts that create receipts for donations (contributions) after the fact.  We don't (yet) take donations through CiviCRM, only enter the checks we receive in the mail manually.

Let me know if you want these scripts or if you have already created a solution.

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Creating Invoice post-transaction
May 21, 2008, 04:51:40 am
I would definitely be interested in them. I haven't had a chance to give this issue much time lately, but still need to address it. Thanks.
-Brian
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

prickeke

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 4
Re: Creating Invoice post-transaction
May 21, 2008, 11:43:50 am
I'll try to get back on here and attach some stuff in the next week or so (I have a really busy schedule, then vacation coming up till Tuesday).

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Creating Invoice post-transaction
June 16, 2008, 08:49:40 am
prickeke --
I'm planning on working on this project this week. Just wondered if I can get those scripts you referred to earlier.
thx,
-Brian
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

prickeke

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 4
Re: Creating Invoice post-transaction
June 17, 2008, 08:09:59 am
I've attached some scripts.  They depend on the fpdf package that comes (came?) with CiviCRM when I created them.  They also might use deprecated APIs, but not sure -- haven't looked into the new ones/which ones are deprecated.  Along with that, they use hacks to run SQL queries directly because the API didn't support what I wanted to do.

They were located under my civicrm main folder (crm) as follows:

/path_to_www_root/crm/sites/all/modules/pdf-reports/.

Description of files:
- preview_thank_you.php - Generates an official or preview thank-you letter with monthly donation totals listed on the side along with the most recent payment.  This file looks for a POST key called "submit_official."  If the name is official then it runs the official reports, otherwise it runs the preview reports.  The "official" version of the report are saved in the filesystem, whereas the preview versions are simply displayed in the browser.

!!!WARNING!!! - The official  (non-preview) version of the script (preview_thank_you.php) sets the thank-you date on contributions to the current date on the server it is run on.  !!!WARNING!!!  When you simply preview the reports it will not set the thank-you dates.

- tax_report.php - Runs the scripts to generate end of year tax reports or envelopes (for mailing).  I don't believe this one modifies anything in the database so it is safe to run whenever.  The reports show up in the browser and are not saved (as far as I can remember) in the filesystem

- thank_you.php - The worker file -- Has all the functions and data manipulation in it.  The other files include it and call the functions within.  All of our address and info is in the file but it's nothing you can't find in a search online, so I've left it so you can test it with the stuff in place.

It looks like you need a logo.png file in this same directory and also need another POST key called "thank_you_textarea" which, is the note to include in the thank-you output generated from a textarea HTML form element.  I used Drupal pages to generate the forms I needed and had it call the first two files depending on what I was doing.

These are all a mess and I have learned a lot about programming, style, etc. since I created these so please excuse the hacked up junk code. 

Let me know if there is any way further I can help.  (looks like it won't let me upload .php files so I am changing the extension to .txt)


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: Creating Invoice post-transaction
June 22, 2008, 01:54:06 am

There is now an issue for this: http://issues.civicrm.org/jira/browse/CRM-3227

I've also been using dompdf (http://www.digitaljunkies.ca/dompdf/) which makes it quite easy to print the email receipt as PDF.

I've checked in the first version of the code into trunk (its a big patch, so backport will be a bit messy)

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Creating Invoice post-transaction

This forum was archived on 2017-11-26.