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 Aug 1, 2020
1 parent d73f979 commit 11a082b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 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
34 changes: 14 additions & 20 deletions templates/CRM/Contribute/Form/Contribution.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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 @@ -63,7 +62,7 @@
<td>{$form.contact_id.html}</td>
</tr>
<tr class="crm-contribution-form-block-contribution_type_id crm-contribution-form-block-financial_type_id">
<td class="label">{$form.financial_type_id.label}</td><td{$valueStyle}>{$form.financial_type_id.html}&nbsp;
<td class="label">{$form.financial_type_id.label}</td><td{$valueStyle}>{$form.financial_type_id.html}
{if $is_test}
{ts}(test){/ts}
{/if} {help id="id-financial_type"}
Expand All @@ -78,7 +77,7 @@
<tr class="crm-contribution-form-block-total_amount">
<td class="label">{$form.total_amount.label}</td>
<td {$valueStyle}>
<span id='totalAmount'>{$form.currency.html|crmAddClass:eight}&nbsp;{$form.total_amount.html|crmAddClass:eight}</span>
<span id='totalAmount'>{$form.currency.html|crmAddClass:eight} {$form.total_amount.html|crmAddClass:eight}</span>
{if $freezeFinancialType}
{help id="id-total_amount"}
{/if}
Expand All @@ -99,15 +98,15 @@
</tr>

{if $buildRecurBlock && !$payNow}
<tr id='recurringPaymentBlock' class='hiddenElement'>
<tr id='recurringPaymentBlock'>
<td></td>
<td>
<strong>{$form.is_recur.html} {ts}every{/ts}
&nbsp;{$form.frequency_interval.html}
&nbsp;{$form.frequency_unit.html}&nbsp;
<strong>{$form.is_recur.html}<label for="is_recur">{ts}every{/ts}</label>
{$form.frequency_interval.html}
{$form.frequency_unit.html}
{ts}for{/ts}
&nbsp;{$form.installments.html}
&nbsp;{$form.installments.label}
{$form.installments.html}
{$form.installments.label}
</strong>
<br />
<span class="description">
Expand Down Expand Up @@ -203,7 +202,7 @@
{if $email and $outBound_option != 2}
<tr class="crm-contribution-form-block-is_email_receipt">
<td class="label">{$form.is_email_receipt.label}</td>
<td>{$form.is_email_receipt.html}&nbsp;
<td>{$form.is_email_receipt.html}
<span class="description">{ts 1=$email}Automatically email a receipt for this payment to %1?{/ts}</span>
</td>
</tr>
Expand Down Expand Up @@ -259,7 +258,7 @@
{if !$payNow}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed {if $noSoftCredit}collapsed{/if}" id="softCredit">
<div class="crm-accordion-header">
{ts}Soft Credit{/ts}&nbsp;{help id="id-soft_credit"}
{ts}Soft Credit{/ts} {help id="id-soft_credit"}
</div>
<div class="crm-accordion-body">
<table class="form-layout-compressed">
Expand All @@ -278,14 +277,14 @@
{if $siteHasPCPs && !$payNow}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed {if $noPCP}collapsed{/if}" id="softCredit">
<div class="crm-accordion-header">
{ts}Personal Campaign Page{/ts}&nbsp;{help id="id-pcp"}
{ts}Personal Campaign Page{/ts} {help id="id-pcp"}
</div>
<div class="crm-accordion-body">
<table class="form-layout-compressed">
<tr class="crm-contribution-pcp-block crm-contribution-form-block-pcp_made_through_id">
<td class="label">{$form.pcp_made_through_id.label}</td>
<td>
{$form.pcp_made_through_id.html} &nbsp;
{$form.pcp_made_through_id.html}
<div class="description">{ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts}</div>

<div class="spacer"></div>
Expand Down Expand Up @@ -340,6 +339,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 @@ -395,9 +395,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 @@ -466,17 +464,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 11a082b

Please sign in to comment.