2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
10 {* this template is used for adding/editing/deleting contributions and pledge payments *}
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"}
17 {include file="CRM/Contribute/Form/AdditionalInfo/Payment.tpl"}
18 {if $contributionMode}
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}
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}
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}
32 <div class="crm-block crm-form-block crm-contribution-form-block">
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> {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}
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}
46 {if $newCredit AND $action EQ 1 AND $contributionMode EQ null}
47 <div class="action-link css_right crm-link-credit-card-mode">
49 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=add&cid=`$contactId`&context=`$context`&mode=live"}{/capture}
51 {capture assign=ccModeLink}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=add&context=standalone&mode=live"}{/capture}
53 <a class="open-inline-noreturn action-item crm-hover-button" href="{$ccModeLink}"><i class="crm-i fa-credit-card" aria-hidden="true"></i> {ts}submit credit card contribution{/ts}</a>
56 <div class="crm-submit-buttons">
57 {include file="CRM/common/formButtons.tpl"}
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>
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}
69 {/if} {help id="id-financial_type"}
72 {if $action eq 2 and $lineItem and !$defaultContribution}
74 <td class="label">{ts}Contribution Amount{/ts}</td>
75 <td>{include file="CRM/Price/Page/LineItem.tpl" context="Contribution"}</td>
78 <tr class="crm-contribution-form-block-total_amount">
79 <td class="label">{$form.total_amount.label}</td>
81 <span id='totalAmount'>{$form.currency.html|crmAddClass:eight} {$form.total_amount.html|crmAddClass:eight}</span>
82 {if $freezeFinancialType}
83 {help id="id-total_amount"}
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>
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>
101 {if $buildRecurBlock && !$payNow}
102 <tr id='recurringPaymentBlock' class='hiddenElement'>
105 <strong>{$form.is_recur.html} {ts}every{/ts}
106 {$form.frequency_interval.html}
107 {$form.frequency_unit.html}
109 {$form.installments.html}
110 {$form.installments.label}
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}
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>
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>
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"}
139 {* CRM-7362 --add campaign to contributions *}
140 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-contribution-form-block-campaign_id"}
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}
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}"><i class="crm-i fa-credit-card" aria-hidden="true"></i> {ts}Pay with Credit Card{/ts}</a>
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">
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>
166 {if $hideCalendar neq true}
167 {$form.cancel_date.html}
169 {$form.cancel_date.value|crmDate}
173 <tr id="cancelDescription" class="crm-contribution-form-block-cancel_reason">
174 <td class="label"> </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>
177 <tr id="cancelReason">
178 <td class="label" style="vertical-align: top;">{$form.cancel_reason.label}</td>
179 <td>{$form.cancel_reason.html}</td>
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>
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>
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>
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}
207 <span class="description">{ts 1=$email}Automatically email a receipt for this payment to %1?{/ts}</span>
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>
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>
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>
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>
232 {if !$contributionMode}
233 <fieldset class="payment-details_group">
235 {ts}Payment Details{/ts}
237 {if $isUsePaymentBlock}
238 {include file="CRM/Contribute/Form/PaymentInfoBlock.tpl"}
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>
245 <tr class="crm-contribution-form-block-trxn_id">
246 <td class="label">{$form.trxn_id.label}</td>
247 <td {$valueStyle}>{$form.trxn_id.html} {help id="id-trans_id"}</td>
254 {if !$isUsePaymentBlock}
255 {include file='CRM/Core/BillingBlockWrapper.tpl'}
258 <!-- start of soft credit -->
260 <div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed {if $noSoftCredit}collapsed{/if}" id="softCredit">
261 <div class="crm-accordion-header">
262 {ts}Soft Credit{/ts} {help id="id-soft_credit"}
264 <div class="crm-accordion-body">
265 <table class="form-layout-compressed">
266 <tr class="crm-contribution-form-block-soft_credit_to">
268 {include file="CRM/Contribute/Form/SoftCredit.tpl"}
275 <!-- end of soft credit -->
277 <!-- start of PCP -->
278 {if $siteHasPCPs && !$payNow}
279 <div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed {if $noPCP}collapsed{/if}" id="softCredit">
280 <div class="crm-accordion-header">
281 {ts}Personal Campaign Page{/ts} {help id="id-pcp"}
283 <div class="crm-accordion-body">
284 <table class="form-layout-compressed">
285 <tr class="crm-contribution-pcp-block crm-contribution-form-block-pcp_made_through_id">
286 <td class="label">{$form.pcp_made_through_id.label}</td>
288 {$form.pcp_made_through_id.html}
289 <div class="description">{ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts}</div>
291 <div class="spacer"></div>
292 <div class="crm-contribution-form-block-pcp_details">
293 <table class="crm-contribution-form-table-credit_to_pcp">
294 <tr id="pcpDisplayRollID" class="crm-contribution-form-block-pcp_display_in_roll">
295 <td class="label">{$form.pcp_display_in_roll.label}</td>
296 <td>{$form.pcp_display_in_roll.html}</td>
298 <tr id="nickID" class="crm-contribution-form-block-pcp_roll_nickname">
299 <td class="label">{$form.pcp_roll_nickname.label}</td>
300 <td>{$form.pcp_roll_nickname.html|crmAddClass:big}<br/>
301 <div class="description">{ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts}</div>
304 <tr id="personalNoteID" class="crm-contribution-form-block-pcp_personal_note">
305 <td class="label" style="vertical-align: top">{$form.pcp_personal_note.label}</td>
307 {$form.pcp_personal_note.html}
308 <div class="description">{ts}Personal message submitted by contributor for display in the Honor Roll.{/ts}</div>
318 {include file="CRM/Contribute/Form/PCP.js.tpl"}
323 {include file="CRM/common/customDataBlock.tpl"}
327 <script type="text/javascript">
330 {if $buildPriceSet}{literal}buildAmount();{/literal}{/if}
333 // bind first click of accordion header to load crm-accordion-body with snippet
334 // everything else taken care of by cj().crm-accordions()
335 cj('#adjust-option-type').hide();
336 cj('.crm-ajax-accordion .crm-accordion-header').one('click', function() {
337 loadPanes(cj(this).attr('id'));
339 cj('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) {
340 loadPanes(cj(this).attr('id'));
343 // load panes function calls for snippet based on id of crm-accordion-header
344 function loadPanes(id) {
345 var url = "{/literal}{crmURL p='civicrm/contact/view/contribution' q="snippet=4&id=`$entityID`&formType=" h=0}{literal}" + id;
347 {if $contributionMode}
348 url = url + "&mode={$contributionMode}";
351 url = url + "&qfKey={$qfKey}";
354 if (! cj('div.'+id).html()) {
355 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}...';
356 cj('div.'+id).html(loading);
359 success: function(data) { cj('div.'+id).html(data).trigger('crmLoad'); }
364 var url = {/literal}{$dataUrl|@json_encode}{literal};
367 {if $context eq 'standalone' and $outBound_option != 2}
371 var $form = $("form.{/literal}{$form.formClass}{literal}");
372 $("#contact_id", $form).change(checkEmail);
375 function checkEmail() {
376 var data = $("#contact_id", $form).select2('data');
377 if (data && data.extra && data.extra.email && data.extra.email.length) {
378 $("#email-receipt", $form).show();
379 $("#email-address", $form).html(data.extra.email);
382 $("#email-receipt", $form).hide();
386 showHideByValue('is_email_receipt', '', 'receiptDate', 'table-row', 'radio', true);
387 showHideByValue('is_email_receipt', '', 'fromEmail', 'table-row', 'radio', false);
394 <div class="accordion ui-accordion ui-widget ui-helper-reset">
395 {* Additional Detail / Honoree Information / Premium Information *}
396 {foreach from=$allPanes key=paneName item=paneValue}
397 <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}">
398 <div class="crm-accordion-header" id="{$paneValue.id}">
400 </div><!-- /.crm-accordion-header -->
401 <div class="crm-accordion-body">
402 <div class="{$paneValue.id}"></div>
403 </div><!-- /.crm-accordion-body -->
404 </div><!-- /.crm-accordion-wrapper -->
409 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
413 <script type="text/javascript">
415 if (cj('#is_email_receipt').prop('checked')) {
416 var ok = confirm('{/literal}{ts escape='js'}Click OK to save this contribution record AND send a receipt to the contributor now{/ts}{literal}.');
427 <script type="text/javascript">
429 var $form = $('form.{/literal}{$form.formClass}{literal}');
430 checkEmailDependancies();
431 $('#is_email_receipt', $form).click(function() {
432 checkEmailDependancies();
435 function checkEmailDependancies() {
436 if ($('#is_email_receipt', $form).prop('checked')) {
437 $('#fromEmail', $form).show();
438 $('#receiptDate', $form).hide();
441 $('#fromEmail', $form).hide();
442 $('#receiptDate', $form).show();
445 {/literal}{if !$contributionMode}{literal}
446 showHideCancelInfo($('#contribution_status_id', $form));
448 $('#contribution_status_id', $form).change(function() {
449 showHideCancelInfo($('#contribution_status_id', $form));
452 function showHideCancelInfo(obj) {
453 var cancelInfo_show_ids = [{/literal}{$cancelInfo_show_ids}{literal}];
454 if (cancelInfo_show_ids.indexOf(obj.val()) > -1) {
455 $('#cancelInfo', $form).show();
456 $('#total_amount', $form).attr('readonly', true);
459 $("#cancel_date", $form).val('');
460 $("#cancel_reason", $form).val('');
461 $('#cancelInfo', $form).hide();
462 $("#total_amount", $form).removeAttr('readonly');
468 {/if} {* not delete mode if*}
470 {/if} {* closing of main custom data if *}
473 <script type="text/javascript">
477 // load form during form rule.
478 {if $buildPriceSet}{literal}buildAmount();{/literal}{/if}
482 // CRM-16451: set financial type of 'Price Set' in back office contribution
483 // instead of selecting manually
484 function buildAmount(priceSetId, financialtypeIds) {
485 if (!priceSetId) { priceSetId = cj("#price_set_id").val(); }
486 var fname = '#priceset';
488 // hide price set fields.
491 // show/hide price set amount and total amount.
492 cj("#totalAmountORPriceSet").show();
493 cj("#totalAmount").show();
494 var choose = "{/literal}{ts escape='js'}Choose price set{/ts}{literal}";
495 cj("#price_set_id option[value='']").html(choose);
497 cj('label[for="total_amount"]').text('{/literal}{ts}Total Amount{/ts}{literal}');
498 cj(".crm-contribution-form-block-financial_type_id").show();
499 cj("#financial_type_id option[value='']").attr('selected', true);
501 //we might want to build recur block.
502 if (cj("#is_recur")) { buildRecurBlock(null); }
506 //don't allow recurring w/ priceset.
507 if (cj("#is_recur") && cj('input:radio[name="is_recur"]:checked').val()) {
508 //reset the values of recur block.
509 cj("#installments").val('');
510 cj("#frequency_interval").val('');
511 cj('input:radio[name="is_recur"]')[0].checked = true;
512 cj("#recurringPaymentBlock").hide();
515 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
517 var response = cj.ajax({
522 cj(fname).show().html(response).trigger('crmLoad');
523 // freeze total amount text field.
524 cj( "#total_amount").val('');
526 cj( "#totalAmountORPriceSet" ).hide();
527 cj( "#totalAmount").hide();
528 var manual = "{/literal}{ts escape='js'}Manual contribution amount{/ts}{literal}";
529 cj("#price_set_id option[value='']").html(manual);
531 cj('label[for="total_amount"]').text('{/literal}{ts}Price Sets{/ts}{literal}');
532 if (financialtypeIds) {
533 cj("#financial_type_id option[value="+financialtypeIds[priceSetId]+"]").prop('selected', true);
535 cj(".crm-contribution-form-block-financial_type_id").css("display", "none");
538 function adjustPayment() {
539 cj('#adjust-option-type').show();
540 cj("#total_amount").removeAttr("READONLY");
541 cj("#total_amount").css('background-color', '#ffffff');
544 {/literal}{if $processorSupportsFutureStartDate}{literal}
545 cj ('#is_recur').click(function() {
551 function showStartDate() {
552 if (!cj('#is_recur').is(':checked')) {
553 cj('#start_date').hide();
556 cj('#start_date').show();
560 {/literal}{/if}{literal}
561 var thousandMarker = "{/literal}{$config->monetaryThousandSeparator}{literal}";
562 var separator = "{/literal}{$config->monetaryDecimalPoint}{literal}";
564 cj("#financial_type_id").on("change", function() {
565 cj('#total_amount').trigger("change");
568 cj("#currency").on("change", function() {
569 cj('#total_amount').trigger("change");
572 {/literal}{if $taxRates && $invoicing}{literal}
574 $('#total_amount').on("change", function(event) {
575 if (event.handled !== true) {
576 var freezeFinancialType = '{/literal}{$freezeFinancialType}{literal}';
577 if (!freezeFinancialType) {
578 var financialType = $('#financial_type_id').val();
579 var taxRates = '{/literal}{$taxRates}{literal}';
580 var taxTerm = '{/literal}{$taxTerm}{literal}';
581 taxRates = JSON.parse(taxRates);
582 var currencies = '{/literal}{$currencies}{literal}';
583 currencies = JSON.parse(currencies);
584 var currencySelect = $('#currency').val();
585 var currencySymbol = currencies[currencySelect];
586 var re= /\((.*?)\)/g;
587 for(m = re.exec(currencySymbol); m; m = re.exec(currencySymbol)){
588 currencySymbol = m[1];
590 var taxRate = taxRates[financialType];
593 cj("#totalTaxAmount").hide();
595 cj("#totalTaxAmount").show();
597 var totalAmount = $('#total_amount').val();
598 // replace all thousandMarker and change the separator to a dot
599 totalAmount = totalAmount.replace(thousandMarker,'').replace(separator,'.');
601 var totalTaxAmount = '{/literal}{$totalTaxAmount}{literal}';
602 var taxAmount = (taxRate/100)*totalAmount;
603 taxAmount = isNaN (taxAmount) ? 0:taxAmount;
604 var totalTaxAmount = taxAmount + Number(totalAmount);
605 totalTaxAmount = formatMoney( totalTaxAmount, 2, separator, thousandMarker );
606 $("#totalTaxAmount" ).html('{/literal}{ts 1=$taxTerm}Amount with %1 :{/ts}{literal} <span id="currencySymbolShow">' + currencySymbol + '</span> '+ totalTaxAmount);
608 event.handled = true;
613 $('#total_amount').trigger("change");
615 {/literal}{/if}{literal}
618 $('#price_set_id').click(function() {
619 if($('#price_set_id').val()) {
620 $('#totalAmountBlock').hide();
623 $('#totalAmountBlock').show();
628 function formatMoney(amount, c, d, t) {
630 c = isNaN(c = Math.abs(c)) ? 2 : c,
631 d = d == undefined ? "," : d,
632 t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
633 i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
634 j = (j = i.length) > 3 ? j % 3 : 0;
635 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) : "");