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>
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>
255 {if !$isUsePaymentBlock}
256 {include file='CRM/Core/BillingBlockWrapper.tpl'}
259 <!-- start of soft credit -->
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} {help id="id-soft_credit"}
265 <div class="crm-accordion-body">
266 <table class="form-layout-compressed">
267 <tr class="crm-contribution-form-block-soft_credit_to">
269 {include file="CRM/Contribute/Form/SoftCredit.tpl"}
276 <!-- end of soft credit -->
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} {help id="id-pcp"}
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>
289 {$form.pcp_made_through_id.html}
290 <div class="description">{ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts}</div>
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>
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>
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>
308 {$form.pcp_personal_note.html}
310 class="description">{ts}Personal message submitted by contributor for display in the Honor Roll.{/ts}</div>
320 {include file="CRM/Contribute/Form/PCP.js.tpl"}
325 {include file="CRM/common/customDataBlock.tpl"}
329 <script type="text/javascript">
332 {if $buildPriceSet}{literal}buildAmount();{/literal}{/if}
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'));
341 cj('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) {
342 loadPanes(cj(this).attr('id'));
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;
349 {if $contributionMode}
350 url = url + "&mode={$contributionMode}";
353 url = url + "&qfKey={$qfKey}";
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}" /> {/literal}{ts escape='js'}Loading{/ts}{literal}...';
358 cj('div.'+id).html(loading);
361 success: function(data) { cj('div.'+id).html(data).trigger('crmLoad'); }
366 var url = {/literal}{$dataUrl|@json_encode}{literal};
369 {if $context eq 'standalone' and $outBound_option != 2 }
373 var $form = $("form.{/literal}{$form.formClass}{literal}");
374 $("#contact_id", $form).change(checkEmail);
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);
384 $("#email-receipt", $form).hide();
388 showHideByValue( 'is_email_receipt', '', 'receiptDate', 'table-row', 'radio', true);
389 showHideByValue( 'is_email_receipt', '', 'fromEmail', 'table-row', 'radio', false );
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}
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}">
404 </div><!-- /.crm-accordion-header -->
405 <div class="crm-accordion-body">
407 <div class="{$paneValue.id}"></div>
408 </div><!-- /.crm-accordion-body -->
409 </div><!-- /.crm-accordion-wrapper -->
416 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
420 <script type="text/javascript">
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}.' );
434 <script type="text/javascript">
436 var $form = $('form.{/literal}{$form.formClass}{literal}');
437 checkEmailDependancies();
438 $('#is_email_receipt', $form).click(function() {
439 checkEmailDependancies();
442 function checkEmailDependancies( ) {
443 if ($('#is_email_receipt', $form).prop('checked')) {
444 $('#fromEmail', $form).show();
445 $('#receiptDate', $form).hide();
448 $('#fromEmail', $form).hide();
449 $('#receiptDate', $form).show();
452 {/literal}{if !$contributionMode}{literal}
453 showHideCancelInfo($('#contribution_status_id', $form));
455 $('#contribution_status_id', $form).change(function() {
456 showHideCancelInfo($('#contribution_status_id', $form));
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);
466 $("#cancel_date", $form).val('');
467 $("#cancel_reason", $form).val('');
468 $('#cancelInfo', $form).hide();
469 $("#total_amount", $form).removeAttr('readonly');
475 {/if} {* not delete mode if*}
477 {/if} {* closing of main custom data if *}
480 <script type="text/javascript">
484 // load form during form rule.
485 {if $buildPriceSet}{literal}buildAmount( );{/literal}{/if}
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';
495 // hide price set fields.
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 );
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);
508 //we might want to build recur block.
509 if (cj("#is_recur")) buildRecurBlock( null );
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( );
522 var dataUrl = {/literal}"{crmURL h=0 q='snippet=4'}"{literal} + '&priceSetId=' + priceSetId;
524 var response = cj.ajax({
529 cj( fname ).show( ).html( response ).trigger('crmLoad');
530 // freeze total amount text field.
531 cj( "#total_amount").val('');
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 );
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);
542 cj(".crm-contribution-form-block-financial_type_id").css("display", "none");
545 function adjustPayment( ) {
546 cj('#adjust-option-type').show();
547 cj("#total_amount").removeAttr("READONLY");
548 cj("#total_amount").css('background-color', '#ffffff');
551 {/literal}{if $processorSupportsFutureStartDate}{literal}
552 cj ('input:radio[name="is_recur"]').click( function( ) {
558 function showStartDate( ) {
559 if (cj( 'input:radio[name="is_recur"]:checked').val( ) == 0 ) {
560 cj('#start_date').hide( );
563 cj('#start_date').show( );
567 {/literal}{/if}{literal}
568 var thousandMarker = "{/literal}{$config->monetaryThousandSeparator}{literal}";
569 var separator = "{/literal}{$config->monetaryDecimalPoint}{literal}";
571 cj("#financial_type_id").on("change",function(){
572 cj('#total_amount').trigger("change");
575 cj("#currency").on("change",function(){
576 cj('#total_amount').trigger("change");
579 {/literal}{if $taxRates && $invoicing}{literal}
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];
597 var taxRate = taxRates[financialType];
600 cj("#totalTaxAmount").hide( );
602 cj("#totalTaxAmount").show( );
604 var totalAmount = $('#total_amount').val();
605 // replace all thousandMarker and change the separator to a dot
606 totalAmount = totalAmount.replace(thousandMarker,'').replace(separator,'.');
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);
615 event.handled = true;
620 $('#total_amount').trigger("change");
622 {/literal}{/if}{literal}
625 $('#price_set_id').click(function() {
626 if( $('#price_set_id').val() ) {
627 $('#totalAmountBlock').hide();
630 $('#totalAmountBlock').show();
635 function formatMoney (amount, c, d, t){
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) : "");