2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2019 |
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 <div class="crm-block crm-form-block crm-uf-field-form-block">
28 <div class="messages status no-popup">
29 <div class="icon inform-icon"></div>
30 {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}
33 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
34 <table class="form-layout-compressed">
35 <tr class="crm-uf-field-form-block-field_name">
36 <td class="label">{$form.field_name.label} {help id='field_name_0'}</td>
37 <td>{$form.field_name.html}<br />
38 <span class="description"> {ts}Select the type of CiviCRM record and the field you want to include in this Profile.{/ts}</span></td>
40 <tr class="crm-uf-field-form-block-label">
41 <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>
42 <td>{$form.label.html}</td>
44 <tr class="crm-uf-field-form-block-is_multi">
45 <td class="label">{$form.is_multi_summary.label}{help id='is_multi_summary'}</td>
46 <td>{$form.is_multi_summary.html}<br />
48 <tr class="crm-uf-field-form-block-is_required">
49 <td class="label">{$form.is_required.label} {help id='is_required'}</td>
50 <td>{$form.is_required.html}</td>
52 <tr class="crm-uf-field-form-block-is_view">
53 <td class="label">{$form.is_view.label} {help id='is_view'}</td>
54 <td>{$form.is_view.html}</td>
56 <tr id="profile_visibility" class="crm-uf-field-form-block-visibility">
57 <td class="label">{$form.visibility.label} {help id='visibility'}</td>
58 <td>{$form.visibility.html}</td>
60 <tr class="crm-uf-field-form-block-is_searchable">
61 <td class="label"><div id="is_search_label">{$form.is_searchable.label} {help id='is_searchable'}</div></td>
62 <td><div id="is_search_html">{$form.is_searchable.html}</td>
64 <tr class="crm-uf-field-form-block-in_selector">
65 <td class="label"><div id="in_selector_label">{$form.in_selector.label}{help id='in_selector'}</div></td>
66 <td><div id="in_selector_html">{$form.in_selector.html}</div></td>
68 <tr class="crm-uf-field-form-block-help_pre">
69 <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>
70 <td>{$form.help_pre.html}</td>
72 <tr class="crm-uf-field-form-block-help_post">
73 <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>
74 <td>{$form.help_post.html}</td>
76 <tr class="crm-uf-field-form-block-weight">
77 <td class="label">{$form.weight.label} {help id='weight'}</td>
78 <td> {$form.weight.html}</td>
80 <tr class="crm-uf-field-form-block-is_active">
81 <td class="label">{$form.is_active.label} {help id='is_active'}</td>
82 <td>{$form.is_active.html}</td>
86 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
92 <script type="text/javascript">
95 var otherModule = {/literal}{$otherModules|@json_encode}{literal};
96 if ( $.inArray( "Profile", otherModule ) > -1 && $.inArray( "Search Profile", otherModule ) == -1 ){
97 $('#profile_visibility').show();
99 else if( $.inArray( "Search Profile", otherModule ) > -1 ){
100 $('#profile_visibility').show();
101 $("#in_selector").prop('checked',true);
103 else if( $.inArray( "Profile", otherModule ) == -1 && $.inArray( "Search Profile", otherModule ) == -1 ){
104 $('#profile_visibility').hide();
106 $('[id^=field_name]').change(function() {
112 var preHelpLabel = "";
113 function showLabel( ) {
115 cj(".crm-uf-field-form-block-help_pre .label").html(preHelpLabel);
117 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");
121 if (cj('[name="field_name[0]"]').val() == "Formatting") {
123 preHelpLabel = cj(".crm-uf-field-form-block-help_post .label").html();
125 cj(".crm-uf-field-form-block-help_pre .label").html('<label for="help_pre">HTML Code</label>');
129 // Set the Field Label
131 if (cj('[name="field_name[0]"]').val()) {
132 var fieldId = cj('[name="field_name[1]"]').val();
134 labelValue = cj('[name="field_name[1]"] :selected').text().split(' :: ', 2)[0];
135 if (cj('[name="field_name[3]"]').val()) {
136 labelValue += '-' + cj('[name="field_name[3]"] :selected').text();
138 if (cj('[name="field_name[2]"]').val()) {
139 labelValue += ' (' + cj('[name="field_name[2]"] :selected').text() + ')';
144 cj('#label').val(labelValue);
146 /* Code to hide searchable attribute for no searchable fields */
147 if (document.getElementsByName("field_name[1]")[0].selectedIndex == -1) {
150 var field2 = document.getElementsByName("field_name[1]")[0][document.getElementsByName("field_name[1]")[0].selectedIndex].text;
152 {foreach from=$noSearchable key=dnc item=val}
154 if (field2 == "{/literal}{$val}{literal}") {
155 cj('#is_search_label, #is_search_html').hide();
161 // Code to set Profile Field help, from custom data field help
162 if (fieldId.substring(0, 7) == 'custom_') {
163 fieldId = fieldId.substring( fieldId.length, 7);
164 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/custom' h=0 }"{literal};
165 cj.post( dataUrl, { id: fieldId }, function(data) {
166 cj('#help_post').val(data.help_post);
167 cj('#help_pre').val(data.help_pre);
172 {/literal}{if $action neq 8}{literal}
173 showHideSeletorSearch();
175 function showHideSeletorSearch() {
176 var is_search = cj('#is_search_label, #is_search_html');
177 var in_selector = cj('#in_selector_label, #in_selector_html');
178 if (cj("#visibility").val() == "User and User Admin Only") {
181 cj("#is_searchable").prop('checked',false);
184 if (!cj("#is_view").prop('checked')) {
187 var fldName = cj("#field_name_1").val();
188 if (fldName == 'group' || fldName == 'tag') {
197 cj("#field_name_1").bind( 'change blur', function( ) {
198 showHideSeletorSearch( );
202 cj("#field_name_1").addClass( 'huge' );
204 cj("#is_view").click( function(){
208 {/literal}{/if}{literal}
210 cj("#field_name_1").change(
212 multiSummaryToggle(cj(this).val());
216 var fieldId = cj("#field_name_1").val();
217 multiSummaryToggle(fieldId);
220 function multiSummaryToggle(customId) {
221 if (customId && customId.match(/custom_[\d]/)) {
223 var dataUrl = "{/literal}{crmURL p='civicrm/ajax/rest' q='className=CRM_UF_Page_AJAX&fnName=checkIsMultiRecord&json=1' h=0 }"{literal};
224 dataUrl = dataUrl + '&customId=' + customId;
225 cj.ajax({ url: dataUrl,
229 success : function(response) {
230 if (response.is_multi != 0 ) {
231 cj('.crm-uf-field-form-block-is_multi').show();
234 if (cj('#is_multi_summary').is(':checked')) {
235 cj('#is_multi_summary').prop('checked', false);
237 cj('.crm-uf-field-form-block-is_multi').hide();
243 if (cj('#is_multi_summary').is(':checked')) {
244 cj('#is_multi_summary').prop('checked', false);
246 cj('.crm-uf-field-form-block-is_multi').hide();
250 function viewOnlyShowHide() {
251 var is_search = cj('#is_search_label, #is_search_html');
252 if (cj("#is_view").prop('checked')) {
254 cj("#is_searchable").prop('checked', false);
256 else if (cj("#visibility").val() != "User and User Admin Only") {
262 function mixProfile( ) {
263 var allMixTypes = ["Participant", "Membership", "Contribution"];
264 var type = document.forms.Field['field_name[0]'].value;
265 var alreadyMixProfile = {/literal}{if $alreadyMixProfile}true{else}false{/if}{literal};
266 if (allMixTypes.indexOf( type ) != -1 || alreadyMixProfile) {
267 if (document.getElementById("is_searchable").checked) {
268 document.getElementById("is_searchable").checked = false;
269 if ( alreadyMixProfile ) {
270 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};
273 var message = type + {/literal}'{ts escape="js"} fields can not be marked as Searchable in a profile.{/ts}'{literal};
275 cj().crmError(message, {/literal}'{ts escape="js"}Error{/ts}'{literal});
277 if ( document.getElementById("in_selector").checked ) {
278 document.getElementById("in_selector").checked = false;
279 if ( alreadyMixProfile ) {
280 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};
283 var message = type + {/literal}'{ts escape="js"} can not be used as a Result Column for profile searches.{/ts}'{literal};
285 cj().crmError(message, {/literal}'{ts escape="js"}Error{/ts}'{literal});
291 var allMixTypes = ["Participant", "Membership", "Contribution"];
292 var type = document.forms.Field['field_name[0]'].value;
293 if ( allMixTypes.indexOf( type ) != -1 ) {
294 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}'
295 + 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};
296 var ok = confirm( message );