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