-
-
Notifications
You must be signed in to change notification settings - Fork 824
/
Copy pathParticipantFeeSelection.tpl
217 lines (198 loc) · 9.15 KB
/
ParticipantFeeSelection.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
{*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{* This template is used to change selections of fees for a participant *}
{literal}
<script type='text/javascript'>
function display(totalfee) {
{/literal}{if $optionFullTotalAmount}
totalfee += {$optionFullTotalAmount};{/if}
{literal};
// totalfee is monetary, round it to 2 decimal points so it can
// go as a float - CRM-13491
totalfee = Math.round(totalfee*100)/100;
// note : some variables used used here are global variables defined inside Calculate.tpl
var totalEventFee = formatMoney( totalfee, 2, separator, thousandMarker);
cj('#pricevalue').html("<b>"+symbol+"</b> "+totalEventFee);
scriptfee = totalfee;
scriptarray = price;
cj('#total_amount').val(totalfee);
( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled');
// populate the balance amount div
// change the status selections according to updated selections
populatebalanceFee(totalfee, false);
}
function populatebalanceFee(updatedAmt, onlyStatusUpdate) {
// updatedAmt is: selected line total
// assign statuses
var partiallyPaid = {/literal}{$partiallyPaid}{literal};
var pendingRefund = {/literal}{$pendingRefund}{literal};
var participantStatus = {/literal}{$participantStatus}{literal};
// fee actually paid
var feePaid = {/literal}{$feePaid}{literal};
var updatedTotalLineTotal = updatedAmt;
{/literal}{if $totalLineTotal}{literal}
// line total of current participant stored in DB
var linetotal = {/literal}{$lineItemTotal}{literal};
// line total of all the participants
var totalLineTotal = {/literal}{$totalLineTotal}{literal};
updatedTotalLineTotal = totalLineTotal + (updatedAmt - linetotal);
{/literal}{/if}{literal}
// calculate the balance amount using total paid and updated amount
var balanceAmt = updatedTotalLineTotal - feePaid;
// change the status selections according to updated selections
if (balanceAmt > 0 && feePaid != 0) {
cj('#status_id').val(partiallyPaid);
}
else if(balanceAmt < 0) {
cj('#status_id').val(pendingRefund);
}
else {
cj('#status_id').val(participantStatus);
}
if (!onlyStatusUpdate) {
balanceAmt = formatMoney(balanceAmt, 2, separator, thousandMarker);
cj('#balance-fee').text(symbol+" "+balanceAmt);
}
}
CRM.$(function($) {
var updatedFeeUnFormatted = $('#pricevalue').text();
var updatedAmt = parseFloat(updatedFeeUnFormatted.replace(/[^0-9-.]/g, ''));
populatebalanceFee(updatedAmt, true);
});
{/literal}
</script>
<h3>{ts}Change Registration Selections{/ts}</h3>
<div class="crm-block crm-form-block crm-payment-form-block">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
{if !$email}
<div class="messages status no-popup">
<i class="crm-i fa-info-circle" aria-hidden="true"></i> {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}
</div>
{/if}
<table class="form-layout">
<tr>
<td class="label"><strong>{ts}Participant{/ts}</strong></td><td><strong>{$displayName}</strong></td>
</tr>
<tr>
<td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td>
</tr>
<tr class="crm-participant-form-block-status_id">
<td class="label">{$form.status_id.label}</td>
<td>{$form.status_id.html}</td>
</tr>
{if $lineItem}
<tr class="crm-event-eventfees-form-block-line_items">
<td class="label">{ts}Current Selections{/ts}</td>
<td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td>
</tr>
{/if}
</table>
{if $priceSet.fields}
<fieldset id="priceset" class="crm-group priceset-group">
<table class='form-layout'>
<tr class="crm-event-eventfees-form-block-price_set_amount">
<td class="label" style="padding-top: 10px;">{$form.amount.label}</td>
<td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event" hideTotal=false isShowAdminVisibilityFields=true}</table></td>
</tr>
{if $paymentInfo}
<tr><td></td><td>
<div class='crm-section'>
<div class='label'>{ts}Updated Fee(s){/ts}</div><div id="pricevalue" class='content updated-fee'> </div>
<div class='label'>{ts}Total Paid{/ts}</div>
<div class='content'>
{$paymentInfo.paid|crmMoney} <a class="crm-hover-button action-item crm-popup medium-popup" href='{crmURL p="civicrm/payment" q="view=transaction&action=browse&cid=`$contactId`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&context=transaction"}'><i class="crm-i fa-list-alt" aria-hidden="true"></i> {ts}view payments{/ts}</a>
</div>
<div class='label'><strong>{ts}Balance Owed{/ts}</strong></div><div class='content'><strong id='balance-fee'></strong></div>
</div>
{include file='CRM/Price/Form/Calculate.tpl' currencySymbol=$currencySymbol hideTotal=1 displayOveride='true'}
{/if}
</table>
</fieldset>
{/if}
{if $email}
<fieldset id="email-receipt"><legend>{ts}Participant Confirmation{/ts}</legend>
<table class="form-layout" style="width:auto;">
<tr class="crm-event-eventfees-form-block-send_receipt">
<td class="label">{ts}Send Confirmation{/ts}</td>
<td>{$form.send_receipt.html} <span class="description">{ts 1=$email}Automatically email a confirmation to %1?{/ts}</span>
</td>
</tr>
<tr id="from-email" class="crm-event-eventfees-form-block-from_email_address">
<td class="label">{$form.from_email_address.label}</td>
<td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Help/Email/id-from_email.hlp" title=$form.from_email_address.label}</td>
</tr>
<tr id='notice' class="crm-event-eventfees-form-block-receipt_text">
<td class="label">{$form.receipt_text.label}</td>
<td><span class="description">
{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}
</span><br />
{$form.receipt_text.html|crmAddClass:huge}
</td>
</tr>
</table>
</fieldset>
{/if}
<fieldset>
<table class="form-layout">
<tr class="crm-participant-form-block-note">
<td class="label">{$form.note.label}</td><td>{$form.note.html}</td>
</tr>
</table>
</fieldset>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
{if $email}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="send_receipt"
trigger_value =""
target_element_id ="notice"
target_element_type ="table-row"
field_type ="radio"
invert = 0
}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="send_receipt"
trigger_value =""
target_element_id ="from-email"
target_element_type ="table-row"
field_type ="radio"
invert = 0
}
{/if}
{literal}
<script type='text/javascript'>
CRM.$(function($) {
var $form = $('form.{/literal}{$form.formClass}{literal}');
cj('.total_amount-section').remove();
cj($form).submit(function(e) {
var partiallyPaid = {/literal}{$partiallyPaid}{literal};
var pendingRefund = {/literal}{$pendingRefund}{literal};
var statusId = cj('#status_id').val();
var statusLabel = cj('#status_id option:selected').text();
var balanceFee = cj('#balance-fee').text();
// fee actually paid
var feePaid = {/literal}{$feePaid}{literal};
balanceFee = parseFloat(balanceFee.replace(/[^0-9-.]/g, ''));
if ((balanceFee > 0 && feePaid != 0) && statusId != partiallyPaid) {
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.');
if (result == false) {
e.preventDefault();
}
}
else if ((balanceFee < 0 && feePaid != 0) && statusId != pendingRefund) {
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');
if (result == false) {
e.preventDefault();
}
}
});
});
</script>
{/literal}