Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unreachable code & variable cleanup in membership back office form template #19647

Merged
merged 4 commits into from
Feb 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 17 additions & 32 deletions templates/CRM/Member/Form/Membership.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,21 @@
{literal}
<script type="text/javascript">
function setPaymentBlock(mode, checkboxEvent) {
var memType = parseInt(cj('#membership_type_id_1').val( ));
var isPriceSet = 0;
var existingAmount = 0;

if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
isPriceSet = 1;
if (cj('#price_set_id').length > 0 && cj('#price_set_id').val()) {
return;
}

if ( !memType || isPriceSet ) {
var membershipTypeID = parseInt(cj('#membership_type_id_1').val());
if (!membershipTypeID) {
return;
}

var allMemberships = {/literal}{$allMembershipInfo}{literal};
membershipType = allMemberships[membershipTypeID];
if (!mode) {
//check the record_contribution checkbox if membership is a paid one
{/literal}{if $action eq 1}{literal}
if (!checkboxEvent) {
if (allMemberships[memType]['total_amount_numeric'] > 0) {
if (membershipType['total_amount_numeric'] > 0) {
cj('#record_contribution').prop('checked','checked');
cj('#recordContribution').show();
}
Expand All @@ -296,37 +293,25 @@
}

// skip this for test and live modes because financial type is set automatically
cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
cj("#financial_type_id").val(membershipType['financial_type_id']);
var term = cj('#num_terms').val();
var taxRates = {/literal}{$taxRates}{literal};
var taxTerm = {/literal}{$taxTerm|@json_encode}{literal};
var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
var taxRate = taxRates[membershipType['financial_type_id']];
var currency = {/literal}{$currency_symbol|@json_encode}{literal};
var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
var taxAmount = (taxRate/100)*membershipType['total_amount_numeric'];
taxAmount = isNaN (taxAmount) ? 0:taxAmount;
if (term) {
if (!taxRate) {
var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
var feeTotal = membershipType['total_amount_numeric'] * term;
}
else {
var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number
(allMemberships[memType]['total_amount_numeric'] * term );
var feeTotal = Number((taxRate/100) * (membershipType['total_amount_numeric'] * term))+Number
(membershipType['total_amount_numeric'] * term );
}
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));
}
else {
var feeTotal = allMemberships[memType]['total_amount'];
if (!existingAmount) {
// CRM-16680 don't set amount if there is an existing contribution.
cj("#total_amount").val(allMemberships[memType]['total_amount']);
}
}
}

var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
cj('.totaltaxAmount').html(taxMessage);
}
Expand Down Expand Up @@ -577,12 +562,12 @@
if (!processorId) {
processorId = cj( '#payment_processor_id' ).val( );
}
if (!membershipType) {
membershipType = parseInt( cj('#membership_type_id_1').val( ) );
if (!membershipTypeID) {
membershipTypeID = parseInt( cj('#membership_type_id_1').val( ) );
}

//we don't have both required values.
if (!processorId || !membershipType) {
if (!processorId || !membershipTypeID) {
cj("#auto_renew").prop('checked', false);
cj("#autoRenew").hide();
showEmailOptions();
Expand All @@ -591,7 +576,7 @@

var recurProcessors = {/literal}{$recurProcessor}{literal};
var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
var currentOption = autoRenewOptions[membershipType];
var currentOption = autoRenewOptions[membershipTypeID];

if (!currentOption || !recurProcessors[processorId]) {
cj("#auto_renew").prop('checked', false );
Expand Down