From 53ddc10ca10d00d6be3e07105d166f035ff8f851 Mon Sep 17 00:00:00 2001 From: Civiware Solutions Date: Thu, 1 Nov 2018 22:16:25 +0530 Subject: [PATCH] use description not labels --- ftoverride.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ftoverride.php b/ftoverride.php index 0f57884..9a987b8 100644 --- a/ftoverride.php +++ b/ftoverride.php @@ -204,9 +204,9 @@ function ftoverride_civicrm_buildForm($formName, &$form) { $showElement = FALSE; } } + $form->assign('showElement', $showElement); - $financialTypes = []; - CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $form->getVar('_action')); + $financialTypes = ftoverride_get_financialType($form->getVar('_action')); $form->add( 'select', 'designation', @@ -249,9 +249,7 @@ function ftoverride_civicrm_buildForm($formName, &$form) { if (empty($designations)) { return; } - - $financialTypes = []; - CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $form->getVar('_action')); + $financialTypes = ftoverride_get_financialType($form->getVar('_action')); $designations = array_flip($designations); $financialTypes = array_intersect_key($financialTypes, $designations); $form->add( @@ -336,3 +334,18 @@ function ftoverride_get_designation($pageId) { ]); return $designations; } + +function ftoverride_get_financialType($action) { + $financialTypes = []; + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $action); + $result = civicrm_api3('FinancialType', 'get', [ + 'return' => ["description"], + 'description' => ['!=' => ""], + 'id' => ['IN' => array_keys($financialTypes)], + ]); + $descFinancialType = []; + if (!empty($result['values'])) { + $descFinancialType = array_column($result['values'], 'description', 'id'); + } + return $descFinancialType + $financialTypes; +}