Merge pull request #12958 from pradpnayak/Tags
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / MembershipBlock.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
fee14197 3 | CiviCRM version 5 |
6a488035 4 +--------------------------------------------------------------------+
8c9251b3 5 | Copyright CiviCRM LLC (c) 2004-2018 |
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 84CRM.$(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};
81308445
JP
87 var autoRenew = $("#auto_renew_section");
88 var autoRenewCheckbox = $("#auto_renew");
c843169c
MW
89 var forceRenew = $("#force_renew");
90 autoRenew.hide();
91 forceRenew.hide();
6a488035 92 if ( autoRenewOption == 1 ) {
c843169c 93 autoRenew.show();
6a488035 94 } else if ( autoRenewOption == 2 ) {
81308445
JP
95 autoRenewCheckbox.prop('checked', true );
96 autoRenewCheckbox.attr( 'readonly', true );
c843169c
MW
97 autoRenew.hide();
98 forceRenew.show();
6a488035
TO
99 }
100});
101</script>
102{/literal}
103{elseif $membershipBlock AND !$is_quick_config}
104<div id="membership" class="crm-group membership-group">
105 {if $context EQ "makeContribution"}
106 <fieldset>
107 {if $renewal_mode }
108 {if $membershipBlock.renewal_title}
109 <legend>{$membershipBlock.renewal_title}</legend>
110 {/if}
111 {if $membershipBlock.renewal_text}
112 <div id="membership-intro" class="crm-section membership_renewal_intro-section">
113 <p>{$membershipBlock.renewal_text}</p>
114 </div>
115 {/if}
116
117 {else}
118 {if $membershipBlock.new_title}
119 <legend>{$membershipBlock.new_title}</legend>
120 {/if}
121 {if $membershipBlock.new_text}
122 <div id="membership-intro" class="crm-section membership_new_intro-section">
123 <p>{$membershipBlock.new_text}</p>
124 </div>
125 {/if}
126 {/if}
127 {/if}
128 {if $context neq "makeContribution" }
129 <div class="header-dark">
130 {if $renewal_mode }
131 {if $membershipBlock.renewal_title}
132 {$membershipBlock.renewal_title}
133 {else}
134 {ts}Select a Membership Renewal Level{/ts}
135 {/if}
136
137 {else}
138 {if $membershipBlock.new_title}
139 {$membershipBlock.new_title}
140 {else}
141 {ts}Select a Membership Level{/ts}
142 {/if}
143 {/if}
144 </div>
145 {/if}
146
147 {if $context EQ "makeContribution"}
148 </fieldset>
149 {/if}
150</div>
151
152{/if}{* membership block end here *}
153
154{if $membershipBlock AND $is_quick_config}
155{if $context neq "makeContribution" }
156 <div class="header-dark">
157 {if $renewal_mode }
158 {if $membershipBlock.renewal_title}
159 {$membershipBlock.renewal_title}
160 {else}
161 {ts}Select a Membership Renewal Level{/ts}
162 {/if}
163 {else}
164 {if $membershipBlock.new_title}
165 {$membershipBlock.new_title}
166 {else}
167 {ts}Select a Membership Level{/ts}
168 {/if}
169 {/if}
170 </div>
171{/if}
172 {strip}
173 <table id="membership-listings">
174 {foreach from=$membershipTypes item=row}
175 <tr {if $context EQ "makeContribution"}class="odd-row" {/if}valign="top">
176 {if $showRadio }
177 {assign var="pid" value=$row.id}
178 <td style="width: 1em;">{$form.selectMembership.$pid.html}</td>
179 {else}
180 <td>&nbsp;</td>
181 {/if}
182 <td style="width: auto;">
183 <span class="bold">{$row.name} &nbsp;
184 {if ($membershipBlock.display_min_fee AND $context EQ "makeContribution") AND $row.minimum_fee GT 0 }
185 {if $is_separate_payment OR ! $form.amount.label}
4c030d33 186 &ndash; {$row.minimum_fee|crmMoney}
6a488035
TO
187 {else}
188 {ts 1=$row.minimum_fee|crmMoney}(contribute at least %1 to be eligible for this membership){/ts}
189 {/if}
190 {/if}
191 </span><br />
192 {$row.description} &nbsp;
193 </td>
194
195 <td style="width: auto;">
196 {* Check if there is an existing membership of this type (current_membership NOT empty) and if the end-date is prior to today. *}
197 {if array_key_exists( 'current_membership', $row ) AND $context EQ "makeContribution" }
198 {if $row.current_membership}
199 {if $row.current_membership|date_format:"%Y%m%d" LT $smarty.now|date_format:"%Y%m%d"}
200 <br /><em>{ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expired on %1.{/ts}</em>
201 {else}
202 <br /><em>{ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expires on %1.{/ts}</em>
203 {/if}
204 {else}
205 {ts 1=$row.name}Your <strong>%1</strong> membership does not expire (you do not need to renew that membership).{/ts}<br />
206 {/if}
207 {else}
208 &nbsp;
209 {/if}
210 </td>
211 </tr>
212
213 {/foreach}
214 {if isset($form.auto_renew) }
215 <tr id="allow_auto_renew">
216 <td style="width: auto;">{$form.auto_renew.html}</td>
217 <td style="width: auto;">
218 {$form.auto_renew.label}
219 </td>
220 </tr>
221 {/if}
222 {if $showRadio}
223 {if $showRadioNoThanks } {* Provide no-thanks option when Membership signup is not required - per membership block configuration. *}
224 <tr class="odd-row">
225 <td>{$form.selectMembership.no_thanks.html}</td>
226 <td colspan="2"><strong>{ts}No thank you{/ts}</strong></td>
227 </tr>
228 {/if}
229 {/if}
230 </table>
231 {/strip}
232{/if}
233{* Include JS for auto renew membership if priceset is Quick Config*}
dfa81da9 234{if $membershipBlock}
6a488035
TO
235{literal}
236<script type="text/javascript">
3cc60a06 237CRM.$(function($) {
6a488035
TO
238 showHideAutoRenew( null );
239});
240function showHideAutoRenew( memTypeId )
241{
242 var priceSetName = "price_"+{/literal}'{$membershipFieldID}'{literal};
243 var considerUserInput = {/literal}'{$takeUserSubmittedAutoRenew}'{literal};
244 if ( memTypeId ) considerUserInput = false;
245 if ( !memTypeId ) memTypeId = cj('input:radio[name='+priceSetName+']:checked').attr('membership-type');
246
247 //does this page has only one membership type.
248 var singleMembership = {/literal}'{$singleMembership}'{literal};
249 if ( !memTypeId && singleMembership ) memTypeId = cj("input:radio[name="+priceSetName+"]").attr('membership-type');
250 var renewOptions = {/literal}{$autoRenewMembershipTypeOptions}{literal};
251 var currentOption = eval( "renewOptions." + 'autoRenewMembershipType_' + memTypeId );
81308445 252 var autoRenew = cj('#auto_renew_section');
c843169c
MW
253 var autoRenewC = cj('input[name="auto_renew"]');
254 var forceRenew = cj("#force_renew");
6a488035 255
6a488035
TO
256 var readOnly = false;
257 var isChecked = false;
c843169c
MW
258 if ( currentOption == 0 ) {
259 isChecked = false;
260 forceRenew.hide();
261 autoRenew.hide();
262 }
6a488035 263 if ( currentOption == 1 ) {
c843169c
MW
264 forceRenew.hide();
265 autoRenew.show();
6a488035
TO
266
267 //uncomment me, if we'd like
268 //to load auto_renew checked.
269 //isChecked = true;
979e1051 270 } else if ( currentOption == 2 || currentOption == 4) {
c843169c
MW
271 autoRenew.hide();
272 forceRenew.show();
6a488035
TO
273 isChecked = readOnly = true;
274 }
275
8539f25d 276 if ( considerUserInput ) isChecked = autoRenew.prop('checked' );
6a488035
TO
277
278 //its a normal recur contribution.
279 if ( cj( "is_recur" ) &&
280 ( cj( 'input:radio[name="is_recur"]:checked').val() == 1 ) ) {
281 isChecked = false;
c843169c
MW
282 autoRenew.hide();
283 forceRenew.hide();
6a488035
TO
284 }
285
c843169c
MW
286 autoRenewC.attr( 'readonly', readOnly );
287 autoRenewC.prop('checked', isChecked );
6a488035
TO
288}
289
290{/literal}{if $allowAutoRenewMembership}{literal}
3cc60a06 291 CRM.$(function($) {
6a488035
TO
292 //keep read only always checked.
293 cj( "#auto_renew" ).click(function( ) {
294 if ( cj(this).attr( 'readonly' ) ) {
8539f25d 295 cj(this).prop('checked', true );
6a488035
TO
296 }
297 });
298 });
299{/literal}{/if}{literal}
300</script>
301{/literal}
302{/if}