Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
3 | | CiviCRM version 4.3 | | |
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 template is used for adding/editing/viewing relationships *} | |
27 | {if $cdType } | |
28 | {include file="CRM/Custom/Form/CustomData.tpl"} | |
29 | {else} | |
30 | {if $action eq 4 } {* action = view *} | |
31 | <h3>{ts}View Relationship{/ts}</h3> | |
32 | <div class="crm-block crm-content-block crm-relationship-view-block"> | |
33 | <table class="crm-info-panel"> | |
34 | {foreach from=$viewRelationship item="row"} | |
35 | <tr> | |
36 | <td class="label">{$row.relation}</td> | |
37 | <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.cid`"}">{$row.name}</a></td> | |
38 | </tr> | |
39 | {if $isCurrentEmployer} | |
40 | <tr><td class="label">{ts}Current Employee?{/ts}</td><td>{ts}Yes{/ts}</td></tr> | |
41 | {/if} | |
42 | {if $row.start_date} | |
43 | <tr><td class="label">{ts}Start Date{/ts}</td><td>{$row.start_date|crmDate}</td></tr> | |
44 | {/if} | |
45 | {if $row.end_date} | |
46 | <tr><td class="label">{ts}End Date{/ts}</td><td>{$row.end_date|crmDate}</td></tr> | |
47 | {/if} | |
48 | {if $row.description} | |
49 | <tr><td class="label">{ts}Description{/ts}</td><td>{$row.description}</td></tr> | |
50 | {/if} | |
51 | {foreach from=$viewNote item="rec"} | |
52 | {if $rec } | |
53 | <tr><td class="label">{ts}Note{/ts}</td><td>{$rec}</td></tr> | |
54 | {/if} | |
55 | {/foreach} | |
56 | {if $row.is_permission_a_b} | |
57 | {if $row.rtype EQ 'a_b' AND $is_contact_id_a} | |
58 | <tr><td class="label"> </td><td><strong>'{$displayName}'</strong> can view and update information for <strong>'{$row.display_name}'</strong></td></tr> | |
59 | {else} | |
60 | <tr><td class="label"> </td><td><strong>'{$row.display_name}'</strong> can view and update information for <strong>'{$displayName}'</strong></td></tr> | |
61 | {/if} | |
62 | {/if} | |
63 | {if $row.is_permission_b_a} | |
64 | {if $row.rtype EQ 'a_b' AND $is_contact_id_a} | |
65 | <tr><td class="label"> </td><td><strong>'{$row.display_name}'</strong> can view and update information for <strong>'{$displayName}'</strong></td></tr> | |
66 | {else} | |
67 | <tr><td class="label"> </td><td><strong>'{$displayName}'</strong> can view and update information for <strong>'{$row.display_name}'</strong></td></tr> | |
68 | {/if} | |
69 | {/if} | |
70 | ||
71 | <tr><td class="label">{ts}Status{/ts}</td><td>{if $row.is_active}{ts}Enabled{/ts} {else} {ts}Disabled{/ts}{/if}</td></tr> | |
72 | {/foreach} | |
73 | </table> | |
74 | {include file="CRM/Custom/Page/CustomDataView.tpl"} | |
75 | <div class="crm-submit-buttons"><input type="button" name='cancel' value="{ts}Done{/ts}" onclick="location.href='{crmURL p='civicrm/contact/view' q='action=browse&selectedChild=rel'}';"/></div> | |
76 | </div> | |
77 | {/if} | |
78 | ||
79 | {if $action eq 2 | $action eq 1} {* add and update actions *} | |
80 | <h3>{if $action eq 1}{ts}New Relationship{/ts}{else}{ts}Edit Relationship{/ts}{/if}</h3> | |
81 | <div class="crm-block crm-form-block crm-relationship-form-block"> | |
82 | {if $action eq 1} | |
83 | <div class="description"> | |
84 | {ts}Select the relationship type. Then locate target contact(s) for this relationship by entering a partial name and selecting from the dropdown, or clicking 'Search'. If the target contact does not exist, you can create a new contact.{/ts} | |
85 | </div> | |
86 | {/if} | |
87 | <table class="form-layout-compressed"> | |
88 | <tr class="crm-relationship-form-block-relationship_type_id"> | |
89 | <td class="label">{$form.relationship_type_id.label}</td><td>{$form.relationship_type_id.html}</td> | |
90 | {if $action EQ 2} {* action = update *} | |
91 | {literal} | |
92 | <script type="text/javascript"> | |
93 | var relType = 0; | |
94 | cj( function( ) { | |
95 | var relationshipType = cj('#relationship_type_id'); | |
96 | relationshipType.change( function( ) { | |
97 | changeCustomData( 'Relationship' ); | |
98 | currentEmployer( ); | |
99 | }); | |
100 | setPermissionStatus( relationshipType.val( ) ); | |
101 | }); | |
102 | </script> | |
103 | {/literal} | |
104 | <td><label>{$sort_name_b}</label></td></tr> | |
105 | <tr class="crm-relationship-form-block-is_current_employer"> | |
106 | <td class="label"> | |
107 | <span id="employee"><label>{ts}Current Employee?{/ts}</label></span> | |
108 | <span id="employer"><label>{ts}Current Employer?{/ts}</label></span> | |
109 | </td> | |
110 | <td id="current_employer">{$form.is_current_employer.html}</td> | |
111 | </tr> | |
112 | </table> | |
113 | {else} {* action = add *} | |
114 | </tr> | |
115 | {include file="CRM/Contact/Form/NewContact.tpl" newContactCallback="afterCreateNew()"} | |
116 | <tr class="crm-relationship-form-block-rel_contact"> | |
117 | <td colspan="2"> | |
118 | {literal} | |
119 | <script type="text/javascript"> | |
120 | var relType = 0; | |
121 | cj( function( ) { | |
122 | enableDisableContactSelection( ); | |
123 | createRelation( ); | |
124 | var relationshipType = cj('#relationship_type_id'); | |
125 | relationshipType.change( function() { | |
126 | enableDisableContactSelection( ); | |
127 | cj('#relationship-refresh-save').hide(); | |
128 | cj('#saveButtons').hide(); | |
129 | createRelation( ); | |
130 | changeCustomData( 'Relationship' ); | |
131 | setPermissionStatus( cj(this).val( ) ); | |
132 | }); | |
133 | setPermissionStatus( relationshipType.val( ) ); | |
134 | }); | |
135 | ||
136 | function enableDisableContactSelection( ) { | |
137 | var relationshipTypeValue = cj('#relationship_type_id').val(); | |
138 | var contactAutocomplete = cj('#contact_1'); | |
139 | ||
140 | //always reset field so that correct data url is linked | |
141 | contactAutocomplete.unautocomplete( ); | |
142 | ||
143 | if ( relationshipTypeValue ) { | |
144 | cj('#profiles_1').attr('disabled', false); | |
145 | contactAutocomplete.attr('disabled', false); | |
146 | contactAutocomplete.addClass('ac_input'); | |
147 | buildCreateNewSelect( 'profiles_1', relationshipTypeValue ); | |
148 | } else { | |
149 | cj('#profiles_1').attr('disabled', true); | |
150 | contactAutocomplete.removeClass('ac_input'); | |
151 | contactAutocomplete.attr('disabled', true); | |
152 | } | |
153 | } | |
154 | ||
155 | function afterCreateNew() { | |
156 | var relType = cj('#relationship_type_id').val( ); | |
157 | var contactSelected = cj('#contact_1').val( ); | |
158 | if ( relType && contactSelected ) { | |
159 | cj('#relationship-refresh-save').show( ); | |
160 | buildRelationFields( relType ); | |
161 | } | |
162 | } | |
163 | ||
164 | function createRelation( ) { | |
165 | var relType = cj('#relationship_type_id').val( ); | |
166 | var relContact = cj('#contact_1'); | |
167 | if ( relType ) { | |
168 | var dataUrl = {/literal}'{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=relationship&rel="}'{literal} + relType; | |
401906c1 | 169 | relContact.autocomplete( dataUrl, { width : 200, selectFirst : false, matchContains: true, max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal} }); |
6a488035 TO |
170 | relContact.result(function( event, data ) { |
171 | cj("input[name='contact_select_id[1]']").val(data[1]); | |
172 | cj('#relationship-refresh-save').show( ); | |
173 | buildRelationFields( relType ); | |
174 | }); | |
175 | } else { | |
176 | relContact.unautocomplete( ); | |
177 | } | |
178 | } | |
179 | ||
180 | function buildCreateNewSelect( selectID, relType ) { | |
181 | selectID = '#' + selectID; | |
182 | cj( selectID ).html(''); | |
183 | var postUrl = "{/literal}{crmURL p='civicrm/ajax/relationshipContactTypeList' h=0}{literal}"; | |
184 | cj.post( postUrl, { relType: relType }, | |
185 | function ( response ) { | |
186 | cj( selectID ).get(0).add(new Option('{/literal}{ts escape="js"}- create new contact -{/ts}{literal}', ''), document.all ? i : null); | |
187 | response = eval( response ); | |
188 | for (i = 0; i < response.length; i++) { | |
189 | cj( selectID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null); | |
190 | } | |
191 | } | |
192 | ); | |
193 | } | |
194 | ||
195 | </script> | |
196 | {/literal} | |
197 | </td> | |
198 | </tr> | |
199 | </table> | |
200 | <div class="crm-submit-buttons"> | |
201 | <span id="relationship-refresh" class="crm-button crm-button-type-refresh crm-button_qf_Relationship_refresh">{$form._qf_Relationship_refresh.html}</span> | |
202 | <span id="relationship-refresh-save" class="crm-button crm-button-type-save crm-button_qf_Relationship_refresh_save" style="display:none">{$form._qf_Relationship_refresh_save.html}</span> | |
203 | <span class="crm-button crm-button-type-cancel crm-button_qf_Relationship_cancel">{$form._qf_Relationship_cancel.html}</span> | |
204 | </div> | |
205 | <div class="clear"></div> | |
206 | ||
207 | {if $searchDone } {* Search button clicked *} | |
208 | {if $searchCount || $callAjax} | |
209 | {if $searchRows || $callAjax} {* we got rows to display *} | |
210 | <fieldset id="searchResult"><legend>{ts}Mark Target Contact(s) for this Relationship{/ts}</legend> | |
211 | <div class="description"> | |
212 | {ts}Mark the target contact(s) for this relationship if it appears below. Otherwise you may modify the search name above and click Search again.{/ts} | |
213 | </div> | |
214 | {strip} | |
215 | {if $callAjax} | |
216 | <div id="count_selected"> </div><br /> | |
217 | {$form.store_contacts.html} | |
218 | ||
219 | {if $isEmployeeOf || $isEmployerOf} | |
220 | {$form.store_employer.html} | |
221 | {/if} | |
222 | {include file="CRM/common/jsortable.tpl" sourceUrl=$sourceUrl useAjax=1 callBack=1 } | |
223 | {/if} | |
224 | ||
225 | <table id="rel-contacts" class="pagerDisplay"> | |
226 | <thead> | |
227 | <tr class="columnheader"> | |
228 | <th id="nosort" class="contact_select"> </th> | |
229 | <th>{ts}Name{/ts}</th> | |
230 | {if $isEmployeeOf}<th id="nosort" class="current_employer">{ts}Current Employer?{/ts}</th> | |
231 | {elseif $isEmployerOf}<th id="nosort" class="current_employer">{ts}Current Employee?{/ts}</th>{/if} | |
232 | <th>{ts}City{/ts}</th> | |
233 | <th>{ts}State{/ts}</th> | |
234 | <th>{ts}Email{/ts}</th> | |
235 | <th>{ts}Phone{/ts}</th> | |
236 | </tr> | |
237 | </thead> | |
238 | <tbody> | |
239 | {if !$callAjax} | |
240 | {foreach from=$searchRows item=row} | |
241 | <tr class="{cycle values="odd-row,even-row"}"> | |
242 | <td class="contact_select">{$form.contact_check[$row.id].html}</td> | |
243 | <td>{$row.type} {$row.name}</td> | |
244 | {if $isEmployeeOf}<td>{$form.employee_of[$row.id].html}</td> | |
245 | {elseif $isEmployerOf}<td>{$form.employer_of[$row.id].html}</td>{/if} | |
246 | <td>{$row.city}</td> | |
247 | <td>{$row.state}</td> | |
248 | <td>{$row.email}</td> | |
249 | <td>{$row.phone}</td> | |
250 | </tr> | |
251 | {/foreach} | |
252 | {else} | |
253 | <tr><td colspan="5" class="dataTables_empty">Loading data from server</td></tr> | |
254 | {/if} | |
255 | </tbody> | |
256 | </table> | |
257 | {/strip} | |
258 | </fieldset> | |
259 | <div class="spacer"></div> | |
260 | {else} {* too many results - we display only 50 *} | |
261 | {if $duplicateRelationship} | |
262 | {capture assign=infoTitle}{ts}Duplicate relationship.{/ts}{/capture} | |
263 | {capture assign=infoMessage}{ts}This relationship already exists.{/ts}{/capture} | |
264 | {else} | |
265 | {capture assign=infoTitle}{ts}Too many matching results.{/ts}{/capture} | |
266 | {capture assign=infoMessage}{ts}Please narrow your search by entering a more complete target contact name.{/ts}{/capture} | |
267 | {/if} | |
268 | {include file="CRM/common/info.tpl"} | |
269 | {/if} | |
270 | {else} {* no valid matches for name + contact_type *} | |
271 | {capture assign=infoTitle}{ts}No matching results for{/ts}{/capture} | |
272 | {capture assign=infoMessage}<ul><li>{ts 1=$form.contact_1.value}Name like: %1{/ts}</li><li>{ts}Contact Type{/ts}: {$contact_type_display}</li></ul>{ts}Check your spelling, or try fewer letters for the target contact name.{/ts}{/capture} | |
273 | {include file="CRM/common/info.tpl"} | |
274 | {/if} {* end if searchCount *} | |
275 | {else} | |
276 | {/if} {* end if searchDone *} | |
277 | {/if} {* end action = add *} | |
278 | ||
247506c6 | 279 | <div id='saveElements'> |
6a488035 TO |
280 | {if $action EQ 1} |
281 | <div id='addCurrentEmployer'> | |
282 | <table class="form-layout-compressed"> | |
283 | <tr class="crm-relationship-form-block-add_current_employer"> | |
284 | <td class="label">{$form.add_current_employer.label}</td> | |
285 | <td>{$form.add_current_employer.html}</td> | |
286 | </tr> | |
287 | </table> | |
288 | </div> | |
289 | <div id='addCurrentEmployee'> | |
290 | <table class="form-layout-compressed"> | |
291 | <tr class="crm-relationship-form-block-add_current_employee"> | |
292 | <td class="label">{$form.add_current_employee.label}</td> | |
293 | <td>{$form.add_current_employee.html}</td> | |
294 | </tr> | |
295 | </table> | |
296 | </div> | |
297 | {/if} | |
298 | <table class="form-layout-compressed"> | |
299 | <tr class="crm-relationship-form-block-start_date"> | |
300 | <td class="label">{$form.start_date.label}</td> | |
301 | <td>{include file="CRM/common/jcalendar.tpl" elementName=start_date}</td></tr> | |
302 | <tr class="crm-relationship-form-block-end_date"> | |
303 | <td class="label">{$form.end_date.label}</td> | |
304 | <td>{include file="CRM/common/jcalendar.tpl" elementName=end_date}<br /> | |
305 | <span class="description">{ts}If this relationship has start and/or end dates, specify them here.{/ts}</span></td> | |
306 | </tr> | |
307 | <tr class="crm-relationship-form-block-description"> | |
308 | <td class="label">{$form.description.label}</td> | |
309 | <td>{$form.description.html}</td> | |
310 | </tr> | |
311 | <tr class="crm-relationship-form-block-note"> | |
312 | <td class="label">{$form.note.label}</td> | |
313 | <td>{$form.note.html}</td> | |
314 | </tr> | |
315 | <tr class="crm-relationship-form-block-is_permission_a_b"> | |
316 | <td class="label"></td><td>{$form.is_permission_a_b.html} | |
317 | <span id='permision_a_b-a_b' class="hiddenElement"> | |
318 | {if $action eq 1} | |
319 | <strong>'{$sort_name_a}'</strong> {ts}can view and update information for selected contact(s){/ts} | |
320 | {else} | |
321 | <strong>'{$sort_name_a}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_b}'</strong> | |
322 | {/if} | |
323 | </span> | |
247506c6 | 324 | <span id='permision_a_b-b_a' class="hiddenElement"> |
6a488035 TO |
325 | {if $action eq 1} |
326 | <strong>{ts}Selected contact(s)</strong> can view and update information for {/ts} <strong>'{$sort_name_a}'</strong> | |
327 | {else} | |
328 | <strong>'{$sort_name_b}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_a}'</strong> | |
329 | {/if} | |
330 | </span> | |
331 | </td> | |
332 | </tr> | |
333 | <tr class="crm-relationship-form-block-is_permission_b_a"> | |
334 | <td class="label"></td><td>{$form.is_permission_b_a.html} | |
335 | <span id='permision_b_a-b_a' class="hiddenElement"> | |
336 | {if $action eq 1} | |
337 | <strong>'{$sort_name_a}'</strong> {ts}can view and update information for selected contact(s){/ts} | |
338 | {else} | |
339 | <strong>'{$sort_name_a}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_b}'</strong> | |
340 | {/if} | |
341 | </span> | |
247506c6 | 342 | <span id='permision_b_a-a_b' class="hiddenElement"> |
6a488035 TO |
343 | {if $action eq 1} |
344 | <strong>{ts}Selected contact(s)</strong> can view and update information for {/ts} <strong>'{$sort_name_a}'</strong> | |
345 | {else} | |
346 | <strong>'{$sort_name_b}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_a}'</strong> | |
347 | {/if} | |
348 | </span> | |
349 | </td> | |
350 | </tr> | |
351 | <tr class="crm-relationship-form-block-is_active"> | |
352 | <td class="label">{$form.is_active.label}</td> | |
353 | <td>{$form.is_active.html}</td> | |
354 | </tr> | |
355 | </table> | |
356 | {literal} | |
357 | <script type="text/javascript"> | |
358 | function setPermissionStatus( relTypeDirection ) { | |
359 | var direction = relTypeDirection.split( '_' ); | |
360 | cj('#permision_a_b-' + direction[1] + '_' + direction[2] ).show( ); | |
361 | cj('#permision_a_b-' + direction[2] + '_' + direction[1] ).hide( ); | |
362 | cj('#permision_b_a-' + direction[1] + '_' + direction[2] ).show( ); | |
363 | cj('#permision_b_a-' + direction[2] + '_' + direction[1] ).hide( ); | |
364 | } | |
365 | </script> | |
366 | {/literal} | |
367 | </div>{* end of save element div *} | |
368 | <div id="customData"></div> | |
369 | <div class="spacer"></div> | |
370 | <div class="crm-submit-buttons" id="saveButtons"> {include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
371 | {if $action EQ 1} | |
372 | <div class="crm-submit-buttons" id="saveDetails"> | |
373 | <span class="crm-button crm-button-type-save crm-button_qf_Relationship_refresh_savedetails">{$form._qf_Relationship_refresh_savedetails.html}</span> | |
374 | <span class="crm-button crm-button-type-cancel crm-button_qf_Relationship_cancel">{$form._qf_Relationship_cancel.html}</span> | |
375 | </div> | |
376 | {/if} | |
377 | </div> {* close main block div *} | |
378 | {/if} | |
379 | ||
380 | {if $action eq 8} | |
381 | <fieldset><legend>{ts}Delete Relationship{/ts}</legend> | |
382 | <div class="status"> | |
383 | {capture assign=relationshipsString}{$currentRelationships.$id.relation}{ $disableRelationships.$id.relation} {$currentRelationships.$id.name}{ $disableRelationships.$id.name }{/capture} | |
384 | {ts 1=$relationshipsString}Are you sure you want to delete the Relationship '%1'?{/ts} | |
385 | </div> | |
386 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
387 | </fieldset> | |
388 | {/if} | |
389 | {/if} {* close of custom data else*} | |
390 | ||
391 | {if $callAjax} | |
392 | {literal} | |
393 | <script type="text/javascript"> | |
394 | var contact_checked = new Array(); | |
395 | var employer_checked = new Array(); | |
396 | var employer_holdelement = new Array(); | |
397 | var countSelected = useEmployer = isRadio = 0; | |
398 | ||
399 | {/literal} {if $isEmployeeOf || $isEmployerOf} {literal} | |
400 | var storeElement = 'store_employers'; | |
401 | var employerClass = 'current_employer'; | |
402 | useEmployer = 1; | |
403 | {/literal} {/if} {if $isEmployeeOf} {literal} | |
404 | isRadio = 1; | |
405 | {/literal} {/if} {literal} | |
406 | ||
407 | cj( function( ) { | |
408 | // clear old data if any | |
409 | cj('#store_contacts').val(''); | |
410 | if ( useEmployer ) { | |
411 | cj('#store_employers').val(''); | |
412 | } | |
413 | ||
00707e54 | 414 | cj('.pagerDisplay').on('click', '.contact_select input', function () { |
6a488035 TO |
415 | var valueSelected = cj(this).val(); |
416 | if ( cj(this).attr('checked') ) { | |
417 | contact_checked[valueSelected] = valueSelected; | |
418 | countSelected++; | |
419 | } else if( contact_checked[valueSelected] ) { | |
420 | delete contact_checked[valueSelected]; | |
421 | countSelected--; | |
422 | if ( useEmployer && employer_holdelement[valueSelected] ) { | |
423 | cj( employer_holdelement[valueSelected] ).attr('checked',false); | |
424 | delete employer_checked[valueSelected]; | |
425 | delete employer_holdelement[valueSelected]; | |
426 | } | |
427 | } | |
428 | cj('#count_selected').html(countSelected +' Contacts selected.') | |
429 | } ); | |
430 | ||
431 | if ( useEmployer ) { | |
00707e54 | 432 | cj('.pagerDisplay').on('click', '.'+ employerClass +' input', function () { |
6a488035 TO |
433 | var valueSelected = cj(this).val(); |
434 | if ( isRadio ) { | |
435 | employer_checked = new Array(); | |
436 | } | |
437 | if ( cj(this).attr('checked') ) { | |
438 | // add validation to match with selected contacts | |
439 | if( !contact_checked[valueSelected] ) { | |
440 | cj(this).crmError({/literal}'{ts escape="js"}Current employer / Current employee should be among the selected contacts.{/ts}'{literal}); | |
441 | cj(this).attr('checked',false); | |
442 | } else { | |
443 | employer_checked[valueSelected] = valueSelected; | |
444 | employer_holdelement[valueSelected] = this; | |
445 | } | |
446 | ||
447 | } else if ( employer_checked[valueSelected] ) { | |
448 | delete employer_checked[valueSelected]; | |
449 | delete employer_holdelement[valueSelected]; | |
450 | } | |
451 | } ); | |
452 | } | |
453 | ||
454 | }); | |
455 | ||
456 | function checkSelected( ) { | |
457 | cj('.pagerDisplay tbody tr .contact_select input').each( function( ) { | |
458 | if ( contact_checked[cj(this).val()] ) { | |
459 | cj(this).attr('checked',true); | |
460 | } | |
461 | }); | |
462 | ||
463 | if ( useEmployer ) { | |
464 | // register new elements | |
465 | employer_holdelement = new Array(); | |
466 | cj('.pagerDisplay tbody tr .'+ employerClass +' input').each( function( ) { | |
467 | if ( employer_checked[cj(this).val()] ) { | |
468 | cj(this).attr('checked',true); | |
469 | employer_holdelement[cj(this).val()] = this; | |
470 | } | |
471 | }); | |
472 | } | |
473 | } | |
474 | ||
475 | function submitAjaxData() { | |
48739ceb KJ |
476 | var total_checked = new Array(); |
477 | cj.each(contact_checked, function (index, value) { | |
478 | if (typeof value !== "undefined") { | |
479 | total_checked.push(value); | |
480 | } | |
481 | }); | |
482 | contact_checked = total_checked; | |
483 | ||
6a488035 TO |
484 | cj('#store_contacts').val( contact_checked.toString() ); |
485 | if ( useEmployer ) { | |
486 | cj('#store_employers').val( employer_checked.toString() ); | |
487 | } | |
488 | return true; | |
489 | } | |
490 | ||
491 | </script> | |
492 | {/literal} | |
493 | {/if} | |
494 | ||
495 | {if ($action EQ 1) OR ($action EQ 2) } | |
496 | {*include custom data js file*} | |
497 | {include file="CRM/common/customData.tpl"} | |
498 | {literal} | |
499 | <script type="text/javascript"> | |
500 | ||
501 | {/literal} {if $searchRows} {literal} | |
502 | cj(".contact_select .form-checkbox").each( function( ) { | |
503 | if (this) { | |
504 | cj(this).attr('checked',true); | |
505 | } | |
506 | }); | |
507 | {/literal} {/if} {literal} | |
508 | ||
509 | {/literal} {if $action EQ 1}{literal} | |
510 | cj('#saveDetails').hide( ); | |
511 | cj('#addCurrentEmployer').hide( ); | |
512 | cj('#addCurrentEmployee').hide( ); | |
513 | ||
514 | cj( function() { | |
515 | if ( cj.browser.msie ) { | |
516 | cj('#contact_1').keyup( function(e) { | |
517 | if( e.keyCode == 9 || e.keyCode == 13 ) { | |
518 | return false; | |
519 | } | |
520 | cj("input[name='contact_select_id[1]']").val(''); | |
521 | cj('#relationship-refresh').show( ); | |
522 | cj('#relationship-refresh-save').hide( ); | |
523 | }); | |
524 | } else { | |
525 | cj('#contact_1').focus( function() { | |
526 | cj("input[name='contact_select_id[1]']").val(''); | |
527 | cj('#relationship-refresh').show( ); | |
528 | cj('#relationship-refresh-save').hide( ); | |
529 | }); | |
530 | } | |
531 | }); | |
532 | ||
533 | {/literal}{if $searchRows || $callAjax}{literal} | |
534 | cj('#saveElements, #saveButtons').show(); | |
535 | {/literal}{else}{literal} | |
536 | cj('#saveElements, #saveButtons').hide(); | |
537 | {/literal}{/if}{/if}{literal} | |
538 | ||
539 | cj( function( ) { | |
540 | var relType = cj('#relationship_type_id').val( ); | |
541 | if ( relType ) { | |
542 | var relTypeId = relType.split("_"); | |
543 | if (relTypeId) { | |
544 | CRM.buildCustomData( 'Relationship', relTypeId[0]); | |
545 | } | |
546 | } else { | |
547 | CRM.buildCustomData('Relationship'); | |
548 | } | |
549 | }); | |
550 | ||
551 | function buildRelationFields( relType ) { | |
552 | {/literal} {if $action EQ 1} {literal} | |
553 | if ( relType ) { | |
554 | var relTypeId = relType.split("_"); | |
555 | if ( relTypeId[0] == 4 ) { | |
556 | if ( relTypeId[1] == 'a' ) { | |
557 | cj('#addCurrentEmployee').show(); | |
558 | cj('#addCurrentEmployer').hide(); | |
559 | } else { | |
560 | cj('#addCurrentEmployee').hide(); | |
561 | cj('#addCurrentEmployer').show(); | |
562 | } | |
563 | } else { | |
564 | cj('#addCurrentEmployee').hide(); | |
565 | cj('#addCurrentEmployer').hide(); | |
566 | } | |
567 | cj('#relationship-refresh').hide(); | |
568 | cj('#relationship-refresh-save').show(); | |
569 | cj('#details-save').show(); | |
570 | cj('#saveElements').show(); | |
571 | cj('#saveDetails').show(); | |
572 | {/literal}{if $searchRows || $callAjax}{literal} | |
573 | cj('#searchResult').hide(); | |
574 | {/literal}{/if}{literal} | |
575 | cj('#saveButtons').hide(); | |
576 | } | |
577 | {/literal}{/if}{literal} | |
578 | } | |
579 | ||
580 | function changeCustomData( cType ) { | |
581 | {/literal}{if $action EQ 1} {literal} | |
582 | cj('#customData').html(''); | |
583 | cj('#relationship-refresh').show(); | |
584 | cj('#saveElements').hide(); | |
585 | cj('#addCurrentEmployee').hide(); | |
586 | cj('#addCurrentEmployer').hide(); | |
587 | cj('#saveDetails').hide(); | |
588 | {/literal}{if $searchRows || $callAjax}{literal} | |
589 | cj('#searchResult').hide(); | |
590 | {/literal}{/if}{literal} | |
591 | {/literal}{/if} {literal} | |
592 | ||
593 | var relType = cj('#relationship_type_id').val( ); | |
594 | if ( relType ) { | |
595 | var relTypeId = relType.split("_"); | |
596 | if (relTypeId) { | |
597 | CRM.buildCustomData( cType, relTypeId[0]); | |
598 | } | |
599 | } else { | |
600 | CRM.buildCustomData( cType ); | |
601 | } | |
602 | } | |
603 | ||
604 | </script> | |
605 | {/literal} | |
606 | {/if} | |
607 | {if $action EQ 2} | |
608 | {literal} | |
609 | <script type="text/javascript"> | |
610 | currentEmployer( ); | |
611 | function currentEmployer( ) | |
612 | { | |
613 | var relType = document.getElementById('relationship_type_id').value; | |
614 | if ( relType == '4_a_b' ) { | |
615 | cj('#current_employer').show(); | |
616 | cj('#employee').show(); | |
617 | cj('#employer').hide(); | |
618 | } else if ( relType == '4_b_a' ) { | |
619 | cj('#current_employer').show(); | |
620 | cj('#employer').show(); | |
621 | cj('#employee').hide(); | |
622 | } else { | |
623 | cj('#employer').hide(); | |
624 | cj('#employee').hide(); | |
625 | cj('#current_employer').hide(); | |
626 | } | |
627 | } | |
628 | </script> | |
629 | {/literal} | |
630 | {/if} |