Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
39de6fd5 | 3 | | CiviCRM version 4.6 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
e7112fa7 | 5 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
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. | | |
12 | | | | |
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. | | |
17 | | | | |
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 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | {if !empty($useForMember) AND !$is_quick_config} | |
27 | <div id="membership" class="crm-group membership-group"> | |
28 | {if $context EQ "makeContribution"} | |
29 | <div id="priceset"> | |
30 | <fieldset> | |
31 | {if $renewal_mode} | |
32 | {if $membershipBlock.renewal_title} | |
33 | <legend>{$membershipBlock.renewal_title}</legend> | |
34 | {/if} | |
35 | {if $membershipBlock.renewal_text} | |
36 | <div id="membership-intro" class="crm-section membership_renewal_intro-section"> | |
37 | {$membershipBlock.renewal_text} | |
38 | </div> | |
39 | {/if} | |
40 | {else} | |
41 | {if $membershipBlock.new_title} | |
42 | <legend>{$membershipBlock.new_title}</legend> | |
43 | {/if} | |
44 | {if $membershipBlock.new_text} | |
45 | <div id="membership-intro" class="crm-section membership_new_intro-section"> | |
46 | {$membershipBlock.new_text} | |
47 | </div> | |
48 | {/if} | |
49 | {/if} | |
50 | {if !empty($membershipTypes)} | |
51 | {foreach from=$membershipTypes item=row} | |
52 | {if array_key_exists( 'current_membership', $row )} | |
53 | <div id='help'> | |
54 | {* Lifetime memberships have no end-date so current_membership array key exists but is NULL *} | |
55 | {if $row.current_membership} | |
56 | {if $row.current_membership|date_format:"%Y%m%d" LT $smarty.now|date_format:"%Y%m%d"} | |
57 | {ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expired on %1.{/ts}<br /> | |
58 | {else} | |
59 | {ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expires on %1.{/ts}<br /> | |
60 | {/if} | |
61 | {else} | |
62 | {ts 1=$row.name}Your <strong>%1</strong> membership does not expire (you do not need to renew that membership).{/ts}<br /> | |
63 | {/if} | |
64 | </div> | |
65 | {/if} | |
66 | {/foreach} | |
67 | {/if} | |
68 | ||
69 | {include file="CRM/Price/Form/PriceSet.tpl" extends="Membership"} | |
6a488035 TO |
70 | </fieldset> |
71 | </div> | |
72 | {elseif $lineItem and $priceSetID AND !$is_quick_config} | |
73 | {assign var="totalAmount" value=$amount} | |
74 | <div class="header-dark"> | |
75 | {ts}Membership Fee{/ts} | |
76 | </div> | |
77 | <div class="display-block"> | |
78 | {include file="CRM/Price/Page/LineItem.tpl" context="Membership"} | |
79 | </div> | |
80 | {/if} | |
81 | </div> | |
82 | {literal} | |
83 | <script type="text/javascript"> | |
3cc60a06 | 84 | CRM.$(function($) { |
6a488035 TO |
85 | //if price set is set we use below below code to show for showing auto renew |
86 | var autoRenewOption = {/literal}'{$autoRenewOption}'{literal}; | |
ae8f569f | 87 | $('#allow_auto_renew').hide(); |
6a488035 | 88 | if ( autoRenewOption == 1 ) { |
ae8f569f | 89 | $('#allow_auto_renew').show(); |
6a488035 | 90 | } else if ( autoRenewOption == 2 ) { |
ae8f569f | 91 | var autoRenew = $("#auto_renew"); |
8539f25d | 92 | autoRenew.prop('checked', true ); |
6a488035 | 93 | autoRenew.attr( 'readonly', true ); |
ae8f569f | 94 | $('#allow_auto_renew').show(); |
6a488035 TO |
95 | } |
96 | }); | |
97 | </script> | |
98 | {/literal} | |
99 | {elseif $membershipBlock AND !$is_quick_config} | |
100 | <div id="membership" class="crm-group membership-group"> | |
101 | {if $context EQ "makeContribution"} | |
102 | <fieldset> | |
103 | {if $renewal_mode } | |
104 | {if $membershipBlock.renewal_title} | |
105 | <legend>{$membershipBlock.renewal_title}</legend> | |
106 | {/if} | |
107 | {if $membershipBlock.renewal_text} | |
108 | <div id="membership-intro" class="crm-section membership_renewal_intro-section"> | |
109 | <p>{$membershipBlock.renewal_text}</p> | |
110 | </div> | |
111 | {/if} | |
112 | ||
113 | {else} | |
114 | {if $membershipBlock.new_title} | |
115 | <legend>{$membershipBlock.new_title}</legend> | |
116 | {/if} | |
117 | {if $membershipBlock.new_text} | |
118 | <div id="membership-intro" class="crm-section membership_new_intro-section"> | |
119 | <p>{$membershipBlock.new_text}</p> | |
120 | </div> | |
121 | {/if} | |
122 | {/if} | |
123 | {/if} | |
124 | {if $context neq "makeContribution" } | |
125 | <div class="header-dark"> | |
126 | {if $renewal_mode } | |
127 | {if $membershipBlock.renewal_title} | |
128 | {$membershipBlock.renewal_title} | |
129 | {else} | |
130 | {ts}Select a Membership Renewal Level{/ts} | |
131 | {/if} | |
132 | ||
133 | {else} | |
134 | {if $membershipBlock.new_title} | |
135 | {$membershipBlock.new_title} | |
136 | {else} | |
137 | {ts}Select a Membership Level{/ts} | |
138 | {/if} | |
139 | {/if} | |
140 | </div> | |
141 | {/if} | |
142 | ||
143 | {if $context EQ "makeContribution"} | |
144 | </fieldset> | |
145 | {/if} | |
146 | </div> | |
147 | ||
148 | {/if}{* membership block end here *} | |
149 | ||
150 | {if $membershipBlock AND $is_quick_config} | |
151 | {if $context neq "makeContribution" } | |
152 | <div class="header-dark"> | |
153 | {if $renewal_mode } | |
154 | {if $membershipBlock.renewal_title} | |
155 | {$membershipBlock.renewal_title} | |
156 | {else} | |
157 | {ts}Select a Membership Renewal Level{/ts} | |
158 | {/if} | |
159 | {else} | |
160 | {if $membershipBlock.new_title} | |
161 | {$membershipBlock.new_title} | |
162 | {else} | |
163 | {ts}Select a Membership Level{/ts} | |
164 | {/if} | |
165 | {/if} | |
166 | </div> | |
167 | {/if} | |
168 | {strip} | |
169 | <table id="membership-listings"> | |
170 | {foreach from=$membershipTypes item=row} | |
171 | <tr {if $context EQ "makeContribution"}class="odd-row" {/if}valign="top"> | |
172 | {if $showRadio } | |
173 | {assign var="pid" value=$row.id} | |
174 | <td style="width: 1em;">{$form.selectMembership.$pid.html}</td> | |
175 | {else} | |
176 | <td> </td> | |
177 | {/if} | |
178 | <td style="width: auto;"> | |
179 | <span class="bold">{$row.name} | |
180 | {if ($membershipBlock.display_min_fee AND $context EQ "makeContribution") AND $row.minimum_fee GT 0 } | |
181 | {if $is_separate_payment OR ! $form.amount.label} | |
182 | - {$row.minimum_fee|crmMoney} | |
183 | {else} | |
184 | {ts 1=$row.minimum_fee|crmMoney}(contribute at least %1 to be eligible for this membership){/ts} | |
185 | {/if} | |
186 | {/if} | |
187 | </span><br /> | |
188 | {$row.description} | |
189 | </td> | |
190 | ||
191 | <td style="width: auto;"> | |
192 | {* Check if there is an existing membership of this type (current_membership NOT empty) and if the end-date is prior to today. *} | |
193 | {if array_key_exists( 'current_membership', $row ) AND $context EQ "makeContribution" } | |
194 | {if $row.current_membership} | |
195 | {if $row.current_membership|date_format:"%Y%m%d" LT $smarty.now|date_format:"%Y%m%d"} | |
196 | <br /><em>{ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expired on %1.{/ts}</em> | |
197 | {else} | |
198 | <br /><em>{ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expires on %1.{/ts}</em> | |
199 | {/if} | |
200 | {else} | |
201 | {ts 1=$row.name}Your <strong>%1</strong> membership does not expire (you do not need to renew that membership).{/ts}<br /> | |
202 | {/if} | |
203 | {else} | |
204 | | |
205 | {/if} | |
206 | </td> | |
207 | </tr> | |
208 | ||
209 | {/foreach} | |
210 | {if isset($form.auto_renew) } | |
211 | <tr id="allow_auto_renew"> | |
212 | <td style="width: auto;">{$form.auto_renew.html}</td> | |
213 | <td style="width: auto;"> | |
214 | {$form.auto_renew.label} | |
215 | </td> | |
216 | </tr> | |
217 | {/if} | |
218 | {if $showRadio} | |
219 | {if $showRadioNoThanks } {* Provide no-thanks option when Membership signup is not required - per membership block configuration. *} | |
220 | <tr class="odd-row"> | |
221 | <td>{$form.selectMembership.no_thanks.html}</td> | |
222 | <td colspan="2"><strong>{ts}No thank you{/ts}</strong></td> | |
223 | </tr> | |
224 | {/if} | |
225 | {/if} | |
226 | </table> | |
227 | {/strip} | |
228 | {/if} | |
229 | {* Include JS for auto renew membership if priceset is Quick Config*} | |
230 | {if $membershipBlock AND $quickConfig} | |
231 | {literal} | |
232 | <script type="text/javascript"> | |
3cc60a06 | 233 | CRM.$(function($) { |
6a488035 TO |
234 | showHideAutoRenew( null ); |
235 | }); | |
236 | function showHideAutoRenew( memTypeId ) | |
237 | { | |
238 | var priceSetName = "price_"+{/literal}'{$membershipFieldID}'{literal}; | |
239 | var considerUserInput = {/literal}'{$takeUserSubmittedAutoRenew}'{literal}; | |
240 | if ( memTypeId ) considerUserInput = false; | |
241 | if ( !memTypeId ) memTypeId = cj('input:radio[name='+priceSetName+']:checked').attr('membership-type'); | |
242 | ||
243 | //does this page has only one membership type. | |
244 | var singleMembership = {/literal}'{$singleMembership}'{literal}; | |
245 | if ( !memTypeId && singleMembership ) memTypeId = cj("input:radio[name="+priceSetName+"]").attr('membership-type'); | |
246 | var renewOptions = {/literal}{$autoRenewMembershipTypeOptions}{literal}; | |
247 | var currentOption = eval( "renewOptions." + 'autoRenewMembershipType_' + memTypeId ); | |
248 | ||
249 | funName = 'hide();'; | |
250 | var readOnly = false; | |
251 | var isChecked = false; | |
252 | if ( currentOption == 1 ) { | |
253 | funName = 'show();'; | |
254 | ||
255 | //uncomment me, if we'd like | |
256 | //to load auto_renew checked. | |
257 | //isChecked = true; | |
258 | ||
259 | } else if ( currentOption == 2 ) { | |
260 | funName = 'show();'; | |
261 | isChecked = readOnly = true; | |
262 | } | |
263 | ||
264 | var autoRenew = cj("#auto_renew"); | |
8539f25d | 265 | if ( considerUserInput ) isChecked = autoRenew.prop('checked' ); |
6a488035 TO |
266 | |
267 | //its a normal recur contribution. | |
268 | if ( cj( "is_recur" ) && | |
269 | ( cj( 'input:radio[name="is_recur"]:checked').val() == 1 ) ) { | |
270 | isChecked = false; | |
271 | funName = 'hide();'; | |
272 | } | |
273 | ||
274 | //when we do show auto_renew read only | |
275 | //which implies it should be checked. | |
276 | if ( readOnly && funName == 'show();' ) isChecked = true; | |
277 | ||
278 | autoRenew.attr( 'readonly', readOnly ); | |
8539f25d | 279 | autoRenew.prop('checked', isChecked ); |
6a488035 TO |
280 | eval( "cj('#allow_auto_renew')." + funName ); |
281 | } | |
282 | ||
283 | {/literal}{if $allowAutoRenewMembership}{literal} | |
3cc60a06 | 284 | CRM.$(function($) { |
6a488035 TO |
285 | //keep read only always checked. |
286 | cj( "#auto_renew" ).click(function( ) { | |
287 | if ( cj(this).attr( 'readonly' ) ) { | |
8539f25d | 288 | cj(this).prop('checked', true ); |
6a488035 TO |
289 | } |
290 | }); | |
291 | }); | |
292 | {/literal}{/if}{literal} | |
293 | </script> | |
294 | {/literal} | |
295 | {/if} |