}
$result = civicrm_api3('Contribution', 'get', ['id' => $id]);
// lab.c.o mail#46 - show labels, not values, for custom fields with option values.
- if (!empty($messageToken)) {
+ if (!empty($messageToken['contribution'])) {
foreach ($result['values'][$id] as $fieldName => $fieldValue) {
if (strpos($fieldName, 'custom_') === 0 && array_search($fieldName, $messageToken['contribution']) !== FALSE) {
$result['values'][$id][$fieldName] = CRM_Core_BAO_CustomField::displayValue($result['values'][$id][$fieldName], $fieldName);
*
* @param array $contributionIds
*/
- public function setContributionIds($contributionIds) {
- $this->_contributionIds = $contributionIds;
+ public function setContributionIds(array $contributionIds): void {
+ $this->ids = $contributionIds;
}
/**
/**
* Process the form after the input has been submitted and validated.
+ *
+ * @throws \CRM_Core_Exception
*/
public function postProcess() {
$formValues = $this->controller->exportValues($this->getName());
}
// a placeholder in case the separator is common in the string - e.g ', '
$separator = '****~~~~';
- $groupBy = $formValues['group_by'];
+ $groupBy = $this->getSubmittedValue('group_by');
// skip some contacts ?
$skipOnHold = $this->skipOnHold ?? FALSE;
$skipDeceased = $this->skipDeceased ?? TRUE;
- $contributionIDs = $this->getVar('_contributionIds');
+ $contributionIDs = $this->getIDs();
if ($this->isQueryIncludesSoftCredits()) {
$contributionIDs = [];
$result = $this->getSearchQueryResults();
//CRM-19761
if (!empty($html)) {
- $type = $formValues['document_type'];
+ $type = $this->getSubmittedValue('document_type');
if ($type === 'pdf') {
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
/**
* Build the form object.
+ *
+ * @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
$this->add('checkbox', 'is_email_receipt', ts('Send e-mail receipt'));
$this->setDefaults(['is_email_receipt' => 1]);
- $contribIDs = implode(',', $this->_contributionIds);
+ $contribIDs = implode(',', $this->getIDs());
$query = "
SELECT c.id as contact_id,
co.id as contribution_id,
* @throws \CRM_Core_Exception
*/
public function testPostProcess(): void {
- $this->createLoggedInUser();
- $this->_individualId = $this->individualCreate();
+ $this->createLoggedInUser();;
foreach (['docx', 'odt'] as $docType) {
$formValues = [
'is_unit_test' => TRUE,
],
];
- $contributionParams = [
- 'contact_id' => $this->_individualId,
- 'total_amount' => 100,
- 'financial_type_id' => 'Donation',
- ];
- $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
- $contributionId = $contribution['id'];
+ $contributionId = $this->createContribution();
/* @var $form CRM_Contribute_Form_Task_PDFLetter */
$form = $this->getFormObject('CRM_Contribute_Form_Task_PDFLetter', $formValues);
$form->setContributionIds([$contributionId]);
}
}
+ /**
+ * Test that no notice or errors occur if no contribution tokens are requested.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
+ */
+ public function testNoContributionTokens(): void {
+ $this->createLoggedInUser();
+ $formValues = [
+ 'html_message' => '{contact.display_name}',
+ 'document_type' => 'pdf',
+ ];
+ /* @var $form CRM_Contribute_Form_Task_PDFLetter */
+ $form = $this->getFormObject('CRM_Contribute_Form_Task_PDFLetter', $formValues);
+ $form->setContributionIds([$this->createContribution()]);
+ try {
+ $form->postProcess();
+ }
+ catch (CRM_Core_Exception_PrematureExitException $e) {
+ $html = $e->errorData['html'];
+ }
+ $this->assertStringContainsString('Mr. Anthony Anderson II', $html);
+ }
+
/**
* Test assignment of variables when using the group by function.
*
}
}
+ /**
+ * @return mixed
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
+ */
+ protected function createContribution() {
+ $contributionParams = [
+ 'contact_id' => $this->individualCreate(),
+ 'total_amount' => 100,
+ 'financial_type_id' => 'Donation',
+ ];
+ $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
+ $contributionId = $contribution['id'];
+ return $contributionId;
+ }
+
}
/**
* Test update pending contribution with sending a confirmation mail.
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
+ * @throws \Exception
*/
- public function testUpdatePendingContributionWithSendingEmail() {
+ public function testUpdatePendingContributionWithSendingEmail(): void {
$this->_individualId = $this->individualCreate();
$form = new CRM_Contribute_Form_Task_Status();