[795] | 1 | /* armazena os parâmetro passados para a construção da caixa de entrada */ |
---|
| 2 | var workflowInboxParams; |
---|
| 3 | |
---|
| 4 | /* um digest (MD5) das instâncias exibidas (para saber quando ocorreu a última atualização */ |
---|
| 5 | var workflowInstancesDigest = null; |
---|
| 6 | |
---|
| 7 | /* armazena os nomes dos usuários que possuem as instâncias */ |
---|
| 8 | var workflowInboxUserNames; |
---|
| 9 | |
---|
| 10 | /* armazena informações dos processos */ |
---|
| 11 | var workflowInboxProcessesInfo; |
---|
| 12 | |
---|
| 13 | /* armazena os nomes das atividades */ |
---|
| 14 | var workflowInboxActivityNames; |
---|
| 15 | |
---|
| 16 | /* armazena os conjuntos de ações */ |
---|
| 17 | var workflowInboxActions; |
---|
| 18 | |
---|
| 19 | /* armazena a lista de processos cujas instâncias o usuário pode acessar */ |
---|
| 20 | var workflowInboxProcesses; |
---|
| 21 | |
---|
| 22 | /* indica se o usuário utiliza a versão leve da interface */ |
---|
| 23 | var workflowInboxLightVersion; |
---|
| 24 | |
---|
| 25 | /* indica se a interface está configurada para auto atualização */ |
---|
| 26 | var workflowInboxAutoRefresh = true; |
---|
| 27 | |
---|
| 28 | /* armazena o tempo entre cada atualização, em milisegundos */ |
---|
| 29 | var workflowInboxRefreshTimeInterval = 120000; |
---|
| 30 | |
---|
| 31 | /* armazena a referência do "interval" utilizado para atualização */ |
---|
| 32 | var workflowInboxRefreshInterval = null; |
---|
| 33 | |
---|
| 34 | /* armazena a função (e parâmetros) que deve ser chamada para a atualização */ |
---|
| 35 | var workflowInboxRefreshFunction = ''; |
---|
| 36 | |
---|
| 37 | /* número de atividades view abertas na interface (usado para evitar atualização no caso de alguma view estar aberta) */ |
---|
| 38 | var workflowInboxOpenedViewActivities = 0; |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * Recria os headers da caixa de entrada sem a necessidade de |
---|
| 43 | * recarregar todos os dados. É utilizado para o caso do resultado |
---|
| 44 | * ser igual ao conjunto de dados mostrados |
---|
| 45 | * @params string sortParam Nome da coluna do banco que é o parâmetro order by |
---|
| 46 | * @params object Paging Objeto de paginação |
---|
| 47 | * @return null |
---|
| 48 | * @access public |
---|
| 49 | */ |
---|
| 50 | function redrawInboxHeaders(sortParam, paging) |
---|
| 51 | { |
---|
| 52 | workflowInboxParams['sort'] = sortParam; |
---|
| 53 | |
---|
| 54 | content = '<th width="13%" align="left">' + createSortingHeaders('Data', 'wf_act_started') + '</th>'; |
---|
| 55 | content += '<th width="20%" align="left">' + createSortingHeaders('Processo', 'wf_procname') + '</th>'; |
---|
| 56 | content += '<th width="10%" align="left">' + createSortingHeaders('Identificador', 'insname') + '</th>'; |
---|
| 57 | content += '<th width="3%" align="left">' + createSortingHeaders('P', 'wf_priority') + '</th>'; |
---|
| 58 | content += '<th width="20%" align="left">' + createSortingHeaders('Atividade', 'wf_name') + '</th>'; |
---|
| 59 | content += '<th width="20%" align="left">Atribuído a</th>'; |
---|
| 60 | content += '<th width="7%" align="left">Ações</th>'; |
---|
| 61 | |
---|
| 62 | $('table_elements_inbox').firstChild.firstChild.innerHTML = content; |
---|
| 63 | $('td_tools_inbox_3').innerHTML = createPagingLinks(paging); |
---|
| 64 | |
---|
| 65 | return; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /** |
---|
| 69 | * Recebe os dados do Ajax e chama os métodos para construção da interface |
---|
| 70 | * @param array data Os dados retornados por Ajax |
---|
| 71 | * @return void |
---|
| 72 | */ |
---|
| 73 | function inbox(data) |
---|
| 74 | { |
---|
| 75 | if (_checkError(data)) |
---|
| 76 | return; |
---|
| 77 | |
---|
| 78 | if (workflowInstancesDigest == data['instancesDigest']){ |
---|
| 79 | if(workflowInboxParams && (workflowInboxParams['sort'] != data['sort_param'])){ |
---|
| 80 | redrawInboxHeaders(data['sort_param'], data['paging_links']); |
---|
| 81 | } |
---|
| 82 | return; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | workflowInstancesDigest = data['instancesDigest']; |
---|
| 86 | |
---|
| 87 | var currentSearchField = ''; |
---|
| 88 | var busca = $('busca'); |
---|
| 89 | if (busca) |
---|
| 90 | currentSearchField = busca.value; |
---|
| 91 | var flagSearchPerformed = false; |
---|
| 92 | |
---|
| 93 | if (data['params']['search_term']) |
---|
| 94 | if (data['params']['search_term'] != '') |
---|
| 95 | flagSearchPerformed = true; |
---|
| 96 | |
---|
| 97 | workflowInboxUserNames = data['userNames']; |
---|
| 98 | workflowInboxProcessesInfo = data['processesInfo']; |
---|
| 99 | workflowInboxActivityNames = data['activityNames']; |
---|
| 100 | workflowInboxProcesses = data['processes']; |
---|
| 101 | workflowInboxActions = data['actions']; |
---|
| 102 | workflowInboxParams = data['params']; |
---|
| 103 | workflowInboxLightVersion = data['light']; |
---|
| 104 | |
---|
| 105 | var information = $('workflowInboxInformation'); |
---|
| 106 | if (information) |
---|
| 107 | information.remove(); |
---|
| 108 | |
---|
| 109 | var currentInboxMenu = $('table_tools_inbox'); |
---|
| 110 | var currentInboxElements = $('table_elements_inbox'); |
---|
| 111 | if (currentInboxElements) |
---|
| 112 | currentInboxElements.remove(); |
---|
| 113 | |
---|
| 114 | if (data['instances'].length > 0) |
---|
| 115 | { |
---|
| 116 | if (!currentInboxMenu) |
---|
| 117 | createInboxMenu(); |
---|
| 118 | createInbox(data['instances'], data['paging_links']); |
---|
| 119 | } |
---|
| 120 | else |
---|
| 121 | { |
---|
| 122 | if ((!flagSearchPerformed) && currentInboxMenu) |
---|
| 123 | currentInboxMenu.remove(); |
---|
| 124 | var pagingContainer = $('td_tools_inbox_3'); |
---|
| 125 | if (pagingContainer) |
---|
| 126 | pagingContainer.innerHTML = ''; |
---|
| 127 | $('content_id_0').innerHTML += '<p class="text_dsp" id="workflowInboxInformation">Não existem atividades a serem executadas</p>'; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | busca = $('busca'); |
---|
| 131 | if (busca) |
---|
| 132 | { |
---|
| 133 | if (flagSearchPerformed) |
---|
| 134 | busca.value = data['params']['search_term']; |
---|
| 135 | else |
---|
| 136 | if (currentSearchField != '') |
---|
| 137 | busca.value = currentSearchField; |
---|
| 138 | busca.focus(); |
---|
| 139 | } |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | /** |
---|
| 143 | * Cria o menu da interface |
---|
| 144 | * @return void |
---|
| 145 | */ |
---|
| 146 | function createInboxMenu() |
---|
| 147 | { |
---|
| 148 | var content = '<div id="extraContent"></div>'; |
---|
| 149 | content += '<table id="table_tools_inbox" width="100%">'; |
---|
| 150 | content += '<td id="td_tools_inbox_1" width="470">'; |
---|
| 151 | content += '<ul class="horizontalMenu">'; |
---|
| 152 | content += '<li><a href="javascript:group_inbox()">' + ((workflowInboxLightVersion) ? '' : '<img src="templateFile.php?file=images/group.png"/> ') + 'Agrupar</a></li>'; |
---|
| 153 | content += '<li id="processFilterButton"><a href="javascript:showProcessFilter()">' + ((workflowInboxLightVersion) ? '' : '<img src="templateFile.php?file=images/filter.png"/> ') + 'Filtrar por Processo...</a></li>'; |
---|
| 154 | content += '<li><a href="doc/manual_do_usuario.pdf">' + ((workflowInboxLightVersion) ? '' : '<img src="templateFile.php?file=images/help.png"/> ') + 'Ajuda</a></li>'; |
---|
| 155 | content += '<li id="refreshButton"><a href="javascript:workflowInboxRefreshNow()" id="refreshLink"' + (((!workflowInboxAutoRefresh) && workflowInboxLightVersion) ? ' style="color: gray !important"' : '') + '>' + ((workflowInboxLightVersion) ? '' : '<img id="reloadImage" src="templateFile.php?file=images/reload' + ((workflowInboxAutoRefresh) ? '' : '_bw') + '.png"/> ') + 'Atualizar</a><a href="javascript:showRefreshMenu()" style="padding: 0px;"><img src="templateFile.php?file=images/arrow_ascendant.gif" style="padding-top: 11px"/></a></li>'; |
---|
| 156 | content += '</ul>'; |
---|
| 157 | content += '</td>'; |
---|
| 158 | content += '<td id="td_tools_inbox_2" valign="middle" align="left" width="270">'; |
---|
| 159 | content += ' Busca: <input type="text" size="15" id="busca" name="busca" onkeypress="if (((window.Event) ? event.which : event.keyCode) == 13) $(\'searchInboxButton\').onclick(); return true;"/> <a href="#" id="searchInboxButton" onclick="searchInbox($F(\'busca\')); $(\'show_all\').show(); return false;">filtrar</a> <a href="#" id="show_all" onclick="$(\'busca\').value = \'\'; searchInbox(\'\'); this.hide(); return false;" style="display: none;">todos</a>'; |
---|
| 160 | content += '</td>'; |
---|
| 161 | content += '<td id="td_tools_inbox_3" align="right"></td>'; |
---|
| 162 | content += '</tr>'; |
---|
| 163 | content += '</table>'; |
---|
| 164 | |
---|
| 165 | $('content_id_0').innerHTML = content; |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | /** |
---|
| 169 | * Cria a tabela das instâncias |
---|
| 170 | * @param array data As instâncias que serão listadas |
---|
| 171 | * @param array paging Dados da paginação |
---|
| 172 | * @return void |
---|
| 173 | */ |
---|
| 174 | function createInbox(data, paging) |
---|
| 175 | { |
---|
| 176 | var content = ''; |
---|
| 177 | content += '<table id="table_elements_inbox" cellpadding="2" class="inboxElements">'; |
---|
| 178 | content += '<tr>'; |
---|
| 179 | content += '<th width="13%" align="left">' + createSortingHeaders('Data', 'wf_act_started') + '</th>'; |
---|
| 180 | content += '<th width="20%" align="left">' + createSortingHeaders('Processo', 'wf_procname') + '</th>'; |
---|
| 181 | content += '<th width="10%" align="left">' + createSortingHeaders('Identificador', 'insname') + '</th>'; |
---|
| 182 | content += '<th width="3%" align="left">' + createSortingHeaders('P', 'wf_priority') + '</th>'; |
---|
| 183 | content += '<th width="20%" align="left">' + createSortingHeaders('Atividade', 'wf_name') + '</th>'; |
---|
| 184 | content += '<th width="20%" align="left">Atribuído a</th>'; |
---|
| 185 | content += '<th width="7%" align="left">Ações</th>'; |
---|
| 186 | content += '</tr>'; |
---|
| 187 | |
---|
| 188 | var inboxLimit = data.length; |
---|
| 189 | var current; |
---|
| 190 | for (var i = 0; i < inboxLimit; i++) |
---|
| 191 | { |
---|
| 192 | current = data[i]; |
---|
| 193 | content += '<tr>'; |
---|
| 194 | content += '<td>' + current['wf_act_started'] + '</td>'; |
---|
| 195 | if (current['viewRunAction']) |
---|
| 196 | content += '<td onclick="toggleHiddenView(\'inbox\', ' + current['wf_instance_id'] + ', ' + current['wf_activity_id'] + ', ' + current['viewRunAction']['viewActivityID'] + ', ' + workflowInboxProcessesInfo[current['wf_p_id']]['useHTTPS'] + ');" style="cursor: pointer;">' + workflowInboxProcessesInfo[current['wf_p_id']]['name'] + '</td>'; |
---|
| 197 | else |
---|
| 198 | content += '<td>' + workflowInboxProcessesInfo[current['wf_p_id']]['name'] + '</td>'; |
---|
| 199 | content += '<td>' + current['insname'] + '</td>'; |
---|
| 200 | |
---|
| 201 | content += '<td>'; |
---|
| 202 | content += ((workflowInboxLightVersion) ? workflowInboxPriority[current['wf_priority']] : ('<img src="templateFile.php?file=images/pr' + current['wf_priority'] + '.png"/> ')); |
---|
| 203 | if (current['wf_status'] != 'active') |
---|
| 204 | content += ((workflowInboxLightVersion) ? '<font color="red">Exc.</font>' : '<img src="templateFile.php?file=images/exception.png"/></td>') + ' '; |
---|
| 205 | content += '<td>'+workflowInboxActivityNames[current['wf_activity_id']] + '</td>'; |
---|
| 206 | |
---|
| 207 | content += '<td>' + workflowInboxUserNames[current['wf_user']] + '</td>'; |
---|
| 208 | content += '<td>' + constructActions(current['wf_instance_id'], current['wf_activity_id'], current['wf_p_id'], current['wf_actions']) + '</td>'; |
---|
| 209 | content += '</tr>'; |
---|
| 210 | if (current['viewRunAction']) |
---|
| 211 | content += constructHiddenView('inbox', 6, current['wf_instance_id'], current['wf_activity_id'], current['viewRunAction']['height']); |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | $('content_id_0').innerHTML += content; |
---|
| 215 | $('td_tools_inbox_3').innerHTML = createPagingLinks(paging); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | /** |
---|
| 219 | * Cria os links para ordenação das instâncias |
---|
| 220 | * @param string O texto do link |
---|
| 221 | * @param string A ordenação esperada |
---|
| 222 | * @return string O link criado |
---|
| 223 | */ |
---|
| 224 | function createSortingHeaders(text, expectedSort) |
---|
| 225 | { |
---|
| 226 | workflowInboxParams['sort'] = workflowInboxParams['sort'].split(',').shift(); |
---|
| 227 | var currentSort = workflowInboxParams['sort'].split('__'); |
---|
| 228 | var theSame = (expectedSort == currentSort[0]); |
---|
| 229 | direction = false; |
---|
| 230 | |
---|
| 231 | var output = ''; |
---|
| 232 | if (theSame) |
---|
| 233 | { |
---|
| 234 | output += '<strong>'; |
---|
| 235 | direction = (currentSort[1] == 'ASC'); |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | output += '<a href="javascript:sortInbox(\'' + expectedSort + '__' + (direction ? 'DESC' : 'ASC') + '\');">' + text + '</a>'; |
---|
| 239 | |
---|
| 240 | if (theSame) |
---|
| 241 | output += '<img src="templateFile.php?file=images/arrow_' + (direction ? 'ascendant' : 'descendant') + '.gif"/></strong>'; |
---|
| 242 | |
---|
| 243 | return output; |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | /** |
---|
| 247 | * Cria e exibe o menu listando os processos das instâncias que o usuário pode ver |
---|
| 248 | * @return void |
---|
| 249 | */ |
---|
| 250 | function showProcessFilter() |
---|
| 251 | { |
---|
| 252 | hideExtraContents(); |
---|
| 253 | /* se o menu já existe, apenas o exibe */ |
---|
| 254 | if ($('processFilter')) |
---|
| 255 | { |
---|
| 256 | $('divProcessFilter').style.display = ''; |
---|
| 257 | $('extraContent').style.display = ''; |
---|
| 258 | return; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | /* coleta informações sobre posicionamento */ |
---|
| 262 | var li = $('processFilterButton'); |
---|
| 263 | var offset = Position.cumulativeOffset(li); |
---|
| 264 | var height = li.getHeight() - 1; |
---|
| 265 | |
---|
| 266 | /* cria as opções do menu */ |
---|
| 267 | var content = '<div id="divProcessFilter"><ul id="processFilter" onmouseover="$(\'divProcessFilter\').style.display = \'\'; $(\'extraContent\').style.display = \'\'" onmouseout="$(\'divProcessFilter\').style.display = \'none\'; $(\'extraContent\').style.display = \'none\'" class="submenu" style="top: ' + (offset[1] + height) + 'px; left: ' + offset[0] + 'px;">'; |
---|
| 268 | /* insere manualmente a linha para exibir todos os processos */ |
---|
| 269 | content += '<li><a href="javascript:$(\'divProcessFilter\').style.display = \'none\';filterInbox(0)">Todos</a></li>'; |
---|
| 270 | var size = workflowInboxProcesses.length; |
---|
| 271 | for (var i = 0; i < size; i++) |
---|
| 272 | content += '<li><a href="javascript:$(\'divProcessFilter\').style.display = \'none\';filterInbox(' + workflowInboxProcesses[i].pid +')">' + workflowInboxProcesses[i].name + '</a></li>'; |
---|
| 273 | content += '</ul>'; |
---|
| 274 | |
---|
| 275 | /* insere o novo conteúdo */ |
---|
| 276 | var extraContent = $('extraContent'); |
---|
| 277 | extraContent.innerHTML += content; |
---|
| 278 | extraContent.style.display = ''; |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | /** |
---|
| 282 | * Cria e exibe o menu de atualização da interface de Tarefas Pendentes |
---|
| 283 | * @return void |
---|
| 284 | */ |
---|
| 285 | function showRefreshMenu() |
---|
| 286 | { |
---|
| 287 | hideExtraContents(); |
---|
| 288 | |
---|
| 289 | /* se o menu já existe, apenas o exibe */ |
---|
| 290 | if ($('refreshMenu')) |
---|
| 291 | { |
---|
| 292 | $('divRefreshMenu').style.display = ''; |
---|
| 293 | $('extraContent').style.display = ''; |
---|
| 294 | return; |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | /* coleta informações sobre posicionamento */ |
---|
| 298 | var li = $('refreshButton'); |
---|
| 299 | var offset = Position.cumulativeOffset(li); |
---|
| 300 | var height = li.getHeight() - 1; |
---|
| 301 | |
---|
| 302 | /* cria as opções do menu */ |
---|
| 303 | var content = '<div id="divRefreshMenu"><ul id="refreshMenu" onmouseover="$(\'divRefreshMenu\').style.display = \'\'; $(\'extraContent\').style.display = \'\'" onmouseout="$(\'divRefreshMenu\').style.display = \'none\'; $(\'extraContent\').style.display = \'none\'" class="submenu" style="top: ' + (offset[1] + height) + 'px; left: ' + offset[0] + 'px;">'; |
---|
| 304 | /* insere manualmente a linha para exibir todos os processos */ |
---|
| 305 | content += '<li><a href="javascript:$(\'divRefreshMenu\').style.display = \'none\';workflowInboxStopAutoRefresh()">Interromper Atualização Automática</a></li>'; |
---|
| 306 | content += '<li><a href="javascript:$(\'divRefreshMenu\').style.display = \'none\';workflowInboxStartAutoRefresh()">Ativar Atualização Automática</a></li>'; |
---|
| 307 | content += '<li><a href="javascript:$(\'divRefreshMenu\').style.display = \'none\';workflowInboxRefreshNow();">Atualizar Agora</a></li>'; |
---|
| 308 | |
---|
| 309 | /* insere o novo conteúdo */ |
---|
| 310 | var extraContent = $('extraContent'); |
---|
| 311 | extraContent.innerHTML += content; |
---|
| 312 | extraContent.style.display = ''; |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | /** |
---|
| 316 | * Oculta todos os elementos dentro do div 'extraContent' |
---|
| 317 | * @return void |
---|
| 318 | */ |
---|
| 319 | function hideExtraContents() |
---|
| 320 | { |
---|
| 321 | $A($('extraContent').childNodes).each(function(item) |
---|
| 322 | { |
---|
| 323 | item.style.display = 'none'; |
---|
| 324 | }); |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | /** |
---|
| 328 | * Constrói o menu de ações de acordo com a permissão do usuário |
---|
| 329 | * @param int instanceID O ID da instância |
---|
| 330 | * @param int activityID O ID da atividade |
---|
| 331 | * @param int processID O ID do processo |
---|
| 332 | * @param int actionID O ID do conjunto de ações |
---|
| 333 | * @return string O código XHTML do menu de ações |
---|
| 334 | */ |
---|
| 335 | function constructActions(instanceID, activityID, processID, actionID) |
---|
| 336 | { |
---|
| 337 | var actions = workflowInboxActions[actionID]; |
---|
| 338 | var content = ''; |
---|
| 339 | |
---|
| 340 | var instanceURL = getInstanceURL(instanceID, activityID, workflowInboxProcessesInfo[processID]['useHTTPS']); |
---|
| 341 | |
---|
| 342 | if (workflowInboxLightVersion) |
---|
| 343 | { |
---|
| 344 | if (actions[0]['value']) |
---|
| 345 | content += '<a href="' + instanceURL + '">Exec.</a>'; |
---|
| 346 | else |
---|
| 347 | content += 'Exec'; |
---|
| 348 | content += ' <a href="javascript:constructMoreActions(' + instanceID + ', ' + activityID + ', ' + actionID + ');">Mais</a>'; |
---|
| 349 | } |
---|
| 350 | else |
---|
| 351 | { |
---|
| 352 | content += '<a href="' + instanceURL + '"><img src="templateFile.php?file=images/actions/' + ((actions[0].value) ? '' : 'no_') + 'run.png" alt="' + actions[0].text + '" title="' + actions[0].text + '"/></a> '; |
---|
| 353 | for (var i = 0; i < actions.length; i++) |
---|
| 354 | if (actions[i].name == 'view') |
---|
| 355 | content += '<a href="javascript:workflowInboxAction' + actions[i].name.charAt(0).capitalize() + actions[i].name.substr(1) + '(' + instanceID + ', ' + activityID + ');"><img src="templateFile.php?file=images/actions/' + ((actions[i].value) ? '' : 'no_') + actions[i].name + '.png" alt="' + actions[i].text + '" title="' + actions[i].text + '"/></a> '; |
---|
| 356 | content += '<a href="javascript:constructMoreActions(' + instanceID + ', ' + activityID + ', ' + actionID + ');"><img src="templateFile.php?file=images/more_down.png" alt="Mais Ações" title="Mais Ações"/></a>'; |
---|
| 357 | } |
---|
| 358 | content += '<div id="advancedActionsMenu_' + instanceID + '_' + activityID + '" onmouseout="this.hide();" onmouseover="this.show();" style="display: none; width: 150px;" class="advancedActions"></div>'; |
---|
| 359 | |
---|
| 360 | return content; |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | /** |
---|
| 364 | * Constrói o menu de ações avançadas de acordo com a permissão do usuário |
---|
| 365 | * @param int instanceID O ID da instância |
---|
| 366 | * @param int activityID O ID da atividade |
---|
| 367 | * @param int actionID O ID do conjunto de ações |
---|
| 368 | * @return string O código XHTML do menu de ações avançadas |
---|
| 369 | */ |
---|
| 370 | function constructMoreActions(instanceID, activityID, actionID) |
---|
| 371 | { |
---|
| 372 | var content = ''; |
---|
| 373 | var div = $('advancedActionsMenu_' + instanceID + '_' + activityID); |
---|
| 374 | |
---|
| 375 | if (!div.innerHTML) |
---|
| 376 | { |
---|
| 377 | var actions = workflowInboxActions[actionID]; |
---|
| 378 | if (workflowInboxLightVersion) |
---|
| 379 | { |
---|
| 380 | for (var i = 0; i < actions.length; i++) |
---|
| 381 | if ((actions[i].name != 'run') && (actions[i].name != 'viewrun')) |
---|
| 382 | if (actions[i].value) |
---|
| 383 | content += '<a href="javascript:workflowInboxAction' + actions[i].name.charAt(0).capitalize() + actions[i].name.substr(1) + '(' + instanceID + ', ' + activityID + ');"> ' + actions[i].text + '</a><br/>'; |
---|
| 384 | else |
---|
| 385 | content += ' ' + actions[i].text + '<br/>'; |
---|
| 386 | } |
---|
| 387 | else |
---|
| 388 | { |
---|
| 389 | for (var i = 0; i < actions.length; i++) |
---|
| 390 | if ((actions[i].name != 'run') && (actions[i].name != 'viewrun') && (actions[i].name != 'view')) |
---|
| 391 | if (actions[i].value) |
---|
| 392 | content += '<a href="javascript:workflowInboxAction' + actions[i].name.charAt(0).capitalize() + actions[i].name.substr(1) + '(' + instanceID + ', ' + activityID + ');"><img src="templateFile.php?file=images/actions/' + actions[i].name + '.png"/> ' + actions[i].text + '</a><br/>'; |
---|
| 393 | else |
---|
| 394 | content += '<img src="templateFile.php?file=images/actions/no_' + actions[i].name + '.png"/> ' + actions[i].text + '<br/>'; |
---|
| 395 | } |
---|
| 396 | div.innerHTML = content; |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | var offset = Position.cumulativeOffset(div.parentNode); |
---|
| 400 | div.style.top = (offset[1] + 20) + 'px'; |
---|
| 401 | div.style.left = (offset[0] - 80) + 'px'; |
---|
| 402 | |
---|
| 403 | if (div.visible()) |
---|
| 404 | div.hide(); |
---|
| 405 | else |
---|
| 406 | div.show(); |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | /** |
---|
| 410 | * Cria os links de paginação |
---|
| 411 | * @param array paging Dados da paginação |
---|
| 412 | * @return string O código XHTML dos links de paginação |
---|
| 413 | */ |
---|
| 414 | function createPagingLinks(pagingData) |
---|
| 415 | { |
---|
| 416 | var output = ''; |
---|
| 417 | if (pagingData) |
---|
| 418 | { |
---|
| 419 | var pagingSize = pagingData.length; |
---|
| 420 | for (var i = 0; i < pagingSize; i++) |
---|
| 421 | { |
---|
| 422 | if (pagingData[i].do_link == true) |
---|
| 423 | output += '<a href="javascript:draw_inbox_folder(' + pagingData[i].p_page + ', \'' + workflowInboxParams['sort'] + '\', ' + workflowInboxParams['pid'] + ', \'' + workflowInboxParams['search_term'] + '\');">' + pagingData[i].name + '</a> '; |
---|
| 424 | else |
---|
| 425 | output += '<strong>' + pagingData[i].name + '</strong> '; |
---|
| 426 | } |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | return output; |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | /** |
---|
| 433 | * Ordena as instâncias da interface |
---|
| 434 | * @param string sort A ordenação selecionada |
---|
| 435 | * @return void |
---|
| 436 | */ |
---|
| 437 | function sortInbox(sort) |
---|
| 438 | { |
---|
| 439 | draw_inbox_folder(0, sort, workflowInboxParams['pid'], workflowInboxParams['search_term']); |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | /** |
---|
| 443 | * Faz uma busca nas instâncias da interface |
---|
| 444 | * @param string search_term A string que será procurada |
---|
| 445 | * @return void |
---|
| 446 | */ |
---|
| 447 | function searchInbox(search_term) |
---|
| 448 | { |
---|
| 449 | draw_inbox_folder(0, workflowInboxParams['sort'], workflowInboxParams['pid'], escape(search_term)); |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | /** |
---|
| 453 | * Filtra a interface para exibir somente as instâncias de um determinado processo |
---|
| 454 | * @param int pid O ID do processo que se quer filtrar (ao utilizar 0 (zero), todos os processos serão exibidos |
---|
| 455 | * @return void |
---|
| 456 | */ |
---|
| 457 | function filterInbox(pid) |
---|
| 458 | { |
---|
| 459 | draw_inbox_folder(null, workflowInboxParams['sort'], pid, workflowInboxParams['search_term']); |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | /** |
---|
| 463 | * Busca os dados, por Ajax, para a reconstrução da interface |
---|
| 464 | * @param int p_page O número da página (quando houver paginação) que está sendo exibida |
---|
| 465 | * @param string sort A ordenação selecionada |
---|
| 466 | * @param int pid O ID do processo que se quer filtrar (ao utilizar 0 (zero), todos os processos serão exibidos |
---|
| 467 | * @param string search_term A string que será procurada |
---|
| 468 | * @return void |
---|
| 469 | */ |
---|
| 470 | function draw_inbox_folder(p_page, sort, pid, search_term) |
---|
| 471 | { |
---|
| 472 | var p_page = (p_page == null) ? 0 : p_page; |
---|
| 473 | var sort = (sort == null) ? 0 : sort; |
---|
| 474 | var pid = (pid == null) ? 0 : pid; |
---|
| 475 | var search_term = (search_term == null) ? '' : search_term; |
---|
| 476 | |
---|
| 477 | workflowInboxRefreshFunction = 'cExecute("$this.bo_userinterface.inbox", inbox, "sort=' + sort + '&pid=' + pid + '&p_page=' + p_page + '&search_term=' + search_term + '")'; |
---|
| 478 | if (workflowInboxAutoRefresh) |
---|
| 479 | workflowInboxStartRefreshInterval(); |
---|
| 480 | |
---|
| 481 | cExecute("$this.bo_userinterface.inbox", inbox, "sort=" + sort + "&pid=" + pid + "&p_page=" + p_page + "&search_term=" + search_term); |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | /** |
---|
| 485 | * Atualiza a lista de instâncias |
---|
| 486 | * @return void |
---|
| 487 | */ |
---|
| 488 | function workflowInboxRefreshNow() |
---|
| 489 | { |
---|
| 490 | if (workflowInboxRefreshFunction != '') |
---|
| 491 | eval(workflowInboxRefreshFunction); |
---|
| 492 | else |
---|
| 493 | draw_inbox_folder(); |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | /** |
---|
| 497 | * Pára o "interval" que chama a função de atualização |
---|
| 498 | * @return void |
---|
| 499 | */ |
---|
| 500 | function workflowInboxStopRefreshInterval() |
---|
| 501 | { |
---|
| 502 | if (workflowInboxRefreshInterval) |
---|
| 503 | { |
---|
| 504 | clearInterval(workflowInboxRefreshInterval); |
---|
| 505 | workflowInboxRefreshInterval = null; |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | /** |
---|
| 510 | * Inicia o "interval" que chama a função de atualização |
---|
| 511 | * @return void |
---|
| 512 | */ |
---|
| 513 | function workflowInboxStartRefreshInterval() |
---|
| 514 | { |
---|
| 515 | workflowInboxStopRefreshInterval(); |
---|
| 516 | workflowInboxRefreshInterval = setInterval('workflowInboxRefresh()', workflowInboxRefreshTimeInterval); |
---|
| 517 | } |
---|
| 518 | |
---|
| 519 | /** |
---|
| 520 | * Pára a atualização automática |
---|
| 521 | * @return void |
---|
| 522 | */ |
---|
| 523 | function workflowInboxStopAutoRefresh() |
---|
| 524 | { |
---|
| 525 | workflowInboxAutoRefresh = false; |
---|
| 526 | workflowInboxStopRefreshInterval(); |
---|
| 527 | if (workflowInboxLightVersion) |
---|
| 528 | $('refreshLink').style.setProperty('color', 'gray', 'important'); |
---|
| 529 | else |
---|
| 530 | $('reloadImage').src = 'templateFile.php?file=images/reload_bw.png'; |
---|
| 531 | } |
---|
| 532 | |
---|
| 533 | /** |
---|
| 534 | * Inicia a atualização automática |
---|
| 535 | * @return void |
---|
| 536 | */ |
---|
| 537 | function workflowInboxStartAutoRefresh() |
---|
| 538 | { |
---|
| 539 | workflowInboxAutoRefresh = true; |
---|
| 540 | workflowInboxStartRefreshInterval(); |
---|
| 541 | if (workflowInboxLightVersion) |
---|
| 542 | $('refreshLink').style.setProperty('color', 'black', 'important'); |
---|
| 543 | else |
---|
| 544 | $('reloadImage').src = 'templateFile.php?file=images/reload.png'; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | /** |
---|
| 548 | * Função que é chamada pelo "interval" para atualizar, automaticamente, a lista de instâncias |
---|
| 549 | * @return void |
---|
| 550 | */ |
---|
| 551 | function workflowInboxRefresh() |
---|
| 552 | { |
---|
| 553 | /* verifica se a aba aberta é a de "Tarefas Pendentes" */ |
---|
| 554 | if (tabStack[tabStack.length - 1] != 0) |
---|
| 555 | return; |
---|
| 556 | |
---|
| 557 | if ($('divProgressBar').style.visibility == 'visible') |
---|
| 558 | return; |
---|
| 559 | |
---|
| 560 | if (workflowInboxOpenedViewActivities > 0) |
---|
| 561 | return; |
---|
| 562 | |
---|
| 563 | /* atualiza a lista de instâncias */ |
---|
| 564 | workflowInboxRefreshNow(); |
---|
| 565 | } |
---|