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