Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

swiss number format

Questions related to using nuBuilder Forte.
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

swiss number format

Unread post 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
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 11 times
Been thanked: 18 times

Re: swiss number format

Unread post by Janusz »

In browse form for example you can use Format:

FORMAT(ofe_cena,2,'rm_CH')
swiss.png
You do not have the required permissions to view the files attached to this post.
If you like nuBuilder, please leave a review on SourceForge
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

Re: swiss number format

Unread post by paulkauz »

Thanks for the proposal, but where can I put that Format in?
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 11 times
Been thanked: 18 times

Re: swiss number format

Unread post 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)
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: swiss number format

Unread post 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)
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

Re: swiss number format

Unread post by paulkauz »

thanks so far and what about the edit part of a form?
how can I set there the right format?

BR Paul
You do not have the required permissions to view the files attached to this post.
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 11 times
Been thanked: 18 times

Re: swiss number format

Unread post by Janusz »

Hi,
Please find enclosed short movie how you can add your own format.
https://drive.google.com/file/d/1wzEzVw ... sp=sharing
If you like nuBuilder, please leave a review on SourceForge
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

Re: swiss number format

Unread post by paulkauz »

Perfect, I'll try that and I'm sure it will work. :D
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: swiss number format

Unread post 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.
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

Re: swiss number format

Unread post 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.
If you like nuBuilder, please leave a review on SourceForge
Post Reply