AppGini 5.81 number format

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

AppGini 5.81 number format

Post by Moh Youba » 2019-11-09 12:18

Hello
I am looking for help to get number format like this " 5 000" instead of this "5000"

How to custom these code

Code 1
SELECT `caisse`.`recettes` - `caisse`.`depenses`
FROM `caisse`
WHERE `caisse`.`idcaisse`='%ID%'

Code 2
SELECT
SUM(montant) depenses
FROM
depenses;

Thank you

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-09 13:36

Hi,

you can use

replace(format( VALUE ,0),',',' ')

like

SELECT replace(format(`caisse`.`recettes` - `caisse`.`depenses`,0),',',' ') FROM `caisse`
WHERE `caisse`.`idcaisse`='%ID%'
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: AppGini 5.81 number format

Post by jsetzer » 2019-11-10 00:03

You can try to use MySql number format function with your locale as 3rd parameter:

http://www.mysqltutorial.org/mysql-format-function/

Available locales:
https://dev.mysql.com/doc/refman/5.7/en ... pport.html
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-10 14:45

Hello

Thank you for your help

Regards

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-17 22:18

Hello
I have try many type but still not working for me

SELECT replace(format(`membres`.`montant` * `membres`.`duree`,0),',','')
FROM `membres`
WHERE `membres`.`idmembre`='%ID%'

"montante is set to decimal and "duree" is set to integer (for reference)

Thank you for any help.

Best regards

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-18 20:30

Hi,

can you post the result you get from the native sql statement.

SELECT `membres`.`montant` * `membres`.`duree`
FROM `membres`
WHERE `membres`.`idmembre`='%ID%'
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 20:35

Hi

Sorry, I am not sure to get your question, but this is what I get.

When I put 1000 I get 1000

I want to get this 1 000

Thank you

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-18 20:44

Hi,

if the montante is set to decimal, you should have a result with decimal precision. Can you check that.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 20:48

ok, I set the field "montant" as this
Decimal with precision 0

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-18 21:12

Hi,

can you try

SELECT replace(format(`membres`.`montant` * `membres`.`duree`,0,'en_EN'),',',' ')
FROM `membres`
WHERE `membres`.`idmembre`='%ID%'

watch the space at the end ',','SPACE')
Last edited by pbottcher on 2019-11-18 21:20, edited 1 time in total.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 21:18

thank you, please give a moment to try and back to you

best regards,

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 21:29

not working, maybe I miss some point
number_format-1.jpg
number_format-1.jpg (102.39 KiB) Viewed 10641 times
number_format-1.jpg
number_format-1.jpg (102.39 KiB) Viewed 10641 times
Attachments
app.zip
(6.56 KiB) Downloaded 209 times
number_format-2.jpg
number_format-2.jpg (72.66 KiB) Viewed 10641 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-18 21:37

Hi,

the statement itself is only

Code: Select all

SELECT replace(format(`membres`.`montant` * `membres`.`duree`,0,'en_EN'),',',' ')
FROM `membres`
WHERE `membres`.`idmembre`='%ID%'
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 21:48

thank you Olaf, and sorry for my poor knowledge. back to you once fixed.

regards,

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-18 21:54

Even so I'm not Olaf, hope it works now.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 21:56

my bad !
sorry

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 21:58

ok, I correct the code but still not working for me unfortunately !!!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-18 22:01

Hi,

I think you need to change the type for the field Montant TOTAL to varchar (10) or what suits you best.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 22:08

ok I will try all type until I find the correct.
Thank you

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-18 22:13

yes it is working. When I change to varchar (10) it is working.
but the problem is I cannot use the option "show column sum" with varchar

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: AppGini 5.81 number format

Post by pbottcher » 2019-11-19 20:12

Hi,

ok, so there was a missunderstanding. If you want to see the result in the table view with your format, you should change back the type to decimal, or integer (if you do not use decimals).

montant total
you can create in the hooks folder a file called membres-tv.js. Add the following to the file.

Code: Select all

$j(document).ready(function(){

$j('tr td.parent-credit').each(function(){var value=$j(this).text(); $j(this).text(Intl.NumberFormat('en-ZA').format(value))});
})
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: AppGini 5.81 number format

Post by Moh Youba » 2019-11-19 22:01

Hello
thank sir for your help and support, I am going to check and let you know.

Best regards,

Post Reply