From: <dai...@us...> - 2011-12-02 21:14:09
|
Revision: 4760 http://web-erp.svn.sourceforge.net/web-erp/?rev=4760&view=rev Author: daintree Date: 2011-12-02 21:14:02 +0000 (Fri, 02 Dec 2011) Log Message: ----------- Modified Paths: -------------- trunk/includes/MiscFunctions.php Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2011-11-30 15:20:37 UTC (rev 4759) +++ trunk/includes/MiscFunctions.php 2011-12-02 21:14:02 UTC (rev 4760) @@ -316,14 +316,17 @@ function locale_number_format($Number, $DecimalPlaces=0) { global $DecimalPoint; global $ThousandsSeparator; - - if (!is_numeric($DecimalPlaces) AND $DecimalPlaces == 'Variable'){ - $DecimalPlaces = mb_strlen($Number) - mb_strlen(intval($Number)); - if ($DecimalPlaces > 0){ - $DecimalPlaces--; + if ($_SESSION['Language']=='hi_IN.utf8' OR $_SESSION['Language']=='en_IN.utf8'){ + return indian_number_format($Number,$DecimalPlaces); + } else { + if (!is_numeric($DecimalPlaces) AND $DecimalPlaces == 'Variable'){ + $DecimalPlaces = mb_strlen($Number) - mb_strlen(intval($Number)); + if ($DecimalPlaces > 0){ + $DecimalPlaces--; + } } + return number_format($Number,$DecimalPlaces,$DecimalPoint,$ThousandsSeparator); } - return number_format($Number,$DecimalPlaces,$DecimalPoint,$ThousandsSeparator); } /* and to parse the input of the user into useable number */ @@ -344,4 +347,31 @@ } +function indian_number_format($Number,$DecimalPlaces){ + $IntegerNumber = intval($Number); + $DecimalValue = $Number - $IntegerNumber; + if ($DecimalPlaces !='Variable'){ + $DecimalValue= round($DecimalValue,$DecimalPlaces); + } + if (strlen(substr($DecimalValue,2))>0){ + $DecimalValue = substr($DecimalValue,1); + } else { + $DecimalValue =''; + } + if(strlen($IntegerNumber)>3){ + $LastThreeNumbers = substr($IntegerNumber, strlen($IntegerNumber)-3, strlen($IntegerNumber)); + $RestUnits = substr($IntegerNumber, 0, strlen($IntegerNumber)-3); // extracts the last three digits + $RestUnits = (strlen($RestUnits)%2 == 1)?'0'.$RestUnits:$RestUnits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. + $FirstPart =''; + $ExplodedUnits = str_split($RestUnits, 2); + for($i=0; $i<sizeof($ExplodedUnits); $i++){ + $FirstPart .= intval($ExplodedUnits[$i]).','; // creates each of the 2's group and adds a comma to the end + } + + return $FirstPart.$LastThreeNumbers.$DecimalValue; + } else { + return $IntegerNumber. $DecimalValue; + } +} + ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |