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