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( ));
260 if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
264 if ( !memType || isPriceSet ) {
268 var allMemberships = {/literal}{$allMembershipInfo}{literal};
270 //check the record_contribution checkbox if membership is a paid one
271 {/literal}{if $action eq 1}{literal}
272 if (!checkboxEvent) {
273 if (allMemberships[memType]['total_amount_numeric'] > 0) {
274 cj('#record_contribution').prop('checked','checked');
275 cj('#recordContribution').show();
278 cj('#record_contribution').prop('checked', false);
279 cj('#recordContribution').hide();
282 {/literal}{/if}{literal}
285 // skip this for test and live modes because financial type is set automatically
286 cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
287 var term = cj('#num_terms').val();
288 var taxRates = '{/literal}{$taxRates}{literal}';
289 var taxTerm = '{/literal}{$taxTerm}{literal}';
290 var taxRates = JSON.parse(taxRates);
291 var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
292 var currency = '{/literal}{$currency}{literal}';
293 var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
294 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
297 var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
300 var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number(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 cj("#total_amount").val( allMemberships[memType]['total_amount'] );
314 var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
315 cj('.totaltaxAmount').html(taxMessage);
320 var mode = {/literal}'{$membershipMode}'{literal};
322 // Offline form (mode = false) has the record_contribution checkbox
323 cj('#record_contribution').click( function( ) {
324 if ( cj(this).prop('checked') ) {
325 cj('#recordContribution').show( );
326 setPaymentBlock( false, true);
329 cj('#recordContribution').hide( );
334 cj('#membership_type_id_1').change( function( ) {
335 setPaymentBlock(mode);
337 cj('#num_terms').change( function( ) {
338 setPaymentBlock(mode);
340 setPaymentBlock(mode);
342 // show/hide different contact section
343 setDifferentContactBlock();
344 cj('#is_different_contribution_contact').change( function() {
345 setDifferentContactBlock();
348 // give option to override end-date for auto-renew memberships
350 {if $isRecur && $endDate}
351 cj('#end-date-readonly').show();
352 cj('#end-date-editable').hide();
354 cj('#end-date-readonly').hide();
355 cj('#end-date-editable').show();
359 cj('#show-end-date').click( function( e ) {
361 cj('#end-date-readonly').hide();
362 cj('#end-date-editable').show();
367 function setDifferentContactBlock( ) {
368 // show/hide different contact section
369 if ( cj('#is_different_contribution_contact').prop('checked') ) {
370 cj('#record-different-contact').show();
373 cj('#record-different-contact').hide();
380 {if ($emailExists and $outBound_option != 2) OR $context eq 'standalone' }
381 {include file="CRM/common/showHideByFieldValue.tpl"
382 trigger_field_id ="send_receipt"
384 target_element_id ="notice"
385 target_element_type ="table-row"
389 {include file="CRM/common/showHideByFieldValue.tpl"
390 trigger_field_id ="send_receipt"
392 target_element_id ="fromEmail"
393 target_element_type ="table-row"
400 <script type="text/javascript">
402 {/literal}{if !$membershipMode}{literal}
403 showHideMemberStatus();
404 function showHideMemberStatus() {
405 if ( cj( "#is_override" ).prop('checked' ) ) {
406 cj('#memberStatus').show( );
407 cj('#memberStatus_show').hide( );
410 cj('#memberStatus').hide( );
411 cj('#memberStatus_show').show( );
416 {if $context eq 'standalone' and $outBound_option != 2 }
419 var $form = $("form.{/literal}{$form.formClass}{literal}");
420 $("#contact_id", $form).change(checkEmail);
423 function checkEmail( ) {
424 var data = $("#contact_id", $form).select2('data');
425 if (data && data.extra && data.extra.email && data.extra.email.length) {
426 $("#email-receipt", $form).show();
427 if ($("#send_receipt", $form).is(':checked')) {
428 $("#notice", $form).show();
430 $("#email-address", $form).html(data.extra.email);
433 $("#email-receipt, #notice", $form).hide();
442 //keep read only always checked.
444 var $form = $("form.{/literal}{$form.formClass}{literal}");
445 var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
446 var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
447 if ( allowAutoRenew || alreadyAutoRenew ) {
448 $( "#auto_renew" ).click(function( ) {
449 if ( $(this).attr( 'readonly' ) ) {
450 $(this).prop('checked', true );
456 {if !empty($existingContactMemberships)}
458 var alert, memberorgs = {$existingContactMemberships|@json_encode};
461 $("select[name='membership_type_id[0]']").change(checkExistingMemOrg);
465 function checkExistingMemOrg () {
466 alert && alert.close && alert.close();
467 var selectedorg = $("select[name='membership_type_id[0]']").val();
468 if (selectedorg in memberorgs) {
470 endDate = memberorgs[selectedorg].membership_end_date,
471 org = $('option:selected', "select[name='membership_type_id[0]']").text();
473 andEndDate = '{/literal}{ts escape='js' 1='%1'}and end date of %1{/ts}{literal}';
474 andEndDate = ' ' + ts(andEndDate, {1:endDate});
478 // Mixing client-side variables with a translated string in smarty is awkward!
479 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})
480 + '<ul><li><a href="' + memberorgs[selectedorg].renewUrl + '">'
481 + {/literal}'{ts escape='js'}Renew the existing membership instead{/ts}'
482 + '</a></li><li><a href="' + memberorgs[selectedorg].membershipTab + '">'
483 + '{ts escape='js'}View all existing and / or expired memberships for this contact{/ts}'{literal}
485 '{/literal}{ts escape='js'}Duplicate Membership?{/ts}{literal}', 'alert');
488 checkExistingMemOrg();
497 {if $membershipMode or $action eq 2}
500 buildAutoRenew( null, null );
502 function buildAutoRenew( membershipType, processorId ) {
503 var mode = {/literal}'{$membershipMode}'{literal};
504 var action = {/literal}'{$action}'{literal};
506 //for update lets hide it when not already recurring.
508 //user can't cancel auto renew by unchecking.
509 if ( cj("#auto_renew").prop('checked' ) ) {
510 cj("#auto_renew").attr( 'readonly', true );
513 cj("#autoRenew").hide( );
517 //we should do all auto renew for cc memberships.
520 //get the required values in case missing.
521 if ( !processorId ) processorId = cj( '#payment_processor_id' ).val( );
522 if ( !membershipType ) membershipType = parseInt( cj('#membership_type_id_1').val( ) );
524 //we don't have both required values.
525 if ( !processorId || !membershipType ) {
526 cj("#auto_renew").prop('checked', false );
527 cj("#autoRenew").hide( );
531 var recurProcessors = {/literal}{$recurProcessor}{literal};
532 var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
533 var currentOption = autoRenewOptions[membershipType];
535 if ( !currentOption || !recurProcessors[processorId] ) {
536 cj("#auto_renew").prop('checked', false );
537 cj("#autoRenew").hide( );
541 if ( currentOption == 1 ) {
542 cj("#autoRenew").show( );
543 if ( cj("#auto_renew").attr( 'readonly' ) ) {
544 cj("#auto_renew").prop('checked', false );
545 cj("#auto_renew").removeAttr( 'readonly' );
548 else if ( currentOption == 2 ) {
549 cj("#autoRenew").show( );
550 cj("#auto_renew").prop('checked', true );
551 cj("#auto_renew").attr( 'readonly', true );
554 cj("#auto_renew").prop('checked', false );
555 cj("#autoRenew").hide( );
558 //play w/ receipt option.
559 if ( cj("#auto_renew").prop('checked' ) ) {
560 cj("#notice").hide( );
561 cj("#send_receipt").prop('checked', false );
562 cj("#send-receipt").hide( );
565 cj("#send-receipt").show( );
566 if ( cj("#send_receipt").prop('checked' ) ) {
567 cj("#notice").show( );
575 function buildReceiptANDNotice( ) {
576 if ( cj("#auto_renew").prop('checked' ) ) {
577 cj("#notice").hide( );
578 cj("#send-receipt").hide( );
581 cj("#send-receipt").show( );
582 if ( cj("#send_receipt").prop('checked' ) ) {
583 cj("#notice").show( );
588 var customDataType = '{/literal}{$customDataType}{literal}';
590 // load form during form rule.
591 {/literal}{if $buildPriceSet}{literal}
592 cj( "#totalAmountORPriceSet" ).hide( );
593 cj( "#mem_type_id" ).hide( );
594 cj('#total_amount').attr("readonly", true);
595 cj( "#num_terms_row" ).hide( );
596 cj(".crm-membership-form-block-financial_type_id-mode").hide();
597 {/literal}{/if}{literal}
599 function buildAmount( priceSetId ) {
601 priceSetId = cj("#price_set_id").val( );
603 var fname = '#priceset';
605 cj('#membership_type_id_1').val(0);
606 CRM.buildCustomData(customDataType, 'null' );
608 // hide price set fields.
611 // show/hide price set amount and total amount.
612 cj( "#mem_type_id").show( );
613 var choose = "{/literal}{ts}Choose price set{/ts}{literal}";
614 cj("#price_set_id option[value='']").html( choose );
615 cj( "#totalAmountORPriceSet" ).show( );
616 cj('#total_amount').removeAttr("readonly");
617 cj( "#num_terms_row").show( );
618 cj(".crm-membership-form-block-financial_type_id-mode").show();
620 {/literal}{if $allowAutoRenew}{literal}
621 cj('#autoRenew').hide();
622 var autoRenew = cj("#auto_renew");
623 autoRenew.removeAttr( 'readOnly' );
624 autoRenew.prop('checked', false );
625 {/literal}{/if}{literal}
629 cj( "#total_amount" ).val( '' );
630 cj('#total_amount').attr("readonly", true);
632 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
634 var response = cj.ajax({
639 cj( fname ).show( ).html( response );
640 // freeze total amount text field.
642 cj( "#totalAmountORPriceSet" ).hide( );
643 cj( "#mem_type_id" ).hide( );
644 var manual = "{/literal}{ts}Manual membership and price{/ts}{literal}";
645 cj("#price_set_id option[value='']").html( manual );
646 cj( "#num_terms_row" ).hide( );
647 cj(".crm-membership-form-block-financial_type_id-mode").hide();
650 buildMaxRelated(cj('#membership_type_id_1', false).val());
652 function buildMaxRelated( memType, setDefault ) {
653 var allMemberships = {/literal}{$allMembershipInfo}{literal};
655 if ((memType > 0) && (allMemberships[memType]['has_related'])) {
656 if (setDefault) cj('#max_related').val(allMemberships[memType]['max_related']);
657 cj('#maxRelated').show();
658 var cid = {/literal}{if $contactID}{$contactID}{else}null{/if}{literal};
660 CRM.api('relationship', 'getcount', {contact_id: cid, membership_type_id: memType}, {
661 success: function(result) {
663 if (result.result === 0) {
664 relatable = '{/literal}{ts escape='js'}No contacts are currently eligible to inherit this relationship.{/ts}{literal}';
666 else if (result.result === 1) {
667 relatable = '{/literal}{ts escape='js'}One contact is currently eligible to inherit this relationship.{/ts}{literal}';
670 relatable = '{/literal}{ts escape='js' 1='%1'}%1 contacts are currently eligible to inherit this relationship.{/ts}{literal}';
671 relatable = ts(relatable, {1: result});
673 cj('#max_related').siblings('.description').append(' ' + relatable);
678 cj('#max_related').val('');
679 cj('#maxRelated').hide();
683 var lastMembershipTypes = [];
684 var optionsMembershipTypes = [];
686 // function to load custom data for selected membership types through priceset
687 function processMembershipPriceset( membershipValues, autoRenewOption, reload ) {
688 var currentMembershipType = [];
690 var loadCustomData = 0;
691 if ( membershipValues ) {
692 optionsMembershipTypes = membershipValues;
696 lastMembershipTypes = [];
697 {/literal}{if $allowAutoRenew}{literal}
698 cj('#autoRenew').hide();
699 var autoRenew = cj("#auto_renew");
700 autoRenew.removeAttr( 'readOnly' );
701 autoRenew.prop('checked', false );
702 if ( autoRenewOption == 1 ) {
703 cj('#autoRenew').show();
705 else if ( autoRenewOption == 2 ) {
706 autoRenew.attr( 'readOnly', true );
707 autoRenew.prop('checked', true );
708 cj('#autoRenew').show();
710 {/literal}{/if}{literal}
713 cj("input,#priceset select,#priceset").each(function () {
714 if ( cj(this).attr('price') ) {
715 switch( cj(this).attr('type') ) {
717 if ( cj(this).prop('checked') ) {
718 eval( 'var option = ' + cj(this).attr('price') ) ;
720 var memTypeId = optionsMembershipTypes[ele];
721 if ( memTypeId && cj.inArray(optionsMembershipTypes[ele], currentMembershipType) == -1 ) {
722 currentMembershipType[count] = memTypeId;
727 cj(this).click( function( ) {
728 processMembershipPriceset();
734 if ( cj(this).prop('checked') && cj(this).val() ) {
735 var memTypeId = optionsMembershipTypes[cj(this).val()];
736 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
737 currentMembershipType[count] = memTypeId;
742 cj(this).click( function( ) {
743 processMembershipPriceset();
749 if ( cj(this).val( ) ) {
750 var memTypeId = optionsMembershipTypes[cj(this).val()];
751 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
752 currentMembershipType[count] = memTypeId;
757 cj(this).change( function( ) {
758 processMembershipPriceset();
766 for( i in currentMembershipType ) {
767 if ( cj.inArray(currentMembershipType[i], lastMembershipTypes) == -1 ) {
773 if ( !loadCustomData ) {
774 for( i in lastMembershipTypes) {
775 if ( cj.inArray(lastMembershipTypes[i], currentMembershipType) == -1 ) {
782 lastMembershipTypes = currentMembershipType;
784 // load custom data only if change in membership type selection
785 if ( !loadCustomData ) {
789 subTypeNames = currentMembershipType.join(',');
790 if ( subTypeNames.length < 1 ) {
791 subTypeNames = 'null';
794 CRM.buildCustomData( customDataType, subTypeNames );
797 function enableAmountSection( setContributionType ) {
798 if ( !cj('#record_contribution').prop('checked') ) {
799 cj('#record_contribution').click( );
800 cj('#recordContribution').show( );
802 if ( setContributionType ) {
803 cj('#financial_type_id').val(setContributionType);
808 {/if} {* closing of delete check if *}
809 {/if}{* closing of custom data if *}