show check number on View/edit contribution form
This commit is contained in:
parent
889293c1aa
commit
66082cc24e
@ -185,30 +185,14 @@ function checknumberpaymentmethod_civicrm_preProcess($formName, &$form) {
|
||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_preProcess
|
||||
*/
|
||||
function checknumberpaymentmethod_civicrm_buildForm($formName, &$form) {
|
||||
if ('CRM_Contribute_Form_AdditionalPayment' == $formName
|
||||
if (('CRM_Contribute_Form_AdditionalPayment' == $formName
|
||||
&& $form->getVar('_view') == 'transaction'
|
||||
&& ($form->getVar('_action') & CRM_Core_Action::BROWSE)
|
||||
&& ($form->getVar('_action') & CRM_Core_Action::BROWSE))
|
||||
|| 'CRM_Contribute_Form_Contribution' == $formName
|
||||
|| 'CRM_Contribute_Form_ContributionView' == $formName
|
||||
) {
|
||||
|
||||
$paymentInstrumentsFromSettings = civicrm_api3('Setting', 'getvalue', [
|
||||
'name' => 'check_payment_instrument_ids',
|
||||
]);
|
||||
$payments = $form->get_template_vars('payments');
|
||||
foreach ($payments as &$payment) {
|
||||
try {
|
||||
$checkNumber = civicrm_api3('FinancialTrxn', 'getvalue', [
|
||||
'return' => "check_number",
|
||||
'id' => $payment['id'],
|
||||
'payment_instrument_id' => ['IN' => $paymentInstrumentsFromSettings],
|
||||
]);
|
||||
if (!empty($checkNumber)) {
|
||||
$payment['payment_instrument'] .= " (#{$checkNumber})";
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
_checknumberpaymentmethod_alterpayments($payments);
|
||||
$form->assign('payments', $payments);
|
||||
}
|
||||
if ('CRM_Admin_Form_Preferences_Contribute' == $formName) {
|
||||
@ -272,3 +256,24 @@ function checknumberpaymentmethod_civicrm_pre($op, $objectName, $id, &$params) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _checknumberpaymentmethod_alterpayments(&$payments) {
|
||||
$paymentInstrumentsFromSettings = civicrm_api3('Setting', 'getvalue', [
|
||||
'name' => 'check_payment_instrument_ids',
|
||||
]);
|
||||
foreach ($payments as &$payment) {
|
||||
try {
|
||||
$checkNumber = civicrm_api3('FinancialTrxn', 'getvalue', [
|
||||
'return' => "check_number",
|
||||
'id' => $payment['id'],
|
||||
'payment_instrument_id' => ['IN' => $paymentInstrumentsFromSettings],
|
||||
]);
|
||||
if (!empty($checkNumber)) {
|
||||
$payment['payment_instrument'] .= " (#{$checkNumber})";
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user