2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 = new Array( );
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}] = new Array( );
43 fieldOptionsFull[{/literal}{$fldId}{literal}][{/literal}{$opId}{literal}] = 1;
51 if ( fieldOptionsFull.length > 0 ) {
53 cj("input,#priceset select,#priceset").each(function () {
54 if ( cj(this).attr('price') ) {
55 switch( cj(this).attr('type') ) {
58 cj(this).click( function() {
59 validatePriceField(this);
64 cj(this).change( function() {
65 validatePriceField(this);
69 cj(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("<span class='icon red-icon alert-icon'></span>{/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('#Participant').on("click",'.validate',
156 var userSubmittedStatus = cj('#status_id').val();
157 var statusLabel = cj('#status_id option:selected').text();
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}));
161 if (result == false) {
170 {include file="CRM/Event/Form/EventFees.tpl"}
172 {* Ajax callback for custom data snippet *}
174 {include file="CRM/Custom/Form/CustomData.tpl"}
176 {* Main event form template *}
178 {if $participantMode == 'test' }
179 {assign var=registerMode value="TEST"}
180 {elseif $participantMode == 'live'}
181 {assign var=registerMode value="LIVE"}
183 <h3>{if $action eq 1}{ts}New Event Registration{/ts}{elseif $action eq 8}{ts}Delete Event Registration{/ts}{else}{ts}Edit Event Registration{/ts}{/if}</h3>
184 <div class="crm-block crm-form-block crm-participant-form-block">
185 <div class="view-content">
186 {if $participantMode}
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}
191 <div id="eventFullMsg" class="messages status no-popup" style="display:none;"></div>
194 {if $action eq 1 AND $paid}
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}
200 {if $action eq 8} {* If action is Delete *}
201 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
202 <div class="crm-participant-form-block-delete messages status no-popup">
203 <div class="crm-content">
204 <div class="icon inform-icon"></div>
205 {ts}WARNING: Deleting this registration will result in the loss of related payment records (if any).{/ts} {ts}Do you want to continue?{/ts}
207 {if $additionalParticipant}
208 <div class="crm-content">
209 {ts 1=$additionalParticipant} There are %1 more Participant(s) registered by this participant.{/ts}
213 {if $additionalParticipant}
214 {$form.delete_participant.html}
216 {else} {* If action is other than Delete *}
217 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
218 <table class="form-layout-compressed">
219 {if $single and $context neq 'standalone'}
220 <tr class="crm-participant-form-block-displayName">
221 <td class="label font-size12pt"><label>{ts}Participant{/ts}</label></td>
222 <td class="font-size12pt view-value">{$displayName} </td>
225 {if !$participantMode and !$email and $outBound_option != 2 }
226 {assign var='profileCreateCallback' value=1}
228 <tr class="crm-participant-form-contact-id">
229 <td class="label">{$form.contact_id.label}</td>
230 <td>{$form.contact_id.html}</td>
234 {if $additionalParticipants} {* Display others registered by this participant *}
235 <tr class="crm-participant-form-block-additionalParticipants">
236 <td class="label"><label>{ts}Also Registered by this Participant{/ts}</label></td>
238 {foreach from=$additionalParticipants key=apName item=apURL}
239 <a href="{$apURL}" title="{ts}view additional participant{/ts}">{$apName}</a><br />
244 {if $registered_by_contact_id}
245 <tr class="crm-participant-form-block-registered-by">
246 <td class="label"><label>{ts}Registered By{/ts}</label></td>
247 <td class="view-value">
248 <a href="{crmURL p='civicrm/contact/view/participant' q="reset=1&id=$participant_registered_by_id&cid=$registered_by_contact_id&action=view"}"
249 title="{ts}view primary participant{/ts}">{$registered_by_display_name}</a>
254 {if $participantMode}
255 <tr class="crm-participant-form-block-payment_processor_id">
256 <td class="label nowrap">{$form.payment_processor_id.label}</td>
257 <td>{$form.payment_processor_id.html}</td>
260 <tr class="crm-participant-form-block-event_id">
261 <td class="label">{$form.event_id.label}</td>
262 <td class="view-value">
263 {$form.event_id.html}
270 {* CRM-7362 --add campaign *}
271 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-participant-form-block-campaign_id"}
273 <tr class="crm-participant-form-block-role_id">
274 <td class="label">{$form.role_id.label}</td>
275 <td>{$form.role_id.html}</td>
277 <tr class="crm-participant-form-block-register_date">
278 <td class="label">{$form.register_date.label}</td>
280 {if $hideCalendar neq true}
281 {include file="CRM/common/jcalendar.tpl" elementName=register_date}
283 {$form.register_date.html|crmDate}
287 <tr class="crm-participant-form-block-status_id">
288 <td class="label">{$form.status_id.label}</td>
289 <td>{$form.status_id.html}{if $event_is_test} {ts}(test){/ts}{/if}
290 <div id="notify">{$form.is_notify.html}{$form.is_notify.label}</div>
293 <tr class="crm-participant-form-block-source">
294 <td class="label">{$form.source.label}</td><td>{$form.source.html|crmAddClass:huge}<br />
295 <span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td>
299 <table class='form-layout'>
301 <td class='label'>{ts}Fees{/ts}</td>
302 {* this is where the payment info is shown using CRM/Contribute/Page/PaymentInfo.tpl tpl*}
303 <td id='payment-info'></td>
307 {* Fee block (EventFees.tpl) is injected here when an event is selected. *}
308 <div id="feeBlock"></div>
310 <table class="form-layout">
311 <tr class="crm-participant-form-block-note">
312 <td class="label">{$form.note.label}</td><td>{$form.note.html}</td>
317 <div class="crm-participant-form-block-customData">
318 <div id="customData" class="crm-customData-block"></div> {* Participant Custom data *}
319 <div id="customData{$eventNameCustomDataTypeID}" class="crm-customData-block"></div> {* Event Custom Data *}
320 <div id="customData{$roleCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
321 <div id="customData{$eventTypeCustomDataTypeID}" class="crm-customData-block"></div> {* Role Custom Data *}
325 {if $accessContribution and $action eq 2 and $rows.0.contribution_id}
326 {include file="CRM/Contribute/Form/Selector.tpl" context="Search"}
329 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
332 {* JS block for ADD or UPDATE actions only *}
333 {if $action eq 1 or $action eq 2}
335 {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
338 {*include custom data js file*}
339 {include file="CRM/common/customData.tpl"}
341 <script type="text/javascript">
345 var $form = $('form#{/literal}{$form.formName}{literal}');
347 // don't show cart related statuses if it's disabled
348 var pendingInCartStatusId = {/literal}{$pendingInCartStatusId}{literal};
349 $("#status_id option[value='" + pendingInCartStatusId + "']").remove();
351 // Handle event selection
352 $('#event_id', $form).change(function() {
353 var eventId = $(this).val();
357 var info = $(this).select2('data').extra;
359 // Set role from default
360 $('[name^=role_id]:checkbox', $form).each(function() {
361 var check = $(this).is('[name="role_id[' + info.default_role_id + ']"]');
362 if (check !== $(this).prop('checked')) {
363 $(this).prop('checked', check).change();
367 // Set campaign default
368 $('#campaign_id', $form).select2('val', info.campaign_id);
370 // Event and event-type custom data
371 CRM.buildCustomData('Participant', eventId, {/literal}{$eventNameCustomDataTypeID}{literal});
372 CRM.buildCustomData('Participant', info.event_type_id, {/literal}{$eventTypeCustomDataTypeID}{literal});
377 // Handle participant role selection
378 $('[name^=role_id]:checkbox', $form).change(function() {
379 var roleId = $(this).attr('name').replace(/role_id\[|\]/g, '');
380 showCustomData('Participant', roleId, {/literal}{$roleCustomDataTypeID}{literal});
382 $('[name^=role_id]:checked', $form).change();
386 //build discount block
387 if ($('#discount_id', $form).val()) {
388 buildFeeBlock($('#discount_id', $form).val());
392 function buildFeeBlock(discountId) {
393 var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q="snippet=4&qfKey=$qfKey"}";
396 dataUrl += '&' + '{$urlPathVar}';
400 var eventId = $('#event_id').val();
403 dataUrl += '&eventId=' + eventId;
406 $('#eventFullMsg').hide( );
407 $('#feeBlock').html('');
411 var participantId = "{/literal}{$participantId}{literal}";
414 dataUrl += '&participantId=' + participantId;
418 dataUrl += '&discountId=' + discountId;
425 success: function ( html ) {
426 $("#feeBlock").html( html ).trigger('crmLoad');
430 $("#feeBlock").ajaxStart(function(){
431 $(".disable-buttons input").prop('disabled', true);
434 $("#feeBlock").ajaxStop(function(){
435 $(".disable-buttons input").prop('disabled', false);
438 //show event real full as well as waiting list message.
439 if ( $("#hidden_eventFullMsg").val( ) ) {
440 $( "#eventFullMsg" ).show( ).html( $("#hidden_eventFullMsg" ).val( ) );
443 $( "#eventFullMsg" ).hide( );
447 var roleGroupMapper = {/literal}{$participantRoleIds|@json_encode}{literal};
448 function showCustomData( type, subType, subName ) {
449 var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q='snippet=4&type='}"{literal} + type;
450 var roleid = "role_id_"+subType;
451 var loadData = false;
453 if ( document.getElementById( roleid ).checked == true ) {
454 if ( typeof roleGroupMapper !== 'undefined' && roleGroupMapper[subType] ) {
455 var splitGroup = roleGroupMapper[subType].split(",");
456 for ( i = 0; i < splitGroup.length; i++ ) {
457 var roleCustomGroupId = splitGroup[i];
458 if ( $( '#'+roleCustomGroupId ).length > 0 ) {
459 $( '#'+roleCustomGroupId ).remove( );
466 var groupUnload = [];
469 if ( roleGroupMapper[0] ) {
470 var splitGroup = roleGroupMapper[0].split(",");
471 for ( x = 0; x < splitGroup.length; x++ ) {
472 groupUnload[x] = splitGroup[x];
476 for ( var i in roleGroupMapper ) {
477 if ( ( i > 0 ) && ( document.getElementById( "role_id_"+i ).checked ) ) {
478 var splitGroup = roleGroupMapper[i].split(",");
479 for ( j = 0; j < splitGroup.length; j++ ) {
480 groupUnload[x+j+1] = splitGroup[j];
485 if ( roleGroupMapper[subType] ) {
486 var splitGroup = roleGroupMapper[subType].split(",");
487 for ( i = 0; i < splitGroup.length; i++ ) {
488 var roleCustomGroupId = splitGroup[i];
489 if ( $( '#'+roleCustomGroupId ).length > 0 ) {
490 if ( $.inArray( roleCustomGroupId, groupUnload ) == -1 ) {
491 $( '#'+roleCustomGroupId ).remove( );
498 if ( !( loadData ) ) {
503 dataUrl += '&subType=' + subType;
507 dataUrl += '&subName=' + subName;
508 $( '#customData' + subName ).show( );
511 $( '#customData' ).show( );
516 dataUrl += '&{$urlPathVar}';
519 dataUrl += '&groupID=' + '{$groupID}';
522 dataUrl += '&qfKey=' + '{$qfKey}';
525 dataUrl += '&entityID=' + '{$entityID}';
530 if ( subName && subName != 'null' ) {
531 var fname = '#customData' + subName;
534 var fname = '#customData';
537 var response = $.ajax({url: dataUrl,
541 if ( subType != 'null' ) {
542 if ( document.getElementById(roleid).checked == true ) {
543 var response_text = '<div style="display:block;" id = '+subType+'_chk >'+response+'</div>';
544 $( fname ).append(response_text).trigger('crmLoad');
547 $('#'+subType+'_chk').remove();
553 CRM.buildCustomData( '{$customDataType}', 'null', 'null' );
555 CRM.buildCustomData( '{$customDataType}', {$eventID}, {$eventNameCustomDataTypeID} );
558 CRM.buildCustomData( '{$customDataType}', {$eventTypeID}, {$eventTypeCustomDataTypeID} );
566 {* jscript to warn if unsaved form field changes *}
567 {include file="CRM/common/formNavigate.tpl"}
571 <script type="text/javascript">
575 function sendNotification() {
576 var notificationStatusIds = {/literal}"{$notificationStatusIds}"{literal};
577 notificationStatusIds = notificationStatusIds.split(',');
578 if (cj.inArray(cj('select#status_id option:selected').val(), notificationStatusIds) > -1) {
579 cj("#notify").show();
580 cj("#is_notify").prop('checked', true);
583 cj("#notify").hide();
584 cj("#is_notify").prop('checked', false);
589 {if $profileCreateCallback}
591 function profileCreateCallback( blockNo ) {
592 if( cj('#event_id').val( ) && cj('#email-receipt').length > 0 ) {
600 cj().crmAccordions();
605 {/if} {* end of main event block*}