[795] | 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 | { |
---|
[2042] | 171 | //displayArea.innerHTML += '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
| 172 | elem = document.createElement('div'); |
---|
| 173 | elem.id = this.name.capitalize() + 'List'; |
---|
| 174 | elem.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; |
---|
| 175 | displayArea.appendChild(elem); |
---|
[795] | 176 | return true; |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | for (var i = 0; i < data.length; i++) |
---|
| 180 | { |
---|
| 181 | var dataHash = new Hash(); |
---|
| 182 | for (j in data[i]) |
---|
| 183 | if (typeof data[i][j] != "function") |
---|
[1245] | 184 | { |
---|
[795] | 185 | dataHash[j] = data[i][j]; |
---|
[1245] | 186 | if ( dataHash[j] == null ) |
---|
| 187 | dataHash[j] = ''; |
---|
| 188 | } |
---|
[795] | 189 | |
---|
| 190 | for (j in tableHeader) |
---|
| 191 | if (typeof tableHeader[j] != "function") |
---|
| 192 | if (j != 'actions') |
---|
| 193 | data[i][j] = '<a href="#" onclick="obj' + name + '.fillForm(' + dataHash.customInspect() + '); return false;">' + data[i][j] + '</a>'; |
---|
| 194 | |
---|
| 195 | data[i]['tr_attributes'] = new Array(); |
---|
| 196 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
| 197 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
| 198 | 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>'; |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | var tableAtributes = new Array(); |
---|
| 202 | tableAtributes['id'] = this.name + 'List'; |
---|
| 203 | tableAtributes['class'] = 'orgchartUpdateTable'; |
---|
| 204 | tableAtributes['className'] = 'orgchartUpdateTable'; |
---|
| 205 | displayArea.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
| 206 | }; |
---|
| 207 | this.list(tableResult, params); |
---|
| 208 | }, |
---|
| 209 | |
---|
| 210 | fillForm: function(dataHash) |
---|
| 211 | { |
---|
| 212 | dataHash = $H(dataHash); |
---|
| 213 | dataHash.each(function(pair) |
---|
| 214 | { |
---|
| 215 | var campo = $(pair.key); |
---|
| 216 | if (campo) |
---|
| 217 | { |
---|
| 218 | if ((campo.nodeName == "SELECT") && (pair.value == null)) |
---|
| 219 | campo.value = campo.firstChild.value; |
---|
| 220 | else |
---|
| 221 | if (pair.value != null) |
---|
| 222 | campo.value = pair.value; |
---|
| 223 | } |
---|
| 224 | else |
---|
| 225 | new Insertion.Bottom($('orgchartForm'), '<input type="hidden" name="' + pair.key + '" id="' + pair.key + '" value="' + pair.value + '" />'); |
---|
| 226 | }); |
---|
| 227 | if (!$('updateOrgchart')) |
---|
| 228 | new Insertion.Bottom($('orgchartForm'), '<input type="hidden" name="updateOrgchart" id="updateOrgchart" value="true" />'); |
---|
| 229 | var saveButton = $('inserir'); |
---|
| 230 | saveButton.innerHTML = "Salvar"; |
---|
| 231 | var name = this.name; |
---|
| 232 | saveButton.onclick = function(){ eval('obj' + name.charAt(0).capitalize() + name.substr(1) + '.update();')}; |
---|
| 233 | var titleObject = $('modalTitle'); |
---|
| 234 | var title = titleObject.innerHTML.split(' '); |
---|
| 235 | title[0] = "Atualizar"; |
---|
| 236 | titleObject.innerHTML = title.join(' '); |
---|
| 237 | $('lightbox').scrollTop = 0; |
---|
| 238 | }, |
---|
| 239 | |
---|
| 240 | generateComboBox: function(params, displayArea, includeNull, name, callback) |
---|
| 241 | { |
---|
| 242 | if (!name) |
---|
| 243 | name = this.combo['id']; |
---|
| 244 | combo = this.combo; |
---|
| 245 | var comboResult = function(data) |
---|
| 246 | { |
---|
| 247 | if (!handleError(data)) |
---|
| 248 | return; |
---|
| 249 | |
---|
| 250 | var newFormat = new Array(); |
---|
| 251 | if (includeNull) |
---|
| 252 | newFormat['NULL'] = "Nenhum"; |
---|
| 253 | for (var i = 0; i < data.length; i++) |
---|
| 254 | newFormat[data[i][combo['id']]] = data[i][combo['name']]; |
---|
| 255 | if ((newFormat.length > 0) || includeNull) |
---|
| 256 | displayArea.innerHTML = constructSelectBox(name, newFormat); |
---|
| 257 | else |
---|
| 258 | displayArea.innerHTML = '<i>nenhum registro encontado</i><input type="hidden" id="' + name + '" value=""/>'; |
---|
| 259 | if (callback) |
---|
| 260 | callback(); |
---|
| 261 | }; |
---|
| 262 | this.list(comboResult, params); |
---|
| 263 | }, |
---|
| 264 | |
---|
| 265 | ajaxAction: function(action, callback, params) |
---|
| 266 | { |
---|
| 267 | if (params == "") |
---|
| 268 | cExecute('$this.bo_orgchart.' + action + this.name.charAt(0).capitalize() + this.name.substr(1), callback); |
---|
| 269 | else |
---|
| 270 | cExecute('$this.bo_orgchart.' + action + this.name.charAt(0).capitalize() + this.name.substr(1), callback, params); |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | }; |
---|
| 274 | |
---|
| 275 | var CadastroOrganization = |
---|
| 276 | { |
---|
| 277 | name: 'organization', |
---|
| 278 | required: new Array('nome', 'descricao', 'ativa'), |
---|
| 279 | tableHeader: {'nome': 'Organização'}, |
---|
| 280 | combo: {'id': 'organizacao_id', 'name': 'nome'} |
---|
| 281 | }; |
---|
| 282 | var objOrganization = new CadastroAjax(); |
---|
| 283 | Object.extend(objOrganization, CadastroOrganization); |
---|
| 284 | |
---|
| 285 | var CadastroEmployeeStatus = |
---|
| 286 | { |
---|
| 287 | name: 'employeeStatus', |
---|
| 288 | required: new Array('descricao', 'exibir'), |
---|
| 289 | tableHeader: {'descricao': 'Status de Funcionário'}, |
---|
| 290 | combo: {'id': 'funcionario_status_id', 'name': 'descricao'} |
---|
| 291 | }; |
---|
| 292 | var objEmployeeStatus = new CadastroAjax(); |
---|
| 293 | Object.extend(objEmployeeStatus, CadastroEmployeeStatus); |
---|
| 294 | |
---|
| 295 | var CadastroEmployeeCategory = |
---|
| 296 | { |
---|
| 297 | name: 'employeeCategory', |
---|
| 298 | required: new Array('organizacao_id', 'descricao'), |
---|
| 299 | tableHeader: {'descricao': 'Nome'}, |
---|
| 300 | combo: {'id': 'funcionario_categoria_id', 'name': 'descricao'} |
---|
| 301 | }; |
---|
| 302 | var objEmployeeCategory = new CadastroAjax(); |
---|
| 303 | Object.extend(objEmployeeCategory, CadastroEmployeeCategory); |
---|
| 304 | |
---|
| 305 | var CadastroJobTitle = |
---|
| 306 | { |
---|
| 307 | name: 'jobTitle', |
---|
| 308 | required: new Array('organizacao_id', 'descricao'), |
---|
| 309 | tableHeader: {'descricao': 'Nome'}, |
---|
| 310 | combo: {'id': 'cargo_id', 'name': 'descricao'} |
---|
| 311 | }; |
---|
| 312 | var objJobTitle = new CadastroAjax(); |
---|
| 313 | Object.extend(objJobTitle, CadastroJobTitle); |
---|
| 314 | |
---|
| 315 | var CadastroAreaStatus = |
---|
| 316 | { |
---|
| 317 | name: 'areaStatus', |
---|
| 318 | required: new Array('organizacao_id', 'descricao', 'nivel'), |
---|
| 319 | tableHeader: {'descricao': 'Nome', 'nivel': 'Nível'}, |
---|
| 320 | combo: {'id': 'area_status_id', 'name': 'descricao'} |
---|
| 321 | }; |
---|
| 322 | var objAreaStatus = new CadastroAjax(); |
---|
| 323 | Object.extend(objAreaStatus, CadastroAreaStatus); |
---|
| 324 | |
---|
| 325 | var CadastroCostCenter = |
---|
| 326 | { |
---|
| 327 | name: 'costCenter', |
---|
| 328 | required: new Array('organizacao_id', 'nm_centro_custo', 'descricao', 'grupo'), |
---|
| 329 | tableHeader: {'nm_centro_custo': 'Número', 'descricao': 'Nome', 'grupo': 'Grupo'}, |
---|
| 330 | combo: {'id': 'centro_custo_id', 'name': 'descricao'} |
---|
| 331 | }; |
---|
| 332 | var objCostCenter = new CadastroAjax(); |
---|
| 333 | Object.extend(objCostCenter, CadastroCostCenter); |
---|
| 334 | |
---|
| 335 | var CadastroLocal = |
---|
| 336 | { |
---|
| 337 | name: 'local', |
---|
| 338 | required: new Array('organizacao_id', 'descricao'), |
---|
| 339 | tableHeader: {'descricao': 'Localidade'}, |
---|
| 340 | combo: {'id': 'localidade_id', 'name': 'descricao'} |
---|
| 341 | }; |
---|
| 342 | var objLocal = new CadastroAjax(); |
---|
| 343 | Object.extend(objLocal, CadastroLocal); |
---|
| 344 | |
---|
| 345 | var CadastroEmployee = |
---|
| 346 | { |
---|
| 347 | name: 'employee', |
---|
| 348 | required: new Array('funcionario_id', 'organizacao_id', 'funcionario_status_id', 'centro_custo_id', 'localidade_id', 'area_id'), |
---|
| 349 | tableHeader: {'funcionario_id': 'Funcionário'}, |
---|
| 350 | combo: {'id': 'funcionario_id', 'name': 'funcionario_id'} |
---|
| 351 | }; |
---|
| 352 | var objEmployee = new CadastroAjax(); |
---|
| 353 | Object.extend(objEmployee, CadastroEmployee); |
---|
| 354 | |
---|
| 355 | var CadastroArea = |
---|
| 356 | { |
---|
| 357 | name: 'area', |
---|
| 358 | required: new Array('organizacao_id', 'area_status_id', 'centro_custo_id', 'superior_area_id', 'sigla', 'descricao', 'ativa'), |
---|
| 359 | tableHeader: {'sigla': 'Área'}, |
---|
| 360 | combo: {'id': 'area_id', 'name': 'sigla'} |
---|
| 361 | }; |
---|
| 362 | var objArea = new CadastroAjax(); |
---|
| 363 | Object.extend(objArea, CadastroArea); |
---|
| 364 | |
---|
[1245] | 365 | var CadastroTelefone = |
---|
| 366 | { |
---|
| 367 | name: 'telephones', |
---|
| 368 | required: new Array('organizacao_id', 'descricao', 'numero'), |
---|
| 369 | tableHeader: {'descricao': 'Descrição', 'numero': 'Telefones'}, |
---|
| 370 | combo: {'id': 'telefone_id', 'name': 'descricao'} |
---|
| 371 | }; |
---|
| 372 | var objTelephones = new CadastroAjax(); |
---|
| 373 | Object.extend(objTelephones, CadastroTelefone); |
---|
| 374 | |
---|
[2042] | 375 | var CadastroSubstituto = |
---|
| 376 | { |
---|
| 377 | name: 'substitution', |
---|
| 378 | required: new Array('organizacao_id', 'area_id', 'descricao', 'titular_funcionario_id', 'substituto_funcionario_id', 'data_inicio', 'data_fim'), |
---|
| 379 | tableHeader: {'substituto_funcionario_id_desc': 'Nome', 'data_inicio': 'Data de início', 'data_fim': 'Data de término'}, |
---|
| 380 | combo: {} |
---|
| 381 | }; |
---|
| 382 | var objSubstitution = new CadastroAjax(); |
---|
| 383 | Object.extend(objSubstitution, CadastroSubstituto); |
---|
| 384 | |
---|
| 385 | |
---|
[795] | 386 | function createOrganizationLayout(organizationID, organizationDiv) |
---|
| 387 | { |
---|
| 388 | organizationDiv.innerHTML = '<div id="orgchartMenu_' + organizationID + '"></div>'; |
---|
| 389 | organizationDiv.innerHTML += '<div class="orgchartAreas" id="orgchartAreas_' + organizationID + '"></div>'; |
---|
| 390 | organizationDiv.innerHTML += '<div class="orgchartEmployees" id="orgchartEmployees_' + organizationID + '"></div>'; |
---|
| 391 | organizationDiv.innerHTML += '<div class="orgchartFooter"></div>'; |
---|
| 392 | organizationDiv.innerHTML += '<div id="employeeInfo" class="employeeInfo" style="display: none;"></div>'; |
---|
| 393 | organizationDiv.innerHTML += '<div id="areaInfo" class="employeeInfo" style="display: none;"></div>'; |
---|
| 394 | |
---|
| 395 | createOrganizationMenu(organizationID, $('orgchartMenu_' + organizationID)); |
---|
| 396 | loadOrganizationAreas(organizationID, $('orgchartAreas_' + organizationID)); |
---|
| 397 | lb_initialize(); |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | function createOrganizationMenu(organizationID, div) |
---|
| 401 | { |
---|
| 402 | var content = '<ul class="horizontalMenu">'; |
---|
[1279] | 403 | content += '<li style="margin: 5px 5px 0 5px">Atualizar : <select>' |
---|
| 404 | content += '<option></option>' |
---|
| 405 | content += '<option onclick="loadAddEmployeeStatusUI(' + organizationID + ');" class="lbOn">Status de Funcionário</option>' |
---|
| 406 | content += '<option onclick="loadAddEmployeeCategoryUI(' + organizationID + ');" class="lbOn">Categorias</option>' |
---|
| 407 | content += '<option onclick="loadAddJobTitleUI(' + organizationID + ');" class="lbOn">Cargos</option>' |
---|
| 408 | content += '<option onclick="loadAddAreaStatusUI(' + organizationID + ');" class="lbOn">Status de Área</option>' |
---|
| 409 | content += '<option onclick="loadAddCostCenterUI(' + organizationID + ');" class="lbOn">Centros de Custo</option>' |
---|
| 410 | content += '<option onclick="loadAddLocalUI(' + organizationID + ');" class="lbOn">Localidade</option>' |
---|
| 411 | content += '<option onclick="loadAddAreaUI(' + organizationID + ');" class="lbOn">Áreas</option>' |
---|
| 412 | content += '<option onclick="loadAddEmployeeUI(' + organizationID + ');" class="lbOn">Funcionários</option>' |
---|
| 413 | content += '<option onclick="loadAddTelephoneUI(' + organizationID + ');" class="lbOn">Telefones</option>' |
---|
[2042] | 414 | content += '<option onclick="loadAddSubstitutionUI(' + organizationID + ');" class="lbOn">Substituições</option>' |
---|
[1279] | 415 | content += '</select></li>'; |
---|
[795] | 416 | 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>'; |
---|
| 417 | content += '</ul>'; |
---|
| 418 | content += '<br/>'; |
---|
| 419 | content += '<br/>'; |
---|
| 420 | div.innerHTML = content; |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | function loadOrganizationAreas(organizationID, div) |
---|
| 424 | { |
---|
| 425 | var loadOrganizationAreasResult = function(data) |
---|
| 426 | { |
---|
| 427 | function recursivePrint(subdata) |
---|
| 428 | { |
---|
| 429 | for (var i = 0; i < subdata.length; i++) |
---|
| 430 | { |
---|
| 431 | 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>'; |
---|
| 432 | if (subdata[i]['children'].length > 0) |
---|
| 433 | recursivePrint(subdata[i]['children']); |
---|
| 434 | } |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | if (!handleError(data)) |
---|
| 438 | return; |
---|
| 439 | |
---|
| 440 | if (data.length == 0) |
---|
| 441 | { |
---|
| 442 | div.innerHTML = "<br/><br/><center><strong>Nenhuma área cadastrada.</strong></center><br/><br/>"; |
---|
| 443 | return; |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | div.innerHTML = "<center><strong>ÁREAS</strong></center>"; |
---|
| 447 | recursivePrint(data); |
---|
| 448 | if (refreshEmployees[organizationID]) |
---|
| 449 | refreshEmployees[organizationID](); |
---|
| 450 | }; |
---|
| 451 | |
---|
| 452 | objArea.ajaxAction('listHierarchical', loadOrganizationAreasResult, $H({'organizacao_id': organizationID}).toQueryString()); |
---|
| 453 | refreshAreas[organizationID] = function(){objArea.ajaxAction('listHierarchical', loadOrganizationAreasResult, $H({'organizacao_id': organizationID}).toQueryString());}; |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | function searchEmployee(organizationID, div) |
---|
| 457 | { |
---|
| 458 | var searchEmployeeResult = function(data) |
---|
| 459 | { |
---|
| 460 | if (!handleError(data)) |
---|
| 461 | return; |
---|
| 462 | |
---|
| 463 | div.innerHTML = ""; |
---|
| 464 | if (data.length == 0) |
---|
| 465 | { |
---|
| 466 | div.innerHTML = "<br/><br/><center><strong>Nenhum funcionário encontrado.</strong></center>"; |
---|
| 467 | return; |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | var tableHeader = new Array(); |
---|
| 471 | tableHeader['funcionario_id_desc'] = 'Funcionário'; |
---|
| 472 | tableHeader['area_sigla'] = 'Área'; |
---|
| 473 | tableHeader['uid'] = 'UID'; |
---|
| 474 | tableHeader['actions'] = 'Ações'; |
---|
| 475 | for (var i = 0; i < data.length; i++) |
---|
| 476 | { |
---|
| 477 | var dataHash = new Hash(); |
---|
| 478 | for (j in data[i]) |
---|
| 479 | if (typeof data[i][j] != "function") |
---|
| 480 | dataHash[j] = data[i][j]; |
---|
| 481 | |
---|
| 482 | data[i]['tr_attributes'] = new Array(); |
---|
| 483 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
| 484 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
| 485 | 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>' : ''); |
---|
| 486 | 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>'; |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | var tableAtributes = new Array(); |
---|
| 490 | tableAtributes['class'] = 'employeeList'; |
---|
| 491 | tableAtributes['className'] = 'employeeList'; |
---|
| 492 | div.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
| 493 | lb_initialize(); |
---|
| 494 | }; |
---|
| 495 | |
---|
| 496 | objEmployee.ajaxAction('search', searchEmployeeResult, $H({'organizacao_id': organizationID, 'search_term': $F('search_term')}).toQueryString()); |
---|
| 497 | refreshEmployees[organizationID] = function(){objEmployee.ajaxAction('search', searchEmployeeResult, $H({'organizacao_id': organizationID, 'search_term': $F('search_term')}).toQueryString());}; |
---|
| 498 | } |
---|
| 499 | |
---|
| 500 | function loadAreaEmployees(organizationID, areaID, div) |
---|
| 501 | { |
---|
| 502 | var loadAreaEmployeesResult = function(data) |
---|
| 503 | { |
---|
| 504 | if (!handleError(data)) |
---|
| 505 | return; |
---|
| 506 | |
---|
| 507 | var areaLink = $('area_' + areaID); |
---|
| 508 | if (!areaLink.hasClassName('destaque')) |
---|
| 509 | areaLink.addClassName('destaque'); |
---|
| 510 | |
---|
| 511 | div.innerHTML = ""; |
---|
| 512 | if (data.length == 0) |
---|
| 513 | { |
---|
| 514 | div.innerHTML = "<br/><br/><center><strong>Nenhum funcionário alocado nesta área.</strong></center>"; |
---|
| 515 | return; |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | var tableHeader = new Array(); |
---|
| 519 | tableHeader['funcionario_id_desc'] = 'Funcionário'; |
---|
| 520 | tableHeader['uid'] = 'UID'; |
---|
| 521 | tableHeader['actions'] = 'Ações'; |
---|
[2063] | 522 | |
---|
| 523 | var complement; |
---|
[795] | 524 | for (var i = 0; i < data.length; i++) |
---|
| 525 | { |
---|
| 526 | var dataHash = new Hash(); |
---|
| 527 | for (j in data[i]) |
---|
| 528 | if (typeof data[i][j] != "function") |
---|
| 529 | dataHash[j] = data[i][j]; |
---|
| 530 | |
---|
[2063] | 531 | // are you a chief ('titular' or 'substituto')? |
---|
| 532 | complement = ''; |
---|
| 533 | if (data[i]['chief']) |
---|
| 534 | complement = ' <strong>(' + ((data[i]['chief'] == 1) ? 'Titular' : 'Substituto') + ')</strong>'; |
---|
| 535 | |
---|
[795] | 536 | data[i]['tr_attributes'] = new Array(); |
---|
| 537 | data[i]['tr_attributes']['class'] = "linha" + i%2; |
---|
| 538 | data[i]['tr_attributes']['className'] = "linha" + i%2; |
---|
[2063] | 539 | 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'] + ' ' + complement + '</a>' + (data[i]['removed'] ? ' <font color="red">(excluído)</font>' : ''); |
---|
[795] | 540 | 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>'; |
---|
| 541 | window.scrollTo(0,0); |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | var tableAtributes = new Array(); |
---|
| 545 | tableAtributes['class'] = 'employeeList'; |
---|
| 546 | tableAtributes['className'] = 'employeeList'; |
---|
| 547 | div.appendChild(constructTable(tableHeader, data, tableAtributes)); |
---|
| 548 | |
---|
| 549 | lb_initialize(); |
---|
| 550 | }; |
---|
| 551 | |
---|
| 552 | objEmployee.ajaxAction('listArea', loadAreaEmployeesResult, $H({'area_id': areaID, 'organizacao_id': organizationID}).toQueryString()); |
---|
| 553 | refreshEmployees[organizationID] = function(){objEmployee.ajaxAction('listArea', loadAreaEmployeesResult, $H({'area_id': areaID, 'organizacao_id': organizationID}).toQueryString());}; |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | function loadAddEmployeeStatusUI(organizationID) |
---|
| 557 | { |
---|
| 558 | var valoresSimNao = new Array(); |
---|
| 559 | valoresSimNao['S'] = 'Sim'; |
---|
| 560 | valoresSimNao['N'] = 'Não'; |
---|
| 561 | |
---|
| 562 | var content; |
---|
| 563 | content = '<h2 id="modalTitle">Adicionar Status de Funcionário</h2>'; |
---|
| 564 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 565 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 566 | content += "<table>"; |
---|
| 567 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 568 | content += '<tr><td><label for="exibir">Exibir para o usuário</label></td>' + constructSelectBox('exibir', valoresSimNao) + '</td></tr>'; |
---|
| 569 | content += "</table>"; |
---|
| 570 | content += '</form>'; |
---|
| 571 | content += '<button id="inserir" onclick="objEmployeeStatus.add(); return false;">Inserir</button>'; |
---|
| 572 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 573 | |
---|
| 574 | var divLB = $('lbContent'); |
---|
| 575 | divLB.innerHTML = content; |
---|
| 576 | $('descricao').focus(); |
---|
| 577 | objEmployeeStatus.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | function loadAddEmployeeCategoryUI(organizationID) |
---|
| 581 | { |
---|
| 582 | var content; |
---|
| 583 | content = '<h2 id="modalTitle">Adicionar Categoria</h2>'; |
---|
| 584 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 585 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 586 | content += '<table>'; |
---|
| 587 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 588 | content += "</table>"; |
---|
| 589 | content += '</form>'; |
---|
| 590 | content += '<button id="inserir" onclick="objEmployeeCategory.add(); return false;">Inserir</button>'; |
---|
| 591 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 592 | |
---|
| 593 | var divLB = $('lbContent'); |
---|
| 594 | divLB.innerHTML = content; |
---|
| 595 | $('descricao').focus(); |
---|
| 596 | objEmployeeCategory.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 597 | } |
---|
| 598 | |
---|
| 599 | function loadAddJobTitleUI(organizationID) |
---|
| 600 | { |
---|
| 601 | var content; |
---|
| 602 | content = '<h2 id="modalTitle">Adicionar Cargos</h2>'; |
---|
| 603 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 604 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 605 | content += '<table>'; |
---|
| 606 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 607 | content += "</table>"; |
---|
| 608 | content += '</form>'; |
---|
| 609 | content += '<button id="inserir" onclick="objJobTitle.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 | $('descricao').focus(); |
---|
| 615 | objJobTitle.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 616 | } |
---|
| 617 | |
---|
| 618 | function loadAddAreaStatusUI(organizationID) |
---|
| 619 | { |
---|
| 620 | var content; |
---|
| 621 | content = '<h2 id="modalTitle">Adicionar Status de Área</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="nivel">Nível</label></td><td><input type="text" name="nivel" id="nivel" size="3" /></td></tr>'; |
---|
| 627 | content += "</table>"; |
---|
| 628 | content += '</form>'; |
---|
| 629 | content += '<button id="inserir" onclick="objAreaStatus.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 | objAreaStatus.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 636 | } |
---|
| 637 | |
---|
| 638 | function loadAddCostCenterUI(organizationID) |
---|
| 639 | { |
---|
| 640 | var content; |
---|
| 641 | content = '<h2 id="modalTitle">Adicionar Centro de Custo</h2>'; |
---|
| 642 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 643 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 644 | content += "<table>"; |
---|
| 645 | 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>'; |
---|
| 646 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 647 | content += '<tr><td><label for="grupo">Grupo</label></td><td><input type="text" name="grupo" id="grupo" size="10" /></td></tr>'; |
---|
| 648 | content += "</table>"; |
---|
| 649 | content += '</form>'; |
---|
| 650 | content += '<button id="inserir" onclick="objCostCenter.add(); return false;">Inserir</button>'; |
---|
| 651 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 652 | |
---|
| 653 | var divLB = $('lbContent'); |
---|
| 654 | divLB.innerHTML = content; |
---|
| 655 | $('nm_centro_custo').focus(); |
---|
| 656 | objCostCenter.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 657 | } |
---|
| 658 | |
---|
| 659 | function loadAddLocalUI(organizationID) |
---|
| 660 | { |
---|
| 661 | var content; |
---|
| 662 | content = '<h2 id="modalTitle">Adicionar Localidade</h2>'; |
---|
| 663 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 664 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 665 | content += "<table>"; |
---|
| 666 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
[1245] | 667 | |
---|
| 668 | content += '<tr><td><label for="empresa">Empresa</label></td><td><input type="text" name="empresa" id="empresa" size="80" /></td></tr>'; |
---|
| 669 | content += '<tr><td><label for="endereco">Endereço</label></td><td><input type="text" name="endereco" id="endereco" size="80" /></td></tr>'; |
---|
| 670 | content += '<tr><td><label for="complemento">Complemento</label></td><td><input type="text" name="complemento" id="complemento" size="50" /></td></tr>'; |
---|
| 671 | content += '<tr><td><label for="cep">Cep</label></td><td><input type="text" name="cep" id="cep" size="10" /></td></tr>'; |
---|
| 672 | content += '<tr><td><label for="bairro">Bairro</label></td><td><input type="text" name="bairro" id="bairro" size="30" /></td></tr>'; |
---|
| 673 | content += '<tr><td><label for="cidade">Cidade</label></td><td><input type="text" name="cidade" id="cidade" size="50" /></td></tr>'; |
---|
| 674 | content += '<tr><td><label for="uf">UF</label></td><td><input type="text" name="uf" id="uf" size="2" maxlength="2" /></td></tr>'; |
---|
| 675 | |
---|
[795] | 676 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
| 677 | content += "</table>"; |
---|
| 678 | content += '</form>'; |
---|
| 679 | content += '<button id="inserir" onclick="objLocal.add(); return false;">Inserir</button>'; |
---|
| 680 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 681 | |
---|
| 682 | var divLB = $('lbContent'); |
---|
| 683 | divLB.innerHTML = content; |
---|
| 684 | $('descricao').focus(); |
---|
| 685 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), true, null, |
---|
| 686 | function() |
---|
| 687 | { |
---|
| 688 | objLocal.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 689 | } |
---|
| 690 | ); |
---|
| 691 | } |
---|
| 692 | |
---|
| 693 | function loadAddEmployeeUI(organizationID, callback) |
---|
| 694 | { |
---|
| 695 | var content; |
---|
| 696 | content = '<h2 id="modalTitle">Adicionar Funcionário</h2>'; |
---|
| 697 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 698 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 699 | content += "<table>"; |
---|
| 700 | content += '<tr><td><label for="funcionario_id_desc">Funcionário</label></td><td>'; |
---|
| 701 | content += '<input type="hidden" name="funcionario_id" id="funcionario_id" value="" />'; |
---|
| 702 | content += '<input type="input" name="funcionario_id_desc" id="funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 703 | 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>'; |
---|
| 704 | content += '</td></tr>'; |
---|
| 705 | content += '<tr><td><label for="funcionario_status_id">Status</label></td><td id="comboStatus"><i>carregando</i></td></tr>'; |
---|
| 706 | content += '<tr><td><label for="funcionario_categoria_id">Categoria</label></td><td id="comboFuncionarioCategoria"><i>carregando</i></td></tr>'; |
---|
| 707 | content += '<tr><td><label for="cargo_id">Cargo</label></td><td id="comboCargo"><i>carregando</i></td></tr>'; |
---|
[1245] | 708 | |
---|
| 709 | content += '<tr><td><label for="titulo">Título</label></td><td><input type="text" size="30" name="titulo" id="titulo"/></td></tr>'; |
---|
| 710 | |
---|
[795] | 711 | content += '<tr><td><label for="nivel">Nível</label></td><td><input type="text" size="3" name="nivel" id="nivel"/></td></tr>'; |
---|
| 712 | content += '<tr><td><label for="area_id">Área</label></td><td id="comboArea"><i>carregando</i></td></tr>'; |
---|
| 713 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
| 714 | content += '<tr><td><label for="localidade_id">Localidade</label></td><td id="comboLocalidade"><i>carregando</i></td></tr>'; |
---|
| 715 | content += "</table>"; |
---|
| 716 | content += '</form>'; |
---|
| 717 | content += '<button id="inserir" onclick="objEmployee.add(); return false;">Inserir</button>'; |
---|
| 718 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 719 | |
---|
| 720 | var divLB = $('lbContent'); |
---|
| 721 | divLB.innerHTML = content; |
---|
| 722 | |
---|
| 723 | objEmployeeStatus.generateComboBox({'organizacao_id': organizationID}, $('comboStatus'), false, null, |
---|
| 724 | function() |
---|
| 725 | { |
---|
| 726 | objEmployeeCategory.generateComboBox({'organizacao_id': organizationID}, $('comboFuncionarioCategoria'), true, null, |
---|
| 727 | function() |
---|
| 728 | { |
---|
| 729 | objJobTitle.generateComboBox({'organizacao_id': organizationID}, $('comboCargo'), true, null, |
---|
| 730 | function() |
---|
| 731 | { |
---|
| 732 | objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), false, null, |
---|
| 733 | function() |
---|
| 734 | { |
---|
| 735 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), true, null, |
---|
| 736 | function() |
---|
| 737 | { |
---|
| 738 | objLocal.generateComboBox({'organizacao_id': organizationID}, $('comboLocalidade'), false, null, callback); |
---|
| 739 | } |
---|
| 740 | ) |
---|
| 741 | } |
---|
| 742 | ) |
---|
| 743 | } |
---|
| 744 | ) |
---|
| 745 | } |
---|
| 746 | ) |
---|
| 747 | } |
---|
| 748 | ); |
---|
| 749 | } |
---|
| 750 | |
---|
| 751 | function loadAddAreaUI(organizationID) |
---|
| 752 | { |
---|
| 753 | var valoresSimNao = new Array(); |
---|
| 754 | valoresSimNao['S'] = 'Sim'; |
---|
| 755 | valoresSimNao['N'] = 'Não'; |
---|
| 756 | |
---|
| 757 | var content; |
---|
| 758 | content = '<h2 id="modalTitle">Adicionar Área</h2>'; |
---|
| 759 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 760 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 761 | content += "<table>"; |
---|
| 762 | content += '<tr><td><label for="sigla">Sigla</label></td><td><input type="text" name="sigla" id="sigla" size="15" /></td></tr>'; |
---|
| 763 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" size="30" /></td></tr>'; |
---|
| 764 | content += '<tr><td><label for="titular_funcionario_id">Titular</label></td><td>'; |
---|
| 765 | content += '<input type="hidden" name="titular_funcionario_id" id="titular_funcionario_id" value="" />'; |
---|
| 766 | content += '<input type="input" name="titular_funcionario_id_desc" id="titular_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 767 | 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>'; |
---|
| 768 | 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>'; |
---|
| 769 | content += '</td></tr>'; |
---|
| 770 | content += '<tr><td><label for="auxiliar_funcionario_id">Auxiliar Administrativo</label></td><td>'; |
---|
| 771 | content += '<input type="hidden" name="auxiliar_funcionario_id" id="auxiliar_funcionario_id" value="" />'; |
---|
| 772 | content += '<input type="input" name="auxiliar_funcionario_id_desc" id="auxiliar_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 773 | 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>'; |
---|
| 774 | 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>'; |
---|
| 775 | content += '</td></tr>'; |
---|
| 776 | content += '<tr><td><label for="area_status_id">Status</label></td><td id="comboStatus"><i>carregando</i></td></tr>'; |
---|
| 777 | content += '<tr><td><label for="superior_area_id">Área Superior</label></td><td id="comboArea"><i>carregando</i></td></tr>'; |
---|
| 778 | content += '<tr><td><label for="centro_custo_id">Centro de Custo</label></td><td id="comboCentroCusto"><i>carregando</i></td></tr>'; |
---|
| 779 | content += '<tr><td><label for="ativa">Ativa</label></td><td>' + constructSelectBox('ativa', valoresSimNao) + '</td></tr>'; |
---|
| 780 | content += "</table>"; |
---|
| 781 | content += '</form>'; |
---|
| 782 | content += '<button id="inserir" onclick="objArea.add(); return false;">Inserir</button>'; |
---|
| 783 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 784 | |
---|
| 785 | var divLB = $('lbContent'); |
---|
| 786 | divLB.innerHTML = content; |
---|
| 787 | $('sigla').focus(); |
---|
| 788 | |
---|
| 789 | objAreaStatus.generateComboBox({'organizacao_id': organizationID}, $('comboStatus'), false, null, |
---|
| 790 | function() |
---|
| 791 | { |
---|
| 792 | objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), true, 'superior_area_id', |
---|
| 793 | function() |
---|
| 794 | { |
---|
| 795 | objCostCenter.generateComboBox({'organizacao_id': organizationID}, $('comboCentroCusto'), false, null, |
---|
| 796 | function() |
---|
| 797 | { |
---|
| 798 | objArea.generateUpdateTable({'organizacao_id': organizationID}, divLB); |
---|
| 799 | } |
---|
| 800 | ) |
---|
| 801 | } |
---|
| 802 | ) |
---|
| 803 | } |
---|
| 804 | ); |
---|
| 805 | } |
---|
| 806 | |
---|
[1245] | 807 | function loadAddTelephoneUI(organizationID) |
---|
| 808 | { |
---|
| 809 | var content; |
---|
| 810 | content = '<h2 id="modalTitle">Adicionar Telefones da Organização</h2>'; |
---|
| 811 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 812 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 813 | content += '<table>'; |
---|
| 814 | content += '<tr><td><label for="descricao">Descrição</label></td><td><input type="text" name="descricao" id="descricao" size="50" /></td></tr>'; |
---|
| 815 | content += '<tr><td><label for="nivel">Telefones</label></td><td><input type="text" name="numero" id="numero" size="50" /></td></tr>'; |
---|
| 816 | content += "</table>"; |
---|
| 817 | content += '</form>'; |
---|
| 818 | content += '<button id="inserir" onclick="objTelephones.add(); return false;">Inserir</button>'; |
---|
| 819 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 820 | |
---|
| 821 | var divLB = $( 'lbContent' ); |
---|
| 822 | divLB.innerHTML = content; |
---|
| 823 | $( 'descricao' ).focus( ); |
---|
| 824 | objTelephones.generateUpdateTable( { 'organizacao_id' : organizationID }, divLB ); |
---|
| 825 | } |
---|
| 826 | |
---|
[2042] | 827 | |
---|
| 828 | function loadAddSubstitutionUI(organizationID) |
---|
| 829 | { |
---|
| 830 | var area_id = 'combo_area'; |
---|
| 831 | var content; |
---|
| 832 | |
---|
| 833 | content = '<h2 id="modalTitle">Adicionar Substituição</h2>'; |
---|
| 834 | content += '<form name="orgchartForm" id="orgchartForm">'; |
---|
| 835 | content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; |
---|
| 836 | content += "<table>"; |
---|
| 837 | content += '<tr><td><label for="area_id">Sigla</label>'; |
---|
| 838 | content += '<input type="hidden" name="area_id" id="area_id" value="" />'; |
---|
| 839 | content += '</td><td id="comboArea"><i>carregando</i></td></tr>'; |
---|
| 840 | content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" readonly="true" size="40" /></td></tr>'; |
---|
| 841 | content += '<tr><td><label for="titular_funcionario_id">Titular</label></td><td>'; |
---|
| 842 | content += '<input type="hidden" name="titular_funcionario_id" id="titular_funcionario_id" value="" readonly="true" />'; |
---|
| 843 | content += '<input type="input" name="titular_funcionario_id_desc" id="titular_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 844 | content += '</td></tr>'; |
---|
| 845 | content += '<tr><td><label for="substituto_funcionario_id">Substituto</label></td><td>'; |
---|
| 846 | content += '<input type="hidden" name="substituto_funcionario_id" id="substituto_funcionario_id" value="" />'; |
---|
| 847 | content += '<input type="input" name="substituto_funcionario_id_desc" id="substituto_funcionario_id_desc" value="" readonly="true" size="40" />'; |
---|
| 848 | 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>'; |
---|
| 849 | 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>'; |
---|
| 850 | content += '</td></tr>'; |
---|
| 851 | content += '<tr><td><label for="data_inicio">Data de início</label></td><td><input type="text" name="data_inicio" id="data_inicio" size="15" onkeypress="return formatDateField(event, this);" /></td></tr>'; |
---|
| 852 | content += '<tr><td><label for="data_fim">Data de término</label></td><td><input type="text" name="data_fim" id="data_fim" size="15" onkeypress="return formatDateField(event, this);"/></td></tr>'; |
---|
| 853 | content += "</table>"; |
---|
| 854 | content += '</form>'; |
---|
| 855 | content += '<button id="inserir" onclick="objSubstitution.add(); return false;">Inserir</button>'; |
---|
| 856 | content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; |
---|
| 857 | |
---|
| 858 | var divLB = $('lbContent'); |
---|
| 859 | divLB.innerHTML = content; |
---|
| 860 | |
---|
| 861 | // function that must be called after loading areas on the combobox |
---|
| 862 | var areas_callback = function () { |
---|
| 863 | |
---|
| 864 | // every change on the combo box must query for area information |
---|
| 865 | $(area_id).onchange = function () { |
---|
| 866 | if ($('SubstitutionList')) |
---|
| 867 | $('SubstitutionList').remove(); |
---|
| 868 | |
---|
| 869 | var info_callback = function (data) { |
---|
| 870 | |
---|
| 871 | // just to be sure |
---|
| 872 | if (!data[0]) { |
---|
| 873 | alert("Não foi possível encontrar os dados."); |
---|
| 874 | } |
---|
| 875 | |
---|
| 876 | // we received an empty response. Let's reset the form. |
---|
| 877 | if ((data[0]['area_id'] == '') || (data[0]['area_id'] == null)) { |
---|
| 878 | alert('RESET'); |
---|
| 879 | $('area_id').value = ''; |
---|
| 880 | $('descricao').value = ''; |
---|
| 881 | $('titular_funcionario_id').value = ''; |
---|
| 882 | $('titular_funcionario_id_desc').value = ''; |
---|
| 883 | } |
---|
| 884 | // fill the form |
---|
| 885 | else { |
---|
| 886 | $('area_id').value = data[0]['area_id']; |
---|
| 887 | $('descricao').value = data[0]['descricao']; |
---|
| 888 | $('titular_funcionario_id').value = data[0]['titular_funcionario_id']; |
---|
| 889 | $('titular_funcionario_id_desc').value = data[0]['titular_funcionario_id_desc']; |
---|
| 890 | } |
---|
| 891 | |
---|
| 892 | // get the list of substitutions |
---|
[2056] | 893 | objSubstitution.generateUpdateTable({'organizacao_id': organizationID, 'area_id': $(area_id).value}, divLB); |
---|
[2042] | 894 | } |
---|
| 895 | objArea.list(info_callback, {'organizacao_id': organizationID, 'area_id': $(area_id).value}); |
---|
| 896 | |
---|
| 897 | } |
---|
| 898 | } |
---|
| 899 | objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), true, area_id, areas_callback); |
---|
| 900 | } |
---|
| 901 | |
---|
[795] | 902 | function getEmployeeInfoTimer(e, employeeID, organizationID) |
---|
| 903 | { |
---|
| 904 | var div = $('employeeInfo'); |
---|
| 905 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
| 906 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
| 907 | |
---|
| 908 | if (workflowOrgchartAdminEmployeeInfoTimer != null) |
---|
| 909 | { |
---|
| 910 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
| 911 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
| 912 | } |
---|
| 913 | |
---|
| 914 | workflowOrgchartAdminEmployeeInfoTimer = setTimeout('getEmployeeInfo(' + employeeID + ', ' + organizationID + ' )', 500); |
---|
| 915 | } |
---|
| 916 | |
---|
| 917 | function getEmployeeInfo(employeeID, organizationID) |
---|
| 918 | { |
---|
| 919 | function resultGetEmployeeInfo(data) |
---|
| 920 | { |
---|
| 921 | if (workflowOrgchartAdminEmployeeInfoTimer == null) |
---|
| 922 | return; |
---|
| 923 | |
---|
| 924 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
| 925 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
| 926 | |
---|
| 927 | var content = ''; |
---|
| 928 | content += '<table><tr><td valign="top">'; |
---|
| 929 | content += '<img src="workflow/showUserPicture.php?userID=' + employeeID + '"/>'; |
---|
| 930 | content += '</td><td valign="top" style="padding-left: 12px;">'; |
---|
| 931 | for (var i = 0; i < data['info'].length; i++) |
---|
| 932 | content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>'; |
---|
| 933 | content += '</td></tr></table>'; |
---|
| 934 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
| 935 | var div = $('employeeInfo'); |
---|
| 936 | div.innerHTML = content; |
---|
| 937 | |
---|
| 938 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
| 939 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
| 940 | |
---|
| 941 | div.show(); |
---|
| 942 | } |
---|
| 943 | cExecute('$this.bo_orgchart.getEmployeeInfo', resultGetEmployeeInfo, 'funcionario_id=' + employeeID + '&organizacao_id=' + organizationID); |
---|
| 944 | } |
---|
| 945 | |
---|
| 946 | function hideEmployeeInfo() |
---|
| 947 | { |
---|
| 948 | if (workflowOrgchartAdminEmployeeInfoTimer != null) |
---|
| 949 | { |
---|
| 950 | workflowOrgchartAdminEmployeeInfoTimer = clearTimeout(workflowOrgchartAdminEmployeeInfoTimer); |
---|
| 951 | workflowOrgchartAdminEmployeeInfoTimer = null; |
---|
| 952 | } |
---|
| 953 | $('employeeInfo').hide(); |
---|
| 954 | } |
---|
| 955 | |
---|
| 956 | function getAreaInfoTimer(e, areaID, organizationID) |
---|
| 957 | { |
---|
| 958 | var div = $('areaInfo'); |
---|
| 959 | div.style.left = (Event.pointerX(e) + 20) + 'px'; |
---|
| 960 | div.style.top = (Event.pointerY(e) + 14) + 'px'; |
---|
| 961 | |
---|
| 962 | if (workflowOrgchartAdminAreaInfoTimer != null) |
---|
| 963 | { |
---|
| 964 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
| 965 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
| 966 | } |
---|
| 967 | |
---|
| 968 | workflowOrgchartAdminAreaInfoTimer = setTimeout('getAreaInfo(' + areaID + ', ' + organizationID + ' )', 500); |
---|
| 969 | } |
---|
| 970 | |
---|
| 971 | function getAreaInfo(areaID, organizationID) |
---|
| 972 | { |
---|
| 973 | function resultGetAreaInfo(data) |
---|
| 974 | { |
---|
| 975 | if (workflowOrgchartAdminAreaInfoTimer == null) |
---|
| 976 | return; |
---|
| 977 | |
---|
| 978 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
| 979 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
| 980 | |
---|
| 981 | var content = ''; |
---|
| 982 | content += '<table><tr>'; |
---|
| 983 | content += '<td valign="top" style="padding-left: 12px;">'; |
---|
| 984 | for (var i = 0; i < data['info'].length; i++) |
---|
| 985 | content += '<strong>' + data['info'][i]['name'] + '</strong>: ' + data['info'][i]['value'] + '<br/>'; |
---|
| 986 | content += '</td></tr></table>'; |
---|
| 987 | var pageYLimit = document.body.scrollTop + document.body.clientHeight; |
---|
| 988 | var div = $('areaInfo'); |
---|
| 989 | div.innerHTML = content; |
---|
| 990 | |
---|
| 991 | if ((parseInt(div.style.top.replace(/px/g, '')) + div.getHeight()) > pageYLimit) |
---|
| 992 | div.style.top = (parseInt(div.style.top.replace(/px/g, '')) - (div.getHeight())) + 'px'; |
---|
| 993 | |
---|
| 994 | div.show(); |
---|
| 995 | } |
---|
| 996 | cExecute('$this.bo_orgchart.getAreaInfo', resultGetAreaInfo, 'area_id=' + areaID + '&organizacao_id=' + organizationID); |
---|
| 997 | } |
---|
| 998 | |
---|
| 999 | function hideAreaInfo() |
---|
| 1000 | { |
---|
| 1001 | if (workflowOrgchartAdminAreaInfoTimer != null) |
---|
| 1002 | { |
---|
| 1003 | workflowOrgchartAdminAreaInfoTimer = clearTimeout(workflowOrgchartAdminAreaInfoTimer); |
---|
| 1004 | workflowOrgchartAdminAreaInfoTimer = null; |
---|
| 1005 | } |
---|
| 1006 | $('areaInfo').hide(); |
---|
| 1007 | } |
---|