2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
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/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 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
70 <div class="messages status no-popup">
71 <div class="icon inform-icon"></div>
72 <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>
73 <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>
74 <p>{ts}Click 'Delete' if you want to continue.{/ts}</p>
77 <table class="form-layout-compressed">
78 {if $context neq 'standalone'}
80 <td class="font-size12pt label"><strong>{ts}Member{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
83 <td class="label">{$form.contact_id.label}</td>
84 <td>{$form.contact_id.html}</td>
88 <td class="label">{$form.payment_processor_id.label}</td>
89 <td>{$form.payment_processor_id.html}</td>
92 <tr class="crm-membership-form-block-membership_type_id">
93 <td class="label">{$form.membership_type_id.label}</td>
94 <td><span id='mem_type_id'>{$form.membership_type_id.html}</span>
96 <span id='totalAmountORPriceSet'> {ts}OR{/ts}</span>
97 <span id='selectPriceSet'>{$form.price_set_id.html}</span>
98 {if $buildPriceSet && $priceSet}
99 <div id="priceset"><br/>{include file="CRM/Price/Form/PriceSet.tpl" extends="Membership"}</div>
101 <div id="priceset" class="hiddenElement"></div>
104 {if $member_is_test} {ts}(test){/ts}{/if}<br />
105 <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>
108 <tr id="maxRelated" class="crm-membership-form-block-max_related">
109 <td class="label">{$form.max_related.label}</td>
110 <td>{$form.max_related.html}<br />
111 <span class="description">{ts}Maximum number of related memberships (leave blank for unlimited).{/ts}</span>
115 <tr id="num_terms_row" class="crm-membership-form-block-num_terms">
116 <td class="label">{$form.num_terms.label}</td>
117 <td> {$form.num_terms.html}<br />
118 <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>
122 <tr class="crm-membership-form-block-source">
123 <td class="label">{$form.source.label}</td>
124 <td> {$form.source.html}<br />
125 <span class="description">{ts}Source of this membership. This value is searchable.{/ts}</span></td>
128 {* CRM-7362 --add campaign to membership *}
129 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
130 campaignTrClass="crm-membership-form-block-campaign_id"}
132 <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}
134 <span class="description">{ts}When did this contact first become a member?{/ts}</span></td></tr>
135 <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}
137 <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>
138 <tr class="crm-membership-form-block-end_date"><td class="label">{$form.end_date.label}</td>
139 <td id="end-date-readonly">
141 <a href="#" class="crm-hover-button action-item override-date" id="show-end-date">
142 {ts}Over-ride end date{/ts}
144 {help id="override_end_date"}
146 <td id="end-date-editable">
147 {include file="CRM/common/jcalendar.tpl" elementName=end_date}
149 <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>
152 {if !$membershipMode}
153 <tr><td class="label">{$form.is_override.label} {help id="id-status-override"}</td><td>{$form.is_override.html}</td></tr>
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}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>
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"}
177 {if $emailExists and $isEmailEnabledForSite}
178 <tr id="send-receipt" class="crm-membership-form-block-send_receipt">
179 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
180 <span class="description">{ts 1=$emailExists}Automatically email a membership confirmation and receipt to %1 ?{/ts} {ts}OR if the payment is from a different contact, this email will only go to them.{/ts}</span></td>
182 {elseif $context eq 'standalone' and $isEmailEnabledForSite}
183 <tr id="email-receipt" style="display:none;">
184 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
185 <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>
188 <tr id="fromEmail" style="display:none;">
189 <td class="label">{$form.from_email_address.label}</td>
190 <td>{$form.from_email_address.html}</td>
192 <tr id='notice' style="display:none;">
193 <td class="label">{$form.receipt_text.label}</td>
194 <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>
195 {$form.receipt_text.html|crmAddClass:huge}</td>
198 <div id="customData"></div>
199 {*include custom data js file*}
200 {include file="CRM/common/customData.tpl"}
202 <script type="text/javascript">
205 CRM.buildCustomData( '{$customDataType}' );
206 {if $customDataSubType}
207 CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
213 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
214 <div class="crm-accordion-wrapper">
215 <div class="crm-accordion-header">{ts}Related Contributions{/ts}</div>
216 <div class="crm-accordion-body">{include file="CRM/Contribute/Form/Selector.tpl" context="Search"}</div>
220 <div class="crm-accordion-wrapper">
221 <div class="crm-accordion-header">{ts}Related Soft Contributions{/ts}</div>
222 <div class="crm-accordion-body">{include file="CRM/Contribute/Page/ContributionSoft.tpl" context="membership"}</div>
227 <div class="spacer"></div>
228 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
229 </div> <!-- end form-block -->
231 {if $action neq 8} {* Jscript additions not need for Delete action *}
232 {if $accessContribution and !$membershipMode AND ($action neq 2 or !$rows.0.contribution_id or $onlinePendingContributionId)}
234 {include file="CRM/common/showHideByFieldValue.tpl"
235 trigger_field_id ="record_contribution"
237 target_element_id ="recordContribution"
238 target_element_type ="table-row"
242 {include file="CRM/common/showHideByFieldValue.tpl"
243 trigger_field_id ="payment_instrument_id"
245 target_element_id ="checkNumber"
246 target_element_type ="table-row"
253 <script type="text/javascript">
254 function setPaymentBlock(mode, checkboxEvent) {
255 var memType = parseInt(cj('#membership_type_id_1').val( ));
257 var existingAmount = {/literal}{if !empty($onlinePendingContributionId)}1{else}0{/if}{literal};
259 if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
263 if ( !memType || isPriceSet ) {
267 var allMemberships = {/literal}{$allMembershipInfo}{literal};
269 //check the record_contribution checkbox if membership is a paid one
270 {/literal}{if $action eq 1}{literal}
271 if (!checkboxEvent) {
272 if (allMemberships[memType]['total_amount_numeric'] > 0) {
273 cj('#record_contribution').prop('checked','checked');
274 cj('#recordContribution').show();
277 cj('#record_contribution').prop('checked', false);
278 cj('#recordContribution').hide();
281 {/literal}{/if}{literal}
284 // skip this for test and live modes because financial type is set automatically
285 cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
286 var term = cj('#num_terms').val();
287 var taxRates = '{/literal}{$taxRates}{literal}';
288 var taxTerm = '{/literal}{$taxTerm}{literal}';
289 var taxRates = JSON.parse(taxRates);
290 var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
291 var currency = '{/literal}{$currency}{literal}';
292 var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
293 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
296 var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
299 var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number
300 (allMemberships[memType]['total_amount_numeric'] * term );
302 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
306 var feeTotal = parseFloat(Number((taxRate/100) * allMemberships[memType]['total_amount'])+Number(allMemberships[memType]['total_amount_numeric'])).toFixed(2);
307 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
310 var feeTotal = allMemberships[memType]['total_amount'];
311 if (!existingAmount) {
312 // CRM-16680 don't set amount if there is an existing contribution.
313 cj("#total_amount").val(allMemberships[memType]['total_amount']);
317 var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
318 cj('.totaltaxAmount').html(taxMessage);
323 var mode = {/literal}'{$membershipMode}'{literal};
325 // Offline form (mode = false) has the record_contribution checkbox
326 cj('#record_contribution').click( function( ) {
327 if ( cj(this).prop('checked') ) {
328 cj('#recordContribution').show( );
329 setPaymentBlock( false, true);
332 cj('#recordContribution').hide( );
337 cj('#membership_type_id_1').change( function( ) {
338 setPaymentBlock(mode);
340 cj('#num_terms').change( function( ) {
341 setPaymentBlock(mode);
343 setPaymentBlock(mode);
345 // show/hide different contact section
346 setDifferentContactBlock();
347 cj('#is_different_contribution_contact').change( function() {
348 setDifferentContactBlock();
351 // give option to override end-date for auto-renew memberships
353 {if $isRecur && $endDate}
354 cj('#end-date-readonly').show();
355 cj('#end-date-editable').hide();
357 cj('#end-date-readonly').hide();
358 cj('#end-date-editable').show();
362 cj('#show-end-date').click( function( e ) {
364 cj('#end-date-readonly').hide();
365 cj('#end-date-editable').show();
370 function setDifferentContactBlock( ) {
371 // show/hide different contact section
372 if ( cj('#is_different_contribution_contact').prop('checked') ) {
373 cj('#record-different-contact').show();
376 cj('#record-different-contact').hide();
380 function showEmailOptions() {
382 // @todo emailExists refers to the primary contact for the page.
383 // elsewhere some script determines if there is a paying contact the
384 // email should go to instead (e.g gift membership). This should be checked for here
385 // and that merged into that code as currently behaviour is inconsistent.
386 var emailExists = '{$emailExists}';
387 var isStandalone = ('{$context}' == 'standalone');
388 var isEmailEnabledForSite = {$isEmailEnabledForSite};
391 var isEmailable = (isEmailEnabledForSite && (emailExists || isStandalone));
393 if (isEmailable && cj('#send_receipt').prop('checked') && !cj('#auto_renew').prop('checked')) {
394 // Hide extra message and from email for recurring as they cannot be stored until use.
395 cj('#notice').show();
396 cj('#fromEmail').show();
399 cj('#notice').hide();
400 cj('#fromEmail').hide();
404 <script type="text/javascript">
406 {/literal}{if !$membershipMode}{literal}
407 showHideMemberStatus();
408 function showHideMemberStatus() {
409 if ( cj( "#is_override" ).prop('checked') ) {
410 cj('#memberStatus').show( );
411 cj('#memberStatus_show').hide( );
414 cj('#memberStatus').hide( );
415 cj('#memberStatus_show').show( );
420 {if $context eq 'standalone' and $isEmailEnabledForSite }
423 var $form = $("form.{/literal}{$form.formClass}{literal}");
424 $("#contact_id", $form).change(checkEmail);
427 function checkEmail( ) {
428 var data = $("#contact_id", $form).select2('data');
429 if (data && data.extra && data.extra.email && data.extra.email.length) {
430 $("#email-receipt", $form).show();
431 if ($("#send_receipt", $form).is(':checked')) {
432 $("#notice", $form).show();
434 $("#email-address", $form).html(data.extra.email);
437 $("#email-receipt, #notice", $form).hide();
446 //keep read only always checked.
448 var $form = $("form.{/literal}{$form.formClass}{literal}");
449 var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
450 var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
451 if ( allowAutoRenew || alreadyAutoRenew ) {
452 $( "#auto_renew" ).click(function( ) {
453 if ( $(this).attr( 'readonly' ) ) {
454 $(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}
504 buildAutoRenew( null, null, '{$membershipMode}');
506 function buildAutoRenew( membershipType, processorId, mode ) {
507 var action = {/literal}'{$action}'{literal};
509 //for update lets hide it when not already recurring.
511 //user can't cancel auto renew by unchecking.
512 if ( cj("#auto_renew").prop('checked' ) ) {
513 cj("#auto_renew").attr( 'readonly', true );
516 cj("#autoRenew").hide( );
520 //we should do all auto renew for cc memberships.
523 //get the required values in case missing.
524 if ( !processorId ) processorId = cj( '#payment_processor_id' ).val( );
525 if ( !membershipType ) membershipType = parseInt( cj('#membership_type_id_1').val( ) );
527 //we don't have both required values.
528 if ( !processorId || !membershipType ) {
529 cj("#auto_renew").prop('checked', false );
530 cj("#autoRenew").hide( );
535 var recurProcessors = {/literal}{$recurProcessor}{literal};
536 var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
537 var currentOption = autoRenewOptions[membershipType];
539 if ( !currentOption || !recurProcessors[processorId] ) {
540 cj("#auto_renew").prop('checked', false );
541 cj("#autoRenew").hide();
545 if ( currentOption == 1 ) {
546 cj("#autoRenew").show( );
547 if ( cj("#auto_renew").attr( 'readonly' ) ) {
548 cj("#auto_renew").prop('checked', false );
549 cj("#auto_renew").removeAttr( 'readonly' );
552 else if ( currentOption == 2 ) {
553 cj("#autoRenew").show( );
554 cj("#auto_renew").prop('checked', true );
555 cj("#auto_renew").attr( 'readonly', true );
558 cj("#auto_renew").prop('checked', false );
559 cj("#autoRenew").hide( );
568 var customDataType = '{/literal}{$customDataType}{literal}';
570 // load form during form rule.
571 {/literal}{if $buildPriceSet}{literal}
572 cj( "#totalAmountORPriceSet" ).hide( );
573 cj( "#mem_type_id" ).hide( );
574 cj('#total_amount').attr("readonly", true);
575 cj( "#num_terms_row" ).hide( );
576 cj(".crm-membership-form-block-financial_type_id-mode").hide();
577 {/literal}{/if}{literal}
579 function buildAmount( priceSetId ) {
581 priceSetId = cj("#price_set_id").val( );
583 var fname = '#priceset';
585 cj('#membership_type_id_1').val(0);
586 CRM.buildCustomData(customDataType, 'null' );
588 // hide price set fields.
591 // show/hide price set amount and total amount.
592 cj( "#mem_type_id").show( );
593 var choose = "{/literal}{ts}Choose price set{/ts}{literal}";
594 cj("#price_set_id option[value='']").html( choose );
595 cj( "#totalAmountORPriceSet" ).show( );
596 cj('#total_amount').removeAttr("readonly");
597 cj( "#num_terms_row").show( );
598 cj(".crm-membership-form-block-financial_type_id-mode").show();
600 {/literal}{if $allowAutoRenew}{literal}
601 cj('#autoRenew').hide();
602 var autoRenew = cj("#auto_renew");
603 autoRenew.removeAttr( 'readOnly' );
604 autoRenew.prop('checked', false );
605 {/literal}{/if}{literal}
609 cj( "#total_amount" ).val( '' );
610 cj('#total_amount').attr("readonly", true);
612 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
614 var response = cj.ajax({
619 cj( fname ).show( ).html( response );
620 // freeze total amount text field.
622 cj( "#totalAmountORPriceSet" ).hide( );
623 cj( "#mem_type_id" ).hide( );
624 var manual = "{/literal}{ts}Manual membership and price{/ts}{literal}";
625 cj("#price_set_id option[value='']").html( manual );
626 cj( "#num_terms_row" ).hide( );
627 cj(".crm-membership-form-block-financial_type_id-mode").hide();
630 buildMaxRelated(cj('#membership_type_id_1', false).val());
632 function buildMaxRelated( memType, setDefault ) {
633 var allMemberships = {/literal}{$allMembershipInfo}{literal};
635 if ((memType > 0) && (allMemberships[memType]['has_related'])) {
636 if (setDefault) cj('#max_related').val(allMemberships[memType]['max_related']);
637 cj('#maxRelated').show();
638 var cid = {/literal}{if $contactID}{$contactID}{else}null{/if}{literal};
640 CRM.api('relationship', 'getcount', {contact_id: cid, membership_type_id: memType}, {
641 success: function(result) {
643 if (result.result === 0) {
644 relatable = '{/literal}{ts escape='js'}No contacts are currently eligible to inherit this relationship.{/ts}{literal}';
646 else if (result.result === 1) {
647 relatable = '{/literal}{ts escape='js'}One contact is currently eligible to inherit this relationship.{/ts}{literal}';
650 relatable = '{/literal}{ts escape='js' 1='%1'}%1 contacts are currently eligible to inherit this relationship.{/ts}{literal}';
651 relatable = ts(relatable, {1: result});
653 cj('#max_related').siblings('.description').append(' ' + relatable);
658 cj('#max_related').val('');
659 cj('#maxRelated').hide();
663 var lastMembershipTypes = [];
664 var optionsMembershipTypes = [];
666 // function to load custom data for selected membership types through priceset
667 function processMembershipPriceset( membershipValues, autoRenewOption, reload ) {
668 var currentMembershipType = [];
670 var loadCustomData = 0;
671 if ( membershipValues ) {
672 optionsMembershipTypes = membershipValues;
676 lastMembershipTypes = [];
677 {/literal}{if $allowAutoRenew}{literal}
678 cj('#autoRenew').hide();
679 var autoRenew = cj("#auto_renew");
680 autoRenew.removeAttr( 'readOnly' );
681 autoRenew.prop('checked', false );
682 if ( autoRenewOption == 1 ) {
683 cj('#autoRenew').show();
685 else if ( autoRenewOption == 2 ) {
686 autoRenew.attr( 'readOnly', true );
687 autoRenew.prop('checked', true );
688 cj('#autoRenew').show();
690 {/literal}{/if}{literal}
693 cj("input,#priceset select,#priceset").each(function () {
694 if ( cj(this).attr('price') ) {
695 switch( cj(this).attr('type') ) {
697 if ( cj(this).prop('checked') ) {
698 eval( 'var option = ' + cj(this).attr('price') ) ;
700 var memTypeId = optionsMembershipTypes[ele];
701 if ( memTypeId && cj.inArray(optionsMembershipTypes[ele], currentMembershipType) == -1 ) {
702 currentMembershipType[count] = memTypeId;
707 cj(this).click( function( ) {
708 processMembershipPriceset();
714 if ( cj(this).prop('checked') && cj(this).val() ) {
715 var memTypeId = optionsMembershipTypes[cj(this).val()];
716 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
717 currentMembershipType[count] = memTypeId;
722 cj(this).click( function( ) {
723 processMembershipPriceset();
729 if ( cj(this).val( ) ) {
730 var memTypeId = optionsMembershipTypes[cj(this).val()];
731 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
732 currentMembershipType[count] = memTypeId;
737 cj(this).change( function( ) {
738 processMembershipPriceset();
746 for( i in currentMembershipType ) {
747 if ( cj.inArray(currentMembershipType[i], lastMembershipTypes) == -1 ) {
753 if ( !loadCustomData ) {
754 for( i in lastMembershipTypes) {
755 if ( cj.inArray(lastMembershipTypes[i], currentMembershipType) == -1 ) {
762 lastMembershipTypes = currentMembershipType;
764 // load custom data only if change in membership type selection
765 if ( !loadCustomData ) {
769 subTypeNames = currentMembershipType.join(',');
770 if ( subTypeNames.length < 1 ) {
771 subTypeNames = 'null';
774 CRM.buildCustomData( customDataType, subTypeNames );
777 function enableAmountSection( setContributionType ) {
778 if ( !cj('#record_contribution').prop('checked') ) {
779 cj('#record_contribution').click( );
780 cj('#recordContribution').show( );
782 if ( setContributionType ) {
783 cj('#financial_type_id').val(setContributionType);
788 {/if} {* closing of delete check if *}
789 {/if}{* closing of custom data if *}