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