/**
* Clientside currency formatting
* @param number value
+ * @param [optional] boolean onlyNumber - if true, we return formated amount without currency sign
* @param [optional] string format - currency representation of the number 1234.56
* @return string
*/
var currencyTemplate;
- CRM.formatMoney = function(value, format, onlyNumber) {
+ CRM.formatMoney = function(value, onlyNumber, format) {
var decimal, separator, sign, i, j, result;
if (value === 'init' && format) {
currencyTemplate = format;
return;
}
format = format || currencyTemplate;
- onlyNumber = onlyNumber || false;
result = /1(.?)234(.?)56/.exec(format);
if (result === null) {
return 'Invalid format passed to CRM.formatMoney';
else {
var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number(allMemberships[memType]['total_amount_numeric'] * term );
}
- cj("#total_amount").val(CRM.formatMoney(feeTotal, '', true));
+ cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
}
else {
if (taxRate) {
var feeTotal = parseFloat(Number((taxRate/100) * allMemberships[memType]['total_amount'])+Number(allMemberships[memType]['total_amount_numeric'])).toFixed(2);
- cj("#total_amount").val(CRM.formatMoney(feeTotal, '', true));
+ cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
}
else {
var feeTotal = allMemberships[memType]['total_amount'];
var term = cj("#num_terms").val();
if (term) {
var renewTotal = allMemberships[memType]['total_amount_numeric'] * term;
- cj("#total_amount").val(CRM.formatMoney(renewTotal, '', true));
+ cj("#total_amount").val(CRM.formatMoney(renewTotal, true));
}
else {
cj("#total_amount").val(allMemberships[memType]['total_amount']);
// Initialize CRM.url and CRM.formatMoney
CRM.url({ldelim}back: '{crmURL p="*path*" q="*query*" h=0 fb=1}', front: '{crmURL p="*path*" q="*query*" h=0 fe=1}'{rdelim});
- CRM.formatMoney('init', {$moneyFormat});
+ CRM.formatMoney('init', false, {$moneyFormat});
// Localize select2
$.fn.select2.defaults.formatNoMatches = "{ts escape='js'}None found.{/ts}";