Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-07-14-13-42-39
[civicrm-core.git] / templates / CRM / Contact / Form / Contact.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 <div class="crm-accordion-wrapper crm-contactDetails-accordion">
43 <div class="crm-accordion-header">
44 {ts}Contact Details{/ts}
45 </div><!-- /.crm-accordion-header -->
46 <div class="crm-accordion-body" id="contactDetails">
47 <div id="contactDetails">
48 <div class="crm-section contact_basic_information-section">
49 {include file="CRM/Contact/Form/Edit/$contactType.tpl"}
50 </div>
51 <table class="crm-section contact_information-section form-layout-compressed">
52 {foreach from=$blocks item="label" key="block"}
53 {include file="CRM/Contact/Form/Edit/$block.tpl"}
54 {/foreach}
55 </table>
56 <table class="crm-section contact_source-section form-layout-compressed">
57 <tr class="last-row">
58 <td>{$form.contact_source.label} {help id="id-source"}<br />
59 {$form.contact_source.html|crmAddClass:twenty}
60 </td>
61 <td>{$form.external_identifier.label}&nbsp;{help id="id-external-id"}<br />
62 {$form.external_identifier.html}
63 </td>
64 {if $contactId}
65 <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>
66 {/if}
67 </tr>
68 </table>
69 <table class="image_URL-section form-layout-compressed">
70 <tr>
71 <td>
72 {$form.image_URL.label}&nbsp;&nbsp;{help id="id-upload-image" file="CRM/Contact/Form/Contact.hlp"}<br />
73 {$form.image_URL.html|crmAddClass:twenty}
74 {if !empty($imageURL)}
75 {include file="CRM/Contact/Page/ContactImage.tpl"}
76 {/if}
77 </td>
78 </tr>
79 </table>
80
81 {*add dupe buttons *}
82 <span class="crm-button crm-button_qf_Contact_refresh_dedupe">
83 {$form._qf_Contact_refresh_dedupe.html}
84 </span>
85 {if $isDuplicate}
86 &nbsp;&nbsp;
87 <span class="crm-button crm-button_qf_Contact_upload_duplicate">
88 {$form._qf_Contact_upload_duplicate.html}
89 </span>
90 {/if}
91 <div class="spacer"></div>
92 </div>
93 </div><!-- /.crm-accordion-body -->
94 </div><!-- /.crm-accordion-wrapper -->
95
96 {foreach from = $editOptions item = "title" key="name"}
97 {if $name eq 'CustomData' }
98 <div id='customData'>{include file="CRM/Contact/Form/Edit/CustomData.tpl"}</div>
99 {else}
100 {include file="CRM/Contact/Form/Edit/$name.tpl"}
101 {/if}
102 {/foreach}
103 <div class="crm-submit-buttons">
104 {include file="CRM/common/formButtons.tpl" location="bottom"}
105 </div>
106 </div>
107 {literal}
108
109 <script type="text/javascript" >
110 CRM.$(function($) {
111 var action = "{/literal}{$action}{literal}";
112
113 $('.crm-accordion-body').each( function() {
114 //remove tab which doesn't have any element
115 if ( ! $.trim( $(this).text() ) ) {
116 ele = $(this);
117 prevEle = $(this).prev();
118 $(ele).remove();
119 $(prevEle).remove();
120 }
121 //open tab if form rule throws error
122 if ( $(this).children().find('span.crm-error').text().length > 0 ) {
123 $(this).parents('.collapsed').crmAccordionToggle();
124 }
125 });
126 if (action == '2') {
127 $('.crm-accordion-wrapper').not('.crm-accordion-wrapper .crm-accordion-wrapper').each(function() {
128 highlightTabs(this);
129 });
130 $('#crm-container').on('change click', '.crm-accordion-body :input, .crm-accordion-body a', function() {
131 highlightTabs($(this).parents('.crm-accordion-wrapper'));
132 });
133 }
134 function highlightTabs(tab) {
135 //highlight the tab having data inside.
136 $('.crm-accordion-body :input', tab).each( function() {
137 var active = false;
138 switch($(this).prop('type')) {
139 case 'checkbox':
140 case 'radio':
141 if($(this).is(':checked') && !$(this).is('[id$=IsPrimary],[id$=IsBilling]')) {
142 $('.crm-accordion-header:first', tab).addClass('active');
143 return false;
144 }
145 break;
146
147 case 'text':
148 case 'textarea':
149 if($(this).val()) {
150 $('.crm-accordion-header:first', tab).addClass('active');
151 return false;
152 }
153 break;
154
155 case 'select-one':
156 case 'select-multiple':
157 if($(this).val() && $('option[value=""]', this).length > 0) {
158 $('.crm-accordion-header:first', tab).addClass('active');
159 return false;
160 }
161 break;
162
163 case 'file':
164 if($(this).next().html()) {
165 $('.crm-accordion-header:first', tab).addClass('active');
166 return false;
167 }
168 break;
169 }
170 $('.crm-accordion-header:first', tab).removeClass('active');
171 });
172 }
173
174 $('a#expand').click( function() {
175 if( $(this).attr('href') == '#expand') {
176 var message = {/literal}"{ts escape='js'}Collapse all tabs{/ts}"{literal};
177 $(this).attr('href', '#collapse');
178 $('.crm-accordion-wrapper.collapsed').crmAccordionToggle();
179 }
180 else {
181 var message = {/literal}"{ts escape='js'}Expand all tabs{/ts}"{literal};
182 $('.crm-accordion-wrapper:not(.collapsed)').crmAccordionToggle();
183 $(this).attr('href', '#expand');
184 }
185 $(this).html(message);
186 return false;
187 });
188
189 $('.customDataPresent').change(function() {
190 //$('.crm-custom-accordion').remove();
191 var values = $("#contact_sub_type").val();
192 var contactType = {/literal}"{$contactType}"{literal};
193 CRM.buildCustomData(contactType, values);
194 loadMultiRecordFields(values);
195 $('.crm-custom-accordion').each(function() {
196 highlightTabs(this);
197 });
198 });
199
200 function loadMultiRecordFields(subTypeValues) {
201 if (subTypeValues == false) {
202 var subTypeValues = null;
203 }
204 else if (!subTypeValues) {
205 var subTypeValues = {/literal}"{$paramSubType}"{literal};
206 }
207 {/literal}
208 {foreach from=$customValueCount item="groupCount" key="groupValue"}
209 {if $groupValue}{literal}
210 for ( var i = 1; i < {/literal}{$groupCount}{literal}; i++ ) {
211 CRM.buildCustomData( {/literal}"{$contactType}"{literal}, subTypeValues, null, i, {/literal}{$groupValue}{literal}, true );
212 }
213 {/literal}
214 {/if}
215 {/foreach}
216 {literal}
217 }
218
219 loadMultiRecordFields();
220
221 {/literal}{if $oldSubtypes}{literal}
222 $('input[name=_qf_Contact_upload_view], input[name=_qf_Contact_upload_new]').click(function() {
223 var submittedSubtypes = $('#contact_sub_type').val();
224 var oldSubtypes = {/literal}{$oldSubtypes}{literal};
225
226 var warning = false;
227 $.each(oldSubtypes, function(index, subtype) {
228 if ( $.inArray(subtype, submittedSubtypes) < 0 ) {
229 warning = true;
230 }
231 });
232 if ( warning ) {
233 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});
234 }
235 return true;
236 });
237 {/literal}{/if}{literal}
238 });
239
240 </script>
241 {/literal}
242
243 {* jQuery validate *}
244 {include file="CRM/Form/validate.tpl"}
245
246 {* include common additional blocks tpl *}
247 {include file="CRM/common/additionalBlocks.tpl"}
248
249 {/if}