Merge remote-tracking branch 'upstream/4.3' into 4.3-4.4-2013-10-21-22-31-28
[civicrm-core.git] / templates / CRM / Contact / Form / Contact.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 {* This form is for Contact Add/Edit interface *}
27 {if $addBlock}
28 {include file="CRM/Contact/Form/Edit/$blockName.tpl"}
29 {else}
30 {if $contactId}
31 {include file="CRM/Contact/Form/Edit/Lock.tpl"}
32 {/if}
33 <div class="crm-form-block crm-search-form-block">
34 {if call_user_func(array('CRM_Core_Permission','check'), 'administer CiviCRM') }
35 <a href='{crmURL p="civicrm/admin/setting/preferences/display" q="reset=1"}' title="{ts}Click here to configure the panes.{/ts}"><span class="icon settings-icon"></span></a>
36 {/if}
37 <span style="float:right;"><a href="#expand" id="expand">{ts}Expand all tabs{/ts}</a></span>
38 <div class="crm-submit-buttons">
39 {include file="CRM/common/formButtons.tpl" location="top"}
40 </div>
41
42 {* include overlay js *}
43 {include file="CRM/common/overlay.tpl"}
44
45 <div class="crm-accordion-wrapper crm-contactDetails-accordion">
46 <div class="crm-accordion-header">
47 {ts}Contact Details{/ts}
48 </div><!-- /.crm-accordion-header -->
49 <div class="crm-accordion-body" id="contactDetails">
50 <div id="contactDetails">
51 <div class="crm-section contact_basic_information-section">
52 {include file="CRM/Contact/Form/Edit/$contactType.tpl"}
53 </div>
54 <table class="crm-section contact_information-section form-layout-compressed">
55 {foreach from=$blocks item="label" key="block"}
56 {include file="CRM/Contact/Form/Edit/$block.tpl"}
57 {/foreach}
58 </table>
59 <table class="crm-section contact_source-section form-layout-compressed">
60 <tr class="last-row">
61 <td>{$form.contact_source.label} {help id="id-source"}<br />
62 {$form.contact_source.html|crmAddClass:twenty}
63 </td>
64 <td>{$form.external_identifier.label}&nbsp;{help id="id-external-id"}<br />
65 {$form.external_identifier.html}
66 </td>
67 {if $contactId}
68 <td><label for="internal_identifier_display">{ts}CiviCRM ID{/ts}{help id="id-internal-id"}</label><br /><input id="internal_identifier_display" type="text" class="form-text eight" size="8" disabled="disabled" value="{$contactId}"></td>
69 {/if}
70 </tr>
71 </table>
72 <table class="image_URL-section form-layout-compressed">
73 <tr>
74 <td>
75 {$form.image_URL.label}&nbsp;&nbsp;{help id="id-upload-image" file="CRM/Contact/Form/Contact.hlp"}<br />
76 {$form.image_URL.html|crmAddClass:twenty}
77 {if !empty($imageURL)}
78 {include file="CRM/Contact/Page/ContactImage.tpl"}
79 {/if}
80 </td>
81 </tr>
82 </table>
83
84 {*add dupe buttons *}
85 <span class="crm-button crm-button_qf_Contact_refresh_dedupe">
86 {$form._qf_Contact_refresh_dedupe.html}
87 </span>
88 {if $isDuplicate}
89 &nbsp;&nbsp;
90 <span class="crm-button crm-button_qf_Contact_upload_duplicate">
91 {$form._qf_Contact_upload_duplicate.html}
92 </span>
93 {/if}
94 <div class="spacer"></div>
95 </div>
96 </div><!-- /.crm-accordion-body -->
97 </div><!-- /.crm-accordion-wrapper -->
98
99 {foreach from = $editOptions item = "title" key="name"}
100 {if $name eq 'CustomData' }
101 <div id='customData'>{include file="CRM/Contact/Form/Edit/CustomData.tpl"}</div>
102 {else}
103 {include file="CRM/Contact/Form/Edit/$name.tpl"}
104 {/if}
105 {/foreach}
106 <div class="crm-submit-buttons">
107 {include file="CRM/common/formButtons.tpl" location="bottom"}
108 </div>
109 </div>
110 {literal}
111
112 <script type="text/javascript" >
113 cj(function($) {
114 var action = "{/literal}{$action}{literal}";
115 $().crmAccordions();
116
117 $('.crm-accordion-body').each( function() {
118 //remove tab which doesn't have any element
119 if ( ! $.trim( $(this).text() ) ) {
120 ele = $(this);
121 prevEle = $(this).prev();
122 $(ele).remove();
123 $(prevEle).remove();
124 }
125 //open tab if form rule throws error
126 if ( $(this).children().find('span.crm-error').text().length > 0 ) {
127 $(this).parents('.collapsed').crmAccordionToggle();
128 }
129 });
130 if (action == '2') {
131 $('.crm-accordion-wrapper').not('.crm-accordion-wrapper .crm-accordion-wrapper').each(function() {
132 highlightTabs(this);
133 });
134 $('#crm-container').on('change click', '.crm-accordion-body :input, .crm-accordion-body a', function() {
135 highlightTabs($(this).parents('.crm-accordion-wrapper'));
136 });
137 }
138 function highlightTabs(tab) {
139 //highlight the tab having data inside.
140 $('.crm-accordion-body :input', tab).each( function() {
141 var active = false;
142 switch($(this).prop('type')) {
143 case 'checkbox':
144 case 'radio':
145 if($(this).is(':checked') && !$(this).is('[id$=IsPrimary],[id$=IsBilling]')) {
146 $('.crm-accordion-header:first', tab).addClass('active');
147 return false;
148 }
149 break;
150
151 case 'text':
152 case 'textarea':
153 if($(this).val()) {
154 $('.crm-accordion-header:first', tab).addClass('active');
155 return false;
156 }
157 break;
158
159 case 'select-one':
160 case 'select-multiple':
161 if($(this).val() && $('option[value=""]', this).length > 0) {
162 $('.crm-accordion-header:first', tab).addClass('active');
163 return false;
164 }
165 break;
166
167 case 'file':
168 if($(this).next().html()) {
169 $('.crm-accordion-header:first', tab).addClass('active');
170 return false;
171 }
172 break;
173 }
174 $('.crm-accordion-header:first', tab).removeClass('active');
175 });
176 }
177
178 $('a#expand').click( function() {
179 if( $(this).attr('href') == '#expand') {
180 var message = {/literal}"{ts escape='js'}Collapse all tabs{/ts}"{literal};
181 $(this).attr('href', '#collapse');
182 $('.crm-accordion-wrapper.collapsed').crmAccordionToggle();
183 }
184 else {
185 var message = {/literal}"{ts escape='js'}Expand all tabs{/ts}"{literal};
186 $('.crm-accordion-wrapper:not(.collapsed)').crmAccordionToggle();
187 $(this).attr('href', '#expand');
188 }
189 $(this).html(message);
190 return false;
191 });
192
193 $('.customDataPresent').change(function() {
194 //$('.crm-custom-accordion').remove();
195 var values = $("#contact_sub_type").val();
196 var contactType = {/literal}"{$contactType}"{literal};
197 CRM.buildCustomData(contactType, values);
198 loadMultiRecordFields(values);
199 $('.crm-custom-accordion').each(function() {
200 highlightTabs(this);
201 });
202 });
203
204 function loadMultiRecordFields(subTypeValues) {
205 if (subTypeValues == false) {
206 var subTypeValues = null;
207 }
208 else if (!subTypeValues) {
209 var subTypeValues = {/literal}"{$paramSubType}"{literal};
210 }
211 {/literal}
212 {foreach from=$customValueCount item="groupCount" key="groupValue"}
213 {if $groupValue}{literal}
214 for ( var i = 1; i < {/literal}{$groupCount}{literal}; i++ ) {
215 CRM.buildCustomData( {/literal}"{$contactType}"{literal}, subTypeValues, null, i, {/literal}{$groupValue}{literal}, true );
216 }
217 {/literal}
218 {/if}
219 {/foreach}
220 {literal}
221 }
222
223 loadMultiRecordFields();
224
225 {/literal}{if $oldSubtypes}{literal}
226 $('input[name=_qf_Contact_upload_view], input[name=_qf_Contact_upload_new]').click(function() {
227 var submittedSubtypes = $('#contact_sub_type').val();
228 var oldSubtypes = {/literal}{$oldSubtypes}{literal};
229
230 var warning = false;
231 $.each(oldSubtypes, function(index, subtype) {
232 if ( $.inArray(subtype, submittedSubtypes) < 0 ) {
233 warning = true;
234 }
235 });
236 if ( warning ) {
237 return confirm({/literal}'{ts escape="js"}One or more contact subtypes have been de-selected from the list for this contact. Any custom data associated with de-selected subtype will be removed. Click OK to proceed, or Cancel to review your changes before saving.{/ts}'{literal});
238 }
239 return true;
240 });
241 {/literal}{/if}{literal}
242
243 $("select#contact_sub_type").crmasmSelect({
244 addItemTarget: 'bottom',
245 animate: false,
246 highlight: true,
247 respectParents: true
248 });
249 });
250
251 </script>
252 {/literal}
253
254 {* jQuery validate *}
255 {include file="CRM/Form/validate.tpl"}
256
257 {* include common additional blocks tpl *}
258 {include file="CRM/common/additionalBlocks.tpl"}
259
260 {* include jscript to warn if unsaved form field changes *}
261 {include file="CRM/common/formNavigate.tpl"}
262
263 {/if}