Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
e7112fa7 | 5 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
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 for adding/editing/deleting offline Event Registrations *} | |
1beb268a CW |
27 | |
28 | {* Ajax callback for showing event fee snippet *} | |
bc2eeabb | 29 | {if $showFeeBlock} |
6a488035 TO |
30 | {if $priceSet} |
31 | <div id='validate_pricefield' class='messages crm-error hiddenElement'></div> | |
32 | {literal} | |
33 | <script type="text/javascript"> | |
34 | ||
ae8f569f | 35 | var fieldOptionsFull = []; |
6a488035 TO |
36 | {/literal} |
37 | {foreach from=$priceSet.fields item=fldElement key=fldId} | |
38 | {if $fldElement.options} | |
39 | {foreach from=$fldElement.options item=fldOptions key=opId} | |
40 | {if $fldOptions.is_full} | |
41 | {literal} | |
ae8f569f | 42 | fieldOptionsFull[{/literal}{$fldId}{literal}] = []; |
6a488035 TO |
43 | fieldOptionsFull[{/literal}{$fldId}{literal}][{/literal}{$opId}{literal}] = 1; |
44 | {/literal} | |
45 | {/if} | |
46 | {/foreach} | |
47 | {/if} | |
48 | {/foreach} | |
49 | {literal} | |
50 | ||
51 | if ( fieldOptionsFull.length > 0 ) { | |
3cc60a06 | 52 | CRM.$(function($) { |
ae8f569f CW |
53 | $("input,#priceset select,#priceset").each(function () { |
54 | if ( $(this).attr('price') ) { | |
55 | switch( $(this).attr('type') ) { | |
6a488035 TO |
56 | case 'checkbox': |
57 | case 'radio': | |
ae8f569f | 58 | $(this).click( function() { |
6a488035 TO |
59 | validatePriceField(this); |
60 | }); | |
61 | break; | |
62 | ||
63 | case 'select-one': | |
ae8f569f | 64 | $(this).change( function() { |
6a488035 TO |
65 | validatePriceField(this); |
66 | }); | |
67 | break; | |
68 | case 'text': | |
ae8f569f | 69 | $(this).bind( 'keyup', function() { validatePriceField(this) }); |
6a488035 TO |
70 | break; |
71 | } | |
72 | } | |
73 | }); | |
74 | }); | |
75 | ||
76 | function validatePriceField( obj ) { | |
77 | var namePart = cj(obj).attr('name').split('_'); | |
78 | var fldVal = cj(obj).val(); | |
79 | if ( cj(obj).attr('type') == 'checkbox') { | |
80 | var eleIdpart = namePart[1].split('['); | |
81 | var eleId = eleIdpart[0]; | |
82 | } | |
83 | else { | |
84 | var eleId = namePart[1]; | |
85 | } | |
86 | var showError = false; | |
87 | ||
88 | switch( cj(obj).attr('type') ) { | |
89 | case 'text': | |
90 | if ( fieldOptionsFull[eleId] && fldVal ) { | |
91 | showError = true; | |
92 | cj(obj).parent( ).parent( ).children('.label').addClass('crm-error'); | |
93 | } | |
94 | else { | |
95 | cj(obj).parent( ).parent( ).children('.label').removeClass('crm-error'); | |
96 | cj('#validate_pricefield').hide( ).html(''); | |
97 | } | |
98 | break; | |
99 | ||
100 | case 'checkbox': | |
101 | var checkBoxValue = eleIdpart[1].split(']'); | |
8539f25d | 102 | if ( cj(obj).prop("checked") == true && |
6a488035 TO |
103 | fieldOptionsFull[eleId] && |
104 | fieldOptionsFull[eleId][checkBoxValue[0]]) { | |
105 | showError = true; | |
106 | cj(obj).parent( ).addClass('crm-error'); | |
107 | } | |
108 | else { | |
109 | cj(obj).parent( ).removeClass('crm-error'); | |
110 | } | |
111 | break; | |
112 | ||
113 | default: | |
114 | if ( fieldOptionsFull[eleId] && | |
115 | fieldOptionsFull[eleId][fldVal] ) { | |
116 | showError = true; | |
117 | cj(obj).parent( ).addClass('crm-error'); | |
118 | } | |
119 | else { | |
120 | cj(obj).parent( ).removeClass('crm-error'); | |
121 | } | |
122 | } | |
123 | ||
124 | if ( showError ) { | |
52604b19 | 125 | cj('#validate_pricefield').show().html("<span class='icon red-icon ui-icon-alert'></span>{/literal}{ts escape='js'}This Option is already full for this event.{/ts}{literal}"); |
6a488035 TO |
126 | } |
127 | else { | |
128 | cj('#validate_pricefield').hide( ).html(''); | |
129 | } | |
130 | } | |
131 | } | |
59e44db1 PJ |
132 | |
133 | // change the status to default 'partially paid' for partial payments | |
b6c15d8a | 134 | var feeAmount, userModifiedAmount; |
81f3d017 | 135 | var partiallyPaidStatusId = {/literal}{$partiallyPaidStatusId}{literal}; |
59e44db1 PJ |
136 | |
137 | cj('#total_amount') | |
138 | .focus( | |
139 | function() { | |
140 | feeAmount = cj(this).val(); | |
141 | feeAmount = parseInt(feeAmount); | |
142 | } | |
143 | ) | |
144 | .change( | |
145 | function() { | |
146 | userModifiedAmount = cj(this).val(); | |
147 | userModifiedAmount = parseInt(userModifiedAmount); | |
148 | if (userModifiedAmount < feeAmount) { | |
f5bb53b8 | 149 | cj('#status_id').val(partiallyPaidStatusId).change(); |
59e44db1 PJ |
150 | } |
151 | } | |
152 | ); | |
153 | ||
b50fdacc | 154 | cj('form[name=Participant]').on("click", '.validate', |
59e44db1 PJ |
155 | function(e) { |
156 | var userSubmittedStatus = cj('#status_id').val(); | |
157 | var statusLabel = cj('#status_id option:selected').text(); | |
81f3d017 PJ |
158 | if (userModifiedAmount < feeAmount && userSubmittedStatus != partiallyPaidStatusId) { |
159 | var msg = "{/literal}{ts escape="js" 1="%1"}Payment amount is less than the amount owed. Expected participant status is 'Partially paid'. Are you sure you want to set the participant status to %1? Click OK to continue, Cancel to change your entries.{/ts}{literal}"; | |
160 | var result = confirm(ts(msg, {1: statusLabel})); | |
59e44db1 | 161 | if (result == false) { |
81f3d017 | 162 | return false; |
59e44db1 PJ |
163 | } |
164 | } | |
165 | } | |
166 | ); | |
6a488035 TO |
167 | </script> |
168 | {/literal} | |
169 | {/if} | |
d5397f2f | 170 | |
6a488035 | 171 | {include file="CRM/Event/Form/EventFees.tpl"} |
1beb268a | 172 | |
1beb268a | 173 | {* Main event form template *} |
6a488035 TO |
174 | {else} |
175 | {if $participantMode == 'test' } | |
176 | {assign var=registerMode value="TEST"} | |
177 | {elseif $participantMode == 'live'} | |
178 | {assign var=registerMode value="LIVE"} | |
179 | {/if} | |
6a488035 TO |
180 | <div class="crm-block crm-form-block crm-participant-form-block"> |
181 | <div class="view-content"> | |
182 | {if $participantMode} | |
183 | <div id="help"> | |
184 | {ts 1=$displayName 2=$registerMode}Use this form to submit an event registration on behalf of %1. <strong>A %2 transaction will be submitted</strong> using the selected payment processor.{/ts} | |
185 | </div> | |
186 | {/if} | |
187 | <div id="eventFullMsg" class="messages status no-popup" style="display:none;"></div> | |
188 | ||
189 | ||
190 | {if $action eq 1 AND $paid} | |
191 | <div id="help"> | |
192 | {ts}If you are accepting offline payment from this participant, check <strong>Record Payment</strong>. You will be able to fill in the payment information, and optionally send a receipt.{/ts} | |
193 | </div> | |
194 | {/if} | |
195 | ||
196 | {if $action eq 8} {* If action is Delete *} | |
6a488035 TO |
197 | <div class="crm-participant-form-block-delete messages status no-popup"> |
198 | <div class="crm-content"> | |
199 | <div class="icon inform-icon"></div> | |
200 | {ts}WARNING: Deleting this registration will result in the loss of related payment records (if any).{/ts} {ts}Do you want to continue?{/ts} | |
201 | </div> | |
202 | {if $additionalParticipant} | |
203 | <div class="crm-content"> | |
204 | {ts 1=$additionalParticipant} There are %1 more Participant(s) registered by this participant.{/ts} | |
205 | </div> | |
206 | {/if} | |
207 | </div> | |
208 | {if $additionalParticipant} | |
209 | {$form.delete_participant.html} | |
210 | {/if} | |
211 | {else} {* If action is other than Delete *} | |
212 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div> | |
213 | <table class="form-layout-compressed"> | |
214 | {if $single and $context neq 'standalone'} | |
215 | <tr class="crm-participant-form-block-displayName"> | |
216 | <td class="label font-size12pt"><label>{ts}Participant{/ts}</label></td> | |
217 | <td class="font-size12pt view-value">{$displayName} </td> | |
218 | </tr> | |
219 | {else} | |
479696ed CW |
220 | <tr class="crm-participant-form-contact-id"> |
221 | <td class="label">{$form.contact_id.label}</td> | |
222 | <td>{$form.contact_id.html}</td> | |
223 | </tr> | |
6a488035 TO |
224 | {/if} |
225 | {if $action EQ 2} | |
226 | {if $additionalParticipants} {* Display others registered by this participant *} | |
227 | <tr class="crm-participant-form-block-additionalParticipants"> | |
228 | <td class="label"><label>{ts}Also Registered by this Participant{/ts}</label></td> | |
229 | <td> | |
230 | {foreach from=$additionalParticipants key=apName item=apURL} | |
231 | <a href="{$apURL}" title="{ts}view additional participant{/ts}">{$apName}</a><br /> | |
232 | {/foreach} | |
233 | </td> | |
234 | </tr> | |
235 | {/if} | |
236 | {if $registered_by_contact_id} | |
237 | <tr class="crm-participant-form-block-registered-by"> | |
238 | <td class="label"><label>{ts}Registered By{/ts}</label></td> | |
239 | <td class="view-value"> | |
240 | <a href="{crmURL p='civicrm/contact/view/participant' q="reset=1&id=$participant_registered_by_id&cid=$registered_by_contact_id&action=view"}" | |
241 | title="{ts}view primary participant{/ts}">{$registered_by_display_name}</a> | |
242 | </td> | |
243 | </tr> | |
244 | {/if} | |
245 | {/if} | |
246 | {if $participantMode} | |
247 | <tr class="crm-participant-form-block-payment_processor_id"> | |
248 | <td class="label nowrap">{$form.payment_processor_id.label}</td> | |
249 | <td>{$form.payment_processor_id.html}</td> | |
250 | </tr> | |
251 | {/if} | |
252 | <tr class="crm-participant-form-block-event_id"> | |
1beb268a CW |
253 | <td class="label">{$form.event_id.label}</td> |
254 | <td class="view-value"> | |
255 | {$form.event_id.html} | |
256 | {if $is_test} | |
257 | {ts}(test){/ts} | |
258 | {/if} | |
259 | </td> | |
6a488035 TO |
260 | </tr> |
261 | ||
262 | {* CRM-7362 --add campaign *} | |
1beb268a | 263 | {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-participant-form-block-campaign_id"} |
6a488035 TO |
264 | |
265 | <tr class="crm-participant-form-block-role_id"> | |
266 | <td class="label">{$form.role_id.label}</td> | |
267 | <td>{$form.role_id.html}</td> | |
268 | </tr> | |
269 | <tr class="crm-participant-form-block-register_date"> | |
270 | <td class="label">{$form.register_date.label}</td> | |
271 | <td> | |
272 | {if $hideCalendar neq true} | |
273 | {include file="CRM/common/jcalendar.tpl" elementName=register_date} | |
274 | {else} | |
d32858b8 | 275 | {$form.register_date.value|crmDate} |
6a488035 TO |
276 | {/if} |
277 | </td> | |
278 | </tr> | |
279 | <tr class="crm-participant-form-block-status_id"> | |
280 | <td class="label">{$form.status_id.label}</td> | |
281 | <td>{$form.status_id.html}{if $event_is_test} {ts}(test){/ts}{/if} | |
282 | <div id="notify">{$form.is_notify.html}{$form.is_notify.label}</div> | |
283 | </td> | |
284 | </tr> | |
285 | <tr class="crm-participant-form-block-source"> | |
286 | <td class="label">{$form.source.label}</td><td>{$form.source.html|crmAddClass:huge}<br /> | |
287 | <span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td> | |
288 | </tr> | |
289 | </table> | |
0b2b58ea | 290 | {if $participantId and $hasPayment} |
29c61b58 PJ |
291 | <table class='form-layout'> |
292 | <tr> | |
293 | <td class='label'>{ts}Fees{/ts}</td> | |
294 | {* this is where the payment info is shown using CRM/Contribute/Page/PaymentInfo.tpl tpl*} | |
295 | <td id='payment-info'></td> | |
296 | </tr> | |
297 | </table> | |
298 | {/if} | |
6a488035 | 299 | {* Fee block (EventFees.tpl) is injected here when an event is selected. *} |
ab421ec6 | 300 | <div class="crm-event-form-fee-block"></div> |
6a488035 TO |
301 | <fieldset> |
302 | <table class="form-layout"> | |
303 | <tr class="crm-participant-form-block-note"> | |
304 | <td class="label">{$form.note.label}</td><td>{$form.note.html}</td> | |
305 | </tr> | |
306 | </table> | |
307 | </fieldset> | |
308 | ||
309 | <div class="crm-participant-form-block-customData"> | |
310 | <div id="customData" class="crm-customData-block"></div> {* Participant Custom data *} | |
311 | <div id="customData{$eventNameCustomDataTypeID}" class="crm-customData-block"></div> {* Event Custom Data *} | |
312 | <div id="customData{$roleCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *} | |
313 | <div id="customData{$eventTypeCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *} | |
314 | </div> | |
315 | {/if} | |
316 | ||
317 | {if $accessContribution and $action eq 2 and $rows.0.contribution_id} | |
318 | {include file="CRM/Contribute/Form/Selector.tpl" context="Search"} | |
319 | {/if} | |
320 | ||
321 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
322 | </div> | |
323 | </div> | |
1beb268a | 324 | {* JS block for ADD or UPDATE actions only *} |
6a488035 | 325 | {if $action eq 1 or $action eq 2} |
0b2b58ea | 326 | {if $participantId and $hasPayment} |
dfbeebc5 PJ |
327 | {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'} |
328 | {/if} | |
b1ea2569 PJ |
329 | |
330 | {*include custom data js file*} | |
331 | {include file="CRM/common/customData.tpl"} | |
332 | ||
6a488035 | 333 | <script type="text/javascript"> |
1beb268a | 334 | {literal} |
3cc60a06 | 335 | CRM.$(function($) { |
82a54c66 | 336 | |
b50fdacc | 337 | var $form = $('form.{/literal}{$form.formClass}{literal}'); |
6a488035 | 338 | |
1beb268a CW |
339 | // Handle event selection |
340 | $('#event_id', $form).change(function() { | |
341 | var eventId = $(this).val(); | |
342 | if (!eventId) { | |
343 | return; | |
344 | } | |
345 | var info = $(this).select2('data').extra; | |
6a488035 | 346 | |
1beb268a | 347 | // Set role from default |
cd120ea0 | 348 | $('select[name^=role_id]', $form).select2('val', [info.default_role_id], true); |
6a488035 | 349 | |
1beb268a CW |
350 | // Set campaign default |
351 | $('#campaign_id', $form).select2('val', info.campaign_id); | |
6a488035 | 352 | |
1beb268a CW |
353 | // Event and event-type custom data |
354 | CRM.buildCustomData('Participant', eventId, {/literal}{$eventNameCustomDataTypeID}{literal}); | |
355 | CRM.buildCustomData('Participant', info.event_type_id, {/literal}{$eventTypeCustomDataTypeID}{literal}); | |
6a488035 | 356 | |
1beb268a CW |
357 | buildFeeBlock(); |
358 | }); | |
6a488035 | 359 | |
1beb268a | 360 | // Handle participant role selection |
cd120ea0 CW |
361 | $('select[name^=role_id]', $form).change(buildRoleCustomData); |
362 | if ($('select[name^=role_id]', $form).val()) { | |
363 | buildRoleCustomData(); | |
364 | } | |
6a488035 | 365 | |
1beb268a | 366 | buildFeeBlock(); |
6a488035 | 367 | |
1beb268a CW |
368 | //build discount block |
369 | if ($('#discount_id', $form).val()) { | |
370 | buildFeeBlock($('#discount_id', $form).val()); | |
371 | } | |
95e7a695 CW |
372 | $($form).on('change', '#discount_id', function() { |
373 | buildFeeBlock($(this).val()); | |
374 | }); | |
6a488035 | 375 | |
cd120ea0 | 376 | function buildRoleCustomData() { |
b4db8847 | 377 | var roleId = $('select[name^=role_id]', $form).val().join(); |
cd120ea0 CW |
378 | CRM.buildCustomData('Participant', roleId, {/literal}{$roleCustomDataTypeID}{literal}); |
379 | } | |
380 | ||
1beb268a CW |
381 | //build fee block |
382 | function buildFeeBlock(discountId) { | |
383 | var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q="snippet=4&qfKey=$qfKey"}"; | |
6a488035 | 384 | |
1beb268a CW |
385 | {if $urlPathVar} |
386 | dataUrl += '&' + '{$urlPathVar}'; | |
387 | {/if} | |
6a488035 | 388 | |
1beb268a | 389 | {literal} |
ab421ec6 | 390 | var eventId = $('[name=event_id], #event_id', $form).val(); |
6a488035 | 391 | |
1beb268a CW |
392 | if (eventId) { |
393 | dataUrl += '&eventId=' + eventId; | |
394 | } | |
395 | else { | |
ab421ec6 CW |
396 | $('#eventFullMsg', $form).hide( ); |
397 | $('.crm-event-form-fee-block', $form).html(''); | |
1beb268a CW |
398 | return; |
399 | } | |
6a488035 | 400 | |
1beb268a | 401 | var participantId = "{/literal}{$participantId}{literal}"; |
6a488035 | 402 | |
1beb268a CW |
403 | if (participantId) { |
404 | dataUrl += '&participantId=' + participantId; | |
405 | } | |
6a488035 | 406 | |
1beb268a CW |
407 | if (discountId) { |
408 | dataUrl += '&discountId=' + discountId; | |
409 | } | |
6a488035 | 410 | |
b6c15d8a | 411 | $.ajax({ |
1beb268a | 412 | url: dataUrl, |
1beb268a | 413 | success: function ( html ) { |
ab421ec6 | 414 | $(".crm-event-form-fee-block", $form).html( html ).trigger('crmLoad'); |
5be1890a | 415 | //show event real full as well as waiting list message. |
ab421ec6 CW |
416 | if ( $("#hidden_eventFullMsg", $form).val( ) ) { |
417 | $( "#eventFullMsg", $form).show( ).html( $("#hidden_eventFullMsg", $form).val( ) ); | |
5be1890a CW |
418 | } |
419 | else { | |
ab421ec6 | 420 | $( "#eventFullMsg", $form ).hide( ); |
5be1890a | 421 | } |
1beb268a CW |
422 | } |
423 | }); | |
6a488035 | 424 | } |
1beb268a | 425 | |
b6c15d8a CW |
426 | {/literal} |
427 | CRM.buildCustomData( '{$customDataType}', 'null', 'null' ); | |
428 | {if $eventID} | |
429 | CRM.buildCustomData( '{$customDataType}', {$eventID}, {$eventNameCustomDataTypeID} ); | |
430 | {/if} | |
431 | {if $eventTypeID} | |
432 | CRM.buildCustomData( '{$customDataType}', {$eventTypeID}, {$eventTypeCustomDataTypeID} ); | |
433 | {/if} | |
434 | {literal} | |
6a488035 | 435 | |
1beb268a | 436 | }); |
6a488035 TO |
437 | </script> |
438 | {/literal} | |
439 | ||
440 | {/if} | |
441 | ||
6a488035 | 442 | |
6a488035 TO |
443 | <script type="text/javascript"> |
444 | {literal} | |
453ed6d1 | 445 | |
6a488035 | 446 | sendNotification(); |
453ed6d1 KJ |
447 | function sendNotification() { |
448 | var notificationStatusIds = {/literal}"{$notificationStatusIds}"{literal}; | |
449 | notificationStatusIds = notificationStatusIds.split(','); | |
450 | if (cj.inArray(cj('select#status_id option:selected').val(), notificationStatusIds) > -1) { | |
6a488035 | 451 | cj("#notify").show(); |
8539f25d | 452 | cj("#is_notify").prop('checked', true); |
453ed6d1 KJ |
453 | } |
454 | else { | |
455 | cj("#notify").hide(); | |
8539f25d | 456 | cj("#is_notify").prop('checked', false); |
6a488035 TO |
457 | } |
458 | } | |
459 | ||
6a488035 | 460 | {/literal} |
6a488035 | 461 | </script> |
6a488035 | 462 | |
453ed6d1 KJ |
463 | {/if} {* end of main event block*} |
464 |