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

Revision 1451, 25.8 KB checked in by rodsouza, 15 years ago (diff)

Ticket #637 - Habilitar o clique nos telefones apenas para as pessoas presente nos grupos inerentes ao VOIP.

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</span></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></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 += '</tr>';
183        }
184        content += '</table>';
185        div.innerHTML = content;
186}
187
188function displayHierarchicalAreas(data)
189{
190        if (_checkError(data))
191                return;
192
193        function recursivePrint(subdata)
194        {
195                for (var i = 0; i < subdata.length; i++)
196                {
197                        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>';
198                        if (subdata[i]['children'].length > 0)
199                                recursivePrint(subdata[i]['children']);
200                }
201        }
202
203        var div = $('orgchartAreas');
204        div.innerHTML = "<center><strong>ÁREAS</strong></center>";
205        recursivePrint(data);
206}
207
208function getUsefulPhones( )
209{
210        workflowUserInterfaceCurrentAreaID = 0;
211
212        cExecute("$this.bo_userinterface.getUsefulPhones", displayUsefulPhones, "");
213}
214
215function getAreaWithSubtituteBoss( )
216{
217        workflowUserInterfaceCurrentAreaID = 0;
218
219        cExecute("$this.bo_userinterface.getAreaWithSubtituteBoss", displayAreaWithSubtituteBoss, "");
220}
221
222function getCostCenters()
223{
224        workflowUserInterfaceCurrentAreaID = 0;
225
226        cExecute("$this.bo_userinterface.getCostCenters", displayCostCenters, "");
227}
228
229function getHierarchicalArea()
230{
231        workflowUserInterfaceCurrentAreaID = 0;
232
233        cExecute("$this.bo_userinterface.getHierarchicalArea", displayHierarchicalAreas, "");
234}
235
236function getAreaList()
237{
238        cExecute("$this.bo_userinterface.getAreaList", displayHierarchicalAreas, "");
239}
240
241function getCategoriesList()
242{
243        workflowUserInterfaceCurrentAreaID = 0;
244
245        var div = $('orgchartEmployees');
246        div.innerHTML = '';
247
248        function resultGetCategoriesList(data)
249        {
250                if (_checkError(data))
251                        return;
252
253                var content = '<center><strong>VÍNCULOS</strong></center>';
254                for (var i = 0; i < data.length; i++)
255                        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>';
256                content += '<br/><br/>';
257                $('orgchartAreas').innerHTML = content;
258        }
259
260        cExecute("$this.bo_userinterface.getCategoriesList", resultGetCategoriesList, "");
261}
262
263function getManning( )
264{
265        workflowUserInterfaceCurrentAreaID = 0;
266
267        var div = $('orgchartEmployees');
268        div.innerHTML = '';
269
270        function resultGetManning( data )
271        {
272                if ( _checkError( data ) )
273                        return;
274
275                var content = '<center><strong>Localidades</strong></center>';
276                for ( var i = 0; i < data.length; i++ )
277                        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>';
278
279                content += '<br/><br/>';
280
281                $('orgchartAreas').innerHTML = content;
282        }
283
284        cExecute("$this.bo_userinterface.getManning", resultGetManning, "");
285}
286
287function printEmployeesHandler(data)
288{
289        /* check for errors */
290        if (_checkError(data))
291                return;
292
293        var div = $('orgchartEmployees');
294
295        /* no employee to list */
296        if ( ( ! data['employees'] || data['employees'].length == 0 ) && ( ! data['bygroup'] || data['bygroup'].length == 0 ) )
297        {
298                div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>';
299                return;
300        }
301
302        if ( data['employees'] && data['employees'].length )
303        {
304                /* initialize varivables */
305                var content = '';
306                var employees = data['employees'];
307                var useCategories = false;
308                var useArea = false;
309
310                /* check the informations that will be displayed */
311                if (data['categories'])
312                        if (data['categories'].length > 1)
313                                useCategories = true;
314                if (employees[0]['area'])
315                        useArea = true;
316
317                /* build the display table (headers)*/
318                content += '<table id="employeeList" class="employeeList" style="clear: both">';
319                content += '<tr>';
320                content += '<th>Nome</th>';
321                if (useArea)
322                        content += '<th>Área</th>';
323                content += '<th>Telefone</th>';
324                content += '</tr>';
325
326                /* if available, insert a menu to filter the categories */
327                if (useCategories)
328                {
329                        content += '<tr><td colspan="' + (useArea ? '3' : '2') + '">';
330                        content += '<ul class="horizontalMenu">';
331                        for (var i = 0; i < data['categories'].length; i++)
332                                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>';
333                        content += '</ul>';
334                        content += '</td></tr>';
335                }
336
337                /* list the employees */
338                var complement = '';
339                for (var i = 0; i < employees.length; i++)
340                {
341                        if (employees[i]['chief'])
342                                complement = ' <strong>(' + ((employees[i]['chief'] == 1) ? 'Titular' : 'Substituto') + ')</strong>';
343                        else
344                                complement = '';
345                        if (employees[i]['removed'])
346                                complement += ' <font color="red">(excluído)</font>';
347                        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'] : '') + '\'">';
348                        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>';
349                        if (useArea)
350                                content += '<td><a href="javascript:void(0);" onclick="loadAreaEmployees(\''+employees[i]['area_id']+'\', \'' + employees[i]['area'] + '\')">' + employees[i]['area'] + '</a></td>';
351                        content += '<td align="center">';
352                        if ( ! workflowUserInterfaceClickToCall )
353                                content += employees[i]['telephoneNumber'];
354                        else
355                        {
356                                content += '<a href="javascript:void(0);" onclick="callVoipConnect(\''+employees[i]['telephoneNumber']+'\')"';
357                                content += '>' + employees[i]['telephoneNumber'] + '</a>';
358                        }
359                        content += '</td></tr>';
360                }
361                content += '</table>';
362
363                if ( arguments[ 1 ] != 'returnResult' )
364                {
365                        /* display the employees list and go to the top of the page */
366                        div.innerHTML = content;
367                        window.scrollTo(0,0);
368                }
369                else
370                        return content;
371        }
372}
373
374function highlightCategory(categoryID)
375{
376        var rows = $('employeeList').childNodes[0].childNodes;
377        var categoryClass = 'categoria_' + categoryID;
378
379        var highlightClass = '';
380        var row;
381        for (var i = 1; i < rows.length; i++)
382        {
383                row = $(rows[i]);
384                /* in case alternated color rows are needed, just change the second 'highlight0' to something else (e.g. 'highlight1' which is alread defined) */
385                highlightClass = row.hasClassName('linha0') ? 'highlight0' : 'highlight0';
386                if (row.hasClassName(categoryClass))
387                        row.addClassName(highlightClass);
388                else
389                        row.removeClassName(highlightClass);
390        }
391}
392
393function loadAreaEmployees(areaID, areaName)
394{
395        workflowUserInterfaceCurrentAreaID = areaID;
396        $('orgchartEmployees').innerHTML = '';
397        cExecute('$this.bo_userinterface.getAreaEmployees', function( data )
398        {
399                var content = printEmployeesHandler( data, 'returnResult' );
400                if ( content )
401                        $('orgchartEmployees').innerHTML = '<center><h2>Área: ' + areaName + '</h2></center>' + content;
402        }, 'areaID=' + areaID);
403}
404
405function loadCategoryEmployees(categoryID, categoryName)
406{
407        workflowUserInterfaceCurrentAreaID = 0;
408        $('orgchartEmployees').innerHTML = '';
409        cExecute('$this.bo_userinterface.getCategoryEmployees', function( data )
410        {
411                var content = printEmployeesHandler( data, 'returnResult' );
412                if ( content )
413                        $('orgchartEmployees').innerHTML = '<center><h2>Vínculo: ' + categoryName + '</h2></center>' + content;
414        }, 'categoryID=' + categoryID);
415}
416
417function loadManningEmployees( locationID, locationName )
418{
419        workflowUserInterfaceCurrentAreaID = 0;
420        $('orgchartEmployees').innerHTML = '';
421        cExecute('$this.bo_userinterface.getManningEmployees', function( data )
422        {
423                var content = printEmployeesHandler( data, 'returnResult' );
424                if ( content )
425                        $('orgchartEmployees').innerHTML = '<center><h2>Localidade: ' + locationName + '</h2></center>' + content;
426        }, 'locationID=' + locationID);
427}
428
429function getAlphabeticalEmployees( )
430{
431        workflowUserInterfaceCurrentAreaID = 0;
432
433        var div = $('orgchartEmployees');
434        div.innerHTML = '';
435
436        var p_page = 0;
437        if ( arguments.length )
438        {
439                p_page = parseInt(arguments[ 0 ]);
440                if ( isNaN( p_page ) )
441                        p_page = 0;
442        }
443        cExecute('$this.bo_userinterface.getAlphabeticalEmployees', function( data )
444        {
445                var pagingData = data['paging_links'];
446                var output = '';
447                if (pagingData)
448                {
449                        var pagingSize = pagingData.length;
450                        for (var i = 0; i < pagingSize; i++)
451                        {
452                                if (pagingData[i].do_link == true)
453                                        output += '<a style="font-size: 13px" href="#" onclick="getAlphabeticalEmployees(' + pagingData[i].p_page + ');">' + pagingData[i].name + '</a>&nbsp;';
454                                else
455                                        output += '<strong style="font-size: 14px">' + pagingData[i].name + '</strong>&nbsp;';
456                        }
457                }
458
459                var content = '<center><h2>Vizualização Alfabética</h2></center>';
460                content += printEmployeesHandler( data, 'returnResult' );
461                content += '<br /><center>' + output + '</center>';
462                div.innerHTML = content;
463
464        }, 'p_page='+p_page);
465}
466
467function orgchartSearchEmployee(searchTerm)
468{
469        workflowUserInterfaceCurrentAreaID = 0;
470        var div = $('orgchartEmployees');
471        div.innerHTML = '';
472        cExecute('$this.bo_userinterface.searchEmployee', function( data )
473        {
474                div.innerHTML = '<center><h2>Resultado da Busca</h2>';
475                var content = printEmployeesHandler( data, 'returnResult' );
476                if ( content )
477                        div.innerHTML += '</center><span style="color:red">Busca pelo nome: ' + searchTerm.toUpperCase( ) + '</span>' + content;
478
479                if ( data['bygroup'] && data['bygroup'].length )
480                {
481                        employees = [ ];
482                        employees[ 'employees' ] = data['bygroup'];
483                        content = printEmployeesHandler( employees, 'returnResult' );
484                        if ( content )
485                                div.innerHTML += '<br/><br/><span style="color:red">Busca pelo setor: ' + searchTerm.toUpperCase( ) + '</span><br/>' + content;
486                }
487
488        }, 'searchTerm=' + searchTerm);
489}
490
491function printArea()
492{
493        if (workflowUserInterfaceCurrentAreaID == 0)
494                if (!confirm('Tem certeza de que deseja imprimir todo o Organograma?'))
495                        return false;
496        var endereco = '../index.php?menuaction=workflow.ui_userinterface.printArea&areaID=' + workflowUserInterfaceCurrentAreaID;
497        window.open(endereco, 'extwindow');
498}
499
500function getEmployeeInfoTimer(e, employeeID)
501{
502        var div = $('employeeInfo');
503        div.style.left = (Event.pointerX(e) - 50) + 'px';
504        div.style.top = (Event.pointerY(e) + 14) + 'px';
505        div.hide();
506
507        if (workflowUserInterfaceEmployeeInfoTimer != null)
508        {
509                workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
510                workflowUserInterfaceEmployeeInfoTimer = null;
511        }
512
513        workflowUserInterfaceEmployeeInfoTimer = setTimeout('getEmployeeInfo(' + employeeID + ')', 500);
514}
515
516function getEmployeeInfo(employeeID)
517{
518        function resultGetEmployeeInfo(data)
519        {
520                if (workflowUserInterfaceEmployeeInfoTimer == null)
521                        return;
522
523                workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
524                workflowUserInterfaceEmployeeInfoTimer = null;
525
526                var card_data = [ ];
527
528                for (var i = 0; i < data['info'].length; i++)
529                        card_data[ data[ 'info' ][ i ][ 'name' ] ] = data[ 'info' ][ i ][ 'value' ];
530
531                var card = document.createElement( 'div' );
532                card.style.fontSize = '12px';
533                card.style.padding = '5px';
534                card.style.marginRight = '70px';
535
536                card.onmouseover = function( )
537                {
538                        workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
539                        workflowUserInterfaceEmployeeInfoTimer = null;
540                }
541
542                card.onmouseout = function( )
543                {
544                        workflowUserInterfaceEmployeeInfoTimer = setTimeout( "$('employeeInfo').hide( )", 1000 );
545                }
546
547                var photo = document.createElement( 'img' );
548                photo.src = 'showUserPicture.php?userID=' + employeeID;
549                photo.style.position = 'absolute';
550                photo.style.right = '10px';
551
552                card.appendChild( photo );
553
554                if ( card_data[ 'Nome' ] )
555                {
556                        var name = document.createElement( 'span' );
557                        name.style.fontWeight = 'bold';
558                        name.appendChild( document.createTextNode( card_data[ 'Nome' ] ) );
559                        card.appendChild( name );
560                        card.appendChild( document.createElement( 'br' ) );
561                }
562
563                if ( card_data[ 'Título' ] )
564                        var role = card.appendChild( document.createTextNode( card_data[ 'Título' ] ) );
565
566                if ( card_data[ 'Área' ] )
567                {
568                        if ( role )
569                                card.appendChild( document.createTextNode( ' - ' ) );
570
571                        var area = document.createElement( 'a' );
572                        area.href = "javascript:void(0)";
573                        area.appendChild( document.createTextNode( card_data[ 'Área' ] ) );
574                        area.onclick = function( )
575                        {
576                                loadAreaEmployees( card_data[ 'ÁreaID' ], card_data[ 'Área' ] );
577                                $('employeeInfo').hide( );
578                        };
579                        card.appendChild( area );
580                }
581
582                if ( card_data[ 'Matrícula' ] )
583                {
584                        if ( role || area )
585                                card.appendChild( document.createElement( 'br' ) );
586                        card.appendChild( document.createTextNode( 'Matrícula : ' + card_data[ 'Matrícula' ] ) );
587                }
588
589                card.appendChild( document.createElement( 'br' ) );
590                card.appendChild( document.createElement( 'br' ) );
591
592                if ( card_data[ 'Empresa' ] )
593                {
594                        var company = document.createElement( 'span' );
595                        company.style.fontWeight = 'bold';
596                        company.appendChild( document.createTextNode( card_data[ 'Empresa' ] ) );
597                        card.appendChild( company );
598                        card.appendChild( document.createElement( 'br' ) );
599                }
600
601                if ( card_data[ 'Endereço' ] )
602                        var address = card.appendChild( document.createTextNode( card_data[ 'Endereço' ] ) );
603
604                if ( card_data[ 'Complemento' ] )
605                {
606                        if ( address )
607                                card.appendChild( document.createTextNode( ' - ' ) );
608                        var complement = card.appendChild( document.createTextNode( card_data[ 'Complemento' ] ) );
609                }
610
611                if ( address || complement )
612                        card.appendChild( document.createElement( 'br' ) );
613
614                if ( card_data[ 'Cep' ] )
615                        var zipcode = card.appendChild( document.createTextNode( card_data[ 'Cep' ] ) );
616
617                if ( card_data[ 'Bairro' ] )
618                {
619                        if ( zipcode )
620                                card.appendChild( document.createTextNode( ' - ' ) );
621                        var district = card.appendChild( document.createTextNode( card_data[ 'Bairro' ] ) );
622                }
623
624                if ( zipcode || district )
625                        card.appendChild( document.createElement( 'br' ) );
626
627                if ( card_data[ 'Cidade' ] )
628                        var city = card.appendChild( document.createTextNode( card_data[ 'Cidade' ] ) );
629
630                if ( card_data[ 'UF' ] )
631                {
632                        if ( city )
633                                card.appendChild( document.createTextNode( ' - ' ) );
634                        card.appendChild( document.createTextNode( card_data[ 'UF' ] ) );
635                }
636
637                card.appendChild( document.createElement( 'br' ) );
638                card.appendChild( document.createElement( 'br' ) );
639
640                if ( card_data[ 'Telefone' ] )
641                {
642                        var phone = document.createElement( ( workflowUserInterfaceClickToCall ) ? 'a' : 'span' );
643                        phone.appendChild( document.createTextNode( card_data[ 'Telefone' ] ) );
644                        phone.style.paddingLeft = '20px';
645                        phone.style.whiteSpace = 'nowrap';
646                        phone.style.background = 'url(templateFile.php?file=images/phone.png) no-repeat 0 0';
647
648                        var phoneNumber = card_data[ 'Telefone' ];
649                        if ( workflowUserInterfaceClickToCall )
650                                phone.onclick = function( )
651                                {
652                                        callVoipConnect( phoneNumber );
653                                }
654
655                        card.appendChild( phone );
656                }
657
658                card.appendChild( document.createElement( 'br' ) );
659                card.appendChild( document.createElement( 'br' ) );
660
661                if ( card_data[ 'e-mail' ] )
662                {
663                        var mail = document.createElement( 'a' );
664                        mail.appendChild( document.createTextNode( card_data[ 'e-mail' ] ) );
665                        mail.href = '../expressoMail1_2/index.php?to=' + card_data[ 'e-mail' ];
666                        mail.style.paddingLeft = '20px';
667                        mail.style.whiteSpace = 'nowrap';
668                        mail.style.background = 'url(templateFile.php?file=images/mail.png) no-repeat 0 0';
669                        card.appendChild( mail );
670                }
671
672                card.appendChild( document.createElement( 'br' ) );
673
674                if ( card_data[ 'sitio' ] )
675                {
676                        var sitio = document.createElement( 'a' );
677                        sitio.target = '_blank';
678                        sitio.href = card_data[ 'sitio' ];
679                        sitio.appendChild( document.createTextNode( card_data[ 'sitio' ] ) );
680                        sitio.style.paddingLeft = '20px';
681                        sitio.style.background = 'url(templateFile.php?file=images/sitio.png) no-repeat 0 2px';
682                        card.appendChild( sitio );
683                }
684
685                var pageYLimit = document.body.scrollTop + document.body.clientHeight;
686                var div = $('employeeInfo');
687
688                div.innerHTML = '';
689                div.appendChild( card );
690
691                if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit)
692                        div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight() - 50)) + 'px';
693                else
694                        div.style.top = ( parseInt(div.style.top.replace(/px/g, '')) - 50 ) + 'px';
695
696                div.show();
697        }
698        cExecute('$this.bo_userinterface.getEmployeeInfo', resultGetEmployeeInfo, 'funcionario_id=' + employeeID);
699}
700
701function hideEmployeeInfo()
702{
703        if (workflowUserInterfaceEmployeeInfoTimer != null)
704        {
705                workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer);
706                workflowUserInterfaceEmployeeInfoTimer = null;
707        }
708        workflowUserInterfaceEmployeeInfoTimer = setTimeout( "$('employeeInfo').hide()", 1000 );
709}
710
711function getAreaInfoTimer(e, areaID)
712{
713        var div = $('areaInfo');
714        div.style.left = (Event.pointerX(e) + 20) + 'px';
715        div.style.top = (Event.pointerY(e) + 14) + 'px';
716
717        if (workflowUserInterfaceAreaInfoTimer != null)
718        {
719                workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer);
720                workflowUserInterfaceAreaInfoTimer = null;
721        }
722
723        workflowUserInterfaceAreaInfoTimer = setTimeout('getAreaInfo(' + areaID + ')', 500);
724}
725
726function getAreaInfo(areaID)
727{
728        function resultGetAreaInfo(data)
729        {
730                if (workflowUserInterfaceAreaInfoTimer == null)
731                        return;
732
733                workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer);
734                workflowUserInterfaceAreaInfoTimer = null;
735
736                var content = '';
737                content += '<table><tr>';
738                content += '<td valign="top" style="padding-left: 12px;">';
739                for (var i = 0; i < data['info'].length; i++)
740                        content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>';
741
742                content += '</td></tr></table>';
743                var pageYLimit = document.body.scrollTop + document.body.clientHeight;
744                var div = $('areaInfo');
745                div.innerHTML = content;
746
747                if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit)
748                        div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px';
749                div.show();
750        }
751        cExecute('$this.bo_userinterface.getAreaInfo', resultGetAreaInfo, 'area_id=' + areaID);
752}
753
754function hideAreaInfo()
755{
756        if (workflowUserInterfaceAreaInfoTimer != null)
757        {
758                workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer);
759                workflowUserInterfaceAreaInfoTimer = null;
760        }
761        $('areaInfo').hide();
762}
763
764function callVoipConnect( phoneNumber )
765{
766        var handler_connectVoip = function(data){
767                if(!data) {
768                        alert("Error contacting VoIP server.");
769                }
770                else{
771                        alert("Requesting a VoIP call"+":\n"+data);
772                }
773        }
774
775        cExecute( '$this.bo_userinterface.callVoipConnect&to='+phoneNumber+"&typePhone=com", handler_connectVoip );
776}
Note: See TracBrowser for help on using the repository browser.