Currency Symbol on Field and Calc Elements

psyfer

New Member
I'm using the calc element to calculate amounts, my php is:

$myCalc = (int)'{sisc_income___net_monthly_salary}' + '{sisc_income___other_income}' - '{sisc_income___monthly_expenses}' - '{sisc_income___other_monthly_debt_repayments}';
setlocale(LC_MONETARY, 'en_ZA');
return $myCalc;

Above I used setlocale, but that does not seem to work also..
The Format String I tried: %.2f

I need my currency symbol to display which is: R

Also, not only for the calc element. I need the currency format to work with my other decimal field elements as well but doesn't work with them.,

Please can someone tell me how to get my currency symbol added for these fields and for the calc return..?

Any ideas?

Thank you.
Kind Regards,
Psyfer
 
Well, just setting the LC_MONETARY locale won't have any effect on an sprintf format, as sprintf has no concept of a currency symbol. So for the calc, you could either just embed your currency symbol in the sprintf string, or not use the format string we provide, and return a money_format() output instead. Although note that money_format() doesn't work on Windows.

For regular fields, you'll need to embed the symbol in the sprintf format string.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top