1 | String.prototype.repeat = function(l) |
---|
2 | { |
---|
3 | return new Array(l+1).join(this); |
---|
4 | }; |
---|
5 | |
---|
6 | var workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
7 | var workflowOrgchartAdminAreaInfoTimer = null; |
---|
8 | |
---|
9 | var CadastroAjax = Class.create(); |
---|
10 | |
---|
11 | CadastroAjax.prototype = |
---|
12 | { |
---|
13 | initialize: function() |
---|
14 | { |
---|
15 | this.name = ''; |
---|
16 | this.required = new Array(); |
---|
17 | this.tableHeader = new Array(); |
---|
18 | this.combo = new Array(); |
---|
19 | }, |
---|
20 | |
---|
21 | add: function() |
---|
22 | { |
---|
23 | for (var i = 0; i < this.required.length; i++) |
---|
24 | { |
---|
25 | if ($F(this.required[i]) == '') |
---|
26 | { |
---|
27 | alert("Campo necessário ausente: " + $(this.required[i]).parentNode.parentNode.childNodes[0].childNodes[0].innerHTML); |
---|
28 | $(this.required[i]).focus(); |
---|
29 | return; |
---|
30 | } |
---|
31 | } |
---|
32 | var cb = function(data) |
---|
33 | { |
---|
34 | if (!handleError(data)) |
---|
35 | return; |
---|
36 | |
---|
37 | /* update the screen info */ |
---|
38 | if (this.name.toLowerCase() == "organization") |
---|
39 | listOrganizations(); |
---|
40 | else |
---|
41 | { |
---|
42 | if ($('organizacao_id')) |
---|
43 | { |
---|
44 | var index = $F('organizacao_id'); |
---|
45 | if (refreshAreas[index]) |
---|
46 | refreshAreas[index](); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | valid.deactivate(); |
---|
51 | }; |
---|
52 | |
---|
53 | return this.ajaxAction('add', cb, Form.serialize($('orgchartForm'))); |
---|
54 | }, |
---|
55 | |
---|
56 | update: function() |
---|
57 | { |
---|
58 | for (var i = 0; i < this.required.length; i++) |
---|
59 | { |
---|
60 | if ($F(this.required[i]) == '') |
---|
61 | { |
---|
62 | alert("Campo necessário ausente: " + $(this.required[i]).parentNode.parentNode.childNodes[0].childNodes[0].innerHTML); |
---|
63 | $(this.required[i]).focus(); |
---|
64 | return; |
---|
65 | } |
---|
66 | } |
---|
67 | var cb = function(data) |
---|
68 | { |
---|
69 | if (!handleError(data)) |
---|
70 | return; |
---|
71 | |
---|
72 | /* update the screen info */ |
---|
73 | if (this.name.toLowerCase() == "organization") |
---|
74 | listOrganizations(); |
---|
75 | else |
---|
76 | { |
---|
77 | if ($('organizacao_id')) |
---|
78 | { |
---|
79 | var index = $F('organizacao_id'); |
---|
80 | if (refreshAreas[index]) |
---|
81 | refreshAreas[index](); |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | valid.deactivate(); |
---|
86 | }; |
---|
87 | |
---|
88 | return this.ajaxAction('update', cb, Form.serialize($('orgchartForm'))); |
---|
89 | }, |
---|
90 | |
---|
91 | remove: function(params, linkRemove) |
---|
92 | { |
---|
93 | |
---|
94 | if (linkRemove.addClassName) |
---|
95 | linkRemove.addClassName('alerta'); |
---|
96 | if (confirm("Tem certeza que deseja excluir o registro selecionado?")) |
---|
97 | { |
---|
98 | var cb = function(data) |
---|
99 | { |
---|
100 | if (!handleError(data)) |
---|
101 | return; |
---|
102 | |
---|
103 | /* update the screen info */ |
---|
104 | if (this.name.toLowerCase() == "organization") |
---|
105 | listOrganizations(); |
---|
106 | else |
---|
107 | { |
---|
108 | var index = $('organizacao_id') ? $F('organizacao_id') : params['organizacao_id']; |
---|
109 | if (refreshAreas[index]) |
---|
110 | refreshAreas[index](); |
---|
111 | } |
---|
112 | |
---|
113 | if ($('lbContent')) |
---|
114 | valid.deactivate(); |
---|
115 | }; |
---|
116 | return this.ajaxAction('remove', cb, $H(params).toQueryString()); |
---|
117 | } |
---|
118 | else |
---|
119 | if (linkRemove.removeClassName) |
---|
120 | linkRemove.removeClassName('alerta'); |
---|
121 | }, |
---|
122 | |
---|
123 | list: function(callback, params) |
---|
124 | { |
---|
125 | return this.ajaxAction('list', callback, $H(params).toQueryString()); |
---|
126 | }, |
---|
127 | |
---|
128 | generateTable: function(params, displayArea) |
---|
129 | { |
---|
130 | tableHeader = this.tableHeader; |
---|
131 | var tableResult = function(data) |
---|
132 | { |
---|
133 | if (!handleError(data)) |
---|
134 | return; |
---|
135 | |
---|
136 | if (data.length == 0) |
---|
137 | { |
---|
138 | displayArea.innerHTML += '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
139 | return true; |
---|
140 | } |
---|
141 | |
---|
142 | for (var i = 0; i < data.length; i++) |
---|
143 | { |
---|
144 | data[i]['tr_attributes'] = new Array(); |
---|
145 | data[i]['tr_attributes']['class'] = "linha" + i%2;; |
---|
146 | data[i]['tr_attributes']['className'] = "linha" + i%2;; |
---|
147 | } |
---|
148 | |
---|
149 | var tableAtributes = new Array(); |
---|
150 | tableAtributes['id'] = this.name + 'List'; |
---|
151 | tableAtributes['class'] = 'organizationList'; |
---|
152 | tableAtributes['className'] = 'organizationList'; |
---|
153 | displayArea.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
154 | }; |
---|
155 | this.list(tableResult, params); |
---|
156 | }, |
---|
157 | |
---|
158 | generateUpdateTable: function(params, displayArea) |
---|
159 | { |
---|
160 | tableHeader = this.tableHeader; |
---|
161 | if (!tableHeader['actions']) |
---|
162 | tableHeader['actions'] = "Ações"; |
---|
163 | name = this.name.charAt(0).capitalize() + this.name.substr(1); |
---|
164 | var tableResult = function(data) |
---|
165 | { |
---|
166 | if (!handleError(data)) |
---|
167 | return; |
---|
168 | |
---|
169 | if (data.length == 0) |
---|
170 | { |
---|
171 | displayArea.innerHTML += '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
172 | return true; |
---|
173 | } |
---|
174 | |
---|
175 | for (var i = 0; i < data.length; i++) |
---|
176 | { |
---|
177 | var dataHash = new Hash(); |
---|
178 | for (j in data[i]) |
---|
179 | if (typeof data[i][j] != "function") |
---|
180 | { |
---|
181 | dataHash[j] = data[i][j]; |
---|
182 | if ( dataHash[j] == null ) |
---|
183 | dataHash[j] = ''; |
---|
184 | } |
---|
185 | |
---|
186 | for (j in tableHeader) |
---|
187 | if (typeof tableHeader[j] != "function") |
---|
188 | if (j != 'actions') |
---|
189 | data[i][j] = '<a href="#" onclick="obj' + name + '.fillForm(' + dataHash.customInspect() + '); return false;">' + data[i][j] + '</a>'; |
---|
190 | |
---|
191 | data[i]['tr_attributes'] = new Array(); |
---|
192 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
193 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
194 | data[i]['actions'] = '<a href="#" onclick="obj' + name + '.remove(' + dataHash.customInspect() + ' , this.parentNode.parentNode); return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/button_cancel.png" /></a>'; |
---|
195 | } |
---|
196 | |
---|
197 | var tableAtributes = new Array(); |
---|
198 | tableAtributes['id'] = this.name + 'List'; |
---|
199 | tableAtributes['class'] = 'orgchartUpdateTable'; |
---|
200 | tableAtributes['className'] = 'orgchartUpdateTable'; |
---|
201 | displayArea.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
202 | }; |
---|
203 | this.list(tableResult, params); |
---|
204 | }, |
---|
205 | |
---|
206 | fillForm: function(dataHash) |
---|
207 | { |
---|
208 | dataHash = $H(dataHash); |
---|
209 | dataHash.each(function(pair) |
---|
210 | { |
---|
211 | var campo = $(pair.key); |
---|
212 | if (campo) |
---|
213 | { |
---|
214 | if ((campo.nodeName == "SELECT") && (pair.value == null)) |
---|
215 | campo.value = campo.firstChild.value; |
---|
216 | else |
---|
217 | if (pair.value != null) |
---|
218 | campo.value = pair.value; |
---|
219 | } |
---|
220 | else |
---|
221 | new Insertion.Bottom($('orgchartForm'), '<input type="hidden" name="' + pair.key + '" id="' + pair.key + '" value="' + pair.value + '" />'); |
---|
222 | }); |
---|
223 | if (!$('updateOrgchart')) |
---|
224 | new Insertion.Bottom($('orgchartForm'), '<input type="hidden" name="updateOrgchart" id="updateOrgchart" value="true" />'); |
---|
225 | var saveButton = $('inserir'); |
---|
226 | saveButton.innerHTML = "Salvar"; |
---|
227 | var name = this.name; |
---|
228 | saveButton.onclick = function(){ eval('obj' + name.charAt(0).capitalize() + name.substr(1) + '.update();')}; |
---|
229 | var titleObject = $('modalTitle'); |
---|
230 | var title = titleObject.innerHTML.split(' '); |
---|
231 | title[0] = "Atualizar"; |
---|
232 | titleObject.innerHTML = title.join(' '); |
---|
233 | $('lightbox').scrollTop = 0; |
---|
234 | }, |
---|
235 | |
---|
236 | generateComboBox: function(params, displayArea, includeNull, name, callback) |
---|
237 | { |
---|
238 | if (!name) |
---|
239 | name = this.combo['id']; |
---|
240 | combo = this.combo; |
---|
241 | var comboResult = function(data) |
---|
242 | { |
---|
243 | if (!handleError(data)) |
---|
244 | return; |
---|
245 | |
---|
246 | var newFormat = new Array(); |
---|
247 | if (includeNull) |
---|
248 | newFormat['NULL'] = "Nenhum"; |
---|
249 | for (var i = 0; i < data.length; i++) |
---|
250 | newFormat[data[i][combo['id']]] = data[i][combo['name']]; |
---|
251 | if ((newFormat.length > 0) || includeNull) |
---|
252 | displayArea.innerHTML = constructSelectBox(name, newFormat); |
---|
253 | else |
---|
254 | displayArea.innerHTML = '<i>nenhum registro encontado</i><input type="hidden" id="' + name + '" value=""/>'; |
---|
255 | if (callback) |
---|
256 | callback(); |
---|
257 | }; |
---|
258 | this.list(comboResult, params); |
---|
259 | }, |
---|
260 | |
---|
261 | ajaxAction: function(action, callback, params) |
---|
262 | { |
---|
263 | if (params == "") |
---|
264 | cExecute('$this.bo_orgchart.' + action + this.name.charAt(0).capitalize() + this.name.substr(1), callback); |
---|
265 | else |
---|
266 | cExecute('$this.bo_orgchart.' + action + this.name.charAt(0).capitalize() + this.name.substr(1), callback, params); |
---|
267 | } |
---|
268 | |
---|
269 | }; |
---|
270 | |
---|
271 | var CadastroOrganization = |
---|
272 | { |
---|
273 | name: 'organization', |
---|
274 | required: new Array('nome', 'descricao', 'ativa'), |
---|
275 | tableHeader: {'nome': 'Organização'}, |
---|
276 | combo: {'id': 'organizacao_id', 'name': 'nome'} |
---|
277 | }; |
---|
278 | var objOrganization = new CadastroAjax(); |
---|
279 | Object.extend(objOrganization, CadastroOrganization); |
---|
280 | |
---|
281 | var CadastroEmployeeStatus = |
---|
282 | { |
---|
283 | name: 'employeeStatus', |
---|
284 | required: new Array('descricao', 'exibir'), |
---|
285 | tableHeader: {'descricao': 'Status de Funcionário'}, |
---|
286 | combo: {'id': 'funcionario_status_id', 'name': 'descricao'} |
---|
287 | }; |
---|
288 | var objEmployeeStatus = new CadastroAjax(); |
---|
289 | Object.extend(objEmployeeStatus, CadastroEmployeeStatus); |
---|
290 | |
---|
291 | var CadastroEmployeeCategory = |
---|
292 | { |
---|
293 | name: 'employeeCategory', |
---|
294 | required: new Array('organizacao_id', 'descricao'), |
---|
295 | tableHeader: {'descricao': 'Nome'}, |
---|
296 | combo: {'id': 'funcionario_categoria_id', 'name': 'descricao'} |
---|
297 | }; |
---|
298 | var objEmployeeCategory = new CadastroAjax(); |
---|
299 | Object.extend(objEmployeeCategory, CadastroEmployeeCategory); |
---|
300 | |
---|
301 | var CadastroJobTitle = |
---|
302 | { |
---|
303 | name: 'jobTitle', |
---|
304 | required: new Array('organizacao_id', 'descricao'), |
---|
305 | tableHeader: {'descricao': 'Nome'}, |
---|
306 | combo: {'id': 'cargo_id', 'name': 'descricao'} |
---|
307 | }; |
---|
308 | var objJobTitle = new CadastroAjax(); |
---|
309 | Object.extend(objJobTitle, CadastroJobTitle); |
---|
310 | |
---|
311 | var CadastroAreaStatus = |
---|
312 | { |
---|
313 | name: 'areaStatus', |
---|
314 | required: new Array('organizacao_id', 'descricao', 'nivel'), |
---|
315 | tableHeader: {'descricao': 'Nome', 'nivel': 'Nível'}, |
---|
316 | combo: {'id': 'area_status_id', 'name': 'descricao'} |
---|
317 | }; |
---|
318 | var objAreaStatus = new CadastroAjax(); |
---|
319 | Object.extend(objAreaStatus, CadastroAreaStatus); |
---|
320 | |
---|
321 | var CadastroCostCenter = |
---|
322 | { |
---|
323 | name: 'costCenter', |
---|
324 | required: new Array('organizacao_id', 'nm_centro_custo', 'descricao', 'grupo'), |
---|
325 | tableHeader: {'nm_centro_custo': 'Número', 'descricao': 'Nome', 'grupo': 'Grupo'}, |
---|
326 | combo: {'id': 'centro_custo_id', 'name': 'descricao'} |
---|
327 | }; |
---|
328 | var objCostCenter = new CadastroAjax(); |
---|
329 | Object.extend(objCostCenter, CadastroCostCenter); |
---|
330 | |
---|
331 | var CadastroLocal = |
---|
332 | { |
---|
333 | name: 'local', |
---|
334 | required: new Array('organizacao_id', 'descricao'), |
---|
335 | tableHeader: {'descricao': 'Localidade'}, |
---|
336 | combo: {'id': 'localidade_id', 'name': 'descricao'} |
---|
337 | }; |
---|
338 | var objLocal = new CadastroAjax(); |
---|
339 | Object.extend(objLocal, CadastroLocal); |
---|
340 | |
---|
341 | var CadastroEmployee = |
---|
342 | { |
---|
343 | name: 'employee', |
---|
344 | required: new Array('funcionario_id', 'organizacao_id', 'funcionario_status_id', 'centro_custo_id', 'localidade_id', 'area_id'), |
---|
345 | tableHeader: {'funcionario_id': 'Funcionário'}, |
---|
346 | combo: {'id': 'funcionario_id', 'name': 'funcionario_id'} |
---|
347 | }; |
---|
348 | var objEmployee = new CadastroAjax(); |
---|
349 | Object.extend(objEmployee, CadastroEmployee); |
---|
350 | |
---|
351 | var CadastroArea = |
---|
352 | { |
---|
353 | name: 'area', |
---|
354 | required: new Array('organizacao_id', 'area_status_id', 'centro_custo_id', 'superior_area_id', 'sigla', 'descricao', 'ativa'), |
---|
355 | tableHeader: {'sigla': 'Área'}, |
---|
356 | combo: {'id': 'area_id', 'name': 'sigla'} |
---|
357 | }; |
---|
358 | var objArea = new CadastroAjax(); |
---|
359 | Object.extend(objArea, CadastroArea); |
---|
360 | |
---|
361 | var CadastroTelefone = |
---|
362 | { |
---|
363 | name: 'telephones', |
---|
364 | required: new Array('organizacao_id', 'descricao', 'numero'), |
---|
365 | tableHeader: {'descricao': 'Descrição', 'numero': 'Telefones'}, |
---|
366 | combo: {'id': 'telefone_id', 'name': 'descricao'} |
---|
367 | }; |
---|
368 | var objTelephones = new CadastroAjax(); |
---|
369 | Object.extend(objTelephones, CadastroTelefone); |
---|
370 | |
---|
371 | function createOrganizationLayout(organizationID, organizationDiv) |
---|
372 | { |
---|
373 | organizationDiv.innerHTML = '<div id="orgchartMenu_' + organizationID + '"></div>'; |
---|
374 | organizationDiv.innerHTML += '<div class="orgchartAreas" id="orgchartAreas_' + organizationID + '"></div>'; |
---|
375 | organizationDiv.innerHTML += '<div class="orgchartEmployees" id="orgchartEmployees_' + organizationID + '"></div>'; |
---|
376 | organizationDiv.innerHTML += '<div class="orgchartFooter"></div>'; |
---|
377 | organizationDiv.innerHTML += '<div id="employeeInfo" class="employeeInfo" style="display: none;"></div>'; |
---|
378 | organizationDiv.innerHTML += '<div id="areaInfo" class="employeeInfo" style="display: none;"></div>'; |
---|
379 | |
---|
380 | createOrganizationMenu(organizationID, $('orgchartMenu_' + organizationID)); |
---|
381 | loadOrganizationAreas(organizationID, $('orgchartAreas_' + organizationID)); |
---|
382 | lb_initialize(); |
---|
383 | } |
---|
384 | |
---|
385 | function createOrganizationMenu(organizationID, div) |
---|
386 | { |
---|
387 | var content = '<ul class="horizontalMenu">'; |
---|
388 | content += '<li style="margin: 5px 5px 0 5px">Atualizar : <select>' |
---|
389 | content += '<option></option>' |
---|
390 | content += '<option onclick="loadAddEmployeeStatusUI(' + organizationID + ');" class="lbOn">Status de Funcionário</option>' |
---|
391 | content += '<option onclick="loadAddEmployeeCategoryUI(' + organizationID + ');" class="lbOn">Categorias</option>' |
---|
392 | content += '<option onclick="loadAddJobTitleUI(' + organizationID + ');" class="lbOn">Cargos</option>' |
---|
393 | content += '<option onclick="loadAddAreaStatusUI(' + organizationID + ');" class="lbOn">Status de Área</option>' |
---|
394 | content += '<option onclick="loadAddCostCenterUI(' + organizationID + ');" class="lbOn">Centros de Custo</option>' |
---|
395 | content += '<option onclick="loadAddLocalUI(' + organizationID + ');" class="lbOn">Localidade</option>' |
---|
396 | content += '<option onclick="loadAddAreaUI(' + organizationID + ');" class="lbOn">Áreas</option>' |
---|
397 | content += '<option onclick="loadAddEmployeeUI(' + organizationID + ');" class="lbOn">Funcionários</option>' |
---|
398 | content += '<option onclick="loadAddTelephoneUI(' + organizationID + ');" class="lbOn">Telefones</option>' |
---|
399 | content += '</select></li>'; |
---|
400 | content += '<li><a><input type="text" name="search_term" id="search_term" onkeypress="if (((window.Event) ? event.which : event.keyCode) == 13) $(\'search_span_' + organizationID + '\').onclick(); return true;" /> <span id="search_span_' + organizationID + '" onclick="tmp = $$(\'div#orgchartAreas_' + organizationID + ' a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); searchEmployee(' + organizationID + ', $(\'orgchartEmployees_' + organizationID + '\')); return false;">busca</span></a></li>'; |
---|
401 | content += '</ul>'; |
---|
402 | content += '<br/>'; |
---|
403 | content += '<br/>'; |
---|
404 | div.innerHTML = content; |
---|
405 | } |
---|
406 | |
---|
407 | function loadOrganizationAreas(organizationID, div) |
---|
408 | { |
---|
409 | var loadOrganizationAreasResult = function(data) |
---|
410 | { |
---|
411 | function recursivePrint(subdata) |
---|
412 | { |
---|
413 | for (var i = 0; i < subdata.length; i++) |
---|
414 | { |
---|
415 | 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'] + ', ' + organizationID + '); return false;" onmouseout="hideAreaInfo(); return false;" onclick="tmp = $$(\'div#orgchartAreas_' + organizationID + ' a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); this.addClassName(\'destaque\'); loadAreaEmployees(' + organizationID + ', ' + subdata[i]['area_id'] + ', $(\'orgchartEmployees_' + organizationID + '\'))">' + subdata[i]['sigla'] + '</a>'; |
---|
416 | if (subdata[i]['children'].length > 0) |
---|
417 | recursivePrint(subdata[i]['children']); |
---|
418 | } |
---|
419 | } |
---|
420 | |
---|
421 | if (!handleError(data)) |
---|
422 | return; |
---|
423 | |
---|
424 | if (data.length == 0) |
---|
425 | { |
---|
426 | div.innerHTML = "<br/><br/><center><strong>Nenhuma área cadastrada.</strong></center><br/><br/>"; |
---|
427 | return; |
---|
428 | } |
---|
429 | |
---|
430 | div.innerHTML = "<center><strong>ÁREAS</strong></center>"; |
---|
431 | recursivePrint(data); |
---|
432 | if (refreshEmployees[organizationID]) |
---|
433 | refreshEmployees[organizationID](); |
---|
434 | }; |
---|
435 | |
---|
436 | objArea.ajaxAction('listHierarchical', loadOrganizationAreasResult, $H({'organizacao_id': organizationID}).toQueryString()); |
---|
437 | refreshAreas[organizationID] = function(){objArea.ajaxAction('listHierarchical', loadOrganizationAreasResult, $H({'organizacao_id': organizationID}).toQueryString());}; |
---|
438 | } |
---|
439 | |
---|
440 | function searchEmployee(organizationID, div) |
---|
441 | { |
---|
442 | var searchEmployeeResult = function(data) |
---|
443 | { |
---|
444 | if (!handleError(data)) |
---|
445 | return; |
---|
446 | |
---|
447 | div.innerHTML = ""; |
---|
448 | if (data.length == 0) |
---|
449 | { |
---|
450 | div.innerHTML = "<br/><br/><center><strong>Nenhum funcionário encontrado.</strong></center>"; |
---|
451 | return; |
---|
452 | } |
---|
453 | |
---|
454 | var tableHeader = new Array(); |
---|
455 | tableHeader['funcionario_id_desc'] = 'Funcionário'; |
---|
456 | tableHeader['area_sigla'] = 'Área'; |
---|
457 | tableHeader['uid'] = 'UID'; |
---|
458 | tableHeader['actions'] = 'Ações'; |
---|
459 | for (var i = 0; i < data.length; i++) |
---|
460 | { |
---|
461 | var dataHash = new Hash(); |
---|
462 | for (j in data[i]) |
---|
463 | if (typeof data[i][j] != "function") |
---|
464 | dataHash[j] = data[i][j]; |
---|
465 | |
---|
466 | data[i]['tr_attributes'] = new Array(); |
---|
467 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
468 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
469 | data[i]['funcionario_id_desc'] = '<a href="javascript:void(0)" class="lbOn" onmouseover="getEmployeeInfoTimer(event, ' + data[i]['funcionario_id'] + ', ' + organizationID + '); return false;" onmouseout="hideEmployeeInfo(); return false;" onclick="loadAddEmployeeUI(' + organizationID + ', function(){objEmployee.fillForm(' + dataHash.customInspect() + ')}); $(\'addEmployeeLink\').parentNode.removeChild($(\'addEmployeeLink\')); return false;">' + data[i]['funcionario_id_desc'] + '</a>' + (data[i]['removed'] ? ' <font color="red">(excluído)</font>' : ''); |
---|
470 | data[i]['actions'] = '<a href="#" onclick="objEmployee.remove({\'funcionario_id\': ' + data[i]['funcionario_id'] + ', \'organizacao_id\': ' + organizationID + '} , this.parentNode.parentNode); return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/button_cancel.png" /></a>'; |
---|
471 | } |
---|
472 | |
---|
473 | var tableAtributes = new Array(); |
---|
474 | tableAtributes['class'] = 'employeeList'; |
---|
475 | tableAtributes['className'] = 'employeeList'; |
---|
476 | div.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
477 | lb_initialize(); |
---|
478 | }; |
---|
479 | |
---|
480 | objEmployee.ajaxAction('search', searchEmployeeResult, $H({'organizacao_id': organizationID, 'search_term': $F('search_term')}).toQueryString()); |
---|
481 | refreshEmployees[organizationID] = function(){objEmployee.ajaxAction('search', searchEmployeeResult, $H({'organizacao_id': organizationID, 'search_term': $F('search_term')}).toQueryString());}; |
---|
482 | } |
---|
483 | |
---|
484 | function loadAreaEmployees(organizationID, areaID, div) |
---|
485 | { |
---|
486 | var loadAreaEmployeesResult = function(data) |
---|
487 | { |
---|
488 | if (!handleError(data)) |
---|
489 | return; |
---|
490 | |
---|
491 | var areaLink = $('area_' + areaID); |
---|
492 | if (!areaLink.hasClassName('destaque')) |
---|
493 | areaLink.addClassName('destaque'); |
---|
494 | |
---|
495 | div.innerHTML = ""; |
---|
496 | if (data.length == 0) |
---|
497 | { |
---|
498 | div.innerHTML = "<br/><br/><center><strong>Nenhum funcionário alocado nesta área.</strong></center>"; |
---|
499 | return; |
---|
500 | } |
---|
501 | |
---|
502 | var tableHeader = new Array(); |
---|
503 | tableHeader['funcionario_id_desc'] = 'Funcionário'; |
---|
504 | tableHeader['uid'] = 'UID'; |
---|
505 | tableHeader['actions'] = 'Ações'; |
---|
506 | for (var i = 0; i < data.length; i++) |
---|
507 | { |
---|
508 | var dataHash = new Hash(); |
---|
509 | for (j in data[i]) |
---|
510 | if (typeof data[i][j] != "function") |
---|
511 | dataHash[j] = data[i][j]; |
---|
512 | |
---|
513 | data[i]['tr_attributes'] = new Array(); |
---|
514 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
515 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
516 | data[i]['funcionario_id_desc'] = '<a href="javascript:void(0)" class="lbOn" onmouseover="getEmployeeInfoTimer(event, ' + data[i]['funcionario_id'] + ', ' + organizationID + '); return false;" onmouseout="hideEmployeeInfo(); return false;" onclick="loadAddEmployeeUI(' + organizationID + ', function(){objEmployee.fillForm(' + dataHash.customInspect() + ')}); $(\'addEmployeeLink\').parentNode.removeChild($(\'addEmployeeLink\')); return false;">' + data[i]['funcionario_id_desc'] + '</a>' + (data[i]['removed'] ? ' <font color="red">(excluído)</font>' : ''); |
---|
517 | data[i]['actions'] = '<a href="#" onclick="objEmployee.remove({\'funcionario_id\': ' + data[i]['funcionario_id'] + ', \'organizacao_id\': ' + organizationID + '} , this.parentNode.parentNode); return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/button_cancel.png" /></a>'; |
---|
518 | window.scrollTo(0,0); |
---|
519 | } |
---|
520 | |
---|
521 | var tableAtributes = new Array(); |
---|
522 | tableAtributes['class'] = 'employeeList'; |
---|
523 | tableAtributes['className'] = 'employeeList'; |
---|
524 | div.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
525 | |
---|
526 | lb_initialize(); |
---|
527 | }; |
---|
528 | |
---|
529 | objEmployee.ajaxAction('listArea', loadAreaEmployeesResult, $H({'area_id': areaID, 'organizacao_id': organizationID}).toQueryString()); |
---|
530 | refreshEmployees[organizationID] = function(){objEmployee.ajaxAction('listArea', loadAreaEmployeesResult, $H({'area_id': areaID, 'organizacao_id': organizationID}).toQueryString());}; |
---|
531 | } |
---|
532 | |
---|
533 | function loadAddEmployeeStatusUI(organizationID) |
---|
534 | { |
---|
535 | var valoresSimNao = new Array(); |
---|
536 | valoresSimNao['S'] = 'Sim'; |
---|
537 | valoresSimNao['N'] = 'Não'; |
---|
538 | |
---|
539 | var content; |
---|
540 | content = '<h2 id="modalTitle">Adicionar Status de Funcionário</h2>'; |
---|
541 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
542 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
543 | content += "<table>"; |
---|
544 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
545 | content += '<tr><td><label for="exibir">Exibir para o usuário</label></td>' + constructSelectBox('exibir', valoresSimNao) + '</td></tr>'; |
---|
546 | content += "</table>"; |
---|
547 | content += '</form>'; |
---|
548 | content += '<button id="inserir" onclick="objEmployeeStatus.add(); return false;">Inserir</button>'; |
---|
549 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
550 | |
---|
551 | var divLB = $('lbContent'); |
---|
552 | divLB.innerHTML = content; |
---|
553 | $('descricao').focus(); |
---|
554 | objEmployeeStatus.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
555 | } |
---|
556 | |
---|
557 | function loadAddEmployeeCategoryUI(organizationID) |
---|
558 | { |
---|
559 | var content; |
---|
560 | content = '<h2 id="modalTitle">Adicionar Categoria</h2>'; |
---|
561 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
562 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
563 | content += '<table>'; |
---|
564 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
565 | content += "</table>"; |
---|
566 | content += '</form>'; |
---|
567 | content += '<button id="inserir" onclick="objEmployeeCategory.add(); return false;">Inserir</button>'; |
---|
568 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
569 | |
---|
570 | var divLB = $('lbContent'); |
---|
571 | divLB.innerHTML = content; |
---|
572 | $('descricao').focus(); |
---|
573 | objEmployeeCategory.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
574 | } |
---|
575 | |
---|
576 | function loadAddJobTitleUI(organizationID) |
---|
577 | { |
---|
578 | var content; |
---|
579 | content = '<h2 id="modalTitle">Adicionar Cargos</h2>'; |
---|
580 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
581 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
582 | content += '<table>'; |
---|
583 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
584 | content += "</table>"; |
---|
585 | content += '</form>'; |
---|
586 | content += '<button id="inserir" onclick="objJobTitle.add(); return false;">Inserir</button>'; |
---|
587 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
588 | |
---|
589 | var divLB = $('lbContent'); |
---|
590 | divLB.innerHTML = content; |
---|
591 | $('descricao').focus(); |
---|
592 | objJobTitle.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
593 | } |
---|
594 | |
---|
595 | function loadAddAreaStatusUI(organizationID) |
---|
596 | { |
---|
597 | var content; |
---|
598 | content = '<h2 id="modalTitle">Adicionar Status de Área</h2>'; |
---|
599 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
600 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
601 | content += '<table>'; |
---|
602 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
603 | content += '<tr><td><label for="nivel">Nível</label></td><td><input type="text" name="nivel" id="nivel" size="3" /></td></tr>'; |
---|
604 | content += "</table>"; |
---|
605 | content += '</form>'; |
---|
606 | content += '<button id="inserir" onclick="objAreaStatus.add(); return false;">Inserir</button>'; |
---|
607 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
608 | |
---|
609 | var divLB = $('lbContent'); |
---|
610 | divLB.innerHTML = content; |
---|
611 | $('descricao').focus(); |
---|
612 | objAreaStatus.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
613 | } |
---|
614 | |
---|
615 | function loadAddCostCenterUI(organizationID) |
---|
616 | { |
---|
617 | var content; |
---|
618 | content = '<h2 id="modalTitle">Adicionar Centro de Custo</h2>'; |
---|
619 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
620 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
621 | content += "<table>"; |
---|
622 | content += '<tr><td><label for="nm_centro_custo">Número</label></td><td><input type="text" name="nm_centro_custo" id="nm_centro_custo" size="4" /></td></tr>'; |
---|
623 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
624 | content += '<tr><td><label for="grupo">Grupo</label></td><td><input type="text" name="grupo" id="grupo" size="10" /></td></tr>'; |
---|
625 | content += "</table>"; |
---|
626 | content += '</form>'; |
---|
627 | content += '<button id="inserir" onclick="objCostCenter.add(); return false;">Inserir</button>'; |
---|
628 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
629 | |
---|
630 | var divLB = $('lbContent'); |
---|
631 | divLB.innerHTML = content; |
---|
632 | $('nm_centro_custo').focus(); |
---|
633 | objCostCenter.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
634 | } |
---|
635 | |
---|
636 | function loadAddLocalUI(organizationID) |
---|
637 | { |
---|
638 | var content; |
---|
639 | content = '<h2 id="modalTitle">Adicionar Localidade</h2>'; |
---|
640 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
641 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
642 | content += "<table>"; |
---|
643 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
644 | |
---|
645 | content += '<tr><td><label for="empresa">Empresa</label></td><td><input type="text" name="empresa" id="empresa" size="80" /></td></tr>'; |
---|
646 | content += '<tr><td><label for="endereco">Endereço</label></td><td><input type="text" name="endereco" id="endereco" size="80" /></td></tr>'; |
---|
647 | content += '<tr><td><label for="complemento">Complemento</label></td><td><input type="text" name="complemento" id="complemento" size="50" /></td></tr>'; |
---|
648 | content += '<tr><td><label for="cep">Cep</label></td><td><input type="text" name="cep" id="cep" size="10" /></td></tr>'; |
---|
649 | content += '<tr><td><label for="bairro">Bairro</label></td><td><input type="text" name="bairro" id="bairro" size="30" /></td></tr>'; |
---|
650 | content += '<tr><td><label for="cidade">Cidade</label></td><td><input type="text" name="cidade" id="cidade" size="50" /></td></tr>'; |
---|
651 | content += '<tr><td><label for="uf">UF</label></td><td><input type="text" name="uf" id="uf" size="2" maxlength="2" /></td></tr>'; |
---|
652 | |
---|
653 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
654 | content += "</table>"; |
---|
655 | content += '</form>'; |
---|
656 | content += '<button id="inserir" onclick="objLocal.add(); return false;">Inserir</button>'; |
---|
657 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
658 | |
---|
659 | var divLB = $('lbContent'); |
---|
660 | divLB.innerHTML = content; |
---|
661 | $('descricao').focus(); |
---|
662 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), true, null, |
---|
663 | function() |
---|
664 | { |
---|
665 | objLocal.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
666 | } |
---|
667 | ); |
---|
668 | } |
---|
669 | |
---|
670 | function loadAddEmployeeUI(organizationID, callback) |
---|
671 | { |
---|
672 | var content; |
---|
673 | content = '<h2 id="modalTitle">Adicionar Funcionário</h2>'; |
---|
674 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
675 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
676 | content += "<table>"; |
---|
677 | content += '<tr><td><label for="funcionario_id_desc">Funcionário</label></td><td>'; |
---|
678 | content += '<input type="hidden" name="funcionario_id" id="funcionario_id" value="" />'; |
---|
679 | content += '<input type="input" name="funcionario_id_desc" id="funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
680 | content += '<a href="javascript:void(0)" onclick="openParticipants(\'funcionario_id\', \'uid=1&hidegroups=1\');" id="addEmployeeLink"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/add_user.png" /></a>'; |
---|
681 | content += '</td></tr>'; |
---|
682 | content += '<tr><td><label for="funcionario_status_id">Status</label></td><td id="comboStatus"><i>carregando</i></td></tr>'; |
---|
683 | content += '<tr><td><label for="funcionario_categoria_id">Categoria</label></td><td id="comboFuncionarioCategoria"><i>carregando</i></td></tr>'; |
---|
684 | content += '<tr><td><label for="cargo_id">Cargo</label></td><td id="comboCargo"><i>carregando</i></td></tr>'; |
---|
685 | |
---|
686 | content += '<tr><td><label for="titulo">Título</label></td><td><input type="text" size="30" name="titulo" id="titulo"/></td></tr>'; |
---|
687 | |
---|
688 | content += '<tr><td><label for="nivel">Nível</label></td><td><input type="text" size="3" name="nivel" id="nivel"/></td></tr>'; |
---|
689 | content += '<tr><td><label for="area_id">Área</label></td><td id="comboArea"><i>carregando</i></td></tr>'; |
---|
690 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
691 | content += '<tr><td><label for="localidade_id">Localidade</label></td><td id="comboLocalidade"><i>carregando</i></td></tr>'; |
---|
692 | content += "</table>"; |
---|
693 | content += '</form>'; |
---|
694 | content += '<button id="inserir" onclick="objEmployee.add(); return false;">Inserir</button>'; |
---|
695 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
696 | |
---|
697 | var divLB = $('lbContent'); |
---|
698 | divLB.innerHTML = content; |
---|
699 | |
---|
700 | objEmployeeStatus.generateComboBox({'organizacao_id': organizationID}, $('comboStatus'), false, null, |
---|
701 | function() |
---|
702 | { |
---|
703 | objEmployeeCategory.generateComboBox({'organizacao_id': organizationID}, $('comboFuncionarioCategoria'), true, null, |
---|
704 | function() |
---|
705 | { |
---|
706 | objJobTitle.generateComboBox({'organizacao_id': organizationID}, $('comboCargo'), true, null, |
---|
707 | function() |
---|
708 | { |
---|
709 | objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), false, null, |
---|
710 | function() |
---|
711 | { |
---|
712 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), true, null, |
---|
713 | function() |
---|
714 | { |
---|
715 | objLocal.generateComboBox({'organizacao_id': organizationID}, $('comboLocalidade'), false, null, callback); |
---|
716 | } |
---|
717 | ) |
---|
718 | } |
---|
719 | ) |
---|
720 | } |
---|
721 | ) |
---|
722 | } |
---|
723 | ) |
---|
724 | } |
---|
725 | ); |
---|
726 | } |
---|
727 | |
---|
728 | function loadAddAreaUI(organizationID) |
---|
729 | { |
---|
730 | var valoresSimNao = new Array(); |
---|
731 | valoresSimNao['S'] = 'Sim'; |
---|
732 | valoresSimNao['N'] = 'Não'; |
---|
733 | |
---|
734 | var content; |
---|
735 | content = '<h2 id="modalTitle">Adicionar Área</h2>'; |
---|
736 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
737 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
738 | content += "<table>"; |
---|
739 | content += '<tr><td><label for="sigla">Sigla</label></td><td><input type="text" name="sigla" id="sigla" size="15" /></td></tr>'; |
---|
740 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
741 | content += '<tr><td><label for="titular_funcionario_id">Titular</label></td><td>'; |
---|
742 | content += '<input type="hidden" name="titular_funcionario_id" id="titular_funcionario_id" value="" />'; |
---|
743 | content += '<input type="input" name="titular_funcionario_id_desc" id="titular_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
744 | content += '<a href="javascript:void(0)" onclick="openParticipants(\'titular_funcionario_id\', \'uid=1&hidegroups=1\');"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/add_user.png" /></a>'; |
---|
745 | content += ' <a href="javascript:void(0)" onclick="$(\'titular_funcionario_id\').value=\'\'; $(\'titular_funcionario_id_desc\').value=\'\'; return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/delete_user.png" /></a>'; |
---|
746 | content += '</td></tr>'; |
---|
747 | content += '<tr><td><label for="substituto_funcionario_id">Substituto</label></td><td>'; |
---|
748 | content += '<input type="hidden" name="substituto_funcionario_id" id="substituto_funcionario_id" value="" />'; |
---|
749 | content += '<input type="input" name="substituto_funcionario_id_desc" id="substituto_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
750 | content += '<a href="javascript:void(0)" onclick="openParticipants(\'substituto_funcionario_id\', \'uid=1&hidegroups=1\');"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/add_user.png" /></a>'; |
---|
751 | content += ' <a href="javascript:void(0)" onclick="$(\'substituto_funcionario_id\').value=\'\'; $(\'substituto_funcionario_id_desc\').value=\'\'; return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/delete_user.png" /></a>'; |
---|
752 | content += '</td></tr>'; |
---|
753 | content += '<tr><td><label for="auxiliar_funcionario_id">Auxiliar Administrativo</label></td><td>'; |
---|
754 | content += '<input type="hidden" name="auxiliar_funcionario_id" id="auxiliar_funcionario_id" value="" />'; |
---|
755 | content += '<input type="input" name="auxiliar_funcionario_id_desc" id="auxiliar_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
756 | content += '<a href="javascript:void(0)" onclick="openParticipants(\'auxiliar_funcionario_id\', \'uid=1&hidegroups=1\');"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/add_user.png" /></a>'; |
---|
757 | content += ' <a href="javascript:void(0)" onclick="$(\'auxiliar_funcionario_id\').value=\'\'; $(\'auxiliar_funcionario_id_desc\').value=\'\'; return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/delete_user.png" /></a>'; |
---|
758 | content += '</td></tr>'; |
---|
759 | content += '<tr><td><label for="area_status_id">Status</label></td><td id="comboStatus"><i>carregando</i></td></tr>'; |
---|
760 | content += '<tr><td><label for="superior_area_id">Área Superior</label></td><td id="comboArea"><i>carregando</i></td></tr>'; |
---|
761 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
762 | content += '<tr><td><label for="ativa">Ativa</label></td><td>' + constructSelectBox('ativa', valoresSimNao) + '</td></tr>'; |
---|
763 | content += "</table>"; |
---|
764 | content += '</form>'; |
---|
765 | content += '<button id="inserir" onclick="objArea.add(); return false;">Inserir</button>'; |
---|
766 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
767 | |
---|
768 | var divLB = $('lbContent'); |
---|
769 | divLB.innerHTML = content; |
---|
770 | $('sigla').focus(); |
---|
771 | |
---|
772 | objAreaStatus.generateComboBox({'organizacao_id': organizationID}, $('comboStatus'), false, null, |
---|
773 | function() |
---|
774 | { |
---|
775 | objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), true, 'superior_area_id', |
---|
776 | function() |
---|
777 | { |
---|
778 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), false, null, |
---|
779 | function() |
---|
780 | { |
---|
781 | objArea.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
782 | } |
---|
783 | ) |
---|
784 | } |
---|
785 | ) |
---|
786 | } |
---|
787 | ); |
---|
788 | } |
---|
789 | |
---|
790 | function loadAddTelephoneUI(organizationID) |
---|
791 | { |
---|
792 | var content; |
---|
793 | content = '<h2 id="modalTitle">Adicionar Telefones da Organização</h2>'; |
---|
794 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
795 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
796 | content += '<table>'; |
---|
797 | content += '<tr><td><label for="descricao">Descrição</label></td><td><input type="text" name="descricao" id="descricao" size="50" /></td></tr>'; |
---|
798 | content += '<tr><td><label for="nivel">Telefones</label></td><td><input type="text" name="numero" id="numero" size="50" /></td></tr>'; |
---|
799 | content += "</table>"; |
---|
800 | content += '</form>'; |
---|
801 | content += '<button id="inserir" onclick="objTelephones.add(); return false;">Inserir</button>'; |
---|
802 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
803 | |
---|
804 | var divLB = $( 'lbContent' ); |
---|
805 | divLB.innerHTML = content; |
---|
806 | $( 'descricao' ).focus( ); |
---|
807 | objTelephones.generateUpdateTable( { 'organizacao_id' : organizationID }, divLB ); |
---|
808 | } |
---|
809 | |
---|
810 | function getEmployeeInfoTimer(e, employeeID, organizationID) |
---|
811 | { |
---|
812 | var div = $('employeeInfo'); |
---|
813 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
814 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
815 | |
---|
816 | if (workflowOrgchartAdminEmployeeInfoTimer != null) |
---|
817 | { |
---|
818 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
819 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
820 | } |
---|
821 | |
---|
822 | workflowOrgchartAdminEmployeeInfoTimer = setTimeout('getEmployeeInfo(' + employeeID + ', ' + organizationID + ' )', 500); |
---|
823 | } |
---|
824 | |
---|
825 | function getEmployeeInfo(employeeID, organizationID) |
---|
826 | { |
---|
827 | function resultGetEmployeeInfo(data) |
---|
828 | { |
---|
829 | if (workflowOrgchartAdminEmployeeInfoTimer == null) |
---|
830 | return; |
---|
831 | |
---|
832 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
833 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
834 | |
---|
835 | var content = ''; |
---|
836 | content += '<table><tr><td valign="top">'; |
---|
837 | content += '<img src="workflow/showUserPicture.php?userID=' + employeeID + '"/>'; |
---|
838 | content += '</td><td valign="top" style="padding-left: 12px;">'; |
---|
839 | for (var i = 0; i < data['info'].length; i++) |
---|
840 | content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>'; |
---|
841 | content += '</td></tr></table>'; |
---|
842 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
843 | var div = $('employeeInfo'); |
---|
844 | div.innerHTML = content; |
---|
845 | |
---|
846 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
847 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
848 | |
---|
849 | div.show(); |
---|
850 | } |
---|
851 | cExecute('$this.bo_orgchart.getEmployeeInfo', resultGetEmployeeInfo, 'funcionario_id=' + employeeID + '&organizacao_id=' + organizationID); |
---|
852 | } |
---|
853 | |
---|
854 | function hideEmployeeInfo() |
---|
855 | { |
---|
856 | if (workflowOrgchartAdminEmployeeInfoTimer != null) |
---|
857 | { |
---|
858 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
859 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
860 | } |
---|
861 | $('employeeInfo').hide(); |
---|
862 | } |
---|
863 | |
---|
864 | function getAreaInfoTimer(e, areaID, organizationID) |
---|
865 | { |
---|
866 | var div = $('areaInfo'); |
---|
867 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
868 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
869 | |
---|
870 | if (workflowOrgchartAdminAreaInfoTimer != null) |
---|
871 | { |
---|
872 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
873 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
874 | } |
---|
875 | |
---|
876 | workflowOrgchartAdminAreaInfoTimer = setTimeout('getAreaInfo(' + areaID + ', ' + organizationID + ' )', 500); |
---|
877 | } |
---|
878 | |
---|
879 | function getAreaInfo(areaID, organizationID) |
---|
880 | { |
---|
881 | function resultGetAreaInfo(data) |
---|
882 | { |
---|
883 | if (workflowOrgchartAdminAreaInfoTimer == null) |
---|
884 | return; |
---|
885 | |
---|
886 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
887 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
888 | |
---|
889 | var content = ''; |
---|
890 | content += '<table><tr>'; |
---|
891 | content += '<td valign="top" style="padding-left: 12px;">'; |
---|
892 | for (var i = 0; i < data['info'].length; i++) |
---|
893 | content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>'; |
---|
894 | content += '</td></tr></table>'; |
---|
895 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
896 | var div = $('areaInfo'); |
---|
897 | div.innerHTML = content; |
---|
898 | |
---|
899 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
900 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
901 | |
---|
902 | div.show(); |
---|
903 | } |
---|
904 | cExecute('$this.bo_orgchart.getAreaInfo', resultGetAreaInfo, 'area_id=' + areaID + '&organizacao_id=' + organizationID); |
---|
905 | } |
---|
906 | |
---|
907 | function hideAreaInfo() |
---|
908 | { |
---|
909 | if (workflowOrgchartAdminAreaInfoTimer != null) |
---|
910 | { |
---|
911 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
912 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
913 | } |
---|
914 | $('areaInfo').hide(); |
---|
915 | } |
---|