[1349] | 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 | dataHash[j] = data[i][j]; |
---|
| 181 | |
---|
| 182 | for (j in tableHeader) |
---|
| 183 | if (typeof tableHeader[j] != "function") |
---|
| 184 | if (j != 'actions') |
---|
| 185 | data[i][j] = '<a href="#" onclick="obj' + name + '.fillForm(' + dataHash.customInspect() + '); return false;">' + data[i][j] + '</a>'; |
---|
| 186 | |
---|
| 187 | data[i]['tr_attributes'] = new Array(); |
---|
| 188 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
| 189 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
| 190 | 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>'; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | var tableAtributes = new Array(); |
---|
| 194 | tableAtributes['id'] = this.name + 'List'; |
---|
| 195 | tableAtributes['class'] = 'orgchartUpdateTable'; |
---|
| 196 | tableAtributes['className'] = 'orgchartUpdateTable'; |
---|
| 197 | displayArea.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
| 198 | }; |
---|
| 199 | this.list(tableResult, params); |
---|
| 200 | }, |
---|
| 201 | |
---|
| 202 | fillForm: function(dataHash) |
---|
| 203 | { |
---|
| 204 | dataHash = $H(dataHash); |
---|
| 205 | dataHash.each(function(pair) |
---|
| 206 | { |
---|
| 207 | var campo = $(pair.key); |
---|
| 208 | if (campo) |
---|
| 209 | { |
---|
| 210 | if ((campo.nodeName == "SELECT") && (pair.value == null)) |
---|
| 211 | campo.value = campo.firstChild.value; |
---|
| 212 | else |
---|
| 213 | if (pair.value != null) |
---|
| 214 | campo.value = pair.value; |
---|
| 215 | } |
---|
| 216 | else |
---|
| 217 | new Insertion.Bottom($('orgchartForm'), '<input type="hidden" name="' + pair.key + '" id="' + pair.key + '" value="' + pair.value + '" />'); |
---|
| 218 | }); |
---|
| 219 | if (!$('updateOrgchart')) |
---|
| 220 | new Insertion.Bottom($('orgchartForm'), '<input type="hidden" name="updateOrgchart" id="updateOrgchart" value="true" />'); |
---|
| 221 | var saveButton = $('inserir'); |
---|
| 222 | saveButton.innerHTML = "Salvar"; |
---|
| 223 | var name = this.name; |
---|
| 224 | saveButton.onclick = function(){ eval('obj' + name.charAt(0).capitalize() + name.substr(1) + '.update();')}; |
---|
| 225 | var titleObject = $('modalTitle'); |
---|
| 226 | var title = titleObject.innerHTML.split(' '); |
---|
| 227 | title[0] = "Atualizar"; |
---|
| 228 | titleObject.innerHTML = title.join(' '); |
---|
| 229 | $('lightbox').scrollTop = 0; |
---|
| 230 | }, |
---|
| 231 | |
---|
| 232 | generateComboBox: function(params, displayArea, includeNull, name, callback) |
---|
| 233 | { |
---|
| 234 | if (!name) |
---|
| 235 | name = this.combo['id']; |
---|
| 236 | combo = this.combo; |
---|
| 237 | var comboResult = function(data) |
---|
| 238 | { |
---|
| 239 | if (!handleError(data)) |
---|
| 240 | return; |
---|
| 241 | |
---|
| 242 | var newFormat = new Array(); |
---|
| 243 | if (includeNull) |
---|
| 244 | newFormat['NULL'] = "Nenhum"; |
---|
| 245 | for (var i = 0; i < data.length; i++) |
---|
| 246 | newFormat[data[i][combo['id']]] = data[i][combo['name']]; |
---|
| 247 | if ((newFormat.length > 0) || includeNull) |
---|
| 248 | displayArea.innerHTML = constructSelectBox(name, newFormat); |
---|
| 249 | else |
---|
| 250 | displayArea.innerHTML = '<i>nenhum registro encontado</i><input type="hidden" id="' + name + '" value=""/>'; |
---|
| 251 | if (callback) |
---|
| 252 | callback(); |
---|
| 253 | }; |
---|
| 254 | this.list(comboResult, params); |
---|
| 255 | }, |
---|
| 256 | |
---|
| 257 | ajaxAction: function(action, callback, params) |
---|
| 258 | { |
---|
| 259 | if (params == "") |
---|
| 260 | cExecute('$this.bo_orgchart.' + action + this.name.charAt(0).capitalize() + this.name.substr(1), callback); |
---|
| 261 | else |
---|
| 262 | cExecute('$this.bo_orgchart.' + action + this.name.charAt(0).capitalize() + this.name.substr(1), callback, params); |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | }; |
---|
| 266 | |
---|
| 267 | var CadastroOrganization = |
---|
| 268 | { |
---|
| 269 | name: 'organization', |
---|
| 270 | required: new Array('nome', 'descricao', 'ativa'), |
---|
| 271 | tableHeader: {'nome': 'Organização'}, |
---|
| 272 | combo: {'id': 'organizacao_id', 'name': 'nome'} |
---|
| 273 | }; |
---|
| 274 | var objOrganization = new CadastroAjax(); |
---|
| 275 | Object.extend(objOrganization, CadastroOrganization); |
---|
| 276 | |
---|
| 277 | var CadastroEmployeeStatus = |
---|
| 278 | { |
---|
| 279 | name: 'employeeStatus', |
---|
| 280 | required: new Array('descricao', 'exibir'), |
---|
| 281 | tableHeader: {'descricao': 'Status de Funcionário'}, |
---|
| 282 | combo: {'id': 'funcionario_status_id', 'name': 'descricao'} |
---|
| 283 | }; |
---|
| 284 | var objEmployeeStatus = new CadastroAjax(); |
---|
| 285 | Object.extend(objEmployeeStatus, CadastroEmployeeStatus); |
---|
| 286 | |
---|
| 287 | var CadastroEmployeeCategory = |
---|
| 288 | { |
---|
| 289 | name: 'employeeCategory', |
---|
| 290 | required: new Array('organizacao_id', 'descricao'), |
---|
| 291 | tableHeader: {'descricao': 'Nome'}, |
---|
| 292 | combo: {'id': 'funcionario_categoria_id', 'name': 'descricao'} |
---|
| 293 | }; |
---|
| 294 | var objEmployeeCategory = new CadastroAjax(); |
---|
| 295 | Object.extend(objEmployeeCategory, CadastroEmployeeCategory); |
---|
| 296 | |
---|
| 297 | var CadastroJobTitle = |
---|
| 298 | { |
---|
| 299 | name: 'jobTitle', |
---|
| 300 | required: new Array('organizacao_id', 'descricao'), |
---|
| 301 | tableHeader: {'descricao': 'Nome'}, |
---|
| 302 | combo: {'id': 'cargo_id', 'name': 'descricao'} |
---|
| 303 | }; |
---|
| 304 | var objJobTitle = new CadastroAjax(); |
---|
| 305 | Object.extend(objJobTitle, CadastroJobTitle); |
---|
| 306 | |
---|
| 307 | var CadastroAreaStatus = |
---|
| 308 | { |
---|
| 309 | name: 'areaStatus', |
---|
| 310 | required: new Array('organizacao_id', 'descricao', 'nivel'), |
---|
| 311 | tableHeader: {'descricao': 'Nome', 'nivel': 'Nível'}, |
---|
| 312 | combo: {'id': 'area_status_id', 'name': 'descricao'} |
---|
| 313 | }; |
---|
| 314 | var objAreaStatus = new CadastroAjax(); |
---|
| 315 | Object.extend(objAreaStatus, CadastroAreaStatus); |
---|
| 316 | |
---|
| 317 | var CadastroCostCenter = |
---|
| 318 | { |
---|
| 319 | name: 'costCenter', |
---|
| 320 | required: new Array('organizacao_id', 'nm_centro_custo', 'descricao', 'grupo'), |
---|
| 321 | tableHeader: {'nm_centro_custo': 'Número', 'descricao': 'Nome', 'grupo': 'Grupo'}, |
---|
| 322 | combo: {'id': 'centro_custo_id', 'name': 'descricao'} |
---|
| 323 | }; |
---|
| 324 | var objCostCenter = new CadastroAjax(); |
---|
| 325 | Object.extend(objCostCenter, CadastroCostCenter); |
---|
| 326 | |
---|
| 327 | var CadastroLocal = |
---|
| 328 | { |
---|
| 329 | name: 'local', |
---|
| 330 | required: new Array('organizacao_id', 'descricao'), |
---|
| 331 | tableHeader: {'descricao': 'Localidade'}, |
---|
| 332 | combo: {'id': 'localidade_id', 'name': 'descricao'} |
---|
| 333 | }; |
---|
| 334 | var objLocal = new CadastroAjax(); |
---|
| 335 | Object.extend(objLocal, CadastroLocal); |
---|
| 336 | |
---|
| 337 | var CadastroEmployee = |
---|
| 338 | { |
---|
| 339 | name: 'employee', |
---|
| 340 | required: new Array('funcionario_id', 'organizacao_id', 'funcionario_status_id', 'centro_custo_id', 'localidade_id', 'area_id'), |
---|
| 341 | tableHeader: {'funcionario_id': 'Funcionário'}, |
---|
| 342 | combo: {'id': 'funcionario_id', 'name': 'funcionario_id'} |
---|
| 343 | }; |
---|
| 344 | var objEmployee = new CadastroAjax(); |
---|
| 345 | Object.extend(objEmployee, CadastroEmployee); |
---|
| 346 | |
---|
| 347 | var CadastroArea = |
---|
| 348 | { |
---|
| 349 | name: 'area', |
---|
| 350 | required: new Array('organizacao_id', 'area_status_id', 'centro_custo_id', 'superior_area_id', 'sigla', 'descricao', 'ativa'), |
---|
| 351 | tableHeader: {'sigla': 'Área'}, |
---|
| 352 | combo: {'id': 'area_id', 'name': 'sigla'} |
---|
| 353 | }; |
---|
| 354 | var objArea = new CadastroAjax(); |
---|
| 355 | Object.extend(objArea, CadastroArea); |
---|
| 356 | |
---|
| 357 | function createOrganizationLayout(organizationID, organizationDiv) |
---|
| 358 | { |
---|
| 359 | organizationDiv.innerHTML = '<div id="orgchartMenu_' + organizationID + '"></div>'; |
---|
| 360 | organizationDiv.innerHTML += '<div class="orgchartAreas" id="orgchartAreas_' + organizationID + '"></div>'; |
---|
| 361 | organizationDiv.innerHTML += '<div class="orgchartEmployees" id="orgchartEmployees_' + organizationID + '"></div>'; |
---|
| 362 | organizationDiv.innerHTML += '<div class="orgchartFooter"></div>'; |
---|
| 363 | organizationDiv.innerHTML += '<div id="employeeInfo" class="employeeInfo" style="display: none;"></div>'; |
---|
| 364 | organizationDiv.innerHTML += '<div id="areaInfo" class="employeeInfo" style="display: none;"></div>'; |
---|
| 365 | |
---|
| 366 | createOrganizationMenu(organizationID, $('orgchartMenu_' + organizationID)); |
---|
| 367 | loadOrganizationAreas(organizationID, $('orgchartAreas_' + organizationID)); |
---|
| 368 | lb_initialize(); |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | function createOrganizationMenu(organizationID, div) |
---|
| 372 | { |
---|
| 373 | var content = '<ul class="horizontalMenu">'; |
---|
| 374 | content += '<li><a href="#" onclick="loadAddEmployeeStatusUI(' + organizationID + '); return false;" class="lbOn">Status de Funcionário</a></li>'; |
---|
| 375 | content += '<li><a href="#" onclick="loadAddEmployeeCategoryUI(' + organizationID + '); return false;" class="lbOn">Categorias</a></li>'; |
---|
| 376 | content += '<li><a href="#" onclick="loadAddJobTitleUI(' + organizationID + '); return false;" class="lbOn">Cargos</a></li>'; |
---|
| 377 | content += '<li><a href="#" onclick="loadAddAreaStatusUI(' + organizationID + '); return false;" class="lbOn">Status de Área</a></li>'; |
---|
| 378 | content += '<li><a href="#" onclick="loadAddCostCenterUI(' + organizationID + '); return false;" class="lbOn">Centros de Custo</a></li>'; |
---|
| 379 | content += '<li><a href="#" onclick="loadAddLocalUI(' + organizationID + '); return false;" class="lbOn">Localidade</a></li>'; |
---|
| 380 | content += '<li><a href="#" onclick="loadAddAreaUI(' + organizationID + '); return false;" class="lbOn">Áreas</a></li>'; |
---|
| 381 | content += '<li><a href="#" onclick="loadAddEmployeeUI(' + organizationID + '); return false;" class="lbOn">Funcionários</a></li>'; |
---|
| 382 | 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>'; |
---|
| 383 | content += '</ul>'; |
---|
| 384 | content += '<br/>'; |
---|
| 385 | content += '<br/>'; |
---|
| 386 | div.innerHTML = content; |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | function loadOrganizationAreas(organizationID, div) |
---|
| 390 | { |
---|
| 391 | var loadOrganizationAreasResult = function(data) |
---|
| 392 | { |
---|
| 393 | function recursivePrint(subdata) |
---|
| 394 | { |
---|
| 395 | for (var i = 0; i < subdata.length; i++) |
---|
| 396 | { |
---|
| 397 | 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>'; |
---|
| 398 | if (subdata[i]['children'].length > 0) |
---|
| 399 | recursivePrint(subdata[i]['children']); |
---|
| 400 | } |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | if (!handleError(data)) |
---|
| 404 | return; |
---|
| 405 | |
---|
| 406 | if (data.length == 0) |
---|
| 407 | { |
---|
| 408 | div.innerHTML = "<br/><br/><center><strong>Nenhuma área cadastrada.</strong></center><br/><br/>"; |
---|
| 409 | return; |
---|
| 410 | } |
---|
| 411 | |
---|
| 412 | div.innerHTML = "<center><strong>ÁREAS</strong></center>"; |
---|
| 413 | recursivePrint(data); |
---|
| 414 | if (refreshEmployees[organizationID]) |
---|
| 415 | refreshEmployees[organizationID](); |
---|
| 416 | }; |
---|
| 417 | |
---|
| 418 | objArea.ajaxAction('listHierarchical', loadOrganizationAreasResult, $H({'organizacao_id': organizationID}).toQueryString()); |
---|
| 419 | refreshAreas[organizationID] = function(){objArea.ajaxAction('listHierarchical', loadOrganizationAreasResult, $H({'organizacao_id': organizationID}).toQueryString());}; |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | function searchEmployee(organizationID, div) |
---|
| 423 | { |
---|
| 424 | var searchEmployeeResult = function(data) |
---|
| 425 | { |
---|
| 426 | if (!handleError(data)) |
---|
| 427 | return; |
---|
| 428 | |
---|
| 429 | div.innerHTML = ""; |
---|
| 430 | if (data.length == 0) |
---|
| 431 | { |
---|
| 432 | div.innerHTML = "<br/><br/><center><strong>Nenhum funcionário encontrado.</strong></center>"; |
---|
| 433 | return; |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | var tableHeader = new Array(); |
---|
| 437 | tableHeader['funcionario_id_desc'] = 'Funcionário'; |
---|
| 438 | tableHeader['area_sigla'] = 'Área'; |
---|
| 439 | tableHeader['uid'] = 'UID'; |
---|
| 440 | tableHeader['actions'] = 'Ações'; |
---|
| 441 | for (var i = 0; i < data.length; i++) |
---|
| 442 | { |
---|
| 443 | var dataHash = new Hash(); |
---|
| 444 | for (j in data[i]) |
---|
| 445 | if (typeof data[i][j] != "function") |
---|
| 446 | dataHash[j] = data[i][j]; |
---|
| 447 | |
---|
| 448 | data[i]['tr_attributes'] = new Array(); |
---|
| 449 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
| 450 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
| 451 | 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>' : ''); |
---|
| 452 | 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>'; |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | var tableAtributes = new Array(); |
---|
| 456 | tableAtributes['class'] = 'employeeList'; |
---|
| 457 | tableAtributes['className'] = 'employeeList'; |
---|
| 458 | div.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
| 459 | lb_initialize(); |
---|
| 460 | }; |
---|
| 461 | |
---|
| 462 | objEmployee.ajaxAction('search', searchEmployeeResult, $H({'organizacao_id': organizationID, 'search_term': $F('search_term')}).toQueryString()); |
---|
| 463 | refreshEmployees[organizationID] = function(){objEmployee.ajaxAction('search', searchEmployeeResult, $H({'organizacao_id': organizationID, 'search_term': $F('search_term')}).toQueryString());}; |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | function loadAreaEmployees(organizationID, areaID, div) |
---|
| 467 | { |
---|
| 468 | var loadAreaEmployeesResult = function(data) |
---|
| 469 | { |
---|
| 470 | if (!handleError(data)) |
---|
| 471 | return; |
---|
| 472 | |
---|
| 473 | var areaLink = $('area_' + areaID); |
---|
| 474 | if (!areaLink.hasClassName('destaque')) |
---|
| 475 | areaLink.addClassName('destaque'); |
---|
| 476 | |
---|
| 477 | div.innerHTML = ""; |
---|
| 478 | if (data.length == 0) |
---|
| 479 | { |
---|
| 480 | div.innerHTML = "<br/><br/><center><strong>Nenhum funcionário alocado nesta área.</strong></center>"; |
---|
| 481 | return; |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | var tableHeader = new Array(); |
---|
| 485 | tableHeader['funcionario_id_desc'] = 'Funcionário'; |
---|
| 486 | tableHeader['uid'] = 'UID'; |
---|
| 487 | tableHeader['actions'] = 'Ações'; |
---|
| 488 | for (var i = 0; i < data.length; i++) |
---|
| 489 | { |
---|
| 490 | var dataHash = new Hash(); |
---|
| 491 | for (j in data[i]) |
---|
| 492 | if (typeof data[i][j] != "function") |
---|
| 493 | dataHash[j] = data[i][j]; |
---|
| 494 | |
---|
| 495 | data[i]['tr_attributes'] = new Array(); |
---|
| 496 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
| 497 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
| 498 | 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>' : ''); |
---|
| 499 | 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>'; |
---|
| 500 | window.scrollTo(0,0); |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | var tableAtributes = new Array(); |
---|
| 504 | tableAtributes['class'] = 'employeeList'; |
---|
| 505 | tableAtributes['className'] = 'employeeList'; |
---|
| 506 | div.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
| 507 | |
---|
| 508 | lb_initialize(); |
---|
| 509 | }; |
---|
| 510 | |
---|
| 511 | objEmployee.ajaxAction('listArea', loadAreaEmployeesResult, $H({'area_id': areaID, 'organizacao_id': organizationID}).toQueryString()); |
---|
| 512 | refreshEmployees[organizationID] = function(){objEmployee.ajaxAction('listArea', loadAreaEmployeesResult, $H({'area_id': areaID, 'organizacao_id': organizationID}).toQueryString());}; |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | function loadAddEmployeeStatusUI(organizationID) |
---|
| 516 | { |
---|
| 517 | var valoresSimNao = new Array(); |
---|
| 518 | valoresSimNao['S'] = 'Sim'; |
---|
| 519 | valoresSimNao['N'] = 'Não'; |
---|
| 520 | |
---|
| 521 | var content; |
---|
| 522 | content = '<h2 id="modalTitle">Adicionar Status de Funcionário</h2>'; |
---|
| 523 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 524 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 525 | content += "<table>"; |
---|
| 526 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 527 | content += '<tr><td><label for="exibir">Exibir para o usuário</label></td>' + constructSelectBox('exibir', valoresSimNao) + '</td></tr>'; |
---|
| 528 | content += "</table>"; |
---|
| 529 | content += '</form>'; |
---|
| 530 | content += '<button id="inserir" onclick="objEmployeeStatus.add(); return false;">Inserir</button>'; |
---|
| 531 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 532 | |
---|
| 533 | var divLB = $('lbContent'); |
---|
| 534 | divLB.innerHTML = content; |
---|
| 535 | $('descricao').focus(); |
---|
| 536 | objEmployeeStatus.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | function loadAddEmployeeCategoryUI(organizationID) |
---|
| 540 | { |
---|
| 541 | var content; |
---|
| 542 | content = '<h2 id="modalTitle">Adicionar Categoria</h2>'; |
---|
| 543 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 544 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 545 | content += '<table>'; |
---|
| 546 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 547 | content += "</table>"; |
---|
| 548 | content += '</form>'; |
---|
| 549 | content += '<button id="inserir" onclick="objEmployeeCategory.add(); return false;">Inserir</button>'; |
---|
| 550 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 551 | |
---|
| 552 | var divLB = $('lbContent'); |
---|
| 553 | divLB.innerHTML = content; |
---|
| 554 | $('descricao').focus(); |
---|
| 555 | objEmployeeCategory.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | function loadAddJobTitleUI(organizationID) |
---|
| 559 | { |
---|
| 560 | var content; |
---|
| 561 | content = '<h2 id="modalTitle">Adicionar Cargos</h2>'; |
---|
| 562 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 563 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 564 | content += '<table>'; |
---|
| 565 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 566 | content += "</table>"; |
---|
| 567 | content += '</form>'; |
---|
| 568 | content += '<button id="inserir" onclick="objJobTitle.add(); return false;">Inserir</button>'; |
---|
| 569 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 570 | |
---|
| 571 | var divLB = $('lbContent'); |
---|
| 572 | divLB.innerHTML = content; |
---|
| 573 | $('descricao').focus(); |
---|
| 574 | objJobTitle.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | function loadAddAreaStatusUI(organizationID) |
---|
| 578 | { |
---|
| 579 | var content; |
---|
| 580 | content = '<h2 id="modalTitle">Adicionar Status de Área</h2>'; |
---|
| 581 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 582 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 583 | content += '<table>'; |
---|
| 584 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 585 | content += '<tr><td><label for="nivel">Nível</label></td><td><input type="text" name="nivel" id="nivel" size="3" /></td></tr>'; |
---|
| 586 | content += "</table>"; |
---|
| 587 | content += '</form>'; |
---|
| 588 | content += '<button id="inserir" onclick="objAreaStatus.add(); return false;">Inserir</button>'; |
---|
| 589 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 590 | |
---|
| 591 | var divLB = $('lbContent'); |
---|
| 592 | divLB.innerHTML = content; |
---|
| 593 | $('descricao').focus(); |
---|
| 594 | objAreaStatus.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 595 | } |
---|
| 596 | |
---|
| 597 | function loadAddCostCenterUI(organizationID) |
---|
| 598 | { |
---|
| 599 | var content; |
---|
| 600 | content = '<h2 id="modalTitle">Adicionar Centro de Custo</h2>'; |
---|
| 601 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 602 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 603 | content += "<table>"; |
---|
| 604 | 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>'; |
---|
| 605 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 606 | content += '<tr><td><label for="grupo">Grupo</label></td><td><input type="text" name="grupo" id="grupo" size="10" /></td></tr>'; |
---|
| 607 | content += "</table>"; |
---|
| 608 | content += '</form>'; |
---|
| 609 | content += '<button id="inserir" onclick="objCostCenter.add(); return false;">Inserir</button>'; |
---|
| 610 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 611 | |
---|
| 612 | var divLB = $('lbContent'); |
---|
| 613 | divLB.innerHTML = content; |
---|
| 614 | $('nm_centro_custo').focus(); |
---|
| 615 | objCostCenter.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 616 | } |
---|
| 617 | |
---|
| 618 | function loadAddLocalUI(organizationID) |
---|
| 619 | { |
---|
| 620 | var content; |
---|
| 621 | content = '<h2 id="modalTitle">Adicionar Localidade</h2>'; |
---|
| 622 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 623 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 624 | content += "<table>"; |
---|
| 625 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 626 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
| 627 | content += "</table>"; |
---|
| 628 | content += '</form>'; |
---|
| 629 | content += '<button id="inserir" onclick="objLocal.add(); return false;">Inserir</button>'; |
---|
| 630 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 631 | |
---|
| 632 | var divLB = $('lbContent'); |
---|
| 633 | divLB.innerHTML = content; |
---|
| 634 | $('descricao').focus(); |
---|
| 635 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), true, null, |
---|
| 636 | function() |
---|
| 637 | { |
---|
| 638 | objLocal.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 639 | } |
---|
| 640 | ); |
---|
| 641 | } |
---|
| 642 | |
---|
| 643 | function loadAddEmployeeUI(organizationID, callback) |
---|
| 644 | { |
---|
| 645 | var content; |
---|
| 646 | content = '<h2 id="modalTitle">Adicionar Funcionário</h2>'; |
---|
| 647 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 648 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 649 | content += "<table>"; |
---|
| 650 | content += '<tr><td><label for="funcionario_id_desc">Funcionário</label></td><td>'; |
---|
| 651 | content += '<input type="hidden" name="funcionario_id" id="funcionario_id" value="" />'; |
---|
| 652 | content += '<input type="input" name="funcionario_id_desc" id="funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 653 | 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>'; |
---|
| 654 | content += '</td></tr>'; |
---|
| 655 | content += '<tr><td><label for="funcionario_status_id">Status</label></td><td id="comboStatus"><i>carregando</i></td></tr>'; |
---|
| 656 | content += '<tr><td><label for="funcionario_categoria_id">Categoria</label></td><td id="comboFuncionarioCategoria"><i>carregando</i></td></tr>'; |
---|
| 657 | content += '<tr><td><label for="cargo_id">Cargo</label></td><td id="comboCargo"><i>carregando</i></td></tr>'; |
---|
| 658 | content += '<tr><td><label for="nivel">Nível</label></td><td><input type="text" size="3" name="nivel" id="nivel"/></td></tr>'; |
---|
| 659 | content += '<tr><td><label for="area_id">Área</label></td><td id="comboArea"><i>carregando</i></td></tr>'; |
---|
| 660 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
| 661 | content += '<tr><td><label for="localidade_id">Localidade</label></td><td id="comboLocalidade"><i>carregando</i></td></tr>'; |
---|
| 662 | content += "</table>"; |
---|
| 663 | content += '</form>'; |
---|
| 664 | content += '<button id="inserir" onclick="objEmployee.add(); return false;">Inserir</button>'; |
---|
| 665 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 666 | |
---|
| 667 | var divLB = $('lbContent'); |
---|
| 668 | divLB.innerHTML = content; |
---|
| 669 | |
---|
| 670 | objEmployeeStatus.generateComboBox({'organizacao_id': organizationID}, $('comboStatus'), false, null, |
---|
| 671 | function() |
---|
| 672 | { |
---|
| 673 | objEmployeeCategory.generateComboBox({'organizacao_id': organizationID}, $('comboFuncionarioCategoria'), true, null, |
---|
| 674 | function() |
---|
| 675 | { |
---|
| 676 | objJobTitle.generateComboBox({'organizacao_id': organizationID}, $('comboCargo'), true, null, |
---|
| 677 | function() |
---|
| 678 | { |
---|
| 679 | objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), false, null, |
---|
| 680 | function() |
---|
| 681 | { |
---|
| 682 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), true, null, |
---|
| 683 | function() |
---|
| 684 | { |
---|
| 685 | objLocal.generateComboBox({'organizacao_id': organizationID}, $('comboLocalidade'), false, null, callback); |
---|
| 686 | } |
---|
| 687 | ) |
---|
| 688 | } |
---|
| 689 | ) |
---|
| 690 | } |
---|
| 691 | ) |
---|
| 692 | } |
---|
| 693 | ) |
---|
| 694 | } |
---|
| 695 | ); |
---|
| 696 | } |
---|
| 697 | |
---|
| 698 | function loadAddAreaUI(organizationID) |
---|
| 699 | { |
---|
| 700 | var valoresSimNao = new Array(); |
---|
| 701 | valoresSimNao['S'] = 'Sim'; |
---|
| 702 | valoresSimNao['N'] = 'Não'; |
---|
| 703 | |
---|
| 704 | var content; |
---|
| 705 | content = '<h2 id="modalTitle">Adicionar Área</h2>'; |
---|
| 706 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 707 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 708 | content += "<table>"; |
---|
| 709 | content += '<tr><td><label for="sigla">Sigla</label></td><td><input type="text" name="sigla" id="sigla" size="15" /></td></tr>'; |
---|
| 710 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 711 | content += '<tr><td><label for="titular_funcionario_id">Titular</label></td><td>'; |
---|
| 712 | content += '<input type="hidden" name="titular_funcionario_id" id="titular_funcionario_id" value="" />'; |
---|
| 713 | content += '<input type="input" name="titular_funcionario_id_desc" id="titular_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 714 | 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>'; |
---|
| 715 | 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>'; |
---|
| 716 | content += '</td></tr>'; |
---|
| 717 | content += '<tr><td><label for="substituto_funcionario_id">Substituto</label></td><td>'; |
---|
| 718 | content += '<input type="hidden" name="substituto_funcionario_id" id="substituto_funcionario_id" value="" />'; |
---|
| 719 | content += '<input type="input" name="substituto_funcionario_id_desc" id="substituto_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 720 | 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>'; |
---|
| 721 | 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>'; |
---|
| 722 | content += '</td></tr>'; |
---|
| 723 | content += '<tr><td><label for="auxiliar_funcionario_id">Auxiliar Administrativo</label></td><td>'; |
---|
| 724 | content += '<input type="hidden" name="auxiliar_funcionario_id" id="auxiliar_funcionario_id" value="" />'; |
---|
| 725 | content += '<input type="input" name="auxiliar_funcionario_id_desc" id="auxiliar_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 726 | 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>'; |
---|
| 727 | 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>'; |
---|
| 728 | content += '</td></tr>'; |
---|
| 729 | content += '<tr><td><label for="area_status_id">Status</label></td><td id="comboStatus"><i>carregando</i></td></tr>'; |
---|
| 730 | content += '<tr><td><label for="superior_area_id">Área Superior</label></td><td id="comboArea"><i>carregando</i></td></tr>'; |
---|
| 731 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
| 732 | content += '<tr><td><label for="ativa">Ativa</label></td><td>' + constructSelectBox('ativa', valoresSimNao) + '</td></tr>'; |
---|
| 733 | content += "</table>"; |
---|
| 734 | content += '</form>'; |
---|
| 735 | content += '<button id="inserir" onclick="objArea.add(); return false;">Inserir</button>'; |
---|
| 736 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 737 | |
---|
| 738 | var divLB = $('lbContent'); |
---|
| 739 | divLB.innerHTML = content; |
---|
| 740 | $('sigla').focus(); |
---|
| 741 | |
---|
| 742 | objAreaStatus.generateComboBox({'organizacao_id': organizationID}, $('comboStatus'), false, null, |
---|
| 743 | function() |
---|
| 744 | { |
---|
| 745 | objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), true, 'superior_area_id', |
---|
| 746 | function() |
---|
| 747 | { |
---|
| 748 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), false, null, |
---|
| 749 | function() |
---|
| 750 | { |
---|
| 751 | objArea.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 752 | } |
---|
| 753 | ) |
---|
| 754 | } |
---|
| 755 | ) |
---|
| 756 | } |
---|
| 757 | ); |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | function getEmployeeInfoTimer(e, employeeID, organizationID) |
---|
| 761 | { |
---|
| 762 | var div = $('employeeInfo'); |
---|
| 763 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
| 764 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
| 765 | |
---|
| 766 | if (workflowOrgchartAdminEmployeeInfoTimer != null) |
---|
| 767 | { |
---|
| 768 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
| 769 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
| 770 | } |
---|
| 771 | |
---|
| 772 | workflowOrgchartAdminEmployeeInfoTimer = setTimeout('getEmployeeInfo(' + employeeID + ', ' + organizationID + ' )', 500); |
---|
| 773 | } |
---|
| 774 | |
---|
| 775 | function getEmployeeInfo(employeeID, organizationID) |
---|
| 776 | { |
---|
| 777 | function resultGetEmployeeInfo(data) |
---|
| 778 | { |
---|
| 779 | if (workflowOrgchartAdminEmployeeInfoTimer == null) |
---|
| 780 | return; |
---|
| 781 | |
---|
| 782 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
| 783 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
| 784 | |
---|
| 785 | var content = ''; |
---|
| 786 | content += '<table><tr><td valign="top">'; |
---|
| 787 | content += '<img src="workflow/showUserPicture.php?userID=' + employeeID + '"/>'; |
---|
| 788 | content += '</td><td valign="top" style="padding-left: 12px;">'; |
---|
| 789 | for (var i = 0; i < data['info'].length; i++) |
---|
| 790 | content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>'; |
---|
| 791 | content += '</td></tr></table>'; |
---|
| 792 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
| 793 | var div = $('employeeInfo'); |
---|
| 794 | div.innerHTML = content; |
---|
| 795 | |
---|
| 796 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
| 797 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
| 798 | |
---|
| 799 | div.show(); |
---|
| 800 | } |
---|
| 801 | cExecute('$this.bo_orgchart.getEmployeeInfo', resultGetEmployeeInfo, 'funcionario_id=' + employeeID + '&organizacao_id=' + organizationID); |
---|
| 802 | } |
---|
| 803 | |
---|
| 804 | function hideEmployeeInfo() |
---|
| 805 | { |
---|
| 806 | if (workflowOrgchartAdminEmployeeInfoTimer != null) |
---|
| 807 | { |
---|
| 808 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
| 809 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
| 810 | } |
---|
| 811 | $('employeeInfo').hide(); |
---|
| 812 | } |
---|
| 813 | |
---|
| 814 | function getAreaInfoTimer(e, areaID, organizationID) |
---|
| 815 | { |
---|
| 816 | var div = $('areaInfo'); |
---|
| 817 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
| 818 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
| 819 | |
---|
| 820 | if (workflowOrgchartAdminAreaInfoTimer != null) |
---|
| 821 | { |
---|
| 822 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
| 823 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
| 824 | } |
---|
| 825 | |
---|
| 826 | workflowOrgchartAdminAreaInfoTimer = setTimeout('getAreaInfo(' + areaID + ', ' + organizationID + ' )', 500); |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | function getAreaInfo(areaID, organizationID) |
---|
| 830 | { |
---|
| 831 | function resultGetAreaInfo(data) |
---|
| 832 | { |
---|
| 833 | if (workflowOrgchartAdminAreaInfoTimer == null) |
---|
| 834 | return; |
---|
| 835 | |
---|
| 836 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
| 837 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
| 838 | |
---|
| 839 | var content = ''; |
---|
| 840 | content += '<table><tr>'; |
---|
| 841 | content += '<td valign="top" style="padding-left: 12px;">'; |
---|
| 842 | for (var i = 0; i < data['info'].length; i++) |
---|
| 843 | content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>'; |
---|
| 844 | content += '</td></tr></table>'; |
---|
| 845 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
| 846 | var div = $('areaInfo'); |
---|
| 847 | div.innerHTML = content; |
---|
| 848 | |
---|
| 849 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
| 850 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
| 851 | |
---|
| 852 | div.show(); |
---|
| 853 | } |
---|
| 854 | cExecute('$this.bo_orgchart.getAreaInfo', resultGetAreaInfo, 'area_id=' + areaID + '&organizacao_id=' + organizationID); |
---|
| 855 | } |
---|
| 856 | |
---|
| 857 | function hideAreaInfo() |
---|
| 858 | { |
---|
| 859 | if (workflowOrgchartAdminAreaInfoTimer != null) |
---|
| 860 | { |
---|
| 861 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
| 862 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
| 863 | } |
---|
| 864 | $('areaInfo').hide(); |
---|
| 865 | } |
---|