$takeUserSubmittedAutoRenew = (!empty($_POST) || $this->isSubmitted()) ? TRUE : FALSE;
$this->assign('takeUserSubmittedAutoRenew', $takeUserSubmittedAutoRenew);
+ // Assign autorenew option (0:hide,1:optional,2:required) so we can use it in confirmation etc.
+ $autoRenewOption = CRM_Price_BAO_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId);
+ if (isset($membershipTypeValues[$selectedMembershipTypeID]['auto_renew'])) {
+ $this->assign('autoRenewOption', $membershipTypeValues[$selectedMembershipTypeID]['auto_renew']);
+ }
+ else {
+ $this->assign('autoRenewOption', $autoRenewOption);
+ }
+
if ($isContributionMainPage) {
if (!$membershipPriceset) {
if (!$this->_membershipBlock['is_required']) {
$this->addRule('selectMembership', ts('Please select one of the memberships.'), 'required');
}
- else {
- $autoRenewOption = CRM_Price_BAO_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId);
- $this->assign('autoRenewOption', $autoRenewOption);
- }
if ((!$this->_values['is_pay_later'] || is_array($this->_paymentProcessors)) && ($allowAutoRenewMembership || $autoRenewOption)) {
- $this->addElement('checkbox', 'auto_renew', ts('Please renew my membership automatically.'));
+ if ($autoRenewOption == 2) {
+ $this->addElement('hidden', 'auto_renew', ts('Please renew my membership automatically.'));
+ }
+ else {
+ $this->addElement('checkbox', 'auto_renew', ts('Please renew my membership automatically.'));
+ }
}
}
{if !empty($auto_renew)} {* Auto-renew membership confirmation *}
{crmRegion name="contribution-confirm-recur-membership"}
<br />
- <strong>{ts 1=$frequency_interval 2=$frequency_unit}I want this membership to be renewed automatically every %1 %2(s).{/ts}</strong></p>
+ <strong>
+ {if $autoRenewOption == 1}
+ {ts 1=$frequency_interval 2=$frequency_unit}I want this membership to be renewed automatically every %1 %2(s).{/ts}
+ {elseif $autoRenewOption == 2}
+ {ts 1=$frequency_interval 2=$frequency_unit}This membership will be renewed automatically every %1 %2(s).{/ts}
+ {/if}
+ </strong></p>
<div class="description crm-auto-renew-cancel-info">({ts}Your initial membership fee will be processed once you complete the confirmation step. You will be able to cancel the auto-renewal option by visiting the web page link that will be included in your receipt.{/ts})</div>
{/crmRegion}
{else}
CRM.$(function($) {
//if price set is set we use below below code to show for showing auto renew
var autoRenewOption = {/literal}'{$autoRenewOption}'{literal};
- $('#allow_auto_renew').hide();
+ var autoRenew = $("#auto_renew");
+ var forceRenew = $("#force_renew");
+ autoRenew.hide();
+ forceRenew.hide();
if ( autoRenewOption == 1 ) {
- $('#allow_auto_renew').show();
+ autoRenew.show();
} else if ( autoRenewOption == 2 ) {
- var autoRenew = $("#auto_renew");
autoRenew.prop('checked', true );
autoRenew.attr( 'readonly', true );
- $('#allow_auto_renew').show();
+ autoRenew.hide();
+ forceRenew.show();
}
});
</script>
if ( !memTypeId && singleMembership ) memTypeId = cj("input:radio[name="+priceSetName+"]").attr('membership-type');
var renewOptions = {/literal}{$autoRenewMembershipTypeOptions}{literal};
var currentOption = eval( "renewOptions." + 'autoRenewMembershipType_' + memTypeId );
+ var autoRenew = cj('#auto_renew');
+ var autoRenewC = cj('input[name="auto_renew"]');
+ var forceRenew = cj("#force_renew");
- funName = 'hide();';
var readOnly = false;
var isChecked = false;
+ if ( currentOption == 0 ) {
+ isChecked = false;
+ forceRenew.hide();
+ autoRenew.hide();
+ }
if ( currentOption == 1 ) {
- funName = 'show();';
+ forceRenew.hide();
+ autoRenew.show();
//uncomment me, if we'd like
//to load auto_renew checked.
//isChecked = true;
-
} else if ( currentOption == 2 || currentOption == 4) {
- funName = 'show();';
+ autoRenew.hide();
+ forceRenew.show();
isChecked = readOnly = true;
}
- var autoRenew = cj("#auto_renew");
if ( considerUserInput ) isChecked = autoRenew.prop('checked' );
//its a normal recur contribution.
if ( cj( "is_recur" ) &&
( cj( 'input:radio[name="is_recur"]:checked').val() == 1 ) ) {
isChecked = false;
- funName = 'hide();';
+ autoRenew.hide();
+ forceRenew.hide();
}
- //when we do show auto_renew read only
- //which implies it should be checked.
- if ( readOnly && funName == 'show();' ) isChecked = true;
-
- autoRenew.attr( 'readonly', readOnly );
- autoRenew.prop('checked', isChecked );
- eval( "cj('#allow_auto_renew')." + funName );
+ autoRenewC.attr( 'readonly', readOnly );
+ autoRenewC.prop('checked', isChecked );
}
{/literal}{if $allowAutoRenewMembership}{literal}
<div id="allow_auto_renew">
<div class='crm-section auto-renew'>
<div class='label'></div>
- <div class ='content'>
+ <div class='content' id="auto_renew">
{if isset($form.auto_renew) }
{$form.auto_renew.html} {$form.auto_renew.label}
{/if}
</div>
+ <div class='content' id="force_renew" style='display: none'>{ts}Membership will renew automatically.{/ts}</div>
</div>
</div>
{/if}