return;
}
$whereTable = $fields[$fldName];
- $value = trim($value);
+ if (!is_array($value)) {
+ $value = trim($value);
+ }
$dataType = "String";
if (!empty($whereTable['type'])) {
$form->add('text', 'contribution_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
- // Adding Cancelled Contribution fields -- CRM-21343
- $form->add('text', 'contribution_cancel_reason', ts('Cancellation / Refund Reason'), array('size' => 40));
+ $form->addField('cancel_reason');
CRM_Core_Form_Date::buildDateRange($form, 'contribution_cancel_date', 1, '_low', '_high', ts('From:'), FALSE);
$form->addElement('hidden', 'contribution_cancel_date_range_error');
*
* Generated from xml/schema/CRM/Contribute/Contribution.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:45a20d00d01766a61687cbac5cef1482)
+ * (GenCodeChecksum:eec525df6c3c6151861750217f3ebe5d)
*/
/**
'cancel_reason' => [
'name' => 'cancel_reason',
'type' => CRM_Utils_Type::T_TEXT,
- 'title' => ts('Cancel Reason'),
+ 'title' => ts('Cancellation / Refund Reason'),
'import' => TRUE,
'where' => 'civicrm_contribution.cancel_reason',
'headerPattern' => '/(cancel.?)?reason/i',
*/
protected $_prefix = "contribute_";
+
+ /**
+ * Explicitly declare the entity api name.
+ */
+ public function getDefaultEntity() {
+ return 'Contribution';
+ }
+
/**
* Processing needed for buildForm and later.
*/
{include file="CRM/Contribute/Form/PCP.js.tpl"}
</td>
<td>
- {$form.contribution_cancel_reason.label}<br />
- {$form.contribution_cancel_reason.html}
+ {$form.cancel_reason.label}<br />
+ {$form.cancel_reason.html}
</td>
</tr>
<tr>
'form_value' => array('cancel_reason' => 'Invalid Credit Card Number'),
'expected_count' => 1,
'expected_contribution' => array($Contribution3['id']),
- 'expected_qill' => "Cancel Reason Like '%Invalid Credit Card Number%'",
+ 'expected_qill' => "Cancellation / Refund Reason Like '%Invalid Credit Card Number%'",
),
// Case 3: Search for Cancelled Date and Cancelled Reason
array(
'form_value' => array('cancel_date' => date('Y-m-d'), 'cancel_reason' => 'Insufficient funds'),
'expected_count' => 1,
'expected_contribution' => array($Contribution1['id']),
- 'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'ANDCancel Reason Like '%Insufficient funds%'",
+ 'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'ANDCancellation / Refund Reason Like '%Insufficient funds%'",
),
);
95 => 'Invoice Reference',
96 => 'Invoice Number',
97 => 'Currency',
- 98 => 'Cancel Reason',
+ 98 => 'Cancellation / Refund Reason',
99 => 'Receipt Date',
100 => 'Product Name',
101 => 'SKU',
}
}
+ /**
+ * Test cancel reason works as a filter.
+ */
+ public function testFilterCancelReason() {
+ $params = $this->_params;
+ $params['cancel_date'] = 'yesterday';
+ $params['cancel_reason'] = 'You lose sucker';
+ $this->callAPISuccess('Contribution', 'create', $params);
+ $params = $this->_params;
+ $params['cancel_date'] = 'yesterday';
+ $params['cancel_reason'] = 'You are a winner';
+ $this->callAPISuccess('Contribution', 'create', $params);
+ $this->callAPISuccessGetCount('Contribution', ['cancel_reason' => 'You are a winner'], 1);
+ }
+
/**
* We need to ensure previous tested behaviour still works as part of the api contract.
*/
<field>
<name>cancel_reason</name>
<type>text</type>
+ <title>Cancellation / Refund Reason</title>
<import>true</import>
+ <export>true</export>
<headerPattern>/(cancel.?)?reason/i</headerPattern>
<html>
<type>Text</type>
+ <size>40</size>
</html>
<add>1.3</add>
</field>