Cleanup tpl js for switching to a price set
[civicrm-core.git] / templates / CRM / Member / Form / MembershipBlock.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 {* Configure Membership signup/renewal block for an Online Contribution page *}
27 <div id="form" class="crm-block crm-form-block crm-member-membershipblock-form-block">
28 <div id="help">
29 {ts}Use this form to enable and configure a Membership Signup and Renewal section for this Online Contribution Page. If you're not using this page for membership signup, leave the <strong>Enabled</strong> box un-checked..{/ts} {docURL page="user/membership/setup"}
30 </div>
31 {if $form.membership_type.html}
32 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
33 <table class="form-layout-compressed">
34 <tr class="crm-member-membershipblock-form-block-member_is_active">
35 <td class="label"></td><td class="html-adjust">{$form.member_is_active.html}&nbsp;{$form.member_is_active.label}<br />
36 <span class="description">{ts}Include a Membership Signup section in this Online Contribution page?{/ts}</span></td>
37 </tr>
38 </table>
39 <div id="memberFields">
40 <table class="form-layout-compressed">
41 <tr class="crm-member-membershipblock-form-block-new_title">
42 <td class="label">{$form.new_title.label}
43 {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_membership_block' field='new_title' id=$membershipBlockId}{/if}</td><td>{$form.new_title.html}<br />
44 <span class="description">{ts}Membership section title - for new member signups.{/ts}</span></td>
45 </tr>
46 <tr class="crm-member-membershipblock-form-block-new_text">
47 <td class="label">{$form.new_text.label}
48 {if $action == 2}<br />{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_membership_block' field='new_text' id=$membershipBlockId}{/if}
49 </td>
50 <td>{$form.new_text.html}<br />
51 <span class="description">{ts}Membership section introductory text - for new member signups.{/ts}<br /></span><br /></td>
52 </tr>
53 <tr class="crm-member-membershipblock-form-block-renewal_title">
54 <td class="label">{$form.renewal_title.label}
55 {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_membership_block' field='renewal_title' id=$membershipBlockId}{/if}</td><td>{$form.renewal_title.html}<br />
56 <span class="description">{ts}Membership section title - displayed to renewing members.{/ts}</span></td>
57 </tr>
58 <tr class="crm-member-membershipblock-form-block-renewal_text">
59 <td class="label">{$form.renewal_text.label}
60 {if $action == 2}<br />{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_membership_block' field='renewal_text' id=$membershipBlockId}{/if}
61 </td>
62 <td>{$form.renewal_text.html}<br />
63 <span class="description">{ts}Membership section introductory text - displayed to renewing members.{/ts}</span><br /></td>
64 </tr>
65 <tr class="crm-member-membershipblock-form-block-member_price_set_id">
66 <td class="label">{$form.member_price_set_id.label}</td>
67 <td>
68 {if $price eq false}
69 {capture assign=adminPriceSetsURL}{crmURL p="civicrm/admin/price" q="reset=1"}{/capture}
70 <div class="status message">{ts 1=$adminPriceSetsURL}No Membership Price Sets have been configured / enabled for your site. Price sets allow you to configure more complex membership signup and renewal options, including allowing constituents to sign up for multiple memberships at the same time. Click <a href='%1'>here</a> if you want to configure price sets for your site.{/ts}</div>
71 {else}
72 {$form.member_price_set_id.html}
73 {/if}
74 </td>
75 </tr>
76 {if $isQuick}
77 <tr id="quickConfigConvertMessage">
78 <td></td>
79 <td><div class="status message">{ts}Click <a id='memQuickconfig' href='#'>here</a> if you want to configure the Membership Types below as part of a Price Set, with the added flexibility and complexity that entails.{/ts}</div></td>
80 </tr>
81 {/if}
82 <tr id="membership_type-block" class="crm-member-membershipblock-form-block-membership_type">
83 <td class="label">{$form.membership_type.label}</td>
84 <td>
85 {assign var="count" value="1"}
86 {strip}
87 <table class="report">
88 <tr class="columnheader" style="vertical-align:top;"><th style="border-right: 1px solid #4E82CF;">{ts}Include these membership types{/ts}</th><th{if $is_recur} style="border-right: 1px solid #4E82CF;"{/if}>{ts}Default{/ts}<br />
89 </th>{if $is_recur}<th>{ts}Auto-renew{/ts}</th>{/if}</tr>
90 {assign var="index" value="1"}
91 {foreach name=outer key=key item=item from=$form.membership_type}
92 {if $index < 10}
93 {assign var="index" value=`$index+1`}
94 {else}
95 <tr>
96 <td class="labels font-light">{$form.membership_type.$key.html}</td>
97 <td class="labels font-light">{$form.membership_type_default.$key.html}</td>
98 {if $is_recur}
99 <td class="labels font-light">
100 {if $auto_renew.$key}
101 {assign var="element" value="auto_renew"|cat:_|cat:$key}{$form.$element.html}
102 {else}
103 {ts}(Not Available){/ts}
104 {/if}
105 </td>
106 {/if}
107 </tr>
108 {/if}
109 {/foreach}
110 </table>
111 {/strip}
112 </td>
113 </tr>
114 <tr id="requiredSignup" class="crm-member-membershipblock-form-block-is_required">
115 <td class="label"></td><td class="html-adjust">{$form.is_required.html}&nbsp;{$form.is_required.label}<br />
116 <span class="description">{ts}If checked, user must signup for one of the displayed membership options before continuing.{/ts}</span></td>
117 </tr>
118 <tr id="separatePayment" class="crm-member-membershipblock-form-block-is_separate_payment">
119 <td class="label"></td><td class="html-adjust">{$form.is_separate_payment.html}&nbsp;{$form.is_separate_payment.label} {help id="id-separate-pay"}<br />
120 <span class="description">{ts}Check this box if you are including both Membership Signup/Renewal AND a Contribution Amount section, AND you want the membership fee to be charged separately from any additional contribution amount.{/ts}</span></td>
121 </tr>
122 <tr id="displayFee" class="crm-member-membershipblock-form-block-display_min_fee">
123 <td class="label"></td><td class="html-adjust">{$form.display_min_fee.html}&nbsp;{$form.display_min_fee.label} {help id="id-display-fee"}<br />
124 <span class="description">{ts}Display the membership fee along with the membership name and description for each membership option?{/ts}</span></td>
125 </tr>
126
127 </table>
128 </div>
129 {else}
130 <div class="status message">
131 {capture assign=linkURL}{crmURL p="civicrm/admin/member/membershipType" q="reset=1"}{/capture}
132 {ts 1=$linkURL}You need to have at least one <a href="%1">Membership Type</a> with 'Public' visibility in order to enable self-service Membership Signup and Renewal.{/ts}
133 </div>
134 {/if}
135 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
136 </div>
137
138 {literal}
139 <script type="text/javascript">
140 CRM.$(function($) {
141 //show/hide membership block
142 showHideMembershipBlock();
143 $('#member_is_active').click( function() {
144 showHideMembershipBlock();
145 });
146
147 //show/ hide blocks if price set is selected
148 checkIfPriceSetIsSelected( );
149 $('#member_price_set_id').change( function(){
150 checkIfPriceSetIsSelected( );
151 });
152 });
153
154 // function to show/hide membership block fields
155 function showHideMembershipBlock( ) {
156 if ( cj('#member_is_active').prop('checked') ) {
157 cj('#memberFields').show();
158 } else {
159 cj('#memberFields').hide();
160 }
161 }
162 // function to handle show/hide of membership type and related blocks if price set is selected
163 function checkIfPriceSetIsSelected( ) {
164 if ( cj('#member_price_set_id').val() ) {
165 cj('#membership_type-block').hide();
166 cj('#requiredSignup').hide();
167 cj('#displayFee').hide();
168 cj('#separatePayment').hide();
169 cj('#quickConfigConvertMessage').hide();
170 } else {
171 cj('#membership_type-block').show();
172 cj('#requiredSignup').show();
173 cj('#displayFee').show();
174 cj('#separatePayment').show();
175 }
176 }
177 </script>
178 {/literal}
179
180 {if $isQuick}
181 {literal}
182 <script type="text/javascript">
183 CRM.$(function($) {
184 $("#memQuickconfig").click(function(e) {
185 e.preventDefault();
186 CRM.confirm({
187 width: 400,
188 message: {/literal}"{ts escape='js'}Once you switch to using a Price Set, you won't be able to switch back to your existing settings below except by re-entering them. Are you sure you want to switch to a Price Set?{/ts}"{literal}
189 }).on('crmConfirm:yes', function() {
190 {/literal}
191 var dataUrl = '{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Core_Page_AJAX&fnName=setIsQuickConfig&context=civicrm_contribution_page&id=$contributionPageID" }';
192 {literal}
193 $.getJSON(dataUrl).done(function(result) {window.location = CRM.url("civicrm/admin/price/field", {reset: 1, action: 'browse', sid: result});});
194 });
195 });
196 });
197 </script>
198 {/literal}
199 {/if}