Commit | Line | Data |
---|---|---|
bc2eeabb PJ |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
819d0d41 | 3 | | CiviCRM version 4.5 | |
bc2eeabb | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
bc2eeabb PJ |
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 to change selections of fees for a participant *} | |
1a0d17b9 PJ |
27 | {literal} |
28 | <script type='text/javascript'> | |
29 | function display(totalfee) { | |
a50f4059 DG |
30 | {/literal}{if $optionFullTotalAmount} |
31 | totalfee += {$optionFullTotalAmount};{/if} | |
32 | {literal}; | |
1a0d17b9 PJ |
33 | // totalfee is monetary, round it to 2 decimal points so it can |
34 | // go as a float - CRM-13491 | |
35 | totalfee = Math.round(totalfee*100)/100; | |
36 | // note : some variables used used here are global variables defined inside Calculate.tpl | |
37 | var totalEventFee = formatMoney( totalfee, 2, seperator, thousandMarker); | |
b17ee3ee | 38 | cj('#pricevalue').html("<b>"+symbol+"</b> "+totalEventFee); |
1a0d17b9 PJ |
39 | scriptfee = totalfee; |
40 | scriptarray = price; | |
b17ee3ee | 41 | cj('#total_amount').val(totalfee); |
1a0d17b9 PJ |
42 | ( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled'); |
43 | ||
44 | // populate the balance amount div | |
b17ee3ee | 45 | // change the status selections according to updated selections |
ae53df5f | 46 | populatebalanceFee(totalfee, false); |
1a0d17b9 PJ |
47 | } |
48 | ||
ae53df5f PJ |
49 | function populatebalanceFee(updatedAmt, onlyStatusUpdate) { |
50 | // updatedAmt is: selected line total | |
51 | ||
1010c4e1 PJ |
52 | // assign statuses |
53 | var partiallyPaid = {/literal}{$partiallyPaid}{literal}; | |
54 | var pendingRefund = {/literal}{$pendingRefund}{literal}; | |
55 | var participantStatus = {/literal}{$participantStatus}{literal}; | |
ae53df5f PJ |
56 | |
57 | // fee actually paid | |
1010c4e1 PJ |
58 | var feePaid = {/literal}{$feePaid}{literal}; |
59 | ||
ae53df5f PJ |
60 | var updatedTotalLineTotal = updatedAmt; |
61 | ||
62 | {/literal}{if $totalLineTotal}{literal} | |
63 | // line total of current participant stored in DB | |
64 | var linetotal = {/literal}{$lineItemTotal}{literal}; | |
65 | ||
66 | // line total of all the participants | |
67 | var totalLineTotal = {/literal}{$totalLineTotal}{literal}; | |
68 | updatedTotalLineTotal = totalLineTotal + (updatedAmt - linetotal); | |
69 | {/literal}{/if}{literal} | |
70 | ||
1a0d17b9 | 71 | // calculate the balance amount using total paid and updated amount |
ae53df5f PJ |
72 | var balanceAmt = updatedTotalLineTotal - feePaid; |
73 | ||
b17ee3ee | 74 | // change the status selections according to updated selections |
c6191312 | 75 | if (balanceAmt > 0 && feePaid != 0) { |
1010c4e1 | 76 | cj('#status_id').val(partiallyPaid); |
b17ee3ee PJ |
77 | } |
78 | else if(balanceAmt < 0) { | |
1010c4e1 | 79 | cj('#status_id').val(pendingRefund); |
b17ee3ee | 80 | } |
c6191312 | 81 | else { |
1010c4e1 | 82 | cj('#status_id').val(participantStatus); |
b17ee3ee PJ |
83 | } |
84 | ||
ae53df5f PJ |
85 | if (!onlyStatusUpdate) { |
86 | balanceAmt = formatMoney(balanceAmt, 2, seperator, thousandMarker); | |
87 | cj('#balance-fee').text(symbol+" "+balanceAmt); | |
88 | } | |
1a0d17b9 PJ |
89 | } |
90 | ||
3cc60a06 | 91 | CRM.$(function($) { |
ae8f569f | 92 | var updatedFeeUnFormatted = $('#pricevalue').text(); |
b17ee3ee | 93 | var updatedAmt = parseFloat(updatedFeeUnFormatted.replace(/[^0-9-.]/g, '')); |
b17ee3ee | 94 | |
ae53df5f | 95 | populatebalanceFee(updatedAmt, true); |
b17ee3ee PJ |
96 | }); |
97 | ||
1a0d17b9 PJ |
98 | {/literal} |
99 | </script> | |
bc2eeabb PJ |
100 | <h3>Change Registration Selections</h3> |
101 | ||
102 | <div class="crm-block crm-form-block crm-payment-form-block"> | |
103 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
2429e40c PJ |
104 | {if !$email} |
105 | <div class="messages status no-popup"> | |
106 | <div class="icon inform-icon"></div> {ts}You will not be able to send an automatic email receipt for this payment because there is no email address recorded for this contact. If you want a receipt to be sent when this payment is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the payment.{/ts} | |
107 | </div> | |
108 | {/if} | |
66cae705 | 109 | <table class="form-layout"> |
bc2eeabb PJ |
110 | <tr> |
111 | <td class="font-size12pt label"><strong>{ts}Participant{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td> | |
112 | </tr> | |
113 | <tr> | |
114 | <td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td> | |
115 | </tr> | |
116 | <tr class="crm-participant-form-block-status_id"> | |
117 | <td class="label">{$form.status_id.label}</td> | |
118 | <td>{$form.status_id.html}</td> | |
119 | </tr> | |
120 | {if $lineItem} | |
121 | <tr class="crm-event-eventfees-form-block-line_items"> | |
122 | <td class="label">{ts}Current Selections{/ts}</td> | |
123 | <td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td> | |
124 | </tr> | |
66cae705 | 125 | {/if} |
bc2eeabb | 126 | </table> |
66cae705 | 127 | |
bc2eeabb PJ |
128 | {if $priceSet.fields} |
129 | <fieldset id="priceset" class="crm-group priceset-group"> | |
130 | <table class='form-layout'> | |
131 | <tr class="crm-event-eventfees-form-block-price_set_amount"> | |
132 | <td class="label" style="padding-top: 10px;">{$form.amount.label}</td> | |
d06f3157 | 133 | <td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event" dontInclCal="true" context="participant"}</table></td> |
1a0d17b9 | 134 | </tr> |
bc2eeabb PJ |
135 | {if $paymentInfo} |
136 | <tr><td></td><td> | |
66cae705 | 137 | <div class='crm-section'> |
bc2eeabb PJ |
138 | <div class='label'>{ts}Updated Fee(s){/ts}</div><div id="pricevalue" class='content updated-fee'></div> |
139 | <div class='label'>{ts}Total Paid{/ts}</div> | |
77042884 CW |
140 | <div class='content'> |
141 | {$paymentInfo.paid|crmMoney}<br/> | |
142 | <a class="crm-hover-button crm-popup medium-popup" href='{crmURL p="civicrm/payment" q="view=transaction&action=browse&cid=`$contactId`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&context=transaction"}'>» {ts}view payments{/ts}</a> | |
bc2eeabb | 143 | </div> |
2429e40c | 144 | <div class='label'><strong>{ts}Balance Owed{/ts}</strong></div><div class='content'><strong id='balance-fee'></strong></div> |
bc2eeabb | 145 | </div> |
1a0d17b9 | 146 | {include file='CRM/Price/Form/Calculate.tpl' currencySymbol=$currencySymbol noCalcValueDisplay='false' displayOveride='true'} |
66cae705 | 147 | {/if} |
bc2eeabb PJ |
148 | </table> |
149 | </fieldset> | |
150 | {/if} | |
2429e40c PJ |
151 | {if $email} |
152 | <fieldset id="email-receipt"><legend>{ts}Participant Confirmation{/ts}</legend> | |
153 | <table class="form-layout" style="width:auto;"> | |
154 | <tr class="crm-event-eventfees-form-block-send_receipt"> | |
155 | <td class="label">{ts}Send Confirmation{/ts}</td> | |
156 | <td>{$form.send_receipt.html}<br> | |
a9255f2c | 157 | <span class="description">{ts 1=$email}Automatically email a confirmation to %1?{/ts}</span> |
2429e40c PJ |
158 | </td> |
159 | </tr> | |
160 | <tr id="from-email" class="crm-event-eventfees-form-block-from_email_address"> | |
161 | <td class="label">{$form.from_email_address.label}</td> | |
162 | <td>{$form.from_email_address.html} {help id ="id-from_email" file="CRM/Contact/Form/Task/Email.hlp"}</td> | |
163 | </tr> | |
164 | <tr id='notice' class="crm-event-eventfees-form-block-receipt_text"> | |
165 | <td class="label">{$form.receipt_text.label}</td> | |
166 | <td><span class="description"> | |
167 | {ts}Enter a message you want included at the beginning of the confirmation email. EXAMPLE: 'We have made the changes you requested to your registration.'{/ts} | |
168 | </span><br /> | |
169 | {$form.receipt_text.html|crmAddClass:huge} | |
170 | </td> | |
171 | </tr> | |
172 | </table> | |
173 | </fieldset> | |
174 | {/if} | |
175 | <fieldset> | |
176 | <table class="form-layout"> | |
177 | <tr class="crm-participant-form-block-note"> | |
178 | <td class="label">{$form.note.label}</td><td>{$form.note.html}</td> | |
179 | </tr> | |
180 | </table> | |
181 | </fieldset> | |
bc2eeabb PJ |
182 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> |
183 | </div> | |
2429e40c PJ |
184 | {if $email} |
185 | {include file="CRM/common/showHideByFieldValue.tpl" | |
186 | trigger_field_id ="send_receipt" | |
187 | trigger_value ="" | |
188 | target_element_id ="notice" | |
189 | target_element_type ="table-row" | |
190 | field_type ="radio" | |
191 | invert = 0 | |
192 | } | |
193 | {include file="CRM/common/showHideByFieldValue.tpl" | |
194 | trigger_field_id ="send_receipt" | |
195 | trigger_value ="" | |
196 | target_element_id ="from-email" | |
197 | target_element_type ="table-row" | |
198 | field_type ="radio" | |
199 | invert = 0 | |
200 | } | |
201 | {/if} | |
bc2eeabb PJ |
202 | {literal} |
203 | <script type='text/javascript'> | |
3cc60a06 | 204 | CRM.$(function($) { |
b50fdacc | 205 | var $form = $('form.{/literal}{$form.formClass}{literal}'); |
66cae705 | 206 | cj('.total_amount-section').remove(); |
d5397f2f | 207 | |
b50fdacc | 208 | cj($form).submit(function(e) { |
d5397f2f PJ |
209 | var partiallyPaid = {/literal}{$partiallyPaid}{literal}; |
210 | var pendingRefund = {/literal}{$pendingRefund}{literal}; | |
b17ee3ee | 211 | var statusId = cj('#status_id').val(); |
d5397f2f | 212 | var statusLabel = cj('#status_id option:selected').text(); |
b17ee3ee | 213 | var balanceFee = cj('#balance-fee').text(); |
c6191312 PJ |
214 | |
215 | // fee actually paid | |
216 | var feePaid = {/literal}{$feePaid}{literal}; | |
217 | ||
b17ee3ee | 218 | balanceFee = parseFloat(balanceFee.replace(/[^0-9-.]/g, '')); |
d5397f2f | 219 | |
c6191312 | 220 | if ((balanceFee > 0 && feePaid != 0) && statusId != partiallyPaid) { |
b17ee3ee PJ |
221 | var result = confirm('Balance is owing for the updated selections. Expected participant status is \'Partially paid\'. Are you sure you want to set the participant status to ' + statusLabel + ' ? Click OK to continue, Cancel to change your entries.'); |
222 | if (result == false) { | |
223 | e.preventDefault(); | |
224 | } | |
2429e40c | 225 | } |
c6191312 | 226 | else if ((balanceFee < 0 && feePaid != 0) && statusId != pendingRefund) { |
b17ee3ee PJ |
227 | var result = confirm('Balance is overpaid for the updated selections. Expected participant status is \'Pending refund\'. Are you sure you want to set the participant status to ' + statusLabel + ' ? Click OK to continue, Cancel to change your entries'); |
228 | if (result == false) { | |
229 | e.preventDefault(); | |
230 | } | |
2429e40c | 231 | } |
b17ee3ee | 232 | }); |
bc2eeabb PJ |
233 | }); |
234 | </script> | |
a9255f2c | 235 | {/literal} |