DBA Data[Home] [Help]

PACKAGE BODY: APPS.WF_MONITOR

Source


1 package body WF_MONITOR as
2 /* $Header: wfmonb.pls 120.14 2006/09/19 11:34:35 santosin ship $: */
3 
4 type NameArrayTyp is table of varchar2(240) index by binary_integer;
5 
6 gClob clob;
7 gUseClob boolean := false;
8 gClobInit boolean := false;
9 
10 l_data varchar2(32000);
11 NL_CHAR varchar2(1):= '
12 ';
13 
14  /*
15  ** Set up a table for the list of activity status and there associated
16  ** icons.  This is used for the advanced activity filtering capability
17  ** as well as the listing of the activity statuses
18  */
19  /*
20  ** Here is the list of status subscripts that are used to reference the table
21  ** elements
22  */
23  G_FIRST_STATUS   PLS_INTEGER := 1;
24  G_ACTIVE         PLS_INTEGER := 1;
25  G_COMPLETE       PLS_INTEGER := 2;
26  G_ERROR          PLS_INTEGER := 3;
27  G_SUSPEND        PLS_INTEGER := 4;
28  G_LAST_STATUS    PLS_INTEGER := 4;
29  /*
30  ** Here is the record definition that holds the
31  ** list of status_codes and their associated icons
32  */
33  TYPE wf_status_icons_record IS RECORD (
34     status_code         VARCHAR2(8),
35     icon_file_name      VARCHAR2(30)
36 );
37 
38  /*
39  ** Here is the table that is populated with the appropriate icon information
40  */
41  TYPE wf_status_icons_table IS TABLE OF wf_status_icons_record
42     INDEX BY BINARY_INTEGER;
43 
44 
45 
46 --
47 -- Error (PRIVATE)
48 --   Print a page with an error message.
49 --   Errors are retrieved from these sources in order:
50 --     1. wf_core errors
51 --     2. Oracle errors
52 --     3. Unspecified INTERNAL error
53 --
54 procedure Error
55 as
56 begin
57    null;
58 end Error;
59 
60 procedure appendClobData(newData in varchar2)
61 is
62 begin
63   if (gUseClob) then
64     if NOT (gClobInit) then
65       dbms_lob.createTemporary(gClob, true, dbms_lob.session);
66       dbms_lob.open(gClob, dbms_lob.lob_readwrite);
67       gClobInit := true;
68     end if;
69     if (newData is not null) then
70         dbms_lob.writeAppend(gClob, length(newData), newData);
71     end if;
72   end if;
73 end;
74 
75 --appendData (PRIVATE)
76 procedure appendData(newData in varchar2)
77 is
78 begin
79   if (gUseClob) then
80    appendClobData(newData|| NL_CHAR);
81   else
82    if(newData is not null) then
83      l_data := l_data || NL_CHAR || newData;
84    end if;
85   end if;
86 
87 end;
88 
89 
90 /*
91 ** Create the status icons table.  This table is
92 ** used to draw to advanced options list and the
93 ** status column in the activities list when youre
94 ** in advanced mode
95 */
96 procedure create_status_icons_table (
97 x_status_icons_table IN OUT NOCOPY wf_status_icons_table
98 )
99 IS
100 
101 BEGIN
102 
103    x_status_icons_table(G_ACTIVE).status_code       := 'ACTIVE';
104    x_status_icons_table(G_ACTIVE).icon_file_name    := 'FNDIACTV.gif';
105 
106    x_status_icons_table(G_COMPLETE).status_code     := 'COMPLETE';
107    x_status_icons_table(G_COMPLETE).icon_file_name  := 'FNDIDONE.gif';
108 
109    x_status_icons_table(G_ERROR).status_code        := 'ERROR';
110    x_status_icons_table(G_ERROR).icon_file_name     := 'FNDIREDL.gif';
111 
112    x_status_icons_table(G_SUSPEND).status_code      := 'SUSPEND';
113    x_status_icons_table(G_SUSPEND).icon_file_name   := 'FNDIYLWL.gif';
114 
115   EXCEPTION
116   WHEN OTHERS THEN
117      Wf_Core.Context('wf_monitor',
118         'create_status_icons_table');
119      Error;
120 
121 END create_status_icons_table;
122 
123 
124 -- GetAccessKey
125 function GetAccessKey(
126     x_item_type  varchar2,
127     x_item_key   varchar2,
128     x_admin_mode varchar2) return varchar2 is
129 
130   access_key varchar2(2000);
131 begin
132 
133   if (upper(substr(x_admin_mode, 1, 1)) <> 'Y') then
134     access_key := Wf_Engine.GetItemAttrText(x_item_type,
135                                             x_item_key, '.MONITOR_KEY');
136   else
137     access_key := Wf_Engine.GetItemAttrText(x_item_type,
138                                             x_item_key, '.ADMIN_KEY');
139   end if;
140 
141   return access_key;
142 
143   exception
144     when others then
145       raise;
146 end;
147 
148 -- AccessKeyCheck
149 function AccessKeyCheck(
150     x_item_type  varchar2,
151     x_item_key   varchar2,
152     x_admin_mode varchar2,
153     x_access_key varchar2) return boolean is
154 
155   access_key varchar2(2000);
156 begin
157 
158   if (x_access_key is null) then
159     return(false);
160   end if;
161 
162   -- Check for access key
163   begin
164     if (GetAccessKey(x_item_type,x_item_key,x_admin_mode) <> x_access_key) then
165       return(false);
166     end if;
167 
168     return(true);
169 
170     exception
171       when others then
172         Error;
173         return(false);
174   end;
175 end;
176 
177 -- Html
178 --   Sends back a very simple dynamic HTML page to tell the browser what
179 --   applet to run.
180 -- IN
181 --   x_item_type
182 --   x_item_key
183 --   x_admin_mode
184 procedure Html(
185     x_item_type  in varchar2,
186     x_item_key   in varchar2,
187     x_admin_mode in varchar2,
188     x_access_key in varchar2,
189     x_nls_lang   in varchar2) is
190 
191  username varchar2(320);
192  rt_activity varchar2(30) := '';
193  rt_activity_version pls_integer;
194  bg_date date;
195  access_key varchar2(30);
196  lang_codeset varchar2(50);
197  admin_role varchar2(320);
198  admin_privilege boolean := FALSE;
199  pseudo_login BOOLEAN := FALSE;
200  item_type_tl varchar2(80);
201  l_ie_plugin_ver varchar2(80);  -- IE version is delimited by ','
202  l_archive varchar2(2000);      -- first look for java classes at this archive
203  l_java_loc VARCHAR2(80) := '/OA_JAVA/';
204  l_code varchar2(80) :=  'oracle.apps.fnd.wf.Monitor';
205  l_wf_plugin_download varchar2(80);
206  l_wf_plugin_version varchar2(80);
207  l_wf_classid varchar2(80);
208  l_admin varchar(4) := 'no';
209  l_installType varchar2(30);
210 
211 begin
212 
213  -- We will check the installation type to be passed to the monitor applet.
214   l_installType := WF_CORE.Translate('WF_INSTALL');
215 
216   /*
217   ** Hide any session creation issues for now and depend on the
218   ** access key to prevent a user from running this function without
219   ** logging in.
220   */
221   begin
222 
223      -- set the validate_only flag to true so you don't throw up the login
224      -- page and you have a chance to check the access key.
225      wfa_sec.validate_only := TRUE;
226 
227      wfa_sec.GetSession(username);
228 
229      -- Security checking
230      admin_role := wf_core.Translate('WF_ADMIN_ROLE');
231      if (admin_role <> '*')  then
232         if (wf_directory.IsPerformer(username, admin_role)) then
233            admin_privilege := true;
234            if (upper(substr(x_admin_mode, 1, 1)) = 'Y') then
235               l_admin := 'yes';
236            end if;
237         else
238            admin_privilege := false;
239         end if;
240      else
241         -- no security. Eveybody is admin
242         admin_privilege := true;
243         if (upper(substr(x_admin_mode, 1, 1)) = 'Y') then
244            l_admin := 'yes';
245         end if;
246      end if;
247   exception
248      when others then
249         -- If AccessKeyCheck will return "ERROR" directly if failed
250         if (not(AccessKeyCheck(x_item_type, x_item_key, x_admin_mode,
251                 x_access_key))) then
252            htp.p(wf_core.translate('WRONG_ACCESS_KEY'));
253            return;
254         else
255            dbms_session.set_nls('NLS_LANGUAGE', ''''||x_nls_lang||'''');
256            pseudo_login := TRUE;
257            if (upper(substr(x_admin_mode, 1, 1)) = 'Y') then
258               admin_privilege := TRUE;
259               l_admin := 'yes';
260            else
261               admin_privilege := FALSE;
262            end if;
263         end if;
264   end;
265 
266   begin
267     select root_activity,
268            root_activity_version,
269            begin_date
270     into rt_activity,
271          rt_activity_version,
272          bg_date
273     from wf_items
274     where item_type = x_item_type
275     and item_key = x_item_key;
276 
277   exception
278     when NO_DATA_FOUND then
279       wf_core.Context('Wf_Monitor', 'HTML', x_item_type, x_item_key);
280       wf_core.Token('TYPE', x_item_type);
281       wf_core.Token('KEY', x_item_key);
282       wf_core.Raise('WFENG_ITEM');
283     when OTHERS then
284       htp.p(sqlerrm);
285       return;
286   end;
287 
288   lang_codeset := substr(userenv('LANGUAGE'),instr(userenv('LANGUAGE'),'.')+1,
289                          length(userenv('LANGUAGE')));
290 
291   begin
292     select display_name
293     into item_type_tl
294     from wf_item_types_vl
295     where name = x_item_type;
296 
297   exception
298     when OTHERS then
299       htp.p(sqlerrm);
300       return;
301   end;
302 
303   -- Otherwise, we can continue our work here
304   -- Generate the html page
305   htp.p('<html>');
306   if (admin_privilege) then
307       htp.p('<head><title> ' || item_type_tl || ', ' || x_item_type
308             || ', ' || x_item_key || ' </title>');
309   else
310      htp.p('<head><title> ' || item_type_tl || ', ' || x_item_key || ' </title>');
311   end if;
312 
313   wfa_html.create_help_function('wf/links/wfm.htm?WFMON');
314   htp.p('</head>');
315 
316   -- Open body and draw standard header
317   wfa_sec.header(FALSE, 'wf_monitor.find_instance" TARGET="_top',
318          wf_core.translate('WFMON_VIEW_DIAGRAM'), TRUE, pseudo_login);
319 
320   if (l_installType = 'EMBEDDED') then
321     if (instr(UPPER(owa_util.get_cgi_env('HTTP_USER_AGENT')), 'WIN') > 0) then
322       l_archive := '/OA_JAVA/oracle/apps/fnd/jar/wfmon.jar, ' ||
323                    '/OA_JAVA/oracle/apps/fnd/jar/fndewt.jar, ' ||
324                    '/OA_JAVA/oracle/apps/fnd/jar/fndswing.jar, ' ||
325                    '/OA_JAVA/oracle/apps/fnd/jar/fndbalishare.jar, ' ||
326                    '/OA_JAVA/oracle/apps/fnd/jar/fndctx.jar';
327 
328       l_wf_plugin_download := Wf_Core.translate('WF_PLUGIN_DOWNLOAD');
329       l_wf_plugin_version := Wf_Core.translate('WF_PLUGIN_VERSION');
330       l_wf_classid := Wf_Core.translate('WF_CLASSID');
331       l_ie_plugin_ver := replace(Wf_Core.translate('WF_PLUGIN_VERSION'), '.', ',');
332 
333       htp.p('<OBJECT classid="clsid:'||l_wf_classid||'" '||
334             'WIDTH=100% HEIGHT=90% '||
335             'CODEBASE="'||l_wf_plugin_download||
336             '#Version='||l_ie_plugin_ver||'">'||
337             '<PARAM NAME="jinit_appletcache" VALUE="off">'||
338             '<PARAM NAME="CODE"     VALUE="'||l_code||'">'||
339             '<PARAM NAME="CODEBASE" VALUE="'||'/OA_JAVA/'||'">'||
340             '<PARAM NAME="ARCHIVE"  VALUE="'||l_archive||'">' ||
341             '<PARAM NAME="itemtype"  VALUE="'||x_item_type||'">' ||
342             '<PARAM NAME="itemkey"  VALUE="'||x_item_key||'">' ||
343             '<PARAM NAME="langcodeset"  VALUE="'||lang_codeset||'">' ||
344             '<PARAM NAME="accesskey"  VALUE="'||x_access_key||'">' ||
345             '<PARAM NAME="admin"  VALUE="'||l_admin||'">' ||
346             '<PARAM NAME="type"     VALUE="'||
347                         'application/x-jinit-applet;version='||
348                         l_wf_plugin_version||'">' ||
349             '<PARAM NAME="installType"  VALUE="' || l_installType || '">');
350       htp.p('<COMMENT>'||
351             '<EMBED type="application/x-jinit-applet;version='||
352              l_wf_plugin_version||'"'||
353             ' WIDTH="100%" HEIGHT="90%"'||
354             ' jinit_appletcache="off"'||
355             ' java_CODE="'||l_code||'"'||
356             ' java_CODEBASE="'||l_java_loc||'"'||
357             ' java_ARCHIVE="'||l_archive||'"');
358       htp.p(' itemtype="'||x_item_type||'"' ||
359             ' itemkey="'||x_item_key||'"' ||
360             ' langcodeset="'||lang_codeset||'"' ||
361             ' accesskey="'||x_access_key||'"' ||
362             ' admin="'||l_admin||'"' ||
363             ' pluginurl="'|| l_wf_plugin_download||'"' ||
364             ' installType="' || l_installType || '">'||
365             '<NOEMBED></COMMENT></NOEMBED></EMBED></OBJECT>');
366     else
367       -- Client is not Windows, so we don't want to call Jinitiator.
368       htp.p('<applet code=oracle.apps.fnd.wf.Monitor.class codebase="/OA_JAVA"');
369 
370       l_archive := '/OA_JAVA/oracle/apps/fnd/jar/wfmon.jar, ' ||
371                    '/OA_JAVA/oracle/apps/fnd/jar/fndewt.jar, ' ||
372                    '/OA_JAVA/oracle/apps/fnd/jar/fndswing.jar, ' ||
373                    '/OA_JAVA/oracle/apps/fnd/jar/fndbalishare.jar, ' ||
374                    '/OA_JAVA/oracle/apps/fnd/jar/fndctx.jar';
375 
376       htp.p(' archive="' || l_archive || '"');
377 
378       htp.p(' width=100% height=90%>');
379       htp.p('<param name=itemtype value="' || x_item_type || '">');
380       htp.p('<param name=itemkey value="' || x_item_key || '">');
381       htp.p('<param name=langcodeset value="' || lang_codeset || '">');
382       htp.p('<param name=admin value="' || l_admin || '">');
383       htp.p('<param name=accesskey value="' || x_access_key || '">');
384       htp.p('<param name=installType value="' || l_installType || '">');
385       htp.p('</applet>');
386 
387     end if;
388 
389   else
390 
391     htp.p('<applet code=oracle.apps.fnd.wf.Monitor.class codebase="/OA_JAVA"');
392 
393     -- ### We should have this be under fnd/jar after 2.6
394     -- htp.p(' archive="/OA_JAVA/oracle/apps/fnd/wf/jar/wfmon.jar, /OA_JAVA/oracle/apps/fnd/wf/jar/fndewt.jar, /OA_JAVA/oracle/apps/fnd/wf/jar/fndswing.jar, /OA_JAVA/oracle/apps/fnd/wf/jar/fndbalishare.jar"');
395 
396     -- Path for 9i, OA_JAVA sets to ORACLE_HOME/jlib, where all needed jar file locates
397     htp.p(' archive="/OA_JAVA/wfmon.jar, /OA_JAVA/ewt3.jar, /OA_JAVA/ewt3-nls.jar, /OA_JAVA/swingall-1_1_1.jar, /OA_JAVA/share.jar, /OA_JAVA/fndctx.jar"');
398 
399     htp.p(' width=100% height=90%>');
400     htp.p('<param name=itemtype value="' || x_item_type || '">');
401     htp.p('<param name=itemkey value="' || x_item_key || '">');
402     htp.p('<param name=langcodeset value="' || lang_codeset || '">');
403     htp.p('<param name=admin value="' || l_admin || '">');
404     htp.p('<param name=accesskey value="' || x_access_key || '">');
405     htp.p('<param name=installType value="' || l_installType || '">');
406     htp.p('</applet>');
407   end if;
408 
409   htp.p('</body>');
410 
411 exception
412    when others then
413         Error;
414         return;
415 end html;
416 
417 -- GetRootInfo (Private Procedure)
418 --   Gets the root process information about the item key.
419 -- IN
420 --  x_item_type
421 --  x_item_key
422 --  x_proc_name varchar2,
423 --  x_proc_type varchar2,
424 --  x_version   number,
425 --  x_begin_date varchar2);
426 procedure GetRootInfo(
427     x_item_type varchar2,
428     x_item_key  varchar2,
429     x_proc_parent varchar2,
430     x_proc_name varchar2,
431     x_proc_type varchar2,
432     x_version   number,
433     x_begin_date varchar2) is
434 
435   -- To find info about the "root" process, we first figure out
436   -- what its parent process is, then perform the same select we
437   -- use in the 'GetProcessInfo' procedure.
438 
439   cursor rootproc_info is
440    select a.item_type,          /* activity definition */
441           ait.display_name item_type_disp,
442           a.name,
443           a1.display_name,
444           a1.description,
445           a.type,
446           l1.meaning  type_disp,
447           a.function,
448           a.result_type,
449           art.display_name result_type_disp,
450           a.cost,
451           a.rerun,
452           a.icon_name,
453           a.message,
454           to_char(s.due_date)||' '||to_char(s.due_date, 'HH24:MI:SS') due_date,
455           a.error_item_type||'/'||a.error_process error_process,
456           a.expand_role,
457           p.instance_id,        /* activity usage */
458           p.instance_label,     /* activity usage */
459           '' timeout,
460           p.start_end,
461           p.default_result,
462           wf_core.activity_result(a.result_type, p.default_result)
463             activity_usage_result,
464           p.icon_geometry,
465           p.perform_role,
466           p.user_comment,
467           s.activity_status,    /* activity status */
468           l2.meaning  activity_status_disp,
469           s.activity_result_code,
470           wf_core.activity_result(a.result_type, s.activity_result_code)
471             activity_status_result,
472           s.assigned_user,
473           wf_directory.getroledisplayname(s.assigned_user) rolename,
474           s.notification_id,
475           /* date conversion is ok */
476           /* BINDVAR_SCAN_IGNORE */
477           to_char(s.begin_date) || ' ' || to_char(s.begin_date, 'HH24:MI:SS')
478             begin_date,
479           /* date conversion is ok */
480           /* BINDVAR_SCAN_IGNORE */
481           to_char(s.end_date) || ' ' || to_char(s.end_date, 'HH24:MI:SS')
482             end_date,
483           s.execution_time,
484           s.error_name,
485           s.error_message,
486           s.error_stack,
487           n.recipient_role,
488           n.status not_status,
489           n.due_date not_due_date,
490           n.begin_date not_begin_date,
491           n.end_date not_end_date
492    from   wf_activities pd,
493           wf_process_activities p,
494           wf_activities a,
495           wf_activities_tl a1,
496           wf_item_types_vl ait,
497           wf_item_activity_statuses s,
498           wf_lookups l1,
499           wf_lookups l2,
500           wf_lookup_types art,
501           wf_notifications n
502    where  pd.item_type = x_item_type
503      and  pd.name = x_proc_parent
504      and  pd.begin_date <= to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS')
505      and (pd.end_date is null or
506           pd.end_date > to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS'))
507      and  p.process_version = pd.version
508      and  p.process_name = pd.name
509      and  p.process_item_type = pd.item_type
510      and  p.activity_name = x_proc_name
511      and  a.item_type = p.activity_item_type
512      and  a.name = p.activity_name
513      and  a.begin_date <= to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS')
514      and (a.end_date is null or
515           a.end_date > to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS'))
516      and  a1.item_type = a.item_type
517      and  a1.name = a.name
518      and  a1.version = a.version
519      and  a1.language = userenv('LANG')
520      and  ait.name = a.item_type
521      and  s.item_type (+) = x_item_type
522      and  s.item_key (+) = x_item_key
523      and  s.process_activity (+) = p.instance_id
524      and art.lookup_type(+) = a.result_type
525      and l1.lookup_code (+) = a.type
526      and l1.lookup_type (+) = 'WFENG_ACTIVITY_TYPE'
527      and l2.lookup_code (+) = s.activity_status
528      and l2.lookup_type (+) = 'WFENG_STATUS'
529      and s.notification_id = n.notification_id(+);
530 
531   cursor act_result(act_result_type varchar2) is
532     select l.lookup_code,
533            l.meaning
534     from wf_lookups l
535     where l.lookup_type = act_result_type;
536 
537   rc rootproc_info%rowtype;
538 
539   tokenized_mesg  VARCHAR2(10000);
540   tokenized_stack  VARCHAR2(10000);
541   tokenized_description  VARCHAR2(10000);
542   return_token  VARCHAR2(9) := '@#@';
543   l_tab varchar2(30) := wf_core.tab;
544 
545 begin
546 
547   open rootproc_info;
548 
549   fetch rootproc_info into rc;
550 
551   if (rootproc_info%notfound) then
552     appendData('ERROR:' || 'Internal Error in GetRootProcess');
553     return;
554   end if;
555 
556    -- The htp.p proc does not handle returns well, replace them
557    -- with the value <RET_TOK>, will resubstitute later on.
558 --   tokenized_mesg := substr((replace (rc.error_message, wf_core.newline, return_token)), 1, 220);
559    tokenized_mesg := replace (rc.error_message, wf_core.newline,
560                               return_token);
561    tokenized_stack := replace (rc.error_stack, wf_core.newline,
562                                return_token);
563    tokenized_description := replace (rc.description, wf_core.newline,
564                                      return_token);
565 
566   -- The format we use is to list all the fields,
567   -- delineated by tabs (wf_core.tab).  We place a space after each
568   -- field, in case the value returned is null (then the space
569   -- acts as a 'placeholder'), making sure to strip those spaces
570   -- off when we read this into our javacode.
571 
572    appendData('ROOT:' || rc.item_type        || ' ' || l_tab
573                  || rc.item_type_disp   || ' ' || l_tab
574                  || rc.name     || ' ' || l_tab
575                  || rc.display_name     || ' ' || l_tab
576                  || tokenized_description       || ' ' || l_tab
577                  || rc.type     || ' ' || l_tab
578                  || rc.type_disp        || ' ' || l_tab
579                  || rc.function || ' ' || l_tab
580                  || rc.result_type      || ' ' || l_tab
581                  || rc.result_type_disp || ' ' || l_tab
582                  || rc.cost     || ' ' || l_tab
583                  || rc.rerun    || ' ' || l_tab
584                  || rc.icon_name        || ' ' || l_tab
585                  || rc.message  || ' ' || l_tab
586                  || rc.due_date|| ' ' || l_tab
587                  || rc.error_process    || ' ' || l_tab
588                  || rc.expand_role      || ' ' || l_tab
589                  || rc.instance_id      || ' ' || l_tab
590                  || rc.instance_label   || ' ' || l_tab
591                  || rc.timeout  || ' ' || l_tab
592                  || rc.start_end        || ' ' || l_tab
593                  || rc.default_result   || ' ' || l_tab
594                  || rc.activity_usage_result    || ' ' || l_tab
595                  || rc.icon_geometry    || ' ' || l_tab
596                  || rc.perform_role     || ' ' || l_tab
597                  || rc.user_comment     || ' ' || l_tab
598                  || rc.activity_status  || ' ' || l_tab
599                  || rc.activity_status_disp     || ' ' || l_tab
600                  || rc.activity_result_code     || ' ' || l_tab
601                  || rc.activity_status_result   || ' ' || l_tab
602                  || rc.assigned_user    || ' ' || l_tab
603                  || rc.rolename || ' ' || l_tab
604                  || rc.notification_id  || ' ' || l_tab
605                  || rc.begin_date       || ' ' || l_tab
606                  || rc.end_date || ' ' || l_tab
607                  || rc.execution_time   || ' ' || l_tab
608                  || rc.error_name       || ' ' || l_tab
609                  || rc.recipient_role   || ' ' || l_tab
610                  || rc.not_status       || ' ' || l_tab
611                  || rc.not_due_date     || ' ' || l_tab
612                  || rc.not_begin_date   || ' ' || l_tab
613                  || rc.not_end_date     || ' ' || l_tab
614                  || tokenized_mesg      || ' ' || l_tab
615                  || tokenized_stack || ' ');
616 
617     if (rc.result_type <> '*') then
618       for code in act_result(rc.result_type) loop
619         appendData('ROOT_ACTIVITY_RESULT:' || code.lookup_code || ' ' || l_tab
620                                       || code.meaning || ' ');
621 
622       end loop;
623     end if;
624 
625 end GetRootInfo;
626 
627 
628 -- GetItemInfo (Private Procedure)
629 --   Gets the item information.
630 -- IN
631 --   x_item_type
632 --   x_item_key
633 procedure GetItemInfo(
634     x_item_type varchar2,
635     x_item_key  varchar2,
636     x_admin_mode varchar2) is
637 
638   cursor item_info is
639    select ia.name,
640           ia.display_name,
641           ia.type,
642           ia.format,
643           decode(ia.type,
644                  'NUMBER', to_char(iav.number_value),
645                  'DATE', to_char(iav.date_value, nvl(ia.format,
646                                                     'DD-MON-YYYY HH24:MI:SS')),
647                   'LOOKUP', wf_core.activity_result(ia.format, iav.text_value),
648                  iav.text_value) value
649    from wf_item_attributes_vl ia,
650         wf_item_attribute_values iav
651    where iav.item_type = x_item_type
652      and iav.item_key = x_item_key
653      and ia.item_type = iav.item_type
654      and ia.name = iav.name
655      and substr(ia.name, 1, 1) <> '.'
656    order by ia.sequence;
657 
658   item_rec item_info%rowtype;
659 
660   /* 05/14/01 JWSMITH BUG1708024 - CHANGED tokenized_value from */
661   /* VARCHAR2(2100) to VARCHAR2(4000) */
662   tokenized_value  VARCHAR2(4000);
663   return_token  VARCHAR2(9) := '@#@';
664   l_tab varchar2(30) := wf_core.tab;
665 
666   begin
667 
668   open item_info;
669 
670   loop
671    fetch item_info into item_rec;
672    exit when item_info%notfound;
673 
674    if ( (upper(substr(x_admin_mode, 1, 1)) = 'Y') or
675         (substr(item_rec.name, 1, 1) <> '.') ) then
676    tokenized_value := replace (item_rec.value, wf_core.newline,
677                                return_token);
678    appendData('ITEM_ATTRIBUTE:' || item_rec.name     || ' ' || l_tab
679                            || item_rec.display_name     || ' ' || l_tab
680                            || item_rec.type     || ' ' || l_tab
681                            || item_rec.format   || ' ' || l_tab
682                            || tokenized_value   || ' ');
683    end if;
684 
685   end loop;
686 
687 end GetItemInfo;
688 
689 -- GetProcessInfo (Private Procedure)
690 --   Gets process activity information.
691 -- IN
692 --   x_item_type
693 --   x_item_key
694 --   x_proc_name
695 --   x_proc_type
696 --   x_begin_date
697 --   x_admin_mode
698 procedure GetProcessInfo(
699     x_item_type varchar2,
700     x_item_key varchar2,
701     x_proc_name varchar2,
702     x_proc_type varchar2,
703     x_begin_date varchar2,
704     x_admin_mode varchar2) is
705 
706   cursor proc_info is
707    select a.item_type,          /* activity definition */
708           ait.display_name item_type_disp,
709           a.name,
710           a1.display_name,
711           a.version,
712           a1.description,
713           a.type,
714           l1.meaning type_disp,
715           a.function,
716           a.result_type,
717           art.display_name result_type_disp,
718           a.cost,
719           a.rerun,
720           a.icon_name,
721           a.message,
722           to_char(s.due_date)||' '||to_char(s.due_date, 'HH24:MI:SS') due_date,
723           a.error_item_type||'/'||a.error_process error_process,
724           a.expand_role,
725           p.instance_id,        /* activity usage */
726           p.instance_label,     /* activity usage */
727           wf_engine_util.activity_timeout(p.instance_id) timeout,
728           p.start_end,
729           p.default_result,
730           wf_core.activity_result(pd.result_type, p.default_result)
731             activity_usage_result,
732           p.icon_geometry,
733           p.perform_role,
734           p.user_comment,
735           s.activity_status,    /* activity status */
736           l2.meaning  activity_status_disp,
737           s.activity_result_code,
738           wf_core.activity_result(a.result_type, s.activity_result_code)
739             activity_status_result,
740           s.assigned_user,
741           wf_directory.getroledisplayname(s.assigned_user) rolename,
742           s.notification_id,
743           to_char(s.begin_date) || ' ' || to_char(s.begin_date, 'HH24:MI:SS')
744             begin_date,
745           to_char(s.end_date) || ' ' || to_char(s.end_date, 'HH24:MI:SS')
746             end_date,
747           s.execution_time,
748           s.error_name,
749           s.error_message,
750           s.error_stack,
751           n.recipient_role,
752           n.status not_status,
753           to_char(n.due_date) || ' '|| to_char(n.due_date, 'HH24:MI:SS')
754             not_due_date,
755           to_char(n.begin_date) || ' '|| to_char(n.begin_date, 'HH24:MI:SS')
756             not_begin_date,
757           to_char(n.end_date) || ' '|| to_char(n.end_date, 'HH24:MI:SS')
758             not_end_date
759    from   wf_activities pd,
760           wf_process_activities p,
761           wf_activities a,
762           wf_activities_tl a1,
763           wf_item_types_vl ait,
764           wf_item_activity_statuses s,
765           wf_notifications n,
766           wf_lookups l1,
767           wf_lookups l2,
768           wf_lookup_types art
769    where  pd.item_type = x_proc_type
770      and  pd.name = x_proc_name
771      and  pd.begin_date <= to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS')
772      and (pd.end_date is null or
773           pd.end_date > to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS'))
774      and  p.process_item_type = pd.item_type
775      and  p.process_name = pd.name
776      and  p.process_version = pd.version
777      and  a.item_type = p.activity_item_type
778      and  a.name = p.activity_name
779      and  a.begin_date <= to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS')
780      and (a.end_date is null or
781           a.end_date > to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS'))
782      and  a1.item_type = a.item_type
783      and  a1.name = a.name
784      and  a1.version = a.version
785      and  a1.language = userenv('LANG')
786      and  ait.name = a.item_type
787      and  s.item_type (+) = x_item_type
788      and  s.item_key (+) = x_item_key
789      and  s.process_activity (+) = p.instance_id
790      and art.lookup_type(+) = a.result_type
791      and l1.lookup_code (+) = a.type
792      and l1.lookup_type (+) = 'WFENG_ACTIVITY_TYPE'
793      and l2.lookup_code (+) = s.activity_status
794      and l2.lookup_type (+) = 'WFENG_STATUS'
795      and s.notification_id = n.notification_id(+);
796 
797   cursor act_result(act_result_type varchar2) is
798     select l.lookup_code,
799            l.meaning
800     from wf_lookups l
801     where l.lookup_type = act_result_type;
802 
803   cursor act_attr(act_item_type varchar2, act_name varchar2,
804                   act_version number, act_instance_id number) is
805     select aa.name,
806            aa.display_name,
807            aa.type,
808            aa.format,
809            decode(aa.type,
810                   'NUMBER', to_char(aav.number_value),
811                   'DATE', to_char(aav.date_value, nvl(aa.format,
812                                                     'DD-MON-YYYY HH24:MI:SS')),
813                   'LOOKUP', wf_core.activity_result(aa.format, aav.text_value),
814                   aav.text_value) value
815     from wf_activity_attributes_vl aa,
816          wf_activity_attr_values aav
817     where aa.activity_item_type = act_item_type
818     and   aa.activity_name = act_name
819     and   aa.activity_version = act_version
820     and   aav.process_activity_id = act_instance_id
821     and   aa.name = aav.name
822     and   aa.name not like '#%';
823 
824   cursor not_attr(nid pls_integer) is
825     select n.notification_id,
826            n.recipient_role,
827            n.status,
828            to_char(n.due_date) || ' ' || to_char(n.due_date, 'HH24:MI:SS')
829             due_date,
830            to_char(n.begin_date) || ' ' || to_char(n.begin_date, 'HH24:MI:SS')
831             begin_date,
832            to_char(n.end_date) || ' ' || to_char(n.end_date, 'HH24:MI:SS')
833             end_date,
834            ma.name,
835            ma.display_name,
836            ma.type,
837            ma.format,
838            decode(ma.type,
839                   'NUMBER', to_char(na.number_value),
840                   'DATE', to_char(na.date_value, nvl(ma.format,
841                                                     'DD-MON-YYYY HH24:MI:SS')),
842                   'LOOKUP', wf_core.activity_result(ma.format, na.text_value),
843                   na.text_value) value
844     from wf_notifications n,
845          wf_notification_attributes na,
846          wf_message_attributes_vl ma
847     where n.group_id = nid
848     and   n.message_type = ma.message_type
849     and   n.message_name = ma.message_name
850     and   ma.name = na.name
851     and   na.notification_id = n.notification_id;
852 
853 
854   prc proc_info%rowtype;
855 
856   tokenized_mesg  VARCHAR2(10000);
857   tokenized_stack  VARCHAR2(10000);
858   /* JWSMITH, BUG1708024M CHANGED tokenized_value VARCHAR2(2100) */
859   /* to tokenized_value  VARCHAR2(4000) */
860   tokenized_value  VARCHAR2(4000);
861   tokenized_description  VARCHAR2(1000);
862   return_token  VARCHAR2(9) := '@#@';
863   l_tab varchar2(30) := wf_core.tab;
864 
865 begin
866   open proc_info;
867 
868   loop
869    fetch proc_info into prc;
870    exit when proc_info%notfound;
871 
872    -- The htp.p proc does not handle returns well, replace them
873    -- with the value <RET_TOK>, will resubstitute later on.
874 --   tokenized_mesg := substr((replace (prc.error_message, wf_core.newline, return_token)), 1, 220);
875    tokenized_mesg := replace (prc.error_message, wf_core.newline,
876                               return_token);
877    tokenized_stack := replace (prc.error_stack, wf_core.newline,
878                                return_token);
879    tokenized_description := replace (prc.description, wf_core.newline,
880                                      return_token);
881 
882   -- The format we use is to list all the fields,
883   -- delineated by tabs (wf_core.tab).  We place a space after each
884   -- field, in case the value returned is null (then the space
885   -- acts as a 'placeholder'), making sure to strip those spaces
886   -- off when we read this into our javacode.
887 
888 
889    appendData('ACTIVITY:' || prc.item_type   || ' ' || l_tab
890                      || prc.item_type_disp      || ' ' || l_tab
891                      || prc.name        || ' ' || l_tab
892                      || prc.display_name        || ' ' || l_tab
893                      || tokenized_description   || ' ' || l_tab
894                      || prc.type        || ' ' || l_tab
895                      || prc.type_disp   || ' ' || l_tab
896                      || prc.function    || ' ' || l_tab
897                      || prc.result_type || ' ' || l_tab
898                      || prc.result_type_disp    || ' ' || l_tab
899                      || prc.cost        || ' ' || l_tab
900                      || prc.rerun       || ' ' || l_tab
901                      || prc.icon_name   || ' ' || l_tab
902                      || prc.message     || ' ' || l_tab
903                      || prc.due_date|| ' ' || l_tab
904                      || prc.error_process       || ' ' || l_tab
905                      || prc.expand_role || ' ' || l_tab
906                      || prc.instance_id || ' ' || l_tab
907                      || prc.instance_label || ' ' || l_tab
908                      || prc.timeout || ' ' || l_tab
909                      || prc.start_end   || ' ' || l_tab
910                      || prc.default_result      || ' ' || l_tab
911                      || prc.activity_usage_result       || ' ' || l_tab
912                      || prc.icon_geometry       || ' ' || l_tab
913                      || prc.perform_role        || ' ' || l_tab
914                      || prc.user_comment        || ' ' || l_tab
915                      || prc.activity_status     || ' ' || l_tab
916                      || prc.activity_status_disp        || ' ' || l_tab
917                      || prc.activity_result_code        || ' ' || l_tab
918                      || prc.activity_status_result      || ' ' || l_tab
919                      || prc.assigned_user       || ' ' || l_tab
920                      || prc.rolename    || ' ' || l_tab
921                      || prc.notification_id     || ' ' || l_tab
922                      || prc.begin_date  || ' ' || l_tab
923                      || prc.end_date    || ' ' || l_tab
924                      || prc.execution_time      || ' ' || l_tab
925                      || prc.error_name  || ' ' || l_tab
926                      || prc.recipient_role      || ' ' || l_tab
927                      || prc.not_status  || ' ' || l_tab
928                      || prc.not_due_date        || ' ' || l_tab
929                      || prc.not_begin_date      || ' ' || l_tab
930                      || prc.not_end_date        || ' ' || l_tab
931                      || tokenized_mesg  || ' ' || l_tab
932                      || tokenized_stack || ' ');
933 
934     if (prc.result_type <> '*') then
935       for code in act_result(prc.result_type) loop
936         appendData('ACTIVITY_RESULT:' || code.lookup_code || ' ' || l_tab
937                                  || code.meaning || ' ');
938 
939       end loop;
940     end if;
941 
942     -- Fetch activity attributes
943     for attr_value in act_attr(prc.item_type, prc.name, prc.version, prc.instance_id) loop
944       if ( (upper(substr(x_admin_mode, 1, 1)) = 'Y') or
945            (substr(attr_value.name, 1, 1) <> '.') ) then
946       tokenized_value := replace (attr_value.value, wf_core.newline,
947                                   return_token);
948 
949       appendData('ACTIVITY_ATTRIBUTE:' || attr_value.name          || ' ' || l_tab
950                                   || attr_value.display_name  || ' ' || l_tab
951                                   || attr_value.type          || ' ' || l_tab
952                                   || attr_value.format        || ' ' || l_tab
953                                   || tokenized_value         || ' ');
954       end if;
955     end loop;
956 
957     if (prc.notification_id is not null) then
958       -- Fetch notification attributes
959       for not_attr_value in not_attr(prc.notification_id) loop
960         if ( (upper(substr(x_admin_mode, 1, 1)) = 'Y') or
961            (substr(not_attr_value.name, 1, 1) <> '.') ) then
962         tokenized_value := replace (not_attr_value.value,
963                                     wf_core.newline, return_token);
964         appendData('NOTIFICATION_ATTRIBUTE:'
965                          || not_attr_value.notification_id || ' ' || l_tab
966                          || not_attr_value.recipient_role   || ' ' || l_tab
967                          || not_attr_value.status   || ' ' || l_tab
968                          || not_attr_value.due_date   || ' ' || l_tab
969                          || not_attr_value.begin_date   || ' ' || l_tab
970                          || not_attr_value.end_date   || ' ' || l_tab
971                          || not_attr_value.name      || ' ' || l_tab
972                          || not_attr_value.display_name || ' ' || l_tab
973                          || not_attr_value.type || ' ' || l_tab
974                          || not_attr_value.format    || ' ' || l_tab
975                          || tokenized_value        || ' ');
976         end if;
977       end loop;
978     end if;
979 
980 
981   end loop;
982 
983 end GetProcessInfo;
984 
985 
986 -- GetTransitionInfo (Private Procedure)
987 --   Gets the transition information for each process activity.
988 -- IN
989 --   x_item_type
990 --   x_item_key
991 --   x_proc_name
992 --   x_proc_type
993 --   x_begin_date
994 procedure GetTransitionInfo(
995     x_item_type varchar2,
996     x_item_key varchar2,
997     x_proc_name varchar2,
998     x_proc_type varchar2,
999     x_begin_date varchar2) is
1000 
1001 cursor trans is
1002    select p1.icon_geometry from_icon_geometry,  /* from activity */
1003           p1.instance_id from_instance_id,
1004           t.result_code,                        /* transition info */
1005           decode((wf_core.activity_result(a.result_type, t.result_code)),
1006                  '*', wf_core.translate('DEFAULT'),
1007                  '#ANY', wf_core.translate('WFMON_ANYRESULT'),
1008                  wf_core.activity_result(a.result_type, t.result_code))
1009             activity_result,
1010           t.arrow_geometry,
1011           s.activity_status,            /* transition status */
1012           s.activity_result_code,
1013           l.lookup_code,
1014           p2.icon_geometry to_icon_geometry,    /* to activity */
1015           p2.instance_id to_instance_id
1016    from   wf_activities pd,
1017           wf_process_activities p1,
1018           wf_activities a,
1019           wf_activity_transitions t,
1020           wf_item_activity_statuses s,
1021           wf_lookups l,
1022           wf_process_activities p2
1023    where  pd.item_type = x_proc_type
1024      and  pd.name = x_proc_name
1025      and  pd.begin_date <= to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS')
1026      and (pd.end_date is null or
1027           pd.end_date > to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS'))
1028      and  p1.process_item_type = pd.item_type
1029      and  p1.process_name = pd.name
1030      and  p1.process_version = pd.version
1031      and  a.item_type = p1.activity_item_type
1032      and  a.name = p1.activity_name
1033      and  a.begin_date <= to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS')
1034      and (a.end_date is null or
1035           a.end_date > to_date(x_begin_date, 'DD/MM/YYYY HH24:MI:SS'))
1036      and  t.from_process_activity = p1.instance_id
1037      and  s.item_type (+) = x_item_type
1038      and  s.item_key (+) = x_item_key
1039      and  s.process_activity (+) = p1.instance_id
1040      and  l.lookup_type = 'WFSTD_BOOLEAN'
1041      and ((s.activity_status = 'COMPLETE' and
1042            (t.result_code in (nvl(s.activity_result_code, '#NULL'),
1043                               wf_engine.eng_trans_any) or
1044             t.result_code = wf_engine.eng_trans_default and not exists
1045               (select null from wf_activity_transitions tr
1046                where  tr.from_process_activity = p1.instance_id
1047                and  tr.result_code = nvl(s.activity_result_code, '#NULL'))) and
1048             l.lookup_code = 'T') or
1049           (not (s.activity_status = 'COMPLETE' and
1050            (t.result_code in (nvl(s.activity_result_code, '#NULL'),
1051                               wf_engine.eng_trans_any) or
1052             t.result_code = wf_engine.eng_trans_default and not exists
1053                (select null from wf_activity_transitions tr
1054                 where tr.from_process_activity = p1.instance_id
1055                 and  tr.result_code = nvl(s.activity_result_code, '#NULL')))) or
1056             s.activity_status is null) and
1057            l.lookup_code = 'F')
1058      and  p2.instance_id = t.to_process_activity;
1059 
1060   tr trans%rowtype;
1061   l_tab varchar2(30) := wf_core.tab;
1062 
1063 begin
1064   open trans;
1065   loop
1066    fetch trans into tr;
1067    exit when trans%notfound;
1068 
1069    appendData('TRANSITION:'|| tr.from_icon_geometry  || ' ' || l_tab
1070                       || tr.from_instance_id    || ' ' || l_tab
1071                       || tr.result_code || ' ' || l_tab
1072                       || tr.activity_result     || ' ' || l_tab
1073                       || tr.arrow_geometry      || ' ' || l_tab
1074                       || tr.activity_status     || ' ' || l_tab
1075                       || tr.activity_result_code        || ' ' || l_tab
1076                       || tr.lookup_code || ' ' || l_tab
1077                       || tr.to_icon_geometry    || ' ' || l_tab
1078                       || tr.to_instance_id || ' ');
1079 
1080   end loop;
1081 
1082 end GetTransitionInfo;
1083 
1084 -- GetResource
1085 --   Called by Monitor.class.
1086 --   Printf's all the role information back to the
1087 --   Monitor applet, which reads them a line at a time, interpreting them.
1088 -- IN
1089 --  x_filter
1090 function GetResource(x_restype varchar2,
1091                       x_resname varchar2) return varchar2 is
1092 
1093   res_name varchar2(30);
1094   res_text varchar2(2000);
1095   res_id number;
1096   username varchar2(320);
1097   l_tab varchar2(30);
1098 begin
1099   l_data := '';
1100   gUseClob := false;
1101   --wfa_sec.validate_only := TRUE;
1102   --wfa_sec.GetSession(username);
1103 
1104   l_tab := wf_core.tab;
1105 
1106   begin
1107 
1108   select NAME, TEXT, ID
1109   into res_name, res_text, res_id
1110   from WF_RESOURCES
1111   where TYPE = x_restype
1112   and NAME = x_resname
1113   and NAME <> 'WF_ADMIN_ROLE'
1114   and LANGUAGE = userenv('LANG');
1115 
1116   exception
1117   when OTHERS then
1118     res_name := x_resname;
1119     res_text := x_resname;
1120     res_id := 999;
1121   end;
1122 
1123   appendData('RESOURCE:'|| res_name  || ' ' || l_tab
1124                    || res_text || ' ' || l_tab
1125                    || to_char(res_id) || ' ');
1126   return l_data;
1127 end GetResource;
1128 
1129 -- GetResources
1130 --   Called by Monitor.class.
1131 --   Printf's all the role information back to the
1132 --   Monitor applet, which reads them a line at a time, interpreting them.
1133 -- IN
1134 --  x_filter
1135 function GetResources(x_restype varchar2,
1136                       x_respattern varchar2) return varchar2 is
1137 
1138   cursor matched_resource is
1139     select NAME, TEXT, ID
1140     from WF_RESOURCES
1141     where TYPE = x_restype
1142     and NAME like x_respattern||'%'
1143     and NAME <> 'WF_ADMIN_ROLE'
1144     and LANGUAGE = userenv('LANG')
1145     order by NAME;
1146 
1147   res_name varchar2(30);
1148   res_text varchar2(2000);
1149   res_id number;
1150   pattern varchar2(30);
1151   username varchar2(320);
1152   l_tab varchar2(30);
1153 begin
1154   gUseClob := false;
1155   l_data := '';
1156   --wfa_sec.validate_only := TRUE;
1157   --wfa_sec.GetSession(username);
1158 
1159   l_tab := wf_core.tab;
1160 
1161   if (x_respattern is null)  then
1162     pattern := '%';
1163   end if;
1164 
1165   for r in matched_resource loop
1166     appendData('RESOURCE:' || r.name || ' ' || l_tab
1167                   || r.text || ' ' || l_tab
1168                   || to_char(r.id) || ' ');
1169 
1170   end loop;
1171   return l_data || NL_CHAR;
1172 end GetResources;
1173 
1174 procedure GetRole(p_titles_only varchar2,
1175                   P_FIND_CRITERIA varchar2) is
1176 
1177     username varchar2(320);
1178 
1179     cursor role(tmpbuf1 varchar2, tmpbuf2 varchar2,
1180              tmpbuf3 varchar2, tmpbuf4 varchar2) is
1181 
1182     select r.name,
1183            r.display_name
1184     from wf_roles r
1185     where display_name not like '~WF_ADHOC-%'
1186     and (display_name like tmpbuf1 or
1187           display_name like tmpbuf2 or
1188           display_name like tmpbuf3 or
1189           display_name like tmpbuf4) and
1190           upper(display_name) like upper(P_FIND_CRITERIA)||'%'
1191     order by r.display_name;
1192     first_char varchar2(1) := null;
1193     second_char varchar2(1) := null;
1194     tmpbuf1 varchar2(10);
1195     tmpbuf2 varchar2(10);
1196     tmpbuf3 varchar2(10);
1197     tmpbuf4 varchar2(10);
1198     cnt number;
1199 begin
1200    -- Authenticate user
1201  --  wfa_sec.GetSession(username);
1202 
1203   if (P_FIND_CRITERIA is null)  then
1204     first_char := null;
1205     second_char := null;
1206   else
1207     first_char := substr(P_FIND_CRITERIA, 1, 1);
1208     second_char := substr(P_FIND_CRITERIA, 2, 1);
1209   end if;
1210   tmpbuf1 := upper(first_char)||upper(second_char)||'%';
1211   tmpbuf2 := upper(first_char)||lower(second_char)||'%';
1212   tmpbuf3 := lower(first_char)||upper(second_char)||'%';
1213   tmpbuf4 := lower(first_char)||lower(second_char)||'%';
1214   select count(*) into cnt
1215   from wf_roles
1216   where display_name not like '~WF_ADHOC-%'
1217   and (display_name like tmpbuf1 or
1218        display_name like tmpbuf2 or
1219        display_name like tmpbuf3 or
1220        display_name like tmpbuf4) and
1221        upper(display_name) like upper(P_FIND_CRITERIA) ||'%';
1222   appendData(wf_core.translate('WFMON_REASSIGN_TO'));
1223   appendData('2');
1224   appendData(to_char(cnt));
1225   appendData(wf_core.translate('WFITD_ATTR_TYPE_ROLE'));
1226   appendData('50');
1227   appendData(wf_core.translate('WFITD_INTERNAL_NAME'));
1228   appendData('50');
1229   if (upper(substr(p_titles_only, 1, 1)) <> 'Y') then
1230   for r in role(tmpbuf1, tmpbuf2, tmpbuf3, tmpbuf4) loop
1231     appendData(r.display_name);
1232     appendData(r.name);
1233   end loop;
1234   end if;
1235 end GetRole;
1236 
1237 -- GetProcess
1238 --   Called by Monitor.class.
1239 --   Printf's all the information about the workflow objects back to the
1240 --   Monitor applet, which reads them a line at a time, interpreting them.
1241 function GetProcess(
1242     x_item_type varchar2,
1243     x_item_key  varchar2,
1244     x_admin_mode varchar2,
1245     x_access_key varchar2,
1246     x_proc_name varchar2,
1247     x_proc_type varchar2) return clob is
1248 
1249   cursor role is
1250     select r.name,
1251            r.display_name
1252     from wf_roles r
1253     order by r.display_name;
1254 
1255 
1256  username varchar2(320);
1257  rt_activity varchar2(30);
1258  rt_activity_version pls_integer;
1259  bg_date date;
1260  ed_date date;
1261  ukey varchar2(240);
1262  owner varchar2(320);
1263  parent_activity varchar2(30);
1264  l_tab varchar2(30);
1265 begin
1266   l_tab := wf_core.tab;
1267   l_data := '';
1268   gUseClob := false; --init for error msgs only
1269 
1270   /*
1271   ** Hide any session creation issues for now and depend on the
1272   ** access key to prevent a user from running this function without
1273   ** logging in.
1274   */
1275   /*
1276 begin
1277      -- set the validate_only flag to true so you don't throw up the login
1278      -- page and you have a chance to check the access key.
1279      wfa_sec.validate_only := TRUE;
1280 
1281      wfa_sec.GetSession(username);
1282 
1283      exception
1284        when others then
1285            -- If AccessKeyCheck will return "ERROR" directly if failed
1286            if (not(AccessKeyCheck(x_item_type, x_item_key, x_admin_mode,
1287                 x_access_key))) then
1288 
1289                appendData(wf_core.translate('WRONG_ACCESS_KEY'));
1290 
1291                return l_data;
1292 
1293            end if;
1294   end;
1295 */
1296   begin
1297     select root_activity,
1298            root_activity_version,
1299            begin_date,
1300            end_date,
1301            user_key,
1302            owner_role
1303     into rt_activity,
1304          rt_activity_version,
1305          bg_date,
1306          ed_date,
1307          ukey,
1308          owner
1309     from wf_items
1310     where item_type = x_item_type
1311     and item_key = x_item_key;
1312 
1313     exception
1314       when NO_DATA_FOUND then
1315         appendData(wf_core.translate('WRONG_TYPE_OR_KEY'));
1316         return l_data;
1317       when OTHERS then
1318         appendData(wf_core.translate('ERROR'));
1319         return l_data;
1320   end;
1321   /* Set to useClob here */
1322   gUseClob := true;
1323   -- Otherwise, we can continue our work here
1324   appendData('ITEM:' || owner|| ' ' || l_tab
1325                 || ukey || ' ' || l_tab
1326                 || bg_date || ' ' || l_tab
1327                 || ed_date || ' ');
1328   if (x_proc_name is null) then
1329 
1330     GetRootInfo(x_item_type, x_item_key,
1331                   'ROOT', rt_activity, x_item_type,
1332                   rt_activity_version,
1333                   to_char(bg_date, 'DD/MM/YYYY HH24:MI:SS'));
1334 
1335     GetItemInfo (x_item_type, x_item_key, x_admin_mode);
1336 
1337     GetProcessInfo(x_item_type, x_item_key,
1338                      rt_activity, x_item_type,
1339                      to_char(bg_date, 'DD/MM/YYYY HH24:MI:SS'), x_admin_mode);
1340 
1341     GetTransitionInfo(x_item_type, x_item_key,
1342                         rt_activity, x_item_type,
1343                         to_char(bg_date, 'DD/MM/YYYY HH24:MI:SS'));
1344 
1345   else
1346 
1347     GetProcessInfo(x_item_type, x_item_key,
1348                      x_proc_name, x_proc_type,
1349                      to_char(bg_date, 'DD/MM/YYYY HH24:MI:SS'), x_admin_mode);
1350 
1351     GetTransitionInfo(x_item_type, x_item_key,
1352                         x_proc_name, x_proc_type,
1353                         to_char(bg_date, 'DD/MM/YYYY HH24:MI:SS'));
1354 
1355   end if;
1356   --resetting global variables here.This api is currently the only point of use.
1357   gUseClob := false;
1358   gClobInit := false;
1359   return gClob;
1360 
1361 end GetProcess;
1362 
1363 function GetUrl (x_agent in varchar2,
1364                  x_item_type in varchar2,
1365                  x_item_key in varchar2,
1366                  x_admin_mode in varchar2) return varchar2 is
1367 
1368 begin
1369 
1370   return (GetDiagramUrl(x_agent,x_item_type, x_item_key, x_admin_mode));
1371   exception
1372     when others then
1373      raise;
1374 end;
1375 
1376 
1377 function GetDiagramURL (x_agent in varchar2,
1378                         x_item_type in varchar2,
1379                         x_item_key in varchar2,
1380                         x_admin_mode in varchar2) return varchar2 is
1381 
1382   l_url varchar2(4000);
1383   l_adminMode varchar2(2048);
1384   l_accessKey varchar2(2048);
1385   l_regionToDisplay varchar2(30);
1386   l_itemType varchar2(2000);
1387   l_itemKey varchar2(2000);
1388   l_installType varchar2(30);
1389 
1390   access_key varchar2(2000);
1391   l_item_key varchar2(30);
1392   xnls_lang varchar2(60);
1393 
1394 begin
1395   l_regionToDisplay := 'WF_G_MONITOR_DIAGRAM_PAGE';
1396   -- vbhatia - 06/09/03
1397   -- check to see if the current context is APPS context or Standalone context
1398   -- if APPS, then redirect to OA Fwk page
1399   -- if Standalone, then redirect to a PL/SQL Web toolkit page (as was originally done)
1400   l_installType := WF_CORE.Translate('WF_INSTALL');
1401 
1402   if l_installType = 'EMBEDDED' then    -- APPS context
1403 
1404     --
1405     -- Encrypt all parameters.
1406     --
1407     l_accessKey := getAccessKey(x_item_type, x_item_key, x_admin_mode);
1408     l_accessKey := icx_call.encrypt(l_accessKey);
1409     l_adminMode := icx_call.encrypt(x_admin_mode);
1410     l_itemType := icx_call.encrypt(x_item_type);
1411     l_itemKey := icx_call.encrypt(x_item_key);
1412     getFwkMonitorUrl(l_regionToDisplay, l_accessKey, l_adminMode, l_itemType, l_itemKey, l_url);
1413     return l_url;
1414 
1415   else          -- Standalone context
1416 
1417     access_key := GetAccessKey(x_item_type, x_item_key, x_admin_mode);
1418 
1419     select replace(nls_language,' ','%20')
1420     into xnls_lang
1421     from wf_languages
1422     where code=userenv('LANG');
1423 
1424     return(x_agent||'/wf_monitor.html'||
1425            '?'||'x_item_type=' ||wfa_html.conv_special_url_chars(x_item_type)||
1426            '&'||'x_item_key='  ||wfa_html.conv_special_url_chars(x_item_key)||
1427            '&'||'x_admin_mode='||x_admin_mode||
1428            '&'||'x_access_key='||access_key||
1429            '&'||'x_nls_lang='||xnls_lang);
1430 
1431   end if;
1432 
1433   exception
1434     when others then
1435      raise;
1436 end;
1437 
1438 -- vbhatia - 06/09/03
1439 -- Procedure to build a URL to access Status Monitor History, Diagram or
1440 -- Responses pages.
1441 PROCEDURE buildMonitorUrl (akRegionCode in varchar2 default null,
1442                            wa in varchar2 default null,
1443                            wm in varchar2 default null,
1444                            itemType in varchar2 default null,
1445                            itemKey in varchar2 default null,
1446                            ntfId in varchar2 default null) is
1447 
1448   l_session_id number;
1449   l_validate boolean;
1450   l_url varchar2(4000);
1451   l_dbc varchar2(240);
1452   l_language_code varchar2(30);
1453   l_transaction_id number;
1454   l_accessKey varchar2(2000);
1455   l_adminMode varchar2(2000);
1456   l_itemType varchar2(2000);
1457   l_itemKey varchar2(2000);
1458   username varchar2(320);
1459 
1460 begin
1461 
1462   -- set the validate_only flag to true so you don't hold up the page
1463   wfa_sec.validate_only := TRUE;
1464   wfa_sec.GetSession(username);
1465 
1466   -- Converting to use the new FND_SESSION_MANAGEMENT model
1467   if (FND_SESSION_MANAGEMENT.g_transaction_id = -1) then
1468     l_transaction_id := FND_SESSION_MANAGEMENT.NewTransactionId;
1469   else
1470     l_transaction_id := FND_SESSION_MANAGEMENT.g_transaction_id;
1471   end if;
1472 
1473   -- Get the framework agent and make sure it always has a trailing slash.
1474 
1475   l_url := fnd_web_config.trail_slash(fnd_profile.value('APPS_FRAMEWORK_AGENT'));
1476 
1477   fnd_profile.get(name => 'APPS_DATABASE_ID',
1478                    val => l_dbc);
1479 
1480   if l_dbc is null
1481   then
1482     l_dbc := FND_WEB_CONFIG.DATABASE_ID;
1483   end if;
1484 
1485   --
1486   -- Encode all the parameters
1487   --
1488 
1489   l_accessKey := wfa_html.conv_special_url_chars(wa);
1490 
1491   l_adminMode := wfa_html.conv_special_url_chars(wm);
1492 
1493   l_itemType := wfa_html.conv_special_url_chars(itemType);
1494 
1495   l_itemKey := wfa_html.conv_special_url_chars(itemKey);
1496 
1497   l_url := l_url||'OA_HTML/';
1498 
1499   l_url := l_url||'OA.jsp?'||'akRegionCode='||akRegionCode||
1500                   '&'||'akRegionApplicationId=0'||
1501                   '&'||'dbc='||l_dbc||
1502                   '&'||'transactionid='||l_transaction_id||
1503                   '&'||'wa='||l_accessKey||
1504                   '&'||'wm='||l_adminMode||
1505                   '&'||'itemType='||l_itemType||
1506                   '&'||'itemKey='||l_itemKey||
1507                   '&'||'addBreadCrumb=Y'||
1508                   '&'||'retainAM=Y';
1509 
1510 owa_util.redirect_url(l_url);
1511 
1512 end buildMonitorUrl;
1513 
1514 /** Returns Monitor URL constructed in the RF.jsp format. For invalid function the
1515  * URL returned will be NULL
1516  */
1517 PROCEDURE getFWKMonitorUrl(akRegionCode in varchar2 default null,
1518                            wa in varchar2 default null,
1519                            wm in varchar2 default null,
1520                            itemType in varchar2 default null,
1521                            itemKey in varchar2 default null,
1522                            l_lurl out nocopy varchar2) is
1523 
1524   l_function varchar2(4000);
1525   l_params varchar2(4000);
1526   functionId number;
1527 
1528 begin
1529 
1530   l_function := getFunctionForRegion(akRegionCode);
1531   if(l_function is not null) then
1532     functionId := fnd_function.get_function_id (l_function);
1533     l_params := 'itemType='||itemType||
1534               '&'||'itemKey='||itemkey||
1535               '&'||'wa='||wa||
1536               '&'||'wm='||wm||
1537               '&'||'fExt=X';
1538     l_lurl := fnd_run_function.get_run_function_url( p_function_id => functionId,
1539                                 p_resp_appl_id => -1,
1540                                 p_resp_id => -1,
1541                                 p_security_group_id => null,
1542                                 p_parameters => l_params,
1543                                 p_encryptParameters => false);
1544 
1545   end if;
1546 end getFWKMonitorUrl;
1547 
1548 --Get the function name for a given region name
1549 function getFunctionForRegion(akRegionCode in varchar2)
1550          return varchar2 is
1551   l_function varchar2(4000);
1552 begin
1553 
1554   if(akRegionCode = 'WF_G_MONITOR_DIAGRAM_PAGE') then
1555          l_function := 'WF_G_DIAGRAM';
1556   elsif(akRegionCode = 'WF_G_MONITOR_HISTORY_PAGE') then
1557          l_function := 'WF_G_ACTIVITIES';
1558   elsif(akRegionCode = 'WF_G_MONITOR_RESPONSES_PAGE') then
1559          l_function := 'WF_G_RESPONSES';
1560   elsif(akRegionCode = 'WF_G_MON_WORKFLOW_DETAILS_PAGE') then
1561          l_function := 'WF_G_WORKFLOW_DETAILS';
1562   end if;
1563   return l_function;
1564 
1565 end getFunctionForRegion;
1566 
1567 
1568 /**Gets old Status monitor URL's of the form
1569    host:port/pls/<sid>/wf_monitor.buildMonitorUrl?<params>
1570    and converts it to a URL of the form RF.jsp so that the corresponding
1571    Status monitor function(digram, activities etc) gets directly accessed
1572    without the using PL/SQL catridge.Returns following error code
1573    0 - Success
1574    1 - failure
1575   */
1576 PROCEDURE updateToFWKMonitorUrl(oldUrl in varchar2,
1577                                newUrl out nocopy varchar2,
1578                                errorCode out nocopy pls_integer) is
1579  region varchar2(4000);
1580  wm     varchar2(4000);
1581  wa     varchar2(4000);
1582  itemType varchar2(4000);
1583  itemKey varchar2(4000);
1584  l_oldUrl varchar2(4000);
1585 begin
1586    errorCode := 1;
1587    l_oldUrl := oldUrl;
1588    parseUrlForParams('akRegionCode', l_oldUrl, region);
1589    parseUrlForParams('wa', l_oldUrl, wa);
1590    parseUrlForParams('wm', l_oldUrl, wm);
1591    parseUrlForParams('itemType', l_oldUrl, itemType);
1592    parseUrlForParams('itemKey', l_oldUrl, itemKey);
1593    getFwkMonitorUrl(region, wa, wm, itemType, itemKey, newUrl);
1594    if (newUrl is not null) then
1595       errorCode := 0; --success
1596    end if;
1597 end updateToFWKMonitorUrl;
1598 
1599 PROCEDURE parseUrlForParams(paramName in varchar2,
1600                             l_oldUrl in varchar2,
1601                             paramValue out nocopy varchar2) is
1602 startPos Number;
1603 endPos Number;
1604 keyPos Number;
1605 begin
1606   keyPos := instr(l_oldUrl,paramName);
1607   if keyPos = 0 then
1608      paramValue := '';
1609      return;
1610   else
1611      startPos := instr(l_oldUrl,'=',keyPos)+1;
1612      endPos := instr(l_oldUrl,'&',startPos);
1613      if endPos = 0 then     -- No '&', use remaining string as value
1614          endPos := length(l_oldUrl)+1;
1615      end if;
1616      paramValue := substr(l_oldUrl,startPos,endPos-startPos);
1617   end if;
1618 end parseUrlForParams;
1619 
1620 function GetAdvancedEnvelopeURL (
1621   x_agent               IN VARCHAR2,
1622   x_item_type           IN VARCHAR2,
1623   x_item_key            IN VARCHAR2,
1624   x_admin_mode          IN VARCHAR2,
1625   x_options             IN VARCHAR2
1626 ) return varchar2 is
1627 
1628   l_url varchar2(4000);
1629   l_adminMode varchar2(2048);
1630   l_accessKey varchar2(2048);
1631   l_regionToDisplay varchar2(30) := 'WF_G_MONITOR_HISTORY_PAGE';
1632   l_itemType varchar2(2000);
1633   l_itemKey varchar2(2000);
1634   l_installType varchar2(30);
1635 
1636   access_key      varchar2(2000);
1637   xnls_lang       varchar2(60);
1638 
1639 begin
1640 
1641   -- vbhatia - 06/09/03
1642   -- check to see if the current context is APPS context or Standalone context
1643   -- if APPS, then redirect to OA Fwk page
1644   -- if Standalone, then redirect to a PL/SQL Web toolkit page (as was originally done)
1645 
1646   l_installType := WF_CORE.Translate('WF_INSTALL');
1647 
1648   if l_installType = 'EMBEDDED' then    -- APPS context
1649 
1650     --
1651     -- Encrypt all parameters.
1652     --
1653     l_accessKey := getAccessKey(x_item_type, x_item_key, x_admin_mode);
1654     l_accessKey := icx_call.encrypt(l_accessKey);
1655     l_adminMode := icx_call.encrypt(x_admin_mode);
1656     l_itemType := icx_call.encrypt(x_item_type);
1657     l_itemKey := icx_call.encrypt(x_item_key);
1658     getFwkMonitorUrl(l_regionToDisplay, l_accessKey, l_adminMode, l_itemType, l_itemKey, l_url);
1659 
1660     return l_url;
1661 
1662   else     -- Standalone context
1663 
1664     access_key := GetAccessKey(x_item_type, x_item_key, x_admin_mode);
1665 
1666     select replace(nls_language,' ','%20')
1667     into xnls_lang
1668     from wf_languages
1669     where code=userenv('LANG');
1670 
1671     --
1672     if x_options is not null then
1673 
1674       return(x_agent||'/wf_monitor.envelope'||
1675             '?'||'x_item_type=' ||wfa_html.conv_special_url_chars(x_item_type)||
1676             '&'||'x_item_key='  ||wfa_html.conv_special_url_chars(x_item_key)||
1677             '&'||'x_admin_mode='||x_admin_mode||
1678             '&'||'x_access_key='||access_key||
1679             '&'||'x_advanced=TRUE'||
1680             '&'||'x_active=ACTIVE'||
1681             '&'||'x_complete=COMPLETE&x_error=ERROR'||
1682             '&'||'x_suspend=SUSPEND&x_proc_func=Y'||
1683             '&'||'x_note_resp=Y&x_note_noresp=Y'||
1684             '&'||'x_func_std=Y&x_event=Y&x_sort_column=STARTDATE'||
1685             '&'||'x_sort_order=ASC'||
1686             '&'||'x_nls_lang='||xnls_lang);
1687 
1688     else
1689 
1690       return(x_agent||'/wf_monitor.envelope'||
1691             '?'||'x_item_type=' ||wfa_html.conv_special_url_chars(x_item_type)||
1692             '&'||'x_item_key='  ||wfa_html.conv_special_url_chars(x_item_key)||
1693             '&'||'x_admin_mode='||x_admin_mode||
1694             '&'||'x_access_key='||access_key||
1695             '&'||'x_advanced=TRUE'||
1696             '&'||'x_nls_lang='||xnls_lang);
1697 
1698     end if;
1699 
1700   end if;
1701 
1702   exception
1703     when others then
1704      raise;
1705 end;
1706 
1707 
1708 
1709 function GetEnvelopeURL (
1710   x_agent               IN VARCHAR2,
1711   x_item_type           IN VARCHAR2,
1712   x_item_key            IN VARCHAR2,
1713   x_admin_mode          IN VARCHAR2
1714 ) return varchar2 is
1715 
1716   l_url varchar2(4000);
1717   l_adminMode varchar2(2048);
1718   l_accessKey varchar2(2048);
1719   l_regionToDisplay varchar2(30) := 'WF_G_MONITOR_RESPONSES_PAGE';
1720   l_itemType varchar2(2000);
1721   l_itemKey varchar2(2000);
1722   l_installType varchar2(30);
1723 
1724   access_key      varchar2(2000);
1725   xnls_lang       varchar2(60);
1726 
1727 begin
1728 
1729   -- vbhatia - 06/09/03
1730   -- check to see if the current context is APPS context or Standalone context
1731   -- if APPS, then redirect to OA Fwk page
1732   -- if Standalone, then redirect to a PL/SQL Web toolkit page (as was originally done)
1733 
1734   l_installType := WF_CORE.Translate('WF_INSTALL');
1735 
1736   if l_installType = 'EMBEDDED' then    -- APPS context
1737 
1738       --
1739     -- Encrypt all parameters.
1740     --
1741     l_accessKey := getAccessKey(x_item_type, x_item_key, x_admin_mode);
1742     l_accessKey := icx_call.encrypt(l_accessKey);
1743     l_adminMode := icx_call.encrypt(x_admin_mode);
1744     l_itemType := icx_call.encrypt(x_item_type);
1745     l_itemKey := icx_call.encrypt(x_item_key);
1746     getFwkMonitorUrl(l_regionToDisplay, l_accessKey, l_adminMode, l_itemType, l_itemKey, l_url);
1747     return l_url;
1748 
1749   else           -- Standalone context
1750 
1751     access_key := GetAccessKey(x_item_type, x_item_key, x_admin_mode);
1752 
1753     select replace(nls_language,' ','%20')
1754     into xnls_lang
1755     from wf_languages
1756     where code=userenv('LANG');
1757 
1758     return(x_agent||'/wf_monitor.envelope'||
1759            '?'||'x_item_type=' ||wfa_html.conv_special_url_chars(x_item_type)||
1760            '&'||'x_item_key='  ||wfa_html.conv_special_url_chars(x_item_key)||
1761            '&'||'x_admin_mode='||x_admin_mode||
1762            '&'||'x_access_key='||access_key||
1763            '&'||'x_advanced=FALSE'||
1764            '&'||'x_nls_lang='||xnls_lang);
1765 
1766   end if;
1767 
1768   exception
1769     when others then
1770      raise;
1771 end;
1772 
1773 
1774 procedure EngApi (api_name in varchar2,
1775                   x_item_type in varchar2,
1776                   x_item_key in varchar2,
1777                   x_access_key in varchar2,
1778                   third_arg in varchar2,
1779                   forth_arg in varchar2,
1780                   fifth_arg in varchar2) is
1781 
1782   username varchar2(320);
1783 
1784 begin
1785 
1786   -- Security check
1787   if (x_access_key <> GetAccessKey(x_item_type, x_item_key, 'Y')) then
1788     htp.p('ENG_API_ACCESS_DENIED:');
1789   end if;
1790 
1791   begin
1792     -- Validate the session that comes from monitor
1793     wfa_sec.validate_only := TRUE;
1794     wfa_sec.GetSession(username);
1795   exception
1796     when OTHERS then
1797       null;      -- ignore any error
1798   end;
1799 
1800 
1801   if (api_name = 'AbortProcess') then
1802     Wf_Engine.AbortProcess(x_item_type, x_item_key, third_arg, forth_arg);
1803 
1804   elsif (api_name = 'SuspendProcess') then
1805     Wf_Engine.SuspendProcess(x_item_type, x_item_key, third_arg);
1806 
1807   elsif (api_name = 'ResumeProcess') then
1808     Wf_Engine.ResumeProcess(x_item_type, x_item_key, third_arg);
1809 
1810   elsif (api_name = 'AssignActivity') then
1811     Wf_Engine.AssignActivity(x_item_type, x_item_key, third_arg, forth_arg);
1812 
1813   elsif (api_name = 'HandleError') then
1814     Wf_Engine.HandleError(x_item_type, x_item_key, third_arg, forth_arg,
1815                           fifth_arg);
1816 
1817   elsif (api_name = 'SetItemAttrText') then
1818     Wf_Engine.SetItemAttrText(x_item_type, x_item_key, third_arg, forth_arg);
1819   end if;
1820 
1821   htp.p('ENG_API_SUCC:');
1822   return;
1823 
1824 exception
1825    when others then
1826         Error;
1827         return;
1828 end;
1829 
1830 
1831  /**********************************************************************
1832   *
1833   *  Find window procedures
1834   *
1835   **********************************************************************/
1836 
1837 -- Show
1838 --   This is to be called by forms when people want to link to workflow.
1839 --   If nothing to be passed, this will take you to Find_Instance().
1840 --   Otherwise, this will take you to the envelope() page.
1841 procedure Show (
1842   item_type              VARCHAR2,
1843   item_key               VARCHAR2,
1844   admin_mode             VARCHAR2,
1845   access_key             VARCHAR2) is
1846 begin
1847   if (item_type is null and item_key is null) then
1848     wf_monitor.Find_Instance();
1849   else
1850     wf_monitor.Envelope(item_type, item_key, admin_mode, access_key);
1851   end if;
1852 end ;
1853 
1854 
1855 --
1856 -- Find_Instance
1857 --   Query page to find processes
1858 --
1859 -- MODIFICATION LOG:
1860 -- 06-JUN-2001 JWSMITH BUG 1819232 - added alt attrib for the following gifs
1861 --             FNDIACTV,FNDIDONE,FNDIYLWL, FNDIREDL for ADA ENHANCEMENT
1862 procedure Find_Instance
1863 is
1864  begin
1865        null;
1866  end;
1867 
1868 
1869 -- createenvsortlink (PRIVATE)
1870 --   Print a single column header in Envelope page
1871 /*
1872 ** x_cur_sort_column     = Current column that the activity list is sorted by
1873 ** x_cur_sort_order      = Is the list currently sorted ASC or DESC
1874 ** x_sort_column         = What is the current column header to display
1875 ** x_advanced            = Are you in advanced mode
1876 ** x_column_title        = What is the display text for the column header
1877 ** x_column_title_not_adv= What is the display text for the column header
1878 **                         when youre not in advanced mode (Done vs Status)
1879 ** x_show_when_not_adv   = Do you display this column if youre not in
1880 **                         advanced mode (Parent_activity)
1881 ** x_standard_url        = The fixed set of parameters for the envelope
1882 **                         routine
1883 */
1884 procedure createenvsortlink (
1885 
1886 x_cur_sort_column        VARCHAR2,
1887 x_cur_sort_order         VARCHAR2,
1888 x_sort_column            VARCHAR2,
1889 x_advanced               VARCHAR2,
1890 x_column_title           VARCHAR2,
1891 x_column_title_not_adv   VARCHAR2,
1892 x_show_when_not_adv      BOOLEAN,
1893 x_standard_url           VARCHAR2) IS
1894 
1895 BEGIN
1896 
1897    /*
1898    ** If youre supposed to show this column when youre in advanced mode
1899    ** or youre only supposed to show it in advanced mode and you're in
1900    ** advanced mode then determine how to draw the column title.
1901    */
1902    IF (x_show_when_not_adv = TRUE OR
1903         (x_show_when_not_adv = FALSE AND
1904            x_advanced IN  ('FIRST', 'TRUE'))) THEN
1905 
1906       /*
1907       ** If the current column to display matches the current sort column
1908       ** and the current order is ascending and youre in advanced mode
1909       ** then show the column header as a soft link with 'Header*'to resort
1910       ** the list DESC
1911       */
1912       IF (NVL(x_cur_sort_column, 'UNSET') = x_sort_column  AND
1913            NVL(x_cur_sort_order, 'ASC') = 'ASC' AND
1914                 x_advanced IN ('FIRST', 'TRUE')) THEN
1915 
1916              htp.tableHeader(
1917                 cvalue=>'<A HREF="'||x_standard_url||
1918                      '&x_sort_column='||x_sort_column||
1919                      '&x_sort_order='||'DESC'||
1920                      '" onMouseOver="window.status='||''''||
1921       /* Token and text controlled by us */
1922       /* BINDVAR_SCAN_IGNORE[2] */
1923                      wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFMON_REVERSE_SORT_PROMPT'))||' '||
1924                      x_column_title||''''||
1925                      '; return true"'||
1926                      ' TARGET="_top">'||
1927                      '<font color=#FFFFFF>'||x_column_title||'*'||'</font>'||
1928                      '</A>',
1929                 calign=>'Center');
1930 
1931       /*
1932       ** If the current column to display matches the current sort column
1933       ** and the current order is descending and youre in advanced mode
1934       ** then show the column header as a soft link with '*Header'to resort
1935       ** the list DESC
1936       */
1937       ELSIF (NVL(x_cur_sort_column, 'UNSET') = x_sort_column  AND
1938                 NVL(x_cur_sort_order, 'ASC') = 'DESC'  AND
1939                    x_advanced IN ('FIRST', 'TRUE')) THEN
1940 
1941              htp.tableHeader(
1942                 cvalue=>'<A HREF="'||x_standard_url||
1943                      '&x_sort_column='||x_sort_column||
1944                      '&x_sort_order='||'ASC'||
1945                      '" onMouseOver="window.status='||''''||
1946                      wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFMON_REVERSE_SORT_PROMPT'))||' '||
1947                      x_column_title||''''||
1948                      '; return true"'||
1949                      ' TARGET="_top">'||
1950                      '<font color=#FFFFFF>'||'*'|| x_column_title||'</font>'||
1951                      '</A>',
1952                 calign=>'Center');
1953 
1954       /*
1955       ** If the current column to display does not match the current sort column
1956       ** and youre in advanced mode then show the column header as a soft link
1957       ** with 'Header'to sort the list ASC by this column
1958       */
1959       ELSIF (NVL(x_cur_sort_column, 'UNSET') <> x_sort_column AND
1960                  x_advanced IN ('FIRST', 'TRUE')) THEN
1961 
1962           htp.tableHeader(
1963              cvalue=>'<A HREF="'||x_standard_url||
1964                   '&x_sort_column='||x_sort_column||
1965                   '" onMouseOver="window.status='||''''||
1966                   wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFMON_SORT_PROMPT'))||' '||
1967                   x_column_title||''''||
1968                   '; return true"'||
1969                   ' TARGET="_top">'||
1970                   '<font color=#FFFFFF>'||x_column_title||'</font>'||
1971                   '</A>',
1972              calign=>'Center');
1973 
1974       /*
1975       ** If this is not an applicable sort column or your not
1976       ** in advanced mode then just show the header normally.
1977       */
1978       ELSE
1979 
1980          htp.tableHeader('<font color=#FFFFFF>'||x_column_title_not_adv||'</font>', 'Center');
1981 
1982       END IF;
1983 
1984    END IF;
1985 
1986 exception
1987   when others then
1988     Wf_Core.Context(
1989           'Wf_Monitor',
1990           'createenvsortlink',
1991           x_cur_sort_column        ,
1992           x_cur_sort_order         ,
1993           x_sort_column           );
1994 
1995     raise;
1996 
1997 END createenvsortlink;
1998 
1999 --
2000 -- ShowEnvColumnHeaders (PRIVATE)
2001 --   Print column header in Envelope page
2002 --
2003 procedure showEnvColumnHeaders (
2004   x_item_type              varchar2,
2005   x_item_key               varchar2,
2006   x_admin_mode             varchar2,
2007   x_access_key             varchar2,
2008   x_advanced               varchar2,
2009   x_active                 varchar2,
2010   x_complete               varchar2,
2011   x_error                  varchar2,
2012   x_suspend                varchar2,
2013   x_proc_func              varchar2,
2014   x_note_resp              varchar2,
2015   x_note_noresp            varchar2,
2016   x_func_std               varchar2,
2017   x_event                  varchar2,
2018   x_sort_column            varchar2,
2019   x_sort_order             varchar2,
2020   x_nls_lang               varchar2)
2021 
2022 is
2023 
2024 x_standard_url    VARCHAR2(2000);
2025 
2026 begin
2027 
2028    /*
2029    ** Create the fixed set of parameters for the envelope
2030    ** routine that gets passed anywhere you create an
2031    ** envelope url
2032    */
2033    x_standard_url := owa_util.get_owa_service_path||
2034                   'wf_monitor.envelope'||
2035                   '?x_item_type='||wfa_html.conv_special_url_chars(x_item_type)||
2036                   '&x_item_key='||wfa_html.conv_special_url_chars(x_item_key)||
2037                   '&x_admin_mode='||x_admin_mode||
2038                   '&x_access_key='||x_access_key||
2039                   '&x_advanced='||x_advanced||
2040                   '&x_active='||x_active||
2041                   '&x_complete='||x_complete||
2042                   '&x_error='||x_error||
2043                   '&x_suspend='||x_suspend||
2044                   '&x_proc_func='||x_proc_func||
2045                   '&x_note_resp='||x_note_resp||
2046                   '&x_note_noresp='||x_note_noresp||
2047                   '&x_func_std='||x_func_std ||
2048                   '&x_event='||x_event ||
2049                   '&x_nls_lang='||x_nls_lang;
2050 
2051    htp.tableRowOpen(cattributes=>'BGCOLOR=#006699');
2052 
2053    /*
2054    ** Create the done or status column header depending on whether
2055    ** you're in advanced mode or not
2056    */
2057    createenvsortlink(x_sort_column,
2058                      x_sort_order,
2059                      'STATUS',
2060                      x_advanced,
2061                      wf_core.translate('WFMON_STATUS'),
2062                      wf_core.translate('WFMON_DONE'),
2063                      TRUE,
2064                      x_standard_url);
2065 
2066    /*
2067    ** Create the WHO column header
2068    */
2069    createenvsortlink(x_sort_column,
2070                      x_sort_order,
2071                      'WHO',
2072                      x_advanced,
2073                      wf_core.translate('WFMON_WHO'),
2074                      wf_core.translate('WFMON_WHO'),
2075                      TRUE,
2076                      x_standard_url);
2077 
2078    /*
2079    ** Create the PARENT activity column header depending on whether
2080    ** you're in advanced mode or not
2081    */
2082    createenvsortlink(x_sort_column,
2083                      x_sort_order,
2084                      'PARENT',
2085                      x_advanced,
2086                      wf_core.translate('WFMON_PARENT_ACTIVITY'),
2087                      NULL,
2088                      FALSE,
2089                      x_standard_url);
2090 
2091    /*
2092    ** Create the ACTIVITY column header
2093    */
2094    createenvsortlink(x_sort_column,
2095                      x_sort_order,
2096                      'ACTIVITY',
2097                      x_advanced,
2098                      wf_core.translate('WFMON_ACTIVITY'),
2099                      wf_core.translate('WFMON_ACTIVITY'),
2100                      TRUE,
2101                      x_standard_url);
2102 
2103    /*
2104    ** Create the STARTDATE column header
2105    */
2106    createenvsortlink(x_sort_column,
2107                      x_sort_order,
2108                      'STARTDATE',
2109                      x_advanced,
2110                      wf_core.translate('WFMON_STARTED'),
2111                      wf_core.translate('WFMON_STARTED'),
2112                      TRUE,
2113                      x_standard_url);
2114 
2115    /*
2116    ** Create the DURATION column header
2117    */
2118    createenvsortlink(x_sort_column,
2119                      x_sort_order,
2120                      'DURATION',
2121                      x_advanced,
2122                      wf_core.translate('WFMON_DURATION'),
2123                      wf_core.translate('WFMON_DURATION'),
2124                      TRUE,
2125                      x_standard_url);
2126 
2127    /*
2128    ** Create the RESULT column header
2129    */
2130    createenvsortlink(x_sort_column,
2131                      x_sort_order,
2132                      'RESULT',
2133                      x_advanced,
2134                      wf_core.translate('WFMON_RESULT'),
2135                      wf_core.translate('WFMON_RESULT'),
2136                      TRUE,
2137                      x_standard_url);
2138 
2139    htp.tableRowClose;
2140 
2141 end showEnvColumnHeaders;
2142 
2143 --
2144 -- ShowColumnHeaders (PRIVATE)
2145 --   Print column header in InstanceList page
2146 --
2147 procedure showColumnHeaders
2148 is
2149 begin
2150    htp.tableRowOpen(cattributes=>'BGCOLOR=#006699');
2151 
2152    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('ITEMTYPE')||'</font>', 'Center');
2153    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('ITEMKEY')||'</font>', 'Center');
2154    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('USER_ITEMKEY')||'</font>', 'Center');
2155    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('PROCESS_NAME')||'</font>', 'Center');
2156    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('COMPLETE')||'</font>', 'Center');
2157    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('IN_ERROR')||'</font>', 'Center');
2158    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('SUSPENDED')||'</font>', 'Center');
2159    htp.tableHeader('<font color=#FFFFFF>'||wf_core.translate('WFENG_BEGINDATE')||'</font>', 'Center');
2160 
2161    htp.tableRowClose;
2162 
2163 exception
2164   when others then
2165     Wf_Core.Context('Wf_Monitor', 'ShowColumnHeaders');
2166     raise;
2167 end showColumnHeaders;
2168 
2169 --
2170 -- TableRow (PRIVATE)
2171 --   Show a row in the Instance_List table
2172 -- IN
2173 --   itemtype - item type
2174 --   itemkey - item key
2175 --   process - process name
2176 --   url - url for monitor page
2177 --   active - active or completed flag
2178 --   error - errors exist flag
2179 --   suspend - suspensions exist flag
2180 --   startdate - date process started
2181 --
2182 -- MODIFICATION LOG:
2183 -- 06-JUN-2001 JWSMITH 1819232 - added alt attribute to img tags for
2184 --              following gifs: FNDIDONE, FNDIREDL, FNDIYLWL for ADA
2185 --
2186 procedure tableRow(itemtype     varchar2,
2187                    itemkey      varchar2,
2188                    userkey      varchar2,
2189                    process      varchar2,
2190                    url          varchar2,
2191                    active       boolean,
2192                    error        boolean,
2193                    suspend      boolean,
2194                    startdate    varchar2)
2195 is
2196 begin
2197 
2198   htp.tableRowOpen(calign=>'middle');
2199   htp.tableData(itemtype, 'Left', cattributes=>'id=""');
2200   htp.tableData(itemkey, 'Left', cattributes=>'id=""');
2201   if (userkey is not null) then
2202     htp.tableData(userkey, 'Left',cattributes=>'id=""');
2203   else
2204     htp.tableData(htf.br,cattributes=>'id=""');
2205   end if;
2206 
2207   if (url is not null) then
2208     htp.tableData(htf.anchor2(curl=>url, ctext=>process, ctarget=>'_top'),
2209                   'Left',
2210                   cattributes=>'id=""');
2211   else
2212     htp.tableData(process, 'Left', cattributes=>'id=""');
2213   end if;
2214 
2215   -- Active/Complete icon
2216   if (active) then
2217     htp.tableData(htf.br,cattributes=>'id=""');
2218   else
2219     htp.tableData(cvalue=>htf.img(curl=>wfa_html.image_loc||'FNDIDONE.gif',
2220                                   calt=>wf_core.translate('COMPLETE'),
2221                                   cattributes=>'border=no height=26'),
2222                   calign=>'center',
2223                   cattributes=>'id=""');
2224   end if;
2225 
2226   -- Error icon if error
2227   if (error) then
2228     htp.tableData(cvalue=>htf.img(curl=>wfa_html.image_loc||'FNDIREDL.gif',
2229                                   calt=>wf_core.translate('IN_ERROR'),
2230                                   cattributes=>'border=no height=26'),
2231                   calign=>'center',
2232                   cattributes=>'id=""');
2233   else
2234     htp.tableData(htf.br,cattributes=>'id=""');
2235   end if;
2236 
2237   -- Suspend icon if suspended
2238   if (suspend) then
2239     htp.tableData(cvalue=>htf.img(curl=>wfa_html.image_loc||'FNDIYLWL.gif',
2240                                   calt=>wf_core.translate('SUSPEND'),
2241                                   cattributes=>'border=no height=26'),
2242                   calign=>'center', cattributes=>'id=""');
2243   else
2244     htp.tableData(htf.br,cattributes=>'id=""');
2245   end if;
2246 
2247   htp.tableData(startdate, 'Left', cattributes=>'id=""');
2248   htp.tableRowClose;
2249 
2250 exception
2251   when others then
2252     Wf_Core.Context('Wf_Monitor', 'TableRow', itemtype, itemkey, process,
2253                     url, startdate);
2254     raise;
2255 end TableRow;
2256 
2257 --
2258 -- Instance_List
2259 --   Produce list of processes matching criteria
2260 -- IN
2261 --   x_active - Item active or complete (ACTIVE, COMPLETE, ALL)
2262 --   x_itemtype - Itemtype (null for all)
2263 --   x_ident - Itemkey (null for all)
2264 --   x_user_ident - User Itemkey (null for all)
2265 --   x_process - Root process name (null for all)
2266 --   x_status - Only with activities of status (SUSPEND, ERROR, ALL)
2267 --   x_person - Only waiting for reponse from
2268 --   x_numdays - No progress in x days
2269 --
2270 -- MODIFICATION LOG:
2271 -- 06-JUN-2001 JWSMITH BUG 1819232 -Added summary attr for table tag for ADA
2272 --
2273 procedure Instance_List (
2274   x_active      VARCHAR2,
2275   x_itemtype    VARCHAR2,
2276   x_ident       VARCHAR2,
2277   x_user_ident  VARCHAR2,
2278   x_process     VARCHAR2,
2279   x_process_owner       VARCHAR2,
2280   x_display_process_owner       VARCHAR2,
2281   x_admin_privilege     VARCHAR2,
2282   x_status      VARCHAR2,
2283   x_person      VARCHAR2,
2284   x_display_person      VARCHAR2,
2285   x_numdays     VARCHAR2)
2286 is
2287   -- Select items matching criteria
2288   cursor proc_info (c_process_owner IN VARCHAR2,
2289                     c_person IN VARCHAR2)is
2290   select wit.display_name,
2291          wi.item_key,
2292          wi.user_key,
2293          wi.begin_date,
2294          wi.item_type,
2295          wi.end_date,
2296          wa.display_name process_name
2297   from   wf_items wi,
2298          wf_item_types_vl wit,
2299          wf_activities_vl wa
2300   where  wi.item_type = wit.name
2301     and  wa.item_type = wi.item_type
2302     and  wa.name = wi.root_activity
2303     and  wa.version = wi.root_activity_version
2304     and  wi.item_type like decode(x_itemtype,
2305                                   '', '%',
2306                                   'ALL', '%',
2307                                   '*', '%',
2308                                   x_itemtype)
2309     and  wi.item_key like x_ident||'%'
2310     and  (wi.owner_role like upper(c_process_owner)||'%' or
2311           c_process_owner is null)
2312     and  (wi.user_key like x_user_ident||'%' or
2313           x_user_ident is null)
2314     and  (wa.display_name like x_process||'%')
2315     and (((wi.end_date is null) and (x_active in ('ACTIVE', 'ALL'))) or
2316          ((wi.end_date is not null) and (x_active in ('COMPLETE', 'ALL'))))
2317     and  ((x_numdays is null) or
2318           (wi.end_date is null and not exists
2319               (select null
2320                from wf_item_activity_statuses ias
2321                where ias.item_type = wi.item_type
2322                and ias.item_key = wi.item_key
2323                and ias.end_date > sysdate - x_numdays)))
2324     and  ((c_person is null) or exists
2325               (select null
2326                from wf_item_activity_statuses ias,
2327                     wf_notifications ntf
2328                where wi.end_date is null
2329                and ias.item_type = wi.item_type
2330                and ias.item_key = wi.item_key
2331                and ias.activity_status||'' = 'NOTIFIED'
2332                and ntf.group_id = ias.notification_id
2333                and ntf.recipient_role||'' = upper(c_person)))
2334     and  ((x_status = 'ALL') or exists
2335               (select null
2336                from wf_item_activity_statuses ias
2337                where ias.item_type = wi.item_type
2338                and ias.item_key = wi.item_key
2339                and ias.activity_status||'' = x_status))
2340     order by 1,2;
2341 
2342    proc proc_info%rowtype;
2343 
2344    cursor status_info(itype varchar2, ikey varchar2, status varchar2) is
2345    select count(1)
2346    from wf_item_activity_statuses wias
2347    where wias.item_type = itype
2348    and wias.item_key = ikey
2349    and wias.activity_status = status;
2350 
2351    error_count pls_integer;
2352    suspend_count pls_integer;
2353 
2354    envurl   varchar2(2000);
2355 
2356    username varchar2(320);
2357    admin_role varchar2(320);
2358    l_process_owner       VARCHAR2(320) := x_process_owner;
2359    l_person              VARCHAR2(320) := x_person;
2360 
2361 begin
2362 
2363   wfa_sec.GetSession(username);
2364 
2365   -- Get all the username find criteria resolved
2366   wfa_html.validate_display_name (x_display_process_owner, l_process_owner);
2367   wfa_html.validate_display_name (x_display_person, l_person);
2368 
2369   -- Window title
2370   htp.htmlOpen;
2371   htp.headOpen;
2372   htp.title(wf_core.translate('WFMON_LISTTITLE'));
2373   wfa_html.create_help_function('wf/links/pro.htm?PROLIST');
2374   htp.headClose;
2375 
2376   -- Open body and draw standard header
2377   wfa_sec.header(FALSE, 'wf_monitor.find_instance" TARGET="_top',
2378          wf_core.translate('WFMON_LISTTITLE'), TRUE);
2379 
2380   htp.tableOpen(cattributes=>'border=1 cellpadding=3 bgcolor=WHITE
2381                 width=100% summary=""');
2382 
2383   showColumnHeaders;
2384 
2385   -- Security checking 1364970
2386 
2387   admin_role := wf_core.Translate('WF_ADMIN_ROLE');
2388   if (admin_role <> '*')  then
2389     if not (wf_directory.IsPerformer(username, admin_role)) then
2390             l_process_owner := username;
2391     end if;
2392   end if;
2393 
2394   for proc in proc_info (l_process_owner, l_person) loop
2395     -- Check for errors
2396     open status_info(proc.item_type, proc.item_key, 'ERROR');
2397     fetch status_info into error_count;
2398     close status_info;
2399 
2400     -- Check for suspensions
2401     open status_info(proc.item_type, proc.item_key, 'SUSPEND');
2402     fetch status_info into suspend_count;
2403     close status_info;
2404 
2405     begin
2406       envurl :=wf_monitor.GetEnvelopeURL(wfa_html.base_url,
2407                                          proc.item_type,
2408                                          proc.item_key,
2409                                          x_admin_privilege);
2410     exception
2411       when others then
2412       -- ### In case there are any exceptions raised.  Happens
2413       --     right now for older workflows which have not yet
2414       --     had access keys assigned, although all new ones shouled.
2415       envurl := null;
2416     end;
2417 
2418     tableRow(proc.display_name,
2419              proc.item_key,
2420              proc.user_key,
2421              proc.process_name,
2422              envurl,
2423              (proc.end_date is null),
2424              (error_count <> 0),
2425              (suspend_count <> 0),
2426              to_char(proc.begin_date) || ' '
2427               || to_char(proc.begin_date, 'HH24:MI:SS'));
2428   end loop;
2429 
2430   htp.tableClose;
2431 
2432 
2433   wfa_sec.footer;
2434   htp.htmlClose;
2435 exception
2436   when others then
2437     Wf_Core.Context('Wf_Monitor', 'Instance_List', x_active, x_itemtype,
2438                     x_ident, x_process, x_status);
2439     Error;
2440 end Instance_List;
2441 
2442 /*===========================================================================
2443   PROCEDURE NAME:       draw_advanced_controls
2444 
2445   DESCRIPTION:
2446 
2447   -- MODIFICATION LOG:
2448   -- 06-JUN-2001 JWSMITH BUG 1819232 - added ID attrib for HD tag for ADA
2449                  - Added summary attr for table tag for ADA
2450 ============================================================================*/
2451 procedure draw_advanced_controls (
2452   x_item_type              VARCHAR2,
2453   x_item_key               VARCHAR2,
2454   x_admin_mode             VARCHAR2,
2455   x_access_key             VARCHAR2,
2456   x_advanced               VARCHAR2,
2457   x_active                 VARCHAR2,
2458   x_complete               VARCHAR2,
2459   x_error                  VARCHAR2,
2460   x_suspend                VARCHAR2,
2461   x_proc_func              VARCHAR2,
2462   x_note_resp              VARCHAR2,
2463   x_note_noresp            VARCHAR2,
2464   x_func_std               VARCHAR2,
2465   x_event                  VARCHAR2,
2466   x_sort_column            VARCHAR2,
2467   x_sort_order             VARCHAR2,
2468   x_nls_lang               VARCHAR2)
2469 
2470 IS
2471 l_record_num           PLS_INTEGER;
2472 l_status_icons_table   wf_status_icons_table;
2473 
2474 BEGIN
2475 
2476   htp.p('<FORM NAME="controls" ACTION="wf_monitor.envelope_frame" METHOD="GET" TARGET="DETAILS">');
2477 
2478   /*
2479   ** Skip a line
2480   */
2481   wf_item_definition_util_pub.draw_summary_section_title (
2482      wf_core.translate('WFMON_STATUS_OPTIONS'),
2483      0);
2484 
2485   /*
2486   ** Open a new table for the list of checkboxes that show what
2487   ** statuses are currently displayed on the form
2488   */
2489   htp.tableOpen(cattributes=>'border=0 cellpadding=0 cellspacing=0
2490                               summary=""');
2491 
2492   /*
2493   ** Create the checkbox for each activity status.
2494   */
2495   /*
2496   ** Open the checkboxes row
2497   */
2498   htp.tableRowOpen;
2499 
2500   /*
2501   ** Create the icon filename list for the different statuses
2502   */
2503   create_status_icons_table (l_status_icons_table);
2504 
2505   /*
2506   ** Create the active activity checkbox
2507   */
2508   wf_item_definition_util_pub.create_checkbox(
2509         'x_active',
2510         'ACTIVE',
2511         x_active,
2512         wf_core.translate ('ACTIVE'),
2513         l_status_icons_table(G_ACTIVE).icon_file_name,
2514         FALSE);
2515 
2516 
2517   /*
2518   ** Create the completed activity checkbox
2519   */
2520   wf_item_definition_util_pub.create_checkbox(
2521         'x_complete',
2522         'COMPLETE',
2523         x_complete,
2524         wf_core.translate ('COMPLETE'),
2525         l_status_icons_table(G_COMPLETE).icon_file_name,
2526         FALSE);
2527 
2528   /*
2529   ** Create the error activity checkbox
2530   */
2531   wf_item_definition_util_pub.create_checkbox(
2532         'x_error',
2533         'ERROR',
2534         x_error,
2535         wf_core.translate ('ERROR'),
2536         l_status_icons_table(G_ERROR).icon_file_name,
2537         FALSE);
2538 
2539   /*
2540   ** Create the suspended activity checkbox
2541   */
2542   wf_item_definition_util_pub.create_checkbox(
2543         'x_suspend',
2544         'SUSPEND',
2545         x_suspend,
2546         wf_core.translate ('SUSPENDED'),
2547         l_status_icons_table(G_SUSPEND).icon_file_name,
2548         FALSE);
2549 
2550   /*
2551   ** Close the checkboxes row
2552   */
2553   htp.tableRowClose;
2554 
2555   /*
2556   ** Close the checkboxes table
2557   */
2558   htp.tableClose;
2559 
2560   /*
2561   ** Skip a line
2562   */
2563   htp.p('<BR>');
2564 
2565   /*
2566   ** Show the Processes activity options header
2567   */
2568   wf_item_definition_util_pub.draw_summary_section_title (
2569      wf_core.translate('WFMON_ACTIVITY_TYPE'),
2570      0);
2571 
2572   /*
2573   ** Open a new table for the list of checkboxes that show what
2574   ** statuses are currently displayed on the form
2575   */
2576   htp.tableOpen(cattributes=>'border=0 cellpadding=0 cellspacing=0
2577                               summary=""');
2578 
2579   /*
2580   ** Create the checkbox for each activity status.
2581   */
2582   /*
2583   ** Open the checkboxes row
2584   */
2585   htp.tableRowOpen;
2586 
2587   /*
2588   ** Create the checkbox for Notifications With Responses
2589   */
2590   wf_item_definition_util_pub.create_checkbox(
2591              'x_note_resp',
2592              'Y',
2593              x_note_resp,
2594               wf_core.translate('WFMON_NOTIF_RESPONSE'),
2595              null,
2596              FALSE);
2597 
2598   /*
2599   ** Create the checkbox for Notifications Without Responses
2600   */
2601   wf_item_definition_util_pub.create_checkbox(
2602              'x_note_noresp',
2603              'Y',
2604              x_note_noresp,
2605               wf_core.translate('WFMON_NOTIF_NO_RESPONSE'),
2606              null,
2607              FALSE);
2608 
2609   /*
2610   ** Create the checkbox for Processes with results
2611   */
2612   wf_item_definition_util_pub.create_checkbox(
2613              'x_proc_func',
2614              'Y',
2615              x_proc_func,
2616               wf_core.translate('WFMON_PROCESS_FUNCTION'),
2617              null,
2618              FALSE);
2619 
2620   /*
2621   ** Create the checkbox for Standard Workflow Functions
2622   */
2623   wf_item_definition_util_pub.create_checkbox(
2624              'x_func_std',
2625              'Y',
2626              x_func_std,
2627               wf_core.translate('WFMON_FUNCTION_STANDARD'),
2628              null,
2629              FALSE);
2630 
2631 
2632   /*
2633   ** Create the checkbox for Event Activity
2634   */
2635   wf_item_definition_util_pub.create_checkbox(
2636              'x_event',
2637              'Y',
2638              x_event,
2639               wf_core.translate('WFMON_EVENT')||
2640                  '      ',
2641              null,
2642              FALSE);
2643 
2644   htp.p('<TD ID="">');
2645 
2646   wfa_html.create_reg_button ('javascript:document.controls.submit()',
2647                               wf_core.translate ('WFMON_REQUERY'),
2648                               wfa_html.image_loc,
2649                               'fndfind.gif',
2650                               wf_core.translate ('WFMON_REQUERY'));
2651 
2652   htp.p('</TD>');
2653 
2654   /*
2655   ** Close the checkboxes row
2656   */
2657   htp.tableRowClose;
2658 
2659   /*
2660   ** Close the checkboxes table
2661   */
2662   htp.tableClose;
2663 
2664   htp.p(htf.formHidden('x_item_type', x_item_type));
2665   htp.p(htf.formHidden('x_item_key', x_item_key));
2666   htp.p(htf.formHidden('x_admin_mode', x_admin_mode));
2667   htp.p(htf.formHidden('x_access_key', x_access_key));
2668   htp.p(htf.formHidden('x_advanced', 'TRUE'));
2669   htp.p(htf.formHidden('x_sort_column', x_sort_column));
2670   htp.p(htf.formHidden('x_sort_order', x_sort_order));
2671   htp.p(htf.formHidden('x_nls_lang', x_nls_lang));
2672 
2673   htp.formClose;
2674 
2675   EXCEPTION
2676   WHEN OTHERS THEN
2677      Wf_Core.Context('wf_monitor',
2678         'draw_advanced_controls',
2679         x_advanced);
2680 
2681      error;
2682 
2683 END draw_advanced_controls;
2684 
2685 PROCEDURE draw_header (
2686     x_item_type  varchar2,
2687     x_item_key   varchar2,
2688     x_admin_mode varchar2,
2689     x_access_key varchar2,
2690     x_advanced   varchar2,
2691     x_nls_lang   varchar2) IS
2692 
2693   username       varchar2(320);
2694   l_agent        varchar2(100) := owa_util.get_cgi_env('SCRIPT_NAME');
2695   pseudo_login   BOOLEAN := FALSE;
2696 BEGIN
2697 
2698   /*
2699   ** Hide any session creation issues for now and depend on the
2700   ** access key to prevent a user from running this function without
2701   ** logging in.
2702   */
2703   begin
2704 
2705      -- set the validate_only flag to true so you don't throw up the login
2706      -- page and you have a chance to check the access key.
2707      wfa_sec.validate_only := TRUE;
2708 
2709      wfa_sec.GetSession(username);
2710 
2711      exception
2712        when others then
2713            -- If AccessKeyCheck will return "ERROR" directly if failed
2714            if (not(AccessKeyCheck(x_item_type, x_item_key, x_admin_mode,
2715                 x_access_key))) then
2716 
2717                htp.p(wf_core.translate('WRONG_ACCESS_KEY'));
2718 
2719                return;
2720 
2721            else
2722 
2723              dbms_session.set_nls('NLS_LANGUAGE', ''''||x_nls_lang||'''');
2724              pseudo_login := TRUE;
2725            end if;
2726   end;
2727 
2728   -- Window title
2729   htp.htmlOpen;
2730   htp.headOpen;
2731 
2732   /*
2733   ** If you are not in advanced mode then make the window title the
2734   ** standard Notifications List.  Otherwise make it Activities List
2735   */
2736   IF (x_advanced = 'FALSE') THEN
2737 
2738      htp.title(wf_core.translate('WFMON_ENVELOPE_LIST'));
2739      wfa_html.create_help_function('wf/links/nfl.htm?NFLIST');
2740 
2741   ELSE
2742 
2743      htp.title(wf_core.translate('WFMON_ACTIVITIES_LIST'));
2744      wfa_html.create_help_function('wf/links/aal.htm?AALIST');
2745 
2746   END IF;
2747 
2748   htp.headClose;
2749 
2750   -- Open body and draw standard header
2751   IF (x_advanced = 'FALSE') THEN
2752 
2753      wfa_sec.header(FALSE, 'wf_monitor.find_instance" TARGET="_top', wf_core.translate('WFMON_ENVELOPE_LIST'), TRUE, pseudo_login);
2754 
2755   else
2756 
2757      wfa_sec.header(FALSE, 'wf_monitor.find_instance" TARGET="_top', wf_core.translate('WFMON_ACTIVITIES_LIST'), TRUE, pseudo_login);
2758 
2759   end if;
2760 
2761 exception
2762 when others then
2763      Wf_Core.Context('wf_monitor',
2764         'draw_header',
2765         x_item_type,
2766         x_item_key,
2767         x_admin_mode,
2768         x_access_key,
2769         x_advanced);
2770 
2771      error;
2772 
2773 end draw_header;
2774 
2775 procedure Envelope (
2776   x_item_type              VARCHAR2,
2777   x_item_key               VARCHAR2,
2778   x_admin_mode             VARCHAR2,
2779   x_access_key             VARCHAR2,
2780   x_advanced               VARCHAR2,
2781   x_active                 VARCHAR2,
2782   x_complete               VARCHAR2,
2783   x_error                  VARCHAR2,
2784   x_suspend                VARCHAR2,
2785   x_proc_func              VARCHAR2,
2786   x_note_resp              VARCHAR2,
2787   x_note_noresp            VARCHAR2,
2788   x_func_std               VARCHAR2,
2789   x_event                  VARCHAR2,
2790   x_sort_column            VARCHAR2,
2791   x_sort_order             VARCHAR2,
2792   x_nls_lang               VARCHAR2
2793   ) is
2794 
2795   username              varchar2(320);
2796   l_child_item_list     wf_monitor.wf_items_tbl_type;
2797   l_number_of_children  NUMBER :=0;
2798   begin
2799 
2800   /*
2801   ** Hide any session creation issues for now and depend on the
2802   ** access key to prevent a user from running this function without
2803   ** logging in.
2804   */
2805   begin
2806 
2807      -- set the validate_only flag to true so you don't throw up the login
2808      -- page and you have a chance to check the access key.
2809      wfa_sec.validate_only := TRUE;
2810 
2811      wfa_sec.GetSession(username);
2812 
2813      exception
2814        when others then
2815            -- If AccessKeyCheck will return "ERROR" directly if failed
2816            if (not(AccessKeyCheck(x_item_type, x_item_key, x_admin_mode,
2817                 x_access_key))) then
2818 
2819                htp.p(wf_core.translate('WRONG_ACCESS_KEY'));
2820 
2821                return;
2822 
2823            else
2824 
2825              dbms_session.set_nls('NLS_LANGUAGE', ''''||x_nls_lang||'''');
2826 
2827            end if;
2828   end;
2829 
2830   -- Window title
2831   htp.htmlOpen;
2832   htp.headOpen;
2833 
2834   /*
2835   ** If you are not in advanced mode then make the window title the
2836   ** standard Notifications List.  Otherwise make it Activities List
2837   */
2838   htp.title(wf_core.translate('WFMON_ENVELOPE_LIST'));
2839 
2840   wfa_html.create_help_function('wf/links/nfl.htm?NFLIST');
2841 
2842   htp.headClose;
2843 
2844   htp.htmlOpen;
2845 
2846 
2847   -- Open frameset
2848   htp.p('<FRAMESET ROWS="15%,85%" frameborder=no border=0
2849            TITLE="' || WF_CORE.Translate('WFMON_ENVELOPE_LIST') || '" LON
2850 GDESC="' ||           owa_util.get_owa_service_path ||
2851            'wfa_html.LongDesc?p_token=WFMON_ENVELOPE_LIST">');
2852 
2853   htp.p('<FRAME NAME="header_bar" MARGINHEIGHT=10 MARGINWIDTH=10 ' ||
2854         'scrolling=no frameborder=no framespacing=noresize '||
2855         'src="'||owa_util.get_owa_service_path||
2856         'wf_monitor.draw_header'||
2857         '?x_item_type='||wfa_html.conv_special_url_chars(x_item_type)||
2858         '&x_item_key='||wfa_html.conv_special_url_chars(x_item_key)||
2859         '&x_admin_mode='||x_admin_mode||
2860         '&x_access_key='||x_access_key||
2861         '&x_advanced='||x_advanced||
2862         '&x_nls_lang='||x_nls_lang||
2863         '" TITLE="' ||
2864          WF_CORE.Translate('WFMON_ENVELOPE_LIST') || '" LONGDESC="' ||
2865          owa_util.get_owa_service_path ||
2866          'wfa_html.LongDesc?p_token=WFMON_ENVELOPE_LIST">');
2867 
2868   /*
2869   ** Check if there are any children for this process.  If there are
2870   ** then show a two frame set.  One frame for the process hierarchy the other
2871   ** with the envelope list.  If there are no children then just have a single
2872   ** frame for the envelope list details.
2873   */
2874 
2875   /*
2876   ** Get the process children for this row
2877   */
2878   wf_monitor.get_process_children(X_item_type,
2879                                   X_item_key,
2880                                   l_child_item_list,
2881                                   l_number_of_children);
2882 
2883   IF (l_number_of_children > 0) THEN
2884 
2885      htp.p('<FRAMESET COLS="25%,75%" frameborder=no border=1
2886            TITLE="' || WF_CORE.Translate('WFMON_ENVELOPE_LIST') || '" LON
2887 GDESC="' ||           owa_util.get_owa_service_path ||
2888            'wfa_html.LongDesc?p_token=WFMON_ENVELOPE_LIST">');
2889 
2890      htp.p('<FRAME NAME="CHILDREN" scrolling=yes frameborder=no framespacing=noresize ' ||
2891            'src="'||owa_util.get_owa_service_path||
2892                  'wf_monitor.process_children'||
2893                  '?x_item_type='||wfa_html.conv_special_url_chars(x_item_type)||
2894                  '&x_item_key='||wfa_html.conv_special_url_chars(x_item_key)||
2895                  '&x_admin_mode='||x_admin_mode||
2896                  '&x_nls_lang='||x_nls_lang||'" WRAP=OFF "' ||
2897                   '" TITLE="' ||
2898            WF_CORE.Translate('WFMON_ENVELOPE_LIST') || '" LONGDESC="' ||
2899            owa_util.get_owa_service_path ||
2900            'wfa_html.LongDesc?p_token=WFMON_ENVELOPE_LIST">');
2901 
2902      htp.p('<FRAME NAME="DETAILS"  frameborder=no framespacing=0 '||
2903            'src="'||owa_util.get_owa_service_path||
2904            'wf_monitor.envelope_frame'||
2905            '?x_item_type='||wfa_html.conv_special_url_chars(x_item_type)||
2906            '&x_item_key='||wfa_html.conv_special_url_chars(x_item_key)||
2907            '&x_admin_mode='||wfa_html.conv_special_url_chars(x_admin_mode)||
2908            '&x_access_key='||wfa_html.conv_special_url_chars(x_access_key)||
2909            '&x_advanced='||wfa_html.conv_special_url_chars(x_advanced)||
2910            '&x_active='||wfa_html.conv_special_url_chars(x_active)||
2911            '&x_complete='||x_complete||
2912            '&x_error='||x_error||
2913            '&x_suspend='||x_suspend||
2914            '&x_proc_func='||x_proc_func||
2915            '&x_note_resp='||x_note_resp||
2916            '&x_note_noresp='||x_note_noresp||
2917            '&x_func_std='||x_func_std||
2918            '&x_event='||x_event||
2919            '&x_sort_column='||x_sort_column||
2920            '&x_sort_order='||x_sort_column||
2921            '&x_nls_lang='||x_nls_lang||
2922             '" TITLE="' ||
2923            WF_CORE.Translate('WFMON_ENVELOPE_LIST') || '" LONGDESC="' ||
2924            owa_util.get_owa_service_path ||
2925            'wfa_html.LongDesc?p_token=WFMON_ENVELOPE_LIST">');
2926 
2927   ELSE
2928 
2929      htp.p('<FRAMESET COLS="100%" frameborder=no border=0
2930             TITLE="' || WF_CORE.Translate('WFMON_ENVELOPE_LIST') || '" LON
2931 GDESC="' ||           owa_util.get_owa_service_path ||
2932            'wfa_html.LongDesc?p_token=WFMON_ENVELOPE_LIST">');
2933 
2934      htp.p('<FRAME NAME="DETAILS"  frameborder=no framespacing=0 '||
2935            'src="'||owa_util.get_owa_service_path||
2936            'wf_monitor.envelope_frame'||
2937            '?x_item_type='||wfa_html.conv_special_url_chars(x_item_type)||
2938            '&x_item_key='||wfa_html.conv_special_url_chars(x_item_key)||
2939            '&x_admin_mode='||x_admin_mode||
2940            '&x_access_key='||x_access_key||
2941            '&x_advanced='||x_advanced||
2942            '&x_active='||x_active||
2943            '&x_complete='||x_complete||
2944            '&x_error='||x_error||
2945            '&x_suspend='||x_suspend||
2946            '&x_proc_func='||x_proc_func||
2947            '&x_note_resp='||x_note_resp||
2948            '&x_note_noresp='||x_note_noresp||
2949            '&x_func_std='||x_func_std||
2950            '&x_event='||x_event||
2951            '&x_sort_column='||x_sort_column||
2952            '&x_sort_order='||x_sort_order||
2953            '&x_nls_lang='||x_nls_lang||
2954            '" TITLE="' ||
2955            WF_CORE.Translate('WFITD_ITEM_TYPE_DEFINITION') || '" LONGDESC="' ||
2956            owa_util.get_owa_service_path ||
2957            'wfa_html.LongDesc?p_token=WFITD_ITEM_TYPE_DEFINITION">');
2958 
2959   END IF;
2960 
2961   htp.p('</FRAMESET>');
2962 
2963   htp.p('</FRAMESET>');
2964 
2965   htp.htmlClose;
2966 
2967 exception
2968   when others then
2969     Wf_Core.Context('Wf_Monitor', 'Envelope', x_item_type, x_item_key);
2970     Error;
2971 end envelope;
2972 
2973 --
2974 -- Envelope_Frame
2975 --
2976 -- MODIFICATION LOG:
2977 -- 06-JUN-2001 JWSMITH BUG 1819232 - added alt attrib for the following gifs
2978 --             FNDIACTV,FNDIDONE,FNDIYLWL, FNDIREDL for ADA
2979 --             - Also added ID attrib for HD tag for ADA
2980 --             - Also added summary attri for table tag for ADA
2981 --
2982 procedure Envelope_Frame (
2983   x_item_type              VARCHAR2,
2984   x_item_key               VARCHAR2,
2985   x_admin_mode             VARCHAR2,
2986   x_access_key             VARCHAR2,
2987   x_advanced               VARCHAR2,
2988   x_active                 VARCHAR2,
2989   x_complete               VARCHAR2,
2990   x_error                  VARCHAR2,
2991   x_suspend                VARCHAR2,
2992   x_proc_func              VARCHAR2,
2993   x_note_resp              VARCHAR2,
2994   x_note_noresp            VARCHAR2,
2995   x_func_std               VARCHAR2,
2996   x_event                  VARCHAR2,
2997   x_sort_column            VARCHAR2,
2998   x_sort_order             VARCHAR2,
2999   x_nls_lang               VARCHAR2
3000   ) is
3001 
3002   username varchar2(320);
3003   role_name varchar2(320);
3004   email_address varchar2(320);
3005   buf varchar2(2000);
3006   url  varchar2(2000);
3007   mlrurl varchar2(2000);
3008   status_options varchar2(2000);
3009   x_begin_date date;
3010   x_end_date date := null;
3011   proc_dispname varchar2(80);
3012   item_type_dispname varchar2(80);
3013   proc_duration varchar2(30);
3014   x_root_activity varchar2(30);
3015   x_font_color varchar2(30);
3016   x_font_color_end varchar2(30);
3017   title_info varchar2(4000);
3018   status_flag varchar2(15);
3019   x_show_activity              BOOLEAN := FALSE;
3020   x_valid_status               BOOLEAN := FALSE;
3021   l_agent                      VARCHAR2(100) := owa_util.get_cgi_env('SCRIPT_NAME');
3022   l_duration_days              NUMBER := 0;
3023   l_duration_hours             NUMBER := 0;
3024   l_duration_minutes           NUMBER := 0;
3025   l_duration_seconds           NUMBER := 0;
3026   l_record_num                 PLS_INTEGER;
3027   x_notification_id            PLS_INTEGER := NULL;
3028   x_notification_result        VARCHAR2(80) := NULL;
3029   x_notification_response      INTEGER := 0;
3030   x_icon_name                  VARCHAR2(30);
3031   x_duration_str               VARCHAR2(80);
3032   l_date_date                  DATE;
3033   l_valid_date                 BOOLEAN;
3034   l_expected_format            VARCHAR2(80);
3035   u_key                        VARCHAR2(240);
3036   l_status_icons_table         wf_status_icons_table;
3037   x_activity_cursor            wf_monitor.wf_activity_cursor;
3038   x_activity_record            wf_monitor.wf_activity_record;
3039   pseudo_login                 BOOLEAN := FALSE;
3040 
3041   cursor attrs(mnid in number) is
3042     select MA.NAME
3043     from WF_NOTIFICATION_ATTRIBUTES NA,
3044          WF_MESSAGE_ATTRIBUTES_VL MA,
3045          WF_NOTIFICATIONS N
3046     where N.NOTIFICATION_ID = mnid
3047     and NA.NOTIFICATION_ID = N.NOTIFICATION_ID
3048     and MA.MESSAGE_NAME = N.MESSAGE_NAME
3049     and MA.MESSAGE_TYPE = N.MESSAGE_TYPE
3050     and MA.NAME = NA.NAME
3051     and MA.SUBTYPE = 'RESPOND'
3052     and MA.TYPE <> 'FORM'
3053     and MA.NAME = 'RESULT';
3054 
3055   result attrs%rowtype;
3056   n_response varchar2(3200);  -- required response icon
3057 
3058 BEGIN
3059 
3060   /*
3061   ** Hide any session creation issues for now and depend on the
3062   ** access key to prevent a user from running this function without
3063   ** logging in.
3064   */
3065   begin
3066 
3067      -- set the validate_only flag to true so you don't throw up the login
3068      -- page and you have a chance to check the access key.
3069      wfa_sec.validate_only := TRUE;
3070 
3071      wfa_sec.GetSession(username);
3072 
3073      exception
3074        when others then
3075            -- If AccessKeyCheck will return "ERROR" directly if failed
3076            if (not(AccessKeyCheck(x_item_type, x_item_key, x_admin_mode,
3077                 x_access_key))) then
3078 
3079                htp.p(wf_core.translate('WRONG_ACCESS_KEY'));
3080 
3081                return;
3082 
3083            else
3084 
3085              dbms_session.set_nls('NLS_LANGUAGE', ''''||x_nls_lang||'''');
3086              pseudo_login := TRUE;
3087 
3088            end if;
3089   end;
3090 
3091 
3092   -- To avoid having Instance_List() send the begin_date of item_key,
3093   -- do the fetch here.
3094   -- This is to avoid sending spaces throught web server
3095   select i.begin_date, i.end_date, a.display_name, it.display_name, i.root_activity
3096   into  x_begin_date, x_end_date, proc_dispname, item_type_dispname, x_root_activity
3097   from  wf_items i, wf_activities_vl a, wf_item_types_vl it
3098   where i.item_type = x_item_type
3099   and   i.item_key = x_item_key
3100   and   i.item_type = it.name
3101   and   i.root_activity = a.name
3102   and   i.item_type = a.item_type
3103   and   a.begin_date <= i.begin_date
3104   and   (a.end_date is null or a.end_date > i.begin_date);
3105 
3106   if (x_end_date is null) then
3107     proc_duration := to_char(sysdate,'J') - to_char(x_begin_date, 'J');
3108     status_flag := 'FNDIACTV.gif';
3109   else
3110     proc_duration := to_char(x_end_date,'J') - to_char(x_begin_date, 'J');
3111     status_flag := 'FNDIDONE.gif';
3112   end if;
3113 
3114   -- Get User Key
3115   select user_key into u_key from wf_items
3116   where item_type=x_item_type and item_key = x_item_key;
3117   if u_key is null then
3118     u_key := x_item_key;
3119   end if;
3120 
3121 
3122   htp.htmlOpen;
3123 
3124   -- use onload to redraw the header with new title when moving to detail screen
3125   htp.p('<body bgcolor="#CCCCCC" onLoad="'||
3126         'open('||''''||'wf_monitor.draw_header'||
3127         '?x_item_type='||wfa_html.conv_special_url_chars(x_item_type)||
3128         '&x_item_key='||wfa_html.conv_special_url_chars(x_item_key)||
3129         '&x_admin_mode='||x_admin_mode||
3130         '&x_access_key='||x_access_key||
3131         '&x_advanced='||x_advanced||
3132         '&x_nls_lang='||x_nls_lang|| ''''||', '||
3133         ''''||'header_bar'||''''||')">');
3134 
3135   if (status_flag = 'FNDIACTV.gif') then
3136       htp.p(htf.img(wfa_html.image_loc||status_flag,'left',
3137                 wf_core.translate('ACTIVE'), null, 'height=40 width=35'));
3138   else
3139       htp.p(htf.img(wfa_html.image_loc||status_flag,'left',
3140                 wf_core.translate('COMPLETE'), null, 'height=40 width=35'));
3141   end if;
3142 
3143   title_info := proc_dispname||': '||item_type_dispname||', '||u_key;
3144   htp.p(title_info);
3145 
3146   htp.p(htf.br);
3147   title_info := wf_core.translate('WFMON_STARTED')||':  '||
3148                 x_begin_date||'  ( '||
3149                 proc_duration||' '||wf_core.translate('WFMON_DAYS')||' )';
3150   htp.p(title_info);
3151   htp.p(htf.br(cclear=>'clear=left'));
3152   htp.p('<P>');
3153 
3154 
3155   /*
3156   ** Get the NLS Date format that is currently set.  All to_char of
3157   ** date values should use the l_expected_format
3158   */
3159   wf_item_definition_util_pub.validate_date (
3160      TO_CHAR(x_begin_date, 'DD-MON-RRRR HH24:MI:SS'),
3161      l_date_date,
3162      l_valid_date,
3163      l_expected_format);
3164 
3165   /*
3166   **
3167   ** I've created an argument for the envelope procedure for each of the
3168   ** possible statuses.  If the checkbox is checked then the
3169   ** lookup code value will be passed through this argument.  I will concatenate
3170   ** all these arguments together into a single string so that I can use
3171   ** INSTR to determine if the status of a given activity has been requested
3172   ** as one of the activities that have been checked.
3173   */
3174   status_options :=
3175      x_active   ||'-'||
3176      x_complete ||'-'||
3177      x_error    ||'-'||
3178      x_suspend;
3179 
3180   /*
3181   ** Create the icon filename list for the different statuses
3182   */
3183   create_status_icons_table (l_status_icons_table);
3184 
3185   /*
3186   ** Create the advanced controls for the activities list.
3187   **If youre coming into this procedure from the process list
3188   ** then the x_advanced variable will be set to FALSE. If
3189   ** youre coming from the notifications list and select the
3190   ** advanced search option for the first time then the
3191   ** x_advanced variable will be set to FIRST.  All other
3192   ** times it will be set to true
3193   */
3194   IF (x_advanced in ('FIRST', 'TRUE')) THEN
3195 
3196      /*
3197      ** Create the controls frame
3198      */
3199      draw_advanced_controls(
3200         x_item_type,
3201         x_item_key,
3202         x_admin_mode,
3203         x_access_key,
3204         'TRUE',
3205         x_active,
3206         x_complete,
3207         x_error,
3208         x_suspend,
3209         x_proc_func,
3210         x_note_resp,
3211         x_note_noresp,
3212         x_func_std,
3213         x_event,
3214         x_sort_column,
3215         x_sort_order,
3216         x_nls_lang);
3217 
3218   END IF;
3219 
3220   /*
3221   ** Create the envelope form.  The envelope form is under the advanced_controls
3222   ** form and is implemented as a separate form so that you can have the
3223   ** diffent submit controls for View Monitor vs. Show Activities.
3224   */
3225   htp.p('<FORM NAME="envelope" ACTION="wf_monitor.html" METHOD="GET" TARGET="_top">');
3226 
3227   /*
3228   ** Open the main table for the list of activities
3229   */
3230   htp.tableOpen(calign=>'CENTER', cattributes=>'border=1 cellpadding=3 bgcolor=WHITE width=100% summary=""');
3231 
3232   /*
3233   ** Show the Envelope column headers.  All the parameters being passed
3234   ** around is required so that I can create soft links that cause the
3235   ** sorting on different columns to be set up.  We also need to pass
3236   ** the current sort options so we can let the user know what is the
3237   ** current sort column.  We pass the x_advanced parameter to tell the
3238   ** column header routine whether or not to enable the sorting option
3239   ** and whether or not to show the parent activity column or not.
3240   */
3241   showEnvColumnHeaders(
3242      x_item_type,
3243      x_item_key,
3244      x_admin_mode,
3245      x_access_key,
3246      x_advanced,
3247      x_active,
3248      x_complete,
3249      x_error,
3250      x_suspend,
3251      x_proc_func,
3252      x_note_resp,
3253      x_note_noresp,
3254      x_func_std,
3255      x_event,
3256      x_sort_column,
3257      x_sort_order,
3258      x_nls_lang);
3259 
3260   /*
3261   ** Open the appropriate cursor for the requested sort
3262   ** order.  We currently fetch all the activity rows for
3263   ** the given process and then programatically determine
3264   ** which rows to display based on your activity list
3265   ** filters.  You can see these down below.
3266   */
3267 
3268   /*
3269   ** The sorting issues are fairly complicated.
3270   ** You cannot use a decode statement to identify
3271   ** the direction of your sort only the column that
3272   ** will be used for the sort.  To get around this
3273   ** I've had to copy
3274   ** the select statement twice.  The first is the sort
3275   ** for the ascending list.  The second is the list
3276   ** for the descending sort.  The x_activity_cursor is
3277   ** defined in wfmons and can be shared across multiple
3278   ** selects as long as the select list matches the
3279   ** wf_activity_record definition
3280   */
3281   IF (NVL(x_sort_order, 'ASC') = 'ASC') THEN
3282 
3283      OPEN  x_activity_cursor FOR
3284      select item_type,
3285             item_key,
3286             begin_date,
3287             execution_time,
3288             end_date,
3289             begin_date_time,
3290             duration,
3291             activity_item_type,
3292             activity_type,
3293             parent_activity_name,
3294             activity_name,
3295             activity_display_name,
3296             parent_display_name,
3297             activity_status,
3298             notification_status,
3299             notification_id,
3300             recipient_role,
3301             recipient_role_name,
3302             activity_status_display,
3303             result
3304      from  wf_item_activities_history_v wfhist
3305      where wfhist.item_type = x_item_type
3306      and   wfhist.item_key = x_item_key
3307      and   wfhist.activity_def_begin_date <= x_begin_date
3308      and   (wfhist.activity_def_end_date is null or wfhist.activity_def_end_date > x_begin_date)
3309      order by
3310            DECODE(x_sort_column, 'STATUS',       activity_status_display,
3311                                  'WHO',          recipient_role_name,
3312                                  'PARENT',       parent_display_name,
3313                                  'ACTIVITY',     activity_display_name,
3314                                  'STARTDATE',    to_char(begin_date, 'J.SSSSS'),
3315                                  'DURATION',     to_char(duration, '00000000'),
3316                                  'RESULT',       result,
3317                                                  to_char(begin_date, 'J.SSSSS')),
3318            begin_date,
3319            execution_time;
3320 
3321   ELSE
3322 
3323      OPEN  x_activity_cursor FOR
3324      select item_type,
3325             item_key,
3326             begin_date,
3327             execution_time,
3328             end_date,
3329             begin_date_time,
3330             duration,
3331             activity_item_type,
3332             activity_type,
3333             parent_activity_name,
3334             activity_name,
3335             activity_display_name,
3336             parent_display_name,
3337             activity_status,
3338             notification_status,
3339             notification_id,
3340             recipient_role,
3341             recipient_role_name,
3342             activity_status_display,
3343             result
3344      from  wf_item_activities_history_v wfhist
3345      where wfhist.item_type = x_item_type
3346      and   wfhist.item_key = x_item_key
3347      and   wfhist.activity_def_begin_date <= x_begin_date
3348      and   (wfhist.activity_def_end_date is null or wfhist.activity_def_end_date > x_begin_date)
3349      order by
3350            DECODE(x_sort_column, 'STATUS',       activity_status_display,
3351                                  'WHO',          recipient_role_name,
3352                                  'PARENT',       parent_display_name,
3353                                  'ACTIVITY',     activity_display_name,
3354                                  'STARTDATE',    to_char(begin_date, 'J.SSSSS'),
3355                                  'DURATION',     to_char(duration, '00000000'),
3356                                  'RESULT',       result,
3357                                                  to_char(begin_date, 'J.SSSSS')) desc,
3358            begin_date desc,
3359            execution_time desc;
3360 
3361   END IF;
3362 
3363   /*
3364   ** Go fetch all the rows that were selected in the above cursor
3365   */
3366   LOOP
3367 
3368     FETCH x_activity_cursor INTO x_activity_record;
3369 
3370     EXIT WHEN x_activity_cursor%NOTFOUND;
3371 
3372     x_notification_id := x_activity_record.notification_id;
3373 
3374     /*
3375     ** Get the result for a notification
3376     */
3377     BEGIN
3378 
3379        SELECT decode(ma.type,
3380                   'NUMBER', to_char(na.number_value),
3381                   'DATE',   to_char(na.date_value,
3382                                  nvl(ma.format, 'DD/MON/YYYY HH24:MI:SS')),
3383                   'LOOKUP', wf_core.activity_result(ma.format, na.text_value),
3384                      na.text_value) result,
3385                1
3386         INTO   x_notification_result,
3387                x_notification_response
3388         FROM   wf_notification_attributes na,
3389                wf_message_attributes_vl ma,
3390                wf_notifications n
3391         WHERE  n.group_id = x_notification_id
3392         AND    n.message_type = ma.message_type
3393         AND    n.message_name = ma.message_name
3394         AND    ma.name = na.name
3395         AND    ma.name = 'RESULT'
3396         AND    na.notification_id = n.notification_id;
3397 
3398     EXCEPTION
3399         WHEN NO_DATA_FOUND THEN
3400            x_notification_result := 'WF_NOTFOUND';
3401            x_notification_response := 0;
3402 
3403         /*
3404         ** The other exceptions that could occur are that more than one
3405         ** row was fetched into a single row select which is the case
3406         ** for a notification that was
3407         ** sent to a role with multiple receipients.  (Expand Roles is
3408         ** turned on.  In these cases use the result that was selected
3409         ** from the activity that was fetched above.
3410         */
3411         WHEN OTHERS THEN
3412            x_notification_result := x_activity_record.result;
3413            x_notification_response := 0;
3414     END;
3415   /*
3416     ** If the outcome for locating the RESULT is WF_NOTFOUND, then
3417     ** check to see if there are any RESPOND attributes other than
3418     ** RESULT.
3419     */
3420     IF x_notification_result = 'WF_NOTFOUND' THEN
3421        BEGIN
3422           SELECT count(*)
3423            INTO   x_notification_response
3424            FROM   wf_notification_attributes na,
3425                   wf_message_attributes_vl ma,
3426                   wf_notifications n
3427            WHERE  n.group_id = x_notification_id
3428            AND    n.message_type = ma.message_type
3429            AND    n.message_name = ma.message_name
3430            AND    ma.name = na.name
3431            AND    ma.subtype = 'RESPOND'
3432            AND    na.notification_id = n.notification_id;
3433        EXCEPTION
3434           WHEN OTHERS THEN
3435              x_notification_response := 0;
3436 
3437        END;
3438     END IF;
3439 
3440     /*
3441     ** Determine if the status of the activity has been requested on one of
3442     ** the checkboxes.  If the x_advanced is set to FALSE then you
3443     ** know you are calling this function from the main process list and not
3444     ** the framed list so just show the notifications with responses.
3445     */
3446     IF (INSTR(status_options, x_activity_record.activity_status) <> 0 OR
3447         x_advanced IN ('FALSE', 'FIRST')) THEN
3448 
3449        x_valid_status := TRUE;
3450 
3451     ELSE
3452 
3453        x_valid_status := FALSE;
3454 
3455     END IF;
3456 
3457     /*
3458     ** Now determine if the activity type matches what was checked in the
3459     ** activity options checkbox
3460     */
3461     x_show_activity := FALSE;
3462 
3463     /*
3464     ** Show the default list of open or closed notifications as it
3465     ** had done in the original monitor.  The criteria that the original
3466     ** monitor had was that the activity be a notification with a result
3467     ** value and that the notification status was either OPEN or CLOSED
3468     ** The x_advanced parameter tells the envelope function whether this
3469     ** is being called from the process list or the advanced query
3470     ** frame
3471     */
3472     IF (x_activity_record.activity_type = 'NOTICE' AND
3473         x_activity_record.notification_id IS NOT NULL AND
3474         NVL(x_notification_result,'UNSET') <> 'WF_NOTFOUND' AND
3475         NVL(x_activity_record.notification_status, 'OTHER') IN ('OPEN', 'CLOSED') AND
3476         (x_advanced = 'FALSE' OR
3477          x_advanced = 'FIRST')) THEN
3478 
3479         x_show_activity := TRUE;
3480 
3481     /*
3482     ** If the notification has a response and the Notification Option
3483     ** with responses has been checked or if you are in single frame mode
3484     ** which is the case when you first open the window then show the acitivity or
3485     ** If you've just started the multi frame mode in which case the x_advanced is
3486     ** set to FIRST then show the notification
3487     */
3488     ELSIF (x_activity_record.activity_type = 'NOTICE' AND
3489         x_activity_record.notification_id IS NOT NULL AND
3490         x_notification_response <> 0 AND
3491         NVL(x_activity_record.notification_status, 'OTHER') IN ('OPEN', 'CLOSED') AND
3492         x_note_resp IS NOT NULL AND
3493         (x_advanced = 'TRUE' OR
3494          x_advanced = 'FIRST')) THEN
3495 
3496         x_show_activity := TRUE;
3497 
3498     ELSIF (x_activity_record.activity_type = 'NOTICE' AND
3499          x_advanced = 'TRUE' AND x_note_noresp IS NOT NULL AND
3500          x_notification_response = 0 AND
3501         (x_activity_record.notification_id IS NULL OR
3502         NVL(x_notification_result, 'UNSET') = 'WF_NOTFOUND' OR
3503         NVL(x_activity_record.notification_status, 'OTHER') NOT IN ('OPEN', 'CLOSED'))) THEN
3504 
3505         x_show_activity := TRUE;
3506 
3507     ELSIF (x_activity_record.activity_type IN  ('FUNCTION', 'PROCESS') AND
3508         x_proc_func IS NOT NULL AND
3509         x_advanced = 'TRUE') THEN
3510 
3511         x_show_activity := TRUE;
3512 
3513     ELSIF (x_activity_record.activity_type = 'EVENT' AND
3514         x_event IS NOT NULL AND
3515         x_advanced = 'TRUE') THEN
3516 
3517         x_show_activity := TRUE;
3518 
3519     /*
3520     ** Check if you satisfy the show standard activities
3521     ** checkbox.  If the checkbox is set then we should show all
3522     ** standard activities.  We later check to see if the checkbox
3523     ** is not checked and eliminate all standard activities even if
3524     ** all the other criteria are met.
3525     */
3526     ELSIF (x_activity_record.activity_item_type = 'WFSTD' AND
3527            x_func_std IS NOT NULL) THEN
3528 
3529         x_show_activity := TRUE;
3530 
3531     END IF;
3532 
3533     /*
3534     ** Check if you satisfy the show standard activities
3535     ** checkbox.  If the checkbox is not set the don't show
3536     ** the activity under any circumstances.
3537     */
3538     IF (x_activity_record.activity_item_type = 'WFSTD' AND
3539            x_func_std IS NULL) THEN
3540 
3541         x_show_activity := FALSE;
3542 
3543     END IF;
3544 
3545     /*
3546     ** If the status of the activity matches the activity filter
3547     ** checkboxes and the activity options are satisfied then
3548     ** create the row on the html page.
3549     */
3550     IF (x_valid_status = TRUE AND x_show_activity = TRUE) THEN
3551 
3552        htp.tableRowOpen(calign=>'middle');
3553 
3554        /*
3555        ** If you are viewing the standard activity listing with the
3556        ** with the notifications with responses then use the DONE column
3557        ** to tell the user that this notification is completed or not.
3558        ** If you are viewing the Filtered Activity Listing then show the
3559        ** status of each activity rather than just if it's done or not
3560        */
3561        IF (x_advanced IN ('FIRST', 'TRUE')) THEN
3562 
3563            /*
3564            ** Get the appropriate icon for the given status
3565            */
3566            FOR l_record_num IN G_FIRST_STATUS..G_LAST_STATUS LOOP
3567 
3568              /*
3569              ** Check for the matching status_code
3570              */
3571              IF (x_activity_record.activity_status
3572                   = l_status_icons_table(l_record_num).status_code) THEN
3573 
3574                  x_icon_name :=l_status_icons_table(l_record_num).icon_file_name;
3575 
3576                  EXIT;
3577 
3578              END IF;
3579 
3580            END LOOP;
3581 
3582            if (x_icon_name = 'FNDIACTV.gif') then
3583                  htp.tableData(
3584                  htf.img(wfa_html.image_loc||x_icon_name, 'absmiddle',
3585                     wf_core.translate('ACTIVE'),
3586                     null, 'height=26')||
3587                  ' '||
3588                  x_activity_record.activity_status_display,
3589                  cattributes=>'id=""');
3590            elsif (x_icon_name = 'FNDIDONE.gif') then
3591                  htp.tableData(
3592                  htf.img(wfa_html.image_loc||x_icon_name, 'absmiddle',
3593                     wf_core.translate('COMPLETE'),
3594                     null, 'height=26')||
3595                  ' '||
3596                  x_activity_record.activity_status_display,
3597                  cattributes=>'id=""');
3598            elsif (x_icon_name = 'FNDIREDL.gif') then
3599                  htp.tableData(
3600                  htf.img(wfa_html.image_loc||x_icon_name, 'absmiddle',
3601                     wf_core.translate('ERROR'),
3602                     null, 'height=26')||
3603                  ' '||
3604                  x_activity_record.activity_status_display,
3605                  cattributes=>'id=""');
3606            else
3607                  htp.tableData(
3608                  htf.img(wfa_html.image_loc||x_icon_name, 'absmiddle',
3609                     wf_core.translate('SUSPEND'),
3610                     null, 'height=26')||
3611                  ' '||
3612                  x_activity_record.activity_status_display,
3613                  cattributes=>'id=""');
3614             end if;
3615 
3616 
3617        /*
3618        ** If you are still just looking at the notifications list
3619        ** and you are not in advanced mode then just show a DONE
3620        ** checkmark if the activity meets the criteria for being
3621        ** considered completed.
3622        */
3623        ELSE
3624 
3625           IF (x_activity_record.activity_status = 'COMPLETE' OR
3626               NVL(x_activity_record.notification_status, 'OPEN') =
3627                  'CLOSED') THEN
3628 
3629              htp.tableData(
3630                 htf.img(wfa_html.image_loc||'chckmark.gif', 'absmiddle',
3631                     wf_core.translate('COMPLETE'), null, 'height=26'),
3632                     cattributes=>'id=""');
3633 
3634           ELSE
3635 
3636               htp.tableData(htf.br,cattributes=>'id=""');
3637 
3638           END IF;
3639 
3640        END IF;
3641        /*
3642        ** If this activity has completed with status of ERROR then set
3643        ** the font color to red for any column that is not a soft link.
3644        ** If this activity has not completed in error then the string is
3645        ** set to null so that the default color is used.
3646        */
3647        IF (x_activity_record.activity_status = 'ERROR') THEN
3648 
3649           x_font_color := '<font color=#FF0000>';
3650           x_font_color_end := '</font>';
3651 
3652        ELSE
3653 
3654           x_font_color := null;
3655           x_font_color_end := null;
3656 
3657        END IF;
3658 
3659        /*
3660        ** Check to see if the activity you're about to list is a notification.
3661        ** If it is a notification then get the full name of the role that
3662        ** received the notification.
3663        ** If the activity is a process or a function then then use workflow
3664        ** engine for the who column.
3665        */
3666        IF (x_activity_record.activity_type = 'NOTICE') THEN
3667 
3668           /*
3669           ** Retrieve role information.  This has to be selected separately
3670           ** instead of joining into main select so the orig_system_ids can
3671           ** be used on wf_roles to preserve indexes over the view.
3672           */
3673           if (x_activity_record.recipient_role is not null) then
3674              wf_directory.getroleinfo(x_activity_record.recipient_role,
3675                 role_name, email_address, buf, buf, buf);
3676           end if;
3677 
3678           /*
3679           ** Default role info to recipient if role cannot be found
3680           */
3681           role_name := nvl(role_name, x_activity_record.recipient_role);
3682           email_address := nvl(email_address, x_activity_record.recipient_role);
3683 
3684           mlrurl := null;
3685           if (email_address is not null) then
3686             mlrurl := 'mailto:'||email_address;
3687           end if;
3688 
3689        ELSE
3690 
3691           mlrurl := NULL;
3692           role_name := wf_core.translate('WFMON_WF_ENGINE');
3693 
3694        END IF;
3695 
3696        /*
3697        ** Create the WHO column.  If the activity is a notification then
3698        ** the WHO column is based on the role that a notification was sent
3699        ** to.  If it is any other type of activity then the WHO column is
3700        ** set to Workflow engine.
3701        */
3702        if (mlrurl is not null) then
3703          htp.tableData(htf.anchor2(mlrurl, role_name, 'anchor_text', '_top'),
3704                     'Left',cattributes=>'id=""');
3705        else
3706          htp.tableData(x_font_color||role_name||x_font_color_end, 'Left',
3707              cattributes=>'id=""');
3708        end if;
3709 
3710        /*
3711        ** Only show the parent activity column if you are showing the
3712        ** advanced list .  Only create a hotlink in the parent activity
3713        ** column if the activity is not the ROOT activity.
3714        */
3715        IF (x_activity_record.parent_activity_name <> 'ROOT' AND
3716            x_advanced IN ('FIRST','TRUE')and not (pseudo_login)) THEN
3717 
3718           htp.tableData(
3719              cvalue=>'<A HREF="'||
3720                   owa_util.get_owa_service_path||
3721                   'wf_activities_vl_pub.fetch_draw_activity_details?p_item_type='||
3722                   wfa_html.conv_special_url_chars(x_item_type)||
3723                   '&p_activity_type='||
3724                   'PROCESS'||
3725                   '&p_effective_date='||
3726                   TO_CHAR(x_activity_record.begin_date, 'YYYY/MM/DD+HH24:MI:SS')||
3727                   '&p_name='||
3728                   wfa_html.conv_special_url_chars(x_activity_record.parent_activity_name)||
3729                   '" onMouseOver="window.status='||''''||
3730                   wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFMON_VIEW_ACTIVITY_DETAILS'))||''''||
3731                   '; return true"'||
3732                   ' TARGET="_top">'||
3733                   x_activity_record.parent_display_name||
3734                   '</A>',
3735              calign=>'Left', cattributes=>'id=""');
3736 
3737        ELSIF (x_advanced in ('FIRST', 'TRUE')) THEN
3738 
3739             htp.tableData('<BR>', 'Left',cattributes=>'id=""');
3740 
3741        END IF;
3742 
3743        /*
3744        ** Only create a hotlink in the activity column if this is not a folder
3745        ** activity type
3746        */
3747        IF (x_activity_record.activity_type <> 'FOLDER' and not (pseudo_login)) THEN
3748 
3749           -- add this response to point to the notification detail screen
3750           -- so that admin/user can response to a notification.
3751           n_response := null;
3752           if (x_activity_record.notification_status = 'OPEN') then
3753             open attrs(x_activity_record.notification_id);
3754             fetch attrs into result;
3755             if (attrs%found) then
3756               n_response :=
3757                 htf.anchor2(curl=>Wfa_Sec.DetailURL(
3758                                    x_activity_record.notification_id),
3759                            ctarget=>'_top',
3760                            ctext=>htf.img(
3761                                     curl=>wfa_html.image_loc||'reqresp.gif',
3762                         calt=>wf_core.translate('WFSRV_RECIPIENT_MUST_RESPOND'),
3763                                     cattributes=>'BORDER=0'));
3764             end if;
3765             close attrs;
3766           end if;
3767 
3768              htp.tableData(
3769              cvalue=>'<A HREF="'||
3770                      owa_util.get_owa_service_path||
3771                      'wf_activities_vl_pub.fetch_draw_activity_details?p_item_type='||
3772                      wfa_html.conv_special_url_chars(x_activity_record.activity_item_type)||
3773                      '&p_activity_type='||
3774                      x_activity_record.activity_type||
3775                      '&p_effective_date='||
3776                      TO_CHAR(x_activity_record.begin_date, 'YYYY/MM/DD+HH24:MI:SS')||
3777                      '&p_name='||
3778                      wfa_html.conv_special_url_chars(x_activity_record.activity_name)||
3779                      '" onMouseOver="window.status='||''''||
3780                      wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFMON_VIEW_ACTIVITY_DETAILS'))||''''||
3781                      '; return true"'||
3782                      ' TARGET="_top">'||
3783                      x_activity_record.activity_display_name||
3784                      '</A>'||n_response,
3785              calign=>'Left',cattributes=>'id=""');
3786 
3787        ELSE
3788 
3789           htp.tableData(x_font_color||
3790               x_activity_record.activity_display_name||
3791               x_font_color_end, 'Left',cattributes=>'id=""');
3792 
3793        END IF;
3794 
3795        /*
3796        ** Show the begin date column
3797        */
3798        htp.tableData(x_font_color||x_activity_record.begin_date_time||x_font_color_end, 'Left',cattributes=>'id=""');
3799 
3800        /*
3801        ** The x_activity_record.duration is based on the difference between
3802        ** the activity end_date or sysdate if the end_date is null minus the
3803        ** begin_date multiplied by 86400. (The number of seconds in a day.)
3804        ** Thus the x_activity_record.duration is defined in seconds.  We
3805        ** then calculate how many days, hours, minutes, and seconds that
3806        ** equates to.  The duration column is displayed in the most significant
3807        ** unit plus one lower unit.  Therefore if the the duration is more than
3808        ** a day the duration would show days and hours.  If the duration was
3809        ** just over a minute then we would show minutes and seconds.  If it were
3810        ** just a couple of seconds then thats all we show.
3811        */
3812        l_duration_seconds := x_activity_record.duration;
3813        l_duration_days := TRUNC(l_duration_seconds/86400);
3814        l_duration_hours :=
3815           TRUNC((l_duration_seconds - (l_duration_days * 86400))/3600);
3816        l_duration_minutes :=
3817           TRUNC((l_duration_seconds - (l_duration_days * 86400) -
3818              (l_duration_hours * 3600))/60);
3819        l_duration_seconds :=
3820           TRUNC(l_duration_seconds - (l_duration_days * 86400) -
3821              (l_duration_hours * 3600) - (l_duration_minutes * 60));
3822 
3823        IF (l_duration_days > 0) THEN
3824 
3825           x_duration_str :=
3826              TO_CHAR(l_duration_days)||' '||
3827                 wf_core.translate('WFMON_DAYS')||' '||
3828              TO_CHAR(l_duration_hours + (ROUND(l_duration_minutes/60)))||' '||
3829                 wf_core.translate('WFMON_HOURS');
3830 
3831        ELSIF (l_duration_hours > 0) THEN
3832 
3833           x_duration_str :=
3834              TO_CHAR(l_duration_hours)||' '||
3835                 wf_core.translate('WFMON_HOURS')||' '||
3836              TO_CHAR(l_duration_minutes +(ROUND(l_duration_seconds/60)))||' '||
3837                 wf_core.translate('WFMON_MINUTES');
3838 
3839        ELSIF (l_duration_minutes > 0) THEN
3840 
3841           x_duration_str :=
3842              TO_CHAR(l_duration_minutes)||' '||
3843                 wf_core.translate('WFMON_MINUTES')||' '||
3844              TO_CHAR(l_duration_seconds)||' '||
3845                 wf_core.translate('WFMON_SECONDS');
3846 
3847        ELSIF (l_duration_seconds >= 0) THEN
3848 
3849           x_duration_str :=
3850              TO_CHAR(l_duration_seconds)||' '||
3851                 wf_core.translate('WFMON_SECONDS');
3852 
3853 
3854        ELSE
3855 
3856           x_duration_str :=
3857              '0'||' '||wf_core.translate('WFMON_SECONDS');
3858 
3859        END IF;
3860 
3861        /*
3862        ** Show the duration string that we just constructed
3863        */
3864        htp.tableData(x_font_color||x_duration_str||x_font_color_end,
3865           'Left',cattributes=>'id=""');
3866 
3867        /*
3868        ** Show the result column value if the activity is completed or has
3869        ** exited with an error or its a notification and the notification is
3870        ** closed.
3871        */
3872        if (x_activity_record.activity_status IN ('COMPLETE', 'ERROR') OR
3873            NVL(x_activity_record.notification_status, 'OPEN') = 'CLOSED') then
3874 
3875          /*
3876          ** If this is a notification then show the result for that
3877          ** notification otherwise show the display name for the
3878          ** activity result
3879          */
3880          if (x_activity_record.activity_type = 'NOTICE' AND
3881              x_notification_result <> 'WF_NOTFOUND') THEN
3882 
3883             x_activity_record.result :=  x_notification_result;
3884 
3885          end if;
3886 
3887          /*
3888          ** If this is an activity that has exited with an error
3889          ** then create a hotlink in this column to be able to navigate
3890          ** to the error view.
3891          */
3892          IF (x_activity_record.activity_status = 'ERROR') THEN
3893 
3894             IF NOT (pseudo_login) then
3895              htp.tableData(
3896                 cvalue=>'<A TARGET="_top" HREF="'||
3897                         owa_util.get_owa_service_path||
3898                         'wf_monitor.draw_activity_error?x_item_type='||
3899                         wfa_html.conv_special_url_chars(x_item_type)||
3900                         '&x_item_key='||
3901                         wfa_html.conv_special_url_chars(x_item_key)||
3902                         '" onMouseOver="window.status='||''''||
3903                         wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFMON_VIEW_ERROR_DETAILS'))||' '||
3904                         wfa_html.conv_special_url_chars(x_activity_record.result)||''''||
3905                         '; return true"'||
3906                         '>'||
3907                         x_activity_record.result||
3908                         '</A>',
3909                 calign=>'Left',
3910                 cattributes=>'id=""');
3911               ELSE
3912                htp.tableData(x_font_color||x_activity_record.result||x_font_color_end, 'Left',cattributes=>'id=""');
3913               END IF;
3914 
3915          ELSE
3916 
3917             IF (x_activity_record.result IS NOT NULL) THEN
3918 
3919                htp.tableData(x_font_color||x_activity_record.result||x_font_color_end, 'Left',cattributes=>'id=""');
3920 
3921             ELSE
3922 
3923                htp.tableData(htf.br,cattributes=>'id=""');
3924 
3925             END IF;
3926 
3927          END IF;
3928 
3929        else
3930 
3931          htp.tableData(htf.br,cattributes=>'id=""');
3932 
3933        end if;
3934 
3935        htp.tableRowClose;
3936 
3937     end if;
3938 
3939   end loop;
3940 
3941   CLOSE x_activity_cursor;
3942 
3943   htp.tableClose;
3944 
3945   htp.p(htf.formHidden('x_item_type', x_item_type));
3946   htp.p(htf.formHidden('x_item_key', x_item_key));
3947   htp.p(htf.formHidden('x_admin_mode', x_admin_mode));
3948   htp.p(htf.formHidden('x_access_key', x_access_key));
3949   htp.p(htf.formHidden('x_nls_lang', x_nls_lang));
3950 
3951   htp.formClose;
3952 
3953   htp.tableOpen(cattributes=>'border=0 cellpadding=5 cellspacing=0
3954                        ALIGN=CENTER summary=""');
3955 
3956   htp.tableRowOpen;
3957 
3958   htp.p('<TD ID="">');
3959 
3960   wfa_html.create_reg_button ('javascript:document.envelope.submit()',
3961                               wf_core.translate ('WFMON_VIEW_DIAGRAM'),
3962                               wfa_html.image_loc,
3963                               null,
3964                               wf_core.translate ('WFMON_VIEW_DIAGRAM'));
3965 
3966   htp.p('</TD>');
3967 
3968 
3969   /*
3970   ** If the envelope function is being called from the main process
3971   ** window then there will always be FALSE in the activity
3972   ** options parameter so you want to show the advanced options button.
3973   */
3974   IF (x_advanced = 'FALSE') THEN
3975 
3976      htp.p('<FORM NAME="advanced" ACTION="wf_monitor.envelope_frame" METHOD="GET" TARGET="DETAILS">');
3977 
3978      htp.p(htf.formHidden('x_advanced', 'FIRST'));
3979      htp.p(htf.formHidden('x_item_type', x_item_type));
3980      htp.p(htf.formHidden('x_item_key', x_item_key));
3981      htp.p(htf.formHidden('x_admin_mode', x_admin_mode));
3982      htp.p(htf.formHidden('x_access_key', x_access_key));
3983      htp.p(htf.formHidden('x_active','ACTIVE'));
3984      htp.p(htf.formHidden('x_complete','COMPLETE'));
3985      htp.p(htf.formHidden('x_error','ERROR'));
3986      htp.p(htf.formHidden('x_suspend','SUSPEND'));
3987      htp.p(htf.formHidden('x_proc_func',null));
3988      htp.p(htf.formHidden('x_note_resp','Y'));
3989      htp.p(htf.formHidden('x_note_noresp',null));
3990      htp.p(htf.formHidden('x_func_std',null));
3991      htp.p(htf.formHidden('x_event',null));
3992      htp.p(htf.formHidden('x_sort_column','STARTDATE'));
3993      htp.p(htf.formHidden('x_sort_order', 'ASC'));
3994      htp.p(htf.formHidden('x_nls_lang', x_nls_lang));
3995 
3996 
3997      htp.p('<TD ID="">');
3998 
3999      wfa_html.create_reg_button ('javascript:document.advanced.submit()',
4000                                  wf_core.translate ('WFMON_REPORT_OPTIONS'),
4001                                  wfa_html.image_loc,
4002                                  null,
4003                                  wf_core.translate ('WFMON_REPORT_OPTIONS'));
4004 
4005      htp.p('</TD>');
4006 
4007      htp.formClose;
4008 
4009   END IF;
4010 
4011   htp.tableRowClose;
4012 
4013   htp.tableClose;
4014 
4015   wfa_sec.footer;
4016 
4017   htp.htmlClose;
4018 
4019 exception
4020   when others then
4021     Wf_Core.Context('Wf_Monitor', 'Envelope_Frame', x_item_type, x_item_key);
4022     Error;
4023 end envelope_frame;
4024 
4025 -- MODIFICATION LOG:
4026 -- 06-JUN-2001 JWSMITH BUG 1819232 -Added summary attr for table tag for ADA
4027 --
4028 procedure draw_activity_error (
4029  x_item_type IN VARCHAR2,
4030  x_item_key  IN VARCHAR2
4031 ) IS
4032 
4033 CURSOR fetch_errors (c_item_type VARCHAR2,
4034                      c_item_key  VARCHAR2) IS
4035 select  ac.display_name,
4036         wf_core.activity_result(ac.result_type, ias.activity_result_code) result,
4037         ias.error_name,
4038         ias.error_message,
4039         ias.error_stack
4040 from    wf_item_activity_statuses ias,
4041         wf_process_activities pa,
4042         wf_activities_vl ac,
4043         wf_activities_vl ap,
4044         wf_items i
4045 where   ias.item_type = c_item_type
4046 and     ias.item_key  = c_item_key
4047 and     ias.activity_status     = 'ERROR'
4048 and     ias.process_activity    = pa.instance_id
4049 and     pa.activity_name        = ac.name
4050 and     pa.activity_item_type   = ac.item_type
4051 and     pa.process_name         = ap.name
4052 and     pa.process_item_type    = ap.item_type
4053 and     pa.process_version      = ap.version
4054 and     i.item_type             = c_item_type
4055 and     i.item_key              = ias.item_key
4056 and     i.begin_date            >= ac.begin_date
4057 and     i.begin_date            < nvl(ac.end_date, i.begin_date+1)
4058 order by ias.begin_date, ias.execution_time;
4059 
4060 l_title          VARCHAR2(240) := wf_core.translate ('WFMON_ERROR_TITLE');
4061 username varchar2(320);
4062 
4063 BEGIN
4064 
4065   /*
4066   ** Create the  Window title
4067   */
4068   htp.htmlOpen;
4069   htp.headOpen;
4070   htp.title(l_title);
4071   wfa_html.create_help_function('wf/links/wfm.htm?WFMON');
4072 
4073   -- call getsession to set context else header will print
4074   -- differently in apps.
4075 
4076   wfa_sec.GetSession(username);
4077 
4078   /*
4079   ** Open body and draw standard header
4080   */
4081   wfa_sec.header;
4082 
4083   htp.p('</BODY><BR>');
4084 
4085   /*
4086   ** Draw the section title for the lookup detail section
4087   */
4088   wf_item_definition_util_pub.draw_detail_section_title (
4089      l_title,
4090      0);
4091 
4092 
4093   FOR l_error_rec IN fetch_errors(x_item_type, x_item_key) LOOP
4094 
4095      /*
4096      ** Open a new table for each lookup so you can control the spacing
4097      ** between each attribute
4098      */
4099      htp.tableOpen(cattributes=>'border=0 cellpadding=0 cellspacing=0
4100                        summary=""');
4101 
4102      wf_item_definition_util_pub.draw_detail_prompt_value_pair (
4103         wf_core.translate('WFMON_ACTIVITY'),
4104         l_error_rec.display_name);
4105 
4106      wf_item_definition_util_pub.draw_detail_prompt_value_pair (
4107         wf_core.translate('WFMON_RESULT'),
4108         l_error_rec.result);
4109 
4110      wf_item_definition_util_pub.draw_detail_prompt_value_pair (
4111         wf_core.translate('WFMON_ERROR_NAME'),
4112         l_error_rec.error_name);
4113 
4114      wf_item_definition_util_pub.draw_detail_prompt_value_pair (
4115         wf_core.translate('WFMON_ERROR_MESSAGE'),
4116         l_error_rec.error_message);
4117 
4118      wf_item_definition_util_pub.draw_detail_prompt_value_pair (
4119         wf_core.translate('WFMON_ERROR_STACK'),
4120         l_error_rec.error_stack);
4121 
4122      /*
4123      ** Table is created so close it out
4124      */
4125      htp.tableClose;
4126 
4127   END LOOP;
4128 
4129 exception
4130   when others then
4131     Wf_Core.Context('Wf_Monitor', 'Draw_Activity_Error', x_item_type, x_item_key);
4132     Error;
4133 
4134 END draw_activity_error;
4135 
4136 
4137 procedure get_process_children (
4138 p_parent_item_type IN VARCHAR2,
4139 p_parent_item_key  IN VARCHAR2,
4140 p_child_item_list  OUT NOCOPY wf_monitor.wf_items_tbl_type,
4141 p_number_of_children OUT NOCOPY NUMBER) IS
4142 
4143 cursor c_get_process_children IS
4144 SELECT item_type,
4145        item_key,
4146        root_activity,
4147        root_activity_version,
4148        user_key,
4149        owner_role,
4150        begin_date,
4151        end_date
4152 FROM   wf_items
4153 WHERE  parent_item_type = p_parent_item_type
4154 AND    parent_item_key  = p_parent_item_key;
4155 
4156 l_record_num   NUMBER := 0;
4157 
4158 BEGIN
4159 
4160     OPEN c_get_process_children;
4161 
4162     /*
4163     ** Loop through all the lookup_code rows for the given lookup_type
4164     ** filling in the p_wf_lookups_tbl
4165     */
4166     LOOP
4167 
4168        l_record_num := l_record_num + 1;
4169 
4170        FETCH c_get_process_children INTO
4171              p_child_item_list (l_record_num);
4172 
4173        EXIT WHEN c_get_process_children%NOTFOUND;
4174 
4175     END LOOP;
4176 
4177     CLOSE c_get_process_children;
4178     p_number_of_children := l_record_num - 1;
4179 
4180 
4181 exception
4182   when no_data_found THEN
4183      CLOSE c_get_process_children;
4184      p_number_of_children := 0;
4185      return;
4186   when others then
4187     Wf_Core.Context('Wf_Monitor', 'get_process_children',
4188            p_parent_item_type, p_parent_item_key);
4189     Error;
4190 
4191 END get_process_children;
4192 
4193 procedure draw_process_children (
4194 p_parent_item_type IN VARCHAR2,
4195 p_parent_item_key  IN VARCHAR2,
4196 p_admin_mode       IN VARCHAR2,
4197 p_indent_level     IN NUMBER,
4198 p_nls_lang         IN VARCHAR2) IS
4199 
4200 username              VARCHAR2(320);
4201 access_key            VARCHAR2(240);
4202 l_child_item_list     wf_monitor.wf_items_tbl_type;
4203 l_number_of_children  NUMBER :=0;
4204 l_record_num          NUMBER := 0;
4205 ii                    NUMBER := 0;
4206 l_indent_str          VARCHAR2(240) := NULL;
4207 l_item_type_disp_name VARCHAR2(80);
4208 
4209 BEGIN
4210 
4211   access_key := GetAccessKey(p_parent_item_type, p_parent_item_key, p_admin_mode);
4212 
4213    /*
4214    ** Get the display name for the item type
4215    */
4216    BEGIN
4217 
4218    SELECT display_name
4219    INTO   l_item_type_disp_name
4220    FROM   wf_item_types_vl
4221    WHERE  name = p_parent_item_type;
4222 
4223    exception
4224    when no_data_found THEN
4225       l_item_type_disp_name := NULL;
4226    when others THEN
4227       raise;
4228 
4229    END;
4230 
4231    /*
4232    ** Create the indent string
4233    */
4234    for ii in 1..p_indent_level LOOP
4235 
4236       l_indent_str := l_indent_str || '     ';
4237 
4238    END LOOP;
4239 
4240    /*
4241    ** Create the link for the current item
4242    */
4243    htp.tableRowOpen;
4244    htp.p ('<TD ID="" NOWRAP>');
4245 
4246    htp.p ('<FONT SIZE=-1>');
4247 
4248    htp.p(l_indent_str||'<A HREF="'||
4249          wfa_html.base_url||
4250          '/wf_monitor.envelope_frame'||
4251          '?'||'x_item_type=' ||wfa_html.conv_special_url_chars(p_parent_item_type)||
4252          '&'||'x_item_key='  ||wfa_html.conv_special_url_chars(p_parent_item_key)||
4253          '&'||'x_admin_mode='||p_admin_mode||
4254          '&'||'x_access_key='||access_key||
4255          '&'||'x_advanced=FALSE'||
4256          '&'||'x_nls_lang='||p_nls_lang||
4257      '" TARGET="DETAILS">'||
4258      l_item_type_disp_name||' - '||p_parent_item_key||'</A>');
4259 
4260    htp.p ('</FONT>');
4261 
4262    htp.tableRowClose;
4263    htp.p ('</TD>');
4264 
4265    /*
4266    ** Get the process children for this row
4267    */
4268    wf_monitor.get_process_children(p_parent_item_type,
4269                                    p_parent_item_key,
4270                                    l_child_item_list,
4271                                    l_number_of_children);
4272 
4273 
4274    /*
4275    ** Loop through the children and print their children recursively
4276    */
4277    FOR l_record_num IN 1..l_number_of_children LOOP
4278 
4279        wf_monitor.draw_process_children (l_child_item_list(l_record_num).item_type,
4280                                          l_child_item_list(l_record_num).item_key,
4281                                          p_admin_mode,
4282                                          p_indent_level+1,
4283                                          p_nls_lang);
4284 
4285    END LOOP;
4286 
4287 exception
4288   when others then
4289     Wf_Core.Context('Wf_Monitor', 'draw_process_children',
4290            p_parent_item_type, p_parent_item_key,
4291            p_admin_mode , p_indent_level, p_nls_lang);
4292 
4293     Error;
4294 
4295 END draw_process_children;
4296 
4297 -- MODIFICATION LOG:
4298 -- 06-JUN-2001 JWSMITH BUG 1819232 - Added summary attr for table tag for ADA
4299 --
4300 procedure process_children (
4301 x_item_type        IN VARCHAR2,
4302 x_item_key         IN VARCHAR2,
4303 x_admin_mode       IN VARCHAR2,
4304 x_nls_lang         IN varchar2) IS
4305 BEGIN
4306 
4307    wfa_sec.header(background_only=>TRUE);
4308 
4309    htp.tableopen(cattributes=>'summary=""');
4310 
4311    wf_monitor.draw_process_children (x_item_type,
4312                                      x_item_key,
4313                                      x_admin_mode,
4314                                      0,x_nls_lang);
4315 
4316 
4317    htp.tableclose;
4318 
4319    wfa_sec.footer;
4320 
4321 exception
4322   when others then
4323     Wf_Core.Context('Wf_Monitor', 'process_children',
4324            x_item_type, x_item_key);
4325     Error;
4326 
4327 END process_children;
4328 
4329 
4330 function getDiagramDataURL(
4331    p_item_type in varchar2,
4332    p_item_key in varchar2,
4333    p_admin_mode in varchar2,
4334    p_access_key in varchar2,
4335    p_lang_code in varchar2
4336 )
4337 return varchar2
4338 is
4339    l_url_value varchar2(2000);
4340    l_func varchar2(2000);
4341    l_params varchar2(1000);
4342 begin
4343 
4344    l_params := 'itemType='||p_item_type||
4345               '&'||'itemKey='||p_item_key||
4346               '&'||'adminMode='||p_admin_mode||
4347               '&'||'accessKey='||p_access_key||'&retainAM=Y';
4348 
4349    l_func := fnd_run_function.get_run_function_url(
4350                p_function_name =>'WF_MONITOR_DIAGRAM_DATA',
4351                p_resp_appl => null,
4352                p_resp_key => null,
4353                p_security_group_key => null,
4354                p_parameters => l_params,
4355                p_override_agent => null,
4356                p_encryptParameters => false);
4357 
4358    return l_func;
4359 end getDiagramDataURL;
4360 
4361 function getDiagramResourceURL return varchar2
4362 is
4363    l_func varchar2(4000);
4364 begin
4365    l_func := fnd_run_function.get_run_function_url(
4366                 p_function_name =>'WF_MONITOR_RES',
4367                 p_resp_appl => null,
4368                 p_resp_key => null,
4369                 p_security_group_key => null,
4370                 p_parameters => 'retainAM=Y',
4371                 p_override_agent => null,
4372                 p_encryptParameters => false );
4373 
4374   return l_func;
4375 end getDiagramResourceURL;
4376 
4377 function getDiagramResourcesURL return varchar2
4378 is
4379    l_func varchar2(4000);
4380    p_resType varchar2(10) := 'WFTKN';
4381    p_resPattern varchar2(10) := 'WFMON';
4382    l_params varchar2(2000);
4383 begin
4384    l_params := 'resType='||p_resType||
4385               '&'||'resPattern='||p_resPattern||'&retainAM=Y';
4386 
4387    l_func := fnd_run_function.get_run_function_url(
4388                 p_function_name =>'WF_MONITOR_CRES_DATA',
4389                 p_resp_appl => null,
4390                 p_resp_key => null,
4391                 p_security_group_key => null,
4392                 p_parameters => l_params,
4393                 p_override_agent => null,
4394                 p_encryptParameters => false );
4395 
4396   return l_func;
4397 end getDiagramResourcesURL;
4398 
4399 --   Sends back a very simple dynamic HTML page to tell the browser what
4400 --   applet to run.
4401 -- IN
4402 --   x_item_type
4403 --   x_item_key
4404 --   x_admin_mode
4405 function createapplettags(
4406     x_item_type  in varchar2,
4407     x_item_key   in varchar2,
4408     x_admin_mode in varchar2,
4409     x_access_key in varchar2,
4410     x_nls_lang   in varchar2,
4411     x_browser    in varchar2) return varchar2 is
4412 
4413  lang_codeset varchar2(50);
4414  l_code varchar2(80) :=  'oracle.apps.fnd.wf.Monitor';
4415  l_archive varchar2(2000);      -- first look for java classes at this archive
4416  l_wf_plugin_download varchar2(80);
4417  l_wf_plugin_version varchar2(80);
4418  l_wf_classid varchar2(80);
4419  l_ie_plugin_ver varchar2(80);  -- IE version is delimited by ','
4420  l_admin varchar(4) := 'no';
4421  l_installType varchar2(30) := 'EMBEDDED';
4422  l_java_loc VARCHAR2(80) := '/OA_JAVA/';
4423  l_return_buffer varchar2(32000) := '';
4424  username varchar2(320);
4425  admin_role varchar2(320);
4426  l_apps_fwk_agent varchar2(2000);
4427  l_data_url varchar2(4000);
4428  l_res_url varchar2(2000);
4429  l_ress_url varchar2(4000);
4430 
4431 begin
4432 
4433    lang_codeset := substr(userenv('LANGUAGE'),instr(userenv('LANGUAGE'),'.')+1,
4434                          length(userenv('LANGUAGE')));
4435 
4436    -- this portion of the code wil not be executed now as this API is called
4437    -- with x_admin_mode = 'N' all the time.
4438 
4439    if (upper(substr(x_admin_mode, 1, 1)) = 'Y') then
4440       -- wfa_sec.GetSession commented out for the time being. we need to
4441       -- reimplement this in Framework in the future
4442       -- wfa_sec.GetSession(username);
4443       -- Security checking
4444       admin_role := wf_core.Translate('WF_ADMIN_ROLE');
4445       if (admin_role <> '*')  then
4446          if (wf_directory.IsPerformer(username, admin_role)) then
4447             l_admin := 'yes';
4448          end if;
4449       else
4450          -- no security. Eveybody is admin
4451          l_admin := 'yes';
4452       end if;
4453    end if;
4454 
4455    l_apps_fwk_agent :=  fnd_web_config.trail_slash(fnd_profile.value('APPS_FRAMEWORK_AGENT'));
4456    l_data_url := getDiagramDataURL(x_item_type, x_item_key, l_admin, x_access_key, lang_codeset);
4457    l_res_url := getDiagramResourceURL();
4458    l_ress_url := getDiagramResourcesUrl();
4459 
4460 
4461    if ( x_browser = 'WIN') then
4462 
4463       l_archive := '/OA_JAVA/oracle/apps/fnd/jar/wfmon.jar, ' ||
4464                    '/OA_JAVA/oracle/apps/fnd/jar/fndewt.jar, ' ||
4465                    '/OA_JAVA/oracle/apps/fnd/jar/fndswing.jar, ' ||
4466                    '/OA_JAVA/oracle/apps/fnd/jar/fndbalishare.jar, ' ||
4467                    '/OA_JAVA/oracle/apps/fnd/jar/fndctx.jar';
4468 
4469       l_wf_plugin_download := Wf_Core.translate('WF_PLUGIN_DOWNLOAD');
4470       l_wf_plugin_version := Wf_Core.translate('WF_PLUGIN_VERSION');
4471       l_wf_classid := Wf_Core.translate('WF_CLASSID');
4472       l_ie_plugin_ver := replace(Wf_Core.translate('WF_PLUGIN_VERSION'), '.', ',');
4473 
4474        l_return_buffer := l_return_buffer ||
4475              '<OBJECT classid="clsid:'||l_wf_classid||'" '||
4476              'WIDTH=100% HEIGHT=400 '||
4477              'CODEBASE="'||l_wf_plugin_download||
4478              '#Version='||l_ie_plugin_ver||'">'||
4479            '<PARAM NAME="jinit_appletcache" VALUE="off">'||
4480            '<PARAM NAME="CODE"     VALUE="'||l_code||'">'||
4481            '<PARAM NAME="CODEBASE" VALUE="'||'/OA_JAVA/'||'">'||
4482            '<PARAM NAME="ARCHIVE"  VALUE="'||l_archive||'">' ||
4483            '<PARAM NAME="itemtype"  VALUE="'||x_item_type||'">' ||
4484            '<PARAM NAME="itemkey"  VALUE="'||x_item_key||'">' ||
4485            '<PARAM NAME="docbase"  VALUE="'|| l_apps_fwk_agent || '">' ||
4486            '<PARAM NAME="langcodeset"  VALUE="'||lang_codeset||'">' ||
4487            '<PARAM NAME="accesskey"  VALUE="'||x_access_key||'">' ||
4488            '<PARAM NAME="admin"  VALUE="'||l_admin||'">' ||
4489            '<PARAM NAME="dataUrl"  VALUE="'||l_data_url||'">' ||
4490            '<PARAM NAME="resUrl"  VALUE="'||l_res_url||'">' ||
4491            '<PARAM NAME="ressUrl"  VALUE="'||l_ress_url||'">' ||
4492            '<PARAM NAME="type"     VALUE="'||
4493                         'application/x-jinit-applet;version='||
4494                         l_wf_plugin_version||'">' ||
4495            '<PARAM NAME="installType"  VALUE="' || l_installType || '">';
4496 
4497        l_return_buffer := l_return_buffer ||
4498              '<COMMENT>'||
4499              '<EMBED type="application/x-jinit-applet;version='||
4500                l_wf_plugin_version||'"'||
4501              ' WIDTH="100%" HEIGHT="90%"'||
4502              ' jinit_appletcache="off"'||
4503              ' java_CODE="'||l_code||'"'||
4504              ' java_CODEBASE="'||l_java_loc||'"'||
4505              ' java_ARCHIVE="'||l_archive||'"'||
4506              ' itemtype="'||x_item_type||'"' ||
4507              ' itemkey="'||x_item_key||'"' ||
4508              ' langcodeset="'||lang_codeset||'"' ||
4509              ' accesskey="'||x_access_key||'"' ||
4510              ' admin="'||l_admin||'"' ||
4511              ' dataUrl="'||l_data_url||'"' ||
4512              ' resUrl="'||l_res_url||'"' ||
4513              ' ressUrl="'||l_ress_url||'"' ||
4514              ' pluginurl="'|| l_wf_plugin_download||'"' ||
4515              ' installType="' || l_installType || '">'||
4516              '<NOEMBED></COMMENT></NOEMBED></EMBED></OBJECT>';
4517     else
4518 
4519      -- Client is not Windows, so we don't want to call Jinitiator.
4520       l_return_buffer := l_return_buffer ||
4521         '<applet code=oracle.apps.fnd.wf.Monitor.class codebase="/OA_JAVA"';
4522 
4523       l_archive :=  '/OA_JAVA/oracle/apps/fnd/jar/wfmon.jar, ' ||
4524                     '/OA_JAVA/oracle/apps/fnd/jar/fndewt.jar, ' ||
4525                     '/OA_JAVA/oracle/apps/fnd/jar/fndswing.jar, ' ||
4526                     '/OA_JAVA/oracle/apps/fnd/jar/fndbalishare.jar, ' ||
4527                     '/OA_JAVA/oracle/apps/fnd/jar/fndctx.jar';
4528 
4529       l_return_buffer := l_return_buffer ||
4530         ' archive="' || l_archive || '"';
4531 
4532       l_return_buffer := l_return_buffer ||
4533          ' width=800 height=400> '||
4534          ' <param name=itemtype value="' || x_item_type || '">' ||
4535          ' <param name=itemkey value="' || x_item_key || '">'||
4536          ' <param name=langcodeset value="' || lang_codeset || '">' ||
4537          ' <param name=docbase value="' || l_apps_fwk_agent || '">' ||
4538          ' <param name=admin value="' || l_admin || '">' ||
4539          ' <param name=accesskey value="' || x_access_key || '">' ||
4540          ' <param name="dataUrl"  value="'||l_data_url||'">' ||
4541          ' <param name="resUrl"  value="'||l_res_url||'">' ||
4542          ' <param name="ressUrl"  value="'||l_ress_url||'">' ||
4543          ' <param name=installType value="' || l_installType || '">' ||
4544          ' </applet>';
4545 
4546     end if;
4547 
4548     return l_return_buffer;
4549 
4550 end createapplettags;
4551 
4552 end WF_MONITOR;