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

Revision 2042, 26.0 KB checked in by pedroerp, 14 years ago (diff)

Ticket #441 - Suporte a cadastro de substituições de chefia por períodos determinados.

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