commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / templates / CRM / Event / Form / Participant.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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 *}
27
28 {* Ajax callback for showing event fee snippet *}
29 {if $showFeeBlock}
30 {if $priceSet}
31 <div id='validate_pricefield' class='messages crm-error hiddenElement'></div>
32 {literal}
33 <script type="text/javascript">
34
35 var fieldOptionsFull = [];
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}
42 fieldOptionsFull[{/literal}{$fldId}{literal}] = [];
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 ) {
52 CRM.$(function($) {
53 $("input,#priceset select,#priceset").each(function () {
54 if ( $(this).attr('price') ) {
55 switch( $(this).attr('type') ) {
56 case 'checkbox':
57 case 'radio':
58 $(this).click( function() {
59 validatePriceField(this);
60 });
61 break;
62
63 case 'select-one':
64 $(this).change( function() {
65 validatePriceField(this);
66 });
67 break;
68 case 'text':
69 $(this).bind( 'keyup', function() { validatePriceField(this) });
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(']');
102 if ( cj(obj).prop("checked") == true &&
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 ) {
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}");
126 }
127 else {
128 cj('#validate_pricefield').hide( ).html('');
129 }
130 }
131 }
132
133 // change the status to default 'partially paid' for partial payments
134 var feeAmount, userModifiedAmount;
135 var partiallyPaidStatusId = {/literal}{$partiallyPaidStatusId}{literal};
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) {
149 cj('#status_id').val(partiallyPaidStatusId).change();
150 }
151 }
152 );
153
154 cj('form[name=Participant]').on("click", '.validate',
155 function(e) {
156 if (CRM.$('#total_amount').length == 0) {
157 var $balance = CRM.$('#payment-info-balance');
158 if ($balance.length > 0 && parseFloat($balance.attr('data-balance')) == 0) {
159 return true;
160 }
161 }
162 var userSubmittedStatus = cj('#status_id').val();
163 var statusLabel = cj('#status_id option:selected').text();
164 if (userModifiedAmount < feeAmount && userSubmittedStatus != partiallyPaidStatusId) {
165 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}";
166 var result = confirm(ts(msg, {1: statusLabel}));
167 if (result == false) {
168 return false;
169 }
170 }
171 }
172 );
173 </script>
174 {/literal}
175 {/if}
176
177 {include file="CRM/Event/Form/EventFees.tpl"}
178
179 {* Ajax callback for custom data snippet *}
180 {elseif $cdType}
181 {include file="CRM/Custom/Form/CustomData.tpl"}
182
183 {* Main event form template *}
184 {else}
185 {if $participantMode == 'test' }
186 {assign var=registerMode value="TEST"}
187 {elseif $participantMode == 'live'}
188 {assign var=registerMode value="LIVE"}
189 {/if}
190 <div class="crm-block crm-form-block crm-participant-form-block">
191 <div class="view-content">
192 {if $participantMode}
193 <div id="help">
194 {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}
195 </div>
196 {/if}
197 <div id="eventFullMsg" class="messages status no-popup" style="display:none;"></div>
198
199
200 {if $action eq 1 AND $paid}
201 <div id="help">
202 {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}
203 </div>
204 {/if}
205
206 {if $action eq 8} {* If action is Delete *}
207 <div class="crm-participant-form-block-delete messages status no-popup">
208 <div class="crm-content">
209 <div class="icon inform-icon"></div> &nbsp;
210 {ts}WARNING: Deleting this registration will result in the loss of related payment records (if any).{/ts} {ts}Do you want to continue?{/ts}
211 </div>
212 {if $additionalParticipant}
213 <div class="crm-content">
214 {ts 1=$additionalParticipant} There are %1 more Participant(s) registered by this participant.{/ts}
215 </div>
216 {/if}
217 </div>
218 {if $additionalParticipant}
219 {$form.delete_participant.html}
220 {/if}
221 {else} {* If action is other than Delete *}
222 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
223 <table class="form-layout-compressed">
224 {if $single and $context neq 'standalone'}
225 <tr class="crm-participant-form-block-displayName">
226 <td class="label font-size12pt"><label>{ts}Participant{/ts}</label></td>
227 <td class="font-size12pt view-value">{$displayName}&nbsp;</td>
228 </tr>
229 {else}
230 <tr class="crm-participant-form-contact-id">
231 <td class="label">{$form.contact_id.label}</td>
232 <td>{$form.contact_id.html}</td>
233 </tr>
234 {/if}
235 {if $action EQ 2}
236 {if $additionalParticipants} {* Display others registered by this participant *}
237 <tr class="crm-participant-form-block-additionalParticipants">
238 <td class="label"><label>{ts}Also Registered by this Participant{/ts}</label></td>
239 <td>
240 {foreach from=$additionalParticipants key=apName item=apURL}
241 <a href="{$apURL}" title="{ts}view additional participant{/ts}">{$apName}</a><br />
242 {/foreach}
243 </td>
244 </tr>
245 {/if}
246 {if $registered_by_contact_id}
247 <tr class="crm-participant-form-block-registered-by">
248 <td class="label"><label>{ts}Registered By{/ts}</label></td>
249 <td class="view-value">
250 <a href="{crmURL p='civicrm/contact/view/participant' q="reset=1&id=$participant_registered_by_id&cid=$registered_by_contact_id&action=view"}"
251 title="{ts}view primary participant{/ts}">{$registered_by_display_name}</a>
252 </td>
253 </tr>
254 {/if}
255 {/if}
256 {if $participantMode}
257 <tr class="crm-participant-form-block-payment_processor_id">
258 <td class="label nowrap">{$form.payment_processor_id.label}</td>
259 <td>{$form.payment_processor_id.html}</td>
260 </tr>
261 {/if}
262 <tr class="crm-participant-form-block-event_id">
263 <td class="label">{$form.event_id.label}</td>
264 <td class="view-value">
265 {$form.event_id.html}
266 {if $is_test}
267 {ts}(test){/ts}
268 {/if}
269 </td>
270 </tr>
271
272 {* CRM-7362 --add campaign *}
273 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-participant-form-block-campaign_id"}
274
275 <tr class="crm-participant-form-block-role_id">
276 <td class="label">{$form.role_id.label}</td>
277 <td>{$form.role_id.html}</td>
278 </tr>
279 <tr class="crm-participant-form-block-register_date">
280 <td class="label">{$form.register_date.label}</td>
281 <td>
282 {if $hideCalendar neq true}
283 {include file="CRM/common/jcalendar.tpl" elementName=register_date}
284 {else}
285 {$form.register_date.value|crmDate}
286 {/if}
287 </td>
288 </tr>
289 <tr class="crm-participant-form-block-status_id">
290 <td class="label">{$form.status_id.label}</td>
291 <td>{$form.status_id.html}{if $event_is_test} {ts}(test){/ts}{/if}
292 <div id="notify">{$form.is_notify.html}{$form.is_notify.label}</div>
293 </td>
294 </tr>
295 <tr class="crm-participant-form-block-source">
296 <td class="label">{$form.source.label}</td><td>{$form.source.html|crmAddClass:huge}<br />
297 <span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td>
298 </tr>
299 </table>
300 {if $participantId and $hasPayment}
301 <table class='form-layout'>
302 <tr>
303 <td class='label'>{ts}Fees{/ts}</td>
304 {* this is where the payment info is shown using CRM/Contribute/Page/PaymentInfo.tpl tpl*}
305 <td id='payment-info'></td>
306 </tr>
307 </table>
308 {/if}
309 {* Fee block (EventFees.tpl) is injected here when an event is selected. *}
310 <div class="crm-event-form-fee-block"></div>
311 <fieldset>
312 <table class="form-layout">
313 <tr class="crm-participant-form-block-note">
314 <td class="label">{$form.note.label}</td><td>{$form.note.html}</td>
315 </tr>
316 </table>
317 </fieldset>
318
319 <div class="crm-participant-form-block-customData">
320 <div id="customData" class="crm-customData-block"></div> {* Participant Custom data *}
321 <div id="customData{$eventNameCustomDataTypeID}" class="crm-customData-block"></div> {* Event Custom Data *}
322 <div id="customData{$roleCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
323 <div id="customData{$eventTypeCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
324 </div>
325 {/if}
326
327 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
328 {include file="CRM/Contribute/Form/Selector.tpl" context="Search"}
329 {/if}
330
331 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
332 </div>
333 </div>
334 {* JS block for ADD or UPDATE actions only *}
335 {if $action eq 1 or $action eq 2}
336 {if $participantId and $hasPayment}
337 {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
338 {/if}
339
340 {*include custom data js file*}
341 {include file="CRM/common/customData.tpl"}
342
343 <script type="text/javascript">
344 {literal}
345 CRM.$(function($) {
346
347 var $form = $('form.{/literal}{$form.formClass}{literal}');
348
349 // Handle event selection
350 $('#event_id', $form).change(function() {
351 var eventId = $(this).val();
352 if (!eventId) {
353 return;
354 }
355 var info = $(this).select2('data').extra;
356
357 // Set role from default
358 $('select[name^=role_id]', $form).select2('val', [info.default_role_id], true);
359
360 // Set campaign default
361 $('#campaign_id', $form).select2('val', info.campaign_id);
362
363 // Event and event-type custom data
364 CRM.buildCustomData('Participant', eventId, {/literal}{$eventNameCustomDataTypeID}{literal});
365 CRM.buildCustomData('Participant', info.event_type_id, {/literal}{$eventTypeCustomDataTypeID}{literal});
366
367 buildFeeBlock();
368 });
369
370 // Handle participant role selection
371 $('select[name^=role_id]', $form).change(buildRoleCustomData);
372 if ($('select[name^=role_id]', $form).val()) {
373 buildRoleCustomData();
374 }
375
376 buildFeeBlock();
377
378 //build discount block
379 if ($('#discount_id', $form).val()) {
380 buildFeeBlock($('#discount_id', $form).val());
381 }
382 $($form).on('change', '#discount_id', function() {
383 buildFeeBlock($(this).val());
384 });
385
386 function buildRoleCustomData() {
387 var roleId = $('select[name^=role_id]', $form).val().join();
388 CRM.buildCustomData('Participant', roleId, {/literal}{$roleCustomDataTypeID}{literal});
389 }
390
391 //build fee block
392 function buildFeeBlock(discountId) {
393 var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q="snippet=4&qfKey=$qfKey"}";
394
395 {if $urlPathVar}
396 dataUrl += '&' + '{$urlPathVar}';
397 {/if}
398
399 {literal}
400 var eventId = $('[name=event_id], #event_id', $form).val();
401
402 if (eventId) {
403 dataUrl += '&eventId=' + eventId;
404 }
405 else {
406 $('#eventFullMsg', $form).hide( );
407 $('.crm-event-form-fee-block', $form).html('');
408 return;
409 }
410
411 var participantId = "{/literal}{$participantId}{literal}";
412
413 if (participantId) {
414 dataUrl += '&participantId=' + participantId;
415 }
416
417 if (discountId) {
418 dataUrl += '&discountId=' + discountId;
419 }
420
421 $.ajax({
422 url: dataUrl,
423 success: function ( html ) {
424 $(".crm-event-form-fee-block", $form).html( html ).trigger('crmLoad');
425 //show event real full as well as waiting list message.
426 if ( $("#hidden_eventFullMsg", $form).val( ) ) {
427 $( "#eventFullMsg", $form).show( ).html( $("#hidden_eventFullMsg", $form).val( ) );
428 }
429 else {
430 $( "#eventFullMsg", $form ).hide( );
431 }
432 }
433 });
434 }
435
436 {/literal}
437 CRM.buildCustomData( '{$customDataType}', 'null', 'null' );
438 {if $eventID}
439 CRM.buildCustomData( '{$customDataType}', {$eventID}, {$eventNameCustomDataTypeID} );
440 {/if}
441 {if $eventTypeID}
442 CRM.buildCustomData( '{$customDataType}', {$eventTypeID}, {$eventTypeCustomDataTypeID} );
443 {/if}
444 {literal}
445
446 });
447 </script>
448 {/literal}
449
450 {/if}
451
452
453 <script type="text/javascript">
454 {literal}
455
456 sendNotification();
457 function sendNotification() {
458 var notificationStatusIds = {/literal}"{$notificationStatusIds}"{literal};
459 notificationStatusIds = notificationStatusIds.split(',');
460 if (cj.inArray(cj('select#status_id option:selected').val(), notificationStatusIds) > -1) {
461 cj("#notify").show();
462 cj("#is_notify").prop('checked', true);
463 }
464 else {
465 cj("#notify").hide();
466 cj("#is_notify").prop('checked', false);
467 }
468 }
469
470 {/literal}
471 </script>
472
473 {/if} {* end of main event block*}
474