Page 1 of 2
swiss number format
Posted: Mon Nov 09, 2020 10:23 am
by paulkauz
How can I create following format: CHF 9’956’000
In the Form it's possible to exchange the $ trough CHF, but how can I change the 1.000 trough 1'000
Re: swiss number format
Posted: Mon Nov 09, 2020 11:23 am
by Janusz
In browse form for example you can use Format:
FORMAT(ofe_cena,2,'rm_CH')
swiss.png
Re: swiss number format
Posted: Mon Nov 09, 2020 11:40 am
by paulkauz
Thanks for the proposal, but where can I put that Format in?
Re: swiss number format
Posted: Mon Nov 09, 2020 12:33 pm
by Janusz
Put it in the
From / Browse / Display field
for example if you have there: ofe_cena
then replace with: FORMAT(ofe_cena,2,'rm_CH')
(this is OK with MariaDB)
Re: swiss number format
Posted: Mon Nov 09, 2020 12:50 pm
by kev1n
BTW, "rm_CH" is the ICU Locale of “Romansh (Switzerland)
You might want to use "de_CH" instead (even though the grouping separator is ' for both of them)
Re: swiss number format
Posted: Mon Nov 09, 2020 1:14 pm
by paulkauz
thanks so far and what about the edit part of a form?
how can I set there the right format?
BR Paul
Re: swiss number format
Posted: Mon Nov 09, 2020 9:10 pm
by Janusz
Hi,
Please find enclosed short movie how you can add your own format.
https://drive.google.com/file/d/1wzEzVw ... sp=sharing
Re: swiss number format
Posted: Tue Nov 10, 2020 12:05 pm
by paulkauz
Perfect, I'll try that and I'm sure it will work.

Re: swiss number format
Posted: Tue Nov 10, 2020 12:53 pm
by kev1n
Here's another solution (Advantage: No JavaScript required)
Run this query in your database
Code: Select all
INSERT INTO `zzzzsys_format` (`zzzzsys_format_id`, `srm_type`, `srm_format`) VALUES ('5f4759ef6e2cec9', 'Number', 'CHF 1\'000.00');
Then replace the function nuPunctuation() in nucommon.php with this one:
Code: Select all
function nuPunctuation($f){
$c = '';
$d = '';
if(strpos($f , '1,' ) !== false){
$c = ',';
}
if(strpos($f , '1.' ) !== false){
$c = '.';
}
if(strpos($f , '0,' ) !== false){
$d = ',';
}
if(strpos($f , '0.' ) !== false){
$d = '.';
}
if(strpos($f , '0\'' ) !== false){
$d = '\'';
}
return [$c, $d];
}
PS: Other changes will have to be done in nuAddFormatting() to make it work with negative amounts.
Re: swiss number format
Posted: Tue Nov 10, 2020 7:11 pm
by paulkauz
Thanks for the quick help. It works like a charm on forms and I really appreciate it.
The solution with the new code in function nuPunctuation($f) does not work on reports.