1 | var workflowUserInterfaceEmployeeInfoTimer = null; |
---|
2 | var workflowUserInterfaceAreaInfoTimer = null; |
---|
3 | var workflowUserInterfaceCurrentAreaID = 0; |
---|
4 | |
---|
5 | String.prototype.repeat = function(l) |
---|
6 | { |
---|
7 | return new Array(l+1).join(this); |
---|
8 | }; |
---|
9 | |
---|
10 | /* define the orgchart layout */ |
---|
11 | function 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 */ |
---|
27 | function 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 style="margin: 5px 5px 0 5px">Visualizar : <select onclick="this.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></li>'; |
---|
45 | content += '<li><a href="#" onclick="window.open(\'' + enderecoImagem + '\', \'extwindow\'); return false;"><img src="templateFile.php?file=images/Process.gif"> 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;"> busca</span></a></li>'; |
---|
47 | content += '<li><a href="#" onclick="printArea(); return false;"><img src="templateFile.php?file=images/imprimir.png" width="16"> Imprimir</a></li>'; |
---|
48 | content += '</ul>'; |
---|
49 | content += '<br/>'; |
---|
50 | content += '<br/>'; |
---|
51 | |
---|
52 | $('orgchartMenu').innerHTML = content; |
---|
53 | } |
---|
54 | |
---|
55 | /* load the initial data */ |
---|
56 | function draw_orgchart_folder() |
---|
57 | { |
---|
58 | $('orgchartMenu').innerHTML = ''; |
---|
59 | $('orgchartAreas').innerHTML = ''; |
---|
60 | $('orgchartEmployees').innerHTML = '<br/><br/><br/><br/><center><i> carregando...<br/><img src="templateFile.php?file=images/loading.gif"></i></center>'; |
---|
61 | $('orgchartFooter').innerHTML = ''; |
---|
62 | $('orgchartMenu').innerHTML = ''; |
---|
63 | |
---|
64 | cExecute("$this.bo_userinterface.orgchart", orgchart, ""); |
---|
65 | } |
---|
66 | |
---|
67 | /* process the initial data */ |
---|
68 | function orgchart(data) |
---|
69 | { |
---|
70 | if (_checkError(data)) |
---|
71 | return; |
---|
72 | |
---|
73 | /* in case of any warning */ |
---|
74 | if (data['warning']) |
---|
75 | { |
---|
76 | $('content_id_4').innerHTML = '<br/><br/><center><strong>' + data['warning'] + '</strong></center><br/><br/>'; |
---|
77 | return; |
---|
78 | } |
---|
79 | |
---|
80 | if (data['areas'].length == 0) |
---|
81 | { |
---|
82 | $('content_id_4').innerHTML = "<br/><br/><center><strong>Nenhuma área cadastrada.</strong></center><br/><br/>"; |
---|
83 | return; |
---|
84 | } |
---|
85 | |
---|
86 | /* continue displaying the data */ |
---|
87 | displayHierarchicalAreas(data['areas']); |
---|
88 | createOrgchartMenu(data['organizacao_id'], data['url_imagem']); |
---|
89 | $('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>'; |
---|
90 | } |
---|
91 | |
---|
92 | function displayCostCenters(data) |
---|
93 | { |
---|
94 | if (_checkError(data)) |
---|
95 | return; |
---|
96 | |
---|
97 | var div = $('orgchartEmployees'); |
---|
98 | if (data.length == 0) |
---|
99 | { |
---|
100 | div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
101 | return; |
---|
102 | } |
---|
103 | |
---|
104 | var content = ''; |
---|
105 | content += '<table class="employeeList">'; |
---|
106 | content += '<tr><th>Nome</th><th>Número</th><th>Grupo</th></tr>'; |
---|
107 | var current; |
---|
108 | var costCentersCount = data.length; |
---|
109 | for (var i = 0; i < costCentersCount; i++) |
---|
110 | { |
---|
111 | current = data[i]; |
---|
112 | content += '<tr class="linha'+ i%2 + '">'; |
---|
113 | content += '<td>' + current['descricao'] + '</td>'; |
---|
114 | content += '<td>' + current['nm_centro_custo'] + '</td>'; |
---|
115 | content += '<td>' + current['grupo'] + '</td>'; |
---|
116 | content += '</tr>'; |
---|
117 | } |
---|
118 | content += '</table>'; |
---|
119 | div.innerHTML = content; |
---|
120 | } |
---|
121 | |
---|
122 | function displayUsefulPhones( data ) |
---|
123 | { |
---|
124 | if ( _checkError( data ) ) |
---|
125 | return; |
---|
126 | |
---|
127 | var div = $('orgchartEmployees'); |
---|
128 | if (data.length == 0) |
---|
129 | { |
---|
130 | div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
131 | return; |
---|
132 | } |
---|
133 | |
---|
134 | var content = ''; |
---|
135 | content += '<table class="employeeList">'; |
---|
136 | content += '<tr><th>Localidade</th><th>Número</th></tr>'; |
---|
137 | var current; |
---|
138 | var usefulPhoneCount = data.length; |
---|
139 | for (var i = 0; i < usefulPhoneCount; i++) |
---|
140 | { |
---|
141 | current = data[i]; |
---|
142 | content += '<tr class="linha'+ i%2 + '">'; |
---|
143 | content += '<td>' + current[ 'descricao' ] + '</td>'; |
---|
144 | content += '<td>' + current[ 'numero' ] + '</td>'; |
---|
145 | content += '</tr>'; |
---|
146 | } |
---|
147 | content += '</table>'; |
---|
148 | div.innerHTML = content; |
---|
149 | } |
---|
150 | |
---|
151 | function displayAreaWithSubtituteBoss( data ) |
---|
152 | { |
---|
153 | if ( _checkError( data ) ) |
---|
154 | return; |
---|
155 | |
---|
156 | var div = $('orgchartEmployees'); |
---|
157 | if (data.length == 0) |
---|
158 | { |
---|
159 | div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
160 | return; |
---|
161 | } |
---|
162 | |
---|
163 | var content = ''; |
---|
164 | content += '<table class="employeeList">'; |
---|
165 | content += '<tr><th>Área</th><th>Titular</th><th>Substituto</th></tr>'; |
---|
166 | var current; |
---|
167 | var usefulPhoneCount = data.length; |
---|
168 | for (var i = 0; i < usefulPhoneCount; i++) |
---|
169 | { |
---|
170 | current = data[i]; |
---|
171 | content += '<tr class="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 | |
---|
181 | function 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 />' + ' '.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'] + '</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 | |
---|
201 | function getUsefulPhones( ) |
---|
202 | { |
---|
203 | workflowUserInterfaceCurrentAreaID = 0; |
---|
204 | |
---|
205 | cExecute("$this.bo_userinterface.getUsefulPhones", displayUsefulPhones, ""); |
---|
206 | } |
---|
207 | |
---|
208 | function getAreaWithSubtituteBoss( ) |
---|
209 | { |
---|
210 | workflowUserInterfaceCurrentAreaID = 0; |
---|
211 | |
---|
212 | cExecute("$this.bo_userinterface.getAreaWithSubtituteBoss", displayAreaWithSubtituteBoss, ""); |
---|
213 | } |
---|
214 | |
---|
215 | function getCostCenters() |
---|
216 | { |
---|
217 | workflowUserInterfaceCurrentAreaID = 0; |
---|
218 | |
---|
219 | cExecute("$this.bo_userinterface.getCostCenters", displayCostCenters, ""); |
---|
220 | } |
---|
221 | |
---|
222 | function getHierarchicalArea() |
---|
223 | { |
---|
224 | workflowUserInterfaceCurrentAreaID = 0; |
---|
225 | |
---|
226 | cExecute("$this.bo_userinterface.getHierarchicalArea", displayHierarchicalAreas, ""); |
---|
227 | } |
---|
228 | |
---|
229 | function getAreaList() |
---|
230 | { |
---|
231 | cExecute("$this.bo_userinterface.getAreaList", displayHierarchicalAreas, ""); |
---|
232 | } |
---|
233 | |
---|
234 | function 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/>' + ' <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]['contagem'] + ')</a>'; |
---|
249 | content += '<br/><br/>'; |
---|
250 | $('orgchartAreas').innerHTML = content; |
---|
251 | } |
---|
252 | |
---|
253 | cExecute("$this.bo_userinterface.getCategoriesList", resultGetCategoriesList, ""); |
---|
254 | } |
---|
255 | |
---|
256 | function 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/>' + ' <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'] + '</a>'; |
---|
271 | |
---|
272 | content += '<br/><br/>'; |
---|
273 | |
---|
274 | $('orgchartAreas').innerHTML = content; |
---|
275 | } |
---|
276 | |
---|
277 | cExecute("$this.bo_userinterface.getManning", resultGetManning, ""); |
---|
278 | } |
---|
279 | |
---|
280 | function 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'].length == 0) |
---|
290 | { |
---|
291 | div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
292 | return; |
---|
293 | } |
---|
294 | |
---|
295 | /* initialize varivables */ |
---|
296 | var content = ''; |
---|
297 | var employees = data['employees']; |
---|
298 | var useCategories = false; |
---|
299 | var useArea = false; |
---|
300 | |
---|
301 | /* check the informations that will be displayed */ |
---|
302 | if (data['categories']) |
---|
303 | if (data['categories'].length > 1) |
---|
304 | useCategories = true; |
---|
305 | if (employees[0]['area']) |
---|
306 | useArea = true; |
---|
307 | |
---|
308 | /* build the display table (headers)*/ |
---|
309 | content += '<table id="employeeList" class="employeeList" style="clear: both">'; |
---|
310 | content += '<tr>'; |
---|
311 | content += '<th>Funcionário</th>'; |
---|
312 | if (useArea) |
---|
313 | content += '<th>Área</th>'; |
---|
314 | content += '<th>Telefone</th>'; |
---|
315 | content += '</tr>'; |
---|
316 | |
---|
317 | /* if available, insert a menu to filter the categories */ |
---|
318 | if (useCategories) |
---|
319 | { |
---|
320 | content += '<tr><td colspan="' + (useArea ? '3' : '2') + '">'; |
---|
321 | content += '<ul class="horizontalMenu">'; |
---|
322 | for (var i = 0; i < data['categories'].length; i++) |
---|
323 | 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>'; |
---|
324 | content += '</ul>'; |
---|
325 | content += '</td></tr>'; |
---|
326 | } |
---|
327 | |
---|
328 | /* list the employees */ |
---|
329 | var complement = ''; |
---|
330 | for (var i = 0; i < employees.length; i++) |
---|
331 | { |
---|
332 | if (employees[i]['chief']) |
---|
333 | complement = ' <strong>(' + ((employees[i]['chief'] == 1) ? 'Titular' : 'Substituto') + ')</strong>'; |
---|
334 | else |
---|
335 | complement = ''; |
---|
336 | if (employees[i]['removed']) |
---|
337 | complement += ' <font color="red">(excluído)</font>'; |
---|
338 | content += '<tr class="linha'+ i%2 + (useCategories ? ' categoria_' + employees[i]['funcionario_categoria_id'] : '') + '">'; |
---|
339 | 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>'; |
---|
340 | if (useArea) |
---|
341 | content += '<td>' + employees[i]['area'] + '</td>'; |
---|
342 | content += '<td align="center">' + employees[i]['telephoneNumber'] + '</td>'; |
---|
343 | content += '</tr>'; |
---|
344 | } |
---|
345 | content += '</table>'; |
---|
346 | |
---|
347 | /* display the employees list and go to the top of the page */ |
---|
348 | div.innerHTML = content; |
---|
349 | window.scrollTo(0,0); |
---|
350 | } |
---|
351 | |
---|
352 | function highlightCategory(categoryID) |
---|
353 | { |
---|
354 | var rows = $('employeeList').childNodes[0].childNodes; |
---|
355 | var categoryClass = 'categoria_' + categoryID; |
---|
356 | |
---|
357 | var highlightClass = ''; |
---|
358 | var row; |
---|
359 | for (var i = 1; i < rows.length; i++) |
---|
360 | { |
---|
361 | row = $(rows[i]); |
---|
362 | /* in case alternated color rows are needed, just change the second 'highlight0' to something else (e.g. 'highlight1' which is alread defined) */ |
---|
363 | highlightClass = row.hasClassName('linha0') ? 'highlight0' : 'highlight0'; |
---|
364 | if (row.hasClassName(categoryClass)) |
---|
365 | row.addClassName(highlightClass); |
---|
366 | else |
---|
367 | row.removeClassName(highlightClass); |
---|
368 | } |
---|
369 | } |
---|
370 | |
---|
371 | function loadAreaEmployees(areaID) |
---|
372 | { |
---|
373 | workflowUserInterfaceCurrentAreaID = areaID; |
---|
374 | cExecute('$this.bo_userinterface.getAreaEmployees', printEmployeesHandler, 'areaID=' + areaID); |
---|
375 | } |
---|
376 | |
---|
377 | function loadCategoryEmployees(categoryID) |
---|
378 | { |
---|
379 | workflowUserInterfaceCurrentAreaID = 0; |
---|
380 | cExecute('$this.bo_userinterface.getCategoryEmployees', printEmployeesHandler, 'categoryID=' + categoryID); |
---|
381 | } |
---|
382 | |
---|
383 | function loadManningEmployees( locationID ) |
---|
384 | { |
---|
385 | workflowUserInterfaceCurrentAreaID = 0; |
---|
386 | cExecute('$this.bo_userinterface.getManningEmployees', printEmployeesHandler, 'locationID=' + locationID); |
---|
387 | } |
---|
388 | |
---|
389 | function getAlphabeticalEmployees( ) |
---|
390 | { |
---|
391 | workflowUserInterfaceCurrentAreaID = 0; |
---|
392 | |
---|
393 | var div = $('orgchartEmployees'); |
---|
394 | div.innerHTML = ''; |
---|
395 | |
---|
396 | var p_page = 0; |
---|
397 | if ( arguments.length ) |
---|
398 | { |
---|
399 | p_page = parseInt(arguments[ 0 ]); |
---|
400 | if ( isNaN( p_page ) ) |
---|
401 | p_page = 0; |
---|
402 | } |
---|
403 | cExecute('$this.bo_userinterface.getAlphabeticalEmployees', function( data ) |
---|
404 | { |
---|
405 | var pagingData = data['paging_links']; |
---|
406 | var output = ''; |
---|
407 | if (pagingData) |
---|
408 | { |
---|
409 | var pagingSize = pagingData.length; |
---|
410 | for (var i = 0; i < pagingSize; i++) |
---|
411 | { |
---|
412 | if (pagingData[i].do_link == true) |
---|
413 | output += '<a style="font-size: 13px" href="#" onclick="getAlphabeticalEmployees(' + pagingData[i].p_page + ');">' + pagingData[i].name + '</a> '; |
---|
414 | else |
---|
415 | output += '<strong style="font-size: 14px">' + pagingData[i].name + '</strong> '; |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | printEmployeesHandler( data ); |
---|
420 | |
---|
421 | div.innerHTML += '<br /><center>' + output + '</center>'; |
---|
422 | }, 'p_page='+p_page); |
---|
423 | } |
---|
424 | |
---|
425 | function orgchartSearchEmployee(searchTerm) |
---|
426 | { |
---|
427 | workflowUserInterfaceCurrentAreaID = 0; |
---|
428 | cExecute('$this.bo_userinterface.searchEmployee', printEmployeesHandler, 'searchTerm=' + searchTerm); |
---|
429 | } |
---|
430 | |
---|
431 | function printArea() |
---|
432 | { |
---|
433 | if (workflowUserInterfaceCurrentAreaID == 0) |
---|
434 | if (!confirm('Tem certeza de que deseja imprimir todo o Organograma?')) |
---|
435 | return false; |
---|
436 | var endereco = '../index.php?menuaction=workflow.ui_userinterface.printArea&areaID=' + workflowUserInterfaceCurrentAreaID; |
---|
437 | window.open(endereco, 'extwindow'); |
---|
438 | } |
---|
439 | |
---|
440 | function getEmployeeInfoTimer(e, employeeID) |
---|
441 | { |
---|
442 | var div = $('employeeInfo'); |
---|
443 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
444 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
445 | |
---|
446 | if (workflowUserInterfaceEmployeeInfoTimer != null) |
---|
447 | { |
---|
448 | workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer); |
---|
449 | workflowUserInterfaceEmployeeInfoTimer = null; |
---|
450 | } |
---|
451 | |
---|
452 | workflowUserInterfaceEmployeeInfoTimer = setTimeout('getEmployeeInfo(' + employeeID + ')', 500); |
---|
453 | } |
---|
454 | |
---|
455 | function getEmployeeInfo(employeeID) |
---|
456 | { |
---|
457 | function resultGetEmployeeInfo(data) |
---|
458 | { |
---|
459 | if (workflowUserInterfaceEmployeeInfoTimer == null) |
---|
460 | return; |
---|
461 | |
---|
462 | workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer); |
---|
463 | workflowUserInterfaceEmployeeInfoTimer = null; |
---|
464 | |
---|
465 | var card_data = [ ]; |
---|
466 | |
---|
467 | for (var i = 0; i < data['info'].length; i++) |
---|
468 | card_data[ data[ 'info' ][ i ][ 'name' ] ] = data[ 'info' ][ i ][ 'value' ]; |
---|
469 | |
---|
470 | var card = document.createElement( 'div' ); |
---|
471 | card.style.fontSize = '12px'; |
---|
472 | card.style.padding = '5px'; |
---|
473 | card.style.marginRight = '70px'; |
---|
474 | |
---|
475 | var photo = document.createElement( 'img' ); |
---|
476 | photo.src = 'showUserPicture.php?userID=' + employeeID; |
---|
477 | photo.style.position = 'absolute'; |
---|
478 | photo.style.right = '10px'; |
---|
479 | |
---|
480 | card.appendChild( photo ); |
---|
481 | |
---|
482 | if ( card_data[ 'Nome' ] ) |
---|
483 | { |
---|
484 | var name = document.createElement( 'span' ); |
---|
485 | name.style.fontWeight = 'bold'; |
---|
486 | name.appendChild( document.createTextNode( card_data[ 'Nome' ] ) ); |
---|
487 | card.appendChild( name ); |
---|
488 | card.appendChild( document.createElement( 'br' ) ); |
---|
489 | } |
---|
490 | |
---|
491 | if ( card_data[ 'Título' ] ) |
---|
492 | var role = card.appendChild( document.createTextNode( card_data[ 'Título' ] ) ); |
---|
493 | |
---|
494 | if ( card_data[ 'Área' ] ) |
---|
495 | { |
---|
496 | if ( role ) |
---|
497 | card.appendChild( document.createTextNode( ' - ' ) ); |
---|
498 | card.appendChild( document.createTextNode( card_data[ 'Área' ] ) ); |
---|
499 | } |
---|
500 | |
---|
501 | card.appendChild( document.createElement( 'br' ) ); |
---|
502 | card.appendChild( document.createElement( 'br' ) ); |
---|
503 | |
---|
504 | if ( card_data[ 'Empresa' ] ) |
---|
505 | { |
---|
506 | var company = document.createElement( 'span' ); |
---|
507 | company.style.fontWeight = 'bold'; |
---|
508 | company.appendChild( document.createTextNode( card_data[ 'Empresa' ] ) ); |
---|
509 | card.appendChild( company ); |
---|
510 | card.appendChild( document.createElement( 'br' ) ); |
---|
511 | } |
---|
512 | |
---|
513 | if ( card_data[ 'Endereço' ] ) |
---|
514 | var address = card.appendChild( document.createTextNode( card_data[ 'Endereço' ] ) ); |
---|
515 | |
---|
516 | if ( card_data[ 'Complemento' ] ) |
---|
517 | { |
---|
518 | if ( address ) |
---|
519 | card.appendChild( document.createTextNode( ' - ' ) ); |
---|
520 | var complement = card.appendChild( document.createTextNode( card_data[ 'Complemento' ] ) ); |
---|
521 | } |
---|
522 | |
---|
523 | if ( address || complement ) |
---|
524 | card.appendChild( document.createElement( 'br' ) ); |
---|
525 | |
---|
526 | if ( card_data[ 'Cep' ] ) |
---|
527 | var zipcode = card.appendChild( document.createTextNode( card_data[ 'Cep' ] ) ); |
---|
528 | |
---|
529 | if ( card_data[ 'Bairro' ] ) |
---|
530 | { |
---|
531 | if ( zipcode ) |
---|
532 | card.appendChild( document.createTextNode( ' - ' ) ); |
---|
533 | var district = card.appendChild( document.createTextNode( card_data[ 'Bairro' ] ) ); |
---|
534 | } |
---|
535 | |
---|
536 | if ( zipcode || district ) |
---|
537 | card.appendChild( document.createElement( 'br' ) ); |
---|
538 | |
---|
539 | if ( card_data[ 'Cidade' ] ) |
---|
540 | var city = card.appendChild( document.createTextNode( card_data[ 'Cidade' ] ) ); |
---|
541 | |
---|
542 | if ( card_data[ 'UF' ] ) |
---|
543 | { |
---|
544 | if ( city ) |
---|
545 | card.appendChild( document.createTextNode( ' - ' ) ); |
---|
546 | card.appendChild( document.createTextNode( card_data[ 'UF' ] ) ); |
---|
547 | } |
---|
548 | |
---|
549 | card.appendChild( document.createElement( 'br' ) ); |
---|
550 | card.appendChild( document.createElement( 'br' ) ); |
---|
551 | |
---|
552 | if ( card_data[ 'Telefone' ] ) |
---|
553 | { |
---|
554 | var phone = document.createElement( 'span' ); |
---|
555 | phone.appendChild( document.createTextNode( card_data[ 'Telefone' ] ) ); |
---|
556 | phone.style.paddingLeft = '20px'; |
---|
557 | phone.style.whiteSpace = 'nowrap'; |
---|
558 | phone.style.background = 'url(templateFile.php?file=images/phone.png) no-repeat 0 0'; |
---|
559 | card.appendChild( phone ); |
---|
560 | } |
---|
561 | |
---|
562 | card.appendChild( document.createElement( 'br' ) ); |
---|
563 | card.appendChild( document.createElement( 'br' ) ); |
---|
564 | |
---|
565 | if ( card_data[ 'e-mail' ] ) |
---|
566 | { |
---|
567 | var mail = document.createElement( 'span' ); |
---|
568 | mail.appendChild( document.createTextNode( card_data[ 'e-mail' ] ) ); |
---|
569 | mail.style.paddingLeft = '20px'; |
---|
570 | mail.style.whiteSpace = 'nowrap'; |
---|
571 | mail.style.background = 'url(templateFile.php?file=images/mail.png) no-repeat 0 0'; |
---|
572 | card.appendChild( mail ); |
---|
573 | } |
---|
574 | |
---|
575 | card.appendChild( document.createElement( 'br' ) ); |
---|
576 | |
---|
577 | if ( card_data[ 'sitio' ] ) |
---|
578 | { |
---|
579 | var sitio = document.createElement( 'span' ); |
---|
580 | sitio.appendChild( document.createTextNode( card_data[ 'sitio' ] ) ); |
---|
581 | sitio.style.paddingLeft = '20px'; |
---|
582 | sitio.style.background = 'url(templateFile.php?file=images/sitio.png) no-repeat 0 2px'; |
---|
583 | card.appendChild( sitio ); |
---|
584 | } |
---|
585 | |
---|
586 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
587 | var div = $('employeeInfo'); |
---|
588 | |
---|
589 | div.innerHTML = ''; |
---|
590 | div.appendChild( card ); |
---|
591 | |
---|
592 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
593 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
594 | div.show(); |
---|
595 | } |
---|
596 | cExecute('$this.bo_userinterface.getEmployeeInfo', resultGetEmployeeInfo, 'funcionario_id=' + employeeID); |
---|
597 | } |
---|
598 | |
---|
599 | function hideEmployeeInfo() |
---|
600 | { |
---|
601 | if (workflowUserInterfaceEmployeeInfoTimer != null) |
---|
602 | { |
---|
603 | workflowUserInterfaceEmployeeInfoTimer = clearTimeout(workflowUserInterfaceEmployeeInfoTimer); |
---|
604 | workflowUserInterfaceEmployeeInfoTimer = null; |
---|
605 | } |
---|
606 | $('employeeInfo').hide(); |
---|
607 | } |
---|
608 | |
---|
609 | function getAreaInfoTimer(e, areaID) |
---|
610 | { |
---|
611 | var div = $('areaInfo'); |
---|
612 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
613 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
614 | |
---|
615 | if (workflowUserInterfaceAreaInfoTimer != null) |
---|
616 | { |
---|
617 | workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer); |
---|
618 | workflowUserInterfaceAreaInfoTimer = null; |
---|
619 | } |
---|
620 | |
---|
621 | workflowUserInterfaceAreaInfoTimer = setTimeout('getAreaInfo(' + areaID + ')', 500); |
---|
622 | } |
---|
623 | |
---|
624 | function getAreaInfo(areaID) |
---|
625 | { |
---|
626 | function resultGetAreaInfo(data) |
---|
627 | { |
---|
628 | if (workflowUserInterfaceAreaInfoTimer == null) |
---|
629 | return; |
---|
630 | |
---|
631 | workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer); |
---|
632 | workflowUserInterfaceAreaInfoTimer = null; |
---|
633 | |
---|
634 | var content = ''; |
---|
635 | content += '<table><tr>'; |
---|
636 | content += '<td valign="top" style="padding-left: 12px;">'; |
---|
637 | for (var i = 0; i < data['info'].length; i++) |
---|
638 | content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>'; |
---|
639 | |
---|
640 | content += '</td></tr></table>'; |
---|
641 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
642 | var div = $('areaInfo'); |
---|
643 | div.innerHTML = content; |
---|
644 | |
---|
645 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
646 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
647 | div.show(); |
---|
648 | } |
---|
649 | cExecute('$this.bo_userinterface.getAreaInfo', resultGetAreaInfo, 'area_id=' + areaID); |
---|
650 | } |
---|
651 | |
---|
652 | function hideAreaInfo() |
---|
653 | { |
---|
654 | if (workflowUserInterfaceAreaInfoTimer != null) |
---|
655 | { |
---|
656 | workflowUserInterfaceAreaInfoTimer = clearTimeout(workflowUserInterfaceAreaInfoTimer); |
---|
657 | workflowUserInterfaceAreaInfoTimer = null; |
---|
658 | } |
---|
659 | $('areaInfo').hide(); |
---|
660 | } |
---|