Merge pull request #1516 from cividesk/CRM-13293
[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 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"><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 {* 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 <div class="crm-block crm-form-block crm-relationship-form-block">
84 {if $action eq 1}
85 <div class="description">
86 {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}
87 </div>
88 {/if}
89 <table class="form-layout-compressed">
90 <tr class="crm-relationship-form-block-relationship_type_id">
91 <td class="label">{$form.relationship_type_id.label}</td><td>{$form.relationship_type_id.html}</td>
92 {if $action EQ 2} {* action = update *}
93 {literal}
94 <script type="text/javascript">
95 var relType = 0;
96 cj( function( ) {
97 var relationshipType = cj('#relationship_type_id');
98 relationshipType.change( function( ) {
99 changeCustomData( 'Relationship' );
100 currentEmployer( );
101 });
102 setPermissionStatus( relationshipType.val( ) );
103 });
104 </script>
105 {/literal}
106 <td><label>{$sort_name_b}</label></td></tr>
107 <tr class="crm-relationship-form-block-is_current_employer">
108 <td class="label">
109 <span id="employee"><label>{ts}Current Employee?{/ts}</label></span>
110 <span id="employer"><label>{ts}Current Employer?{/ts}</label></span>
111 </td>
112 <td id="current_employer">{$form.is_current_employer.html}</td>
113 </tr>
114 </table>
115 {else} {* action = add *}
116 </tr>
117 {include file="CRM/Contact/Form/NewContact.tpl" newContactCallback="afterCreateNew()"}
118 <tr class="crm-relationship-form-block-rel_contact">
119 <td colspan="2">
120 {literal}
121 <script type="text/javascript">
122 var relType = 0;
123 cj( function( ) {
124 enableDisableContactSelection( );
125 createRelation( );
126 var relationshipType = cj('#relationship_type_id');
127 relationshipType.change( function() {
128 enableDisableContactSelection( );
129 cj('#relationship-refresh-save').hide();
130 cj('#saveButtons').hide();
131 createRelation( );
132 changeCustomData( 'Relationship' );
133 setPermissionStatus( cj(this).val( ) );
134 });
135 setPermissionStatus( relationshipType.val( ) );
136 });
137
138 function enableDisableContactSelection( ) {
139 var relationshipTypeValue = cj('#relationship_type_id').val();
140 var contactAutocomplete = cj('#contact_1');
141
142 //always reset field so that correct data url is linked
143 contactAutocomplete.unautocomplete( );
144
145 if ( relationshipTypeValue ) {
146 cj('#profiles_1').attr('disabled', false);
147 contactAutocomplete.attr('disabled', false);
148 contactAutocomplete.addClass('ac_input');
149 buildCreateNewSelect( 'profiles_1', relationshipTypeValue );
150 } else {
151 cj('#profiles_1').attr('disabled', true);
152 contactAutocomplete.removeClass('ac_input');
153 contactAutocomplete.attr('disabled', true);
154 }
155 }
156
157 function afterCreateNew() {
158 var relType = cj('#relationship_type_id').val( );
159 var contactSelected = cj('#contact_1').val( );
160 if ( relType && contactSelected ) {
161 cj('#relationship-refresh-save').show( );
162 buildRelationFields( relType );
163 }
164 }
165
166 function createRelation( ) {
167 var relType = cj('#relationship_type_id').val( );
168 var relContact = cj('#contact_1');
169 if ( relType ) {
170 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;
171 relContact.autocomplete( dataUrl, { width : 200, selectFirst : false, matchContains: true, max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal} });
172 relContact.result(function( event, data ) {
173 cj("input[name='contact_select_id[1]']").val(data[1]);
174 cj('#relationship-refresh-save').show( );
175 buildRelationFields( relType );
176 });
177 } else {
178 relContact.unautocomplete( );
179 }
180 }
181
182 function buildCreateNewSelect( selectID, relType ) {
183 selectID = '#' + selectID;
184 cj( selectID ).html('');
185 var postUrl = "{/literal}{crmURL p='civicrm/ajax/relationshipContactTypeList' h=0}{literal}";
186 cj.post( postUrl, { relType: relType },
187 function ( response ) {
188 cj( selectID ).get(0).add(new Option('{/literal}{ts escape="js"}- create new contact -{/ts}{literal}', ''), document.all ? i : null);
189 response = eval( response );
190 for (i = 0; i < response.length; i++) {
191 cj( selectID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
192 }
193 }
194 );
195 }
196
197 </script>
198 {/literal}
199 </td>
200 </tr>
201 </table>
202 <div class="crm-submit-buttons">
203 <span id="relationship-refresh" class="crm-button crm-button-type-refresh crm-button_qf_Relationship_refresh">{$form._qf_Relationship_refresh.html}</span>
204 <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>
205 <span class="crm-button crm-button-type-cancel crm-button_qf_Relationship_cancel">{$form._qf_Relationship_cancel.html}</span>
206 </div>
207 <div class="clear"></div>
208
209 {if $searchDone } {* Search button clicked *}
210 {if $searchCount || $callAjax}
211 {if $searchRows || $callAjax} {* we got rows to display *}
212 <fieldset id="searchResult"><legend>{ts}Mark Target Contact(s) for this Relationship{/ts}</legend>
213 <div class="description">
214 {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}
215 </div>
216 {strip}
217 {if $callAjax}
218 <div id="count_selected"> </div><br />
219 {$form.store_contacts.html}
220
221 {if $isEmployeeOf || $isEmployerOf}
222 {$form.store_employer.html}
223 {/if}
224 {include file="CRM/common/jsortable.tpl" sourceUrl=$sourceUrl useAjax=1 callBack=1 }
225 {/if}
226
227 <table id="rel-contacts" class="pagerDisplay">
228 <thead>
229 <tr class="columnheader">
230 <th id="nosort" class="contact_select">&nbsp;</th>
231 <th>{ts}Name{/ts}</th>
232 {if $isEmployeeOf}<th id="nosort" class="current_employer">{ts}Current Employer?{/ts}</th>
233 {elseif $isEmployerOf}<th id="nosort" class="current_employer">{ts}Current Employee?{/ts}</th>{/if}
234 <th>{ts}City{/ts}</th>
235 <th>{ts}State{/ts}</th>
236 <th>{ts}Email{/ts}</th>
237 <th>{ts}Phone{/ts}</th>
238 </tr>
239 </thead>
240 <tbody>
241 {if !$callAjax}
242 {foreach from=$searchRows item=row}
243 <tr class="{cycle values="odd-row,even-row"}">
244 <td class="contact_select">{$form.contact_check[$row.id].html}</td>
245 <td>{$row.type} {$row.name}</td>
246 {if $isEmployeeOf}<td>{$form.employee_of[$row.id].html}</td>
247 {elseif $isEmployerOf}<td>{$form.employer_of[$row.id].html}</td>{/if}
248 <td>{$row.city}</td>
249 <td>{$row.state}</td>
250 <td>{$row.email}</td>
251 <td>{$row.phone}</td>
252 </tr>
253 {/foreach}
254 {else}
255 <tr><td colspan="5" class="dataTables_empty">Loading data from server</td></tr>
256 {/if}
257 </tbody>
258 </table>
259 {/strip}
260 </fieldset>
261 <div class="spacer"></div>
262 {else} {* too many results - we display only 50 *}
263 {if $duplicateRelationship}
264 {capture assign=infoTitle}{ts}Duplicate relationship.{/ts}{/capture}
265 {capture assign=infoMessage}{ts}This relationship already exists.{/ts}{/capture}
266 {else}
267 {capture assign=infoTitle}{ts}Too many matching results.{/ts}{/capture}
268 {capture assign=infoMessage}{ts}Please narrow your search by entering a more complete target contact name.{/ts}{/capture}
269 {/if}
270 {include file="CRM/common/info.tpl"}
271 {/if}
272 {else} {* no valid matches for name + contact_type *}
273 {capture assign=infoTitle}{ts}No matching results for{/ts}{/capture}
274 {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}
275 {include file="CRM/common/info.tpl"}
276 {/if} {* end if searchCount *}
277 {else}
278 {/if} {* end if searchDone *}
279 {/if} {* end action = add *}
280
281 <div id='saveElements'>
282 {if $action EQ 1}
283 <div id='addCurrentEmployer'>
284 <table class="form-layout-compressed">
285 <tr class="crm-relationship-form-block-add_current_employer">
286 <td class="label">{$form.add_current_employer.label}</td>
287 <td>{$form.add_current_employer.html}</td>
288 </tr>
289 </table>
290 </div>
291 <div id='addCurrentEmployee'>
292 <table class="form-layout-compressed">
293 <tr class="crm-relationship-form-block-add_current_employee">
294 <td class="label">{$form.add_current_employee.label}</td>
295 <td>{$form.add_current_employee.html}</td>
296 </tr>
297 </table>
298 </div>
299 {/if}
300 <table class="form-layout-compressed">
301 <tr class="crm-relationship-form-block-start_date">
302 <td class="label">{$form.start_date.label}</td>
303 <td>{include file="CRM/common/jcalendar.tpl" elementName=start_date}</td></tr>
304 <tr class="crm-relationship-form-block-end_date">
305 <td class="label">{$form.end_date.label}</td>
306 <td>{include file="CRM/common/jcalendar.tpl" elementName=end_date}<br />
307 <span class="description">{ts}If this relationship has start and/or end dates, specify them here.{/ts}</span></td>
308 </tr>
309 <tr class="crm-relationship-form-block-description">
310 <td class="label">{$form.description.label}</td>
311 <td>{$form.description.html}</td>
312 </tr>
313 <tr class="crm-relationship-form-block-note">
314 <td class="label">{$form.note.label}</td>
315 <td>{$form.note.html}</td>
316 </tr>
317 <tr class="crm-relationship-form-block-is_permission_a_b">
318 <td class="label"></td><td>{$form.is_permission_a_b.html}
319 <span id='permision_a_b-a_b' class="hiddenElement">
320 {if $action eq 1}
321 <strong>'{$sort_name_a}'</strong> {ts}can view and update information for selected contact(s){/ts}
322 {else}
323 <strong>'{$sort_name_a}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_b}'</strong>
324 {/if}
325 </span>
326 <span id='permision_a_b-b_a' class="hiddenElement">
327 {if $action eq 1}
328 <strong>{ts}Selected contact(s)</strong> can view and update information for {/ts} <strong>'{$sort_name_a}'</strong>
329 {else}
330 <strong>'{$sort_name_b}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_a}'</strong>
331 {/if}
332 </span>
333 </td>
334 </tr>
335 <tr class="crm-relationship-form-block-is_permission_b_a">
336 <td class="label"></td><td>{$form.is_permission_b_a.html}
337 <span id='permision_b_a-b_a' class="hiddenElement">
338 {if $action eq 1}
339 <strong>'{$sort_name_a}'</strong> {ts}can view and update information for selected contact(s){/ts}
340 {else}
341 <strong>'{$sort_name_a}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_b}'</strong>
342 {/if}
343 </span>
344 <span id='permision_b_a-a_b' class="hiddenElement">
345 {if $action eq 1}
346 <strong>{ts}Selected contact(s)</strong> can view and update information for {/ts} <strong>'{$sort_name_a}'</strong>
347 {else}
348 <strong>'{$sort_name_b}'</strong> {ts}can view and update information for {/ts} <strong>'{$sort_name_a}'</strong>
349 {/if}
350 </span>
351 </td>
352 </tr>
353 <tr class="crm-relationship-form-block-is_active">
354 <td class="label">{$form.is_active.label}</td>
355 <td>{$form.is_active.html}</td>
356 </tr>
357 </table>
358 {literal}
359 <script type="text/javascript">
360 function setPermissionStatus( relTypeDirection ) {
361 var direction = relTypeDirection.split( '_' );
362 cj('#permision_a_b-' + direction[1] + '_' + direction[2] ).show( );
363 cj('#permision_a_b-' + direction[2] + '_' + direction[1] ).hide( );
364 cj('#permision_b_a-' + direction[1] + '_' + direction[2] ).show( );
365 cj('#permision_b_a-' + direction[2] + '_' + direction[1] ).hide( );
366 }
367 </script>
368 {/literal}
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).attr('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] ).attr('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).attr('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).attr('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).attr('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).attr('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").each( function( ) {
505 if (this) {
506 cj(this).attr('checked',true);
507 }
508 });
509 {/literal} {/if} {literal}
510
511 {/literal} {if $action EQ 1}{literal}
512 cj('#saveDetails').hide( );
513 cj('#addCurrentEmployer').hide( );
514 cj('#addCurrentEmployee').hide( );
515
516 cj( function() {
517 if ( cj.browser.msie ) {
518 cj('#contact_1').keyup( function(e) {
519 if( e.keyCode == 9 || e.keyCode == 13 ) {
520 return false;
521 }
522 cj("input[name='contact_select_id[1]']").val('');
523 cj('#relationship-refresh').show( );
524 cj('#relationship-refresh-save').hide( );
525 });
526 } else {
527 cj('#contact_1').focus( function() {
528 cj("input[name='contact_select_id[1]']").val('');
529 cj('#relationship-refresh').show( );
530 cj('#relationship-refresh-save').hide( );
531 });
532 }
533 });
534
535 {/literal}{if $searchRows || $callAjax}{literal}
536 cj('#saveElements, #saveButtons').show();
537 {/literal}{else}{literal}
538 cj('#saveElements, #saveButtons').hide();
539 {/literal}{/if}{/if}{literal}
540
541 cj( function( ) {
542 var relType = cj('#relationship_type_id').val( );
543 if ( relType ) {
544 var relTypeId = relType.split("_");
545 if (relTypeId) {
546 CRM.buildCustomData( 'Relationship', relTypeId[0]);
547 }
548 } else {
549 CRM.buildCustomData('Relationship');
550 }
551 });
552
553 function buildRelationFields( relType ) {
554 {/literal} {if $action EQ 1} {literal}
555 if ( relType ) {
556 var relTypeId = relType.split("_");
557 if ( relTypeId[0] == {/literal}{$employmentRelationship}{literal} ) {
558 if ( relTypeId[1] == 'a' ) {
559 cj('#addCurrentEmployee').show();
560 cj('#addCurrentEmployer').hide();
561 } else {
562 cj('#addCurrentEmployee').hide();
563 cj('#addCurrentEmployer').show();
564 }
565 } else {
566 cj('#addCurrentEmployee').hide();
567 cj('#addCurrentEmployer').hide();
568 }
569 cj('#relationship-refresh').hide();
570 cj('#relationship-refresh-save').show();
571 cj('#details-save').show();
572 cj('#saveElements').show();
573 cj('#saveDetails').show();
574 {/literal}{if $searchRows || $callAjax}{literal}
575 cj('#searchResult').hide();
576 {/literal}{/if}{literal}
577 cj('#saveButtons').hide();
578 }
579 {/literal}{/if}{literal}
580 }
581
582 function changeCustomData( cType ) {
583 {/literal}{if $action EQ 1} {literal}
584 cj('#customData').html('');
585 cj('#relationship-refresh').show();
586 cj('#saveElements').hide();
587 cj('#addCurrentEmployee').hide();
588 cj('#addCurrentEmployer').hide();
589 cj('#saveDetails').hide();
590 {/literal}{if $searchRows || $callAjax}{literal}
591 cj('#searchResult').hide();
592 {/literal}{/if}{literal}
593 {/literal}{/if} {literal}
594
595 var relType = cj('#relationship_type_id').val( );
596 if ( relType ) {
597 var relTypeId = relType.split("_");
598 if (relTypeId) {
599 CRM.buildCustomData( cType, relTypeId[0]);
600 }
601 } else {
602 CRM.buildCustomData( cType );
603 }
604 }
605
606 </script>
607 {/literal}
608 {/if}
609 {if $action EQ 2}
610 {literal}
611 <script type="text/javascript">
612 currentEmployer( );
613 function currentEmployer( )
614 {
615 var relType = document.getElementById('relationship_type_id').value;
616 if ( relType == "{/literal}{$employmentRelationship}{literal}" + "_a_b" ) {
617 cj('#current_employer').show();
618 cj('#employee').show();
619 cj('#employer').hide();
620 } else if ( relType == "{/literal}{$employmentRelationship}{literal}" + "_b_a" ) {
621 cj('#current_employer').show();
622 cj('#employer').show();
623 cj('#employee').hide();
624 } else {
625 cj('#employer').hide();
626 cj('#employee').hide();
627 cj('#current_employer').hide();
628 }
629 }
630 </script>
631 {/literal}
632 {/if}