Skip to content

Commit

Permalink
Fix recurring fields on backend contribution forms
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jan 7, 2021
1 parent c6eb575 commit 3cb7568
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
35 changes: 20 additions & 15 deletions templates/CRM/Contribute/Form/AdditionalInfo/Payment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@
{literal}
<script type="text/javascript" >

function enablePeriod() {
var frUnit = cj('#frequency_unit');
var frInerval = cj('#frequency_interval');
function toggleRecur() {
var isRecur = cj('input[id="is_recur"]:checked');
var frequencyUnit = cj('#frequency_unit');
var frequencyInterval = cj('#frequency_interval');
var installments = cj('#installments');
isDisabled = false;
if (cj('input:radio[name="is_recur"]:checked').val() == 0) {
isDisabled = true;
frInerval.val('');
if (isRecur.val() > 0) {
frequencyUnit.prop('disabled', false).addClass('required');
frequencyInterval.prop('disabled', false).addClass('required');
installments.prop('disabled', false);
}
else {
frequencyInterval.val('');
installments.val('');
frequencyUnit.prop('disabled', true).removeClass('required');
frequencyInterval.prop('disabled', true).removeClass('required');
installments.prop('disabled', true);
}

frUnit.prop('disabled', isDisabled);
frInerval.prop('disabled', isDisabled);
installments.prop('disabled', isDisabled);
}

function buildRecurBlock(processorId) {
Expand All @@ -44,14 +46,17 @@
cj('input:radio[name="is_recur"]')[0].checked = true;
}
}

enablePeriod();
toggleRecur();
eval('cj("#recurringPaymentBlock").' + funName + "()");
}

CRM.$(function($) {
buildRecurBlock(null);
enablePeriod();
toggleRecur();

cj('input[id="is_recur"]').on('change', function() {
toggleRecur();
});
});

</script>
Expand Down
12 changes: 3 additions & 9 deletions templates/CRM/Contribute/Form/Contribution.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
{/if}

<div class="crm-block crm-form-block crm-contribution-form-block">

{if !$email and $action neq 8 and $context neq 'standalone'}
<div class="messages status no-popup">
{icon icon="fa-info-circle"}{/icon}{ts}You will not be able to send an automatic email receipt for this contribution because there is no email address recorded for this contact. If you want a receipt to be sent when this contribution is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the contribution.{/ts}
Expand Down Expand Up @@ -102,7 +101,7 @@
</tr>

{if $buildRecurBlock && !$payNow}
<tr id='recurringPaymentBlock' class='hiddenElement'>
<tr id='recurringPaymentBlock'>
<td></td>
<td>
<strong>{$form.is_recur.html} {ts}every{/ts}
Expand Down Expand Up @@ -343,6 +342,7 @@
loadPanes(cj(this).attr('id'));
});
});

// load panes function calls for snippet based on id of crm-accordion-header
function loadPanes(id) {
var url = "{/literal}{crmURL p='civicrm/contact/view/contribution' q="snippet=4&id=`$entityID`&formType=" h=0}{literal}" + id;
Expand Down Expand Up @@ -398,9 +398,7 @@
{* Additional Detail / Honoree Information / Premium Information *}
{foreach from=$allPanes key=paneName item=paneValue}
<div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}">
<div class="crm-accordion-header" id="{$paneValue.id}">
{$paneName}
</div><!-- /.crm-accordion-header -->
<div class="crm-accordion-header" id="{$paneValue.id}">{$paneName}</div>
<div class="crm-accordion-body">
<div class="{$paneValue.id}"></div>
</div><!-- /.crm-accordion-body -->
Expand Down Expand Up @@ -469,17 +467,13 @@
});
</script>
{/if} {* not delete mode if*}
{/if} {* closing of main custom data if *}
{literal}
<script type="text/javascript">
{/literal}
// load form during form rule.
{if $buildPriceSet}{literal}buildAmount();{/literal}{/if}
{literal}
// CRM-16451: set financial type of 'Price Set' in back office contribution
Expand Down

0 comments on commit 3cb7568

Please sign in to comment.