Skip to content

Commit

Permalink
Don't bypass hooks when updating contribution receipt/thankyou date
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Nov 8, 2017
1 parent 87e7278 commit 5805be4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions CRM/Contribute/Form/Task/PDFLetterCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,19 @@ public static function postProcess(&$form, $formValues = NULL) {
}
$contact['is_sent'][$groupBy][$groupByID] = TRUE;
}
// update dates (do it for each contribution including grouped recurring contribution)
//@todo - the 2 calls below bypass all hooks. Using the api would possibly be slower than one call but not than 2
// Update receipt/thankyou dates
$contributionParams = array('id' => $contributionId);
if ($receipt_update) {
$result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'receipt_date', $nowDate);
if ($result) {
$receipts++;
}
$contributionParams['receipt_date'] = $nowDate;
}
if ($thankyou_update) {
$result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'thankyou_date', $nowDate);
if ($result) {
$thanks++;
$contributionParams['thankyou_date'] = $nowDate;
}
if ($receipt_update || $thankyou_update) {
$result = civicrm_api3('Contribution', 'create', $contributionParams);
if (empty($result['is_error'])) {
$receipt_update ? $receipts++ : NULL;
$thankyou_update ? $thanks++ : NULL;
}
}
}
Expand Down

0 comments on commit 5805be4

Please sign in to comment.