Merge branch '4.4' of https://github.com/civicrm/civicrm-core into 4.5
[civicrm-core.git] / templates / CRM / Contribute / Form / ContributionPage / Amount.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
819d0d41 3 | CiviCRM version 4.5 |
6a488035 4 +--------------------------------------------------------------------+
819d0d41 5 | Copyright CiviCRM LLC (c) 2004-2014 |
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{capture assign="adminPriceSets"}{crmURL p='civicrm/admin/price' q="reset=1"}{/capture}
27<div class="crm-block crm-form-block crm-contribution-contributionpage-amount-form-block">
6a488035
TO
28<div id="help">
29 {ts}Use this form to configure Contribution Amount options. You can give contributors the ability to enter their own contribution amounts - and/or provide a fixed list of amounts. For fixed amounts, you can enter a label for each 'level' of contribution (e.g. Friend, Sustainer, etc.). If you allow people to enter their own dollar amounts, you can also set minimum and maximum values. Depending on your choice of Payment Processor, you may be able to offer a recurring contribution option.{/ts} {docURL page="user/contributions/payment-processors"}
30</div>
31 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
32 {if !$paymentProcessor}
33 {capture assign=ppUrl}{crmURL p='civicrm/admin/paymentProcessor' q="reset=1"}{/capture}
34 <div class="status message">
35 {ts 1=$ppUrl}No Payment Processor has been configured / enabled for your site. Unless you are only using CiviContribute to solicit non-monetary / in-kind contributions, you will need to <a href='%1'>configure a Payment Processor</a>. Then return to this screen and assign the processor to this Contribution Page.{/ts} {docURL page="user/contributions/payment-processors"}
36 <p>{ts}NOTE: Alternatively, you can enable the <strong>Pay Later</strong> option below without setting up a payment processor. All users will then be asked to submit payment offline (e.g. mail in a check, call in a credit card, etc.).{/ts}</p>
37 </div>
38 {/if}
39 <table class="form-layout-compressed">
40 <tr class="crm-contribution-contributionpage-amount-form-block-is_monetary"><th scope="row" class="label" width="20%">{$form.is_monetary.label}</th>
41 <td>{$form.is_monetary.html}<br />
42 <span class="description">{ts}Uncheck this box if you are using this contribution page for free membership signup ONLY, or to solicit in-kind / non-monetary donations such as furniture, equipment.. etc.{/ts}</span></td>
43 </tr>
44 <tr class="crm-contribution-contributionpage-amount-form-block-currency"><th scope="row" class="label" width="20%">{$form.currency.label}</th>
45 <td>{$form.currency.html}<br />
46 <span class="description">{ts}Select the currency to be used for contributions submitted from this contribution page.{/ts}</span></td>
47 </tr>
48 {if $paymentProcessor}
49 <tr class="crm-contribution-contributionpage-amount-form-block-payment_processor"><th scope="row" class="label" width="20%">{$form.payment_processor.label}</th>
50 <td>{$form.payment_processor.html}<br />
51 <span class="description">{ts}Select the payment processor to be used for contributions submitted from this contribution page (unless you are soliciting non-monetary / in-kind contributions only).{/ts} {docURL page="user/contributions/payment-processors"}</span></td>
52 </tr>
53 {/if}
54 <tr class="crm-contribution-contributionpage-amount-form-block-is_pay_later"><th scope="row" class="label">{$form.is_pay_later.label}</th>
55 <td>{$form.is_pay_later.html}<br />
56 <span class="description">{ts}Check this box if you want to give users the option to submit payment offline (e.g. mail in a check, call in a credit card, etc.).{/ts}</span></td>
57 </tr>
58 <tr id="payLaterFields" class="crm-contribution-form-block-payLaterFields"><td>&nbsp;</td>
59 <td>
60 <table class="form-layout">
61 <tr class="crm-contribution-contributionpage-amount-form-block-pay_later_text"><th scope="row" class="label">{$form.pay_later_text.label} <span class="marker" title="This field is required.">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='pay_later_text' id=$contributionPageID}{/if}</th>
62 <td>{$form.pay_later_text.html|crmAddClass:big}<br />
8a51f5e6 63 <span class="description">{ts}Text displayed next to the checkbox for the 'pay later' option on the contribution form. You may include HTML formatting tags.{/ts}</span></td></tr>
6a488035
TO
64 <tr class="crm-contribution-contributionpage-amount-form-block-pay_later_receipt"><th scope="row" class="label">{$form.pay_later_receipt.label} <span class="marker" title="This field is required.">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='pay_later_receipt' id=$contributionPageID}{/if}</th>
65 <td>{$form.pay_later_receipt.html|crmAddClass:big}<br />
66 <span class="description">{ts}Instructions added to Confirmation and Thank-you pages, as well as the confirmation email, when the user selects the 'pay later' option (e.g. 'Mail your check to ... within 3 business days.').{/ts}</span></td></tr>
b2603e29 67
6a488035
TO
68 </table>
69 </td>
70 </tr>
71 <tr class="crm-contribution-contributionpage-amount-form-block-amount_block_is_active">
72 <th scope="row" class="label">{$form.amount_block_is_active.label}</th>
73 <td>{$form.amount_block_is_active.html}<br />
74 <span class="description">{ts}Uncheck this box if you are using this contribution page for membership signup and renewal only - and you do NOT want users to select or enter any additional contribution amounts.{/ts}</span></td>
75 </tr>
76 <tr id="priceSet" class="crm-contribution-contributionpage-amount-form-block-priceSet">
77 <th scope="row" class="label">{$form.price_set_id.label}</th>
78 {if $price eq true}
79 <td>{$form.price_set_id.html}<br /><span class="description">{ts 1=$adminPriceSets}Select a pre-configured Price Set to offer multiple individually priced options for contributions. Otherwise, select &quot;-none-&quot; and enter one or more fixed contribution options in the table below. Create or edit Price Sets <a href='%1'>here</a>.{/ts}</span></td>
80 {else}
81 <td><div class="status message">{ts 1=$adminPriceSets}No Contribution Price Sets have been configured / enabled for your site. Price sets allow you to configure more complex contribution options (e.g. "Contribute $25 more to receive our monthly magazine."). Click <a href='%1'>here</a> if you want to configure price sets for your site.{/ts}</div></td>
82 {/if}
83 </tr>
84 </table>
85
86 <div id="recurringFields">
87 <table class="form-layout-compressed">
88
89
90 {if $recurringPaymentProcessor}
91 <tr id="recurringContribution" class="crm-contribution-form-block-is_recur"><th scope="row" class="label" width="20%">{$form.is_recur.label}</th>
92 <td>{$form.is_recur.html}<br />
93 <span class="description">{ts}Check this box if you want to give users the option to make recurring contributions. This feature requires that you use a payment processor which supports recurring billing / subscriptions functionality.{/ts} {docURL page="user/contributions/payment-processors"}</span>
94 </td>
95 </tr>
96 <tr id="recurFields" class="crm-contribution-form-block-recurFields"><td>&nbsp;</td>
97 <td>
98 <table class="form-layout-compressed">
99 <tr class="crm-contribution-form-block-recur_frequency_unit"><th scope="row" class="label">{$form.recur_frequency_unit.label}<span class="marker" title="This field is required.">*</span></th>
100 <td>{$form.recur_frequency_unit.html}<br />
101 <span class="description">{ts}Select recurring units supported for recurring payments.{/ts}</span></td>
102 </tr>
103 <tr class="crm-contribution-form-block-is_recur_interval"><th scope="row" class="label">{$form.is_recur_interval.label}</th>
104 <td>{$form.is_recur_interval.html}<br />
105 <span class="description">{ts}Can users also set an interval (e.g. every '3' months)?{/ts}</span></td>
106 </tr>
107 <tr class="crm-contribution-form-block-is_recur_installments"><th scope="row" class="label">{$form.is_recur_installments.label}</th>
108 <td>{$form.is_recur_installments.html}<br />
109 <span class="description">{ts}Give the user a choice of installments (e.g. donate every month for 6 months)? If not, recurring donations will continue indefinitely.{/ts}</span></td>
110 </tr>
111 </table>
112 </td>
113 </tr>
114 {/if}
115
116 </table>
117 </div>
118
119
120 <div id="amountFields">
121 <table class="form-layout-compressed">
122 {* handle CiviPledge fields *}
123 {if $civiPledge}
124 <tr class="crm-contribution-form-block-is_pledge_active"><th scope="row" class="label" width="20%">{$form.is_pledge_active.label}</th>
125 <td>{$form.is_pledge_active.html}<br />
126 <span class="description">{ts}Check this box if you want to give users the option to make a Pledge (a commitment to contribute a fixed amount on a recurring basis).{/ts}</span>
127 </td>
128 </tr>
129 <tr id="pledgeFields" class="crm-contribution-form-block-pledgeFields"><td></td><td>
130 <table class="form-layout-compressed">
131 <tr class="crm-contribution-form-block-pledge_frequency_unit"><th scope="row" class="label">{$form.pledge_frequency_unit.label}<span class="marker"> *</span></th>
132 <td>{$form.pledge_frequency_unit.html}<br />
133 <span class="description">{ts}Which frequencies can the user pick from (e.g. every 'week', every 'month', every 'year')?{/ts}</span></td>
134 </tr>
135 <tr class="crm-contribution-form-block-is_pledge_interval"><th scope="row" class="label">{$form.is_pledge_interval.label}</th>
136 <td>{$form.is_pledge_interval.html}<br />
137 <span class="description">{ts}Can they also set an interval (e.g. every '3' months)?{/ts}</span></td>
138 </tr>
139 <tr class="crm-contribution-form-block-initial_reminder_day"><th scope="row" class="label">{$form.initial_reminder_day.label}</th>
140 <td>{$form.initial_reminder_day.html}
141 <span class="label">{ts}days prior to each scheduled payment due date.{/ts}</span></td>
142 </tr>
143 <tr class="crm-contribution-form-block-max_reminders"><th scope="row" class="label">{$form.max_reminders.label}</th>
144 <td>{$form.max_reminders.html}
145 <span class="label">{ts}reminders for each scheduled payment.{/ts}</span></td>
146 </tr>
147 <tr class="crm-contribution-form-block-additional_reminder_day"><th scope="row" class="label">{$form.additional_reminder_day.label}</th>
148 <td>{$form.additional_reminder_day.html}
149 <span class="label">{ts}days after the last one sent, up to the maximum number of reminders.{/ts}</span></td>
150 </tr>
151 </table>
152 </td>
153 </tr>
154 {/if}
34408315
E
155
156 <tr class="crm-contribution-form-block-amount_label">
b52a8f03 157 <th scope="row" class="label" width="20%">{$form.amount_label.label}<span class="marker"> *</span></th>
34408315
E
158 <td>{$form.amount_label.html}</td>
159 </tr>
6a488035
TO
160 <tr class="crm-contribution-form-block-is_allow_other_amount"><th scope="row" class="label" width="20%">{$form.is_allow_other_amount.label}</th>
161 <td>{$form.is_allow_other_amount.html}<br />
162 <span class="description">{ts}Check this box if you want to give users the option to enter their own contribution amount. Your page will then include a text field labeled <strong>Other Amount</strong>.{/ts}</span></td></tr>
163
164 <tr id="minMaxFields" class="crm-contribution-form-block-minMaxFields"><td>&nbsp;</td><td>
165 <table class="form-layout-compressed">
166 <tr class="crm-contribution-form-block-min_amount"><th scope="row" class="label">{$form.min_amount.label}</th>
167 <td>{$form.min_amount.html|crmMoney}</td></tr>
168 <tr class="crm-contribution-form-block-max_amount"><th scope="row" class="label">{$form.max_amount.label}</th>
169 <td>{$form.max_amount.html|crmMoney}<br />
170 <span class="description">{ts 1=5|crmMoney}If you have chosen to <strong>Allow Other Amounts</strong>, you can use the fields above to control minimum and/or maximum acceptable values (e.g. don't allow contribution amounts less than %1).{/ts}</span></td></tr>
171 </table>
172 </td></tr>
173
174 <tr><td colspan="2">
175 <fieldset><legend>{ts}Fixed Contribution Options{/ts}</legend>
247506c6 176 {ts}Use the table below to enter up to ten fixed contribution amounts. These will be presented as a list of radio button options. Both the label and dollar amount will be displayed.{/ts}{if $isQuick}{ts} Click <a id='quickconfig' href='#'>here</a> if you want to configure the Fixed Contribution Options below as part of a Price Set, with the added flexibility and complexity that entails.{/ts}{/if}<br />
6a488035 177 <table id="map-field-table">
8a4f27dc 178 <tr class="columnheader" ><th scope="column">{ts}Contribution Label{/ts}</th><th scope="column">{ts}Amount{/ts}</th><th scope="column">{ts}Default?{/ts}<br />{$form.default.0.html}</th></tr>
6a488035
TO
179 {section name=loop start=1 loop=11}
180 {assign var=idx value=$smarty.section.loop.index}
181 <tr><td class="even-row">{$form.label.$idx.html}</td><td>{$form.value.$idx.html|crmMoney}</td><td class="even-row">{$form.default.$idx.html}</td></tr>
182 {/section}
183 </table>
184 </fieldset>
185 </td></tr>
186 </table>
187 </div>
188 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
189</div>
190
191{literal}
192<script type="text/javascript">
ae8f569f 193 var paymentProcessorMapper = [];
6a488035
TO
194 {/literal}
195 {if $recurringPaymentProcessor}
196 {foreach from=$recurringPaymentProcessor item="paymentProcessor" key="index"}{literal}
197 paymentProcessorMapper[{/literal}{$index}{literal}] = '{/literal}{$paymentProcessor}{literal}';
198 {/literal}{/foreach}
199 {/if}
200 {literal}
847f8123 201 CRM.$(function($) {
847f8123
CW
202 function checked_payment_processors() {
203 var ids = [];
204 $('.crm-contribution-contributionpage-amount-form-block-payment_processor input[type="checkbox"]').each(function(){
205 if($(this).prop('checked')) {
206 var id = $(this).attr('id').split('_')[2];
207 ids.push(id);
208 }
209 });
210 return ids;
211 }
6a488035
TO
212
213 // show/hide recurring block
847f8123
CW
214 $('.crm-contribution-contributionpage-amount-form-block-payment_processor input[type="checkbox"]').change(function(){
215 showRecurring( checked_payment_processors() );
6a488035 216 });
847f8123 217 showRecurring( checked_payment_processors() );
6a488035
TO
218 });
219 var element_other_amount = document.getElementsByName('is_allow_other_amount');
220 if (! element_other_amount[0].checked) {
221 cj('#minMaxFields').hide();
222 }
223 var amount_block = document.getElementsByName('amount_block_is_active');
224 var priceSetID = {/literal}'{$priceSetID}'{literal};
225
226 if ( ! amount_block[0].checked || priceSetID ) {
227 if ( !priceSetID ) {
228 cj('#priceSet').hide();
1ebebaab
AH
229 if (CRM.memberPriceset) {
230 cj(".crm-contribution-contributionpage-amount-form-block-amount_block_is_active td").html('<span class="description">{/literal}{ts}You cannot enable the Contribution Amounts section when a Membership Price Set is in use. (See the Memberships tab above.) Membership Price Sets may include additional fields for non-membership options that require an additional fee (e.g. magazine subscription) or an additional voluntary contribution.</span>{/ts}{literal}');
231 }
6a488035
TO
232 }
233 cj('#amountFields').hide();
1ebebaab 234 }
6a488035 235
3cc60a06 236 CRM.$(function($) {
6a488035
TO
237 payLater('is_pay_later');
238 });
239
240 cj('#is_pay_later').click( function() {
241 payLater('is_pay_later');
242 });
b2603e29 243
6a488035
TO
244
245 function minMax(chkbox) {
246 if (chkbox.checked) {
247 cj('#minMaxFields').show();
248 } else {
249 cj('#minMaxFields').hide();
250 document.getElementById("min_amount").value = '';
251 document.getElementById("max_amount").value = '';
252 }
253 }
254
255 function payLater(chkbox) {
256 var elementId = 'payLaterFields';
8539f25d 257 if (cj('#' + chkbox).prop('checked')) {
6a488035
TO
258 cj('#' + elementId).show();
259 } else {
260 cj('#' + elementId).hide();
261 }
262 }
263
264 function showHideAmountBlock( element, elementName )
265 {
266 // show / hide when amount section is active check/uncheck.
267
268 var priceSetID = {/literal}'{$priceSetID}'{literal};
269
270 switch ( elementName ) {
271 case 'price_set_id':
272 if ( element ) {
273 cj('#amountFields').hide();
274 } else {
275 cj('#amountFields').show();
276 }
8539f25d 277 cj("#amount_block_is_active").prop('checked', true );
6a488035
TO
278 break;
279
280 case 'is_pledge_active' :
281 case 'is_allow_other_amount' :
282 if ( element.checked ) {
283 if ( priceSetID ) cj( "#price_set_id" ).val( '' );
284 cj('#amountFields').show();
285 }
8539f25d 286 cj("#amount_block_is_active").prop('checked', true );
6a488035
TO
287 break;
288
289 case 'amount_block_is_active' :
290 if ( element.checked ) {
291 if ( priceSetID ) {
292 cj('#amountFields').hide();
293 cj( "#price_set_id" ).val( priceSetID );
294 } else {
295 cj('#amountFields').show();
296 cj( "#price_set_id" ).val( '' );
297 }
298 cj('#priceSet, #recurringFields').show();
299 } else {
300 cj( "#price_set_id" ).val( '' );
301 cj('#amountFields, #priceSet, #recurringFields').hide();
302 }
303 break;
304 }
305 }
306
307 function showRecurring( paymentProcessorIds ) {
308 var display = true;
309 cj.each(paymentProcessorIds, function(k, id){
310 if( cj.inArray(id, paymentProcessorMapper) == -1 ) {
311 display = false;
312 }
313 });
314
315 if(display) {
316 cj( '#recurringContribution' ).show( );
317 } else {
8539f25d
CW
318 if ( cj( '#is_recur' ).prop('checked' ) ) {
319 cj( '#is_recur' ).prop('checked', false);
6a488035
TO
320 cj( '#recurFields' ).hide( );
321 }
322 cj( '#recurringContribution' ).hide( );
323 }
324 }
b2603e29 325
6a488035
TO
326</script>
327{/literal}
328{if $form.is_recur}
329{include file="CRM/common/showHideByFieldValue.tpl"
330 trigger_field_id ="is_recur"
331 trigger_value ="true"
332 target_element_id ="recurFields"
333 target_element_type ="table-row"
334 field_type ="radio"
335 invert = "false"
336}
337{/if}
338{if $civiPledge}
339{include file="CRM/common/showHideByFieldValue.tpl"
340 trigger_field_id = "is_pledge_active"
341 trigger_value = "true"
342 target_element_id = "pledgeFields"
343 target_element_type = "table-row"
344 field_type = "radio"
345 invert = "false"
346}
347{/if}
348
6a488035
TO
349{if $isQuick}
350{literal}
351<script type="text/javascript">
847f8123
CW
352 CRM.$(function($) {
353 $("#quickconfig").click(function(e) {
354 e.preventDefault();
355 CRM.confirm({
356 width: 400,
357 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}
358 }).on('crmConfirm:yes', function() {
359 {/literal}
360 var dataUrl = '{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Core_Page_AJAX&fnName=setIsQuickConfig&context=civicrm_contribution_page&id=$contributionPageID" }';
361 {literal}
362 $.getJSON(dataUrl).done(function(result) {window.location = CRM.url("civicrm/admin/price/field", {reset: 1, action: 'browse', sid: result});});
363 });
364 });
365 });
6a488035
TO
366</script>
367{/literal}
368{/if}