ccc742dad4a3868372ec5e6807647e5e9e9ba578
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
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 {* this template is used for adding/editing/deleting contributions and pledge payments *}
27
28 {if $priceSetId}
29 {include file="CRM/Price/Form/PriceSet.tpl" context="standalone" extends="Contribution"}
30 {elseif $showAdditionalInfo and $formType }
31 {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
32 {else}
33 {include file="CRM/Contribute/Form/AdditionalInfo/Payment.tpl"}
34 {if $contributionMode}
35 <div class="help">
36 {if $contactId && $payNow}
37 {ts 1=$displayName 2=$contributionMode|upper}Use this form to edit a contribution on behalf of %1. <strong>A
38 %2 transaction will be submitted</strong> using the selected payment processor.{/ts}
39 {elseif $contactId}
40 {ts 1=$displayName 2=$contributionMode|upper}Use this form to submit a new contribution on behalf of %1. <strong>A
41 %2 transaction will be submitted</strong> using the selected payment processor.{/ts}
42 {else}
43 {ts 1=$displayName 2=$contributionMode|upper}Use this form to submit a new contribution. <strong>A %2 transaction will be submitted</strong> using the selected payment processor.{/ts}
44 {/if}
45 </div>
46 {/if}
47
48 <div class="crm-block crm-form-block crm-contribution-form-block">
49
50 {if !$email and $action neq 8 and $context neq 'standalone'}
51 <div class="messages status no-popup">
52 <div class="icon inform-icon"></div>&nbsp;{ts}You will not be able to send an automatic email receipt for this contribution because there is no email address recorded for this contact. If you want a receipt to be sent when this contribution is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the contribution.{/ts}
53 </div>
54 {/if}
55
56 {if $action eq 8}
57 <div class="messages status no-popup">
58 <div class="icon inform-icon"></div>
59 {ts}WARNING: Deleting this contribution will result in the loss of the associated financial transactions (if any).{/ts} {ts}Do you want to continue?{/ts}
60 </div>
61 {else}
62 {if $newCredit AND $action EQ 1 AND $contributionMode EQ null}
63 <div class="action-link css_right crm-link-credit-card-mode">
64 {if $contactId}
65 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=add&cid=`$contactId`&context=`$context`&mode=live"}{/capture}
66 {else}
67 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=add&context=standalone&mode=live"}{/capture}
68 {/if}
69 <a class="open-inline-noreturn action-item crm-hover-button" href="{$ccModeLink}">&raquo; {ts}submit credit card contribution{/ts}</a>
70 </div>
71 {/if}
72 <div class="crm-submit-buttons">
73 {include file="CRM/common/formButtons.tpl"}
74 </div>
75 {if $isOnline}{assign var=valueStyle value=" class='view-value'"}{else}{assign var=valueStyle value=""}{/if}
76 <table class="form-layout-compressed">
77 {if $context neq 'standalone'}
78 <tr>
79 <td class="font-size12pt label"><strong><strong>{ts}Contributor{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
80 </tr>
81 {else}
82 <td class="label">{$form.contact_id.label}</td>
83 <td>{$form.contact_id.html}</td>
84 {/if}
85 <tr class="crm-contribution-form-block-contribution_type_id crm-contribution-form-block-financial_type_id">
86 <td class="label">{$form.financial_type_id.label}</td><td{$valueStyle}>{$form.financial_type_id.html}&nbsp;
87 {if $is_test}
88 {ts}(test){/ts}
89 {/if} {help id="id-financial_type"}
90 </td>
91 </tr>
92 {if $action eq 2 and $lineItem and !$defaultContribution}
93 <tr>
94 <td class="label">{ts}Contribution Amount{/ts}</td>
95 <td>{include file="CRM/Price/Page/LineItem.tpl" context="Contribution"}</td>
96 </tr>
97 {else}
98 <tr class="crm-contribution-form-block-total_amount">
99 <td class="label">{$form.total_amount.label}</td>
100 <td {$valueStyle}>
101 <span id='totalAmount'>{$form.currency.html|crmAddClass:eight}&nbsp;{$form.total_amount.html|crmAddClass:eight}</span>
102 {if !$payNow}
103 {if $hasPriceSets}
104 <span id='totalAmountORPriceSet'> {ts}OR{/ts}</span>
105 <span id='selectPriceSet'>{$form.price_set_id.html}</span>
106 <div id="priceset" class="hiddenElement"></div>
107 {/if}
108
109 {if $ppID}{ts}<a class='action-item crm-hover-button' onclick='adjustPayment();'>adjust payment amount</a>{/ts}{help id="adjust-payment-amount"}{/if}
110 <div id="totalAmountBlock">
111 {if $hasPriceSets}<span class="description">{ts}Alternatively, you can use a price set.{/ts}</span>{/if}
112 <div id="totalTaxAmount" class="label"></div>
113 </div>
114 {/if}
115 </td>
116 </tr>
117
118 {if $buildRecurBlock && !$payNow}
119 <tr id='recurringPaymentBlock' class='hiddenElement'>
120 <td></td>
121 <td>
122 <strong>{$form.is_recur.html} {ts}every{/ts}
123 &nbsp;{$form.frequency_interval.html}
124 &nbsp;{$form.frequency_unit.html}&nbsp;
125 {ts}for{/ts}
126 &nbsp;{$form.installments.html}
127 &nbsp;{$form.installments.label}
128 </strong>
129 <br />
130 <span class="description">
131 {ts}Your recurring contribution will be processed automatically for the number of installments you specify. 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. You will receive an email receipt for each recurring contribution. The receipts will include a link you can use if you decide to modify or cancel your future contributions.{/ts}
132 </span>
133 </td>
134 </tr>
135 {/if}
136
137 <tr id="adjust-option-type" class="crm-contribution-form-block-option_type">
138 <td class="label"></td><td {$valueStyle}>{$form.option_type.html}</td>
139 </tr>
140 {/if}
141 {if $contributionMode && $processorSupportsFutureStartDate}
142 <tr id='start_date' class="crm-contribution-form-block-receive_date">
143 <td class="label">{ts}Start Date{/ts}</td>
144 <td {$valueStyle}>{if $hideCalender neq true}{$form.receive_date.html}{/if}<br />
145 <span class="description">{ts}You can set a start date for recurring contributions and the first payment will be on that date. For a single post-dated contribution you must select recurring and choose one installment{/ts}</span>
146 </td>
147 </tr>
148 {/if}
149
150 <tr class="crm-contribution-form-block-source">
151 <td class="label">{$form.source.label}</td>
152 <td {$valueStyle}>{$form.source.html|crmAddClass:huge} {help id="id-contrib_source"}
153 </td>
154 </tr>
155
156 {* CRM-7362 --add campaign to contributions *}
157 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-contribution-form-block-campaign_id"}
158
159 {if !$contributionMode || $payNow}
160 <tr class="crm-contribution-form-block-contribution_status_id">
161 <td class="label">{$form.contribution_status_id.label}</td>
162 <td>{$form.contribution_status_id.html}
163 {if $contribution_status_id eq 2}{if $is_pay_later }: {ts}Pay Later{/ts} {else}: {ts}Incomplete Transaction{/ts}{/if}{/if}
164 </td>
165 <td>
166 {if $contactId && $contribID && $contributionMode EQ null && $contribution_status_id eq 2}
167 {capture assign=payNowLink}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=update&id=`$contribID`&cid=`$contactId`&context=`$context`&mode=live"}{/capture}
168 <a class="open-inline action-item crm-hover-button" href="{$payNowLink}">&raquo; {ts}Pay with Credit Card{/ts}</a>
169 {/if}
170 </td>
171 </tr>
172 {/if}
173
174 {if !$contributionMode}
175 {* Cancellation / Refunded fields are hidden unless contribution status is set to Cancelled or Refunded*}
176 <tr id="cancelInfo" class="crm-contribution-form-block-cancelInfo">
177 <td>&nbsp;</td>
178 <td><fieldset><legend>{ts}Cancellation or Refund Information{/ts}</legend>
179 <table class="form-layout-compressed">
180 <tr id="cancelDate" class="crm-contribution-form-block-cancel_date">
181 <td class="label">{$form.cancel_date.label}</td>
182 <td>
183 {if $hideCalendar neq true}
184 {$form.cancel_date.html}
185 {else}
186 {$form.cancel_date.value|crmDate}
187 {/if}
188 </td>
189 </tr>
190 <tr id="cancelDescription" class="crm-contribution-form-block-cancel_reason">
191 <td class="label">&nbsp;</td>
192 <td class="description">{ts}Enter the cancellation or refunded date, or you can skip this field and the cancellation date or refunded date will be automatically set to TODAY.{/ts}</td>
193 </tr>
194 <tr id="cancelReason">
195 <td class="label" style="vertical-align: top;">{$form.cancel_reason.label}</td>
196 <td>{$form.cancel_reason.html}</td>
197 </tr>
198 <tr id="refundTrxnID">
199 <td class="label" style="vertical-align: top;">{$form.refund_trxn_id.label}</td>
200 <td>{$form.refund_trxn_id.html}</td>
201 </tr>
202 </table>
203 </fieldset>
204 </td>
205 </tr>
206 <tr class="crm-contribution-form-block-receive_date">
207 <td class="label">{$form.receive_date.label}</td>
208 <td>{$form.receive_date.html}<br />
209 <span class="description">{ts}The date this contribution was received.{/ts}</span>
210 </td>
211 </tr>
212 {/if}
213 {if $form.revenue_recognition_date && !$payNow}
214 <tr class="crm-contribution-form-block-revenue_recognition_date">
215 <td class="label">{$form.revenue_recognition_date.label}</td>
216 <td>{$form.revenue_recognition_date.html}</td>
217 </tr>
218 {/if}
219
220 {if $email and $outBound_option != 2}
221 <tr class="crm-contribution-form-block-is_email_receipt">
222 <td class="label">{$form.is_email_receipt.label}</td>
223 <td>{$form.is_email_receipt.html}&nbsp;
224 <span class="description">{ts 1=$email}Automatically email a receipt for this payment to %1?{/ts}</span>
225 </td>
226 </tr>
227 {elseif $context eq 'standalone' and $outBound_option != 2 }
228 <tr id="email-receipt" style="display:none;" class="crm-contribution-form-block-is_email_receipt">
229 <td class="label">{$form.is_email_receipt.label}</td>
230 <td>{$form.is_email_receipt.html} <span class="description">{ts}Automatically email a receipt for this payment to {/ts}<span id="email-address"></span>?</span>
231 </td>
232 </tr>
233 {/if}
234 <tr id="fromEmail" class="crm-contribution-form-block-receipt_date" style="display:none;">
235 <td class="label">{$form.from_email_address.label}</td>
236 <td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin}</td>
237 </tr>
238 <tr id="receiptDate" class="crm-contribution-form-block-receipt_date">
239 <td class="label">{$form.receipt_date.label}</td>
240 <td>{$form.receipt_date.html}<br />
241 <span class="description">{ts}Date that a receipt was sent to the contributor.{/ts}</span>
242 </td>
243 </tr>
244 {if $form.payment_processor_id}
245 <tr class="crm-contribution-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="crm-marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
246 {/if}
247 </table>
248
249 {if !$contributionMode}
250 <fieldset class="payment-details_group">
251 <legend>
252 {ts}Payment Details{/ts}
253 </legend>
254 <table class="form-layout-compressed" >
255 <tr class="crm-contribution-form-block-payment_instrument_id">
256 <td class="label">{$form.payment_instrument_id.label}</td>
257 <td {$valueStyle}>{$form.payment_instrument_id.html} {help id="payment_instrument_id"}</td>
258 </td>
259 </tr>
260 <tr class="crm-contribution-form-block-trxn_id">
261 <td class="label">{$form.trxn_id.label}</td>
262 <td {$valueStyle}>{$form.trxn_id.html} {help id="id-trans_id"}</td>
263 </tr>
264 </table>
265 </fieldset>
266 {/if}
267
268 {include file='CRM/Core/BillingBlockWrapper.tpl'}
269
270 <!-- start of soft credit -->
271 {if !$payNow}
272 <div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed {if $noSoftCredit}collapsed{/if}" id="softCredit">
273 <div class="crm-accordion-header">
274 {ts}Soft Credit{/ts}&nbsp;{help id="id-soft_credit"}
275 </div>
276 <div class="crm-accordion-body">
277 <table class="form-layout-compressed">
278 <tr class="crm-contribution-form-block-soft_credit_to">
279 <td colspan="2">
280 {include file="CRM/Contribute/Form/SoftCredit.tpl"}
281 </td>
282 </tr>
283 </table>
284 </div>
285 </div>
286 {/if}
287 <!-- end of soft credit -->
288
289 <!-- start of PCP -->
290 {if $siteHasPCPs && !$payNow}
291 <div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed {if $noPCP}collapsed{/if}" id="softCredit">
292 <div class="crm-accordion-header">
293 {ts}Personal Campaign Page{/ts}&nbsp;{help id="id-pcp"}
294 </div>
295 <div class="crm-accordion-body">
296 <table class="form-layout-compressed">
297 <tr class="crm-contribution-pcp-block crm-contribution-form-block-pcp_made_through_id">
298 <td class="label">{$form.pcp_made_through_id.label}</td>
299 <td>
300 {$form.pcp_made_through_id.html} &nbsp;
301 <div class="description">{ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts}</div>
302
303 <div class="spacer"></div>
304 <div class="crm-contribution-form-block-pcp_details">
305 <table class="crm-contribution-form-table-credit_to_pcp">
306 <tr id="pcpDisplayRollID" class="crm-contribution-form-block-pcp_display_in_roll">
307 <td class="label">{$form.pcp_display_in_roll.label}</td>
308 <td>{$form.pcp_display_in_roll.html}</td>
309 </tr>
310 <tr id="nickID" class="crm-contribution-form-block-pcp_roll_nickname">
311 <td class="label">{$form.pcp_roll_nickname.label}</td>
312 <td>{$form.pcp_roll_nickname.html|crmAddClass:big}<br/>
313 <div class="description">{ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts}</div>
314 </td>
315 </tr>
316 <tr id="personalNoteID" class="crm-contribution-form-block-pcp_personal_note">
317 <td class="label" style="vertical-align: top">{$form.pcp_personal_note.label}</td>
318 <td>
319 {$form.pcp_personal_note.html}
320 <div
321 class="description">{ts}Personal message submitted by contributor for display in the Honor Roll.{/ts}</div>
322 </td>
323 </tr>
324 </table>
325 </div>
326 </td>
327 </tr>
328 </table>
329 </div>
330 </div>
331 {include file="CRM/Contribute/Form/PCP.js.tpl"}
332 {/if}
333 <!-- end of PCP -->
334
335 {if !$payNow}
336 <div id="customData" class="crm-contribution-form-block-customData"></div>
337 {/if}
338
339 {*include custom data js file*}
340 {include file="CRM/common/customData.tpl"}
341
342 {literal}
343 <script type="text/javascript">
344 CRM.$(function($) {
345 {/literal}
346 CRM.buildCustomData( '{$customDataType}' );
347 {if $customDataSubType}
348 CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
349 {/if}
350
351 {if $buildPriceSet}{literal}buildAmount( );{/literal}{/if}
352 {literal}
353 });
354
355 // bind first click of accordion header to load crm-accordion-body with snippet
356 // everything else taken care of by cj().crm-accordions()
357 CRM.$(function($) {
358 cj('#adjust-option-type').hide();
359 cj('.crm-ajax-accordion .crm-accordion-header').one('click', function() {
360 loadPanes(cj(this).attr('id'));
361 });
362 cj('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) {
363 loadPanes(cj(this).attr('id'));
364 });
365 });
366 // load panes function calls for snippet based on id of crm-accordion-header
367 function loadPanes( id ) {
368 var url = "{/literal}{crmURL p='civicrm/contact/view/contribution' q='snippet=4&formType=' h=0}{literal}" + id;
369 {/literal}
370 {if $contributionMode}
371 url = url + "&mode={$contributionMode}";
372 {/if}
373 {if $qfKey}
374 url = url + "&qfKey={$qfKey}";
375 {/if}
376 {literal}
377 if (! cj('div.'+id).html()) {
378 var loading = '<img src="{/literal}{$config->resourceBase}i/loading.gif{literal}" alt="{/literal}{ts escape='js'}loading{/ts}{literal}" />&nbsp;{/literal}{ts escape='js'}Loading{/ts}{literal}...';
379 cj('div.'+id).html(loading);
380 cj.ajax({
381 url : url,
382 success: function(data) { cj('div.'+id).html(data).trigger('crmLoad'); }
383 });
384 }
385 }
386
387 var url = "{/literal}{$dataUrl}{literal}";
388
389 {/literal}
390 {if $context eq 'standalone' and $outBound_option != 2 }
391 {literal}
392 CRM.$(function($) {
393
394 var $form = $("form.{/literal}{$form.formClass}{literal}");
395 $("#contact_id", $form).change(checkEmail);
396 checkEmail( );
397
398 function checkEmail( ) {
399 var data = $("#contact_id", $form).select2('data');
400 if (data && data.extra && data.extra.email && data.extra.email.length) {
401 $("#email-receipt", $form).show();
402 $("#email-address", $form).html(data.extra.email);
403 }
404 else {
405 $("#email-receipt", $form).hide();
406 }
407 }
408
409 showHideByValue( 'is_email_receipt', '', 'receiptDate', 'table-row', 'radio', true);
410 showHideByValue( 'is_email_receipt', '', 'fromEmail', 'table-row', 'radio', false );
411 });
412
413 {/literal}
414 {/if}
415 </script>
416
417 <div class="accordion ui-accordion ui-widget ui-helper-reset">
418 {* Additional Detail / Honoree Information / Premium Information *}
419 {foreach from=$allPanes key=paneName item=paneValue}
420
421 <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}">
422 <div class="crm-accordion-header" id="{$paneValue.id}">
423
424 {$paneName}
425 </div><!-- /.crm-accordion-header -->
426 <div class="crm-accordion-body">
427
428 <div class="{$paneValue.id}"></div>
429 </div><!-- /.crm-accordion-body -->
430 </div><!-- /.crm-accordion-wrapper -->
431
432 {/foreach}
433 </div>
434
435 {/if}
436 <br />
437 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
438 </div>
439
440 {literal}
441 <script type="text/javascript">
442 function verify( ) {
443 if (cj('#is_email_receipt').prop('checked' )) {
444 var ok = confirm( '{/literal}{ts escape='js'}Click OK to save this contribution record AND send a receipt to the contributor now{/ts}{literal}.' );
445 if (!ok) {
446 return false;
447 }
448 }
449 }
450 </script>
451 {/literal}
452
453 {if $action neq 8}
454 {literal}
455 <script type="text/javascript">
456 CRM.$(function($) {
457 var $form = $('form.{/literal}{$form.formClass}{literal}');
458 checkEmailDependancies();
459 $('#is_email_receipt', $form).click(function() {
460 checkEmailDependancies();
461 });
462
463 function checkEmailDependancies( ) {
464 if ($('#is_email_receipt', $form).prop('checked')) {
465 $('#fromEmail', $form).show();
466 $('#receiptDate', $form).hide();
467 }
468 else {
469 $('#fromEmail', $form).hide();
470 $('#receiptDate', $form).show();
471 }
472 }
473 {/literal}{if !$contributionMode}{literal}
474 showHideCancelInfo($('#contribution_status_id', $form));
475
476 $('#contribution_status_id', $form).change(function() {
477 showHideCancelInfo($('#contribution_status_id', $form));
478 });
479
480 function showHideCancelInfo(obj) {
481 var cancelInfo_show_ids = [{/literal}{$cancelInfo_show_ids}{literal}];
482 if (cancelInfo_show_ids.indexOf(obj.val()) > -1) {
483 $('#cancelInfo', $form).show();
484 $('#total_amount', $form).attr('readonly', true);
485 }
486 else {
487 $("#cancel_date", $form).val('');
488 $("#cancel_reason", $form).val('');
489 $('#cancelInfo', $form).hide();
490 $("#total_amount", $form).removeAttr('readonly');
491 }
492 }
493 {/literal}{/if}
494 });
495 </script>
496 {/if} {* not delete mode if*}
497
498 {/if} {* closing of main custom data if *}
499
500 {literal}
501 <script type="text/javascript">
502
503 {/literal}
504
505 // load form during form rule.
506 {if $buildPriceSet}{literal}buildAmount( );{/literal}{/if}
507
508 {literal}
509
510 // CRM-16451: set financial type of 'Price Set' in back office contribution
511 // instead of selecting manually
512 function buildAmount( priceSetId, financialtypeIds ) {
513 if (!priceSetId) priceSetId = cj("#price_set_id").val( );
514 var fname = '#priceset';
515 if (!priceSetId) {
516 // hide price set fields.
517 cj(fname).hide( );
518
519 // show/hide price set amount and total amount.
520 cj("#totalAmountORPriceSet").show( );
521 cj("#totalAmount").show( );
522 var choose = "{/literal}{ts}Choose price set{/ts}{literal}";
523 cj("#price_set_id option[value='']").html( choose );
524
525 cj('label[for="total_amount"]').text('{/literal}{ts}Total Amount{/ts}{literal}');
526 cj(".crm-contribution-form-block-financial_type_id").show();
527 cj("#financial_type_id option[value='']").attr('selected', true);
528
529 //we might want to build recur block.
530 if (cj("#is_recur")) buildRecurBlock( null );
531 return;
532 }
533
534 //don't allow recurring w/ priceset.
535 if ( cj( "#is_recur" ) && cj( 'input:radio[name="is_recur"]:checked').val( ) ) {
536 //reset the values of recur block.
537 cj("#installments").val('');
538 cj("#frequency_interval").val('');
539 cj('input:radio[name="is_recur"]')[0].checked = true;
540 cj("#recurringPaymentBlock").hide( );
541 }
542
543 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
544
545 var response = cj.ajax({
546 url: dataUrl,
547 async: false
548 }).responseText;
549
550 cj( fname ).show( ).html( response ).trigger('crmLoad');
551 // freeze total amount text field.
552 cj( "#total_amount").val('');
553
554 cj( "#totalAmountORPriceSet" ).hide( );
555 cj( "#totalAmount").hide( );
556 var manual = "{/literal}{ts}Manual contribution amount{/ts}{literal}";
557 cj("#price_set_id option[value='']").html( manual );
558
559 cj('label[for="total_amount"]').text('{/literal}{ts}Price Sets{/ts}{literal}');
560 if (financialtypeIds) {
561 cj("#financial_type_id option[value="+financialtypeIds[priceSetId]+"]").prop('selected', true);
562 }
563 cj(".crm-contribution-form-block-financial_type_id").css("display", "none");
564 }
565
566 function adjustPayment( ) {
567 cj('#adjust-option-type').show();
568 cj("#total_amount").removeAttr("READONLY");
569 cj("#total_amount").css('background-color', '#ffffff');
570 }
571
572 {/literal}{if $processorSupportsFutureStartDate}{literal}
573 cj ('input:radio[name="is_recur"]').click( function( ) {
574 showStartDate( );
575 });
576
577 showStartDate( );
578
579 function showStartDate( ) {
580 if (cj( 'input:radio[name="is_recur"]:checked').val( ) == 0 ) {
581 cj('#start_date').hide( );
582 }
583 else {
584 cj('#start_date').show( );
585 }
586 }
587
588 {/literal}{/if}{literal}
589 var thousandMarker = "{/literal}{$config->monetaryThousandSeparator}{literal}";
590 var separator = "{/literal}{$config->monetaryDecimalPoint}{literal}";
591
592 cj('#fee_amount').change( function() {
593 var totalAmount = cj('#total_amount').val().replace(thousandMarker,'').replace(separator,'.');
594 var feeAmount = cj('#fee_amount').val().replace(thousandMarker,'').replace(separator,'.');
595 var netAmount = totalAmount - feeAmount;
596 if (totalAmount) {
597 cj('#net_amount').val(CRM.formatMoney(netAmount, true));
598 }
599 });
600
601 cj("#financial_type_id").on("change",function(){
602 cj('#total_amount').trigger("change");
603 })
604
605 cj("#currency").on("change",function(){
606 cj('#total_amount').trigger("change");
607 })
608
609 {/literal}{if $taxRates && $invoicing}{literal}
610 CRM.$(function($) {
611 $('#total_amount').on("change",function(event) {
612 if (event.handled !== true) {
613 var freezeFinancialType = '{/literal}{$freezeFinancialType}{literal}';
614 if (!freezeFinancialType) {
615 var financialType = $('#financial_type_id').val();
616 var taxRates = '{/literal}{$taxRates}{literal}';
617 var taxTerm = '{/literal}{$taxTerm}{literal}';
618 taxRates = JSON.parse(taxRates);
619 var currencies = '{/literal}{$currencies}{literal}';
620 currencies = JSON.parse(currencies);
621 var currencySelect = $('#currency').val();
622 var currencySymbol = currencies[currencySelect];
623 var re= /\((.*?)\)/g;
624 for(m = re.exec(currencySymbol); m; m = re.exec(currencySymbol)){
625 currencySymbol = m[1];
626 }
627 var taxRate = taxRates[financialType];
628 if (!taxRate) {
629 taxRate = 0;
630 cj("#totalTaxAmount").hide( );
631 } else {
632 cj("#totalTaxAmount").show( );
633 }
634 var totalAmount = $('#total_amount').val();
635 // replace all thousandMarker and change the separator to a dot
636 totalAmount = totalAmount.replace(thousandMarker,'').replace(separator,'.');
637
638 var totalTaxAmount = '{/literal}{$totalTaxAmount}{literal}';
639 var taxAmount = (taxRate/100)*totalAmount;
640 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
641 var totalTaxAmount = taxAmount + Number(totalAmount);
642 totalTaxAmount = formatMoney( totalTaxAmount, 2, separator, thousandMarker );
643 $("#totalTaxAmount" ).html('{/literal}{ts 1=$taxTerm}Amount with %1 :{/ts}{literal} <span id="currencySymbolShow">' + currencySymbol + '</span> '+ totalTaxAmount);
644 }
645 event.handled = true;
646 }
647 return false;
648 });
649
650 $('#total_amount').trigger("change");
651 });
652 {/literal}{/if}{literal}
653
654 CRM.$(function($) {
655 $('#price_set_id').click(function() {
656 if( $('#price_set_id').val() ) {
657 $('#totalAmountBlock').hide();
658 }
659 else {
660 $('#totalAmountBlock').show();
661 }
662 });
663 });
664
665 function formatMoney (amount, c, d, t){
666 var n = amount,
667 c = isNaN(c = Math.abs(c)) ? 2 : c,
668 d = d == undefined ? "," : d,
669 t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
670 i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
671 j = (j = i.length) > 3 ? j % 3 : 0;
672 return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
673 };
674 </script>
675 {/literal}