|
|
|
@ -240,6 +240,9 @@ function ftoverride_civicrm_buildForm($formName, &$form) {
|
|
|
|
|
$submitValues = $form->_params;
|
|
|
|
|
if (!empty($submitValues['designation'])) {
|
|
|
|
|
$form->assign('contribution_designation', $submitValues['designation']);
|
|
|
|
|
if ($submitValues['designation'] == 'other_financial_type') {
|
|
|
|
|
$form->_params['contribution_note'] = $submitValues['designation_note'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -260,6 +263,11 @@ function ftoverride_civicrm_buildForm($formName, &$form) {
|
|
|
|
|
FALSE,
|
|
|
|
|
['class' => 'crm-select2']
|
|
|
|
|
);
|
|
|
|
|
$form->add(
|
|
|
|
|
'text',
|
|
|
|
|
'designation_note',
|
|
|
|
|
''
|
|
|
|
|
);
|
|
|
|
|
CRM_Core_Region::instance('page-body')->add(array(
|
|
|
|
|
'template' => 'CRM/Contribute/Form/ContributionMain/common.tpl',
|
|
|
|
|
));
|
|
|
|
@ -280,8 +288,12 @@ function ftoverride_civicrm_pre($op, $objectName, $id, &$params) {
|
|
|
|
|
if ($op == 'create' && $objectName == 'Contribution' && !empty($params['contribution_page_id'])) {
|
|
|
|
|
$designation = CRM_Core_Smarty::singleton()->get_template_vars('contribution_designation');
|
|
|
|
|
if (!empty($designation)) {
|
|
|
|
|
if ($designation == 'other_financial_type') {
|
|
|
|
|
// Ignore
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$params['financial_type_id'] = $designation;
|
|
|
|
|
CRM_Core_Smarty::singleton()->assign('contribution_designation', '');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -304,6 +316,22 @@ function ftoverride_civicrm_pre($op, $objectName, $id, &$params) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements hook_civicrm_validateForm().
|
|
|
|
|
*
|
|
|
|
|
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm
|
|
|
|
|
*/
|
|
|
|
|
function ftoverride_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
|
|
|
|
|
if ('CRM_Contribute_Form_Contribution_Main' == $formName) {
|
|
|
|
|
if (!empty($fields['designation'])
|
|
|
|
|
&& $fields['designation'] == 'other_financial_type'
|
|
|
|
|
&& empty($fields['designation_note'])
|
|
|
|
|
) {
|
|
|
|
|
$errors['designation_note'] = ts('Please provide other information about designation.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements hook_civicrm_buildAmount().
|
|
|
|
|
*
|
|
|
|
@ -312,7 +340,7 @@ function ftoverride_civicrm_pre($op, $objectName, $id, &$params) {
|
|
|
|
|
function ftoverride_civicrm_buildAmount($pageType, &$form, &$amount) {
|
|
|
|
|
if (!empty($amount) && $form->_flagSubmitted) {
|
|
|
|
|
$submitValues = $form->_submitValues;
|
|
|
|
|
if (!empty($submitValues['designation'])) {
|
|
|
|
|
if (!empty($submitValues['designation']) && $submitValues['designation'] != 'other_financial_type') {
|
|
|
|
|
foreach ($amount as &$priceFields) {
|
|
|
|
|
foreach ($priceFields['options'] as &$options) {
|
|
|
|
|
$options['financial_type_id'] = $submitValues['designation'];
|
|
|
|
@ -338,6 +366,9 @@ function ftoverride_get_designation($pageId) {
|
|
|
|
|
function ftoverride_get_financialType($action) {
|
|
|
|
|
$financialTypes = [];
|
|
|
|
|
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $action);
|
|
|
|
|
if (empty($financialTypes)) {
|
|
|
|
|
return $financialTypes;
|
|
|
|
|
}
|
|
|
|
|
$result = civicrm_api3('FinancialType', 'get', [
|
|
|
|
|
'return' => ["description"],
|
|
|
|
|
'description' => ['!=' => ""],
|
|
|
|
@ -347,5 +378,5 @@ function ftoverride_get_financialType($action) {
|
|
|
|
|
if (!empty($result['values'])) {
|
|
|
|
|
$descFinancialType = array_column($result['values'], 'description', 'id');
|
|
|
|
|
}
|
|
|
|
|
return $descFinancialType + $financialTypes;
|
|
|
|
|
return $descFinancialType + $financialTypes + ['other_financial_type' => ts('Other')];
|
|
|
|
|
}
|
|
|
|
|