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