2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
10 {* this template is used for adding/editing/deleting memberships for a contact *}
12 <div class="messages status no-popup">
13 <div class="icon inform-icon"></div>
14 <p>{ts}This membership is set to renew automatically {if $endDate}on {$endDate|crmDate}{/if}. Please be aware that any changes that you make here may not be reflected in the payment processor. Please ensure that you alter the related subscription at the payment processor.{/ts}</p>
15 {if $cancelAutoRenew}<p>{ts 1=$cancelAutoRenew}To stop the automatic renewal:
16 <a href="%1">Cancel auto-renew</a>
20 <div class="spacer"></div>
22 {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Membership"}
24 <script type="text/javascript">
26 var membershipValues = [];
27 {/literal}{foreach from=$optionsMembershipTypes item=memType key=opId}{literal}
28 membershipValues[{/literal}{$opId}{literal}] = {/literal}{$memType}{literal};
29 {/literal}{/foreach}{literal}
30 processMembershipPriceset(membershipValues, {/literal}{$autoRenewOption}{literal}, 1);
31 {/literal}{if !$membershipMode}{literal}
32 enableAmountSection({/literal}{$contributionType}{literal});
33 {/literal}{/if}{literal}
38 {if $membershipMode == 'test' }
39 {assign var=registerMode value="TEST"}
40 {elseif $membershipMode == 'live'}
41 {assign var=registerMode value="LIVE"}
43 {if !$emailExists and $action neq 8 and $context neq 'standalone'}
44 <div class="messages status no-popup">
45 <div class="icon inform-icon"></div>
46 <p>{ts}You will not be able to send an automatic email receipt for this Membership because there is no email address recorded for this contact. If you want a receipt to be sent when this Membership is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the Membership.{/ts}</p>
51 {ts 1=$displayName 2=$registerMode}Use this form to submit Membership Record on behalf of %1. <strong>A %2 transaction will be submitted</strong> using the selected payment processor.{/ts}
54 <div class="crm-block crm-form-block crm-membership-form-block">
55 {if $newCredit AND $action EQ 1 AND $membershipMode EQ null}
56 <div class="action-link css_right crm-link-credit-card-mode">
58 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/membership' q="reset=1&action=add&cid=`$contactId`&context=`$context`&mode=live"}{/capture}
60 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/membership' q="reset=1&action=add&context=standalone&mode=live"}{/capture}
62 <a class="open-inline-noreturn action-item crm-hover-button" href="{$ccModeLink}"><i class="crm-i fa-credit-card" aria-hidden="true"></i> {ts}submit credit card membership{/ts}</a>
65 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
67 <div class="messages status no-popup">
68 <div class="icon inform-icon"></div>
72 <table class="form-layout-compressed">
73 <tr class="crm-membership-form-contact-id">
74 <td class="label">{$form.contact_id.label}</td>
75 <td>{$form.contact_id.html}</td>
77 <tr class="crm-membership-form-block-membership_type_id">
78 <td class="label">{$form.membership_type_id.label}</td>
79 <td id="mem_type_id-readonly">
80 <span id="membership_type_id_0-readonly"></span> : <span id="membership_type_id_1-readonly"></span>
81 <span id="mem-type-override">
82 <a href="#" class="crm-hover-button action-item override-mem-type" id="show-mem-type">
83 {ts}Override organization and type{/ts}
85 {help id="override_membership_type"}
88 <td id="mem_type_id-editable"><span id='mem_type_id'>{$form.membership_type_id.html}</span>
90 <span id='totalAmountORPriceSet'> {ts}OR{/ts}</span>
91 <span id='selectPriceSet'>{$form.price_set_id.html}</span>
92 {if $buildPriceSet && $priceSet}
93 <div id="priceset"><br/>{include file="CRM/Price/Form/PriceSet.tpl" extends="Membership"}</div>
95 <div id="priceset" class="hiddenElement"></div>
98 {if $member_is_test} {ts}(test){/ts}{/if}<br />
99 <span class="description">{ts}Select Membership Organization and then Membership Type.{/ts}{if $hasPriceSets} {ts}Alternatively, you can use a price set.{/ts}{/if}</span>
102 <tr id="maxRelated" class="crm-membership-form-block-max_related">
103 <td class="label">{$form.max_related.label}</td>
104 <td>{$form.max_related.html}<br />
105 <span class="description">{ts}Maximum number of related memberships (leave blank for unlimited).{/ts} <span id="eligibleRelated"></span></span>
109 <tr id="num_terms_row" class="crm-membership-form-block-num_terms">
110 <td class="label">{$form.num_terms.label}</td>
111 <td> {$form.num_terms.html}<br />
112 <span class="description">{ts}Set the membership end date this many membership periods from now. Make sure the appropriate corresponding fee is entered below.{/ts}</span>
116 <tr class="crm-membership-form-block-source">
117 <td class="label">{$form.source.label}</td>
118 <td> {$form.source.html}<br />
119 <span class="description">{ts}Source of this membership. This value is searchable.{/ts}</span></td>
122 {* CRM-7362 --add campaign to membership *}
123 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
124 campaignTrClass="crm-membership-form-block-campaign_id"}
126 <tr class="crm-membership-form-block-join_date"><td class="label">{$form.join_date.label}</td><td>{$form.join_date.html}
128 <span class="description">{ts}When did this contact first become a member?{/ts}</span></td></tr>
129 <tr class="crm-membership-form-block-start_date"><td class="label">{$form.start_date.label}</td><td>{$form.start_date.html}
131 <span class="description">{ts}First day of current continuous membership period. Start Date will be automatically set based on Membership Type if you don't select a date.{/ts}</span></td></tr>
132 <tr class="crm-membership-form-block-end_date"><td class="label">{$form.end_date.label}</td>
133 <td id="end-date-readonly">
135 <a href="#" class="crm-hover-button action-item override-date" id="show-end-date">
136 {ts}Override end date{/ts}
138 {help id="override_end_date"}
140 <td id="end-date-editable">
141 {$form.end_date.html}
143 <span class="description">{ts}Latest membership period expiration date. End Date will be automatically set based on Membership Type if you don't select a date.{/ts}</span>
146 {if !$membershipMode}
148 <td class="label">{$form.is_override.label} {help id="id-status-override"}</td>
150 <span id="is-override">{$form.is_override.html}</span>
151 <span id="status-override-end-date">{$form.status_override_end_date.html}</span>
154 {* Show read-only Status block - when action is UPDATE and is_override is FALSE *}
155 <tr id="memberStatus_show">
157 <td class="label">{$form.status_id.label}</td><td class="view-value">{$membershipStatus}</td>
161 {* Show editable status field when is_override is TRUE *}
162 <tr id="memberStatus"><td class="label">{$form.status_id.label}</td><td>{$form.status_id.html}<br />
163 <span class="description">{ts}When <strong>Status Override</strong> is active, the selected status will remain in force (it will NOT be subject to membership status rules) until it is cancelled or become inactive.{/ts}</span></td></tr>
166 {if $accessContribution and !$membershipMode AND ($action neq 2 or (!$rows.0.contribution_id AND !$softCredit) or $onlinePendingContributionId)}
168 <td class="label">{if $onlinePendingContributionId}{ts}Update Payment Status{/ts}{else}{$form.record_contribution.label}{/if}</td>
169 <td>{$form.record_contribution.html}<br />
170 <span class="description">{ts}Check this box to enter or update payment information. You will also be able to generate a customized receipt.{/ts}</span></td>
172 <tr class="crm-membership-form-block-record_contribution"><td colspan="2">
173 <fieldset id="recordContribution"><legend>{ts}Membership Payment and Receipt{/ts}</legend>
175 {include file="CRM/Member/Form/MembershipCommon.tpl"}
176 {if $emailExists and $isEmailEnabledForSite}
177 <tr id="send-receipt" class="crm-membership-form-block-send_receipt">
178 <td class="label">{$form.send_receipt.label}</td>
180 {$form.send_receipt.html}<br />
181 <span class="description">
182 {ts 1=$emailExists}Automatically email a membership confirmation and receipt to %1? OR if the payment is from a different contact, this email will only go to them.{/ts}
183 <span class="auto-renew-text">{ts}For auto-renewing memberships the emails are sent when each payment is received{/ts}</span>
187 {elseif $context eq 'standalone' and $isEmailEnabledForSite}
188 <tr id="email-receipt" style="display:none;">
189 <td class="label">{$form.send_receipt.label}</td>
191 {$form.send_receipt.html}<br />
192 <span class="description">
193 {ts}Automatically email a membership confirmation and receipt to {/ts}<span id="email-address"></span>? {ts}OR if the payment is from a different contact, this email will only go to them.{/ts}
194 <span class="auto-renew-text">{ts}For auto-renewing memberships the emails are sent when each payment is received{/ts}</span>
199 <tr id="fromEmail" style="display: none" class="crm-contactEmail-form-block-fromEmailAddress crm-email-element">
200 <td class="label">{$form.from_email_address.label}</td>
201 <td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin}</td>
203 <tr id='notice' style="display:none;">
204 <td class="label">{$form.receipt_text.label}</td>
205 <td class="html-adjust"><span class="description">{ts}If you need to include a special message for this member, enter it here. Otherwise, the confirmation email will include the standard receipt message configured under System Message Templates.{/ts}</span>
206 {$form.receipt_text.html|crmAddClass:huge}</td>
209 {include file="CRM/common/customDataBlock.tpl"}
210 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
211 <div class="crm-accordion-wrapper">
212 <div class="crm-accordion-header">{ts}Related Contributions{/ts}</div>
213 <div class="crm-accordion-body">
214 {include file="CRM/Contribute/Form/Selector.tpl" context="Search"}
215 <script type="text/javascript">
216 var membershipID = {$entityID};
217 var contactID = {$contactId};
222 'civicrm/membership/recurring-contributions',
225 membershipID: membershipID,
231 target : '#membership-recurring-contributions',
238 <div id="membership-recurring-contributions"></div>
243 <div class="crm-accordion-wrapper">
244 <div class="crm-accordion-header">{ts}Related Soft Contributions{/ts}</div>
245 <div class="crm-accordion-body">{include file="CRM/Contribute/Page/ContributionSoft.tpl" context="membership"}</div>
250 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
251 </div> <!-- end form-block -->
253 {if $action neq 8} {* Jscript additions not need for Delete action *}
254 {if $accessContribution and !$membershipMode AND ($action neq 2 or !$rows.0.contribution_id or $onlinePendingContributionId)}
256 {include file="CRM/common/showHideByFieldValue.tpl"
257 trigger_field_id ="record_contribution"
259 target_element_id ="recordContribution"
260 target_element_type ="table-row"
267 <script type="text/javascript">
268 function setPaymentBlock(mode, checkboxEvent) {
269 var memType = parseInt(cj('#membership_type_id_1').val( ));
271 var existingAmount = {/literal}{if !empty($onlinePendingContributionId)}1{else}0{/if}{literal};
273 if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
277 if ( !memType || isPriceSet ) {
281 var allMemberships = {/literal}{$allMembershipInfo}{literal};
283 //check the record_contribution checkbox if membership is a paid one
284 {/literal}{if $action eq 1}{literal}
285 if (!checkboxEvent) {
286 if (allMemberships[memType]['total_amount_numeric'] > 0) {
287 cj('#record_contribution').prop('checked','checked');
288 cj('#recordContribution').show();
291 cj('#record_contribution').prop('checked', false);
292 cj('#recordContribution').hide();
295 {/literal}{/if}{literal}
298 // skip this for test and live modes because financial type is set automatically
299 cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
300 var term = cj('#num_terms').val();
301 var taxRates = {/literal}{$taxRates}{literal};
302 var taxTerm = {/literal}{$taxTerm|@json_encode}{literal};
303 var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
304 var currency = {/literal}{$currency_symbol|@json_encode}{literal};
305 var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
306 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
309 var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
312 var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number
313 (allMemberships[memType]['total_amount_numeric'] * term );
315 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
319 var feeTotal = parseFloat(Number((taxRate/100) * allMemberships[memType]['total_amount'])+Number(allMemberships[memType]['total_amount_numeric'])).toFixed(2);
320 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
323 var feeTotal = allMemberships[memType]['total_amount'];
324 if (!existingAmount) {
325 // CRM-16680 don't set amount if there is an existing contribution.
326 cj("#total_amount").val(allMemberships[memType]['total_amount']);
330 var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
331 cj('.totaltaxAmount').html(taxMessage);
336 var mode = {/literal}'{$membershipMode}'{literal};
338 // Offline form (mode = false) has the record_contribution checkbox
339 cj('#record_contribution').click( function( ) {
340 if ( cj(this).prop('checked') ) {
341 cj('#recordContribution').show( );
342 setPaymentBlock( false, true);
345 cj('#recordContribution').hide( );
350 cj('#membership_type_id_1').change( function( ) {
351 setPaymentBlock(mode);
353 cj('#num_terms').change( function( ) {
354 setPaymentBlock(mode);
356 setPaymentBlock(mode);
358 // show/hide different contact section
359 setDifferentContactBlock();
360 cj('#is_different_contribution_contact').change( function() {
361 setDifferentContactBlock();
364 // give option to override membership type for auto-renew memberships - dev/core#1331
367 cj('#membership_type_id_0-readonly').text(cj('#membership_type_id_0 option:selected').text());
368 cj('#membership_type_id_1-readonly').text(cj('#membership_type_id_1 option:selected').text());
369 cj('#mem_type_id-readonly').show();
370 cj('#mem_type_id-editable').hide();
372 cj('#mem_type_id-readonly').hide();
373 cj('#mem_type_id-editable').show();
377 cj('#show-mem-type').click( function( e ) {
379 cj('#mem_type_id-readonly').hide();
380 cj('#mem_type_id-editable').show();
383 // give option to override end-date for auto-renew memberships
385 {if $isRecur && $endDate}
386 cj('#end-date-readonly').show();
387 cj('#end-date-editable').hide();
389 cj('#end-date-readonly').hide();
390 cj('#end-date-editable').show();
394 cj('#show-end-date').click( function( e ) {
396 cj('#end-date-readonly').hide();
397 cj('#end-date-editable').show();
402 function setDifferentContactBlock( ) {
403 // show/hide different contact section
404 if ( cj('#is_different_contribution_contact').prop('checked') ) {
405 cj('#record-different-contact').show();
408 cj('#record-different-contact').hide();
412 function showEmailOptions() {
414 // @todo emailExists refers to the primary contact for the page.
415 // elsewhere some script determines if there is a paying contact the
416 // email should go to instead (e.g gift membership). This should be checked for here
417 // and that merged into that code as currently behaviour is inconsistent.
418 var emailExists = {$emailExists|json_encode};
419 var isStandalone = {if $context == 'standalone'}true{else}false{/if};
420 var isEmailEnabledForSite = {if $isEmailEnabledForSite}true{else}false{/if};
423 var isEmailable = (isEmailEnabledForSite && (emailExists || isStandalone));
425 if (isEmailable && cj('#send_receipt').prop('checked') && !cj('#auto_renew').prop('checked')) {
426 // Hide extra message and from email for recurring as they cannot be stored until use.
427 cj('#notice').show();
428 cj('#fromEmail').show();
431 cj('#notice').hide();
432 cj('#fromEmail').hide();
436 <script type="text/javascript">
438 {/literal}{if !$membershipMode}{literal}
439 cj( "#is_override" ).change(function() {
440 showHideMemberStatus();
443 showHideMemberStatus();
444 function showHideMemberStatus() {
445 var isOverride = cj( "#is_override" ).val();
446 switch (isOverride) {
448 cj('#memberStatus').hide();
449 cj('#memberStatus_show').show();
450 cj('#status-override-end-date').hide();
453 cj('#memberStatus').show();
454 cj('#memberStatus_show').hide();
455 cj('#status-override-end-date').hide();
458 cj('#memberStatus').show();
459 cj('#memberStatus_show').hide();
460 cj('#status-override-end-date').show();
463 cj('#memberStatus').hide( );
464 cj('#memberStatus_show').show( );
465 cj('#status-override-end-date').hide();
471 {if $context eq 'standalone' and $isEmailEnabledForSite }
474 var $form = $("form.{/literal}{$form.formClass}{literal}");
475 $("#contact_id", $form).change(checkEmail);
478 function checkEmail( ) {
479 var data = $("#contact_id", $form).select2('data');
480 if (data && data.extra && data.extra.email && data.extra.email.length) {
481 $("#email-receipt", $form).show();
482 if ($("#send_receipt", $form).is(':checked')) {
483 $("#notice", $form).show();
485 $("#email-address", $form).html(data.extra.email);
488 $("#email-receipt, #notice", $form).hide();
497 //keep read only always checked.
499 var $form = $("form.{/literal}{$form.formClass}{literal}");
500 var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
501 var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
502 if ( allowAutoRenew || alreadyAutoRenew ) {
503 $( "#auto_renew" ).click(function( ) {
504 if ( $(this).attr( 'readonly' ) ) {
505 $(this).prop('checked', true );
512 {if !empty($existingContactMemberships)}
514 var alert, memberorgs = {$existingContactMemberships|@json_encode};
517 $("select[name='membership_type_id[0]']").change(checkExistingMemOrg);
521 function checkExistingMemOrg () {
522 alert && alert.close && alert.close();
523 var selectedorg = $("select[name='membership_type_id[0]']").val();
524 if (selectedorg in memberorgs) {
526 endDate = memberorgs[selectedorg].membership_end_date,
527 org = $('option:selected', "select[name='membership_type_id[0]']").text();
529 andEndDate = '{/literal}{ts escape='js' 1='%1'}and end date of %1{/ts}{literal}';
530 andEndDate = ' ' + ts(andEndDate, {1:endDate});
534 // Mixing client-side variables with a translated string in smarty is awkward!
535 ts({/literal}'{ts escape='js'}This contact has an existing %1 membership at %2 with %3 status%4.{/ts}'{literal}, {1:memberorgs[selectedorg].membership_type, 2: org, 3: memberorgs[selectedorg].membership_status, 4: andEndDate})
536 + '<ul><li><a href="' + memberorgs[selectedorg].renewUrl + '">'
537 + {/literal}'{ts escape='js'}Renew the existing membership instead{/ts}'
538 + '</a></li><li><a href="' + memberorgs[selectedorg].membershipTab + '">'
539 + '{ts escape='js'}View all existing and / or expired memberships for this contact{/ts}'{literal}
541 '{/literal}{ts escape='js'}Duplicate Membership?{/ts}{literal}', 'alert');
544 checkExistingMemOrg();
553 {if $membershipMode or $action eq 2}
554 buildAutoRenew( null, null, '{$membershipMode}');
557 function buildAutoRenew( membershipType, processorId, mode ) {
558 var action = {/literal}'{$action}'{literal};
560 //for update lets hide it when not already recurring.
562 //user can't cancel auto renew by unchecking.
563 if (cj("#auto_renew").prop('checked')) {
564 cj("#auto_renew").attr('readonly', true);
567 cj("#autoRenew").hide( );
571 //we should do all auto renew for cc memberships.
576 //get the required values in case missing.
578 processorId = cj( '#payment_processor_id' ).val( );
580 if (!membershipType) {
581 membershipType = parseInt( cj('#membership_type_id_1').val( ) );
584 //we don't have both required values.
585 if (!processorId || !membershipType) {
586 cj("#auto_renew").prop('checked', false);
587 cj("#autoRenew").hide();
592 var recurProcessors = {/literal}{$recurProcessor}{literal};
593 var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
594 var currentOption = autoRenewOptions[membershipType];
596 if (!currentOption || !recurProcessors[processorId]) {
597 cj("#auto_renew").prop('checked', false );
598 cj("#autoRenew").hide();
602 if (currentOption == 1) {
603 cj("#autoRenew").show();
604 if (cj("#auto_renew").attr('readonly')) {
605 cj("#auto_renew").prop('checked', false).removeAttr('readonly');
608 else if ( currentOption == 2 ) {
609 cj("#autoRenew").show();
610 cj("#auto_renew").prop('checked', true).attr('readonly', true);
613 cj("#auto_renew").prop('checked', false);
614 cj("#autoRenew").hide( );
619 var customDataType = {/literal}{$customDataType|@json_encode}{literal};
621 // load form during form rule.
622 {/literal}{if $buildPriceSet}{literal}
623 cj("#totalAmountORPriceSet, #mem_type_id, #num_terms_row, .crm-membership-form-block-financial_type_id-mode").hide();
624 cj('#total_amount').attr("readonly", true);
625 {/literal}{/if}{literal}
627 function buildAmount( priceSetId ) {
629 priceSetId = cj("#price_set_id").val();
631 var fname = '#priceset';
633 cj('#membership_type_id_1').val(0);
634 CRM.buildCustomData(customDataType, null);
636 // hide price set fields.
639 // show/hide price set amount and total amount.
640 cj( "#mem_type_id").show( );
641 var choose = "{/literal}{ts escape='js'}Choose price set{/ts}{literal}";
642 cj("#price_set_id option[value='']").html( choose );
643 cj( "#totalAmountORPriceSet" ).show( );
644 cj('#total_amount').removeAttr("readonly");
645 cj( "#num_terms_row").show( );
646 cj(".crm-membership-form-block-financial_type_id-mode").show();
648 {/literal}{if $allowAutoRenew}{literal}
649 cj('#autoRenew').hide();
650 cj("#auto_renew").removeAttr('readOnly').prop('checked', false );
651 {/literal}{/if}{literal}
655 cj( "#total_amount" ).val('').attr("readonly", true);
657 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
659 var response = cj.ajax({
664 cj( fname ).show( ).html( response );
665 // freeze total amount text field.
667 cj( "#totalAmountORPriceSet" ).hide( );
668 cj( "#mem_type_id" ).hide( );
669 var manual = "{/literal}{ts escape='js'}Manual membership and price{/ts}{literal}";
670 cj("#price_set_id option[value='']").html( manual );
671 cj( "#num_terms_row" ).hide( );
672 cj(".crm-membership-form-block-financial_type_id-mode").hide();
675 buildMaxRelated(cj('#membership_type_id_1', false).val());
677 function buildMaxRelated( memType, setDefault ) {
678 var allMemberships = {/literal}{$allMembershipInfo}{literal};
680 if ((memType > 0) && (allMemberships[memType]['has_related'])) {
681 if (setDefault) cj('#max_related').val(allMemberships[memType]['max_related']);
682 cj('#maxRelated').show();
683 var cid = {/literal}{if $contactID}{$contactID}{else}null{/if}{literal};
685 CRM.api('relationship', 'getcount', {contact_id: cid, membership_type_id: memType}, {
686 success: function(result) {
688 if (result.result === 0) {
689 relatable = '{/literal}{ts escape='js'}No contacts are currently eligible to inherit this relationship.{/ts}{literal}';
691 else if (result.result === 1) {
692 relatable = '{/literal}{ts escape='js'}One contact is currently eligible to inherit this relationship.{/ts}{literal}';
695 relatable = '{/literal}{ts escape='js' 1='%1'}%1 contacts are currently eligible to inherit this relationship.{/ts}{literal}';
696 relatable = ts(relatable, {1: result});
698 cj('#eligibleRelated').text(relatable);
703 cj('#max_related').val('');
704 cj('#maxRelated').hide();
708 var lastMembershipTypes = [];
709 var optionsMembershipTypes = [];
711 // function to load custom data for selected membership types through priceset
712 function processMembershipPriceset( membershipValues, autoRenewOption, reload ) {
713 var currentMembershipType = [];
715 var loadCustomData = 0;
716 if ( membershipValues ) {
717 optionsMembershipTypes = membershipValues;
721 lastMembershipTypes = [];
722 {/literal}{if $allowAutoRenew}{literal}
723 cj('#autoRenew').hide();
724 var autoRenew = cj("#auto_renew");
725 autoRenew.removeAttr('readOnly').prop('checked', false );
726 if (autoRenewOption == 1) {
727 cj('#autoRenew').show();
729 else if (autoRenewOption == 2) {
730 autoRenew.attr('readOnly', true).prop('checked', true );
731 cj('#autoRenew').show();
733 {/literal}{/if}{literal}
736 cj("input,#priceset select,#priceset").each(function () {
737 if ( cj(this).attr('price') ) {
738 switch( cj(this).attr('type') ) {
740 if ( cj(this).prop('checked') ) {
741 eval( 'var option = ' + cj(this).attr('price') ) ;
743 var memTypeId = optionsMembershipTypes[ele];
744 if ( memTypeId && cj.inArray(optionsMembershipTypes[ele], currentMembershipType) == -1 ) {
745 currentMembershipType[count] = memTypeId;
750 cj(this).click( function( ) {
751 processMembershipPriceset();
757 if ( cj(this).prop('checked') && cj(this).val() ) {
758 var memTypeId = optionsMembershipTypes[cj(this).val()];
759 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
760 currentMembershipType[count] = memTypeId;
765 cj(this).click( function( ) {
766 processMembershipPriceset();
772 if ( cj(this).val( ) ) {
773 var memTypeId = optionsMembershipTypes[cj(this).val()];
774 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
775 currentMembershipType[count] = memTypeId;
780 cj(this).change( function( ) {
781 processMembershipPriceset();
789 for( i in currentMembershipType ) {
790 if ( cj.inArray(currentMembershipType[i], lastMembershipTypes) == -1 ) {
796 if ( !loadCustomData ) {
797 for( i in lastMembershipTypes) {
798 if ( cj.inArray(lastMembershipTypes[i], currentMembershipType) == -1 ) {
805 lastMembershipTypes = currentMembershipType;
807 // load custom data only if change in membership type selection
808 if ( !loadCustomData ) {
812 subTypeNames = currentMembershipType.join(',');
813 if ( subTypeNames.length < 1 ) {
817 CRM.buildCustomData(customDataType, subTypeNames);
820 function enableAmountSection( setContributionType ) {
821 if ( !cj('#record_contribution').prop('checked') ) {
822 cj('#record_contribution').click( );
823 cj('#recordContribution').show( );
825 if ( setContributionType ) {
826 cj('#financial_type_id').val(setContributionType);
831 {/if} {* closing of delete check if *}
832 {/if}{* closing of custom data if *}