CRM-13863 - Get rid of double title for forms that use popups
[civicrm-core.git] / templates / CRM / Event / Form / Participant.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
819d0d41 3 | CiviCRM version 4.5 |
6a488035 4 +--------------------------------------------------------------------+
819d0d41 5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 ) {
125 cj('#validate_pricefield').show().html("<span class='icon red-icon alert-icon'></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 }
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
81f3d017 154 cj('#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
CW
172
173{* Ajax callback for custom data snippet *}
29c61b58 174{elseif $cdType}
6a488035 175 {include file="CRM/Custom/Form/CustomData.tpl"}
1beb268a
CW
176
177{* Main event form template *}
6a488035
TO
178{else}
179 {if $participantMode == 'test' }
180 {assign var=registerMode value="TEST"}
181 {elseif $participantMode == 'live'}
182 {assign var=registerMode value="LIVE"}
183 {/if}
6a488035
TO
184 <div class="crm-block crm-form-block crm-participant-form-block">
185 <div class="view-content">
186 {if $participantMode}
187 <div id="help">
188 {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}
189 </div>
190 {/if}
191 <div id="eventFullMsg" class="messages status no-popup" style="display:none;"></div>
192
193
194 {if $action eq 1 AND $paid}
195 <div id="help">
196 {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}
197 </div>
198 {/if}
199
200 {if $action eq 8} {* If action is Delete *}
6a488035
TO
201 <div class="crm-participant-form-block-delete messages status no-popup">
202 <div class="crm-content">
203 <div class="icon inform-icon"></div> &nbsp;
204 {ts}WARNING: Deleting this registration will result in the loss of related payment records (if any).{/ts} {ts}Do you want to continue?{/ts}
205 </div>
206 {if $additionalParticipant}
207 <div class="crm-content">
208 {ts 1=$additionalParticipant} There are %1 more Participant(s) registered by this participant.{/ts}
209 </div>
210 {/if}
211 </div>
212 {if $additionalParticipant}
213 {$form.delete_participant.html}
214 {/if}
215 {else} {* If action is other than Delete *}
216 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
217 <table class="form-layout-compressed">
218 {if $single and $context neq 'standalone'}
219 <tr class="crm-participant-form-block-displayName">
220 <td class="label font-size12pt"><label>{ts}Participant{/ts}</label></td>
221 <td class="font-size12pt view-value">{$displayName}&nbsp;</td>
222 </tr>
223 {else}
479696ed
CW
224 <tr class="crm-participant-form-contact-id">
225 <td class="label">{$form.contact_id.label}</td>
226 <td>{$form.contact_id.html}</td>
227 </tr>
6a488035
TO
228 {/if}
229 {if $action EQ 2}
230 {if $additionalParticipants} {* Display others registered by this participant *}
231 <tr class="crm-participant-form-block-additionalParticipants">
232 <td class="label"><label>{ts}Also Registered by this Participant{/ts}</label></td>
233 <td>
234 {foreach from=$additionalParticipants key=apName item=apURL}
235 <a href="{$apURL}" title="{ts}view additional participant{/ts}">{$apName}</a><br />
236 {/foreach}
237 </td>
238 </tr>
239 {/if}
240 {if $registered_by_contact_id}
241 <tr class="crm-participant-form-block-registered-by">
242 <td class="label"><label>{ts}Registered By{/ts}</label></td>
243 <td class="view-value">
244 <a href="{crmURL p='civicrm/contact/view/participant' q="reset=1&id=$participant_registered_by_id&cid=$registered_by_contact_id&action=view"}"
245 title="{ts}view primary participant{/ts}">{$registered_by_display_name}</a>
246 </td>
247 </tr>
248 {/if}
249 {/if}
250 {if $participantMode}
251 <tr class="crm-participant-form-block-payment_processor_id">
252 <td class="label nowrap">{$form.payment_processor_id.label}</td>
253 <td>{$form.payment_processor_id.html}</td>
254 </tr>
255 {/if}
256 <tr class="crm-participant-form-block-event_id">
1beb268a
CW
257 <td class="label">{$form.event_id.label}</td>
258 <td class="view-value">
259 {$form.event_id.html}
260 {if $is_test}
261 {ts}(test){/ts}
262 {/if}
263 </td>
6a488035
TO
264 </tr>
265
266 {* CRM-7362 --add campaign *}
1beb268a 267 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-participant-form-block-campaign_id"}
6a488035
TO
268
269 <tr class="crm-participant-form-block-role_id">
270 <td class="label">{$form.role_id.label}</td>
271 <td>{$form.role_id.html}</td>
272 </tr>
273 <tr class="crm-participant-form-block-register_date">
274 <td class="label">{$form.register_date.label}</td>
275 <td>
276 {if $hideCalendar neq true}
277 {include file="CRM/common/jcalendar.tpl" elementName=register_date}
278 {else}
d32858b8 279 {$form.register_date.value|crmDate}
6a488035
TO
280 {/if}
281 </td>
282 </tr>
283 <tr class="crm-participant-form-block-status_id">
284 <td class="label">{$form.status_id.label}</td>
285 <td>{$form.status_id.html}{if $event_is_test} {ts}(test){/ts}{/if}
286 <div id="notify">{$form.is_notify.html}{$form.is_notify.label}</div>
287 </td>
288 </tr>
289 <tr class="crm-participant-form-block-source">
290 <td class="label">{$form.source.label}</td><td>{$form.source.html|crmAddClass:huge}<br />
291 <span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td>
292 </tr>
293 </table>
0b2b58ea 294 {if $participantId and $hasPayment}
29c61b58
PJ
295 <table class='form-layout'>
296 <tr>
297 <td class='label'>{ts}Fees{/ts}</td>
298 {* this is where the payment info is shown using CRM/Contribute/Page/PaymentInfo.tpl tpl*}
299 <td id='payment-info'></td>
300 </tr>
301 </table>
302 {/if}
6a488035
TO
303 {* Fee block (EventFees.tpl) is injected here when an event is selected. *}
304 <div id="feeBlock"></div>
305 <fieldset>
306 <table class="form-layout">
307 <tr class="crm-participant-form-block-note">
308 <td class="label">{$form.note.label}</td><td>{$form.note.html}</td>
309 </tr>
310 </table>
311 </fieldset>
312
313 <div class="crm-participant-form-block-customData">
314 <div id="customData" class="crm-customData-block"></div> {* Participant Custom data *}
315 <div id="customData{$eventNameCustomDataTypeID}" class="crm-customData-block"></div> {* Event Custom Data *}
316 <div id="customData{$roleCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
317 <div id="customData{$eventTypeCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
318 </div>
319 {/if}
320
321 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
322 {include file="CRM/Contribute/Form/Selector.tpl" context="Search"}
323 {/if}
324
325 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
326 </div>
327 </div>
1beb268a 328 {* JS block for ADD or UPDATE actions only *}
6a488035 329 {if $action eq 1 or $action eq 2}
0b2b58ea 330 {if $participantId and $hasPayment}
dfbeebc5
PJ
331 {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
332 {/if}
b1ea2569
PJ
333
334 {*include custom data js file*}
335 {include file="CRM/common/customData.tpl"}
336
6a488035 337 <script type="text/javascript">
1beb268a 338 {literal}
3cc60a06 339 CRM.$(function($) {
82a54c66 340
1beb268a 341 var $form = $('form#{/literal}{$form.formName}{literal}');
6a488035 342
f6bae84f 343 // don't show cart related statuses if it's disabled
372ad74d
PJ
344 {/literal}{if !$enableCart}{literal}
345 var pendingInCartStatusId = {/literal}{$pendingInCartStatusId}{literal};
346 $("#status_id option[value='" + pendingInCartStatusId + "']").remove();
347 {/literal}{/if}{literal}
348
349 {/literal}{if $action eq 1}{literal}
350 var pendingRefundStatusId = {/literal}{$pendingRefundStatusId}{literal};
351 $("#status_id option[value='" + pendingRefundStatusId + "']").remove();
352 {/literal}{/if}{literal}
f6bae84f 353
1beb268a
CW
354 // Handle event selection
355 $('#event_id', $form).change(function() {
356 var eventId = $(this).val();
357 if (!eventId) {
358 return;
359 }
360 var info = $(this).select2('data').extra;
6a488035 361
1beb268a 362 // Set role from default
cd120ea0 363 $('select[name^=role_id]', $form).select2('val', [info.default_role_id], true);
6a488035 364
1beb268a
CW
365 // Set campaign default
366 $('#campaign_id', $form).select2('val', info.campaign_id);
6a488035 367
1beb268a
CW
368 // Event and event-type custom data
369 CRM.buildCustomData('Participant', eventId, {/literal}{$eventNameCustomDataTypeID}{literal});
370 CRM.buildCustomData('Participant', info.event_type_id, {/literal}{$eventTypeCustomDataTypeID}{literal});
6a488035 371
1beb268a
CW
372 buildFeeBlock();
373 });
6a488035 374
1beb268a 375 // Handle participant role selection
cd120ea0
CW
376 $('select[name^=role_id]', $form).change(buildRoleCustomData);
377 if ($('select[name^=role_id]', $form).val()) {
378 buildRoleCustomData();
379 }
6a488035 380
1beb268a 381 buildFeeBlock();
6a488035 382
1beb268a
CW
383 //build discount block
384 if ($('#discount_id', $form).val()) {
385 buildFeeBlock($('#discount_id', $form).val());
386 }
6a488035 387
cd120ea0 388 function buildRoleCustomData() {
b4db8847 389 var roleId = $('select[name^=role_id]', $form).val().join();
cd120ea0
CW
390 CRM.buildCustomData('Participant', roleId, {/literal}{$roleCustomDataTypeID}{literal});
391 }
392
1beb268a
CW
393 //build fee block
394 function buildFeeBlock(discountId) {
395 var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q="snippet=4&qfKey=$qfKey"}";
6a488035 396
1beb268a
CW
397 {if $urlPathVar}
398 dataUrl += '&' + '{$urlPathVar}';
399 {/if}
6a488035 400
1beb268a
CW
401 {literal}
402 var eventId = $('#event_id').val();
d5397f2f
PJ
403
404 {/literal}{if $action eq 2}{literal}
405 if (typeof eventId == 'undefined') {
406 var eventId = $('[name=event_id]').val();
407 }
408 {/literal}{/if}{literal}
6a488035 409
1beb268a
CW
410 if (eventId) {
411 dataUrl += '&eventId=' + eventId;
412 }
413 else {
414 $('#eventFullMsg').hide( );
415 $('#feeBlock').html('');
416 return;
417 }
6a488035 418
1beb268a 419 var participantId = "{/literal}{$participantId}{literal}";
6a488035 420
1beb268a
CW
421 if (participantId) {
422 dataUrl += '&participantId=' + participantId;
423 }
6a488035 424
1beb268a
CW
425 if (discountId) {
426 dataUrl += '&discountId=' + discountId;
427 }
6a488035 428
b6c15d8a 429 $.ajax({
1beb268a 430 url: dataUrl,
1beb268a 431 success: function ( html ) {
b22f0cad 432 $("#feeBlock").html( html ).trigger('crmLoad');
1beb268a
CW
433 }
434 });
6a488035 435
b6c15d8a
CW
436 $("#feeBlock").ajaxStart(function(){
437 $(".disable-buttons input").prop('disabled', true);
1beb268a 438 });
6a488035 439
b6c15d8a
CW
440 $("#feeBlock").ajaxStop(function(){
441 $(".disable-buttons input").prop('disabled', false);
1beb268a 442 });
6a488035 443
1beb268a 444 //show event real full as well as waiting list message.
b6c15d8a
CW
445 if ( $("#hidden_eventFullMsg").val( ) ) {
446 $( "#eventFullMsg" ).show( ).html( $("#hidden_eventFullMsg" ).val( ) );
1beb268a
CW
447 }
448 else {
b6c15d8a 449 $( "#eventFullMsg" ).hide( );
6a488035
TO
450 }
451 }
1beb268a 452
b6c15d8a
CW
453 {/literal}
454 CRM.buildCustomData( '{$customDataType}', 'null', 'null' );
455 {if $eventID}
456 CRM.buildCustomData( '{$customDataType}', {$eventID}, {$eventNameCustomDataTypeID} );
457 {/if}
458 {if $eventTypeID}
459 CRM.buildCustomData( '{$customDataType}', {$eventTypeID}, {$eventTypeCustomDataTypeID} );
460 {/if}
461 {literal}
6a488035 462
1beb268a 463 });
6a488035
TO
464 </script>
465 {/literal}
466
467 {/if}
468
6a488035 469
6a488035
TO
470<script type="text/javascript">
471 {literal}
453ed6d1 472
6a488035 473 sendNotification();
453ed6d1
KJ
474 function sendNotification() {
475 var notificationStatusIds = {/literal}"{$notificationStatusIds}"{literal};
476 notificationStatusIds = notificationStatusIds.split(',');
477 if (cj.inArray(cj('select#status_id option:selected').val(), notificationStatusIds) > -1) {
6a488035 478 cj("#notify").show();
8539f25d 479 cj("#is_notify").prop('checked', true);
453ed6d1
KJ
480 }
481 else {
482 cj("#notify").hide();
8539f25d 483 cj("#is_notify").prop('checked', false);
6a488035
TO
484 }
485 }
486
6a488035 487 {/literal}
6a488035 488</script>
6a488035 489
453ed6d1
KJ
490{/if} {* end of main event block*}
491