From a7018f1a13be400472edee706b75cbd638d142f1 Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Wed, 21 Nov 2012 16:00:14 +0100 Subject: [PATCH] Fixed issue #6859: Integer values displayed as floating point numbers Fixed issue: Can add dot on integer only numerci question type Dev: remove all ending 0 to numeric question type, and remove the . if it's at ending Dev: TODO : move control of numeric/integer in clean external js --- application/helpers/common_helper.php | 1 - application/modules/NumericalQuestion.php | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php index 8f795f8cce1..88d3020755f 100644 --- a/application/helpers/common_helper.php +++ b/application/helpers/common_helper.php @@ -1383,7 +1383,6 @@ function getQuestion($fieldcode) } /** -* * @param type $iSurveyID The Survey ID * @param type $sFieldCode Field code of the particular field * @param type $sValue The stored response value diff --git a/application/modules/NumericalQuestion.php b/application/modules/NumericalQuestion.php index 97deabea7a6..a26c23dc72a 100644 --- a/application/modules/NumericalQuestion.php +++ b/application/modules/NumericalQuestion.php @@ -47,21 +47,22 @@ public function getAnswerHTML() $tiwidth=10; } + $fValue=rtrim($_SESSION['survey_'.$this->surveyid][$this->fieldname],'0.');// Remove ending . and extra 0 + $integeronly=0; if (trim($aQuestionAttributes['num_value_int_only'])==1) { - $acomma=""; + $integeronly=1; $extraclass .=" integeronly"; - $answertypeclass = " integeronly"; + $answertypeclass .= " integeronly"; + if(is_numeric($fValue)) + { + $fValue=number_format($fValue, 0, '', ''); + } } - else - { - $acomma=getRadixPointData($thissurvey['surveyls_numberformat']); - $acomma = $acomma['seperator']; - } $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; - $dispVal = str_replace('.',$sSeperator,$_SESSION['survey_'.$this->surveyid][$this->fieldname]); + $fValue = str_replace('.',$sSeperator,$fValue); if ($thissurvey['nokeyboard']=='Y') { @@ -77,7 +78,7 @@ public function getAnswerHTML() $answer = "

" . " \n$prefix\t" . "fieldname\" title=\"".$clang->gT('Only numbers may be entered in this field.')."\" " - . "id=\"answer{$this->fieldname}\" value=\"{$dispVal}\" onkeyup='$checkconditionFunction(this.value, this.name, this.type)' " + . "id=\"answer{$this->fieldname}\" value=\"{$fValue}\" onkeyup=\"{$checkconditionFunction}(this.value, this.name, this.type,'onchange',{$integeronly})\" " . " {$maxlength} />\t{$suffix}\n

\n"; if ($aQuestionAttributes['hide_tip']==0) { @@ -97,13 +98,13 @@ public function getDataEntry($idrow, &$fnames, $language) public function getExtendedAnswer($value, $language) { - echo Yii::trace(CVarDumper::dumpAsString($value),'vardump'); $value=rtrim($value,"0."); $aQuestionAttributes = $this->getAttributeValues(); if($aQuestionAttributes['num_value_int_only']) { - $sValue=number_format($sValue, 0, '', ''); + $value=number_format($value, 0, '', ''); } + return $value; } public function filter($value, $type)