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>
89 <tr><td class="label">{$form.payment_processor_id.label}</td><td>{$form.payment_processor_id.html}</td></tr>
91 <tr class="crm-membership-form-block-membership_type_id">
92 <td class="label">{$form.membership_type_id.label}</td>
93 <td><span id='mem_type_id'>{$form.membership_type_id.html}</span>
95 <span id='totalAmountORPriceSet'> {ts}OR{/ts}</span>
96 <span id='selectPriceSet'>{$form.price_set_id.html}</span>
97 {if $buildPriceSet && $priceSet}
98 <div id="priceset"><br/>{include file="CRM/Price/Form/PriceSet.tpl" extends="Membership"}</div>
100 <div id="priceset" class="hiddenElement"></div>
103 {if $member_is_test} {ts}(test){/ts}{/if}<br />
104 <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>
107 <tr id="maxRelated" class="crm-membership-form-block-max_related">
108 <td class="label">{$form.max_related.label}</td>
109 <td>{$form.max_related.html}<br />
110 <span class="description">{ts}Maximum number of related memberships (leave blank for unlimited).{/ts}</span>
114 <tr id="num_terms_row" class="crm-membership-form-block-num_terms">
115 <td class="label">{$form.num_terms.label}</td>
116 <td> {$form.num_terms.html}<br />
117 <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>
121 <tr class="crm-membership-form-block-source">
122 <td class="label">{$form.source.label}</td>
123 <td> {$form.source.html}<br />
124 <span class="description">{ts}Source of this membership. This value is searchable.{/ts}</span></td>
127 {* CRM-7362 --add campaign to membership *}
128 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
129 campaignTrClass="crm-membership-form-block-campaign_id"}
131 <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}
133 <span class="description">{ts}When did this contact first become a member?{/ts}</span></td></tr>
134 <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}
136 <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>
137 <tr class="crm-membership-form-block-end_date"><td class="label">{$form.end_date.label}</td>
138 <td id="end-date-readonly">
140 <a href="#" class="crm-hover-button action-item override-date" id="show-end-date">
141 {ts}Over-ride end date{/ts}
143 {help id="override_end_date"}
145 <td id="end-date-editable">
146 {include file="CRM/common/jcalendar.tpl" elementName=end_date}
148 <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>
151 {if !empty($form.auto_renew)}
152 <tr id="autoRenew" class="crm-membership-form-block-auto_renew">
153 <td class="label"> {$form.auto_renew.label} {help id="id-auto_renew" file="CRM/Member/Form/Membership.hlp" action=$action} </td>
154 <td> {$form.auto_renew.html} </td>
157 {if !$membershipMode}
158 <tr><td class="label">{$form.is_override.label} {help id="id-status-override"}</td><td>{$form.is_override.html}</td></tr>
161 {if ! $membershipMode}
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}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>
173 {elseif $membershipMode}
174 <tr class="crm-membership-form-block-financial_type_id-mode">
175 <td class="label">{$form.financial_type_id.label}</td>
176 <td>{$form.financial_type_id.html}<br />
177 <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span></td>
179 <tr class="crm-membership-form-block-total_amount">
180 <td class="label">{$form.total_amount.label}</td>
181 <td>{$form.total_amount.html}<br />
182 <span class="description">{ts}Membership payment amount.{/ts}</span><div class="totaltaxAmount"></div></td>
184 <tr class="crm-membership-form-block-contribution-contact">
185 <td class="label">{$form.is_different_contribution_contact.label}</td>
186 <td>{$form.is_different_contribution_contact.html} {help id="id-contribution_contact"}</td>
188 <tr id="record-different-contact">
191 <table class="compressed">
192 <tr class="crm-membership-form-block-soft-credit-type">
194 <td class="label">{$form.soft_credit_type_id.label}</td>
195 <td>{$form.soft_credit_type_id.html}</td>
197 <tr class="crm-membership-form-block-soft-credit-contact-id">
198 <td class="label">{$form.soft_credit_contact_id.label}</td>
199 <td>{$form.soft_credit_contact_id.html}</td>
204 <tr class="crm-membership-form-block-billing">
206 {include file='CRM/Core/BillingBlock.tpl'}
210 {if $accessContribution and ! $membershipMode AND ($action neq 2 or (!$rows.0.contribution_id AND !$softCredit) or $onlinePendingContributionId)}
212 <td class="label">{if $onlinePendingContributionId}{ts}Update Payment Status{/ts}{else}{$form.record_contribution.label}{/if}</td>
213 <td>{$form.record_contribution.html}<br />
214 <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>
216 <tr class="crm-membership-form-block-record_contribution"><td colspan="2">
217 <fieldset id="recordContribution"><legend>{ts}Membership Payment and Receipt{/ts}</legend>
219 <tr class="crm-membership-form-block-contribution-contact">
220 <td class="label">{$form.is_different_contribution_contact.label}</td>
221 <td>{$form.is_different_contribution_contact.html} {help id="id-contribution_contact"}</td>
223 <tr id="record-different-contact">
226 <table class="compressed">
227 <tr class="crm-membership-form-block-soft-credit-type">
228 <td class="label">{$form.soft_credit_type_id.label}</td>
229 <td>{$form.soft_credit_type_id.html}</td>
231 <tr class="crm-membership-form-block-soft-credit-contact-id">
232 <td class="label">{$form.soft_credit_contact_id.label}</td>
233 <td>{$form.soft_credit_contact_id.html}</td>
238 <tr class="crm-membership-form-block-financial_type_id">
239 <td class="label">{$form.financial_type_id.label}</td>
240 <td>{$form.financial_type_id.html}<br />
241 <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span></td>
243 <tr class="crm-membership-form-block-total_amount">
244 <td class="label">{$form.total_amount.label}</td>
245 <td>{$form.total_amount.html}<br />
246 <span class="description">{ts}Membership payment amount. A contribution record will be created for this amount.{/ts}</span><div class="totaltaxAmount"></div></td>
248 <tr class="crm-membership-form-block-receive_date">
249 <td class="label">{$form.receive_date.label}</td>
250 <td>{include file="CRM/common/jcalendar.tpl" elementName=receive_date}</td>
252 <tr class="crm-membership-form-block-payment_instrument_id">
253 <td class="label">{$form.payment_instrument_id.label}<span class="marker"> *</span></td>
254 <td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td>
256 <tr id="checkNumber" class="crm-membership-form-block-check_number">
257 <td class="label">{$form.check_number.label}</td>
258 <td>{$form.check_number.html|crmAddClass:six}</td>
261 <tr class="crm-membership-form-block-trxn_id">
262 <td class="label">{$form.trxn_id.label}</td>
263 <td>{$form.trxn_id.html}</td>
266 <tr class="crm-membership-form-block-contribution_status_id">
267 <td class="label">{$form.contribution_status_id.label}</td>
268 <td>{$form.contribution_status_id.html}</td>
274 <div class="spacer"></div>
277 {if $emailExists and $outBound_option != 2 }
278 <tr id="send-receipt" class="crm-membership-form-block-send_receipt">
279 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
280 <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>
282 {elseif $context eq 'standalone' and $outBound_option != 2 }
283 <tr id="email-receipt" style="display:none;">
284 <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
285 <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>
288 <tr id="fromEmail" style="display:none;">
289 <td class="label">{$form.from_email_address.label}</td>
290 <td>{$form.from_email_address.html}</td>
292 <tr id='notice' style="display:none;">
293 <td class="label">{$form.receipt_text_signup.label}</td>
294 <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>
295 {$form.receipt_text_signup.html|crmAddClass:huge}</td>
298 <div id="customData"></div>
299 {*include custom data js file*}
300 {include file="CRM/common/customData.tpl"}
302 <script type="text/javascript">
305 CRM.buildCustomData( '{$customDataType}' );
306 {if $customDataSubType}
307 CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
313 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
314 <div class="crm-accordion-wrapper">
315 <div class="crm-accordion-header">{ts}Related Contributions{/ts}</div>
316 <div class="crm-accordion-body">{include file="CRM/Contribute/Form/Selector.tpl" context="Search"}</div>
320 <div class="crm-accordion-wrapper">
321 <div class="crm-accordion-header">{ts}Related Soft Contributions{/ts}</div>
322 <div class="crm-accordion-body">{include file="CRM/Contribute/Page/ContributionSoft.tpl" context="membership"}</div>
327 <div class="spacer"></div>
328 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
329 </div> <!-- end form-block -->
331 {if $action neq 8} {* Jscript additions not need for Delete action *}
332 {if $accessContribution and !$membershipMode AND ($action neq 2 or !$rows.0.contribution_id or $onlinePendingContributionId)}
334 {include file="CRM/common/showHideByFieldValue.tpl"
335 trigger_field_id ="record_contribution"
337 target_element_id ="recordContribution"
338 target_element_type ="table-row"
342 {include file="CRM/common/showHideByFieldValue.tpl"
343 trigger_field_id ="payment_instrument_id"
345 target_element_id ="checkNumber"
346 target_element_type ="table-row"
353 <script type="text/javascript">
354 function setPaymentBlock(mode, checkboxEvent) {
355 var memType = parseInt(cj('#membership_type_id_1').val( ));
357 var existingAmount = {/literal}{if !empty($onlinePendingContributionId)}1{else}0{/if}{literal};
359 if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
363 if ( !memType || isPriceSet ) {
367 var allMemberships = {/literal}{$allMembershipInfo}{literal};
369 //check the record_contribution checkbox if membership is a paid one
370 {/literal}{if $action eq 1}{literal}
371 if (!checkboxEvent) {
372 if (allMemberships[memType]['total_amount_numeric'] > 0) {
373 cj('#record_contribution').prop('checked','checked');
374 cj('#recordContribution').show();
377 cj('#record_contribution').prop('checked', false);
378 cj('#recordContribution').hide();
381 {/literal}{/if}{literal}
384 // skip this for test and live modes because financial type is set automatically
385 cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
386 var term = cj('#num_terms').val();
387 var taxRates = '{/literal}{$taxRates}{literal}';
388 var taxTerm = '{/literal}{$taxTerm}{literal}';
389 var taxRates = JSON.parse(taxRates);
390 var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
391 var currency = '{/literal}{$currency}{literal}';
392 var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
393 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
396 var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
399 var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number(allMemberships[memType]['total_amount_numeric'] * term );
401 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
405 var feeTotal = parseFloat(Number((taxRate/100) * allMemberships[memType]['total_amount'])+Number(allMemberships[memType]['total_amount_numeric'])).toFixed(2);
406 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
409 var feeTotal = allMemberships[memType]['total_amount'];
410 if (!existingAmount) {
411 // CRM-16680 don't set amount if there is an existing contribution.
412 cj("#total_amount").val(allMemberships[memType]['total_amount']);
416 var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
417 cj('.totaltaxAmount').html(taxMessage);
422 var mode = {/literal}'{$membershipMode}'{literal};
424 // Offline form (mode = false) has the record_contribution checkbox
425 cj('#record_contribution').click( function( ) {
426 if ( cj(this).prop('checked') ) {
427 cj('#recordContribution').show( );
428 setPaymentBlock( false, true);
431 cj('#recordContribution').hide( );
436 cj('#membership_type_id_1').change( function( ) {
437 setPaymentBlock(mode);
439 cj('#num_terms').change( function( ) {
440 setPaymentBlock(mode);
442 setPaymentBlock(mode);
444 // show/hide different contact section
445 setDifferentContactBlock();
446 cj('#is_different_contribution_contact').change( function() {
447 setDifferentContactBlock();
450 // give option to override end-date for auto-renew memberships
452 {if $isRecur && $endDate}
453 cj('#end-date-readonly').show();
454 cj('#end-date-editable').hide();
456 cj('#end-date-readonly').hide();
457 cj('#end-date-editable').show();
461 cj('#show-end-date').click( function( e ) {
463 cj('#end-date-readonly').hide();
464 cj('#end-date-editable').show();
469 function setDifferentContactBlock( ) {
470 // show/hide different contact section
471 if ( cj('#is_different_contribution_contact').prop('checked') ) {
472 cj('#record-different-contact').show();
475 cj('#record-different-contact').hide();
482 {if ($emailExists and $outBound_option != 2) OR $context eq 'standalone' }
483 {include file="CRM/common/showHideByFieldValue.tpl"
484 trigger_field_id ="send_receipt"
486 target_element_id ="notice"
487 target_element_type ="table-row"
491 {include file="CRM/common/showHideByFieldValue.tpl"
492 trigger_field_id ="send_receipt"
494 target_element_id ="fromEmail"
495 target_element_type ="table-row"
502 <script type="text/javascript">
504 {/literal}{if !$membershipMode}{literal}
505 showHideMemberStatus();
506 function showHideMemberStatus() {
507 if ( cj( "#is_override" ).prop('checked' ) ) {
508 cj('#memberStatus').show( );
509 cj('#memberStatus_show').hide( );
512 cj('#memberStatus').hide( );
513 cj('#memberStatus_show').show( );
518 {if $context eq 'standalone' and $outBound_option != 2 }
521 var $form = $("form.{/literal}{$form.formClass}{literal}");
522 $("#contact_id", $form).change(checkEmail);
525 function checkEmail( ) {
526 var data = $("#contact_id", $form).select2('data');
527 if (data && data.extra && data.extra.email && data.extra.email.length) {
528 $("#email-receipt", $form).show();
529 if ($("#send_receipt", $form).is(':checked')) {
530 $("#notice", $form).show();
532 $("#email-address", $form).html(data.extra.email);
535 $("#email-receipt, #notice", $form).hide();
544 //keep read only always checked.
546 var $form = $("form.{/literal}{$form.formClass}{literal}");
547 var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
548 var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
549 if ( allowAutoRenew || alreadyAutoRenew ) {
550 $( "#auto_renew" ).click(function( ) {
551 if ( $(this).attr( 'readonly' ) ) {
552 $(this).prop('checked', true );
558 {if !empty($existingContactMemberships)}
560 var alert, memberorgs = {$existingContactMemberships|@json_encode};
563 $("select[name='membership_type_id[0]']").change(checkExistingMemOrg);
567 function checkExistingMemOrg () {
568 alert && alert.close && alert.close();
569 var selectedorg = $("select[name='membership_type_id[0]']").val();
570 if (selectedorg in memberorgs) {
572 endDate = memberorgs[selectedorg].membership_end_date,
573 org = $('option:selected', "select[name='membership_type_id[0]']").text();
575 andEndDate = '{/literal}{ts escape='js' 1='%1'}and end date of %1{/ts}{literal}';
576 andEndDate = ' ' + ts(andEndDate, {1:endDate});
580 // Mixing client-side variables with a translated string in smarty is awkward!
581 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})
582 + '<ul><li><a href="' + memberorgs[selectedorg].renewUrl + '">'
583 + {/literal}'{ts escape='js'}Renew the existing membership instead{/ts}'
584 + '</a></li><li><a href="' + memberorgs[selectedorg].membershipTab + '">'
585 + '{ts escape='js'}View all existing and / or expired memberships for this contact{/ts}'{literal}
587 '{/literal}{ts escape='js'}Duplicate Membership?{/ts}{literal}', 'alert');
590 checkExistingMemOrg();
599 {if $membershipMode or $action eq 2}
602 buildAutoRenew( null, null );
604 function buildAutoRenew( membershipType, processorId ) {
605 var mode = {/literal}'{$membershipMode}'{literal};
606 var action = {/literal}'{$action}'{literal};
608 //for update lets hide it when not already recurring.
610 //user can't cancel auto renew by unchecking.
611 if ( cj("#auto_renew").prop('checked' ) ) {
612 cj("#auto_renew").attr( 'readonly', true );
615 cj("#autoRenew").hide( );
619 //we should do all auto renew for cc memberships.
622 //get the required values in case missing.
623 if ( !processorId ) processorId = cj( '#payment_processor_id' ).val( );
624 if ( !membershipType ) membershipType = parseInt( cj('#membership_type_id_1').val( ) );
626 //we don't have both required values.
627 if ( !processorId || !membershipType ) {
628 cj("#auto_renew").prop('checked', false );
629 cj("#autoRenew").hide( );
633 var recurProcessors = {/literal}{$recurProcessor}{literal};
634 var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
635 var currentOption = autoRenewOptions[membershipType];
637 if ( !currentOption || !recurProcessors[processorId] ) {
638 cj("#auto_renew").prop('checked', false );
639 cj("#autoRenew").hide( );
643 if ( currentOption == 1 ) {
644 cj("#autoRenew").show( );
645 if ( cj("#auto_renew").attr( 'readonly' ) ) {
646 cj("#auto_renew").prop('checked', false );
647 cj("#auto_renew").removeAttr( 'readonly' );
650 else if ( currentOption == 2 ) {
651 cj("#autoRenew").show( );
652 cj("#auto_renew").prop('checked', true );
653 cj("#auto_renew").attr( 'readonly', true );
656 cj("#auto_renew").prop('checked', false );
657 cj("#autoRenew").hide( );
660 //play w/ receipt option.
661 if ( cj("#auto_renew").prop('checked' ) ) {
662 cj("#notice").hide( );
663 cj("#send_receipt").prop('checked', false );
664 cj("#send-receipt").hide( );
667 cj("#send-receipt").show( );
668 if ( cj("#send_receipt").prop('checked' ) ) {
669 cj("#notice").show( );
677 function buildReceiptANDNotice( ) {
678 if ( cj("#auto_renew").prop('checked' ) ) {
679 cj("#notice").hide( );
680 cj("#send-receipt").hide( );
683 cj("#send-receipt").show( );
684 if ( cj("#send_receipt").prop('checked' ) ) {
685 cj("#notice").show( );
690 var customDataType = '{/literal}{$customDataType}{literal}';
692 // load form during form rule.
693 {/literal}{if $buildPriceSet}{literal}
694 cj( "#totalAmountORPriceSet" ).hide( );
695 cj( "#mem_type_id" ).hide( );
696 cj('#total_amount').attr("readonly", true);
697 cj( "#num_terms_row" ).hide( );
698 cj(".crm-membership-form-block-financial_type_id-mode").hide();
699 {/literal}{/if}{literal}
701 function buildAmount( priceSetId ) {
703 priceSetId = cj("#price_set_id").val( );
705 var fname = '#priceset';
707 cj('#membership_type_id_1').val(0);
708 CRM.buildCustomData(customDataType, 'null' );
710 // hide price set fields.
713 // show/hide price set amount and total amount.
714 cj( "#mem_type_id").show( );
715 var choose = "{/literal}{ts}Choose price set{/ts}{literal}";
716 cj("#price_set_id option[value='']").html( choose );
717 cj( "#totalAmountORPriceSet" ).show( );
718 cj('#total_amount').removeAttr("readonly");
719 cj( "#num_terms_row").show( );
720 cj(".crm-membership-form-block-financial_type_id-mode").show();
722 {/literal}{if $allowAutoRenew}{literal}
723 cj('#autoRenew').hide();
724 var autoRenew = cj("#auto_renew");
725 autoRenew.removeAttr( 'readOnly' );
726 autoRenew.prop('checked', false );
727 {/literal}{/if}{literal}
731 cj( "#total_amount" ).val( '' );
732 cj('#total_amount').attr("readonly", true);
734 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
736 var response = cj.ajax({
741 cj( fname ).show( ).html( response );
742 // freeze total amount text field.
744 cj( "#totalAmountORPriceSet" ).hide( );
745 cj( "#mem_type_id" ).hide( );
746 var manual = "{/literal}{ts}Manual membership and price{/ts}{literal}";
747 cj("#price_set_id option[value='']").html( manual );
748 cj( "#num_terms_row" ).hide( );
749 cj(".crm-membership-form-block-financial_type_id-mode").hide();
752 buildMaxRelated(cj('#membership_type_id_1', false).val());
754 function buildMaxRelated( memType, setDefault ) {
755 var allMemberships = {/literal}{$allMembershipInfo}{literal};
757 if ((memType > 0) && (allMemberships[memType]['has_related'])) {
758 if (setDefault) cj('#max_related').val(allMemberships[memType]['max_related']);
759 cj('#maxRelated').show();
760 var cid = {/literal}{if $contactID}{$contactID}{else}null{/if}{literal};
762 CRM.api('relationship', 'getcount', {contact_id: cid, membership_type_id: memType}, {
763 success: function(result) {
765 if (result.result === 0) {
766 relatable = '{/literal}{ts escape='js'}No contacts are currently eligible to inherit this relationship.{/ts}{literal}';
768 else if (result.result === 1) {
769 relatable = '{/literal}{ts escape='js'}One contact is currently eligible to inherit this relationship.{/ts}{literal}';
772 relatable = '{/literal}{ts escape='js' 1='%1'}%1 contacts are currently eligible to inherit this relationship.{/ts}{literal}';
773 relatable = ts(relatable, {1: result});
775 cj('#max_related').siblings('.description').append(' ' + relatable);
780 cj('#max_related').val('');
781 cj('#maxRelated').hide();
785 var lastMembershipTypes = [];
786 var optionsMembershipTypes = [];
788 // function to load custom data for selected membership types through priceset
789 function processMembershipPriceset( membershipValues, autoRenewOption, reload ) {
790 var currentMembershipType = [];
792 var loadCustomData = 0;
793 if ( membershipValues ) {
794 optionsMembershipTypes = membershipValues;
798 lastMembershipTypes = [];
799 {/literal}{if $allowAutoRenew}{literal}
800 cj('#autoRenew').hide();
801 var autoRenew = cj("#auto_renew");
802 autoRenew.removeAttr( 'readOnly' );
803 autoRenew.prop('checked', false );
804 if ( autoRenewOption == 1 ) {
805 cj('#autoRenew').show();
807 else if ( autoRenewOption == 2 ) {
808 autoRenew.attr( 'readOnly', true );
809 autoRenew.prop('checked', true );
810 cj('#autoRenew').show();
812 {/literal}{/if}{literal}
815 cj("input,#priceset select,#priceset").each(function () {
816 if ( cj(this).attr('price') ) {
817 switch( cj(this).attr('type') ) {
819 if ( cj(this).prop('checked') ) {
820 eval( 'var option = ' + cj(this).attr('price') ) ;
822 var memTypeId = optionsMembershipTypes[ele];
823 if ( memTypeId && cj.inArray(optionsMembershipTypes[ele], currentMembershipType) == -1 ) {
824 currentMembershipType[count] = memTypeId;
829 cj(this).click( function( ) {
830 processMembershipPriceset();
836 if ( cj(this).prop('checked') && cj(this).val() ) {
837 var memTypeId = optionsMembershipTypes[cj(this).val()];
838 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
839 currentMembershipType[count] = memTypeId;
844 cj(this).click( function( ) {
845 processMembershipPriceset();
851 if ( cj(this).val( ) ) {
852 var memTypeId = optionsMembershipTypes[cj(this).val()];
853 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
854 currentMembershipType[count] = memTypeId;
859 cj(this).change( function( ) {
860 processMembershipPriceset();
868 for( i in currentMembershipType ) {
869 if ( cj.inArray(currentMembershipType[i], lastMembershipTypes) == -1 ) {
875 if ( !loadCustomData ) {
876 for( i in lastMembershipTypes) {
877 if ( cj.inArray(lastMembershipTypes[i], currentMembershipType) == -1 ) {
884 lastMembershipTypes = currentMembershipType;
886 // load custom data only if change in membership type selection
887 if ( !loadCustomData ) {
891 subTypeNames = currentMembershipType.join(',');
892 if ( subTypeNames.length < 1 ) {
893 subTypeNames = 'null';
896 CRM.buildCustomData( customDataType, subTypeNames );
899 function enableAmountSection( setContributionType ) {
900 if ( !cj('#record_contribution').prop('checked') ) {
901 cj('#record_contribution').click( );
902 cj('#recordContribution').show( );
904 if ( setContributionType ) {
905 cj('#financial_type_id').val(setContributionType);
910 {/if} {* closing of delete check if *}
911 {/if}{* closing of custom data if *}