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