Commit | Line | Data |
---|---|---|
bc2eeabb PJ |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
3 | | CiviCRM version 4.4 | | |
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 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 |
1010c4e1 | 43 | populatebalanceFee(totalfee); |
1a0d17b9 PJ |
44 | } |
45 | ||
b17ee3ee | 46 | function populatebalanceFee(updatedAmt) { |
1010c4e1 PJ |
47 | // assign statuses |
48 | var partiallyPaid = {/literal}{$partiallyPaid}{literal}; | |
49 | var pendingRefund = {/literal}{$pendingRefund}{literal}; | |
50 | var participantStatus = {/literal}{$participantStatus}{literal}; | |
51 | var feePaid = {/literal}{$feePaid}{literal}; | |
52 | ||
1a0d17b9 | 53 | // calculate the balance amount using total paid and updated amount |
1010c4e1 | 54 | var balanceAmt = updatedAmt - feePaid; |
b17ee3ee PJ |
55 | // change the status selections according to updated selections |
56 | if (balanceAmt > 0) { | |
1010c4e1 | 57 | cj('#status_id').val(partiallyPaid); |
b17ee3ee PJ |
58 | } |
59 | else if(balanceAmt < 0) { | |
1010c4e1 | 60 | cj('#status_id').val(pendingRefund); |
b17ee3ee PJ |
61 | } |
62 | else if(balanceAmt == 0) { | |
1010c4e1 | 63 | cj('#status_id').val(participantStatus); |
b17ee3ee PJ |
64 | } |
65 | ||
1a0d17b9 PJ |
66 | balanceAmt = formatMoney(balanceAmt, 2, seperator, thousandMarker); |
67 | cj('#balance-fee').text(symbol+" "+balanceAmt); | |
68 | } | |
69 | ||
b17ee3ee | 70 | cj(function(){ |
1010c4e1 PJ |
71 | // assign statuses |
72 | var partiallyPaid = {/literal}{$partiallyPaid}{literal}; | |
73 | var pendingRefund = {/literal}{$pendingRefund}{literal}; | |
74 | var participantStatus = {/literal}{$participantStatus}{literal}; | |
75 | var feePaid = {/literal}{$feePaid}{literal}; | |
76 | ||
b17ee3ee PJ |
77 | var updatedFeeUnFormatted = cj('#pricevalue').text(); |
78 | var updatedAmt = parseFloat(updatedFeeUnFormatted.replace(/[^0-9-.]/g, '')); | |
1010c4e1 | 79 | var balanceAmt = updatedAmt - feePaid; |
b17ee3ee PJ |
80 | |
81 | // change the status selections according to updated selections | |
82 | if (balanceAmt > 0) { | |
1010c4e1 | 83 | cj('#status_id').val(partiallyPaid); |
b17ee3ee PJ |
84 | } |
85 | else if(balanceAmt < 0) { | |
1010c4e1 | 86 | cj('#status_id').val(pendingRefund); |
b17ee3ee PJ |
87 | } |
88 | }); | |
89 | ||
1a0d17b9 PJ |
90 | {/literal} |
91 | </script> | |
bc2eeabb PJ |
92 | <h3>Change Registration Selections</h3> |
93 | ||
94 | <div class="crm-block crm-form-block crm-payment-form-block"> | |
95 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
2429e40c PJ |
96 | {if !$email} |
97 | <div class="messages status no-popup"> | |
98 | <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} | |
99 | </div> | |
100 | {/if} | |
bc2eeabb PJ |
101 | <table class="form-layout"> |
102 | <tr> | |
103 | <td class="font-size12pt label"><strong>{ts}Participant{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td> | |
104 | </tr> | |
105 | <tr> | |
106 | <td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td> | |
107 | </tr> | |
108 | <tr class="crm-participant-form-block-status_id"> | |
109 | <td class="label">{$form.status_id.label}</td> | |
110 | <td>{$form.status_id.html}</td> | |
111 | </tr> | |
112 | {if $lineItem} | |
113 | <tr class="crm-event-eventfees-form-block-line_items"> | |
114 | <td class="label">{ts}Current Selections{/ts}</td> | |
115 | <td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td> | |
116 | </tr> | |
117 | {/if} | |
118 | </table> | |
119 | ||
120 | {if $priceSet.fields} | |
121 | <fieldset id="priceset" class="crm-group priceset-group"> | |
122 | <table class='form-layout'> | |
123 | <tr class="crm-event-eventfees-form-block-price_set_amount"> | |
124 | <td class="label" style="padding-top: 10px;">{$form.amount.label}</td> | |
1a0d17b9 PJ |
125 | <td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event" dontInclCal="true"}</table></td> |
126 | </tr> | |
bc2eeabb PJ |
127 | {if $paymentInfo} |
128 | <tr><td></td><td> | |
129 | <div class='crm-section'> | |
130 | <div class='label'>{ts}Updated Fee(s){/ts}</div><div id="pricevalue" class='content updated-fee'></div> | |
131 | <div class='label'>{ts}Total Paid{/ts}</div> | |
1010c4e1 | 132 | <div class='content'><a class='action-item' href='{crmURL p="civicrm/payment" q="view=transaction&action=browse&cid=`$contactId`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&context=transaction"}'>{$paymentInfo.paid|crmMoney}<br/>>> view payments</a> |
bc2eeabb | 133 | </div> |
2429e40c | 134 | <div class='label'><strong>{ts}Balance Owed{/ts}</strong></div><div class='content'><strong id='balance-fee'></strong></div> |
bc2eeabb | 135 | </div> |
1a0d17b9 | 136 | {include file='CRM/Price/Form/Calculate.tpl' currencySymbol=$currencySymbol noCalcValueDisplay='false' displayOveride='true'} |
bc2eeabb PJ |
137 | {/if} |
138 | </table> | |
139 | </fieldset> | |
140 | {/if} | |
2429e40c PJ |
141 | {if $email} |
142 | <fieldset id="email-receipt"><legend>{ts}Participant Confirmation{/ts}</legend> | |
143 | <table class="form-layout" style="width:auto;"> | |
144 | <tr class="crm-event-eventfees-form-block-send_receipt"> | |
145 | <td class="label">{ts}Send Confirmation{/ts}</td> | |
146 | <td>{$form.send_receipt.html}<br> | |
147 | <span class="description">{ts 1=$email'}Automatically email a confirmation to %1?{/ts}</span> | |
148 | </td> | |
149 | </tr> | |
150 | <tr id="from-email" class="crm-event-eventfees-form-block-from_email_address"> | |
151 | <td class="label">{$form.from_email_address.label}</td> | |
152 | <td>{$form.from_email_address.html} {help id ="id-from_email" file="CRM/Contact/Form/Task/Email.hlp"}</td> | |
153 | </tr> | |
154 | <tr id='notice' class="crm-event-eventfees-form-block-receipt_text"> | |
155 | <td class="label">{$form.receipt_text.label}</td> | |
156 | <td><span class="description"> | |
157 | {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} | |
158 | </span><br /> | |
159 | {$form.receipt_text.html|crmAddClass:huge} | |
160 | </td> | |
161 | </tr> | |
162 | </table> | |
163 | </fieldset> | |
164 | {/if} | |
165 | <fieldset> | |
166 | <table class="form-layout"> | |
167 | <tr class="crm-participant-form-block-note"> | |
168 | <td class="label">{$form.note.label}</td><td>{$form.note.html}</td> | |
169 | </tr> | |
170 | </table> | |
171 | </fieldset> | |
bc2eeabb PJ |
172 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> |
173 | </div> | |
2429e40c PJ |
174 | {if $email} |
175 | {include file="CRM/common/showHideByFieldValue.tpl" | |
176 | trigger_field_id ="send_receipt" | |
177 | trigger_value ="" | |
178 | target_element_id ="notice" | |
179 | target_element_type ="table-row" | |
180 | field_type ="radio" | |
181 | invert = 0 | |
182 | } | |
183 | {include file="CRM/common/showHideByFieldValue.tpl" | |
184 | trigger_field_id ="send_receipt" | |
185 | trigger_value ="" | |
186 | target_element_id ="from-email" | |
187 | target_element_type ="table-row" | |
188 | field_type ="radio" | |
189 | invert = 0 | |
190 | } | |
191 | {/if} | |
bc2eeabb PJ |
192 | {literal} |
193 | <script type='text/javascript'> | |
1a0d17b9 | 194 | cj(function($){ |
2429e40c | 195 | cj('.total_amount-section').remove(); |
2429e40c | 196 | |
b17ee3ee PJ |
197 | cj('#ParticipantFeeSelection').submit(function(e) { |
198 | var statusId = cj('#status_id').val(); | |
199 | var statusLabel = cj('#status_id option:selected').text(); | |
200 | var balanceFee = cj('#balance-fee').text(); | |
201 | balanceFee = parseFloat(balanceFee.replace(/[^0-9-.]/g, '')); | |
202 | ||
1010c4e1 | 203 | if (balanceFee > 0 && statusId != partiallyPaid) { |
b17ee3ee PJ |
204 | 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.'); |
205 | if (result == false) { | |
206 | e.preventDefault(); | |
207 | } | |
2429e40c | 208 | } |
1010c4e1 | 209 | else if (balanceFee < 0 && statusId != pendingRefund) { |
b17ee3ee PJ |
210 | 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'); |
211 | if (result == false) { | |
212 | e.preventDefault(); | |
213 | } | |
2429e40c | 214 | } |
b17ee3ee | 215 | }); |
bc2eeabb PJ |
216 | }); |
217 | </script> | |
218 | {/literal} |