Merge pull request #2744 from pratik-joshi/CRM-13992_temp_fix
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / Main.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 {* Callback snippet: On-behalf profile *}
27 {if $snippet and !empty($isOnBehalfCallback)}
28 {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
29
30 {* Callback snippet: Load payment processor *}
31 {elseif $snippet}
32 {include file="CRM/Core/BillingBlock.tpl" context="front-end"}
33 {if $is_monetary}
34 {* Put PayPal Express button after customPost block since it's the submit button in this case. *}
35 {if $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}
36 <div id="paypalExpress">
37 {assign var=expressButtonName value='_qf_Main_upload_express'}
38 <fieldset class="crm-group paypal_checkout-group">
39 <legend>{ts}Checkout with PayPal{/ts}</legend>
40 <div class="section">
41 <div class="crm-section paypalButtonInfo-section">
42 <div class="content">
43 <span class="description">{ts}Click the PayPal button to continue.{/ts}</span>
44 </div>
45 <div class="clear"></div>
46 </div>
47 <div class="crm-section {$expressButtonName}-section">
48 <div class="content">
49 {$form.$expressButtonName.html} <span class="description">Checkout securely. Pay without sharing your financial information. </span>
50 </div>
51 <div class="clear"></div>
52 </div>
53 </div>
54 </fieldset>
55 </div>
56 {/if}
57 {/if}
58
59 {* Main Form *}
60 {else}
61 {literal}
62 <script type="text/javascript">
63
64 // Putting these functions directly in template so they are available for standalone forms
65 function useAmountOther() {
66 var priceset = {/literal}{if $contriPriceset}'{$contriPriceset}'{else}0{/if}{literal};
67
68 for( i=0; i < document.Main.elements.length; i++ ) {
69 element = document.Main.elements[i];
70 if ( element.type == 'radio' && element.name == priceset ) {
71 if (element.value == '0' ) {
72 element.click();
73 }
74 else {
75 element.checked = false;
76 }
77 }
78 }
79 }
80
81 function clearAmountOther() {
82 var priceset = {/literal}{if $priceset}'#{$priceset}'{else}0{/if}{literal}
83 if( priceset ){
84 cj(priceset).val('');
85 cj(priceset).blur();
86 }
87 if (document.Main.amount_other == null) return; // other_amt field not present; do nothing
88 document.Main.amount_other.value = "";
89 }
90
91 </script>
92 {/literal}
93
94 {if $action & 1024}
95 {include file="CRM/Contribute/Form/Contribution/PreviewHeader.tpl"}
96 {/if}
97
98 {include file="CRM/common/TrackingFields.tpl"}
99
100 {capture assign='reqMark'}<span class="marker" title="{ts}This field is required.{/ts}">*</span>{/capture}
101 <div class="crm-contribution-page-id-{$contributionPageID} crm-block crm-contribution-main-form-block">
102 <div id="intro_text" class="crm-section intro_text-section">
103 {$intro_text}
104 </div>
105 {include file="CRM/common/cidzero.tpl"}
106 {if $islifetime or $ispricelifetime }
107 <div id="help">{ts}You have a current Lifetime Membership which does not need to be renewed.{/ts}</div>
108 {/if}
109
110 {if !empty($useForMember)}
111 {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="makeContribution"}
112 {else}
113 <div id="priceset-div">
114 {include file="CRM/Price/Form/PriceSet.tpl" extends="Contribution"}
115 </div>
116 {/if}
117
118 {if $pledgeBlock}
119 {if $is_pledge_payment}
120 <div class="crm-section {$form.pledge_amount.name}-section">
121 <div class="label">{$form.pledge_amount.label}&nbsp;<span class="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-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 </div>
137 {/if}
138 {/if}
139
140 {if $form.is_recur}
141 <div class="crm-section {$form.is_recur.name}-section">
142 <div class="label">&nbsp;</div>
143 <div class="content">
144 {$form.is_recur.html} {$form.is_recur.label} {ts}every{/ts}
145 {if $is_recur_interval}
146 {$form.frequency_interval.html}
147 {/if}
148 {if $one_frequency_unit}
149 {$frequency_unit}
150 {else}
151 {$form.frequency_unit.html}
152 {/if}
153 {if $is_recur_installments}
154 {ts}for{/ts} {$form.installments.html} {$form.installments.label}
155 {/if}
156 </div>
157 <div class="clear"></div>
158 </div>
159 {/if}
160 {if $pcpSupporterText}
161 <div class="crm-section pcpSupporterText-section">
162 <div class="label">&nbsp;</div>
163 <div class="content">{$pcpSupporterText}</div>
164 <div class="clear"></div>
165 </div>
166 {/if}
167 {assign var=n value=email-$bltID}
168 <div class="crm-section {$form.$n.name}-section">
169 <div class="label">{$form.$n.label}</div>
170 <div class="content">
171 {$form.$n.html}
172 </div>
173 <div class="clear"></div>
174 </div>
175
176 {if $form.is_for_organization}
177 <div class="crm-section {$form.is_for_organization.name}-section">
178 <div class="label">&nbsp;</div>
179 <div class="content">
180 {$form.is_for_organization.html}&nbsp;{$form.is_for_organization.label}
181 </div>
182 <div class="clear"></div>
183 </div>
184 {/if}
185
186 {if $is_for_organization}
187 <div id='onBehalfOfOrg' class="crm-section">
188 {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
189 </div>
190 {/if}
191
192 {* User account registration option. Displays if enabled for one of the profiles on this page. *}
193 {include file="CRM/common/CMSUser.tpl"}
194 {include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl" context="makeContribution"}
195
196 {if $honor_block_is_active}
197 <fieldset class="crm-group honor_block-group">
198 {include file="CRM/Contribute/Form/SoftCredit.tpl"}
199 <div id="honorType" class="honoree-name-email-section">
200 {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
201 </div>
202 </fieldset>
203 {/if}
204
205 <div class="crm-group custom_pre_profile-group">
206 {include file="CRM/UF/Form/Block.tpl" fields=$customPre}
207 </div>
208
209 {if $isHonor}
210 <fieldset class="crm-group pcp-group">
211 <div class="crm-section pcp-section">
212 <div class="crm-section display_in_roll-section">
213 <div class="content">
214 {$form.pcp_display_in_roll.html} &nbsp;
215 {$form.pcp_display_in_roll.label}
216 </div>
217 <div class="clear"></div>
218 </div>
219 <div id="nameID" class="crm-section is_anonymous-section">
220 <div class="content">
221 {$form.pcp_is_anonymous.html}
222 </div>
223 <div class="clear"></div>
224 </div>
225 <div id="nickID" class="crm-section pcp_roll_nickname-section">
226 <div class="label">{$form.pcp_roll_nickname.label}</div>
227 <div class="content">{$form.pcp_roll_nickname.html}
228 <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>
229 </div>
230 <div class="clear"></div>
231 </div>
232 <div id="personalNoteID" class="crm-section pcp_personal_note-section">
233 <div class="label">{$form.pcp_personal_note.label}</div>
234 <div class="content">
235 {$form.pcp_personal_note.html}
236 <div class="description">{ts}Enter a message to accompany this contribution.{/ts}</div>
237 </div>
238 <div class="clear"></div>
239 </div>
240 </div>
241 </fieldset>
242 {/if}
243
244 {if $form.payment_processor.label}
245 {* PP selection only works with JS enabled, so we hide it initially *}
246 <fieldset class="crm-group payment_options-group" style="display:none;">
247 <legend>{ts}Payment Options{/ts}</legend>
248 <div class="crm-section payment_processor-section">
249 <div class="label">{$form.payment_processor.label}</div>
250 <div class="content">{$form.payment_processor.html}</div>
251 <div class="clear"></div>
252 </div>
253 </fieldset>
254 {/if}
255
256 {if $is_pay_later}
257 <fieldset class="crm-group pay_later-group">
258 <legend>{ts}Payment Options{/ts}</legend>
259 <div class="crm-section pay_later_receipt-section">
260 <div class="label">&nbsp;</div>
261 <div class="content">
262 [x] {$pay_later_text}
263 </div>
264 <div class="clear"></div>
265 </div>
266 </fieldset>
267 {/if}
268
269 <div id="billing-payment-block">
270 {* If we have a payment processor, load it - otherwise it happens via ajax *}
271 {if $ppType}
272 {include file="CRM/Contribute/Form/Contribution/Main.tpl" snippet=4}
273 {/if}
274 </div>
275 {include file="CRM/common/paymentBlock.tpl"}
276
277 <div class="crm-group custom_post_profile-group">
278 {include file="CRM/UF/Form/Block.tpl" fields=$customPost}
279 </div>
280
281 {if $is_monetary and $form.bank_account_number}
282 <div id="payment_notice">
283 <fieldset class="crm-group payment_notice-group">
284 <legend>{ts}Agreement{/ts}</legend>
285 {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}
286 </fieldset>
287 </div>
288 {/if}
289
290 {if $isCaptcha}
291 {include file='CRM/common/ReCAPTCHA.tpl'}
292 {/if}
293 <div id="crm-submit-buttons" class="crm-submit-buttons">
294 {include file="CRM/common/formButtons.tpl" location="bottom"}
295 </div>
296 {if $footer_text}
297 <div id="footer_text" class="crm-section contribution_footer_text-section">
298 <p>{$footer_text}</p>
299 </div>
300 {/if}
301 </div>
302
303 <script type="text/javascript">
304 {if $isHonor}
305 pcpAnonymous();
306 {/if}
307
308 {literal}
309 if ({/literal}"{$form.is_recur}"{literal}) {
310 if (document.getElementsByName("is_recur")[0].checked == true) {
311 window.onload = function() {
312 enablePeriod();
313 }
314 }
315 }
316
317 function enablePeriod ( ) {
318 var frqInt = {/literal}"{$form.frequency_interval}"{literal};
319 if ( document.getElementsByName("is_recur")[0].checked == true ) {
320 //get back to auto renew settings.
321 var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
322 if ( allowAutoRenew && cj("#auto_renew") ) {
323 showHideAutoRenew( null );
324 }
325 }
326 else {
327 //disabled auto renew settings.
328 var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
329 if ( allowAutoRenew && cj("#auto_renew") ) {
330 cj("#auto_renew").prop('checked', false );
331 cj('#allow_auto_renew').hide( );
332 }
333 }
334 }
335
336 {/literal}
337 {if $relatedOrganizationFound and $reset}
338 cj( "#is_for_organization" ).prop('checked', true );
339 showOnBehalf(false);
340 {elseif $onBehalfRequired}
341 showOnBehalf(true);
342 {/if}
343
344 {if $honor_block_is_active AND $form.soft_credit_type_id.html}
345 enableHonorType();
346 {/if}
347 {literal}
348
349 function enableHonorType( ) {
350 var element = document.getElementsByName("soft_credit_type_id");
351 for (var i = 0; i < element.length; i++ ) {
352 var isHonor = false;
353 if ( element[i].checked == true ) {
354 var isHonor = true;
355 break;
356 }
357 }
358 if ( isHonor ) {
359 cj('#honorType').show();
360 cj('#honorTypeEmail').show();
361 }
362 else {
363 cj('#honorType').hide();
364 cj('#honorTypeEmail').hide();
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 {/literal}
393 {if $form.is_pay_later and $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}
394 showHidePayPalExpressOption();
395 {/if}
396 {literal}
397
398 function toggleConfirmButton() {
399 var payPalExpressId = "{/literal}{$payPalExpressId}{literal}";
400 var elementObj = cj('input[name="payment_processor"]');
401 if ( elementObj.attr('type') == 'hidden' ) {
402 var processorTypeId = elementObj.val( );
403 }
404 else {
405 var processorTypeId = elementObj.filter(':checked').val();
406 }
407
408 if (payPalExpressId !=0 && payPalExpressId == processorTypeId) {
409 cj("#crm-submit-buttons").hide();
410 }
411 else {
412 cj("#crm-submit-buttons").show();
413 }
414 }
415
416 cj('input[name="payment_processor"]').change( function() {
417 toggleConfirmButton();
418 });
419
420 CRM.$(function($) {
421 toggleConfirmButton();
422 });
423
424 function showHidePayPalExpressOption() {
425 if (cj('input[name="is_pay_later"]').is(':checked')) {
426 cj("#crm-submit-buttons").show();
427 cj("#paypalExpress").hide();
428 }
429 else {
430 cj("#paypalExpress").show();
431 cj("#crm-submit-buttons").hide();
432 }
433 }
434
435 CRM.$(function($) {
436 // highlight price sets
437 function updatePriceSetHighlight() {
438 cj('#priceset .price-set-row').removeClass('highlight');
439 cj('#priceset .price-set-row input:checked').parent().parent().addClass('highlight');
440 }
441 cj('#priceset input[type="radio"]').change(updatePriceSetHighlight);
442 updatePriceSetHighlight();
443 });
444 {/literal}
445 </script>
446 {/if}
447
448 {* jQuery validate *}
449 {* disabled because more work needs to be done to conditionally require credit card fields *}
450 {*include file="CRM/Form/validate.tpl"*}