Merge remote branch 'canonical/master' into merge-forward
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution.tpl
index 6dcef43215cef3a5f61f2f3f258ad3f5a88afb35..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>
 
                 {if $hideCalendar neq true}
                   {include file="CRM/common/jcalendar.tpl" elementName=cancel_date}
                 {else}
-                  {$form.cancel_date.html|crmDate}
+                  {$form.cancel_date.value|crmDate}
                 {/if}
               </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 ) {
     {if $context eq 'standalone' and $outBound_option != 2 }
       {literal}
       CRM.$(function($) {
-        cj("#contact_1").blur( function( ) {
+        cj("#contact_id").change( function( ) {
           checkEmail( );
         });
         checkEmail( );
       });
 
       function checkEmail( ) {
-        var contactID = cj("input[name='contact_select_id[1]']").val();
+        var contactID = cj("#contact_id").val();
         if (contactID) {
           var postUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' h=0}{literal}";
           cj.post( postUrl, {contact_id: contactID},
     {/if}
   {/if} {* not delete mode if*}
 
-  {* include jscript to warn if unsaved form field changes *}
-  {include file="CRM/common/formNavigate.tpl"}
-
 {/if} {* closing of main custom data if *}
 
 {literal}
@@ -624,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}