2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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/Custom/Form/CustomData.tpl"}
37 {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Membership"}
39 <script type="text/javascript">
41 var membershipValues = [];
42 {/literal}{foreach from=$optionsMembershipTypes item=memType key=opId}{literal}
43 membershipValues[{/literal}{$opId}{literal}] = {/literal}{$memType}{literal};
44 {/literal}{/foreach}{literal}
45 processMembershipPriceset(membershipValues, {/literal}{$autoRenewOption}{literal}, 1);
46 {/literal}{if !$membershipMode}{literal}
47 enableAmountSection({/literal}{$contributionType}{literal});
48 {/literal}{/if}{literal}
53 {if $membershipMode == 'test' }
54 {assign var=registerMode value="TEST"}
55 {elseif $membershipMode == 'live'}
56 {assign var=registerMode value="LIVE"}
58 {if !$emailExists and $action neq 8 and $context neq 'standalone'}
59 <div class="messages status no-popup">
60 <div class="icon inform-icon"></div>
61 <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>
66 {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}
69 <div class="crm-block crm-form-block crm-membership-form-block">
70 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
72 <div class="messages status no-popup">
73 <div class="icon inform-icon"></div>
74 <span class="font-red bold">{ts}WARNING: Deleting this membership will also delete any related payment (contribution) records.{/ts} {ts}This action cannot be undone.{/ts}</span>
75 <p>{ts}Consider modifying the membership status instead if you want to maintain an audit trail and avoid losing payment data. You can set the status to Cancelled by editing the membership and clicking the Status Override checkbox.{/ts}</p>
76 <p>{ts}Click 'Delete' if you want to continue.{/ts}</p>
79 <table class="form-layout-compressed">
80 {if $context neq 'standalone'}
82 <td class="font-size12pt label"><strong>{ts}Member{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
85 <td class="label">{$form.contact_id.label}</td>
86 <td>{$form.contact_id.html}</td>
90 <td class="label">{$form.payment_processor_id.label}</td>
91 <td>{$form.payment_processor_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>{include file="CRM/common/jcalendar.tpl" elementName=join_date}
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>{include file="CRM/common/jcalendar.tpl" elementName=start_date}
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 {include file="CRM/common/jcalendar.tpl" elementName=end_date}
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}
155 <tr><td class="label">{$form.is_override.label} {help id="id-status-override"}</td><td>{$form.is_override.html}</td></tr>
156 {* Show read-only Status block - when action is UPDATE and is_override is FALSE *}
157 <tr id="memberStatus_show">
159 <td class="label">{$form.status_id.label}</td><td class="view-value">{$membershipStatus}</td>
163 {* Show editable status field when is_override is TRUE *}
164 <tr id="memberStatus"><td class="label">{$form.status_id.label}</td><td>{$form.status_id.html}<br />
165 <span class="description">{ts}If <strong>Status Override</strong> is checked, the selected status will remain in force (it will NOT be modified by the automated status update script).{/ts}</span></td></tr>
168 {if $accessContribution and !$membershipMode AND ($action neq 2 or (!$rows.0.contribution_id AND !$softCredit) or $onlinePendingContributionId)}
170 <td class="label">{if $onlinePendingContributionId}{ts}Update Payment Status{/ts}{else}{$form.record_contribution.label}{/if}</td>
171 <td>{$form.record_contribution.html}<br />
172 <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>
174 <tr class="crm-membership-form-block-record_contribution"><td colspan="2">
175 <fieldset id="recordContribution"><legend>{ts}Membership Payment and Receipt{/ts}</legend>
177 {include file="CRM/Member/Form/MembershipCommon.tpl"}
179 {if $emailExists and $outBound_option != 2}
180 <tr id="send-receipt" class="crm-membership-form-block-send_receipt">
181 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
182 <span class="description">{ts 1=$emailExists}Automatically email a membership confirmation and receipt to %1?{/ts}</span></td>
184 {elseif $context eq 'standalone' and $outBound_option != 2}
185 <tr id="email-receipt" style="display:none;">
186 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
187 <span class="description">{ts}Automatically email a membership confirmation and receipt to {/ts}<span id="email-address"></span>?</span></td>
190 <tr id="fromEmail" style="display:none;">
191 <td class="label">{$form.from_email_address.label}</td>
192 <td>{$form.from_email_address.html}</td>
194 <tr id='notice' style="display:none;">
195 <td class="label">{$form.receipt_text.label}</td>
196 <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>
197 {$form.receipt_text.html|crmAddClass:huge}</td>
200 <div id="customData"></div>
201 {*include custom data js file*}
202 {include file="CRM/common/customData.tpl"}
204 <script type="text/javascript">
207 CRM.buildCustomData( '{$customDataType}' );
208 {if $customDataSubType}
209 CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
215 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
216 <div class="crm-accordion-wrapper">
217 <div class="crm-accordion-header">{ts}Related Contributions{/ts}</div>
218 <div class="crm-accordion-body">{include file="CRM/Contribute/Form/Selector.tpl" context="Search"}</div>
222 <div class="crm-accordion-wrapper">
223 <div class="crm-accordion-header">{ts}Related Soft Contributions{/ts}</div>
224 <div class="crm-accordion-body">{include file="CRM/Contribute/Page/ContributionSoft.tpl" context="membership"}</div>
229 <div class="spacer"></div>
230 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
231 </div> <!-- end form-block -->
233 {if $action neq 8} {* Jscript additions not need for Delete action *}
234 {if $accessContribution and !$membershipMode AND ($action neq 2 or !$rows.0.contribution_id or $onlinePendingContributionId)}
236 {include file="CRM/common/showHideByFieldValue.tpl"
237 trigger_field_id ="record_contribution"
239 target_element_id ="recordContribution"
240 target_element_type ="table-row"
244 {include file="CRM/common/showHideByFieldValue.tpl"
245 trigger_field_id ="payment_instrument_id"
247 target_element_id ="checkNumber"
248 target_element_type ="table-row"
255 <script type="text/javascript">
256 function setPaymentBlock(mode, checkboxEvent) {
257 var memType = parseInt(cj('#membership_type_id_1').val( ));
259 var existingAmount = {/literal}{if !empty($onlinePendingContributionId)}1{else}0{/if}{literal};
261 if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
265 if ( !memType || isPriceSet ) {
269 var allMemberships = {/literal}{$allMembershipInfo}{literal};
271 //check the record_contribution checkbox if membership is a paid one
272 {/literal}{if $action eq 1}{literal}
273 if (!checkboxEvent) {
274 if (allMemberships[memType]['total_amount_numeric'] > 0) {
275 cj('#record_contribution').prop('checked','checked');
276 cj('#recordContribution').show();
279 cj('#record_contribution').prop('checked', false);
280 cj('#recordContribution').hide();
283 {/literal}{/if}{literal}
286 // skip this for test and live modes because financial type is set automatically
287 cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
288 var term = cj('#num_terms').val();
289 var taxRates = '{/literal}{$taxRates}{literal}';
290 var taxTerm = '{/literal}{$taxTerm}{literal}';
291 var taxRates = JSON.parse(taxRates);
292 var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
293 var currency = '{/literal}{$currency}{literal}';
294 var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
295 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
298 var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
301 var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number
302 (allMemberships[memType]['total_amount_numeric'] * term );
304 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
308 var feeTotal = parseFloat(Number((taxRate/100) * allMemberships[memType]['total_amount'])+Number(allMemberships[memType]['total_amount_numeric'])).toFixed(2);
309 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
312 var feeTotal = allMemberships[memType]['total_amount'];
313 if (!existingAmount) {
314 // CRM-16680 don't set amount if there is an existing contribution.
315 cj("#total_amount").val(allMemberships[memType]['total_amount']);
319 var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
320 cj('.totaltaxAmount').html(taxMessage);
325 var mode = {/literal}'{$membershipMode}'{literal};
327 // Offline form (mode = false) has the record_contribution checkbox
328 cj('#record_contribution').click( function( ) {
329 if ( cj(this).prop('checked') ) {
330 cj('#recordContribution').show( );
331 setPaymentBlock( false, true);
334 cj('#recordContribution').hide( );
339 cj('#membership_type_id_1').change( function( ) {
340 setPaymentBlock(mode);
342 cj('#num_terms').change( function( ) {
343 setPaymentBlock(mode);
345 setPaymentBlock(mode);
347 // show/hide different contact section
348 setDifferentContactBlock();
349 cj('#is_different_contribution_contact').change( function() {
350 setDifferentContactBlock();
353 // give option to override end-date for auto-renew memberships
355 {if $isRecur && $endDate}
356 cj('#end-date-readonly').show();
357 cj('#end-date-editable').hide();
359 cj('#end-date-readonly').hide();
360 cj('#end-date-editable').show();
364 cj('#show-end-date').click( function( e ) {
366 cj('#end-date-readonly').hide();
367 cj('#end-date-editable').show();
372 function setDifferentContactBlock( ) {
373 // show/hide different contact section
374 if ( cj('#is_different_contribution_contact').prop('checked') ) {
375 cj('#record-different-contact').show();
378 cj('#record-different-contact').hide();
385 {if ($emailExists and $outBound_option != 2) OR $context eq 'standalone' }
386 {include file="CRM/common/showHideByFieldValue.tpl"
387 trigger_field_id ="send_receipt"
389 target_element_id ="notice"
390 target_element_type ="table-row"
394 {include file="CRM/common/showHideByFieldValue.tpl"
395 trigger_field_id ="send_receipt"
397 target_element_id ="fromEmail"
398 target_element_type ="table-row"
405 <script type="text/javascript">
407 {/literal}{if !$membershipMode}{literal}
408 showHideMemberStatus();
409 function showHideMemberStatus() {
410 if ( cj( "#is_override" ).prop('checked' ) ) {
411 cj('#memberStatus').show( );
412 cj('#memberStatus_show').hide( );
415 cj('#memberStatus').hide( );
416 cj('#memberStatus_show').show( );
421 {if $context eq 'standalone' and $outBound_option != 2 }
424 var $form = $("form.{/literal}{$form.formClass}{literal}");
425 $("#contact_id", $form).change(checkEmail);
428 function checkEmail( ) {
429 var data = $("#contact_id", $form).select2('data');
430 if (data && data.extra && data.extra.email && data.extra.email.length) {
431 $("#email-receipt", $form).show();
432 if ($("#send_receipt", $form).is(':checked')) {
433 $("#notice", $form).show();
435 $("#email-address", $form).html(data.extra.email);
438 $("#email-receipt, #notice", $form).hide();
447 //keep read only always checked.
449 var $form = $("form.{/literal}{$form.formClass}{literal}");
450 var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
451 var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
452 if ( allowAutoRenew || alreadyAutoRenew ) {
453 $( "#auto_renew" ).click(function( ) {
454 if ( $(this).attr( 'readonly' ) ) {
455 $(this).prop('checked', true );
461 {if !empty($existingContactMemberships)}
463 var alert, memberorgs = {$existingContactMemberships|@json_encode};
466 $("select[name='membership_type_id[0]']").change(checkExistingMemOrg);
470 function checkExistingMemOrg () {
471 alert && alert.close && alert.close();
472 var selectedorg = $("select[name='membership_type_id[0]']").val();
473 if (selectedorg in memberorgs) {
475 endDate = memberorgs[selectedorg].membership_end_date,
476 org = $('option:selected', "select[name='membership_type_id[0]']").text();
478 andEndDate = '{/literal}{ts escape='js' 1='%1'}and end date of %1{/ts}{literal}';
479 andEndDate = ' ' + ts(andEndDate, {1:endDate});
483 // Mixing client-side variables with a translated string in smarty is awkward!
484 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})
485 + '<ul><li><a href="' + memberorgs[selectedorg].renewUrl + '">'
486 + {/literal}'{ts escape='js'}Renew the existing membership instead{/ts}'
487 + '</a></li><li><a href="' + memberorgs[selectedorg].membershipTab + '">'
488 + '{ts escape='js'}View all existing and / or expired memberships for this contact{/ts}'{literal}
490 '{/literal}{ts escape='js'}Duplicate Membership?{/ts}{literal}', 'alert');
493 checkExistingMemOrg();
502 {if $membershipMode or $action eq 2}
505 buildAutoRenew( null, null );
507 function buildAutoRenew( membershipType, processorId ) {
508 var mode = {/literal}'{$membershipMode}'{literal};
509 var action = {/literal}'{$action}'{literal};
511 //for update lets hide it when not already recurring.
513 //user can't cancel auto renew by unchecking.
514 if ( cj("#auto_renew").prop('checked' ) ) {
515 cj("#auto_renew").attr( 'readonly', true );
518 cj("#autoRenew").hide( );
522 //we should do all auto renew for cc memberships.
525 //get the required values in case missing.
526 if ( !processorId ) processorId = cj( '#payment_processor_id' ).val( );
527 if ( !membershipType ) membershipType = parseInt( cj('#membership_type_id_1').val( ) );
529 //we don't have both required values.
530 if ( !processorId || !membershipType ) {
531 cj("#auto_renew").prop('checked', false );
532 cj("#autoRenew").hide( );
536 var recurProcessors = {/literal}{$recurProcessor}{literal};
537 var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
538 var currentOption = autoRenewOptions[membershipType];
540 if ( !currentOption || !recurProcessors[processorId] ) {
541 cj("#auto_renew").prop('checked', false );
542 cj("#autoRenew").hide( );
546 if ( currentOption == 1 ) {
547 cj("#autoRenew").show( );
548 if ( cj("#auto_renew").attr( 'readonly' ) ) {
549 cj("#auto_renew").prop('checked', false );
550 cj("#auto_renew").removeAttr( 'readonly' );
553 else if ( currentOption == 2 ) {
554 cj("#autoRenew").show( );
555 cj("#auto_renew").prop('checked', true );
556 cj("#auto_renew").attr( 'readonly', true );
559 cj("#auto_renew").prop('checked', false );
560 cj("#autoRenew").hide( );
563 //play w/ receipt option.
564 if ( cj("#auto_renew").prop('checked' ) ) {
565 cj("#notice").hide( );
566 cj("#send_receipt").prop('checked', false );
567 cj("#send-receipt").hide( );
570 cj("#send-receipt").show( );
571 if ( cj("#send_receipt").prop('checked' ) ) {
572 cj("#notice").show( );
580 function buildReceiptANDNotice( ) {
581 if ( cj("#auto_renew").prop('checked' ) ) {
582 cj("#notice").hide( );
583 cj("#send-receipt").hide( );
586 cj("#send-receipt").show( );
587 if ( cj("#send_receipt").prop('checked' ) ) {
588 cj("#notice").show( );
593 var customDataType = '{/literal}{$customDataType}{literal}';
595 // load form during form rule.
596 {/literal}{if $buildPriceSet}{literal}
597 cj( "#totalAmountORPriceSet" ).hide( );
598 cj( "#mem_type_id" ).hide( );
599 cj('#total_amount').attr("readonly", true);
600 cj( "#num_terms_row" ).hide( );
601 cj(".crm-membership-form-block-financial_type_id-mode").hide();
602 {/literal}{/if}{literal}
604 function buildAmount( priceSetId ) {
606 priceSetId = cj("#price_set_id").val( );
608 var fname = '#priceset';
610 cj('#membership_type_id_1').val(0);
611 CRM.buildCustomData(customDataType, 'null' );
613 // hide price set fields.
616 // show/hide price set amount and total amount.
617 cj( "#mem_type_id").show( );
618 var choose = "{/literal}{ts}Choose price set{/ts}{literal}";
619 cj("#price_set_id option[value='']").html( choose );
620 cj( "#totalAmountORPriceSet" ).show( );
621 cj('#total_amount').removeAttr("readonly");
622 cj( "#num_terms_row").show( );
623 cj(".crm-membership-form-block-financial_type_id-mode").show();
625 {/literal}{if $allowAutoRenew}{literal}
626 cj('#autoRenew').hide();
627 var autoRenew = cj("#auto_renew");
628 autoRenew.removeAttr( 'readOnly' );
629 autoRenew.prop('checked', false );
630 {/literal}{/if}{literal}
634 cj( "#total_amount" ).val( '' );
635 cj('#total_amount').attr("readonly", true);
637 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
639 var response = cj.ajax({
644 cj( fname ).show( ).html( response );
645 // freeze total amount text field.
647 cj( "#totalAmountORPriceSet" ).hide( );
648 cj( "#mem_type_id" ).hide( );
649 var manual = "{/literal}{ts}Manual membership and price{/ts}{literal}";
650 cj("#price_set_id option[value='']").html( manual );
651 cj( "#num_terms_row" ).hide( );
652 cj(".crm-membership-form-block-financial_type_id-mode").hide();
655 buildMaxRelated(cj('#membership_type_id_1', false).val());
657 function buildMaxRelated( memType, setDefault ) {
658 var allMemberships = {/literal}{$allMembershipInfo}{literal};
660 if ((memType > 0) && (allMemberships[memType]['has_related'])) {
661 if (setDefault) cj('#max_related').val(allMemberships[memType]['max_related']);
662 cj('#maxRelated').show();
663 var cid = {/literal}{if $contactID}{$contactID}{else}null{/if}{literal};
665 CRM.api('relationship', 'getcount', {contact_id: cid, membership_type_id: memType}, {
666 success: function(result) {
668 if (result.result === 0) {
669 relatable = '{/literal}{ts escape='js'}No contacts are currently eligible to inherit this relationship.{/ts}{literal}';
671 else if (result.result === 1) {
672 relatable = '{/literal}{ts escape='js'}One contact is currently eligible to inherit this relationship.{/ts}{literal}';
675 relatable = '{/literal}{ts escape='js' 1='%1'}%1 contacts are currently eligible to inherit this relationship.{/ts}{literal}';
676 relatable = ts(relatable, {1: result});
678 cj('#max_related').siblings('.description').append(' ' + relatable);
683 cj('#max_related').val('');
684 cj('#maxRelated').hide();
688 var lastMembershipTypes = [];
689 var optionsMembershipTypes = [];
691 // function to load custom data for selected membership types through priceset
692 function processMembershipPriceset( membershipValues, autoRenewOption, reload ) {
693 var currentMembershipType = [];
695 var loadCustomData = 0;
696 if ( membershipValues ) {
697 optionsMembershipTypes = membershipValues;
701 lastMembershipTypes = [];
702 {/literal}{if $allowAutoRenew}{literal}
703 cj('#autoRenew').hide();
704 var autoRenew = cj("#auto_renew");
705 autoRenew.removeAttr( 'readOnly' );
706 autoRenew.prop('checked', false );
707 if ( autoRenewOption == 1 ) {
708 cj('#autoRenew').show();
710 else if ( autoRenewOption == 2 ) {
711 autoRenew.attr( 'readOnly', true );
712 autoRenew.prop('checked', true );
713 cj('#autoRenew').show();
715 {/literal}{/if}{literal}
718 cj("input,#priceset select,#priceset").each(function () {
719 if ( cj(this).attr('price') ) {
720 switch( cj(this).attr('type') ) {
722 if ( cj(this).prop('checked') ) {
723 eval( 'var option = ' + cj(this).attr('price') ) ;
725 var memTypeId = optionsMembershipTypes[ele];
726 if ( memTypeId && cj.inArray(optionsMembershipTypes[ele], currentMembershipType) == -1 ) {
727 currentMembershipType[count] = memTypeId;
732 cj(this).click( function( ) {
733 processMembershipPriceset();
739 if ( cj(this).prop('checked') && cj(this).val() ) {
740 var memTypeId = optionsMembershipTypes[cj(this).val()];
741 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
742 currentMembershipType[count] = memTypeId;
747 cj(this).click( function( ) {
748 processMembershipPriceset();
754 if ( cj(this).val( ) ) {
755 var memTypeId = optionsMembershipTypes[cj(this).val()];
756 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
757 currentMembershipType[count] = memTypeId;
762 cj(this).change( function( ) {
763 processMembershipPriceset();
771 for( i in currentMembershipType ) {
772 if ( cj.inArray(currentMembershipType[i], lastMembershipTypes) == -1 ) {
778 if ( !loadCustomData ) {
779 for( i in lastMembershipTypes) {
780 if ( cj.inArray(lastMembershipTypes[i], currentMembershipType) == -1 ) {
787 lastMembershipTypes = currentMembershipType;
789 // load custom data only if change in membership type selection
790 if ( !loadCustomData ) {
794 subTypeNames = currentMembershipType.join(',');
795 if ( subTypeNames.length < 1 ) {
796 subTypeNames = 'null';
799 CRM.buildCustomData( customDataType, subTypeNames );
802 function enableAmountSection( setContributionType ) {
803 if ( !cj('#record_contribution').prop('checked') ) {
804 cj('#record_contribution').click( );
805 cj('#recordContribution').show( );
807 if ( setContributionType ) {
808 cj('#financial_type_id').val(setContributionType);
813 {/if} {* closing of delete check if *}
814 {/if}{* closing of custom data if *}