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