From e5ed33cf7c57709aadf804c1062de34bac73d860 Mon Sep 17 00:00:00 2001 From: Madhu S R <madhu.sr@vtigersolutions.com> Date: Mon, 29 Apr 2024 18:38:03 +0530 Subject: [PATCH] Handled the decimal field values to user preffered format --- include/ListView/ListViewController.php | 3 ++- layouts/v7/modules/Vtiger/DetailViewBlockView.tpl | 3 +++ layouts/v7/modules/Vtiger/uitypes/Number.tpl | 3 ++- layouts/v7/modules/Vtiger/uitypes/StringDetailView.tpl | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/ListView/ListViewController.php b/include/ListView/ListViewController.php index 233f3eb15..832ad9db6 100644 --- a/include/ListView/ListViewController.php +++ b/include/ListView/ListViewController.php @@ -405,7 +405,8 @@ class ListViewController { } } } elseif ($fieldDataType == 'double') { - $value = decimalFormat($value); + //Converting the decimal value to user preferred format, considering number of decimals and decimal separator + $value = CurrencyField::convertToUserFormat(decimalFormat($value)); } elseif($fieldDataType == 'url') { $matchPattern = "^[\w]+:\/\/^"; preg_match($matchPattern, $rawValue, $matches); diff --git a/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl b/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl index f2a99adfe..a9e65902f 100644 --- a/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl +++ b/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl @@ -105,6 +105,9 @@ {assign var=FIELD_VALUE value=$FIELD_MODEL->get('fieldvalue')} {if $fieldDataType eq 'multipicklist'} {assign var=FIELD_DISPLAY_VALUE value=$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'))} + {else if $fieldDataType eq 'double'} + <!-- Converting the decimal value to user format, considering the number of decimals and decimal separator and assigning the value--> + {assign var=FIELD_DISPLAY_VALUE value=Vtiger_Util_Helper::toSafeHTML(CurrencyField::convertToUserFormat($FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'))))} {else} {assign var=FIELD_DISPLAY_VALUE value=Vtiger_Util_Helper::toSafeHTML($FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue')))} {/if} diff --git a/layouts/v7/modules/Vtiger/uitypes/Number.tpl b/layouts/v7/modules/Vtiger/uitypes/Number.tpl index d7d792b43..3a2370e60 100644 --- a/layouts/v7/modules/Vtiger/uitypes/Number.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/Number.tpl @@ -15,7 +15,8 @@ {if $MODULE eq 'HelpDesk' && ($FIELD_MODEL->get('name') eq 'days' || $FIELD_MODEL->get('name') eq 'hours')} {assign var="FIELD_VALUE" value=$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'))} {else if $FIELD_MODEL->getFieldDataType() eq 'double'} - {assign var="FIELD_VALUE" value=$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'))} + <!-- Converting the decimal value to user format, considering the number of decimals and decimal separator --> + {assign var="FIELD_VALUE" value=CurrencyField::convertToUserFormat($FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue')))} {else} {assign var="FIELD_VALUE" value=$FIELD_MODEL->get('fieldvalue')} {/if} diff --git a/layouts/v7/modules/Vtiger/uitypes/StringDetailView.tpl b/layouts/v7/modules/Vtiger/uitypes/StringDetailView.tpl index 6ece8c7be..c057adaca 100644 --- a/layouts/v7/modules/Vtiger/uitypes/StringDetailView.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/StringDetailView.tpl @@ -41,6 +41,9 @@ {/if} {else if $FIELD_MODEL->get('name') eq 'signature'} {decode_html($FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'), $RECORD->getId(), $RECORD))} +{else if $FIELD_MODEL->getFieldDataType() eq 'double'} + <!-- Converting the decimal value to user format, considering the number of decimals and decimal separator --> + {CurrencyField::convertToUserFormat($FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'), $RECORD->getId(), $RECORD))} {else} {$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'), $RECORD->getId(), $RECORD)} {/if} -- GitLab