Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-08-21-20-13-45
[civicrm-core.git] / templates / CRM / Custom / Form / Group.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 id="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" 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" class="hiddenElement">
48 {*<dt>{$form.min_multiple.label}</dt><dd>{$form.min_multiple.html}</dd>*}
49 <td class="label">{$form.max_multiple.label}</td>
50 <td>{$form.max_multiple.html} {help id="id-max_multiple"}</td>
51 </tr>
52 <tr id="style" class="hiddenElement">
53 <td class="label">{$form.style.label}</td>
54 <td>{$form.style.html} {help id="id-display_style"}</td>
55 </tr>
56 <tr class="html-adjust">
57 <td>&nbsp;</td>
58 <td>{$form.collapse_display.html} {$form.collapse_display.label} {help id="id-collapse"}</td>
59 </tr>
60 <tr>
61 <td>&nbsp;</td>
62 <td>{$form.collapse_adv_display.html} {$form.collapse_adv_display.label} {help id="id-collapse-adv"}</td>
63 </tr>
64 <tr>
65 <td>&nbsp;</td>
66 <td>{$form.is_active.html} {$form.is_active.label}</td>
67 </tr>
68 <tr class="html-adjust">
69 <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>
70 <td>{$form.help_pre.html}</td>
71 </tr>
72 <tr class="html-adjust">
73 <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>
74 <td>{$form.help_post.html}</td>
75 </tr>
76 </table>
77 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
78 </div>
79 {if $action eq 2 or $action eq 4} {* Update or View*}
80 <p></p>
81 <div class="action-link">
82 <a href="{crmURL p='civicrm/admin/custom/group/field' q="action=browse&reset=1&gid=$gid"}" class="button"><span>{ts}Custom Fields for this Set{/ts}</span></a>
83 </div>
84 {/if}
85 {$initHideBlocks}
86 {literal}
87 <script type="text/Javascript">
88 cj(function($) {
89
90 showHideStyle();
91 cj('#extends_0').change(function() {
92 showHideStyle();
93 });
94
95 var isGroupEmpty = "{/literal}{$isGroupEmpty}{literal}";
96 if (isGroupEmpty) {
97 showRange(true);
98 }
99 cj('#is_multiple').click(function() {
100 showRange();
101 });
102
103 function showHideStyle() {
104 var isShow = false;
105 var extend = cj('#extends_0').val();
106
107 var contactTypes = {/literal}{$contactTypes}{literal};
108 var showStyle = "{/literal}{$showStyle}{literal}";
109 var showMultiple = "{/literal}{$showMultiple}{literal}";
110 var showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}";
111
112 if (cj.inArray(extend, contactTypes) >= 0) {
113 isShow = true;
114 }
115
116 if (isShow) {
117 cj("tr#style").show();
118 cj("tr#is_multiple").show();
119 if (cj('#is_multiple :checked').length) {
120 cj("tr#multiple").show();
121 }
122 }
123 else {
124 cj("tr#style").hide();
125 cj("tr#is_multiple").hide();
126 cj("tr#multiple").hide();
127 }
128
129 if (showStyle) {
130 cj("tr#style").show();
131 }
132
133 if (showMultiple) {
134 cj("tr#style").show();
135 cj("tr#is_multiple").show();
136 }
137
138 if (!showMaxMultiple) {
139 cj("tr#multiple").hide();
140 }
141 else if(cj( '#is_multiple').attr('checked')) {
142 cj("tr#multiple").show();
143 }
144 }
145
146 function showRange(onFormLoad) {
147 if(cj("#is_multiple :checked").length) {
148 cj("tr#multiple").show();
149 cj("select#style option[value='Tab']").attr("selected", "selected");
150 }
151 else {
152 cj("tr#multiple").hide();
153 if (!onFormLoad) {
154 cj("select#style option[value='Inline']").attr("selected", "selected");
155 }
156 }
157 }
158
159 // In update mode, when 'extends' is set to an option which doesn't have
160 // any options in 2nd selector (for subtypes) -
161 var subtypes = document.getElementById('extends_1');
162 if (subtypes) {
163 if (subtypes.options.length <= 0) {
164 subtypes.style.display = 'none';
165 }
166 else {
167 subtypes.style.display = 'inline';
168 }
169 }
170 });
171
172 function warnDataLoss() {
173 var submittedSubtypes = cj('#extends_1').val();
174 var defaultSubtypes = {/literal}{$defaultSubtypes}{literal};
175
176 var warning = false;
177 cj.each(defaultSubtypes, function(index, subtype) {
178 if (cj.inArray(subtype, submittedSubtypes) < 0) {
179 warning = true;
180 }
181 });
182
183 if (warning) {
184 return confirm( 'One or more subtypes has been un-selected from the list. Any custom data associated with un-selected subtype would be removed. Click OK to proceed.' );
185 }
186 return true;
187 }
188 </script>
189 {/literal}