From e58217b034a1e087e22893960a972afb82be5fe0 Mon Sep 17 00:00:00 2001 From: Madhu S R <madhu.sr@vtigersolutions.com> Date: Tue, 30 Apr 2024 13:05:39 +0530 Subject: [PATCH] Fixes: The decimal field values are formatted according to user's 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 --- modules/Vtiger/uitypes/Double.php | 6 +++++- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/ListView/ListViewController.php b/include/ListView/ListViewController.php index 832ad9db6..233f3eb15 100644 --- a/include/ListView/ListViewController.php +++ b/include/ListView/ListViewController.php @@ -405,8 +405,7 @@ class ListViewController { } } } elseif ($fieldDataType == 'double') { - //Converting the decimal value to user preferred format, considering number of decimals and decimal separator - $value = CurrencyField::convertToUserFormat(decimalFormat($value)); + $value = 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 a9e65902f..f2a99adfe 100644 --- a/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl +++ b/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl @@ -105,9 +105,6 @@ {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 3a2370e60..d7d792b43 100644 --- a/layouts/v7/modules/Vtiger/uitypes/Number.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/Number.tpl @@ -15,8 +15,7 @@ {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'} - <!-- 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')))} + {assign var="FIELD_VALUE" value=$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 c057adaca..6ece8c7be 100644 --- a/layouts/v7/modules/Vtiger/uitypes/StringDetailView.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/StringDetailView.tpl @@ -41,9 +41,6 @@ {/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} diff --git a/modules/Vtiger/uitypes/Double.php b/modules/Vtiger/uitypes/Double.php index d53b532b2..1a8d4e9d2 100644 --- a/modules/Vtiger/uitypes/Double.php +++ b/modules/Vtiger/uitypes/Double.php @@ -24,7 +24,11 @@ class Vtiger_Double_UIType extends Vtiger_Base_UIType { * @return <Object> */ public function getDisplayValue($value, $record=false, $recordInstance=false) { - return decimalFormat($value); + //The value is formatting to the user preffered format + //The third parameter for the converTouserFormat() function is skipConversion. + //We set skipConversion to true because there's no need to convert the values for different currency formats. + $value = CurrencyField::convertToUserFormat(decimalFormat($value), null, true); + return $value; } /** -- GitLab