From 95f2107c6c6dac46d29a596207446cbeb86095ec Mon Sep 17 00:00:00 2001 From: Parag Bhilkar Date: Fri, 8 Aug 2014 19:16:42 +0530 Subject: [PATCH] Hide Amount with tax field for new contribution, if invoicing is disabled and Solved tax calculation js break on popup. --- CRM/Contribute/Form/Contribution.php | 1 + .../CRM/Contribute/Form/Contribution.tpl | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index c2c487140f..288c5470f4 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -514,6 +514,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $buildPriceSet = FALSE; $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $this->assign('invoicing', $invoicing); // display tax amount on edit contribution page if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) { diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 57ec505d76..ac09ec38a7 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -118,8 +118,10 @@ {/if} {if $ppID}{ts}adjust payment amount{/ts}{help id="adjust-payment-amount"}{/if} -
{ts}Total amount of this contribution.{/ts}{if $hasPriceSets} {ts}Alternatively, you can use a price set.{/ts}{/if} -
+
+
{ts}Total amount of this contribution.{/ts}{if $hasPriceSets} {ts}Alternatively, you can use a price set.{/ts}{/if} +
+
@@ -372,7 +374,6 @@ 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 ) { @@ -632,6 +633,7 @@ cj("#currency").on("change",function(){ cj('#total_amount').trigger("change"); }) +{/literal}{if $taxRates && $invoicing}{literal} cj('#total_amount').on("change",function(event) { if (event.handled !== true) { var financialType = cj('#financial_type_id').val(); @@ -651,10 +653,26 @@ cj('#total_amount').on("change",function(event) { } var totalAmount = cj('#total_amount').val(); var totalTaxAmount = parseFloat(Number((taxRate/100)*totalAmount)+Number(totalAmount)).toFixed(2); - cj( "#totalTaxAmount" ).html('Total Amount : ' + currencySymbol + ' '+ totalTaxAmount); + cj( "#totalTaxAmount" ).html('Amount with tax : ' + currencySymbol + ' '+ totalTaxAmount); event.handled = true; } return false; }); + +CRM.$(function($) { + cj('#total_amount').trigger("change"); +}); +{/literal}{/if}{literal} + +cj(function() { + cj('#price_set_id').click(function() { + if( cj('#price_set_id').val() ) { + cj('#totalAmountBlock').hide(); + } + else { + cj('#totalAmountBlock').show(); + } + }); +}); {/literal} -- 2.25.1