2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
10 <div class="crm-block crm-form-block crm-uf-field-form-block">
12 <div class="messages status no-popup">
13 {icon icon="fa-info-circle"}{/icon}
14 {ts}WARNING: Deleting this profile field will remove it from Profile forms and listings. If this field is used in any 'stand-alone' Profile forms, you will need to update those forms to remove this field.{/ts} {ts}Do you want to continue?{/ts}
17 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
18 <table class="form-layout-compressed">
19 <tr class="crm-uf-field-form-block-field_name">
20 <td class="label">{$form.field_name.label} {help id='field_name_0'}</td>
21 <td>{$form.field_name.html}<br />
22 <span class="description"> {ts}Select the type of CiviCRM record and the field you want to include in this Profile.{/ts}</span></td>
24 <tr class="crm-uf-field-form-block-label">
25 <td class="label">{$form.label.label} {help id='label'}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_uf_field' field='label' id=$fieldId}{/if}</td>
26 <td>{$form.label.html}</td>
28 <tr class="crm-uf-field-form-block-is_multi">
29 <td class="label">{$form.is_multi_summary.label}{help id='is_multi_summary'}</td>
30 <td>{$form.is_multi_summary.html}<br />
32 <tr class="crm-uf-field-form-block-is_required">
33 <td class="label">{$form.is_required.label} {help id='is_required'}</td>
34 <td>{$form.is_required.html}</td>
36 <tr class="crm-uf-field-form-block-is_view">
37 <td class="label">{$form.is_view.label} {help id='is_view'}</td>
38 <td>{$form.is_view.html}</td>
40 <tr id="profile_visibility" class="crm-uf-field-form-block-visibility">
41 <td class="label">{$form.visibility.label} {help id='visibility'}</td>
42 <td>{$form.visibility.html}</td>
44 <tr class="crm-uf-field-form-block-is_searchable">
45 <td class="label"><div id="is_search_label">{$form.is_searchable.label} {help id='is_searchable'}</div></td>
46 <td><div id="is_search_html">{$form.is_searchable.html}</td>
48 <tr class="crm-uf-field-form-block-in_selector">
49 <td class="label"><div id="in_selector_label">{$form.in_selector.label}{help id='in_selector'}</div></td>
50 <td><div id="in_selector_html">{$form.in_selector.html}</div></td>
52 <tr class="crm-uf-field-form-block-help_pre">
53 <td class="label">{$form.help_pre.label}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_uf_field' field='help_pre' id=$fieldId}{/if} {help id='help'}</td>
54 <td>{$form.help_pre.html}</td>
56 <tr class="crm-uf-field-form-block-help_post">
57 <td class="label">{$form.help_post.label}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_uf_field' field='help_post' id=$fieldId}{/if} {help id='help'}</td>
58 <td>{$form.help_post.html}</td>
60 <tr class="crm-uf-field-form-block-weight">
61 <td class="label">{$form.weight.label} {help id='weight'}</td>
62 <td> {$form.weight.html}</td>
64 <tr class="crm-uf-field-form-block-is_active">
65 <td class="label">{$form.is_active.label} {help id='is_active'}</td>
66 <td>{$form.is_active.html}</td>
70 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
76 <script type="text/javascript">
79 var otherModule = {/literal}{$otherModules|@json_encode}{literal};
80 if ( $.inArray( "Profile", otherModule ) > -1 && $.inArray( "Search Profile", otherModule ) == -1 ){
81 $('#profile_visibility').show();
83 else if( $.inArray( "Search Profile", otherModule ) > -1 ){
84 $('#profile_visibility').show();
85 $("#in_selector").prop('checked',true);
87 else if( $.inArray( "Profile", otherModule ) == -1 && $.inArray( "Search Profile", otherModule ) == -1 ){
88 $('#profile_visibility').hide();
90 $('[id^=field_name]').change(function() {
96 var preHelpLabel = "";
97 function showLabel( ) {
99 cj(".crm-uf-field-form-block-help_pre .label").html(preHelpLabel);
101 var $elements = cj(".crm-uf-field-form-block-is_view, .crm-uf-field-form-block-is_required, .crm-uf-field-form-block-visibility, .crm-uf-field-form-block-is_searchable, .crm-uf-field-form-block-in_selector, .crm-uf-field-form-block-help_post");
105 if (cj('[name="field_name[0]"]').val() == "Formatting") {
107 preHelpLabel = cj(".crm-uf-field-form-block-help_post .label").html();
109 cj(".crm-uf-field-form-block-help_pre .label").html('<label for="help_pre">HTML Code</label>');
113 // Set the Field Label
115 if (cj('[name="field_name[0]"]').val()) {
116 var fieldId = cj('[name="field_name[1]"]').val();
118 labelValue = cj('[name="field_name[1]"] :selected').text().split(' :: ', 2)[0];
119 if (cj('[name="field_name[3]"]').val()) {
120 labelValue += '-' + cj('[name="field_name[3]"] :selected').text();
122 if (cj('[name="field_name[2]"]').val()) {
123 labelValue += ' (' + cj('[name="field_name[2]"] :selected').text() + ')';
128 cj('#label').val(labelValue);
130 /* Code to hide searchable attribute for no searchable fields */
131 if (document.getElementsByName("field_name[1]")[0].selectedIndex == -1) {
134 var field2 = document.getElementsByName("field_name[1]")[0][document.getElementsByName("field_name[1]")[0].selectedIndex].text;
136 {foreach from=$noSearchable key=dnc item=val}
138 if (field2 == "{/literal}{$val}{literal}") {
139 cj('#is_search_label, #is_search_html').hide();
145 // Code to set Profile Field help, from custom data field help
146 if (fieldId.substring(0, 7) == 'custom_') {
147 fieldId = fieldId.substring( fieldId.length, 7);
148 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/custom' h=0 }"{literal};
149 cj.post( dataUrl, { id: fieldId }, function(data) {
150 cj('#help_post').val(data.help_post);
151 cj('#help_pre').val(data.help_pre);
156 {/literal}{if $action neq 8}{literal}
157 showHideSeletorSearch();
159 function showHideSeletorSearch() {
160 var is_search = cj('#is_search_label, #is_search_html');
161 var in_selector = cj('#in_selector_label, #in_selector_html');
162 if (cj("#visibility").val() == "User and User Admin Only") {
165 cj("#is_searchable").prop('checked',false);
168 if (!cj("#is_view").prop('checked')) {
171 var fldName = cj("#field_name_1").val();
172 if (fldName == 'group' || fldName == 'tag') {
181 cj("#field_name_1").bind( 'change blur', function( ) {
182 showHideSeletorSearch( );
186 cj("#field_name_1").addClass( 'huge' );
188 cj("#is_view").click( function(){
192 {/literal}{/if}{literal}
194 cj("#field_name_1").change(
196 multiSummaryToggle(cj(this).val());
200 var fieldId = cj("#field_name_1").val();
201 multiSummaryToggle(fieldId);
204 function multiSummaryToggle(customId) {
205 if (customId && customId.match(/custom_[\d]/)) {
207 var dataUrl = "{/literal}{crmURL p='civicrm/ajax/rest' q='className=CRM_UF_Page_AJAX&fnName=checkIsMultiRecord&json=1' h=0 }"{literal};
208 dataUrl = dataUrl + '&customId=' + customId;
209 cj.ajax({ url: dataUrl,
213 success : function(response) {
214 if (response.is_multi != 0 ) {
215 cj('.crm-uf-field-form-block-is_multi').show();
218 if (cj('#is_multi_summary').is(':checked')) {
219 cj('#is_multi_summary').prop('checked', false);
221 cj('.crm-uf-field-form-block-is_multi').hide();
227 if (cj('#is_multi_summary').is(':checked')) {
228 cj('#is_multi_summary').prop('checked', false);
230 cj('.crm-uf-field-form-block-is_multi').hide();
234 function viewOnlyShowHide() {
235 var is_search = cj('#is_search_label, #is_search_html');
236 if (cj("#is_view").prop('checked')) {
238 cj("#is_searchable").prop('checked', false);
240 else if (cj("#visibility").val() != "User and User Admin Only") {
246 function mixProfile( ) {
247 var allMixTypes = ["Participant", "Membership", "Contribution"];
248 var type = document.forms.Field['field_name[0]'].value;
249 var alreadyMixProfile = {/literal}{if $alreadyMixProfile}true{else}false{/if}{literal};
250 if (allMixTypes.indexOf( type ) != -1 || alreadyMixProfile) {
251 if (document.getElementById("is_searchable").checked) {
252 document.getElementById("is_searchable").checked = false;
253 if ( alreadyMixProfile ) {
254 var message = {/literal}'{ts escape="js"}You can not mark fields as Searchable in a profile that contains fields for multiple record types.{/ts}'{literal};
257 var message = type + {/literal}'{ts escape="js"} fields can not be marked as Searchable in a profile.{/ts}'{literal};
259 cj().crmError(message, {/literal}'{ts escape="js"}Error{/ts}'{literal});
261 if ( document.getElementById("in_selector").checked ) {
262 document.getElementById("in_selector").checked = false;
263 if ( alreadyMixProfile ) {
264 var message = {/literal}'{ts escape="js"}You can not mark a field as a Result Column in a profile that contains fields from multiple record types.{/ts}'{literal};
267 var message = type + {/literal}'{ts escape="js"} can not be used as a Result Column for profile searches.{/ts}'{literal};
269 cj().crmError(message, {/literal}'{ts escape="js"}Error{/ts}'{literal});
275 var allMixTypes = ["Participant", "Membership", "Contribution"];
276 var type = document.forms.Field['field_name[0]'].value;
277 if ( allMixTypes.indexOf( type ) != -1 ) {
278 var message = {/literal}'{ts escape='js'}Oops. One or more fields in this profile are configured to be Searchable and / or shown in a Results Column, AND you are trying to add a {/ts}'
279 + type + '{ts} field. Profiles with a mixture of field types can not include Searchable or Results Column fields. If you save this field now, the Seachable and Results Column settings will be removed for all fields in this profile. Do you want to continue?{/ts}'{literal};
280 var ok = confirm( message );