source: trunk/workflow/js/userinterface/orgchart.js @ 7384

Revision 7384, 27.9 KB checked in by viani, 12 years ago (diff)

Ticket #3150 - Modificado indicativo de inatividade de usuário no organograma

Line 
1var workflowUserInterfaceEmployeeInfoTimer = null;
2var workflowUserInterfaceAreaInfoTimer = null;
3var workflowUserInterfaceCurrentAreaID = 0;
4var workflowUserInterfaceClickToCall = false;
5
6String.prototype.repeat = function(l)
7{
8        return new Array(l+1).join(this);
9};
10
11/* define the orgchart layout */
12function createOrgchartLayout()
13{
14        var content = '<div id="orgchartMenu"></div>';
15        content += '<div class="orgchartAreas" id="orgchartAreas"></div>';
16        content += '<div class="orgchartEmployees" id="orgchartEmployees"></div>';
17        content += '<div class="orgchartFooter" id="orgchartFooter"></div>';
18        content += '<div id="employeeInfo" class="employeeInfo" style="display: none;"></div>';
19        content += '<div id="areaInfo" class="employeeInfo" style="display: none;"></div>';
20
21        var div = $('content_id_4');
22        div.innerHTML = content;
23
24        draw_orgchart_folder();
25}
26
27/* generates the orgchart menu */
28function createOrgchartMenu(organizationID, imagemURL)
29{
30        var enderecoImagem = '';
31        if ((imagemURL != null) && (imagemURL != ''))
32                enderecoImagem = imagemURL;
33        else
34                enderecoImagem = '../index.php?menuaction=workflow.ui_orgchart.graph&organizationID=' + organizationID;
35
36        var content = '<ul class="horizontalMenu">';
37        content += '<li><a onclick="return false;">Visualizar : <select onclick="this.parentNode.parentNode.parentNode.lastChild.style.display = (this.options[1].selected) ? \'block\' : \'none\' ">'
38        content += '<option onclick="getAlphabeticalEmployees( )">Alfabética</option>'
39        content += '<option onclick="getHierarchicalArea( );" selected="true">Áreas</option>'
40        content += '<option onclick="getCostCenters( );">Centros de Custo</option>'
41        content += '<option onclick="getManning( )">Localidades</option>'
42        content += '<option onclick="getAreaWithSubtituteBoss( )">Substituição de Chefia</option>'
43        content += '<option onclick="getUsefulPhones( );">Telefones Úteis</option>'
44        content += '<option onclick="getCategoriesList( )">Vínculos</option>'
45        content += '</select></a></li>';
46        content += '<li><a href="#" onclick="window.open(\'' + enderecoImagem + '\', \'extwindow\'); return false;"><img src="templateFile.php?file=images/Process.gif">&nbsp;&nbsp;Gráfico</a></li>';
47        content += '<li><a><input type="text" name="search_term" id="search_term" onkeypress="if (((event.which) ? event.which : event.keyCode) == 13) $(\'search_span\').onclick(); return true;" /><span id="search_span" style="cursor: pointer;" onclick="tmp = $$(\'div#orgchartAreas a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); orgchartSearchEmployee($F(\'search_term\')); return false;">&nbsp;busca&nbsp;</span><img src="templateFile.php?file=images/help.png" title="Informe o nome, área ou telefone a ser pesquisado." style="cursor: help" /></a></li>';
48        content += '<li><a href="#" onclick="printArea(); return false;"><img src="templateFile.php?file=images/imprimir.png" width="16">&nbsp;&nbsp;Imprimir</a></li>';
49        content += '</ul>';
50        content += '<br/>';
51        content += '<br/>';
52
53        $('orgchartMenu').innerHTML = content;
54
55        $( 'search_term' ).focus( );
56}
57
58/* load the initial data */
59function draw_orgchart_folder()
60{
61        $('orgchartMenu').innerHTML = '';
62        $('orgchartAreas').innerHTML = '';
63        $('orgchartEmployees').innerHTML = '<br/><br/><br/><br/><center><i>&nbsp;&nbsp;carregando...<br/><img src="templateFile.php?file=images/loading.gif"></i></center>';
64        $('orgchartFooter').innerHTML = '';
65        $('orgchartMenu').innerHTML = '';
66
67        cExecute("$this.bo_userinterface.isVoipEnabled", function( data )
68        {
69                if ( typeof data == 'string' && data == 'VoipIsEnabled' )
70                        workflowUserInterfaceClickToCall = true;
71        }, "");
72
73        cExecute("$this.bo_userinterface.orgchart", orgchart, "");
74}
75
76/* process the initial data */
77function orgchart(data)
78{
79        if (_checkError(data))
80                return;
81
82        /* in case of any warning */
83        if (data['warning'])
84        {
85                $('content_id_4').innerHTML = '<br/><br/><center><strong>' + data['warning'] + '</strong></center><br/><br/>';
86                return;
87        }
88
89        if (data['areas'].length == 0)
90        {
91                $('content_id_4').innerHTML = "<br/><br/><center><strong>Nenhuma área cadastrada.</strong></center><br/><br/>";
92                return;
93        }
94
95        /* continue displaying the data */
96        displayHierarchicalAreas(data['areas']);
97        createOrgchartMenu(data['organizacao_id'], data['url_imagem']);
98        $('orgchartEmployees').innerHTML = '<br/><br/><br/><br/><center><i>faça uma busca ou clique em uma área para ver a lista de funcionários</i></center>';
99}
100
101function displayCostCenters(data)
102{
103        if (_checkError(data))
104                return;
105
106        var div = $('orgchartEmployees');
107        if (data.length == 0)
108        {
109                div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>';
110                return;
111        }
112
113        var content = '<center><h2>Centros de Custo</h2></center>';
114        content += '<table class="employeeList">';
115        content += '<tr><th>Nome</th><th>Número</th><th>Grupo</th></tr>';
116        var current;
117        var costCentersCount = data.length;
118        for (var i = 0; i < costCentersCount; i++)
119        {
120                current = data[i];
121                content += '<tr class="linha'+ i%2 + '" onmouseover="this.className=\'highlight0\'" onmouseout="this.className=\'linha' + i%2 + '\'">';
122                content += '<td>' + current['descricao'] + '</td>';
123                content += '<td>' + current['nm_centro_custo'] + '</td>';
124                content += '<td>' + current['grupo'] + '</td>';
125                content += '</tr>';
126        }
127        content += '</table>';
128        div.innerHTML = content;
129}
130
131function displayUsefulPhones( data )
132{
133        if ( _checkError( data ) )
134                return;
135
136        var div = $('orgchartEmployees');
137        if (data.length == 0)
138        {
139                div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>';
140                return;
141        }
142
143        var content = '<center><h2>Telefones Úteis</h2></center>';
144        content += '<table class="employeeList">';
145        content += '<tr><th>Localidade</th><th>Número</th></tr>';
146        var current;
147        for (var i = 0; i < data.length; i++)
148        {
149                current = data[i];
150                content += '<tr class="linha'+ i%2 + '" onmouseover="this.className=\'highlight0\'" onmouseout="this.className=\'linha' + i%2 + '\'">';
151                content += '<td>' + current[ 'descricao' ] + '</td>';
152                content += '<td>' + current[ 'numero' ] + '</td>';
153                content += '</tr>';
154        }
155        content += '</table>';
156        div.innerHTML = content;
157}
158
159function displayAreaWithSubtituteBoss( data )
160{
161        if ( _checkError( data ) )
162                return;
163
164        var div = $('orgchartEmployees');
165        if (data.length == 0)
166        {
167                div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>';
168                return;
169        }
170
171        var content = '<center><h2>Substituição de Chefia</h2></center>';
172        content += '<table class="employeeList">';
173        content += '<tr><th>Área</th><th>Titular</th><th>Substituto</th><th>Data de início</th><th>Data de término</th></tr>';
174        var current;
175        for (var i = 0; i < data.length; i++)
176        {
177                current = data[i];
178                content += '<tr class="linha'+ i%2 + '" onmouseover="this.className=\'highlight0\'" onmouseout="this.className=\'linha' + i%2 + '\'">';
179                content += '<td>' + current['area'] + '</td>';
180                content += '<td>' + current['titular'] + '</td>';
181                content += '<td>' + current['substituto'] + '</td>';
182                content += '<td>' + current['data_inicio'] + '</td>';
183                content += '<td>' + current['data_fim'] + '</td>';
184                content += '</tr>';
185        }
186        content += '</table>';
187        div.innerHTML = content;
188}
189
190function displayHierarchicalAreas(data)
191{
192        if (_checkError(data))
193                return;
194
195        function recursivePrint(subdata)
196        {
197                for (var i = 0; i < subdata.length; i++)
198                {
199                        div.innerHTML += '<br />' + '&nbsp;&nbsp;&nbsp;&nbsp;'.repeat(subdata[i]['depth']) + '<a href="javascript:void(0)" id="area_' + subdata[i]['area_id'] + '" onmouseover="getAreaInfoTimer(event, ' + subdata[i]['area_id'] + '); return false;" onmouseout="hideAreaInfo(); return false;" onclick="tmp = $$(\'div#orgchartAreas a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); this.addClassName(\'destaque\'); loadAreaEmployees(' + subdata[i]['area_id'] + ', \'' + subdata[i]['sigla'] + '\')">' + subdata[i]['sigla'] + '</a>';
200                        if (subdata[i]['children'].length > 0)
201                                recursivePrint(subdata[i]['children']);
202                }
203        }
204
205        var div = $('orgchartAreas');
206        div.innerHTML = "<center><strong>ÁREAS</strong></center>";
207        recursivePrint(data);
208}
209
210function getUsefulPhones( )
211{
212        workflowUserInterfaceCurrentAreaID = 0;
213
214        cExecute("$this.bo_userinterface.getUsefulPhones", displayUsefulPhones, "");
215}
216
217function getAreaWithSubtituteBoss( )
218{
219        workflowUserInterfaceCurrentAreaID = 0;
220
221        cExecute("$this.bo_userinterface.getAreaWithSubtituteBoss", displayAreaWithSubtituteBoss, "");
222}
223
224function getCostCenters()
225{
226        workflowUserInterfaceCurrentAreaID = 0;
227
228        cExecute("$this.bo_userinterface.getCostCenters", displayCostCenters, "");
229}
230
231function getHierarchicalArea()
232{
233        workflowUserInterfaceCurrentAreaID = 0;
234
235        cExecute("$this.bo_userinterface.getHierarchicalArea", displayHierarchicalAreas, "");
236}
237
238function getAreaList()
239{
240        cExecute("$this.bo_userinterface.getAreaList", displayHierarchicalAreas, "");
241}
242
243function getCategoriesList()
244{
245        workflowUserInterfaceCurrentAreaID = 0;
246
247        var div = $('orgchartEmployees');
248        div.innerHTML = '';
249
250        function resultGetCategoriesList(data)
251        {
252                if (_checkError(data))
253                        return;
254
255                var content = '<center><strong>VÍNCULOS</strong></center>';
256                for (var i = 0; i < data.length; i++)
257                        content += '<br/>' + '&nbsp;&nbsp;<a href="javascript:void(0)" id="categoria_' + data[i]['funcionario_categoria_id'] + '" onclick="tmp = $$(\'div#orgchartAreas a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); this.addClassName(\'destaque\'); loadCategoryEmployees(' + data[i]['funcionario_categoria_id'] + ', \'' + data[i]['descricao'] + '\')">' + data[i]['descricao'] + ' (' + data[i]['contagem'] + ')</a>';
258                content += '<br/><br/>';
259                $('orgchartAreas').innerHTML = content;
260        }
261
262        cExecute("$this.bo_userinterface.getCategoriesList", resultGetCategoriesList, "");
263}
264
265function getManning( )
266{
267        workflowUserInterfaceCurrentAreaID = 0;
268
269        var div = $('orgchartEmployees');
270        div.innerHTML = '';
271
272        function resultGetManning( data )
273        {
274                if ( _checkError( data ) )
275                        return;
276
277                var content = '<center><strong>Localidades</strong></center>';
278                for ( var i = 0; i < data.length; i++ )
279                        content += '<br/>' + '&nbsp;<a href="javascript:void(0)" id="localidade_' + data[i]['localidade_id'] + '" onclick="tmp = $$(\'div#orgchartAreas a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); this.addClassName(\'destaque\');loadManningEmployees(' + data[i]['localidade_id'] + ', \'' + data[i]['descricao'] + '\')">' + data[i]['descricao'] + '</a>';
280
281                content += '<br/><br/>';
282
283                $('orgchartAreas').innerHTML = content;
284        }
285
286        cExecute("$this.bo_userinterface.getManning", resultGetManning, "");
287}
288
289function printEmployeesHandler(data)
290{
291        /* check for errors */
292        if (_checkError(data))
293                return;
294
295        var div = $('orgchartEmployees');
296
297        /* no employee to list */
298        if ( ( ! data['employees'] || data['employees'].length == 0 ) &&
299                 ( ! data['bygroup'] || data['bygroup'].length == 0 ) &&
300                 ( ! data['bytelephone'] || data['bytelephone'].length == 0 ) )
301        {
302                div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>';
303                return;
304        }
305
306        if ( data['employees'] && data['employees'].length )
307        {
308                /* initialize varivables */
309                var content = '';
310                var employees = data['employees'];
311                var useCategories = false;
312                var useArea = false;
313
314                /* check the informations that will be displayed */
315                if (data['categories'])
316                        if (data['categories'].length > 1)
317                                useCategories = true;
318                if (employees[0]['area'])
319                        useArea = true;
320
321                /* build the display table (headers)*/
322                content += '<table id="employeeList" class="employeeList" style="clear: both">';
323                content += '<tr class="message_header">';
324                content += '<th>Nome</th>';
325                if (useArea)
326                        content += '<th>Área</th>';
327                content += '<th>Telefone</th>';
328                content += '</tr>';
329
330                /* if available, insert a menu to filter the categories */
331                if (useCategories)
332                {
333                        content += '<tr><td colspan="' + (useArea ? '3' : '2') + '">';
334                        content += '<ul class="horizontalMenu">';
335                        for (var i = 0; i < data['categories'].length; i++)
336                                content += '<li><a href="#" style="height: 2em; line-height: 2em;" onclick="highlightCategory(' + data['categories'][i]['funcionario_categoria_id'] + '); return false;">' + data['categories'][i]['descricao'] + ' (' + data['categories'][i]['contagem'] + ')</a></li>';
337                        content += '</ul>';
338                        content += '</td></tr>';
339                }
340
341                /* list the employees */
342                var complement = '';
343                var employeeNotFound = false;
344                for (var i = 0; i < employees.length; i++)
345                {
346                        if (employees[i]['chief'])
347                                complement = ' <strong>(' + ((employees[i]['chief'] == 1) ? 'Titular' : 'Substituto') + ')</strong>';
348                        else
349                                complement = '';
350                        if (employees[i]['removed'])
351                        {
352                                complement += ' (*)';
353                                employeeNotFound = true;
354                        }
355                        content += '<tr class="linha'+ i%2 + (useCategories ? ' categoria_' + employees[i]['funcionario_categoria_id'] : '') + '" onmouseover="this.className=\'highlight0\'" onmouseout="this.className=\'linha'+ i%2 + (useCategories ? ' categoria_' + employees[i]['funcionario_categoria_id'] : '') + '\'">';
356                        content += '<td><a href="javascript:void(0);" onmouseover="getEmployeeInfoTimer(event, ' + employees[i]['funcionario_id'] + '); return false;" onmouseout="hideEmployeeInfo(); return false;">' + employees[i]['cn'] + complement + '</a></td>';
357                        if (useArea)
358                                content += '<td><a href="javascript:void(0);" onclick="loadAreaEmployees(\''+employees[i]['area_id']+'\', \'' + employees[i]['area'] + '\')">' + employees[i]['area'] + '</a></td>';
359                        content += '<td align="center">';
360                        if ( ! workflowUserInterfaceClickToCall )
361                                content += employees[i]['telephoneNumber'];
362                        else
363                        {
364                                content += '<a href="javascript:void(0);" title="Discar para Telefone Comercial" onclick="callVoipConnect(\''+employees[i]['telephoneNumber']+'\')"';
365                                content += '>' + employees[i]['telephoneNumber'] + '</a>';
366                        }
367                        content += '</td></tr>';
368                }
369                content += '</table>';
370
371                /* display a indication that some employees where not found */
372                if (employeeNotFound)
373                {
374                        content += '<hr><p>(*) = Usuários não localizados no catálogo do Expresso.</p>';
375                }
376
377                if ( arguments[ 1 ] != 'returnResult' )
378                {
379                        /* display the employees list and go to the top of the page */
380                        div.innerHTML = content;
381                        window.scrollTo(0,0);
382                }
383                else
384                        return content;
385        }
386}
387
388function highlightCategory(categoryID)
389{
390        var rows = $('employeeList').childNodes[0].childNodes;
391        var categoryClass = 'categoria_' + categoryID;
392
393        var highlightClass = '';
394        var row;
395        for (var i = 1; i < rows.length; i++)
396        {
397                row = $(rows[i]);
398                /* in case alternated color rows are needed, just change the second 'highlight0' to something else (e.g. 'highlight1' which is alread defined) */
399                highlightClass = row.hasClassName('linha0') ? 'highlight0' : 'highlight0';
400                if (row.hasClassName(categoryClass))
401                        row.addClassName(highlightClass);
402                else
403                        row.removeClassName(highlightClass);
404        }
405}
406
407function loadAreaEmployees(areaID, areaName)
408{
409        workflowUserInterfaceCurrentAreaID = areaID;
410        $('orgchartEmployees').innerHTML = '';
411        cExecute('$this.bo_userinterface.getAreaEmployees', function( data )
412        {
413                var content = printEmployeesHandler( data, 'returnResult' );
414                if ( content )
415                        $('orgchartEmployees').innerHTML = '<center><h2>Área: ' + areaName + '</h2></center>' + content;
416        }, 'areaID=' + areaID);
417}
418
419function loadCategoryEmployees(categoryID, categoryName)
420{
421        workflowUserInterfaceCurrentAreaID = 0;
422        $('orgchartEmployees').innerHTML = '';
423        cExecute('$this.bo_userinterface.getCategoryEmployees', function( data )
424        {
425                var content = printEmployeesHandler( data, 'returnResult' );
426                if ( content )
427                        $('orgchartEmployees').innerHTML = '<center><h2>Vínculo: ' + categoryName + '</h2></center>' + content;
428        }, 'categoryID=' + categoryID);
429}
430
431function loadManningEmployees( locationID, locationName )
432{
433        workflowUserInterfaceCurrentAreaID = 0;
434        $('orgchartEmployees').innerHTML = '';
435        cExecute('$this.bo_userinterface.getManningEmployees', function( data )
436        {
437                var content = printEmployeesHandler( data, 'returnResult' );
438                if ( content )
439                        $('orgchartEmployees').innerHTML = '<center><h2>Localidade: ' + locationName + '</h2></center>' + content;
440        }, 'locationID=' + locationID);
441}
442
443function getAlphabeticalEmployees( )
444{
445        workflowUserInterfaceCurrentAreaID = 0;
446
447        var div = $('orgchartEmployees');
448        div.innerHTML = '';
449
450        var p_page = 0;
451        if ( arguments.length )
452        {
453                p_page = parseInt(arguments[ 0 ]);
454                if ( isNaN( p_page ) )
455                        p_page = 0;
456        }
457        cExecute('$this.bo_userinterface.getAlphabeticalEmployees', function( data )
458        {
459                var pagingData = data['paging_links'];
460                var output = '';
461                if (pagingData)
462                {
463                        var pagingSize = pagingData.length;
464                        for (var i = 0; i < pagingSize; i++)
465                        {
466                                if (pagingData[i].do_link == true)
467                                        output += '<a style="font-size: 13px" href="#" onclick="getAlphabeticalEmployees(' + pagingData[i].p_page + ');">' + pagingData[i].name + '</a>&nbsp;';
468                                else
469                                        output += '<strong style="font-size: 14px">' + pagingData[i].name + '</strong>&nbsp;';
470                        }
471                }
472
473                var content = '<center><h2>Vizualização Alfabética</h2></center>';
474                content += printEmployeesHandler( data, 'returnResult' );
475                content += '<br /><center>' + output + '</center>';
476                div.innerHTML = content;
477
478        }, 'p_page='+p_page);
479}
480
481function orgchartSearchEmployee(searchTerm)
482{
483        workflowUserInterfaceCurrentAreaID = 0;
484        var div = $('orgchartEmployees');
485        div.innerHTML = '';
486        cExecute('$this.bo_userinterface.searchEmployee', function( data )
487        {
488                div.innerHTML = '<center><h2>Resultado da Busca</h2>';
489                var content = printEmployeesHandler( data, 'returnResult' );
490                if ( content )
491                        div.innerHTML += '</center><span style="color:red">Busca pelo nome: ' + searchTerm.toUpperCase( ) + '</span>' + content;
492
493                // printing records found by group
494                if ( data['bygroup'] && data['bygroup'].length )
495                {
496                        employees = [ ];
497                        employees[ 'employees' ] = data['bygroup'];
498                        content = printEmployeesHandler( employees, 'returnResult' );
499                        if ( content )
500                                div.innerHTML += '<br/><br/><span style="color:red">Busca pelo setor: ' + searchTerm.toUpperCase( ) + '</span><br/>' + content;
501                }
502
503                // printing records found by telephoneNumber
504                if ( data['bytelephone'] && data['bytelephone'].length )
505                {
506                        employees = [ ];
507                        employees[ 'employees' ] = data['bytelephone'];
508                        content = printEmployeesHandler( employees, 'returnResult' );
509                        if ( content )
510                                div.innerHTML += '<br/><br/><span style="color:red">Busca pelo telefone: ' + searchTerm.toUpperCase( ) + '</span><br/>' + content;
511                }
512
513        }, 'searchTerm=' + searchTerm);
514}
515
516function printArea()
517{
518        if (workflowUserInterfaceCurrentAreaID == 0)
519                if (!confirm('Tem certeza de que deseja imprimir todo o Organograma?'))
520                        return false;
521        var endereco = '../index.php?menuaction=workflow.ui_userinterface.printArea&areaID=' + workflowUserInterfaceCurrentAreaID;
522        window.open(endereco, 'extwindow');
523}
524
525function getEmployeeInfoTimer(e, employeeID)
526{
527        var div = $('employeeInfo');
528        div.style.left = (Event.pointerX(e) - 50) + 'px';
529        div.style.top = (Event.pointerY(e) + 14) + 'px';
530        div.hide();
531
532        if (workflowUserInterfaceEmployeeInfoTimer != null)
533        {
534                workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
535                workflowUserInterfaceEmployeeInfoTimer = null;
536        }
537
538        workflowUserInterfaceEmployeeInfoTimer = setTimeout('getEmployeeInfo(' + employeeID + ')', 500);
539}
540
541function getEmployeeInfo(employeeID)
542{
543        function resultGetEmployeeInfo(data)
544        {
545                if (workflowUserInterfaceEmployeeInfoTimer == null)
546                        return;
547
548                workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
549                workflowUserInterfaceEmployeeInfoTimer = null;
550
551                var card_data = [ ];
552
553                for (var i = 0; i < data['info'].length; i++)
554                        card_data[ data[ 'info' ][ i ][ 'name' ] ] = data[ 'info' ][ i ][ 'value' ];
555
556                var card = document.createElement( 'div' );
557                card.style.fontSize = '12px';
558                card.style.padding = '5px';
559                card.style.marginRight = '70px';
560
561                card.onmouseover = function( )
562                {
563                        workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
564                        workflowUserInterfaceEmployeeInfoTimer = null;
565                }
566
567                card.onmouseout = function( )
568                {
569                        workflowUserInterfaceEmployeeInfoTimer = setTimeout( "$('employeeInfo').hide( )", 1000 );
570                }
571
572                var photo = document.createElement( 'img' );
573                photo.src = 'showUserPicture.php?userID=' + employeeID;
574                photo.style.position = 'absolute';
575                photo.style.right = '10px';
576
577                card.appendChild( photo );
578
579                if ( card_data[ 'Nome' ] )
580                {
581                        var name = document.createElement( 'span' );
582                        name.style.fontWeight = 'bold';
583                        name.appendChild( document.createTextNode( card_data[ 'Nome' ] ) );
584                        card.appendChild( name );
585                        card.appendChild( document.createElement( 'br' ) );
586                }
587
588                if ( card_data[ 'Título' ] )
589                        var role = card.appendChild( document.createTextNode( card_data[ 'Título' ] ) );
590
591                if ( card_data[ 'Área' ] )
592                {
593                        if ( role )
594                                card.appendChild( document.createTextNode( ' - ' ) );
595
596                        var area = document.createElement( 'a' );
597                        area.href = "javascript:void(0)";
598                        area.appendChild( document.createTextNode( card_data[ 'Área' ] ) );
599                        area.onclick = function( )
600                        {
601                                loadAreaEmployees( card_data[ 'ÁreaID' ], card_data[ 'Área' ] );
602                                $('employeeInfo').hide( );
603                        };
604                        card.appendChild( area );
605                }
606
607                if ( card_data[ 'Matrícula' ] )
608                {
609                        if ( role || area )
610                                card.appendChild( document.createElement( 'br' ) );
611                        card.appendChild( document.createTextNode( 'Matrícula : ' + card_data[ 'Matrícula' ] ) );
612                }
613
614                card.appendChild( document.createElement( 'br' ) );
615                card.appendChild( document.createElement( 'br' ) );
616
617                if ( card_data[ 'Empresa' ] )
618                {
619                        var company = document.createElement( 'span' );
620                        company.style.fontWeight = 'bold';
621                        company.appendChild( document.createTextNode( card_data[ 'Empresa' ] ) );
622                        card.appendChild( company );
623                        card.appendChild( document.createElement( 'br' ) );
624                }
625
626                if ( card_data[ 'Endereço' ] )
627                        var address = card.appendChild( document.createTextNode( card_data[ 'Endereço' ] ) );
628
629                if ( card_data[ 'Complemento' ] )
630                {
631                        if ( address )
632                                card.appendChild( document.createTextNode( ' - ' ) );
633                        var complement = card.appendChild( document.createTextNode( card_data[ 'Complemento' ] ) );
634                }
635
636                if ( address || complement )
637                        card.appendChild( document.createElement( 'br' ) );
638
639                if ( card_data[ 'Cep' ] )
640                        var zipcode = card.appendChild( document.createTextNode( card_data[ 'Cep' ] ) );
641
642                if ( card_data[ 'Bairro' ] )
643                {
644                        if ( zipcode )
645                                card.appendChild( document.createTextNode( ' - ' ) );
646                        var district = card.appendChild( document.createTextNode( card_data[ 'Bairro' ] ) );
647                }
648
649                if ( zipcode || district )
650                        card.appendChild( document.createElement( 'br' ) );
651
652                if ( card_data[ 'Cidade' ] )
653                        var city = card.appendChild( document.createTextNode( card_data[ 'Cidade' ] ) );
654
655                if ( card_data[ 'UF' ] )
656                {
657                        if ( city )
658                                card.appendChild( document.createTextNode( ' - ' ) );
659                        card.appendChild( document.createTextNode( card_data[ 'UF' ] ) );
660                }
661
662                card.appendChild( document.createElement( 'br' ) );
663                card.appendChild( document.createElement( 'br' ) );
664
665                if ( card_data[ 'Telefone' ] )
666                {
667                        var phone = document.createElement( ( workflowUserInterfaceClickToCall ) ? 'a' : 'span' );
668                        phone.appendChild( document.createTextNode( card_data[ 'Telefone' ] ) );
669                        phone.style.paddingLeft = '20px';
670                        phone.style.whiteSpace = 'nowrap';
671                        phone.style.background = 'url(templateFile.php?file=images/phone.png) no-repeat 0 0';
672
673                        var phoneNumber = card_data[ 'Telefone' ];
674                        if ( workflowUserInterfaceClickToCall )
675                        {
676                                phone.title = "Discar para Telefone Comercial"
677                                phone.onclick = function( )
678                                {
679                                        callVoipConnect( phoneNumber );
680                                }
681                        }
682
683                        card.appendChild( phone );
684                }
685               
686                var mobiles = card_data[ 'Mobile' ];
687                //var arr_mobiles = mobiles.split(',');
688               
689                for (var mob = 0; mob < mobiles.length; mob++) {
690                        if ( card_data[ 'Mobile' ] ) {
691                                card.appendChild( document.createElement( 'br' ) );
692                                var phone = document.createElement('span');
693                                phone.appendChild( document.createTextNode( mobiles[mob] ) );
694                                phone.style.paddingLeft = '20px';
695                                phone.style.whiteSpace = 'nowrap';
696                                phone.style.background = 'url(templateFile.php?file=images/mobile.png) no-repeat 0 0';
697                                card.appendChild( phone );
698                        }
699                }
700
701               
702                if ( card_data[ 'homePhone' ] ) {
703                        card.appendChild( document.createElement( 'br' ) );
704                        var phone = document.createElement( ( workflowUserInterfaceClickToCall ) ? 'a' : 'span' );
705                        phone.appendChild( document.createTextNode( card_data[ 'homePhone' ] ) );
706                        phone.style.paddingLeft = '20px';
707                        phone.style.whiteSpace = 'nowrap';
708                        phone.style.background = 'url(templateFile.php?file=images/homePhone.png) no-repeat 0 0';
709
710                        card.appendChild( phone );
711                }
712
713                card.appendChild( document.createElement( 'br' ) );
714                card.appendChild( document.createElement( 'br' ) );
715
716                if ( card_data[ 'e-mail' ] )
717                {
718                        var mail = document.createElement( 'a' );
719                        mail.appendChild( document.createTextNode( card_data[ 'e-mail' ] ) );
720                        mail.href = '../expressoMail1_2/index.php?to=' + card_data[ 'e-mail' ];
721                        mail.style.paddingLeft = '20px';
722                        mail.style.whiteSpace = 'nowrap';
723                        mail.style.background = 'url(templateFile.php?file=images/mail.png) no-repeat 0 0';
724                        card.appendChild( mail );
725                }
726
727                card.appendChild( document.createElement( 'br' ) );
728
729                if ( card_data[ 'sitio' ] )
730                {
731                        var sitio = document.createElement( 'a' );
732                        sitio.target = '_blank';
733                        sitio.href = card_data[ 'sitio' ];
734                        sitio.appendChild( document.createTextNode( card_data[ 'sitio' ] ) );
735                        sitio.style.paddingLeft = '20px';
736                        sitio.style.background = 'url(templateFile.php?file=images/sitio.png) no-repeat 0 2px';
737                        card.appendChild( sitio );
738                }
739
740                var pageYLimit = document.body.scrollTop + document.body.clientHeight;
741                var div = $('employeeInfo');
742
743                div.innerHTML = '';
744                div.appendChild( card );
745
746                if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit)
747                        div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight() - 50)) + 'px';
748                else
749                        div.style.top = ( parseInt(div.style.top.replace(/px/g, '')) - 50 ) + 'px';
750
751                div.show();
752        }
753        cExecute('$this.bo_userinterface.getEmployeeInfo', resultGetEmployeeInfo, 'funcionario_id=' + employeeID);
754}
755
756function hideEmployeeInfo()
757{
758        if (workflowUserInterfaceEmployeeInfoTimer != null)
759        {
760                workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
761                workflowUserInterfaceEmployeeInfoTimer = null;
762        }
763        workflowUserInterfaceEmployeeInfoTimer = setTimeout( "$('employeeInfo').hide()", 1000 );
764}
765
766function getAreaInfoTimer(e, areaID)
767{
768        var div = $('areaInfo');
769        div.style.left = (Event.pointerX(e) + 20) + 'px';
770        div.style.top = (Event.pointerY(e) + 14) + 'px';
771
772        if (workflowUserInterfaceAreaInfoTimer != null)
773        {
774                workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer);
775                workflowUserInterfaceAreaInfoTimer = null;
776        }
777
778        workflowUserInterfaceAreaInfoTimer = setTimeout('getAreaInfo(' + areaID + ')', 500);
779}
780
781function getAreaInfo(areaID)
782{
783        function resultGetAreaInfo(data)
784        {
785                if (workflowUserInterfaceAreaInfoTimer == null)
786                        return;
787
788                workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer);
789                workflowUserInterfaceAreaInfoTimer = null;
790
791                var content = '';
792                content += '<table><tr>';
793                content += '<td valign="top" style="padding-left: 12px;">';
794                for (var i = 0; i < data['info'].length; i++)
795                        content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>';
796
797                content += '</td></tr></table>';
798                var pageYLimit = document.body.scrollTop + document.body.clientHeight;
799                var div = $('areaInfo');
800                div.innerHTML = content;
801
802                if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit)
803                        div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px';
804                div.show();
805        }
806        cExecute('$this.bo_userinterface.getAreaInfo', resultGetAreaInfo, 'area_id=' + areaID);
807}
808
809function hideAreaInfo()
810{
811        if (workflowUserInterfaceAreaInfoTimer != null)
812        {
813                workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer);
814                workflowUserInterfaceAreaInfoTimer = null;
815        }
816        $('areaInfo').hide();
817}
818
819function callVoipConnect( phoneNumber )
820{
821        var handler_connectVoip = function(data){
822                if(!data) {
823                        alert("Error contacting VoIP server.");
824                }
825                else{
826                        alert("Requesting a VoIP call"+":\n"+data);
827                }
828        }
829
830        cExecute( '$this.bo_userinterface.callVoipConnect&to='+phoneNumber+"&typePhone=com", handler_connectVoip );
831}
Note: See TracBrowser for help on using the repository browser.