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