Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
8c9251b3 | 5 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
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} | |
95392a15 CW |
30 | {if $contactId} |
31 | {include file="CRM/Contact/Form/Edit/Lock.tpl"} | |
32 | {/if} | |
6a488035 TO |
33 | <div class="crm-form-block crm-search-form-block"> |
34 | {if call_user_func(array('CRM_Core_Permission','check'), 'administer CiviCRM') } | |
972bd897 | 35 | <a href='{crmURL p="civicrm/admin/setting/preferences/display" q="reset=1"}' title="{ts}Click here to configure the panes.{/ts}"><i class="crm-i fa-wrench"></i></a> |
6a488035 TO |
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 | ||
6a488035 TO |
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} {help id="id-external-id"}<br /> | |
62 | {$form.external_identifier.html} | |
63 | </td> | |
64 | {if $contactId} | |
e9bce408 | 65 | <td> |
d79be26c | 66 | <label for="internal_identifier_display">{ts}Contact ID{/ts} {help id="id-internal-id"}</label><br /> |
e9bce408 CW |
67 | <input id="internal_identifier_display" type="text" class="crm-form-text six" size="6" readonly="readonly" value="{$contactId}"> |
68 | </td> | |
6a488035 TO |
69 | {/if} |
70 | </tr> | |
71 | </table> | |
72 | <table class="image_URL-section form-layout-compressed"> | |
73 | <tr> | |
74 | <td> | |
75 | {$form.image_URL.label} {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 | | |
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" > | |
3cc60a06 | 113 | CRM.$(function($) { |
b50fdacc | 114 | var $form = $("form.{/literal}{$form.formClass}{literal}"); |
6a488035 | 115 | var action = "{/literal}{$action}{literal}"; |
6a488035 TO |
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() { | |
6a488035 | 194 | var values = $("#contact_sub_type").val(); |
594cfdad | 195 | CRM.buildCustomData({/literal}"{$contactType}"{literal}, values).one('crmLoad', function() { |
6a488035 | 196 | highlightTabs(this); |
594cfdad | 197 | loadMultiRecordFields(values); |
6a488035 TO |
198 | }); |
199 | }); | |
200 | ||
201 | function loadMultiRecordFields(subTypeValues) { | |
594cfdad CW |
202 | if (subTypeValues === false) { |
203 | subTypeValues = null; | |
6a488035 | 204 | } |
594cfdad CW |
205 | else if (!subTypeValues) { |
206 | subTypeValues = {/literal}"{$paramSubType}"{literal}; | |
207 | } | |
208 | function loadNextRecord(i, groupValue, groupCount) { | |
209 | if (i < groupCount) { | |
210 | CRM.buildCustomData({/literal}"{$contactType}"{literal}, subTypeValues, null, i, groupValue, true).one('crmLoad', function() { | |
211 | highlightTabs(this); | |
212 | loadNextRecord(i+1, groupValue, groupCount); | |
213 | }); | |
214 | } | |
6a488035 TO |
215 | } |
216 | {/literal} | |
217 | {foreach from=$customValueCount item="groupCount" key="groupValue"} | |
218 | {if $groupValue}{literal} | |
594cfdad | 219 | loadNextRecord(1, {/literal}{$groupValue}{literal}, {/literal}{$groupCount}{literal}); |
6a488035 TO |
220 | {/literal} |
221 | {/if} | |
222 | {/foreach} | |
223 | {literal} | |
224 | } | |
225 | ||
226 | loadMultiRecordFields(); | |
227 | ||
228 | {/literal}{if $oldSubtypes}{literal} | |
229 | $('input[name=_qf_Contact_upload_view], input[name=_qf_Contact_upload_new]').click(function() { | |
230 | var submittedSubtypes = $('#contact_sub_type').val(); | |
231 | var oldSubtypes = {/literal}{$oldSubtypes}{literal}; | |
232 | ||
233 | var warning = false; | |
234 | $.each(oldSubtypes, function(index, subtype) { | |
235 | if ( $.inArray(subtype, submittedSubtypes) < 0 ) { | |
236 | warning = true; | |
237 | } | |
238 | }); | |
239 | if ( warning ) { | |
42f186fb | 240 | 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 as long as the contact does not have a contact subtype still selected. Click OK to proceed, or Cancel to review your changes before saving.{/ts}'{literal}); |
6a488035 TO |
241 | } |
242 | return true; | |
243 | }); | |
244 | {/literal}{/if}{literal} | |
eaf756c0 CW |
245 | |
246 | // Handle delete of multi-record custom data | |
247 | $form.on('click', '.crm-custom-value-del', function(e) { | |
248 | e.preventDefault(); | |
249 | var $el = $(this), | |
250 | msg = '{/literal}{ts escape="js"}The record will be deleted immediately. This action cannot be undone.{/ts}{literal}'; | |
251 | CRM.confirm({title: $el.attr('title'), message: msg}) | |
252 | .on('crmConfirm:yes', function() { | |
253 | var url = CRM.url('civicrm/ajax/customvalue'); | |
254 | var request = $.post(url, $el.data('post')); | |
255 | CRM.status({success: '{/literal}{ts escape="js"}Record Deleted{/ts}{literal}'}, request); | |
256 | var addClass = '.add-more-link-' + $el.data('post').groupID; | |
257 | $el.closest('div.crm-custom-accordion').remove(); | |
258 | $('div' + addClass).last().show(); | |
259 | }); | |
260 | }); | |
6a488035 TO |
261 | }); |
262 | ||
263 | </script> | |
264 | {/literal} | |
265 | ||
266 | {* jQuery validate *} | |
267 | {include file="CRM/Form/validate.tpl"} | |
268 | ||
269 | {* include common additional blocks tpl *} | |
270 | {include file="CRM/common/additionalBlocks.tpl"} | |
271 | ||
6a488035 | 272 | {/if} |