Merge remote branch 'canonical/master' into merge-forward
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution.tpl
index 151b154bf6be0250eee66f0a35c0a11cb4731ce9..57ec505d76c7acc514563694cb52ca81eb9828b2 100644 (file)
 
         {if $ppID}{ts}<a href='#' onclick='adjustPayment();'>adjust payment amount</a>{/ts}{help id="adjust-payment-amount"}{/if}
         <br /><span class="description">{ts}Total amount of this contribution.{/ts}{if $hasPriceSets} {ts}Alternatively, you can use a price set.{/ts}{/if}</span>
+        <br /><span id="totalTaxAmount" class="label"></span>
       </td>
     </tr>
 
       cj('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) {
         loadPanes(cj(this).attr('id'));
       });
+      cj('#total_amount').trigger("change");
     });
     // load panes function calls for snippet based on id of crm-accordion-header
     function loadPanes( id ) {
@@ -621,5 +623,38 @@ cj('#fee_amount').change( function() {
     cj('#net_amount').val(netAmount);
   }
 });
+
+cj("#financial_type_id").on("change",function(){
+    cj('#total_amount').trigger("change");
+})
+
+cj("#currency").on("change",function(){
+  cj('#total_amount').trigger("change");
+})
+
+cj('#total_amount').on("change",function(event) {
+  if (event.handled !== true) {
+    var financialType = cj('#financial_type_id').val();
+    var taxRates = '{/literal}{$taxRates}{literal}';
+    var taxRates = JSON.parse(taxRates);
+    var currencies = '{/literal}{$currencies}{literal}';
+    var currencies = JSON.parse(currencies);
+    var currencySelect = cj('#currency').val();
+    var currencySymbol = currencies[currencySelect];
+    var re= /\((.*?)\)/g;
+    for(m = re.exec(currencySymbol); m; m = re.exec(currencySymbol)){
+      var currencySymbol = m[1];
+    }
+    var taxRate = taxRates[financialType]; 
+    if (!taxRate) {
+      taxRate = 0;
+    }  
+    var totalAmount = cj('#total_amount').val();
+    var totalTaxAmount = parseFloat(Number((taxRate/100)*totalAmount)+Number(totalAmount)).toFixed(2);
+    cj( "#totalTaxAmount" ).html('Total Amount : <span id="currencySymbolShow">' + currencySymbol + '</span> '+ totalTaxAmount);
+    event.handled = true;
+  }
+  return false;
+});
 </script>
 {/literal}