2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2016 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 {* This template is used for adding/editing/deleting offline Event Registrations *}
28 {* Ajax callback for showing event fee snippet *}
31 <div id='validate_pricefield' class='messages crm-error hiddenElement'></div>
33 <script type="text/javascript">
35 var fieldOptionsFull = [];
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}
42 fieldOptionsFull[{/literal}{$fldId}{literal}] = [];
43 fieldOptionsFull[{/literal}{$fldId}{literal}][{/literal}{$opId}{literal}] = 1;
51 if ( fieldOptionsFull.length > 0 ) {
53 $("input,#priceset select,#priceset").each(function () {
54 if ( $(this).attr('price') ) {
55 switch( $(this).attr('type') ) {
58 $(this).click( function() {
59 validatePriceField(this);
64 $(this).change( function() {
65 validatePriceField(this);
69 $(this).bind( 'keyup', function() { validatePriceField(this) });
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];
84 var eleId = namePart[1];
86 var showError = false;
88 switch( cj(obj).attr('type') ) {
90 if ( fieldOptionsFull[eleId] && fldVal ) {
92 cj(obj).parent( ).parent( ).children('.label').addClass('crm-error');
95 cj(obj).parent( ).parent( ).children('.label').removeClass('crm-error');
96 cj('#validate_pricefield').hide( ).html('');
101 var checkBoxValue = eleIdpart[1].split(']');
102 if ( cj(obj).prop("checked") == true &&
103 fieldOptionsFull[eleId] &&
104 fieldOptionsFull[eleId][checkBoxValue[0]]) {
106 cj(obj).parent( ).addClass('crm-error');
109 cj(obj).parent( ).removeClass('crm-error');
114 if ( fieldOptionsFull[eleId] &&
115 fieldOptionsFull[eleId][fldVal] ) {
117 cj(obj).parent( ).addClass('crm-error');
120 cj(obj).parent( ).removeClass('crm-error');
125 cj('#validate_pricefield').show().html('<i class="crm-i fa-exclamation-triangle crm-i-red"></i>{/literal} {ts escape='js'}This Option is already full for this event.{/ts}{literal}');
128 cj('#validate_pricefield').hide( ).html('');
133 // change the status to default 'partially paid' for partial payments
134 var feeAmount, userModifiedAmount;
135 var partiallyPaidStatusId = {/literal}{$partiallyPaidStatusId}{literal};
140 feeAmount = cj(this).val();
141 feeAmount = parseInt(feeAmount);
146 userModifiedAmount = cj(this).val();
147 userModifiedAmount = parseInt(userModifiedAmount);
148 if (userModifiedAmount < feeAmount) {
149 cj('#status_id').val(partiallyPaidStatusId).change();
154 cj('form[name=Participant]').on("click", '.validate',
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) {
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) {
177 {include file="CRM/Event/Form/EventFees.tpl"}
179 {* Main event form template *}
181 {if $participantMode == 'test' }
182 {assign var=registerMode value="TEST"}
183 {elseif $participantMode == 'live'}
184 {assign var=registerMode value="LIVE"}
186 <div class="crm-block crm-form-block crm-participant-form-block">
187 <div class="view-content">
188 {if $participantMode}
190 {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}
193 <div id="eventFullMsg" class="messages status no-popup" style="display:none;"></div>
196 {if $action eq 1 AND $paid}
198 {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}
202 {if $action eq 8} {* If action is Delete *}
203 <div class="crm-participant-form-block-delete messages status no-popup">
204 <div class="crm-content">
205 <div class="icon inform-icon"></div>
206 {ts}WARNING: Deleting this registration will result in the loss of related payment records (if any).{/ts} {ts}Do you want to continue?{/ts}
208 {if $additionalParticipant}
209 <div class="crm-content">
210 {ts 1=$additionalParticipant} There are %1 more Participant(s) registered by this participant.{/ts}
214 {if $additionalParticipant}
215 {$form.delete_participant.html}
217 {else} {* If action is other than Delete *}
218 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
219 <table class="form-layout-compressed">
220 {if $single and $context neq 'standalone'}
221 <tr class="crm-participant-form-block-displayName">
222 <td class="label font-size12pt"><label>{ts}Participant{/ts}</label></td>
223 <td class="font-size12pt view-value">{$displayName} </td>
226 <tr class="crm-participant-form-contact-id">
227 <td class="label">{$form.contact_id.label}</td>
228 <td>{$form.contact_id.html}</td>
232 {if $additionalParticipants} {* Display others registered by this participant *}
233 <tr class="crm-participant-form-block-additionalParticipants">
234 <td class="label"><label>{ts}Also Registered by this Participant{/ts}</label></td>
236 {foreach from=$additionalParticipants key=apName item=apURL}
237 <a href="{$apURL}" title="{ts}view additional participant{/ts}">{$apName}</a><br />
242 {if $registered_by_contact_id}
243 <tr class="crm-participant-form-block-registered-by">
244 <td class="label"><label>{ts}Registered By{/ts}</label></td>
245 <td class="view-value">
246 <a href="{crmURL p='civicrm/contact/view/participant' q="reset=1&id=$participant_registered_by_id&cid=$registered_by_contact_id&action=view"}"
247 title="{ts}view primary participant{/ts}">{$registered_by_display_name}</a>
252 {if $participantMode}
253 <tr class="crm-participant-form-block-payment_processor_id">
254 <td class="label nowrap">{$form.payment_processor_id.label}</td>
255 <td>{$form.payment_processor_id.html}</td>
258 <tr class="crm-participant-form-block-event_id">
259 <td class="label">{$form.event_id.label}</td>
260 <td class="view-value">
261 {$form.event_id.html}
268 {* CRM-7362 --add campaign *}
269 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-participant-form-block-campaign_id"}
271 <tr class="crm-participant-form-block-role_id">
272 <td class="label">{$form.role_id.label}</td>
273 <td>{$form.role_id.html}</td>
275 <tr class="crm-participant-form-block-register_date">
276 <td class="label">{$form.register_date.label}</td>
278 {if $hideCalendar neq true}
279 {include file="CRM/common/jcalendar.tpl" elementName=register_date}
281 {$form.register_date.value|crmDate}
285 <tr class="crm-participant-form-block-status_id">
286 <td class="label">{$form.status_id.label}</td>
287 <td>{$form.status_id.html}{if $event_is_test} {ts}(test){/ts}{/if}
288 <div id="notify">{$form.is_notify.html}{$form.is_notify.label}</div>
291 <tr class="crm-participant-form-block-source">
292 <td class="label">{$form.source.label}</td><td>{$form.source.html|crmAddClass:huge}<br />
293 <span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td>
296 {if $participantId and $hasPayment}
297 <table class='form-layout'>
299 <td class='label'>{ts}Fees{/ts}</td>
300 {* this is where the payment info is shown using CRM/Contribute/Page/PaymentInfo.tpl tpl*}
301 <td id='payment-info'></td>
305 {* Fee block (EventFees.tpl) is injected here when an event is selected. *}
306 <div class="crm-event-form-fee-block"></div>
308 <table class="form-layout">
309 <tr class="crm-participant-form-block-note">
310 <td class="label">{$form.note.label}</td><td>{$form.note.html}</td>
315 <div class="crm-participant-form-block-customData">
316 <div id="customData" class="crm-customData-block"></div> {* Participant Custom data *}
317 <div id="customData{$eventNameCustomDataTypeID}" class="crm-customData-block"></div> {* Event Custom Data *}
318 <div id="customData{$roleCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
319 <div id="customData{$eventTypeCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
323 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
324 {include file="CRM/Contribute/Form/Selector.tpl" context="Search"}
327 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
330 {* JS block for ADD or UPDATE actions only *}
331 {if $action eq 1 or $action eq 2}
332 {if $participantId and $hasPayment}
333 {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='payments'}
336 {*include custom data js file*}
337 {include file="CRM/common/customData.tpl"}
339 <script type="text/javascript">
343 var $form = $('form.{/literal}{$form.formClass}{literal}');
345 // Handle event selection
346 $('#event_id', $form).change(function() {
347 var eventId = $(this).val();
351 var info = $(this).select2('data').extra;
353 // Set role from default
354 $('select[name^=role_id]', $form).select2('val', [info.default_role_id], true);
356 // Set campaign default
357 $('#campaign_id', $form).select2('val', info.campaign_id);
359 // Event and event-type custom data
360 CRM.buildCustomData('Participant', eventId, {/literal}{$eventNameCustomDataTypeID}{literal});
361 CRM.buildCustomData('Participant', info.event_type_id, {/literal}{$eventTypeCustomDataTypeID}{literal});
366 // Handle participant role selection
367 $('select[name^=role_id]', $form).change(buildRoleCustomData);
368 if ($('select[name^=role_id]', $form).val()) {
369 buildRoleCustomData();
374 //build discount block
375 if ($('#discount_id', $form).val()) {
376 buildFeeBlock($('#discount_id', $form).val());
378 $($form).on('change', '#discount_id', function() {
379 buildFeeBlock($(this).val());
382 function buildRoleCustomData() {
383 var roleId = $('select[name^=role_id]', $form).val() || [];
384 CRM.buildCustomData('Participant', roleId.join(), {/literal}{$roleCustomDataTypeID}{literal});
388 function buildFeeBlock(discountId) {
389 var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q="snippet=4&qfKey=$qfKey"}";
392 dataUrl += '&' + '{$urlPathVar}';
396 var eventId = $('[name=event_id], #event_id', $form).val();
399 dataUrl += '&eventId=' + eventId;
402 $('#eventFullMsg', $form).hide( );
403 $('.crm-event-form-fee-block', $form).html('');
407 var participantId = "{/literal}{$participantId}{literal}";
410 dataUrl += '&participantId=' + participantId;
414 dataUrl += '&discountId=' + discountId;
419 success: function ( html ) {
420 $(".crm-event-form-fee-block", $form).html( html ).trigger('crmLoad');
421 //show event real full as well as waiting list message.
422 if ( $("#hidden_eventFullMsg", $form).val( ) ) {
423 $( "#eventFullMsg", $form).show( ).html( $("#hidden_eventFullMsg", $form).val( ) );
426 $( "#eventFullMsg", $form ).hide( );
433 CRM.buildCustomData( '{$customDataType}', null, null );
435 CRM.buildCustomData( '{$customDataType}', {$eventID}, {$eventNameCustomDataTypeID} );
438 CRM.buildCustomData( '{$customDataType}', {$eventTypeID}, {$eventTypeCustomDataTypeID} );
449 <script type="text/javascript">
453 function sendNotification() {
454 var notificationStatusIds = {/literal}"{$notificationStatusIds}"{literal};
455 notificationStatusIds = notificationStatusIds.split(',');
456 if (cj.inArray(cj('select#status_id option:selected').val(), notificationStatusIds) > -1) {
457 cj("#notify").show();
458 cj("#is_notify").prop('checked', true);
461 cj("#notify").hide();
462 cj("#is_notify").prop('checked', false);
469 {/if} {* end of main event block*}