var workflowMonitorUserMapping; var workflowMonitorActivityMapping; var sortColumn = 2; var order = 'A'; var workflowMonitorInstancesParams = null; var completedSortColumn = 1; var completedOrder = 'A'; var workflowMonitorCurrentList = ''; /* retorno do Ajax para listagem de instâncias */ function instanceList(data) { if (handleError(data)) { /* salva algumas informações vindas da chamada Ajax */ workflowMonitorInstancesParams = data['params']; workflowMonitorUserMapping = data['userMapping']; workflowMonitorActivityMapping = data['activityMapping']; if (!workflowMonitorInstancesParams['filters']) { $('divInstance').innerHTML = ''; } else { var objectRemovalList = new Array(); objectRemovalList[0] = $('monitorMessage'); objectRemovalList[1] = $('instancesTable'); objectRemovalList[2] = $('pagingTop'); objectRemovalList[3] = $('pagingBottom'); for (var i = 0; i < objectRemovalList.length; i++) if (objectRemovalList[i]) objectRemovalList[i].remove(); } if (data['data'].length == 0) { var divInstance = $('divInstance'); if (workflowMonitorInstancesParams['filters']) { new Insertion.Bottom(divInstance, '

Nenhuma instância satisfaz o critério de filtragem utilizado

'); $('instanceCount').innerHTML = '0'; } else divInstance.innerHTML = '

Este processo não possui instâncias ativas

'; } else drawInstancesList(data); } } /* retorno do Ajax para listagem de usuários */ function userList(data) { if (handleError(data)) { if (data['data'].length == 0) { var parag = document.createElement("P"); parag.className = "text_dsp"; parag.innerHTML = "Não existem usuários"; divInstance.appendChild(parag); } else { var aid = data['params']['aid']; var pid = data['params']['pid']; var uid = data['params']['uid']; var iid = data['params']['iid']; var message = document.getElementById("nu_" + iid); var td = message.parentNode; td.innerHTML = constructSelectBox("nu_" + iid, data['data'], uid); td.innerHTML += ""; } } } /* retorno do Ajax para listagem de atividades */ function activityList(data) { if (handleError(data)) { if (data['data'].length == 0) { var parag = document.createElement("P"); parag.className = "text_dsp"; parag.innerHTML = "Não existem atividades"; divInstance.appendChild(parag); } else { var aid = data['params']['aid']; var pid = data['params']['pid']; var iid = data['params']['iid']; var message = document.getElementById("na_" + iid); var td = message.parentNode; td.innerHTML = constructSelectBox("na_" + iid, data['data'], aid); td.innerHTML += ""; } } } /**** LISTA DE INSTÂNCIAS DE UM PROCESSO ****/ function callInstanceList(pid, srt, p_page, p_filters) { workflowMonitorCurrentList = 'active'; var params = 'pid=' + pid; if (srt == null) srt = sortColumn; params += '&srt=' + srt; if ((srt == sortColumn) && (p_page == null)) order = (order == 'A') ? 'D' : 'A'; params += '&ord=' + ((order == 'A') ? '__ASC' : '__DESC'); if (p_page) params += '&p_page=' + p_page; sortColumn = srt; if (p_filters) params += '&filters=' + p_filters; cExecute('$this.bo_monitors.listInstances', instanceList, params); } function resultCompletedInstanceList(data) { if (handleError(data)) { /* salva algumas informações vindas da chamada Ajax */ workflowMonitorInstancesParams = data['params']; workflowMonitorUserMapping = data['userMapping']; if (!workflowMonitorInstancesParams['filters']) { $('divInstance').innerHTML = ''; } else { var objectRemovalList = new Array(); objectRemovalList[0] = $('monitorMessage'); objectRemovalList[1] = $('instancesTable'); objectRemovalList[2] = $('pagingTop'); objectRemovalList[3] = $('pagingBottom'); for (var i = 0; i < objectRemovalList.length; i++) if (objectRemovalList[i]) objectRemovalList[i].remove(); } if (data['data'].length == 0) { var divInstance = $('divInstance'); if (workflowMonitorInstancesParams['filters']) { $('instanceCount').innerHTML = '0'; new Insertion.Bottom(divInstance, '

Nenhuma instância satisfaz o critério de filtragem utilizado

'); } else divInstance.innerHTML = '

Este processo não possui instâncias finalizadas

'; } else drawCompletedInstancesList(data); } } function drawCompletedInstancesList(data) { var instances = data['data']; var pid = data['params']['pid']; var pagingData = data['pagingData']; var divInstance = $('divInstance'); var menuCreated = false; var content = ''; if (divInstance.innerHTML == '') { menuCreated = true; content += '

Instâncias Finalizadas

'; content += '
'; content += ''; content += '   Total de Instâncias: ' + data['instanceCount'] + ''; content += '


'; content += '
'; } else { $('instanceCount').innerHTML = data['instanceCount']; } var pagingDataCount = pagingData.length; var pagingLinks = ''; for (var i = 0; i < pagingDataCount; i++) { if (pagingData[i].do_link == true) pagingLinks += '' + pagingData[i].name + ' '; else pagingLinks += '' + pagingData[i].name + ' '; } content += '
' + pagingLinks + '
'; content += ''; content += ''; /*** gera a lista de instâncias ****/ var instanceCount = instances.length; var ownerName = ''; for (var i = 0; i < instanceCount; i++) { if (workflowMonitorUserMapping[instances[i]['wf_owner']]) ownerName = workflowMonitorUserMapping[instances[i]['wf_owner']]; else ownerName = 'ID: ' + instances[i]['wf_owner']; if (!instances[i]['wf_instance_name']) instances[i]['wf_instance_name'] = ''; content += ''; /* id da instância */ content += ''; /* identificador da instância */ content += ''; /* proprietário da instância */ content += ''; /* prioridade da instância */ content += ''; /* data início da instância */ content += ''; /* data fim da instância */ content += ''; /* status da instância */ content += ''; /* ações da instância */ content += ''; content += ''; } content += '
IDIdentificadorProprietárioPri.Data InícioData FimStatusAções
' + instances[i]['wf_instance_id'] + '' + instances[i]['wf_instance_name'] + '' + ownerName + '' + instances[i]['wf_priority'] + '' + instances[i]['wf_started'] + '' + instances[i]['wf_ended'] + '' + statusQuickTranslation[instances[i]['wf_status']] + 'visualizar
'; content += '
' + pagingLinks + '
'; new Insertion.Bottom(divInstance, content); if (menuCreated) lb_initialize(); } function callCompletedInstanceList(pid, sort, p_page, p_filters) { workflowMonitorCurrentList = 'completed'; var params = 'pid=' + pid; if (sort == null) sort = 1; params += '&sort=' + sort; if ((sort == completedSortColumn) && (p_page == null)) completedOrder = (completedOrder == 'A') ? 'D' : 'A'; params += '&ord=' + ((completedOrder == 'A') ? '__ASC' : '__DESC'); if (p_page) params += '&p_page=' + p_page; completedSortColumn = sort; if (p_filters) params += '&filters=' + p_filters; cExecute('$this.bo_monitors.listCompletedInstances', resultCompletedInstanceList, params); } function drawInstancesList(data) { var instances = data['data']; var pid = data['params']['pid']; var pagingData = data['pagingData']; var divInstance = $('divInstance'); var menuCreated = false; var content = ''; if (divInstance.innerHTML == '') { menuCreated = true; content += '

Instâncias Ativas

'; content += '
'; content += ''; content += '   Total de Instâncias: ' + data['instanceCount'] + ''; content += '


'; content += '
'; } else { $('instanceCount').innerHTML = data['instanceCount']; } var pagingDataCount = pagingData.length; var pagingLinks = ''; for (var i = 0; i < pagingDataCount; i++) { if (pagingData[i].do_link == true) pagingLinks += '' + pagingData[i].name + ' '; else pagingLinks += '' + pagingData[i].name + ' '; } content += '
' + pagingLinks + '
'; content += ''; content += ''; /*** gera a lista de instâncias ****/ var instanceCount = instances.length; for (var i = 0; i < instanceCount; i++) { content += ''; /* id da instância */ content += ''; /* atividade da instância */ content += ''; /* nome da instância */ if (!instances[i]['wf_instance_name']) instances[i]['wf_instance_name'] = "             "; content += ''; /* prioridade da instância */ content += ''; /* usuário da instância */ if (workflowMonitorUserMapping[instances[i]['wf_user']]) userName = workflowMonitorUserMapping[instances[i]['wf_user']]; else userName = 'ID: ' + instances[i]['wf_user']; content += ''; /* staus da instância */ content += ''; instances[i]['wf_actions'] = ''; /* ações da instância */ if ((permissions[pid]['bits'][IP_VIEW_PROPERTIES]) || (permissions[pid]['bits'][IP_CHANGE_PROPERTIES])) instances[i]['wf_actions'] += 'propriedades '; instances[i]['wf_actions'] += 'visualizar'; content += ''; content += ''; } content += '
IDAtividadeIdentificadorPri.UsuárioStatusAções
' + instances[i]['wf_instance_id'] + ''; if (permissions[pid]['bits'][IP_CHANGE_ACTIVITY]) content += "" + workflowMonitorActivityMapping[instances[i]['wf_activity_id']] + ""; else content += workflowMonitorActivityMapping[instances[i]['wf_activity_id']]; content += ''; if (permissions[pid]['bits'][IP_CHANGE_NAME]) content += "" + instances[i]['wf_instance_name'] + ""; else content += instances[i]['wf_instance_name']; content += ''; if (permissions[pid]['bits'][IP_CHANGE_PRIORITY]) content += "" + instances[i]['wf_priority'] + ""; else content += instances[i]['wf_priority']; content += ''; if (permissions[pid]['bits'][IP_CHANGE_USER]) content += "" + userName + ""; else content += userName; content += ''; if (permissions[pid]['bits'][IP_CHANGE_STATUS]) content += "" + statusQuickTranslation[instances[i]['wf_status']] + ""; else content += statusQuickTranslation[instances[i]['wf_status']]; content += ''; if (!instances[i]['wf_actions']) content += " "; else content += instances[i]['wf_actions']; content += '
'; content += '
' + pagingLinks + '
'; new Insertion.Bottom(divInstance, content); if (menuCreated) lb_initialize(); } /**** AÇÕES DE ATUALIZAÇÃO DA INSTÂNCIA ****/ function clickPriority(link, iid, pid) { var td = link.parentNode; var previousValue = link.innerHTML; var items = new Array(); for (var i = 0; i < 5; i++) { items[i] = new Array(); items[i]['id'] = i; items[i]['name'] = i; } td.innerHTML = constructSelectBox('np_' + iid, items, link.innerHTML); td.innerHTML += ""; } function updatePriority(iid, pid) { var selectBox = document.getElementById('np_' + iid); var np = selectBox.value; cExecute ("$this.bo_monitors.updatePriority", updatePriorityResult, 'iid=' + iid + '&pid=' + pid + '&np=' + np); selectBox.parentNode.innerHTML = "

(atualizando)

"; } function updatePriorityResult(data) { if (handleError(data)) { var message = document.getElementById('np_' + data['iid']); message.parentNode.innerHTML = "" + data['np'] + ""; } } function clickUser(link, pid, aid, iid, uid) { link.parentNode.innerHTML = "

(carregando lista)

"; cExecute ("$this.bo_monitors.listUsers", userList, 'pid=' + pid + '&aid=' + aid + '&iid=' + iid + '&uid=' + uid); } function updateUser(iid, aid, pid) { var selectBox = document.getElementById("nu_" + iid); var uid = selectBox.value; cExecute ("$this.bo_monitors.updateUser", updateUserResult, 'iid=' + iid + '&user=' + uid + '&aid=' + aid + '&pid=' + pid); selectBox.parentNode.innerHTML = "

(atualizando)

"; } function updateUserResult(data) { if (handleError(data)) { var message = document.getElementById('nu_' + data['iid']); message.parentNode.innerHTML = "" + data['fullname'] + ""; } } function clickActivity(link, pid, aid, iid) { link.parentNode.innerHTML = "

(carregando lista)

"; cExecute ("$this.bo_monitors.listActivities", activityList, 'pid=' + pid + '&aid=' + aid + '&iid=' + iid); } function updateActivity(iid, pid) { var selectBox = document.getElementById("na_" + iid); var aid = selectBox.value; cExecute ("$this.bo_monitors.updateActivity", updateActivityResult, 'iid=' + iid + '&aid=' + aid + '&pid=' + pid); selectBox.parentNode.innerHTML = "

(atualizando)

"; } function updateActivityResult(data) { if (handleError(data)) { var message = document.getElementById('na_' + data['iid']); message.parentNode.innerHTML = "" + data['name'] + ""; } } function clickStatus(link, iid, pid, selected) { var td = link.parentNode; td.innerHTML = constructSelectBox('np_' + iid, statusCorrelation, selected); td.innerHTML += ""; } function updateStatus(iid, pid) { var selectBox = document.getElementById('np_' + iid); cExecute ("$this.bo_monitors.updateStatus", updateStatusResult, 'iid=' + iid + '&pid=' + pid + '&ns=' + selectBox.value); selectBox.parentNode.innerHTML = "

(atualizando)

"; } function updateStatusResult(data) { if (handleError(data)) { var message = document.getElementById('np_' + data['iid']); if (data['ns'] == 'aborted') message.parentNode.parentNode.remove(); else message.parentNode.innerHTML = "" + statusQuickTranslation[data['ns']] + ""; } } function clickName(link, iid, pid) { var td = link.parentNode; if (link.innerHTML == "             ") link.innerHTML = ""; td.innerHTML = ''; td.innerHTML += ""; td.childNodes[0].focus(); td.childNodes[0].select(); } function updateName(iid, pid) { var text = document.getElementById("nn_" + iid); cExecute ("$this.bo_monitors.updateName", updateNameResult, 'iid=' + iid + '&pid=' + pid + '&nn=' + escape(text.value)); text.parentNode.innerHTML = "

(atualizando)

"; } function updateNameResult(data) { if (handleError(data)) { var message = document.getElementById('nn_' + data['iid']); if (data['nn'] == "") data['nn'] = "             "; message.parentNode.innerHTML = "" + data['nn'] + ""; } } function editProperties(iid, pid) { var border_id = create_border("Propriedades - ID: " + iid); elem = $("content_id_" + border_id); loadProperties(iid, pid, elem); } function monitorPaginateInstances(p_page) { if (workflowMonitorCurrentList == 'active') callInstanceList(workflowMonitorInstancesParams['pid'], workflowMonitorInstancesParams['str'], p_page, workflowMonitorInstancesParams['filters']); else callCompletedInstanceList(workflowMonitorInstancesParams['pid'], workflowMonitorInstancesParams['str'], p_page, workflowMonitorInstancesParams['filters']); } function monitorSortInstances(sort) { if (workflowMonitorCurrentList == 'active') callInstanceList(workflowMonitorInstancesParams['pid'], sort, null, workflowMonitorInstancesParams['filters']); else callCompletedInstanceList(workflowMonitorInstancesParams['pid'], sort, null, workflowMonitorInstancesParams['filters']); } function loadInstances(pid) { for (var i = 0; i < filters.length; i++) filters[i] = null; filters = new Array(); callInstanceList(pid, null, 0); } function loadCompletedInstances(pid) { for (var i = 0; i < filters.length; i++) filters[i] = null; filters = new Array(); callCompletedInstanceList(pid, null, 0); } function loadInconsistentInstances(pid) { cExecute('$this.bo_monitors.loadInconsistentInstances', resultInconsistentInstances, 'pid=' + pid); } function resultInconsistentInstances(data) { var instances = data['instances']; var names = data['names']; var divInstance = $('divInstance'); var content = ''; content += '

Instâncias Inconsistentes

'; for (var i = 0; i < instances.length; i++) { content += '

' + instances[i]['name'] + '

'; content += '

' + instances[i]['description'] + '

'; var instanceList = instances[i]['items']; if (instanceList.length == 0) { content += '

Nenhuma ocorrência encontrada.

'; continue; } content += ''; content += ''; for (var j = 0; j < instanceList.length; j++) { if (!instanceList[j]['wf_instance_name']) instanceList[j]['wf_instance_name'] = ''; content += ''; content += ''; content += ''; content += ''; content += ''; content += ''; content += ''; content += ''; } content += '
IDAtividadeIdentificadorPri.UsuárioStatus
' + instanceList[j]['wf_instance_id'] + '' + instanceList[j]['wf_activity_name'] + '' + instanceList[j]['wf_instance_name'] + '' + instanceList[j]['wf_priority'] + '' + names[instanceList[j]['wf_user']] + '' + statusQuickTranslation[instanceList[j]['wf_status']] + '
'; } divInstance.innerHTML = content; }