Skip to content

Commit

Permalink
Merge pull request #11257 from mattwire/CRM-21409_contribute_pdf_lett…
Browse files Browse the repository at this point in the history
…er_hooks

CRM-21409 Don't bypass hooks when updating contribution receipt/thankyou date
  • Loading branch information
eileenmcnaughton committed Nov 23, 2017
2 parents 43aeabc + fd57820 commit f045767
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions CRM/Contribute/Form/Task/PDFLetterCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,18 @@ 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) {
civicrm_api3('Contribution', 'create', $contributionParams);
$receipts = ($receipt_update ? $receipts + 1 : $receipts);
$thanks = ($thankyou_update ? $thanks + 1 : $thanks);
}
}

Expand Down

0 comments on commit f045767

Please sign in to comment.