2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2019 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
26 {* this template is used for adding/editing/deleting memberships for a contact *}
28 <div class="messages status no-popup">
29 <div class="icon inform-icon"></div>
30 <p>{ts 1=$cancelAutoRenew}This membership is set to renew automatically {if $endDate}on {$endDate|crmDate}{/if}. You will need to cancel the auto-renew option if you want to modify the Membership Type, End Date or Membership Status. <a href="%1">Click here</a> if you want to cancel the automatic renewal option.{/ts}</p>
33 <div class="spacer"></div>
35 {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Membership"}
37 <script type="text/javascript">
39 var membershipValues = [];
40 {/literal}{foreach from=$optionsMembershipTypes item=memType key=opId}{literal}
41 membershipValues[{/literal}{$opId}{literal}] = {/literal}{$memType}{literal};
42 {/literal}{/foreach}{literal}
43 processMembershipPriceset(membershipValues, {/literal}{$autoRenewOption}{literal}, 1);
44 {/literal}{if !$membershipMode}{literal}
45 enableAmountSection({/literal}{$contributionType}{literal});
46 {/literal}{/if}{literal}
51 {if $membershipMode == 'test' }
52 {assign var=registerMode value="TEST"}
53 {elseif $membershipMode == 'live'}
54 {assign var=registerMode value="LIVE"}
56 {if !$emailExists and $action neq 8 and $context neq 'standalone'}
57 <div class="messages status no-popup">
58 <div class="icon inform-icon"></div>
59 <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>
64 {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}
67 <div class="crm-block crm-form-block crm-membership-form-block">
68 {if $newCredit AND $action EQ 1 AND $membershipMode EQ null}
69 <div class="action-link css_right crm-link-credit-card-mode">
71 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/membership' q="reset=1&action=add&cid=`$contactId`&context=`$context`&mode=live"}{/capture}
73 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/membership' q="reset=1&action=add&context=standalone&mode=live"}{/capture}
75 <a class="open-inline-noreturn action-item crm-hover-button" href="{$ccModeLink}">» {ts}submit credit card membership{/ts}</a>
78 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
80 <div class="messages status no-popup">
81 <div class="icon inform-icon"></div>
85 <table class="form-layout-compressed">
86 {if $context neq 'standalone'}
88 <td class="font-size12pt label"><strong>{ts}Member{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
91 <td class="label">{$form.contact_id.label}</td>
92 <td>{$form.contact_id.html}</td>
94 <tr class="crm-membership-form-block-membership_type_id">
95 <td class="label">{$form.membership_type_id.label}</td>
96 <td><span id='mem_type_id'>{$form.membership_type_id.html}</span>
98 <span id='totalAmountORPriceSet'> {ts}OR{/ts}</span>
99 <span id='selectPriceSet'>{$form.price_set_id.html}</span>
100 {if $buildPriceSet && $priceSet}
101 <div id="priceset"><br/>{include file="CRM/Price/Form/PriceSet.tpl" extends="Membership"}</div>
103 <div id="priceset" class="hiddenElement"></div>
106 {if $member_is_test} {ts}(test){/ts}{/if}<br />
107 <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>
110 <tr id="maxRelated" class="crm-membership-form-block-max_related">
111 <td class="label">{$form.max_related.label}</td>
112 <td>{$form.max_related.html}<br />
113 <span class="description">{ts}Maximum number of related memberships (leave blank for unlimited).{/ts}</span>
117 <tr id="num_terms_row" class="crm-membership-form-block-num_terms">
118 <td class="label">{$form.num_terms.label}</td>
119 <td> {$form.num_terms.html}<br />
120 <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>
124 <tr class="crm-membership-form-block-source">
125 <td class="label">{$form.source.label}</td>
126 <td> {$form.source.html}<br />
127 <span class="description">{ts}Source of this membership. This value is searchable.{/ts}</span></td>
130 {* CRM-7362 --add campaign to membership *}
131 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
132 campaignTrClass="crm-membership-form-block-campaign_id"}
134 <tr class="crm-membership-form-block-join_date"><td class="label">{$form.join_date.label}</td><td>{$form.join_date.html}
136 <span class="description">{ts}When did this contact first become a member?{/ts}</span></td></tr>
137 <tr class="crm-membership-form-block-start_date"><td class="label">{$form.start_date.label}</td><td>{$form.start_date.html}
139 <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>
140 <tr class="crm-membership-form-block-end_date"><td class="label">{$form.end_date.label}</td>
141 <td id="end-date-readonly">
143 <a href="#" class="crm-hover-button action-item override-date" id="show-end-date">
144 {ts}Over-ride end date{/ts}
146 {help id="override_end_date"}
148 <td id="end-date-editable">
149 {$form.end_date.html}
151 <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>
154 {if !$membershipMode}
156 <td class="label">{$form.is_override.label} {help id="id-status-override"}</td>
158 <span id="is-override">{$form.is_override.html}</span>
159 <span id="status-override-end-date">{$form.status_override_end_date.html}</span>
162 {* Show read-only Status block - when action is UPDATE and is_override is FALSE *}
163 <tr id="memberStatus_show">
165 <td class="label">{$form.status_id.label}</td><td class="view-value">{$membershipStatus}</td>
169 {* Show editable status field when is_override is TRUE *}
170 <tr id="memberStatus"><td class="label">{$form.status_id.label}</td><td>{$form.status_id.html}<br />
171 <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>
174 {if $accessContribution and !$membershipMode AND ($action neq 2 or (!$rows.0.contribution_id AND !$softCredit) or $onlinePendingContributionId)}
176 <td class="label">{if $onlinePendingContributionId}{ts}Update Payment Status{/ts}{else}{$form.record_contribution.label}{/if}</td>
177 <td>{$form.record_contribution.html}<br />
178 <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>
180 <tr class="crm-membership-form-block-record_contribution"><td colspan="2">
181 <fieldset id="recordContribution"><legend>{ts}Membership Payment and Receipt{/ts}</legend>
183 {include file="CRM/Member/Form/MembershipCommon.tpl"}
184 {if $emailExists and $isEmailEnabledForSite}
185 <tr id="send-receipt" class="crm-membership-form-block-send_receipt">
186 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
187 <span class="description">{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}</span></td>
188 <span class="auto-renew-text">{ts}For auto-renewing memberships the emails are sent when each payment is received{/ts}</span>
190 {elseif $context eq 'standalone' and $isEmailEnabledForSite}
191 <tr id="email-receipt" style="display:none;">
192 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
193 <span class="description">{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}</span></td>
194 <span class="auto-renew-text">{ts}For auto-renewing memberships the emails are sent when each payment is received{/ts}</span>
197 <tr id="fromEmail" style="display: none" class="crm-contactEmail-form-block-fromEmailAddress crm-email-element">
198 <td class="label">{$form.from_email_address.label}</td>
199 <td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin}</td>
201 <tr id='notice' style="display:none;">
202 <td class="label">{$form.receipt_text.label}</td>
203 <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>
204 {$form.receipt_text.html|crmAddClass:huge}</td>
207 {include file="CRM/common/customDataBlock.tpl"}
208 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
209 <div class="crm-accordion-wrapper">
210 <div class="crm-accordion-header">{ts}Related Contributions{/ts}</div>
211 <div class="crm-accordion-body">
212 {include file="CRM/Contribute/Form/Selector.tpl" context="Search"}
213 <script type="text/javascript">
214 var membershipID = {$entityID};
215 var contactID = {$contactId};
220 'civicrm/membership/recurring-contributions',
223 membershipID: membershipID,
229 target : '#membership-recurring-contributions',
236 <div id="membership-recurring-contributions"></div>
241 <div class="crm-accordion-wrapper">
242 <div class="crm-accordion-header">{ts}Related Soft Contributions{/ts}</div>
243 <div class="crm-accordion-body">{include file="CRM/Contribute/Page/ContributionSoft.tpl" context="membership"}</div>
248 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
249 </div> <!-- end form-block -->
251 {if $action neq 8} {* Jscript additions not need for Delete action *}
252 {if $accessContribution and !$membershipMode AND ($action neq 2 or !$rows.0.contribution_id or $onlinePendingContributionId)}
254 {include file="CRM/common/showHideByFieldValue.tpl"
255 trigger_field_id ="record_contribution"
257 target_element_id ="recordContribution"
258 target_element_type ="table-row"
265 <script type="text/javascript">
266 function setPaymentBlock(mode, checkboxEvent) {
267 var memType = parseInt(cj('#membership_type_id_1').val( ));
269 var existingAmount = {/literal}{if !empty($onlinePendingContributionId)}1{else}0{/if}{literal};
271 if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
275 if ( !memType || isPriceSet ) {
279 var allMemberships = {/literal}{$allMembershipInfo}{literal};
281 //check the record_contribution checkbox if membership is a paid one
282 {/literal}{if $action eq 1}{literal}
283 if (!checkboxEvent) {
284 if (allMemberships[memType]['total_amount_numeric'] > 0) {
285 cj('#record_contribution').prop('checked','checked');
286 cj('#recordContribution').show();
289 cj('#record_contribution').prop('checked', false);
290 cj('#recordContribution').hide();
293 {/literal}{/if}{literal}
296 // skip this for test and live modes because financial type is set automatically
297 cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
298 var term = cj('#num_terms').val();
299 var taxRates = {/literal}{$taxRates}{literal};
300 var taxTerm = {/literal}{$taxTerm|@json_encode}{literal};
301 var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
302 var currency = {/literal}{$currency|@json_encode}{literal};
303 var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
304 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
307 var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
310 var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number
311 (allMemberships[memType]['total_amount_numeric'] * term );
313 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
317 var feeTotal = parseFloat(Number((taxRate/100) * allMemberships[memType]['total_amount'])+Number(allMemberships[memType]['total_amount_numeric'])).toFixed(2);
318 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
321 var feeTotal = allMemberships[memType]['total_amount'];
322 if (!existingAmount) {
323 // CRM-16680 don't set amount if there is an existing contribution.
324 cj("#total_amount").val(allMemberships[memType]['total_amount']);
328 var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
329 cj('.totaltaxAmount').html(taxMessage);
334 var mode = {/literal}'{$membershipMode}'{literal};
336 // Offline form (mode = false) has the record_contribution checkbox
337 cj('#record_contribution').click( function( ) {
338 if ( cj(this).prop('checked') ) {
339 cj('#recordContribution').show( );
340 setPaymentBlock( false, true);
343 cj('#recordContribution').hide( );
348 cj('#membership_type_id_1').change( function( ) {
349 setPaymentBlock(mode);
351 cj('#num_terms').change( function( ) {
352 setPaymentBlock(mode);
354 setPaymentBlock(mode);
356 // show/hide different contact section
357 setDifferentContactBlock();
358 cj('#is_different_contribution_contact').change( function() {
359 setDifferentContactBlock();
362 // give option to override end-date for auto-renew memberships
364 {if $isRecur && $endDate}
365 cj('#end-date-readonly').show();
366 cj('#end-date-editable').hide();
368 cj('#end-date-readonly').hide();
369 cj('#end-date-editable').show();
373 cj('#show-end-date').click( function( e ) {
375 cj('#end-date-readonly').hide();
376 cj('#end-date-editable').show();
381 function setDifferentContactBlock( ) {
382 // show/hide different contact section
383 if ( cj('#is_different_contribution_contact').prop('checked') ) {
384 cj('#record-different-contact').show();
387 cj('#record-different-contact').hide();
391 function showEmailOptions() {
393 // @todo emailExists refers to the primary contact for the page.
394 // elsewhere some script determines if there is a paying contact the
395 // email should go to instead (e.g gift membership). This should be checked for here
396 // and that merged into that code as currently behaviour is inconsistent.
397 var emailExists = {$emailExists|json_encode};
398 var isStandalone = {if $context == 'standalone'}true{else}false{/if};
399 var isEmailEnabledForSite = {if $isEmailEnabledForSite}true{else}false{/if};
402 var isEmailable = (isEmailEnabledForSite && (emailExists || isStandalone));
404 if (isEmailable && cj('#send_receipt').prop('checked') && !cj('#auto_renew').prop('checked')) {
405 // Hide extra message and from email for recurring as they cannot be stored until use.
406 cj('#notice').show();
407 cj('#fromEmail').show();
410 cj('#notice').hide();
411 cj('#fromEmail').hide();
415 <script type="text/javascript">
417 {/literal}{if !$membershipMode}{literal}
418 cj( "#is_override" ).change(function() {
419 showHideMemberStatus();
422 showHideMemberStatus();
423 function showHideMemberStatus() {
424 var isOverride = cj( "#is_override" ).val();
425 switch (isOverride) {
427 cj('#memberStatus').hide();
428 cj('#memberStatus_show').show();
429 cj('#status-override-end-date').hide();
432 cj('#memberStatus').show();
433 cj('#memberStatus_show').hide();
434 cj('#status-override-end-date').hide();
437 cj('#memberStatus').show();
438 cj('#memberStatus_show').hide();
439 cj('#status-override-end-date').show();
442 cj('#memberStatus').hide( );
443 cj('#memberStatus_show').show( );
444 cj('#status-override-end-date').hide();
450 {if $context eq 'standalone' and $isEmailEnabledForSite }
453 var $form = $("form.{/literal}{$form.formClass}{literal}");
454 $("#contact_id", $form).change(checkEmail);
457 function checkEmail( ) {
458 var data = $("#contact_id", $form).select2('data');
459 if (data && data.extra && data.extra.email && data.extra.email.length) {
460 $("#email-receipt", $form).show();
461 if ($("#send_receipt", $form).is(':checked')) {
462 $("#notice", $form).show();
464 $("#email-address", $form).html(data.extra.email);
467 $("#email-receipt, #notice", $form).hide();
476 //keep read only always checked.
478 var $form = $("form.{/literal}{$form.formClass}{literal}");
479 var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
480 var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
481 if ( allowAutoRenew || alreadyAutoRenew ) {
482 $( "#auto_renew" ).click(function( ) {
483 if ( $(this).attr( 'readonly' ) ) {
484 $(this).prop('checked', true );
491 {if !empty($existingContactMemberships)}
493 var alert, memberorgs = {$existingContactMemberships|@json_encode};
496 $("select[name='membership_type_id[0]']").change(checkExistingMemOrg);
500 function checkExistingMemOrg () {
501 alert && alert.close && alert.close();
502 var selectedorg = $("select[name='membership_type_id[0]']").val();
503 if (selectedorg in memberorgs) {
505 endDate = memberorgs[selectedorg].membership_end_date,
506 org = $('option:selected', "select[name='membership_type_id[0]']").text();
508 andEndDate = '{/literal}{ts escape='js' 1='%1'}and end date of %1{/ts}{literal}';
509 andEndDate = ' ' + ts(andEndDate, {1:endDate});
513 // Mixing client-side variables with a translated string in smarty is awkward!
514 ts({/literal}'{ts escape='js' 1='%1' 2='%2' 3='%3' 4='%4'}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})
515 + '<ul><li><a href="' + memberorgs[selectedorg].renewUrl + '">'
516 + {/literal}'{ts escape='js'}Renew the existing membership instead{/ts}'
517 + '</a></li><li><a href="' + memberorgs[selectedorg].membershipTab + '">'
518 + '{ts escape='js'}View all existing and / or expired memberships for this contact{/ts}'{literal}
520 '{/literal}{ts escape='js'}Duplicate Membership?{/ts}{literal}', 'alert');
523 checkExistingMemOrg();
532 {if $membershipMode or $action eq 2}
534 buildAutoRenew( null, null, '{$membershipMode}');
536 function buildAutoRenew( membershipType, processorId, mode ) {
537 var action = {/literal}'{$action}'{literal};
539 //for update lets hide it when not already recurring.
541 //user can't cancel auto renew by unchecking.
542 if (cj("#auto_renew").prop('checked')) {
543 cj("#auto_renew").attr('readonly', true);
546 cj("#autoRenew").hide( );
550 //we should do all auto renew for cc memberships.
555 //get the required values in case missing.
557 processorId = cj( '#payment_processor_id' ).val( );
559 if (!membershipType) {
560 membershipType = parseInt( cj('#membership_type_id_1').val( ) );
563 //we don't have both required values.
564 if (!processorId || !membershipType) {
565 cj("#auto_renew").prop('checked', false);
566 cj("#autoRenew").hide();
571 var recurProcessors = {/literal}{$recurProcessor}{literal};
572 var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
573 var currentOption = autoRenewOptions[membershipType];
575 if (!currentOption || !recurProcessors[processorId]) {
576 cj("#auto_renew").prop('checked', false );
577 cj("#autoRenew").hide();
581 if (currentOption == 1) {
582 cj("#autoRenew").show();
583 if (cj("#auto_renew").attr('readonly')) {
584 cj("#auto_renew").prop('checked', false).removeAttr('readonly');
587 else if ( currentOption == 2 ) {
588 cj("#autoRenew").show();
589 cj("#auto_renew").prop('checked', true).attr('readonly', true);
592 cj("#auto_renew").prop('checked', false);
593 cj("#autoRenew").hide( );
602 var customDataType = {/literal}{$customDataType|@json_encode}{literal};
604 // load form during form rule.
605 {/literal}{if $buildPriceSet}{literal}
606 cj("#totalAmountORPriceSet, #mem_type_id, #num_terms_row, .crm-membership-form-block-financial_type_id-mode").hide();
607 cj('#total_amount').attr("readonly", true);
608 {/literal}{/if}{literal}
610 function buildAmount( priceSetId ) {
612 priceSetId = cj("#price_set_id").val();
614 var fname = '#priceset';
616 cj('#membership_type_id_1').val(0);
617 CRM.buildCustomData(customDataType, null);
619 // hide price set fields.
622 // show/hide price set amount and total amount.
623 cj( "#mem_type_id").show( );
624 var choose = "{/literal}{ts escape='js'}Choose price set{/ts}{literal}";
625 cj("#price_set_id option[value='']").html( choose );
626 cj( "#totalAmountORPriceSet" ).show( );
627 cj('#total_amount').removeAttr("readonly");
628 cj( "#num_terms_row").show( );
629 cj(".crm-membership-form-block-financial_type_id-mode").show();
631 {/literal}{if $allowAutoRenew}{literal}
632 cj('#autoRenew').hide();
633 cj("#auto_renew").removeAttr('readOnly').prop('checked', false );
634 {/literal}{/if}{literal}
638 cj( "#total_amount" ).val('').attr("readonly", true);
640 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
642 var response = cj.ajax({
647 cj( fname ).show( ).html( response );
648 // freeze total amount text field.
650 cj( "#totalAmountORPriceSet" ).hide( );
651 cj( "#mem_type_id" ).hide( );
652 var manual = "{/literal}{ts escape='js'}Manual membership and price{/ts}{literal}";
653 cj("#price_set_id option[value='']").html( manual );
654 cj( "#num_terms_row" ).hide( );
655 cj(".crm-membership-form-block-financial_type_id-mode").hide();
658 buildMaxRelated(cj('#membership_type_id_1', false).val());
660 function buildMaxRelated( memType, setDefault ) {
661 var allMemberships = {/literal}{$allMembershipInfo}{literal};
663 if ((memType > 0) && (allMemberships[memType]['has_related'])) {
664 if (setDefault) cj('#max_related').val(allMemberships[memType]['max_related']);
665 cj('#maxRelated').show();
666 var cid = {/literal}{if $contactID}{$contactID}{else}null{/if}{literal};
668 CRM.api('relationship', 'getcount', {contact_id: cid, membership_type_id: memType}, {
669 success: function(result) {
671 if (result.result === 0) {
672 relatable = '{/literal}{ts escape='js'}No contacts are currently eligible to inherit this relationship.{/ts}{literal}';
674 else if (result.result === 1) {
675 relatable = '{/literal}{ts escape='js'}One contact is currently eligible to inherit this relationship.{/ts}{literal}';
678 relatable = '{/literal}{ts escape='js' 1='%1'}%1 contacts are currently eligible to inherit this relationship.{/ts}{literal}';
679 relatable = ts(relatable, {1: result});
681 cj('#max_related').siblings('.description').append(' ' + relatable);
686 cj('#max_related').val('');
687 cj('#maxRelated').hide();
691 var lastMembershipTypes = [];
692 var optionsMembershipTypes = [];
694 // function to load custom data for selected membership types through priceset
695 function processMembershipPriceset( membershipValues, autoRenewOption, reload ) {
696 var currentMembershipType = [];
698 var loadCustomData = 0;
699 if ( membershipValues ) {
700 optionsMembershipTypes = membershipValues;
704 lastMembershipTypes = [];
705 {/literal}{if $allowAutoRenew}{literal}
706 cj('#autoRenew').hide();
707 var autoRenew = cj("#auto_renew");
708 autoRenew.removeAttr('readOnly').prop('checked', false );
709 if (autoRenewOption == 1) {
710 cj('#autoRenew').show();
712 else if (autoRenewOption == 2) {
713 autoRenew.attr('readOnly', true).prop('checked', true );
714 cj('#autoRenew').show();
716 {/literal}{/if}{literal}
719 cj("input,#priceset select,#priceset").each(function () {
720 if ( cj(this).attr('price') ) {
721 switch( cj(this).attr('type') ) {
723 if ( cj(this).prop('checked') ) {
724 eval( 'var option = ' + cj(this).attr('price') ) ;
726 var memTypeId = optionsMembershipTypes[ele];
727 if ( memTypeId && cj.inArray(optionsMembershipTypes[ele], currentMembershipType) == -1 ) {
728 currentMembershipType[count] = memTypeId;
733 cj(this).click( function( ) {
734 processMembershipPriceset();
740 if ( cj(this).prop('checked') && cj(this).val() ) {
741 var memTypeId = optionsMembershipTypes[cj(this).val()];
742 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
743 currentMembershipType[count] = memTypeId;
748 cj(this).click( function( ) {
749 processMembershipPriceset();
755 if ( cj(this).val( ) ) {
756 var memTypeId = optionsMembershipTypes[cj(this).val()];
757 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
758 currentMembershipType[count] = memTypeId;
763 cj(this).change( function( ) {
764 processMembershipPriceset();
772 for( i in currentMembershipType ) {
773 if ( cj.inArray(currentMembershipType[i], lastMembershipTypes) == -1 ) {
779 if ( !loadCustomData ) {
780 for( i in lastMembershipTypes) {
781 if ( cj.inArray(lastMembershipTypes[i], currentMembershipType) == -1 ) {
788 lastMembershipTypes = currentMembershipType;
790 // load custom data only if change in membership type selection
791 if ( !loadCustomData ) {
795 subTypeNames = currentMembershipType.join(',');
796 if ( subTypeNames.length < 1 ) {
800 CRM.buildCustomData(customDataType, subTypeNames);
803 function enableAmountSection( setContributionType ) {
804 if ( !cj('#record_contribution').prop('checked') ) {
805 cj('#record_contribution').click( );
806 cj('#recordContribution').show( );
808 if ( setContributionType ) {
809 cj('#financial_type_id').val(setContributionType);
814 {/if} {* closing of delete check if *}
815 {/if}{* closing of custom data if *}