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