var workflowUserInterfaceEmployeeInfoTimer = null; var workflowUserInterfaceAreaInfoTimer = null; var workflowUserInterfaceCurrentAreaID = 0; String.prototype.repeat = function(l) { return new Array(l+1).join(this); }; /* define the orgchart layout */ function createOrgchartLayout() { var content = '
'; content += '
'; content += '
'; content += '
'; content += ''; content += ''; var div = $('content_id_4'); div.innerHTML = content; draw_orgchart_folder(); } /* generates the orgchart menu */ function createOrgchartMenu(organizationID, imagemURL) { var enderecoImagem = ''; if ((imagemURL != null) && (imagemURL != '')) enderecoImagem = imagemURL; else enderecoImagem = '../index.php?menuaction=workflow.ui_orgchart.graph&organizationID=' + organizationID; var content = ''; content += '
'; content += '
'; $('orgchartMenu').innerHTML = content; } /* load the initial data */ function draw_orgchart_folder() { $('orgchartMenu').innerHTML = ''; $('orgchartAreas').innerHTML = ''; $('orgchartEmployees').innerHTML = '



  carregando...
'; $('orgchartFooter').innerHTML = ''; $('orgchartMenu').innerHTML = ''; cExecute("$this.bo_userinterface.orgchart", orgchart, ""); } /* process the initial data */ function orgchart(data) { if (_checkError(data)) return; /* in case of any warning */ if (data['warning']) { $('content_id_4').innerHTML = '

' + data['warning'] + '


'; return; } if (data['areas'].length == 0) { $('content_id_4').innerHTML = "

Nenhuma área cadastrada.


"; return; } /* continue displaying the data */ displayHierarchicalAreas(data['areas']); createOrgchartMenu(data['organizacao_id'], data['url_imagem']); $('orgchartEmployees').innerHTML = '



faça uma busca ou clique em uma área para ver a lista de funcionários
'; } function displayCostCenters(data) { if (_checkError(data)) return; var div = $('orgchartEmployees'); if (data.length == 0) { div.innerHTML = '

Nenhum registro encontrado
'; return; } var content = '

CENTROS DE CUSTO

'; content += ''; content += ''; var current; var costCentersCount = data.length; for (var i = 0; i < costCentersCount; i++) { current = data[i]; content += ''; content += ''; content += ''; content += ''; content += ''; } content += '
NomeNúmeroGrupo
' + current['descricao'] + '' + current['nm_centro_custo'] + '' + current['grupo'] + '
'; div.innerHTML = content; } function displayHierarchicalAreas(data) { if (_checkError(data)) return; function recursivePrint(subdata) { for (var i = 0; i < subdata.length; i++) { div.innerHTML += '
' + '    '.repeat(subdata[i]['depth']) + '' + subdata[i]['sigla'] + ''; if (subdata[i]['children'].length > 0) recursivePrint(subdata[i]['children']); } } var div = $('orgchartAreas'); div.innerHTML = "
ÁREAS
"; recursivePrint(data); } function getCostCenters() { cExecute("$this.bo_userinterface.getCostCenters", displayCostCenters, ""); } function getHierarchicalArea() { cExecute("$this.bo_userinterface.getHierarchicalArea", displayHierarchicalAreas, ""); } function getAreaList() { cExecute("$this.bo_userinterface.getAreaList", displayHierarchicalAreas, ""); } function getCategoriesList() { function resultGetCategoriesList(data) { if (_checkError(data)) return; var content = '
VÍNCULOS
'; for (var i = 0; i < data.length; i++) content += '
' + '  ' + data[i]['descricao'] + ' (' + data[i]['contagem'] + ')'; content += '

'; $('orgchartAreas').innerHTML = content; } cExecute("$this.bo_userinterface.getCategoriesList", resultGetCategoriesList, ""); } function printEmployeesHandler(data) { /* check for errors */ if (_checkError(data)) return; var div = $('orgchartEmployees'); /* no employee to list */ if (data['employees'].length == 0) { div.innerHTML = '

Nenhum registro encontrado
'; return; } /* initialize varivables */ var content = ''; var employees = data['employees']; var useCategories = false; var useArea = false; /* check the informations that will be displayed */ if (data['categories']) if (data['categories'].length > 1) useCategories = true; if (employees[0]['area']) useArea = true; /* build the display table (headers)*/ content += ''; content += ''; content += ''; if (useArea) content += ''; content += ''; content += ''; /* if available, insert a menu to filter the categories */ if (useCategories) { content += ''; } /* list the employees */ var complement = ''; for (var i = 0; i < employees.length; i++) { if (employees[i]['chief']) complement = ' (' + ((employees[i]['chief'] == 1) ? 'Titular' : 'Substituto') + ')'; else complement = ''; if (employees[i]['removed']) complement += ' (excluído)'; content += ''; content += ''; if (useArea) content += ''; content += ''; content += ''; } content += '
FuncionárioÁreaTelefone
'; content += ''; content += '
' + employees[i]['cn'] + complement + '' + employees[i]['area'] + '' + employees[i]['telephoneNumber'] + '
'; /* display the employees list and go to the top of the page */ div.innerHTML = content; window.scrollTo(0,0); } function highlightCategory(categoryID) { var rows = $('employeeList').childNodes[0].childNodes; var categoryClass = 'categoria_' + categoryID; var highlightClass = ''; var row; for (var i = 1; i < rows.length; i++) { row = $(rows[i]); /* in case alternated color rows are needed, just change the second 'highlight0' to something else (e.g. 'highlight1' which is alread defined) */ highlightClass = row.hasClassName('linha0') ? 'highlight0' : 'highlight0'; if (row.hasClassName(categoryClass)) row.addClassName(highlightClass); else row.removeClassName(highlightClass); } } function loadAreaEmployees(areaID) { workflowUserInterfaceCurrentAreaID = areaID; cExecute('$this.bo_userinterface.getAreaEmployees', printEmployeesHandler, 'areaID=' + areaID); } function loadCategoryEmployees(categoryID) { workflowUserInterfaceCurrentAreaID = 0; cExecute('$this.bo_userinterface.getCategoryEmployees', printEmployeesHandler, 'categoryID=' + categoryID); } function orgchartSearchEmployee(searchTerm) { workflowUserInterfaceCurrentAreaID = 0; cExecute('$this.bo_userinterface.searchEmployee', printEmployeesHandler, 'searchTerm=' + searchTerm); } function printArea() { if (workflowUserInterfaceCurrentAreaID == 0) if (!confirm('Tem certeza de que deseja imprimir todo o Organograma?')) return false; var endereco = '../index.php?menuaction=workflow.ui_userinterface.printArea&areaID=' + workflowUserInterfaceCurrentAreaID; window.open(endereco, 'extwindow'); } function getEmployeeInfoTimer(e, employeeID) { var div = $('employeeInfo'); div.style.left = (Event.pointerX(e) + 20) + 'px'; div.style.top = (Event.pointerY(e) + 14) + 'px'; if (workflowUserInterfaceEmployeeInfoTimer != null) { workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer); workflowUserInterfaceEmployeeInfoTimer = null; } workflowUserInterfaceEmployeeInfoTimer = setTimeout('getEmployeeInfo(' + employeeID + ')', 500); } function getEmployeeInfo(employeeID) { function resultGetEmployeeInfo(data) { if (workflowUserInterfaceEmployeeInfoTimer == null) return; workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer); workflowUserInterfaceEmployeeInfoTimer = null; var content = ''; content += '
'; content += ''; content += ''; for (var i = 0; i < data['info'].length; i++) content += '' + data['info'][i]['name'] + ': ' + data['info'][i]['value'] + '
'; content += '
'; var pageYLimit = document.body.scrollTop + document.body.clientHeight; var div = $('employeeInfo'); div.innerHTML = content; if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; div.show(); } cExecute('$this.bo_userinterface.getEmployeeInfo', resultGetEmployeeInfo, 'funcionario_id=' + employeeID); } function hideEmployeeInfo() { if (workflowUserInterfaceEmployeeInfoTimer != null) { workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer); workflowUserInterfaceEmployeeInfoTimer = null; } $('employeeInfo').hide(); } function getAreaInfoTimer(e, areaID) { var div = $('areaInfo'); div.style.left = (Event.pointerX(e) + 20) + 'px'; div.style.top = (Event.pointerY(e) + 14) + 'px'; if (workflowUserInterfaceAreaInfoTimer != null) { workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer); workflowUserInterfaceAreaInfoTimer = null; } workflowUserInterfaceAreaInfoTimer = setTimeout('getAreaInfo(' + areaID + ')', 500); } function getAreaInfo(areaID) { function resultGetAreaInfo(data) { if (workflowUserInterfaceAreaInfoTimer == null) return; workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer); workflowUserInterfaceAreaInfoTimer = null; var content = ''; content += ''; content += '
'; for (var i = 0; i < data['info'].length; i++) content += '' + data['info'][i]['name'] + ': ' + data['info'][i]['value'] + '
'; content += '
'; var pageYLimit = document.body.scrollTop + document.body.clientHeight; var div = $('areaInfo'); div.innerHTML = content; if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; div.show(); } cExecute('$this.bo_userinterface.getAreaInfo', resultGetAreaInfo, 'area_id=' + areaID); } function hideAreaInfo() { if (workflowUserInterfaceAreaInfoTimer != null) { workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer); workflowUserInterfaceAreaInfoTimer = null; } $('areaInfo').hide(); }