fix year in headers
[civicrm-core.git] / templates / CRM / Custom / Form / Group.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2017 |
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 {* add/update/view custom data group *}
27 <div class="crm-block crm-form-block">
28 <div class="help">{ts}Use Custom Field Sets to add logically related fields for a specific type of CiviCRM record (e.g. contact records, contribution records, etc.).{/ts} {help id="id-group_intro"}</div>
29 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
30 <table class="form-layout">
31 <tr>
32 <td class="label">{$form.title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_group' field='title' id=$gid}{/if}</td>
33 <td class="html-adjust">{$form.title.html} {help id="id-title"}</td>
34 </tr>
35 <tr>
36 <td class="label">{$form.extends.label}</td>
37 <td>{$form.extends.html} {help id="id-extends"}</td>
38 </tr>
39 <tr>
40 <td class="label">{$form.weight.label}</td>
41 <td>{$form.weight.html} {help id="id-weight"}</td>
42 </tr>
43 <tr id="is_multiple_row" class="hiddenElement"> {* This section shown only when Used For = Contact, Individ, Org or Household. *}
44 <td></td>
45 <td class="html-adjust">{$form.is_multiple.html}&nbsp;{$form.is_multiple.label} {help id="id-is_multiple"}</td>
46 </tr>
47 <tr id="multiple_row" class="hiddenElement">
48 <td class="label">{$form.max_multiple.label}</td>
49 <td>{$form.max_multiple.html} {help id="id-max_multiple"}</td>
50 </tr>
51 <tr id="style_row" class="hiddenElement">
52 <td class="label">{$form.style.label}</td>
53 <td>{$form.style.html} {help id="id-display_style"}</td>
54 </tr>
55 <tr class="html-adjust">
56 <td>&nbsp;</td>
57 <td>{$form.collapse_display.html} {$form.collapse_display.label} {help id="id-collapse"}</td>
58 </tr>
59 <tr>
60 <td>&nbsp;</td>
61 <td>{$form.collapse_adv_display.html} {$form.collapse_adv_display.label} {help id="id-collapse-adv"}</td>
62 </tr>
63 <tr>
64 <td>&nbsp;</td>
65 <td>{$form.is_active.html} {$form.is_active.label}</td>
66 </tr>
67 <tr class="html-adjust">
68 <td class="label">{$form.help_pre.label} <!--{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_group' field='help_pre' id=$gid}{/if}-->{help id="id-help_pre"}</td>
69 <td>{$form.help_pre.html}</td>
70 </tr>
71 <tr class="html-adjust">
72 <td class="label">{$form.help_post.label} <!--{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_group' field='help_post' id=$gid}{/if}-->{help id="id-help_post"}</td>
73 <td>{$form.help_post.html}</td>
74 </tr>
75 </table>
76 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
77 </div>
78 {if $action eq 2 or $action eq 4} {* Update or View*}
79 <p></p>
80 <div class="action-link">
81 {crmButton p='civicrm/admin/custom/group/field' q="action=browse&reset=1&gid=$gid" icon="th-list"}{ts}Custom Fields for this Set{/ts}{/crmButton}
82 </div>
83 {/if}
84 {$initHideBlocks}
85 {literal}
86 <script type="text/Javascript">
87 CRM.$(function($) {
88 var tabWithTableOption;
89
90 $('#extends_0').each(showHideStyle).change(showHideStyle);
91
92 var isGroupEmpty = "{/literal}{$isGroupEmpty}{literal}";
93 if (isGroupEmpty) {
94 showRange(true);
95 }
96 $('input#is_multiple').change(showRange);
97
98 // "Collapse" is a bad default for "Tab" display
99 $("select#style").change(function() {
100 if ($(this).val() == 'Tab') {
101 $('#collapse_display').prop('checked', false);
102 }
103 });
104
105 /**
106 * Check if this is a contact-related set and show/hide other options accordingly
107 */
108 function showHideStyle() {
109 var
110 extend = $(this).val(),
111 contactTypes = {/literal}{$contactTypes}{literal},
112 showStyle = "{/literal}{$showStyle}{literal}",
113 showMultiple = "{/literal}{$showMultiple}{literal}",
114 showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}",
115 isContact = ($.inArray(extend, contactTypes) >= 0);
116
117 if (isContact) {
118 $("tr#style_row, tr#is_multiple_row").show();
119 if ($('#is_multiple :checked').length) {
120 $("tr#multiple_row").show();
121 }
122 }
123 else {
124 $("tr#style_row, tr#is_multiple_row, tr#multiple_row").hide();
125 }
126
127 if (showStyle) {
128 $("tr#style_row").show();
129 }
130
131 if (showMultiple) {
132 $("tr#style_row, tr#is_multiple_row").show();
133 }
134
135 if (!showMaxMultiple) {
136 $("tr#multiple_row").hide();
137 }
138 else if ($('#is_multiple').prop('checked')) {
139 $("tr#multiple_row").show();
140 }
141 }
142
143 /**
144 * Check if this set supports multiple records and adjust other options accordingly
145 *
146 * @param onFormLoad
147 */
148 function showRange(onFormLoad) {
149 if($("#is_multiple").is(':checked')) {
150 $("tr#multiple_row").show();
151 if (onFormLoad !== true) {
152 $('#collapse_display').prop('checked', false);
153 $("select#style").append(tabWithTableOption);
154 $("select#style").val('Tab with table');
155 }
156 }
157 else {
158 $("tr#multiple_row").hide();
159 if ($("select#style").val() === 'Tab with table') {
160 $("select#style").val('Inline');
161 }
162 tabWithTableOption = $("select#style option[value='Tab with table']").detach();
163 }
164 }
165
166 // In update mode, when 'extends' is set to an option which doesn't have
167 // any options in 2nd selector (for subtypes)
168 var subtypes = document.getElementById('extends_1');
169 if (subtypes) {
170 if (subtypes.options.length <= 0) {
171 subtypes.style.display = 'none';
172 }
173 else {
174 subtypes.style.display = 'inline';
175 }
176 }
177
178 // When removing sub-types
179 $('.crm-warnDataLoss').on('click', function() {
180 var submittedSubtypes = $('#extends_1').val();
181 var defaultSubtypes = {/literal}{$defaultSubtypes}{literal};
182
183 var warning = false;
184 $.each(defaultSubtypes, function(index, subtype) {
185 if ($.inArray(subtype, submittedSubtypes) < 0) {
186 warning = true;
187 }
188 });
189
190 if (warning) {
191 return confirm({/literal}'{ts escape='js'}Warning: You have chosen to remove one or more subtypes. This will cause any custom data records associated with those subtypes to be removed as long as the contact does not have a contact subtype still selected.{/ts}'{literal});
192 }
193 return true;
194 });
195 });
196 </script>
197 {/literal}