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

Revision 1446, 25.3 KB checked in by viani, 15 years ago (diff)

Ticket #637 - Incluido click-to-call no organograma do workflow e melhorias na interface.

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