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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Update existing contribution
Pages: [1]

Author Topic: Update existing contribution  (Read 1665 times)

Prolineserver

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.0.5
  • CMS version: Drupal 7.7
  • MySQL version: 5.1.49
  • PHP version: 5.0.51a-24+lenny5
Update existing contribution
December 01, 2010, 03:11:48 pm
Hej,

according to the documentation an update of an existing contribution works just in the as adding a new contribution but with an additional id-field as a parameter:http://wiki.civicrm.org/confluence/display/CRMDOC32/Contribution+APIs#ContributionAPIs-civicrmcontributionadd%28%26%24params%29 A minimal example looks e.g. like this:


Code: [Select]
$params = array(
  'id' => 123,
  'trxn_id' => 12345,
  'invoice_id' => 'OCR12345'
);
$contribution =& civicrm_contribution_add($params);
print_r($contribution);
The returned array is quite empty and looks like
Code: [Select]
Array (
 [id] => 123
 [contact_id] =>
 [contribution_type_id] =>
 [contribution_page_id] =>
 [payment_instrument_id] =>
 [receive_date] =>
 [non_deductible_amount] =>
 [total_amount] =>
 [fee_amount] =>
 [net_amount] =>
 [trxn_id] => 12345
 [invoice_id] => OCR12345
 [currency] => SEK
 [cancel_date] =>
 [cancel_reason] =>
 [receipt_date] =>
 [thankyou_date] =>
 [source] =>
 [amount_level] =>
 [contribution_recur_id] =>
 [honor_contact_id] =>
 [is_test] =>
 [is_pay_later] =>
 [contribution_status_id] =>
 [honor_type_id] =>
 [address_id] =>
 [check_number] =>
)

If I look in the database, the civicrm_contribution-table seems to be updated properly. However, if I have a look at the contribution in civicrm via civicrm/contact/view/contribution?action=view&reset=1&id=123&cid=234&context=home the view is messed up. Firebug shows me that the table "<table class="crm-info-panel">" is actually ending up in the container "<div id="sidebar-right" class="sidebar">" instead of the correct place. In addition, I get an additional item in the list of the recent items with the title "- ( - )" and a link to civicrm/contact/view/contribution?action=view&reset=1&id=123&cid=&context=home, i.e. the contact id in this link is missing.

I also tried to query all the params of the contribution first, and than change the updated parameters and pass this array to the add function. In this case, the additional recent items element does not appear, however, the layout in the view of the contribution still messes up. Any ideas of what I do wrong?

Regards, Holger

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Update existing contribution
December 01, 2010, 09:15:35 pm
to retrieve more information related to contribution, you might want to use civicrm_contribution_get( $params ) api

Code: [Select]
require_once 'api/v2/Contribution.php';
$params = array( 'contribution_id' => 1 );
$contribution = civicrm_contribution_get( $params );
             
print_r( $contribution );
exit();
       
kiran
       
You Are Designed To Choose... Defined By Choice.

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Update existing contribution
December 01, 2010, 10:27:25 pm
Prolineserver :
Quote
I get an additional item in the list of the recent items with the title "- ( - )" and a link to civicrm/contact/view/contribution?action=view&reset=1&id=123&cid=&context=home, i.e. the contact id in this link is missing.

This is happening because recently viewed link is getting messed up for the lack of parameters that you are providing in $params.
I 've fixed it for 3.3. You may have a look at the patch here .

Hope that helps!
Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Prolineserver

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.0.5
  • CMS version: Drupal 7.7
  • MySQL version: 5.1.49
  • PHP version: 5.0.51a-24+lenny5
Re: Update existing contribution
December 02, 2010, 03:16:15 pm
@Kiran retrieving information for a contribution works fine, I'm talking about updating and adding information.

@Yashodha Thanks, I'll try the patch. Do I have to provide all parameters? The documentation just says that the id field is mandatory, thatswhy I skipped the rest.

Thanks, Holger

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Update existing contribution
December 02, 2010, 08:31:01 pm
Prolineserver :
Quote
Do I have to provide all parameters?

Nope just the id and all the fields that you wanna update

-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Prolineserver

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.0.5
  • CMS version: Drupal 7.7
  • MySQL version: 5.1.49
  • PHP version: 5.0.51a-24+lenny5
Re: Update existing contribution
December 05, 2010, 07:33:52 am
Hej Yashodha,

The patch works, and I don't get the empty item anymore. However, the issue with the messed up view of the contribution remains (see attachment). Where does it come from, in the contribution table all entries look fine...

Regards, Holger

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Update existing contribution
December 05, 2010, 08:17:21 pm
Prolineserver :
Quote
the issue with the messed up view of the contribution remains
You might wanna login/logout and new recently viewed block won't have those erroneous items.

HTH
-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Prolineserver

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.0.5
  • CMS version: Drupal 7.7
  • MySQL version: 5.1.49
  • PHP version: 5.0.51a-24+lenny5
Re: Update existing contribution
December 05, 2010, 11:23:17 pm
Hej Yashodha,

I'm not worried anymore about the list of the last items, this issue is fine now. I've trouble with the main window: The details of the contribution do not appear between the two edit buttons as they did before the update of the contribution. Instead, this block becomes the last element of the page, i.e. after the footer and, if not empty, the right sidebar. And logging out and in does not make a difference.

Regards, Holger

Prolineserver

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.0.5
  • CMS version: Drupal 7.7
  • MySQL version: 5.1.49
  • PHP version: 5.0.51a-24+lenny5
Re: Update existing contribution
December 07, 2010, 02:46:21 pm
Hej, it seems that the invoice_id-parameter causes the trouble. If I empty this field manually in the DB, the messed up layout recovers, if I set it back to some value the problem arises again. Is the invoice_id some internal parameter connected to another table and since this id is invalid, thing go wrong? So far, I didn't find any table referring to this id.

Regards, Holger

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Update existing contribution
December 11, 2010, 04:47:51 am
Hello Holger,

Could you please try to replicate issue on our public demo site : http://drupal.demo.civicrm.org/

You could easily set/update invoice id for any contribution from UI.
( unless and until contribution is not online/credit card and completed )

click on 'Edit' action link/button for respective contribution and check 'Additional Details'  section you could find 'Invoice ID' field.

thanks

kiran
You Are Designed To Choose... Defined By Choice.

Prolineserver

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.0.5
  • CMS version: Drupal 7.7
  • MySQL version: 5.1.49
  • PHP version: 5.0.51a-24+lenny5
Re: Update existing contribution
December 11, 2010, 06:06:35 am
Mhh, I just updated from 3.2.5 to 3.3.1 and it seems the problem has gone.... So thanks for your help ;) /Holger

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Update existing contribution

This forum was archived on 2017-11-26.