diff --git a/data/CRMEntity.php b/data/CRMEntity.php index c5fcbae1ddc9432d07c244136c2b0f9893b40421..a842d82e3c42885557e39d322d60959b817e2e4b 100644 --- a/data/CRMEntity.php +++ b/data/CRMEntity.php @@ -570,7 +570,7 @@ class CRMEntity { } else { $fldvalue = $this->column_fields[$fieldname]; } - } elseif ($uitype == 7) { + } elseif ($uitype == 7 || $uitype == 9) { //strip out the spaces and commas in numbers if given ie., in amounts there may be , $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]); //trim($this->column_fields[$fieldname],","); if (in_array($datatype, array('N', 'NN'))) { diff --git a/layouts/v7/modules/Vtiger/resources/validation.js b/layouts/v7/modules/Vtiger/resources/validation.js index 16d59a3bb71da07477c3f4570ae6c07eeb4a1e3b..240ea286cda1ef3f7c9eca1cd2b50571aea4ee09 100644 --- a/layouts/v7/modules/Vtiger/resources/validation.js +++ b/layouts/v7/modules/Vtiger/resources/validation.js @@ -700,7 +700,7 @@ jQuery.validator.addMethod("PositiveNumber",function(value,element,params){ jQuery.validator.addMethod("percentage", function(value, element, params){ var decimalSeparator = app.getDecimalSeparator(); - var strippedValue = value.replace(/[^\d,]/g, ''); + var strippedValue = value.replace(decimalSeparator, ''); var spacePattern = /\s/; if(spacePattern.test(decimalSeparator)) { strippedValue = strippedValue.replace(/ /g, ''); diff --git a/modules/Vtiger/uitypes/Percentage.php b/modules/Vtiger/uitypes/Percentage.php index 93815bc501f969d5c404dbdcc3955c1d6a56186f..b046afe29167b9b98168315926e5258d1e81fffd 100644 --- a/modules/Vtiger/uitypes/Percentage.php +++ b/modules/Vtiger/uitypes/Percentage.php @@ -21,7 +21,7 @@ class Vtiger_Percentage_UIType extends Vtiger_Base_UIType { public function getDisplayValue($value, $record = false, $recordInstance = false) { $fldvalue = str_replace(",", ".", $value); $value = (is_numeric($fldvalue)) ? $fldvalue : null; - return Vtiger_Percentage_UIType::convertToUserFormat($value, null, true); + return static::convertToUserFormat($value, null, true); } public static function convertToUserFormat($value, $user = null, $skipConversion = false, $skipFormatting = false) { @@ -32,19 +32,17 @@ class Vtiger_Percentage_UIType extends Vtiger_Base_UIType { if (empty($user)) { $user = Users_Record_Model::getCurrentUserModel(); } - $old_no_of_currency_decimals = $user->no_of_currency_decimals; - // If decimal separator is "," and no.of decimals is "0" then if we give 8,8 (value:8.8) - // which is becoming round of value i,e "9". - // so by default we are setting no_of_currency_decimals to max value. - $user->no_of_currency_decimals = 5; - $currencyField = new CurrencyField($value); $display_value = $currencyField->getDisplayValue($user, $skipConversion, $skipFormatting); - $user->no_of_currency_decimals = $old_no_of_currency_decimals; return $display_value; } public function getEditViewDisplayValue($value) { return $this->getDisplayValue($value); } + + public function getDBInsertValue($value) { + $value = CurrencyField::convertToDBFormat($value, null, true); + return $value; + } } diff --git a/pkg/vtiger/modules/Webforms/settings/actions/Save.php b/pkg/vtiger/modules/Webforms/settings/actions/Save.php index 7ae864e1c61a60e25c5c03b8d88afa3e65d4ee2e..ce190c0fb3d18fa3dc1d25c40b2759fd5a684dbd 100644 --- a/pkg/vtiger/modules/Webforms/settings/actions/Save.php +++ b/pkg/vtiger/modules/Webforms/settings/actions/Save.php @@ -41,10 +41,11 @@ class Settings_Webforms_Save_Action extends Settings_Vtiger_Index_Action { if (!$fieldValue) { $fieldValue = $fieldModel->get('defaultvalue'); } - if($fieldModel->isMandatory() && empty(trim($fieldValue))) { - throw new AppException(vtranslate('LBL_MANDATORY_FIELD_MISSING')); - }else if($fieldName == 'targetmodule' && !array_key_exists($fieldValue,$supportedModules)){ - throw new Exception('Target module is not supported to create webform'); + if($fieldModel->isMandatory() && empty(trim($fieldValue))){ + $label = vtranslate($fieldModel->get('label'), $qualifiedModuleName); + throw new AppException(vtranslate('LBL_MANDATORY_FIELD_MISSING', 'Vtiger', $label)); + } else if($fieldName == 'targetmodule' && !array_key_exists($fieldValue, $supportedModules)){ + throw new Exception(vtranslate('LBL_TARGET_MODULE_IS_NOT_SUPPORTED_TO_CREATE_WEBFORM', 'Vtiger')); } $recordModel->set($fieldName, $fieldValue); } @@ -57,6 +58,10 @@ class Settings_Webforms_Save_Action extends Settings_Vtiger_Index_Action { $returnUrl = $recordModel->getModule()->getListViewUrl(); $recordModel->set('selectedFieldsData', $request->get('selectedFieldsData')); + $selectedFieldsData = $request->get('selectedFieldsData'); + if (empty($selectedFieldsData)) { + throw new AppException(vtranslate('LBL_MANDATORY_FIELDS_MISSING', 'Vtiger')); + } if (!$recordModel->checkDuplicate()) { $recordModel->save(); $returnUrl = $recordModel->getDetailViewUrl(); @@ -67,4 +72,4 @@ class Settings_Webforms_Save_Action extends Settings_Vtiger_Index_Action { public function validateRequest(Vtiger_Request $request) { $request->validateWriteAccess(); } -} \ No newline at end of file +}