1 | var workflowUserInterfaceEmployeeInfoTimer = null; |
---|
2 | var workflowUserInterfaceAreaInfoTimer = null; |
---|
3 | var workflowUserInterfaceCurrentAreaID = 0; |
---|
4 | var workflowUserInterfaceClickToCall = false; |
---|
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">'; |
---|
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"> 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;"> 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>'; |
---|
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; |
---|
54 | |
---|
55 | $( 'search_term' ).focus( ); |
---|
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 | |
---|
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 */ |
---|
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 | |
---|
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 | |
---|
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 | |
---|
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 | |
---|
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 | |
---|
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 | |
---|
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 | { |
---|
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>'; |
---|
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 | |
---|
210 | function getUsefulPhones( ) |
---|
211 | { |
---|
212 | workflowUserInterfaceCurrentAreaID = 0; |
---|
213 | |
---|
214 | cExecute("$this.bo_userinterface.getUsefulPhones", displayUsefulPhones, ""); |
---|
215 | } |
---|
216 | |
---|
217 | function getAreaWithSubtituteBoss( ) |
---|
218 | { |
---|
219 | workflowUserInterfaceCurrentAreaID = 0; |
---|
220 | |
---|
221 | cExecute("$this.bo_userinterface.getAreaWithSubtituteBoss", displayAreaWithSubtituteBoss, ""); |
---|
222 | } |
---|
223 | |
---|
224 | function getCostCenters() |
---|
225 | { |
---|
226 | workflowUserInterfaceCurrentAreaID = 0; |
---|
227 | |
---|
228 | cExecute("$this.bo_userinterface.getCostCenters", displayCostCenters, ""); |
---|
229 | } |
---|
230 | |
---|
231 | function getHierarchicalArea() |
---|
232 | { |
---|
233 | workflowUserInterfaceCurrentAreaID = 0; |
---|
234 | |
---|
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 | { |
---|
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/>' + ' <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 | |
---|
265 | function 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/>' + ' <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 | |
---|
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 */ |
---|
298 | if ( ( ! data['employees'] || data['employees'].length == 0 ) && |
---|
299 | ( ! data['bygroup'] || data['bygroup'].length == 0 ) && |
---|
300 | ( ! data['bytelephone'] || data['bytelephone'].length == 0 ) ) |
---|
301 | { |
---|
302 | div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
303 | return; |
---|
304 | } |
---|
305 | |
---|
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; |
---|
313 | |
---|
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; |
---|
320 | |
---|
321 | /* build the display table (headers)*/ |
---|
322 | content += '<table id="employeeList" class="employeeList" style="clear: both">'; |
---|
323 | content += '<tr class="message_header">'; |
---|
324 | content += '<th>Nome</th>'; |
---|
325 | if (useArea) |
---|
326 | content += '<th>Área</th>'; |
---|
327 | content += '<th>Telefone</th>'; |
---|
328 | content += '</tr>'; |
---|
329 | |
---|
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 | } |
---|
340 | |
---|
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>'; |
---|
355 | content += '<td align="center">'; |
---|
356 | if ( ! workflowUserInterfaceClickToCall ) |
---|
357 | content += employees[i]['telephoneNumber']; |
---|
358 | else |
---|
359 | { |
---|
360 | content += '<a href="javascript:void(0);" title="Discar para Telefone Comercial" onclick="callVoipConnect(\''+employees[i]['telephoneNumber']+'\')"'; |
---|
361 | content += '>' + employees[i]['telephoneNumber'] + '</a>'; |
---|
362 | } |
---|
363 | content += '</td></tr>'; |
---|
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 | } |
---|
373 | else |
---|
374 | return content; |
---|
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 | |
---|
397 | function loadAreaEmployees(areaID, areaName) |
---|
398 | { |
---|
399 | workflowUserInterfaceCurrentAreaID = areaID; |
---|
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); |
---|
407 | } |
---|
408 | |
---|
409 | function loadCategoryEmployees(categoryID, categoryName) |
---|
410 | { |
---|
411 | workflowUserInterfaceCurrentAreaID = 0; |
---|
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); |
---|
419 | } |
---|
420 | |
---|
421 | function loadManningEmployees( locationID, locationName ) |
---|
422 | { |
---|
423 | workflowUserInterfaceCurrentAreaID = 0; |
---|
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); |
---|
431 | } |
---|
432 | |
---|
433 | function getAlphabeticalEmployees( ) |
---|
434 | { |
---|
435 | workflowUserInterfaceCurrentAreaID = 0; |
---|
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) |
---|
457 | output += '<a style="font-size: 13px" href="#" onclick="getAlphabeticalEmployees(' + pagingData[i].p_page + ');">' + pagingData[i].name + '</a> '; |
---|
458 | else |
---|
459 | output += '<strong style="font-size: 14px">' + pagingData[i].name + '</strong> '; |
---|
460 | } |
---|
461 | } |
---|
462 | |
---|
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; |
---|
467 | |
---|
468 | }, 'p_page='+p_page); |
---|
469 | } |
---|
470 | |
---|
471 | function orgchartSearchEmployee(searchTerm) |
---|
472 | { |
---|
473 | workflowUserInterfaceCurrentAreaID = 0; |
---|
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 | |
---|
483 | // printing records found by group |
---|
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 | |
---|
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 | |
---|
503 | }, 'searchTerm=' + searchTerm); |
---|
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'); |
---|
518 | div.style.left = (Event.pointerX(e) - 50) + 'px'; |
---|
519 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
520 | div.hide(); |
---|
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 | |
---|
541 | var card_data = [ ]; |
---|
542 | |
---|
543 | for (var i = 0; i < data['info'].length; i++) |
---|
544 | card_data[ data[ 'info' ][ i ][ 'name' ] ] = data[ 'info' ][ i ][ 'value' ]; |
---|
545 | |
---|
546 | var card = document.createElement( 'div' ); |
---|
547 | card.style.fontSize = '12px'; |
---|
548 | card.style.padding = '5px'; |
---|
549 | card.style.marginRight = '70px'; |
---|
550 | |
---|
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 | |
---|
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 | |
---|
578 | if ( card_data[ 'Título' ] ) |
---|
579 | var role = card.appendChild( document.createTextNode( card_data[ 'Título' ] ) ); |
---|
580 | |
---|
581 | if ( card_data[ 'Área' ] ) |
---|
582 | { |
---|
583 | if ( role ) |
---|
584 | card.appendChild( document.createTextNode( ' - ' ) ); |
---|
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 ); |
---|
595 | } |
---|
596 | |
---|
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 | |
---|
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 | { |
---|
657 | var phone = document.createElement( ( workflowUserInterfaceClickToCall ) ? 'a' : 'span' ); |
---|
658 | phone.appendChild( document.createTextNode( card_data[ 'Telefone' ] ) ); |
---|
659 | phone.style.paddingLeft = '20px'; |
---|
660 | phone.style.whiteSpace = 'nowrap'; |
---|
661 | phone.style.background = 'url(templateFile.php?file=images/phone.png) no-repeat 0 0'; |
---|
662 | |
---|
663 | var phoneNumber = card_data[ 'Telefone' ]; |
---|
664 | if ( workflowUserInterfaceClickToCall ) |
---|
665 | { |
---|
666 | phone.title = "Discar para Telefone Comercial" |
---|
667 | phone.onclick = function( ) |
---|
668 | { |
---|
669 | callVoipConnect( phoneNumber ); |
---|
670 | } |
---|
671 | } |
---|
672 | |
---|
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 | { |
---|
681 | var mail = document.createElement( 'a' ); |
---|
682 | mail.appendChild( document.createTextNode( card_data[ 'e-mail' ] ) ); |
---|
683 | mail.href = '../expressoMail1_2/index.php?to=' + card_data[ 'e-mail' ]; |
---|
684 | mail.style.paddingLeft = '20px'; |
---|
685 | mail.style.whiteSpace = 'nowrap'; |
---|
686 | mail.style.background = 'url(templateFile.php?file=images/mail.png) no-repeat 0 0'; |
---|
687 | card.appendChild( mail ); |
---|
688 | } |
---|
689 | |
---|
690 | card.appendChild( document.createElement( 'br' ) ); |
---|
691 | |
---|
692 | if ( card_data[ 'sitio' ] ) |
---|
693 | { |
---|
694 | var sitio = document.createElement( 'a' ); |
---|
695 | sitio.target = '_blank'; |
---|
696 | sitio.href = card_data[ 'sitio' ]; |
---|
697 | sitio.appendChild( document.createTextNode( card_data[ 'sitio' ] ) ); |
---|
698 | sitio.style.paddingLeft = '20px'; |
---|
699 | sitio.style.background = 'url(templateFile.php?file=images/sitio.png) no-repeat 0 2px'; |
---|
700 | card.appendChild( sitio ); |
---|
701 | } |
---|
702 | |
---|
703 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
704 | var div = $('employeeInfo'); |
---|
705 | |
---|
706 | div.innerHTML = ''; |
---|
707 | div.appendChild( card ); |
---|
708 | |
---|
709 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
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 | |
---|
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 | } |
---|
726 | workflowUserInterfaceEmployeeInfoTimer = setTimeout( "$('employeeInfo').hide()", 1000 ); |
---|
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 | } |
---|
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 | } |
---|