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}</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>?</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( ));
358 if ( cj('#price_set_id').length > 0 && cj('#price_set_id').val() ) {
362 if ( !memType || isPriceSet ) {
366 var allMemberships = {/literal}{$allMembershipInfo}{literal};
368 //check the record_contribution checkbox if membership is a paid one
369 {/literal}{if $action eq 1}{literal}
370 if (!checkboxEvent) {
371 if (allMemberships[memType]['total_amount_numeric'] > 0) {
372 cj('#record_contribution').prop('checked','checked');
373 cj('#recordContribution').show();
376 cj('#record_contribution').prop('checked', false);
377 cj('#recordContribution').hide();
380 {/literal}{/if}{literal}
383 // skip this for test and live modes because financial type is set automatically
384 cj("#financial_type_id").val(allMemberships[memType]['financial_type_id']);
385 var term = cj('#num_terms').val();
386 var taxRates = '{/literal}{$taxRates}{literal}';
387 var taxTerm = '{/literal}{$taxTerm}{literal}';
388 var taxRates = JSON.parse(taxRates);
389 var taxRate = taxRates[allMemberships[memType]['financial_type_id']];
390 var currency = '{/literal}{$currency}{literal}';
391 var taxAmount = (taxRate/100)*allMemberships[memType]['total_amount_numeric'];
392 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
395 var feeTotal = allMemberships[memType]['total_amount_numeric'] * term;
398 var feeTotal = Number((taxRate/100) * (allMemberships[memType]['total_amount_numeric'] * term))+Number(allMemberships[memType]['total_amount_numeric'] * term );
400 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
404 var feeTotal = parseFloat(Number((taxRate/100) * allMemberships[memType]['total_amount'])+Number(allMemberships[memType]['total_amount_numeric'])).toFixed(2);
405 cj("#total_amount").val(CRM.formatMoney(feeTotal, true));
408 var feeTotal = allMemberships[memType]['total_amount'];
409 cj("#total_amount").val( allMemberships[memType]['total_amount'] );
412 var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
413 cj('.totaltaxAmount').html(taxMessage);
418 var mode = {/literal}'{$membershipMode}'{literal};
420 // Offline form (mode = false) has the record_contribution checkbox
421 cj('#record_contribution').click( function( ) {
422 if ( cj(this).prop('checked') ) {
423 cj('#recordContribution').show( );
424 setPaymentBlock( false, true);
427 cj('#recordContribution').hide( );
432 cj('#membership_type_id_1').change( function( ) {
433 setPaymentBlock(mode);
435 cj('#num_terms').change( function( ) {
436 setPaymentBlock(mode);
438 setPaymentBlock(mode);
440 // show/hide different contact section
441 setDifferentContactBlock();
442 cj('#is_different_contribution_contact').change( function() {
443 setDifferentContactBlock();
446 // give option to override end-date for auto-renew memberships
448 {if $isRecur && $endDate}
449 cj('#end-date-readonly').show();
450 cj('#end-date-editable').hide();
452 cj('#end-date-readonly').hide();
453 cj('#end-date-editable').show();
457 cj('#show-end-date').click( function( e ) {
459 cj('#end-date-readonly').hide();
460 cj('#end-date-editable').show();
465 function setDifferentContactBlock( ) {
466 // show/hide different contact section
467 if ( cj('#is_different_contribution_contact').prop('checked') ) {
468 cj('#record-different-contact').show();
471 cj('#record-different-contact').hide();
478 {if ($emailExists and $outBound_option != 2) OR $context eq 'standalone' }
479 {include file="CRM/common/showHideByFieldValue.tpl"
480 trigger_field_id ="send_receipt"
482 target_element_id ="notice"
483 target_element_type ="table-row"
487 {include file="CRM/common/showHideByFieldValue.tpl"
488 trigger_field_id ="send_receipt"
490 target_element_id ="fromEmail"
491 target_element_type ="table-row"
498 <script type="text/javascript">
500 {/literal}{if !$membershipMode}{literal}
501 showHideMemberStatus();
502 function showHideMemberStatus() {
503 if ( cj( "#is_override" ).prop('checked' ) ) {
504 cj('#memberStatus').show( );
505 cj('#memberStatus_show').hide( );
508 cj('#memberStatus').hide( );
509 cj('#memberStatus_show').show( );
514 {if $context eq 'standalone' and $outBound_option != 2 }
517 var $form = $("form.{/literal}{$form.formClass}{literal}");
518 $("#contact_id", $form).change(checkEmail);
521 function checkEmail( ) {
522 var data = $("#contact_id", $form).select2('data');
523 if (data && data.extra && data.extra.email && data.extra.email.length) {
524 $("#email-receipt", $form).show();
525 if ($("#send_receipt", $form).is(':checked')) {
526 $("#notice", $form).show();
528 $("#email-address", $form).html(data.extra.email);
531 $("#email-receipt, #notice", $form).hide();
540 //keep read only always checked.
542 var $form = $("form.{/literal}{$form.formClass}{literal}");
543 var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
544 var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
545 if ( allowAutoRenew || alreadyAutoRenew ) {
546 $( "#auto_renew" ).click(function( ) {
547 if ( $(this).attr( 'readonly' ) ) {
548 $(this).prop('checked', true );
554 {if !empty($existingContactMemberships)}
556 var alert, memberorgs = {$existingContactMemberships|@json_encode};
559 $("select[name='membership_type_id[0]']").change(checkExistingMemOrg);
563 function checkExistingMemOrg () {
564 alert && alert.close && alert.close();
565 var selectedorg = $("select[name='membership_type_id[0]']").val();
566 if (selectedorg in memberorgs) {
568 endDate = memberorgs[selectedorg].membership_end_date,
569 org = $('option:selected', "select[name='membership_type_id[0]']").text();
571 andEndDate = '{/literal}{ts escape='js' 1='%1'}and end date of %1{/ts}{literal}';
572 andEndDate = ' ' + ts(andEndDate, {1:endDate});
576 // Mixing client-side variables with a translated string in smarty is awkward!
577 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})
578 + '<ul><li><a href="' + memberorgs[selectedorg].renewUrl + '">'
579 + {/literal}'{ts escape='js'}Renew the existing membership instead{/ts}'
580 + '</a></li><li><a href="' + memberorgs[selectedorg].membershipTab + '">'
581 + '{ts escape='js'}View all existing and / or expired memberships for this contact{/ts}'{literal}
583 '{/literal}{ts escape='js'}Duplicate Membership?{/ts}{literal}', 'alert');
586 checkExistingMemOrg();
595 {if $membershipMode or $action eq 2}
598 buildAutoRenew( null, null );
600 function buildAutoRenew( membershipType, processorId ) {
601 var mode = {/literal}'{$membershipMode}'{literal};
602 var action = {/literal}'{$action}'{literal};
604 //for update lets hide it when not already recurring.
606 //user can't cancel auto renew by unchecking.
607 if ( cj("#auto_renew").prop('checked' ) ) {
608 cj("#auto_renew").attr( 'readonly', true );
611 cj("#autoRenew").hide( );
615 //we should do all auto renew for cc memberships.
618 //get the required values in case missing.
619 if ( !processorId ) processorId = cj( '#payment_processor_id' ).val( );
620 if ( !membershipType ) membershipType = parseInt( cj('#membership_type_id_1').val( ) );
622 //we don't have both required values.
623 if ( !processorId || !membershipType ) {
624 cj("#auto_renew").prop('checked', false );
625 cj("#autoRenew").hide( );
629 var recurProcessors = {/literal}{$recurProcessor}{literal};
630 var autoRenewOptions = {/literal}{$autoRenewOptions}{literal};
631 var currentOption = autoRenewOptions[membershipType];
633 if ( !currentOption || !recurProcessors[processorId] ) {
634 cj("#auto_renew").prop('checked', false );
635 cj("#autoRenew").hide( );
639 if ( currentOption == 1 ) {
640 cj("#autoRenew").show( );
641 if ( cj("#auto_renew").attr( 'readonly' ) ) {
642 cj("#auto_renew").prop('checked', false );
643 cj("#auto_renew").removeAttr( 'readonly' );
646 else if ( currentOption == 2 ) {
647 cj("#autoRenew").show( );
648 cj("#auto_renew").prop('checked', true );
649 cj("#auto_renew").attr( 'readonly', true );
652 cj("#auto_renew").prop('checked', false );
653 cj("#autoRenew").hide( );
656 //play w/ receipt option.
657 if ( cj("#auto_renew").prop('checked' ) ) {
658 cj("#notice").hide( );
659 cj("#send_receipt").prop('checked', false );
660 cj("#send-receipt").hide( );
663 cj("#send-receipt").show( );
664 if ( cj("#send_receipt").prop('checked' ) ) {
665 cj("#notice").show( );
673 function buildReceiptANDNotice( ) {
674 if ( cj("#auto_renew").prop('checked' ) ) {
675 cj("#notice").hide( );
676 cj("#send-receipt").hide( );
679 cj("#send-receipt").show( );
680 if ( cj("#send_receipt").prop('checked' ) ) {
681 cj("#notice").show( );
686 var customDataType = '{/literal}{$customDataType}{literal}';
688 // load form during form rule.
689 {/literal}{if $buildPriceSet}{literal}
690 cj( "#totalAmountORPriceSet" ).hide( );
691 cj( "#mem_type_id" ).hide( );
692 cj('#total_amount').attr("readonly", true);
693 cj( "#num_terms_row" ).hide( );
694 cj(".crm-membership-form-block-financial_type_id-mode").hide();
695 {/literal}{/if}{literal}
697 function buildAmount( priceSetId ) {
699 priceSetId = cj("#price_set_id").val( );
701 var fname = '#priceset';
703 cj('#membership_type_id_1').val(0);
704 CRM.buildCustomData(customDataType, 'null' );
706 // hide price set fields.
709 // show/hide price set amount and total amount.
710 cj( "#mem_type_id").show( );
711 var choose = "{/literal}{ts}Choose price set{/ts}{literal}";
712 cj("#price_set_id option[value='']").html( choose );
713 cj( "#totalAmountORPriceSet" ).show( );
714 cj('#total_amount').removeAttr("readonly");
715 cj( "#num_terms_row").show( );
716 cj(".crm-membership-form-block-financial_type_id-mode").show();
718 {/literal}{if $allowAutoRenew}{literal}
719 cj('#autoRenew').hide();
720 var autoRenew = cj("#auto_renew");
721 autoRenew.removeAttr( 'readOnly' );
722 autoRenew.prop('checked', false );
723 {/literal}{/if}{literal}
727 cj( "#total_amount" ).val( '' );
728 cj('#total_amount').attr("readonly", true);
730 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
732 var response = cj.ajax({
737 cj( fname ).show( ).html( response );
738 // freeze total amount text field.
740 cj( "#totalAmountORPriceSet" ).hide( );
741 cj( "#mem_type_id" ).hide( );
742 var manual = "{/literal}{ts}Manual membership and price{/ts}{literal}";
743 cj("#price_set_id option[value='']").html( manual );
744 cj( "#num_terms_row" ).hide( );
745 cj(".crm-membership-form-block-financial_type_id-mode").hide();
748 buildMaxRelated(cj('#membership_type_id_1', false).val());
750 function buildMaxRelated( memType, setDefault ) {
751 var allMemberships = {/literal}{$allMembershipInfo}{literal};
753 if ((memType > 0) && (allMemberships[memType]['has_related'])) {
754 if (setDefault) cj('#max_related').val(allMemberships[memType]['max_related']);
755 cj('#maxRelated').show();
756 var cid = {/literal}{if $contactID}{$contactID}{else}null{/if}{literal};
758 CRM.api('relationship', 'getcount', {contact_id: cid, membership_type_id: memType}, {
759 success: function(result) {
761 if (result.result === 0) {
762 relatable = '{/literal}{ts escape='js'}No contacts are currently eligible to inherit this relationship.{/ts}{literal}';
764 else if (result.result === 1) {
765 relatable = '{/literal}{ts escape='js'}One contact is currently eligible to inherit this relationship.{/ts}{literal}';
768 relatable = '{/literal}{ts escape='js' 1='%1'}%1 contacts are currently eligible to inherit this relationship.{/ts}{literal}';
769 relatable = ts(relatable, {1: result});
771 cj('#max_related').siblings('.description').append(' ' + relatable);
776 cj('#max_related').val('');
777 cj('#maxRelated').hide();
781 var lastMembershipTypes = [];
782 var optionsMembershipTypes = [];
784 // function to load custom data for selected membership types through priceset
785 function processMembershipPriceset( membershipValues, autoRenewOption, reload ) {
786 var currentMembershipType = [];
788 var loadCustomData = 0;
789 if ( membershipValues ) {
790 optionsMembershipTypes = membershipValues;
794 lastMembershipTypes = [];
795 {/literal}{if $allowAutoRenew}{literal}
796 cj('#autoRenew').hide();
797 var autoRenew = cj("#auto_renew");
798 autoRenew.removeAttr( 'readOnly' );
799 autoRenew.prop('checked', false );
800 if ( autoRenewOption == 1 ) {
801 cj('#autoRenew').show();
803 else if ( autoRenewOption == 2 ) {
804 autoRenew.attr( 'readOnly', true );
805 autoRenew.prop('checked', true );
806 cj('#autoRenew').show();
808 {/literal}{/if}{literal}
811 cj("input,#priceset select,#priceset").each(function () {
812 if ( cj(this).attr('price') ) {
813 switch( cj(this).attr('type') ) {
815 if ( cj(this).prop('checked') ) {
816 eval( 'var option = ' + cj(this).attr('price') ) ;
818 var memTypeId = optionsMembershipTypes[ele];
819 if ( memTypeId && cj.inArray(optionsMembershipTypes[ele], currentMembershipType) == -1 ) {
820 currentMembershipType[count] = memTypeId;
825 cj(this).click( function( ) {
826 processMembershipPriceset();
832 if ( cj(this).prop('checked') && cj(this).val() ) {
833 var memTypeId = optionsMembershipTypes[cj(this).val()];
834 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
835 currentMembershipType[count] = memTypeId;
840 cj(this).click( function( ) {
841 processMembershipPriceset();
847 if ( cj(this).val( ) ) {
848 var memTypeId = optionsMembershipTypes[cj(this).val()];
849 if ( memTypeId && cj.inArray(memTypeId, currentMembershipType) == -1 ) {
850 currentMembershipType[count] = memTypeId;
855 cj(this).change( function( ) {
856 processMembershipPriceset();
864 for( i in currentMembershipType ) {
865 if ( cj.inArray(currentMembershipType[i], lastMembershipTypes) == -1 ) {
871 if ( !loadCustomData ) {
872 for( i in lastMembershipTypes) {
873 if ( cj.inArray(lastMembershipTypes[i], currentMembershipType) == -1 ) {
880 lastMembershipTypes = currentMembershipType;
882 // load custom data only if change in membership type selection
883 if ( !loadCustomData ) {
887 subTypeNames = currentMembershipType.join(',');
888 if ( subTypeNames.length < 1 ) {
889 subTypeNames = 'null';
892 CRM.buildCustomData( customDataType, subTypeNames );
895 function enableAmountSection( setContributionType ) {
896 if ( !cj('#record_contribution').prop('checked') ) {
897 cj('#record_contribution').click( );
898 cj('#recordContribution').show( );
900 if ( setContributionType ) {
901 cj('#financial_type_id').val(setContributionType);
906 {/if} {* closing of delete check if *}
907 {/if}{* closing of custom data if *}