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