Merge pull request #12515 from civicrm/5.4
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / Main.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
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 {* Callback snippet: On-behalf profile *}
27 {if $snippet and !empty($isOnBehalfCallback) and !$ccid}
28 <div class="crm-public-form-item crm-section">
29 {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
30 </div>
31 {else}
32 {literal}
33 <script type="text/javascript">
34
35 // Putting these functions directly in template so they are available for standalone forms
36 function useAmountOther() {
37 var priceset = {/literal}{if $contriPriceset}'{$contriPriceset}'{else}0{/if}{literal};
38
39 for( i=0; i < document.Main.elements.length; i++ ) {
40 element = document.Main.elements[i];
41 if ( element.type == 'radio' && element.name == priceset ) {
42 if (element.value == '0' ) {
43 element.click();
44 }
45 else {
46 element.checked = false;
47 }
48 }
49 }
50 }
51
52 function clearAmountOther() {
53 var priceset = {/literal}{if $priceset}'#{$priceset}'{else}0{/if}{literal}
54 if( priceset ){
55 cj(priceset).val('');
56 cj(priceset).blur();
57 }
58 if (document.Main.amount_other == null) return; // other_amt field not present; do nothing
59 document.Main.amount_other.value = "";
60 }
61
62 </script>
63 {/literal}
64
65 {if $action & 1024}
66 {include file="CRM/Contribute/Form/Contribution/PreviewHeader.tpl"}
67 {/if}
68
69 {if $displayCaptchaWarning}
70 <div class="messages status no-popup">
71 {ts}To display reCAPTCHA on form you must get an API key from<br /> <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>{/ts}
72 </div>
73 {/if}
74
75 {include file="CRM/common/TrackingFields.tpl"}
76
77 <div class="crm-contribution-page-id-{$contributionPageID} crm-block crm-contribution-main-form-block">
78
79 {if $contact_id && !$ccid}
80 <div class="messages status no-popup crm-not-you-message">
81 {ts 1=$display_name}Welcome %1{/ts}. (<a href="{crmURL p='civicrm/contribute/transact' q="cid=0&reset=1&id=`$contributionPageID`"}" title="{ts}Click here to do this for a different person.{/ts}">{ts 1=$display_name}Not %1, or want to do this for a different person{/ts}</a>?)
82 </div>
83 {/if}
84
85 <div id="intro_text" class="crm-public-form-item crm-section intro_text-section">
86 {$intro_text}
87 </div>
88 {include file="CRM/common/cidzero.tpl"}
89 {if $islifetime or $ispricelifetime }
90 <div class="help">{ts}You have a current Lifetime Membership which does not need to be renewed.{/ts}</div>
91 {/if}
92
93 {if !empty($useForMember) && !$ccid}
94 <div class="crm-public-form-item crm-section">
95 {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="makeContribution"}
96 </div>
97 {elseif !empty($ccid)}
98 {if $lineItem && $priceSetID && !$is_quick_config}
99 <div class="header-dark">
100 {ts}Contribution Information{/ts}{if $display_name} &ndash; {$display_name}{/if}
101 </div>
102 {assign var="totalAmount" value=$pendingAmount}
103 {include file="CRM/Price/Page/LineItem.tpl" context="Contribution"}
104 {else}
105 <div class="display-block">
106 <td class="label">{$form.total_amount.label}</td>
107 <td><span>{$form.total_amount.html|crmMoney}&nbsp;&nbsp;{if $taxAmount}{ts 1=$taxTerm 2=$taxAmount|crmMoney}(includes %1 of %2){/ts}{/if}</span></td>
108 </div>
109 {/if}
110 {else}
111 <div id="priceset-div">
112 {include file="CRM/Price/Form/PriceSet.tpl" extends="Contribution"}
113 </div>
114 {/if}
115
116 {if !$ccid}
117 {crmRegion name='contribution-main-pledge-block'}
118 {if $pledgeBlock}
119 {if $is_pledge_payment}
120 <div class="crm-public-form-item crm-section {$form.pledge_amount.name}-section">
121 <div class="label">{$form.pledge_amount.label}&nbsp;<span class="crm-marker">*</span></div>
122 <div class="content">{$form.pledge_amount.html}</div>
123 <div class="clear"></div>
124 </div>
125 {else}
126 <div class="crm-public-form-item crm-section {$form.is_pledge.name}-section">
127 <div class="label">&nbsp;</div>
128 <div class="content">
129 {$form.is_pledge.html}&nbsp;
130 {if $is_pledge_interval}
131 {$form.pledge_frequency_interval.html}&nbsp;
132 {/if}
133 {$form.pledge_frequency_unit.html}<span id="pledge_installments_num">&nbsp;{ts}for{/ts}&nbsp;{$form.pledge_installments.html}&nbsp;{ts}installments.{/ts}</span>
134 </div>
135 <div class="clear"></div>
136 {if $start_date_editable}
137 {if $is_date}
138 <div class="label">{$form.start_date.label}</div><div class="content">{include file="CRM/common/jcalendar.tpl" elementName=start_date}</div>
139 {else}
140 <div class="label">{$form.start_date.label}</div><div class="content">{$form.start_date.html}</div>
141 {/if}
142 {else}
143 <div class="label">{$form.start_date.label}</div>
144 <div class="content">{$start_date_display|date_format}</div>
145 {/if}
146 <div class="clear"></div>
147 </div>
148 {/if}
149 {/if}
150 {/crmRegion}
151
152 {if $form.is_recur}
153 <div class="crm-public-form-item crm-section {$form.is_recur.name}-section">
154 <div class="label">&nbsp;</div>
155 <div class="content">
156 {$form.is_recur.html} {$form.is_recur.label} {ts}every{/ts}
157 {if $is_recur_interval}
158 {$form.frequency_interval.html}
159 {/if}
160 {if $one_frequency_unit}
161 {$frequency_unit}
162 {else}
163 {$form.frequency_unit.html}
164 {/if}
165 {if $is_recur_installments}
166 <span id="recur_installments_num">
167 {ts}for{/ts} {$form.installments.html} {$form.installments.label}
168 </span>
169 {/if}
170 <div id="recurHelp" class="description">
171 {$recurringHelpText}
172 </div>
173 </div>
174 <div class="clear"></div>
175 </div>
176 {/if}
177 {if $pcpSupporterText}
178 <div class="crm-public-form-item crm-section pcpSupporterText-section">
179 <div class="label">&nbsp;</div>
180 <div class="content">{$pcpSupporterText}</div>
181 <div class="clear"></div>
182 </div>
183 {/if}
184 {if $showMainEmail}
185 {assign var=n value=email-$bltID}
186 <div class="crm-public-form-item crm-section {$form.$n.name}-section">
187 <div class="label">{$form.$n.label}</div>
188 <div class="content">
189 {$form.$n.html}
190 </div>
191 <div class="clear"></div>
192 </div>
193 {/if}
194
195 <div id='onBehalfOfOrg' class="crm-public-form-item crm-section">
196 {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
197 </div>
198
199 {* User account registration option. Displays if enabled for one of the profiles on this page. *}
200 <div class="crm-public-form-item crm-section cms_user-section">
201 {include file="CRM/common/CMSUser.tpl"}
202 </div>
203 <div class="crm-public-form-item crm-section premium_block-section">
204 {include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl" context="makeContribution"}
205 </div>
206
207 {if $honoreeProfileFields|@count}
208 <fieldset class="crm-public-form-item crm-group honor_block-group">
209 {crmRegion name="contribution-soft-credit-block"}
210 <legend>{$honor_block_title}</legend>
211 <div class="crm-public-form-item crm-section honor_block_text-section">
212 {$honor_block_text}
213 </div>
214 {if $form.soft_credit_type_id.html}
215 <div class="crm-public-form-item crm-section {$form.soft_credit_type_id.name}-section">
216 <div class="content" >
217 {$form.soft_credit_type_id.html}
218 <div class="description">{ts}Select an option to reveal honoree information fields.{/ts}</div>
219 </div>
220 </div>
221 {/if}
222 {/crmRegion}
223 <div id="honorType" class="honoree-name-email-section">
224 {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
225 </div>
226 </fieldset>
227 {/if}
228
229 <div class="crm-public-form-item crm-group custom_pre_profile-group">
230 {include file="CRM/UF/Form/Block.tpl" fields=$customPre}
231 </div>
232
233 {if $isHonor}
234 <fieldset class="crm-public-form-item crm-group pcp-group">
235 <div class="crm-public-form-item crm-section pcp-section">
236 <div class="crm-public-form-item crm-section display_in_roll-section">
237 <div class="content">
238 {$form.pcp_display_in_roll.html} &nbsp;
239 {$form.pcp_display_in_roll.label}
240 </div>
241 <div class="clear"></div>
242 </div>
243 <div id="nameID" class="crm-public-form-item crm-section is_anonymous-section">
244 <div class="content">
245 {$form.pcp_is_anonymous.html}
246 </div>
247 <div class="clear"></div>
248 </div>
249 <div id="nickID" class="crm-public-form-item crm-section pcp_roll_nickname-section">
250 <div class="label">{$form.pcp_roll_nickname.label}</div>
251 <div class="content">{$form.pcp_roll_nickname.html}
252 <div class="description">{ts}Enter the name you want listed with this contribution. You can use a nick name like 'The Jones Family' or 'Sarah and Sam'.{/ts}</div>
253 </div>
254 <div class="clear"></div>
255 </div>
256 <div id="personalNoteID" class="crm-public-form-item crm-section pcp_personal_note-section">
257 <div class="label">{$form.pcp_personal_note.label}</div>
258 <div class="content">
259 {$form.pcp_personal_note.html}
260 <div class="description">{ts}Enter a message to accompany this contribution.{/ts}</div>
261 </div>
262 <div class="clear"></div>
263 </div>
264 </div>
265 </fieldset>
266 {/if}
267
268 {* end of ccid loop *}
269 {/if}
270
271 {if $form.payment_processor_id.label}
272 {* PP selection only works with JS enabled, so we hide it initially *}
273 <fieldset class="crm-public-form-item crm-group payment_options-group" style="display:none;">
274 <legend>{ts}Payment Options{/ts}</legend>
275 <div class="crm-public-form-item crm-section payment_processor-section">
276 <div class="label">{$form.payment_processor_id.label}</div>
277 <div class="content">{$form.payment_processor_id.html}</div>
278 <div class="clear"></div>
279 </div>
280 </fieldset>
281 {/if}
282
283 {if $is_pay_later}
284 <fieldset class="crm-public-form-item crm-group pay_later-group">
285 <legend>{ts}Payment Options{/ts}</legend>
286 <div class="crm-public-form-item crm-section pay_later_receipt-section">
287 <div class="label">&nbsp;</div>
288 <div class="content">
289 [x] {$pay_later_text}
290 </div>
291 <div class="clear"></div>
292 </div>
293 </fieldset>
294 {/if}
295
296 <div id="billing-payment-block">
297 {include file="CRM/Financial/Form/Payment.tpl" snippet=4}
298 </div>
299 {include file="CRM/common/paymentBlock.tpl"}
300
301 <div class="crm-public-form-item crm-group custom_post_profile-group">
302 {include file="CRM/UF/Form/Block.tpl" fields=$customPost}
303 </div>
304
305 {if $is_monetary and $form.bank_account_number}
306 <div id="payment_notice">
307 <fieldset class="crm-public-form-item crm-group payment_notice-group">
308 <legend>{ts}Agreement{/ts}</legend>
309 {ts}Your account data will be used to charge your bank account via direct debit. While submitting this form you agree to the charging of your bank account via direct debit.{/ts}
310 </fieldset>
311 </div>
312 {/if}
313
314 {if $isCaptcha}
315 {include file='CRM/common/ReCAPTCHA.tpl'}
316 {/if}
317 <div id="crm-submit-buttons" class="crm-submit-buttons">
318 {include file="CRM/common/formButtons.tpl" location="bottom"}
319 </div>
320 {if $footer_text}
321 <div id="footer_text" class="crm-public-form-item crm-section contribution_footer_text-section">
322 <p>{$footer_text}</p>
323 </div>
324 {/if}
325 </div>
326 <script type="text/javascript">
327 {if $isHonor}
328 pcpAnonymous();
329 {/if}
330
331 {literal}
332
333 cj('input[name="soft_credit_type_id"]').on('change', function() {
334 enableHonorType();
335 });
336
337 function enableHonorType( ) {
338 var selectedValue = cj('input[name="soft_credit_type_id"]:checked');
339 if ( selectedValue.val() > 0) {
340 cj('#honorType').show();
341 }
342 else {
343 cj('#honorType').hide();
344 }
345 }
346
347 cj('input[id="is_recur"]').on('change', function() {
348 toggleRecur();
349 });
350
351 function toggleRecur( ) {
352 var isRecur = cj('input[id="is_recur"]:checked');
353 var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
354 var quickConfig = {/literal}{$quickConfig}{literal};
355 if ( allowAutoRenew && cj("#auto_renew") && quickConfig) {
356 showHideAutoRenew( null );
357 }
358 if (isRecur.val() > 0) {
359 cj('#recurHelp').show();
360 cj('#amount_sum_label').text('{/literal}{ts escape='js'}Regular amount{/ts}{literal}');
361 }
362 else {
363 cj('#recurHelp').hide();
364 cj('#amount_sum_label').text('{/literal}{ts escape='js'}Total Amount{/ts}{literal}');
365 }
366 }
367
368 function pcpAnonymous( ) {
369 // clear nickname field if anonymous is true
370 if (document.getElementsByName("pcp_is_anonymous")[1].checked) {
371 document.getElementById('pcp_roll_nickname').value = '';
372 }
373 if (!document.getElementsByName("pcp_display_in_roll")[0].checked) {
374 cj('#nickID').hide();
375 cj('#nameID').hide();
376 cj('#personalNoteID').hide();
377 }
378 else {
379 if (document.getElementsByName("pcp_is_anonymous")[0].checked) {
380 cj('#nameID').show();
381 cj('#nickID').show();
382 cj('#personalNoteID').show();
383 }
384 else {
385 cj('#nameID').show();
386 cj('#nickID').hide();
387 cj('#personalNoteID').hide();
388 }
389 }
390 }
391
392 CRM.$(function($) {
393 enableHonorType();
394 toggleRecur();
395 skipPaymentMethod();
396 });
397
398 CRM.$(function($) {
399 // highlight price sets
400 function updatePriceSetHighlight() {
401 $('#priceset .price-set-row span').removeClass('highlight');
402 $('#priceset .price-set-row input:checked').parent().addClass('highlight');
403 }
404 $('#priceset input[type="radio"]').change(updatePriceSetHighlight);
405 updatePriceSetHighlight();
406
407 // Update pledge contribution amount when pledge checkboxes change
408 $("input[name^='pledge_amount']").on('change', function() {
409 var total = 0;
410 $("input[name^='pledge_amount']:checked").each(function() {
411 total += Number($(this).attr('amount'));
412 });
413 $("input[name^='price_']").val(total.toFixed(2));
414 });
415 });
416 {/literal}
417 </script>
418 {/if}
419
420 {* jQuery validate *}
421 {* disabled because more work needs to be done to conditionally require credit card fields *}
422 {*include file="CRM/Form/validate.tpl"*}