From: monishdeb Date: Fri, 16 May 2014 15:54:10 +0000 (+0530) Subject: CRM-14669 fix - Amount entered into Text/Numeric Quantity not included correctly X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f8721977e26f4102983ad7b3aa097f46aa6b0cef;p=civicrm-core.git CRM-14669 fix - Amount entered into Text/Numeric Quantity not included correctly https://issues.civicrm.org/jira/browse/CRM-14669 --- diff --git a/templates/CRM/Price/Form/Calculate.tpl b/templates/CRM/Price/Form/Calculate.tpl index 4a1b6a9b47..eb543ae7f6 100644 --- a/templates/CRM/Price/Form/Calculate.tpl +++ b/templates/CRM/Price/Form/Calculate.tpl @@ -108,28 +108,14 @@ cj("input,#priceset select,#priceset").each(function () { case 'text': //default calcution of element. - var textval = parseFloat( cj(this).val() ); - if ( textval ) { - eval( 'var option = '+ cj(this).attr('price') ); - ele = option[0]; - if ( ! price[ele] ) { - price[ele] = 0; - } - optionPart = option[1].split(optionSep); - addprice = parseFloat( optionPart[0] ); - var curval = textval * addprice; - if ( textval >= 0 ) { - totalfee = parseFloat(totalfee) + curval - parseFloat(price[ele]); - price[ele] = curval; - } - } + calculateText( this ); //event driven calculation of element. cj(this).bind( 'keyup', function() { calculateText( this ); }).bind( 'blur' , function() { calculateText( this ); }); - display( totalfee ); - break; + + break; case 'select-one': @@ -181,23 +167,25 @@ cj("input,#priceset select,#priceset").each(function () { //calculation for text box. function calculateText( object ) { - eval( 'var option = ' + cj(object).attr('price') ); - ele = option[0]; - if ( ! price[ele] ) { - price[ele] = 0; - } - var optionPart = option[1].split(optionSep); - addprice = parseFloat( optionPart[0] ); - var textval = parseFloat( cj(object).attr('value') ); - var curval = textval * addprice; - if ( textval >= 0 ) { - totalfee = parseFloat(totalfee) + curval - parseFloat(price[ele]); - price[ele] = curval; - } else { - totalfee = parseFloat(totalfee) - parseFloat(price[ele]); - price[ele] = parseFloat('0'); - } - display( totalfee ); + var textval = parseFloat( cj(object).val() ); + + eval( 'var option = '+ cj(object).attr('price') ); + ele = option[0]; + if ( ! price[ele] ) { + price[ele] = 0; + } + optionPart = option[1].split(optionSep); + addprice = parseFloat( optionPart[0] ); + var curval = textval * addprice; + if ( textval >= 0 ) { + totalfee = parseFloat(totalfee) + curval - parseFloat(price[ele]); + price[ele] = curval; + } + else { + totalfee = parseFloat(totalfee) - parseFloat(price[ele]); + price[ele] = parseFloat('0'); + } + display( totalfee ); } {/literal} {if $displayOveride neq 'true'}