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