Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
0e79cae9
Commit
0e79cae9
authored
8 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
FIX #5534
parent
fc1c3842
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/core/js/lib_head.js.php
+12
-4
12 additions, 4 deletions
htdocs/core/js/lib_head.js.php
with
12 additions
and
4 deletions
htdocs/core/js/lib_head.js.php
+
12
−
4
View file @
0e79cae9
...
...
@@ -1012,6 +1012,9 @@ function getParameterByName(name, valueifnotfound)
}
})();
// Another solution, easier, to build a javascript rounding function
function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); }
/**
* Function similar to PHP price2num()
...
...
@@ -1024,7 +1027,7 @@ function price2numjs(amount) {
if (amount == '') return '';
<?php
$dec
=
','
;
$dec
=
','
;
$thousand
=
' '
;
if
(
$langs
->
transnoentitiesnoconv
(
"SeparatorDecimal"
)
!=
"SeparatorDecimal"
)
{
$dec
=
$langs
->
transnoentitiesnoconv
(
"SeparatorDecimal"
);
...
...
@@ -1032,6 +1035,7 @@ function price2numjs(amount) {
if
(
$langs
->
transnoentitiesnoconv
(
"SeparatorThousand"
)
!=
"SeparatorThousand"
)
{
$thousand
=
$langs
->
transnoentitiesnoconv
(
"SeparatorThousand"
);
}
if
(
$thousand
==
'Space'
)
$thousand
=
' '
;
print
"var dec='"
.
dol_escape_js
(
$dec
)
.
"'; var thousand='"
.
dol_escape_js
(
$thousand
)
.
"';
\n
"
;
// Set var in javascript
?>
...
...
@@ -1050,11 +1054,15 @@ function price2numjs(amount) {
if (nbdec > rounding) rounding = nbdec;
// If rounding higher than max shown
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
if (thousand != ','
&&
thousand != '.') amount = amount.replace(',', '.');
amount = amount.replace(' ', ''); // To avoid spaces
amount = amount.replace(thousand, ''); // Replace of thousand before replace of dec to avoid pb if thousand is .
amount = amount.replace(dec, '.');
return Math.round10(amount, rounding);
//console.log("amount before="+amount+" rouding="+rounding)
var res = Math.round10(amount, - rounding);
// Other solution is
// var res = dolroundjs(amount, rounding)
console.log("res="+res)
return res;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment