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