Optimization
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / Main.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
2c4c49ca 3 | CiviCRM version 4.7 |
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*}
ab234a8a
CW
26{* Callback snippet: On-behalf profile *}
27{if $snippet and !empty($isOnBehalfCallback)}
e63910c5 28 {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
d26729c4 29
6a488035
TO
30{else}
31 {literal}
32 <script type="text/javascript">
33
34 // Putting these functions directly in template so they are available for standalone forms
35 function useAmountOther() {
36 var priceset = {/literal}{if $contriPriceset}'{$contriPriceset}'{else}0{/if}{literal};
37
38 for( i=0; i < document.Main.elements.length; i++ ) {
39 element = document.Main.elements[i];
40 if ( element.type == 'radio' && element.name == priceset ) {
41 if (element.value == '0' ) {
42 element.click();
43 }
44 else {
45 element.checked = false;
46 }
47 }
48 }
49 }
50
51 function clearAmountOther() {
52 var priceset = {/literal}{if $priceset}'#{$priceset}'{else}0{/if}{literal}
53 if( priceset ){
54 cj(priceset).val('');
55 cj(priceset).blur();
56 }
57 if (document.Main.amount_other == null) return; // other_amt field not present; do nothing
58 document.Main.amount_other.value = "";
59 }
60
61 </script>
62 {/literal}
63
64 {if $action & 1024}
65 {include file="CRM/Contribute/Form/Contribution/PreviewHeader.tpl"}
66 {/if}
67
68 {include file="CRM/common/TrackingFields.tpl"}
69
696a8ad6 70 <div class="crm-contribution-page-id-{$contributionPageID} crm-block crm-contribution-main-form-block">
37326fa1
DG
71
72 {if $contact_id}
73 <div class="messages status no-popup crm-not-you-message">
74 {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>?)
75 </div>
76 {/if}
77
6a488035
TO
78 <div id="intro_text" class="crm-section intro_text-section">
79 {$intro_text}
80 </div>
596bff78 81 {include file="CRM/common/cidzero.tpl"}
6a488035
TO
82 {if $islifetime or $ispricelifetime }
83 <div id="help">{ts}You have a current Lifetime Membership which does not need to be renewed.{/ts}</div>
84 {/if}
85
86 {if !empty($useForMember)}
87 {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="makeContribution"}
88 {else}
89 <div id="priceset-div">
90 {include file="CRM/Price/Form/PriceSet.tpl" extends="Contribution"}
91 </div>
92 {/if}
93
94 {if $pledgeBlock}
95 {if $is_pledge_payment}
96 <div class="crm-section {$form.pledge_amount.name}-section">
836cf509 97 <div class="label">{$form.pledge_amount.label}&nbsp;<span class="crm-marker">*</span></div>
6a488035
TO
98 <div class="content">{$form.pledge_amount.html}</div>
99 <div class="clear"></div>
100 </div>
101 {else}
102 <div class="crm-section {$form.is_pledge.name}-section">
103 <div class="label">&nbsp;</div>
104 <div class="content">
105 {$form.is_pledge.html}&nbsp;
106 {if $is_pledge_interval}
107 {$form.pledge_frequency_interval.html}&nbsp;
108 {/if}
109 {$form.pledge_frequency_unit.html}<span id="pledge_installments_num">&nbsp;{ts}for{/ts}&nbsp;{$form.pledge_installments.html}&nbsp;{ts}installments.{/ts}</span>
110 </div>
111 <div class="clear"></div>
112 </div>
113 {/if}
114 {/if}
115
116 {if $form.is_recur}
117 <div class="crm-section {$form.is_recur.name}-section">
118 <div class="label">&nbsp;</div>
119 <div class="content">
120 {$form.is_recur.html} {$form.is_recur.label} {ts}every{/ts}
121 {if $is_recur_interval}
122 {$form.frequency_interval.html}
123 {/if}
124 {if $one_frequency_unit}
125 {$frequency_unit}
126 {else}
127 {$form.frequency_unit.html}
128 {/if}
129 {if $is_recur_installments}
33627071 130 <span id="recur_installments_num">
6a488035 131 {ts}for{/ts} {$form.installments.html} {$form.installments.label}
33627071 132 </span>
6a488035 133 {/if}
33627071 134 <div id="recurHelp" class="description">
7f7fa13a
EM
135 {ts}Your recurring contribution will be processed automatically.{/ts}
136 {if $is_recur_installments}
137 {ts}You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.{/ts}
138 {/if}
33627071
DG
139 {if $is_email_receipt}
140 {ts}You will receive an email receipt for each recurring contribution.{/ts}
141 {/if}
142 </div>
6a488035
TO
143 </div>
144 <div class="clear"></div>
145 </div>
146 {/if}
147 {if $pcpSupporterText}
148 <div class="crm-section pcpSupporterText-section">
149 <div class="label">&nbsp;</div>
150 <div class="content">{$pcpSupporterText}</div>
151 <div class="clear"></div>
152 </div>
153 {/if}
154 {assign var=n value=email-$bltID}
155 <div class="crm-section {$form.$n.name}-section">
156 <div class="label">{$form.$n.label}</div>
157 <div class="content">
158 {$form.$n.html}
159 </div>
160 <div class="clear"></div>
161 </div>
162
cb804cd9 163 {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
6a488035
TO
164
165 {* User account registration option. Displays if enabled for one of the profiles on this page. *}
166 {include file="CRM/common/CMSUser.tpl"}
167 {include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl" context="makeContribution"}
168
4779abb3 169 {if $honoreeProfileFields|@count}
cb804cd9 170 <fieldset class="crm-group honor_block-group">
171 {crmRegion name="contribution-soft-credit-block"}
172 <legend>{$honor_block_title}</legend>
173 <div class="crm-section honor_block_text-section">
174 {$honor_block_text}
175 </div>
176 {if $form.soft_credit_type_id.html}
177 <div class="crm-section {$form.soft_credit_type_id.name}-section">
178 <div class="content" >
179 {$form.soft_credit_type_id.html}
180 <div class="description">{ts}Select an option to reveal honoree information fields.{/ts}</div>
181 </div>
182 </div>
183 {/if}
184 {/crmRegion}
185 <div id="honorType" class="honoree-name-email-section">
186 {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
187 </div>
188 </fieldset>
6a488035
TO
189 {/if}
190
191 <div class="crm-group custom_pre_profile-group">
192 {include file="CRM/UF/Form/Block.tpl" fields=$customPre}
193 </div>
194
4d327c2d 195 {if $isHonor}
6a488035
TO
196 <fieldset class="crm-group pcp-group">
197 <div class="crm-section pcp-section">
198 <div class="crm-section display_in_roll-section">
199 <div class="content">
200 {$form.pcp_display_in_roll.html} &nbsp;
201 {$form.pcp_display_in_roll.label}
202 </div>
203 <div class="clear"></div>
204 </div>
205 <div id="nameID" class="crm-section is_anonymous-section">
206 <div class="content">
207 {$form.pcp_is_anonymous.html}
208 </div>
209 <div class="clear"></div>
210 </div>
211 <div id="nickID" class="crm-section pcp_roll_nickname-section">
212 <div class="label">{$form.pcp_roll_nickname.label}</div>
213 <div class="content">{$form.pcp_roll_nickname.html}
214 <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>
215 </div>
216 <div class="clear"></div>
217 </div>
218 <div id="personalNoteID" class="crm-section pcp_personal_note-section">
219 <div class="label">{$form.pcp_personal_note.label}</div>
220 <div class="content">
221 {$form.pcp_personal_note.html}
222 <div class="description">{ts}Enter a message to accompany this contribution.{/ts}</div>
223 </div>
224 <div class="clear"></div>
225 </div>
226 </div>
227 </fieldset>
228 {/if}
229
e02d7e96 230 {if $form.payment_processor_id.label}
6e56bbfc
CW
231 {* PP selection only works with JS enabled, so we hide it initially *}
232 <fieldset class="crm-group payment_options-group" style="display:none;">
6a488035
TO
233 <legend>{ts}Payment Options{/ts}</legend>
234 <div class="crm-section payment_processor-section">
e02d7e96
EM
235 <div class="label">{$form.payment_processor_id.label}</div>
236 <div class="content">{$form.payment_processor_id.html}</div>
6a488035
TO
237 <div class="clear"></div>
238 </div>
239 </fieldset>
240 {/if}
241
242 {if $is_pay_later}
243 <fieldset class="crm-group pay_later-group">
244 <legend>{ts}Payment Options{/ts}</legend>
245 <div class="crm-section pay_later_receipt-section">
246 <div class="label">&nbsp;</div>
247 <div class="content">
248 [x] {$pay_later_text}
249 </div>
250 <div class="clear"></div>
251 </div>
252 </fieldset>
253 {/if}
254
7c8cc461
CW
255 <div id="billing-payment-block">
256 {* If we have a payment processor, load it - otherwise it happens via ajax *}
e50ee6a3 257 {if $paymentProcessorID or $isBillingAddressRequiredForPayLater}
e02d7e96 258 {include file="CRM/Financial/Form/Payment.tpl" snippet=4}
7c8cc461
CW
259 {/if}
260 </div>
6a488035
TO
261 {include file="CRM/common/paymentBlock.tpl"}
262
263 <div class="crm-group custom_post_profile-group">
264 {include file="CRM/UF/Form/Block.tpl" fields=$customPost}
265 </div>
266
267 {if $is_monetary and $form.bank_account_number}
268 <div id="payment_notice">
269 <fieldset class="crm-group payment_notice-group">
270 <legend>{ts}Agreement{/ts}</legend>
271 {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}
272 </fieldset>
273 </div>
274 {/if}
275
276 {if $isCaptcha}
71fc6ea4 277 {include file='CRM/common/ReCAPTCHA.tpl'}
6a488035
TO
278 {/if}
279 <div id="crm-submit-buttons" class="crm-submit-buttons">
280 {include file="CRM/common/formButtons.tpl" location="bottom"}
281 </div>
282 {if $footer_text}
283 <div id="footer_text" class="crm-section contribution_footer_text-section">
284 <p>{$footer_text}</p>
285 </div>
286 {/if}
6a488035
TO
287</div>
288
6a488035 289<script type="text/javascript">
4d327c2d 290 {if $isHonor}
6a488035
TO
291 pcpAnonymous();
292 {/if}
293
294 {literal}
295 if ({/literal}"{$form.is_recur}"{literal}) {
296 if (document.getElementsByName("is_recur")[0].checked == true) {
297 window.onload = function() {
298 enablePeriod();
299 }
300 }
301 }
302
303 function enablePeriod ( ) {
304 var frqInt = {/literal}"{$form.frequency_interval}"{literal};
305 if ( document.getElementsByName("is_recur")[0].checked == true ) {
306 //get back to auto renew settings.
307 var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
308 if ( allowAutoRenew && cj("#auto_renew") ) {
309 showHideAutoRenew( null );
310 }
311 }
312 else {
313 //disabled auto renew settings.
314 var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
315 if ( allowAutoRenew && cj("#auto_renew") ) {
8539f25d 316 cj("#auto_renew").prop('checked', false );
6a488035
TO
317 cj('#allow_auto_renew').hide( );
318 }
319 }
320 }
321
7f7fa13a
EM
322 cj('input[name="soft_credit_type_id"]').on('change', function() {
323 enableHonorType();
324 });
92ec1d7f 325
6a488035 326 function enableHonorType( ) {
92ec1d7f 327 var selectedValue = cj('input[name="soft_credit_type_id"]:checked');
458a8395 328 if ( selectedValue.val() > 0) {
6a488035 329 cj('#honorType').show();
6a488035
TO
330 }
331 else {
6a488035 332 cj('#honorType').hide();
6a488035
TO
333 }
334 }
335
7f7fa13a
EM
336 cj('input[id="is_recur"]').on('change', function() {
337 showRecurHelp();
338 });
33627071
DG
339
340 function showRecurHelp( ) {
92ec1d7f 341 var showHelp = cj('input[id="is_recur"]:checked');
33627071
DG
342 if ( showHelp.val() > 0) {
343 cj('#recurHelp').show();
344 }
345 else {
346 cj('#recurHelp').hide();
347 }
348 }
92ec1d7f 349
6a488035
TO
350 function pcpAnonymous( ) {
351 // clear nickname field if anonymous is true
352 if (document.getElementsByName("pcp_is_anonymous")[1].checked) {
353 document.getElementById('pcp_roll_nickname').value = '';
354 }
355 if (!document.getElementsByName("pcp_display_in_roll")[0].checked) {
356 cj('#nickID').hide();
357 cj('#nameID').hide();
358 cj('#personalNoteID').hide();
359 }
360 else {
361 if (document.getElementsByName("pcp_is_anonymous")[0].checked) {
362 cj('#nameID').show();
363 cj('#nickID').show();
364 cj('#personalNoteID').show();
365 }
366 else {
367 cj('#nameID').show();
368 cj('#nickID').hide();
369 cj('#personalNoteID').hide();
370 }
371 }
372 }
373
374 {/literal}
375 {if $form.is_pay_later and $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}
376 showHidePayPalExpressOption();
377 {/if}
378 {literal}
379
3cc60a06 380 CRM.$(function($) {
7f7fa13a
EM
381 enableHonorType();
382 showRecurHelp();
7c859cc3 383 skipPaymentMethod();
6a488035
TO
384 });
385
386 function showHidePayPalExpressOption() {
387 if (cj('input[name="is_pay_later"]').is(':checked')) {
388 cj("#crm-submit-buttons").show();
389 cj("#paypalExpress").hide();
390 }
391 else {
392 cj("#paypalExpress").show();
393 cj("#crm-submit-buttons").hide();
394 }
395 }
396
7c859cc3
K
397 function showHidePayment(flag) {
398 var payment_options = cj(".payment_options-group");
399 var payment_processor = cj("div.payment_processor-section");
400 var payment_information = cj("div#payment_information");
401 if (flag) {
402 payment_options.hide();
403 payment_processor.hide();
404 payment_information.hide();
7c859cc3
K
405 }
406 else {
407 payment_options.show();
408 payment_processor.show();
409 payment_information.show();
410 }
411 }
e02d7e96 412
7c859cc3
K
413 function skipPaymentMethod() {
414 var flag = false;
06165b2f 415 cj('.price-set-option-content input[data-amount]').each( function(){
7c859cc3
K
416 currentTotal = cj(this).attr('data-amount').replace(/[^\/\d]/g,'');
417 if( cj(this).is(':checked') && currentTotal == 0 ) {
418 flag = true;
419 }
420 });
f85b8063 421
06165b2f 422 cj('.price-set-option-content input[data-amount]').change( function () {
7c859cc3
K
423 if (cj(this).attr('data-amount').replace(/[^\/\d]/g,'') == 0 ) {
424 flag = true;
425 } else {
426 flag = false;
427 }
428 showHidePayment(flag);
429 });
430 showHidePayment(flag);
431 }
432
3cc60a06 433 CRM.$(function($) {
6a488035
TO
434 // highlight price sets
435 function updatePriceSetHighlight() {
bc782741
CB
436 cj('#priceset .price-set-row span').removeClass('highlight');
437 cj('#priceset .price-set-row input:checked').parent().addClass('highlight');
6a488035
TO
438 }
439 cj('#priceset input[type="radio"]').change(updatePriceSetHighlight);
440 updatePriceSetHighlight();
e6ac320a
DG
441
442 function toggleBillingBlockIfFree(){
92ec1d7f 443 var total_amount_tmp = $(this).data('raw-total');
b451ca6c 444 // Hide billing questions if this is free
50296290 445 if (total_amount_tmp == 0){
2fa79ba1 446 cj("#billing-payment-block").hide();
92ec1d7f
EM
447 cj(".payment_options-group").hide();
448 }
b451ca6c 449 else {
2fa79ba1 450 cj("#billing-payment-block").show();
92ec1d7f 451 cj(".payment_options-group").show();
50296290
DG
452 }
453 }
454
0b2b2583 455 $('#pricevalue').each(toggleBillingBlockIfFree).on('change', toggleBillingBlockIfFree);
6a488035
TO
456 });
457 {/literal}
458</script>
459{/if}
460
461{* jQuery validate *}
462{* disabled because more work needs to be done to conditionally require credit card fields *}
463{*include file="CRM/Form/validate.tpl"*}