[Home] [Help]
PACKAGE BODY: APPS.FND_WEBATTCH
Source
1 package body FND_WEBATTCH as
2 /* $Header: AFATCHMB.pls 120.5.12020000.2 2012/08/30 17:58:50 ctilley ship $ */
3
4
5 -- Package Variables which stores the seed data for attachments.
6 g_function_name varchar2(30) := null;
7 g_entity_name varchar2(40) := null;
8 g_pk1_value varchar2(100) := null;
9 g_pk2_value varchar2(100) := null;
10 g_pk3_value varchar2(100) := null;
11 g_pk4_value varchar2(150) := null;
12 g_pk5_value varchar2(150) := null;
13 g_chr_newline varchar2(1) :='
14 '; -- NewLine Character
15
16
17 -- GetSummaryStatus
18 -- IN
19 -- function_name --Function name of the form
20 -- entity_name - Entity name for which attachment is made.
21 -- pk1_value - First Primary Key value of the entity.
22 -- to
23 -- pk5_value - Fifth Primary key value of the entity.
24 -- OUT
25 -- attchmt_status - Indicates Attachment Status -
26 -- 'EMPTY','FULL','DISABLED'.
27 --
28 procedure GetSummaryStatus (
29 x_function_name in varchar2,
30 x_entity_name in varchar2,
31 x_pk1_value in varchar2,
32 x_pk2_value in varchar2 default NULL,
33 x_pk3_value in varchar2 default NULL,
34 x_pk4_value in varchar2 default NULL,
35 x_pk5_value in varchar2 default NULL,
36 attchmt_status out NOCOPY varchar2
37 )
38 as
39 attchmt_exists varchar2(1);
40 attachment_defined_flag boolean;
41 l_function_type varchar2(1) := 'F';
42 begin
43
44
45 -- Validate the session
46 /*if NOT (icx_sec.ValidateSession(null)) then
47 return;
48 end if; */
49
50 -- Set the parameters to package global
51 g_function_name := x_function_name;
52 g_entity_name := x_entity_name;
53 g_pk1_value := x_pk1_value;
54 g_pk2_value := x_pk2_value;
55 g_pk3_value := x_pk3_value;
56 g_pk4_value := x_pk4_value;
57 g_pk5_value := x_pk5_value;
58
59 -- Find out if attachment is enabled in this function.
60 fnd_attachment_util_pkg.init_atchmt (
61 g_function_name,
62 attachment_defined_flag,
63 l_function_type);
64
65 -- If the attachment is enabled then enable the link.
66 if ( attachment_defined_flag = TRUE ) then
67
68 -- Set the link to 'FULL' or 'EMPTY'.
69 attchmt_exists:=fnd_attachment_util_pkg.get_atchmt_exists (
70 g_entity_name,
71 g_pk1_value,
72 g_pk2_value,
73 g_pk3_value,
74 g_pk4_value,
75 g_pk5_value,
76 g_function_name,
77 l_function_type);
78 if (attchmt_exists = 'Y') then
79 attchmt_status := 'FULL';
80 elsif (attchmt_exists = 'N') then
81 attchmt_status := 'EMPTY';
82 end if;
83 else
84 attchmt_status := 'DISABLED';
85 end if;
86 exception
87 when others then
88 attchmt_status := 'DISABLED';
89 end GetSummaryStatus;
90
91 -- GetSummaryList
92 -- IN
93 -- attchmt_status - Indicates Attachment Status -
94 -- EMPTY, FULL, DISABLED.
95 -- from_url - URL from which the attachments is invoked from.
96 -- This is required to set the back link.
97 -- query_only - Query flag is set 'Y' when called in query only
98 -- mode.
99 -- OUT
100 -- URL - URL string to linked to the attachment button.
101 --
102
103 procedure GetSummaryList (
104 attchmt_status in varchar2 default 'DISABLED',
105 from_url in varchar2,
106 query_only in varchar2 default 'N',
107 package_name in varchar2 default 'FND_WEBATTCH',
108 URL out NOCOPY varchar2
109 )
110 as
111 begin
112
113 -- Check if the attachment status.
114 if (attchmt_status <> 'DISABLED') then
115 URL := fnd_web_config.plsql_agent || package_name
116 ||'.Summary?function_name=' || icx_call.encrypt2(g_function_name)
117 ||'&'||'entity_name='|| icx_call.encrypt2(g_entity_name)
118 ||'&'||'pk1_value='|| icx_call.encrypt2(g_pk1_value)
119 ||'&'||'pk2_value='|| icx_call.encrypt2(g_pk2_value)
120 ||'&'||'pk3_value='|| icx_call.encrypt2(g_pk3_value)
121 ||'&'||'pk4_value='|| icx_call.encrypt2(g_pk4_value)
122 ||'&'||'pk5_value='|| icx_call.encrypt2(g_pk5_value)
123 ||'&'||'from_url=' || icx_call.encrypt2(from_url)
124 ||'&'||'query_only='|| icx_call.encrypt2(query_only);
125 end if;
126
127 end GetSummaryList;
128
129 --
130 -- Summary
131 -- Construct the list of attachments for an entity.
132 --
133 procedure Summary (
134 function_name in varchar2,
135 entity_name in varchar2,
136 pk1_value in varchar2,
137 pk2_value in varchar2 default NULL,
138 pk3_value in varchar2 default NULL,
139 pk4_value in varchar2 default NULL,
140 pk5_value in varchar2 default NULL,
141 from_url in varchar2,
142 query_only in varchar2 default 'N'
143 ) as
144
145 l_function_name varchar2(30) := icx_call.decrypt2(summary.function_name);
146 l_entity_name varchar2(40) := icx_call.decrypt2(summary.entity_name);
147 l_pk1_value varchar2(100) := icx_call.decrypt2(summary.pk1_value);
148 l_pk2_value varchar2(100) := icx_call.decrypt2(summary.pk2_value);
149 l_pk3_value varchar2(100) := icx_call.decrypt2(summary.pk3_value);
150 l_pk4_value varchar2(150) := icx_call.decrypt2(summary.pk4_value);
151 l_pk5_value varchar2(150) := icx_call.decrypt2(summary.pk5_value);
152 l_from_url varchar2(2000) := icx_call.decrypt2(summary.from_url);
153 l_query_only varchar2(100) := icx_call.decrypt2(summary.query_only);
154 l_lang varchar2(24);
155 l_dcdname varchar2(80):= owa_util.get_cgi_env('SCRIPT_NAME');
156 l_packagename varchar2(80) := 'FND_WEBATTCH';
157 begin
158
159 -- Validate the session
160 if NOT (icx_sec.ValidateSession(null)) then
161 return;
162 end if;
163
164 -- Set the language
165 l_lang := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
166
167
168 -- Show attachment summary and document info in frames.
169 htp.htmlOpen;
170 htp.headOpen;
171
172 htp.framesetopen(crows=>'60, *, *', cattributes =>'frameborder=no border=0');
173
174 -- Call the procedure that prints header
175 htp.frame (csrc => l_dcdname || '/fnd_webattch.Header?Lang='||l_lang,
176 cname => 'header_frame', cmarginheight=>'0',
177 cmarginwidth=> '0', cscrolling => 'NO',
178 cnoresize => 'NORESIZE', cattributes => 'FRAMEBORDER=NO');
179
180 -- Print The Body of the Summary page.
181 htp.frame (csrc => l_dcdname ||'/'||
182 'fnd_webattch.PrintSummary?package_name='|| l_packagename ||
183 '&'||'function_name='||l_function_name ||
184 '&'||'entity_name='||l_entity_name ||
185 '&'||'pk1_value='||l_pk1_value ||
186 '&'||'pk2_value='||l_pk2_value ||
187 '&'||'pk3_value='||l_pk3_value ||
188 '&'||'pk4_value='||l_pk4_value ||
189 '&'||'pk5_value='||l_pk5_value||
190 '&'||'from_url='||l_from_url ||
191 '&'||'query_only='||l_query_only,
192 cname => 'list_frame',
193 cmarginheight=>'0', cmarginwidth=> '10', cscrolling => 'AUTO',
194 cnoresize => 'NORESIZE', cattributes => 'FRAMEBORDER=NO');
195
196 -- Make an empty frame for document data.
197 htp.frame (csrc => l_dcdname || '/'||'fnd_webattch.PrintBlankPage',
198 cname => 'document_frame', cmarginheight=>'0',
199 cmarginwidth=> '10', cscrolling => 'AUTO',
200 cnoresize => 'NORESIZE', cattributes => 'FRAMEBORDER=NO');
201
202 -- Close the frameset.
203 htp.framesetclose;
204
205 end Summary;
206
207 -- procedure DocumentInformation (Private Procedure)
208 -- IN
209 -- x_datatype_id - 0 if all the document info.type are blank.
210 -- x_short_text - Short text document Info.
211 -- x_long_text - Long text document Info.
212 -- x_file_name - File / URL info. : File Name when datatype_id is 6
213 -- URL when datatype_id is 5
214 --
215 procedure DocumentInformation (
216 x_datatype_id in number ,
217 x_short_text in varchar2 default NULL ,
218 x_long_text in CLOB default NULL ,
219 x_file_name in varchar2 default NULL
220 ) as
221
222 l_callback_url varchar2(4000);
223 l_search_document_url varchar2(4000);
224 l_username varchar2(80);
225
226 begin
227
228 -- Construct the text document Information.
229 if (x_datatype_id = 1 ) then
230
231 --htp.tableOpen( cattributes => ' border=0 cellpadding=2 cellspacing=0');
232 --htp.tableRowOpen( cvalign => 'TOP' );
233 htp.tableRowOpen;
234 htp.p('<TD align=right valign=top height=5 width=35%>');
235 htp.p('</TD>');
236 htp.p('<TD align=left>');
237 htp.p('<FONT class=datablack><TEXTAREA NAME ="text" ROWS=4 + COLS=38>'||
238 x_short_text || '</TEXTAREA></FONT>');
239 /*htp.tableData( htf.formTextareaOpen2( cname => 'text', nrows => '8',
240 ncolumns => '60', cwrap => 'virtual') ||
241 x_short_text ||
242 htf.formTextareaClose);*/
243 htp.tableRowClose;
244 htp.tableClose;
245 htp.formHidden ( cname =>'file_name', cvalue=>'');
246 htp.formHidden ( cname =>'url', cvalue=>'');
247 elsif(x_datatype_id = 2) then
248
249 --htp.tableOpen( cattributes => ' border=0 cellpadding=2 cellspacing=0');
250 --htp.tableRowOpen( cvalign => 'TOP' );
251 htp.tableRowOpen;
252 htp.p('<TD align=right valign=top height=5 width=35%>');
253 htp.p('</TD>');
254 htp.p('<TD align=left>');
255 htp.p('<FONT class=datablack><TEXTAREA NAME ="text" ROWS=4 + COLS=38>'||
256 x_long_text || '</TEXTAREA></FONT>');
257 /*htp.tableData( htf.formTextareaOpen2( cname => 'text', nrows => '8',
258 ncolumns => '60', cwrap => 'virtual') ||
259 x_long_text ||
260 htf.formTextareaClose);*/
261 htp.tableRowClose;
262 htp.tableClose;
263 htp.formHidden ( cname =>'file_name', cvalue=>'');
264 htp.formHidden ( cname =>'url', cvalue=>'');
265
266 -- Construct file type document information
267 elsif (x_datatype_id = 6 ) then
268
269 htp.formHidden ( cname =>'text', cvalue=>'');
270 --htp.tableOpen( cattributes => ' border=0 cellpadding=2 cellspacing=0' );
271 --htp.tableRowOpen( cvalign => 'TOP' );
272 htp.tableRowOpen;
273 htp.p('<TD align=right valign=top height=5 width=35%>');
274 htp.p('</TD>');
275 htp.p('<TD align=left>');
276 htp.p('<FONT class=datablack><INPUT TYPE="File" NAME="file_name"'||
277 'VALUE="'||x_file_name||'" SIZE="32"></FONT>');
278
279 /*htp.tableData( '<INPUT TYPE="File" NAME="file_name" VALUE="Upload File" SIZE="60">', calign => 'left');*/
280 htp.tableRowClose;
281 htp.tableClose;
282 htp.formHidden ( cname =>'url', cvalue=>'');
283
284 -- Construct the URL document information
285 elsif (x_datatype_id = 5 ) then
286 htp.formHidden ( cname =>'text', cvalue=>'');
287 htp.formHidden ( cname =>'file_name', cvalue=>'');
288
289 --htp.tableOpen( cattributes => ' border=0 cellpadding=2 cellspacing=0' );
290 --htp.tableRowOpen( cvalign => 'TOP' );
291 htp.tableRowOpen;
292 htp.p('<TD align=right valign=top height=5 width=35%>');
293 htp.p('</TD>');
294 htp.p('<TD align=left>');
295 htp.p('<FONT class=datablack><INPUT TYPE="Text" NAME="url" '||
296 'VALUE="'|| x_file_name ||'" SIZE="40"></FONT>');
297 /*htp.tableData( htf.formText( cname => 'url', csize => '70',
298 cmaxlength => '100', cvalue =>x_file_name ),
299 calign => 'left');*/
300 htp.tableRowClose;
301 htp.tableClose;
302 elsif (x_datatype_id = 7 ) then
303 /*
304 ** Create the callback syntax to update the local fields
305 */
306 fnd_document_management.set_document_id_html (
307 null,
308 'FNDATTACH',
309 'dmid',
310 'dmname',
311 l_callback_url);
312
313 -- Get the url syntax for performing a search
314 fnd_document_management.get_launch_attach_url (
315 l_username,
316 l_callback_url,
317 TRUE,
318 l_search_document_URL);
319
320 -- DM Datatype
321 --htp.tableOpen( cattributes => ' border=0 cellpadding=2 cellspacing=0' );
322 --htp.tableRowOpen( cvalign => 'TOP' );
323 htp.tableRowOpen;
324 htp.p('<TD align=right valign=top height=5 width=35%>');
325 htp.p('</TD>');
326 htp.p('<TD align=left>');
327 htp.p('<FONT class=datablack><INPUT TYPE="Text" NAME="dmid" '||
328 'VALUE="'||x_file_name|| '" SIZE="40"></FONT>'||
329 l_search_document_URL);
330 /*htp.tableData( htf.formText( cname => 'dmid', csize => '70',
331 cvalue=>x_file_name)|| l_search_document_URL,
332 calign => 'left');*/
333 htp.tableRowClose;
334 htp.tableClose;
335
336 htp.formHidden ( cname =>'text', cvalue=>'');
337 htp.formHidden ( cname =>'url', cvalue=>'');
338 end if;
339
340 end DocumentInformation;
341
342 --
343 -- UpdateAttachment
344 -- Displays the attachment information for update.
345 -- IN
346 -- attached_document_id
347 -- function_name --Function name of the form
348 -- entity_name - Entity name for which attachment is made.
349 -- pk1_value - First Primary Key value of the entity.
350 -- to
351 -- pk5_value - Fifth Primary key value of the entity.
352 -- from_url - URL from which the attachments is invoked from.
353 -- This is required to set the back link.
354 -- query_only - Query flag is set 'Y' when called in query only
355 -- mode.
356 --
357
358 procedure UpdateAttachment(
359 attached_document_id in varchar2,
360 function_name in varchar2,
361 entity_name in varchar2,
362 pk1_value in varchar2,
363 pk2_value in varchar2 default NULL,
364 pk3_value in varchar2 default NULL,
365 pk4_value in varchar2 default NULL,
366 pk5_value in varchar2 default NULL,
367 from_url in varchar2,
368 query_only in varchar2 default 'N'
369 )
370 as
371 l_attached_document_id varchar2(16);
372 l_function_name varchar2(30);
373 l_entity_name varchar2(40);
374 l_pk1_value varchar2(100);
375 l_pk2_value varchar2(100);
376 l_pk3_value varchar2(150);
377 l_pk4_value varchar2(150);
378 l_pk5_value varchar2(150);
379 l_from_url varchar2(2000);
380 l_query_only varchar2(1);
381 l_lang varchar2(24);
382 l_dcdname varchar2(80):= owa_util.get_cgi_env('SCRIPT_NAME');
383 l_packagename varchar2(80) := 'FND_WEBATTCH';
384
385 begin
386
387 -- Validate the session
388 if NOT (icx_sec.ValidateSession(null)) then
389 return;
390 end if;
391
392 -- Set the language
393 l_lang := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
394
395 -- Decrypt all parameters.
396 l_attached_document_id :=
397 icx_call.decrypt2(UpdateAttachment.attached_document_id);
398 l_function_name := icx_call.decrypt2(UpdateAttachment.function_name);
399 l_entity_name := icx_call.decrypt2(UpdateAttachment.entity_name);
400 l_pk1_value := icx_call.decrypt2(UpdateAttachment.pk1_value);
401 l_pk2_value := icx_call.decrypt2(UpdateAttachment.pk2_value);
402 l_pk3_value := icx_call.decrypt2(UpdateAttachment.pk3_value);
403 l_pk4_value := icx_call.decrypt2(UpdateAttachment.pk4_value);
404 l_pk5_value := icx_call.decrypt2(UpdateAttachment.pk5_value);
405 l_from_url := icx_call.decrypt2(UpdateAttachment.from_url);
406 l_query_only := icx_call.decrypt2(UpdateAttachment.query_only);
407
408 -- Call the procedure that prints header
409 htp.htmlOpen;
410 htp.headOpen;
411
412 htp.framesetopen(crows=>'60, *', cattributes =>'frameborder=no border=0');
413
414 -- Call the procedure that prints header
415 htp.frame (csrc => l_dcdname || '/fnd_webattch.Header?Lang='||l_lang,
416 cname => 'top_frame', cmarginheight=>'0',
417 cmarginwidth=> '0', cscrolling => 'NO',
418 cnoresize => 'NORESIZE', cattributes => 'FRAMEBORDER=NO');
419
420 -- Print The Body of the Add Attachment page.
421 htp.frame (csrc => l_dcdname ||
422 '/fnd_webattch.PrintUpdateAttachment?attached_document_id='||
423 l_attached_document_id ||
424 '&'||'package_name='|| l_packagename ||
425 '&'||'function_name='||l_function_name ||
426 '&'||'entity_name='||l_entity_name ||
427 '&'||'pk1_value='||l_pk1_value ||
428 '&'||'pk2_value='||l_pk2_value ||
429 '&'||'pk3_value='||l_pk3_value ||
430 '&'||'pk4_value='||l_pk4_value ||
431 '&'||'pk5_value='||l_pk5_value||
432 '&'||'from_url='||l_from_url ||
433 '&'||'query_only='||l_query_only,
434 cname => 'main_frame',
435 cmarginheight=>'0', cmarginwidth=> '10', cscrolling => 'AUTO',
436 cnoresize => 'NORESIZE', cattributes => 'FRAMEBORDER=NO');
437
438 -- Close the frameset.
439 htp.framesetclose;
440
441 end UpdateAttachment;
442
443
444 -- DeleteAttachment
445 -- Deletes the attachment and document.
446 -- IN
447 -- attached_document_id
448 --
449
450 procedure DeleteAttachment(
451 attached_document_id in varchar2,
452 function_name in varchar2,
453 entity_name in varchar2,
454 pk1_value in varchar2,
455 pk2_value in varchar2 default NULL,
456 pk3_value in varchar2 default NULL,
457 pk4_value in varchar2 default NULL,
458 pk5_value in varchar2 default NULL,
459 from_url in varchar2,
460 query_only in varchar2 default 'N'
461 )
462 as
463 cursor delatt_cursor (x_attached_document_id varchar2) is
464 select datatype_id,file_name,media_id
465 from fnd_attached_docs_form_vl
466 where attached_document_id = to_number(x_attached_document_id);
467
468 deldatarec delatt_cursor%ROWTYPE;
469
470 l_datatype_id number;
471 l_media_id number;
472 l_file_name varchar2(255);
473 l_attached_document_id varchar2(16) :=
474 icx_call.decrypt2(deleteattachment.attached_document_id);
475 begin
476
477 -- Validate the session
478 if NOT (icx_sec.ValidateSession(null)) then
479 return;
480 end if;
481
482 -- Get the datatype_id for the attachment.
483 open delatt_cursor (l_attached_document_id);
484 fetch delatt_cursor into deldatarec;
485 if delatt_cursor%NOTFOUND then
486 return;
487 end if;
488
489 l_datatype_id := deldatarec.datatype_id ;
490 l_file_name := deldatarec.file_name;
491 l_media_id := deldatarec.media_id;
492
493 -- Call the procedure to delete the attachment and document.
494 fnd_attached_documents3_pkg.delete_row ( l_attached_document_id,
495 l_datatype_id, 'Y' );
496
497 -- Delete the file from fnd_lobs.
498 if (l_datatype_id = 6 ) then
499 DELETE FROM fnd_lobs WHERE file_id = l_media_id;
500 end if;
501
502 -- Redirect the URL to the file location
503 owa_util.redirect_url (curl => owa_util.get_owa_service_path||
504 'fnd_webattch.Summary?function_name=' || function_name
505 ||'&'||'entity_name='||entity_name
506 ||'&'||'pk1_value='||pk1_value
507 ||'&'||'pk2_value='||pk2_value
508 ||'&'||'pk3_value='||pk3_value
509 ||'&'||'pk4_value='||pk4_value
510 ||'&'||'pk5_value='||pk5_value
511 ||'&'||'from_url='||from_url
512 ||'&'||'query_only='||query_only);
513
514 end DeleteAttachment;
515
516 --
517 -- AddAttachment
518 -- Creates an attachment and document.
519 -- IN
520 -- function_name - Function name of the web function
521 -- entity_name - Entity name to which the attachment is made.
522 -- pk1_value - First primary key of the entity.
523 -- through
524 -- pk5_value - Fifth primary key value of the entity.
525 -- from_url - URL from which the attachments is invoked from.
526 -- This is required to set the back link.
527 -- query_only - Query flag is set 'Y' when called in query only
528 -- mode.
529 --
530
531 procedure AddAttachment(
532 function_name in varchar2,
533 entity_name in varchar2,
534 pk1_value in varchar2,
535 pk2_value in varchar2 default NULL,
536 pk3_value in varchar2 default NULL,
537 pk4_value in varchar2 default NULL,
538 pk5_value in varchar2 default NULL,
539 from_url in varchar2,
540 query_only in varchar2 default 'N'
541 ) as
542
543 l_function_name varchar2(30);
544 l_entity_name varchar2(40) ;
545 l_pk1_value varchar2(100);
546 l_pk2_value varchar2(100);
547 l_pk3_value varchar2(150);
548 l_pk4_value varchar2(150);
549 l_pk5_value varchar2(150);
550 l_from_url varchar2(2000);
551 l_query_only varchar2(1);
552 l_lang varchar2(24);
553 l_dcdname varchar2(80):= owa_util.get_cgi_env('SCRIPT_NAME');
554 l_packagename varchar2(80) := 'FND_WEBATTCH';
555
556 begin
557
558 -- Validate the session
559 if NOT (icx_sec.ValidateSession(null)) then
560 return;
561 end if;
562
563 -- Set the language
564 l_lang := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
565
566 -- Decrypt all the parameters.
567 l_function_name :=icx_call.decrypt2(AddAttachment.function_name);
568 l_entity_name := icx_call.decrypt2(AddAttachment.entity_name);
569 l_pk1_value := icx_call.decrypt2(AddAttachment.pk1_value);
570 l_pk2_value := icx_call.decrypt2(AddAttachment.pk2_value);
571 l_pk3_value := icx_call.decrypt2(AddAttachment.pk3_value);
572 l_pk4_value := icx_call.decrypt2(AddAttachment.pk4_value);
573 l_pk5_value := icx_call.decrypt2(AddAttachment.pk5_value);
574 l_from_url := icx_call.decrypt2(AddAttachment.from_url);
575 l_query_only := icx_call.decrypt2(AddAttachment.query_only);
576
577 -- Call the procedure that prints header
578 htp.htmlOpen;
579 htp.headOpen;
580
581 htp.framesetopen(crows=>'60, *', cattributes =>'frameborder=no border=0');
582
583 -- Call the procedure that prints header
584 htp.frame (csrc => l_dcdname || '/fnd_webattch.Header?Lang='||l_lang,
585 cname => 'tooolbar_frame', cmarginheight=>'0',
586 cmarginwidth=> '0', cscrolling => 'NO',
587 cnoresize => 'NORESIZE', cattributes => 'FRAMEBORDER=NO');
588
589 -- Print The Body of the Add Attachment page.
590 htp.frame (csrc => l_dcdname ||
591 '/fnd_webattch.PrintAddAttachment?package_name='||
592 l_packagename ||
593 '&'||'function_name='||l_function_name ||
594 '&'||'entity_name='||l_entity_name ||
595 '&'||'pk1_value='||l_pk1_value ||
596 '&'||'pk2_value='||l_pk2_value ||
597 '&'||'pk3_value='||l_pk3_value ||
598 '&'||'pk4_value='||l_pk4_value ||
599 '&'||'pk5_value='||l_pk5_value||
600 '&'||'from_url='||l_from_url ||
601 '&'||'query_only='||l_query_only,
602 cname => 'form_frame',
603 cmarginheight=>'0', cmarginwidth=> '10', cscrolling => 'AUTO',
604 cnoresize => 'NORESIZE', cattributes => 'FRAMEBORDER=NO');
605
606 -- Close the frameset.
607 htp.framesetclose;
608
609 end AddAttachment;
610
611 -- ViewTextDocument
612 -- IN
613 -- media_id - Key to retrive the document info.
614 -- datatype_id - 1 if it is 'Short Text'
615 -- 2 if it is 'Long Text'.
616 -- function_name - Function name of the form
617 -- entity_name - Entity name for which attachment is made.
618 -- pk1_value - First Primary Key value of the entity.
619 -- to
620 -- pk5_value - Fifth Primary key value of the entity.
621 -- from_url - URL from which the attachments is invoked from.
622 -- This is required to set the back link.
623 -- query_only - Query flag is set 'Y' when called in query only
624 -- mode.
625
626 procedure ViewTextDocument (
627 attached_document_id in varchar2 ,
628 function_name in varchar2 ,
629 entity_name in varchar2 ,
630 pk1_value in varchar2 ,
631 pk2_value in varchar2 ,
632 pk3_value in varchar2 ,
633 pk4_value in varchar2 ,
634 pk5_value in varchar2 ,
635 from_url in varchar2 ,
636 query_only in varchar2 default 'N'
637 )as
638
639 l_lang varchar2(24);
640
641 begin
642
643 -- Validate the session
644 if NOT (icx_sec.ValidateSession(null)) then
645 return;
646 end if;
647
648 -- Set the language
649 l_lang := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
650
651 -- Call the procedure that prints header
652 --Header(fnd_message.get_string('FND', 'FND-WEBATCH-VIEWTEXT-TITLE'),l_lang);
653
654 -- Call PrintTextDocument with the packagename
655 PrintTextDocument (
656 package_name => 'FND_WEBATTCH' ,
657 attached_document_id => attached_document_id ,
658 function_name => function_name ,
659 entity_name => entity_name ,
660 pk1_value => pk1_value ,
661 pk2_value => pk2_value ,
662 pk3_value => pk3_value ,
663 pk4_value => pk4_value ,
664 pk5_value => pk5_value ,
665 from_url => from_url ,
666 query_only => query_only );
667
668 end ViewTextDocument;
669
670 -- ViewFileDocument
671 -- Displays the file document.
672 -- IN
673 -- attached_document_id - Unique id for an attachment.
674 -- function_name - Function name of the form
675 -- entity_name - Entity name for which attachment is made.
676 -- pk1_value - First Primary Key value of the entity.
677 -- to
678 -- pk5_value - Fifth Primary key value of the entity.
679 -- from_url - URL from which the attachments is invoked from.
680 -- This is required to set the back link.
681 -- query_only - Query flag is set 'Y' when called in query only
682 -- mode.
683 --
684
685 procedure ViewFileDocument (
686 attached_document_id in varchar2
687 ) as
688
689 cursor filename_cursor (l_attached_document_id varchar2) is
690 select dt.file_name, dt.media_id
691 from fnd_attached_documents ad, fnd_documents_tl dt
692 where ad.document_id = dt.document_id
693 and ad.attached_document_id = to_number(l_attached_document_id);
694
695 l_url varchar2(255);
696 l_file_name varchar2(255);
697 l_attached_document_id varchar2(16) := icx_call.decrypt2
698 (viewfiledocument.attached_document_id);
699 gfm_agent varchar2(255);
700 l_script_name varchar2(255);
701 l_media_id number;
702
703 begin
704
705 -- Validate the session
706 if NOT (icx_sec.ValidateSession(null)) then
707 return;
708 end if;
709
710 -- Get the file_name which also has the file_content_type.
711 open filename_cursor (l_attached_document_id);
712 fetch filename_cursor into l_file_name, l_media_id;
713 if filename_cursor%NOTFOUND then
714 owa_util.status_line(404, 'File Not Found', TRUE);
715 RETURN;
716 end if;
717
718 l_script_name := owa_util.get_cgi_env('SCRIPT_NAME');
719 /*web_plsql_agent := SUBSTR(l_script_name, 2,
720 INSTR(l_script_name, '/', 2) - 1);
721 web_server_prefix := 'http://' || owa_util.get_cgi_env('SERVER_NAME') ||
722 ':' || owa_util.get_cgi_env('SERVER_PORT'); */
723 gfm_agent := fnd_web_config.gfm_agent;
724
725 l_url := fnd_gfm.construct_download_URL( gfm_agent, l_media_id, FALSE);
726
727 -- Redirect the URL to display the file
728 owa_util.redirect_url( l_url );
729
730 end ViewFileDocument;
731
732 PROCEDURE add_attachment_gfm_wrapper(
733 access_id NUMBER,
734 seq_num VARCHAR2 ,
735 category_id VARCHAR2,
736 document_description VARCHAR2,
737 datatype_id VARCHAR2,
738 text VARCHAR2 DEFAULT NULL,
739 file_name VARCHAR2 DEFAULT NULL,
740 url VARCHAR2 DEFAULT NULL,
741 function_name VARCHAR2 DEFAULT NULL,
742 entity_name VARCHAR2 DEFAULT NULL,
743 pk1_value VARCHAR2 DEFAULT NULL,
744 pk2_value VARCHAR2 DEFAULT NULL,
745 pk3_value VARCHAR2 DEFAULT NULL,
746 pk4_value VARCHAR2 DEFAULT NULL,
747 pk5_value VARCHAR2 DEFAULT NULL,
748 from_url VARCHAR2 DEFAULT NULL,
749 query_only VARCHAR2 DEFAULT NULL,
750 user_id VARCHAR2 DEFAULT NULL,
751 dmid VARCHAR2 DEFAULT NULL,
752 dmname VARCHAR2 DEFAULT NULL,
753 package_name VARCHAR2,
754 dm_node in number DEFAULT NULL,
755 dm_folder_path in varchar2 DEFAULT NULL,
756 dm_type in varchar2 DEFAULT NULL,
757 dm_document_id in number DEFAULT NULL,
758 dm_version_number in varchar2 DEFAULT NULL,
759 title in varchar2 DEFAULT NULL
760 ) AS
761 l_media_id NUMBER;
762 l_file_name VARCHAR2(255);
763 BEGIN
764
765 IF TO_NUMBER(datatype_id) = 6 THEN
766 l_media_id := fnd_gfm.confirm_upload(access_id => access_id,
767 file_name => file_name,
768 program_name => 'ADD_ATTACHMENT');
769 l_file_name := 'INTERNAL';
770 ELSIF TO_NUMBER(datatype_id) = 7 THEN
771 l_file_name := dmid;
772 END IF;
773
774
775 Add_Attachment(seq_num => seq_num,
776 category_id => category_id,
777 document_description => document_description,
778 datatype_id => datatype_id,
779 text => text,
780 file_name => l_file_name,
781 url => url,
782 function_name => function_name,
783 entity_name => entity_name,
784 pk1_value => pk1_value,
785 pk2_value => pk2_value,
786 pk3_value => pk3_value,
787 pk4_value => pk4_value,
788 pk5_value => pk5_value,
789 media_id => l_media_id,
790 user_id => user_id,
791 title => title,
792 dm_node => dm_node,
793 dm_folder_path => dm_folder_path,
794 dm_type => dm_type,
795 dm_document_id => dm_document_id,
796 dm_version_number => dm_version_number);
797
798 -- This htp call is required for webDB implementation.
799 htp.p('');
800
801 END;
802
803 -- Add_Attachment
804 -- IN
805 -- seq_num - Attachment Seq Number.
806 -- category_description
807 -- document_description
808 -- datatype_name - Datatype identifier
809 -- document_text - Document Text Input.
810 -- file_name - File name
811 -- URL - URL
812 -- function_name - Function name of the form
813 -- entity_name - Entity name for which attachment is made.
814 -- pk1_value - First Primary Key value of the entity.
815 -- to
816 -- pk5_value - Fifth Primary key value of the entity.
817 -- from_url - URL from which the attachments is invoked from.
818 -- This is required to set the back link.
819 -- query_only - Query flag is set 'Y' when called in query only
820 -- mode.
821 -- media_id - Document Content reference.
822 -- user_id - Login id of the user
823 -- usage_type - one-time or standard or template.
824 --
825
826 procedure Add_Attachment (
827 seq_num in varchar2 ,
828 category_id in varchar2 ,
829 document_description in varchar2 ,
830 datatype_id in varchar2 ,
831 text in CLOB ,
832 file_name in varchar2 ,
833 url in varchar2 ,
834 function_name in varchar2 ,
835 entity_name in varchar2 ,
836 pk1_value in varchar2 ,
837 pk2_value in varchar2 ,
838 pk3_value in varchar2 ,
839 pk4_value in varchar2 ,
840 pk5_value in varchar2 ,
841 media_id in number ,
842 user_id in varchar2 ,
843 usage_type in varchar2 DEFAULT 'O' ,
844 title in varchar2 DEFAULT NULL ,
845 dm_node in number DEFAULT NULL ,
846 dm_folder_path in varchar2 DEFAULT NULL ,
847 dm_type in varchar2 DEFAULT NULL ,
848 dm_document_id in number DEFAULT NULL ,
849 dm_version_number in varchar2 DEFAULT NULL
850 ) as
851
852 l_rowid varchar2(30);
853 l_attached_document_id number;
854 l_media_id number:= add_attachment.media_id;
855 l_document_id number;
856
857 l_file_name varchar2(255);
858 l_creation_date date := SYSDATE;
859 l_created_by number;
860 l_last_update_date date := SYSDATE;
861 l_last_updated_by number;
862 l_lang varchar2(40);
863
864 begin
865
866 -- Set file name
867 if (to_number(datatype_id) = 5 ) then
868 l_file_name := url;
869 elsif (to_number(datatype_id) in (6,7) ) then
870 l_file_name := add_attachment.file_name;
871 end if;
872
873 -- Set the WHO Columns.
874 l_created_by := to_number(user_id);
875 l_last_updated_by := l_created_by;
876
877 -- Attached Document Id has to be populated from the sequence.
878 select fnd_attached_documents_s.nextval
879 into l_attached_document_id
880 from sys.dual;
881
882 -- Set the language parameter
883 select userenv ('LANG')
884 into l_lang
885 from dual;
886
887 -- Call the server side package for adding the attachment and documents.
888 fnd_attached_documents_pkg.insert_row (
889 x_rowid => l_rowid ,
890 x_attached_document_id => l_attached_document_id ,
891 x_document_id => l_document_id ,
892 x_creation_date => l_creation_date ,
893 x_created_by => l_created_by ,
894 x_last_update_date => l_last_update_date ,
895 x_last_updated_by => l_last_updated_by ,
896 x_last_update_login => NULL ,
897 x_seq_num => to_number(seq_num) ,
898 x_entity_name => entity_name ,
899 x_column1 => NULL ,
900 x_pk1_value => pk1_value ,
901 x_pk2_value => pk2_value ,
902 x_pk3_value => pk3_value ,
903 x_pk4_value => pk4_value ,
904 x_pk5_value => pk5_value ,
905 x_automatically_added_flag => 'N' ,
906 x_request_id => NULL ,
907 x_program_application_id =>NULL ,
908 x_program_id => NULL ,
909 x_program_update_date => NULL ,
910 x_attribute_category => NULL ,
911 x_attribute1 => NULL ,
912 x_attribute2 => NULL ,
913 x_attribute3 => NULL ,
914 x_attribute4 => NULL ,
915 x_attribute5 => NULL ,
916 x_attribute6 => NULL ,
917 x_attribute7 => NULL ,
918 x_attribute8 => NULL ,
919 x_attribute9 => NULL ,
920 x_attribute10 => NULL ,
921 x_attribute11 => NULL ,
922 x_attribute12 => NULL ,
923 x_attribute13 => NULL ,
924 x_attribute14 => NULL ,
925 x_attribute15 => NULL ,
926 x_datatype_id => to_number(datatype_id) ,
927 x_category_id => to_number(category_id) ,
928 x_security_type => 4 ,
929 x_security_id => NULL ,
930 x_publish_flag => 'Y' ,
931 x_image_type => NULL ,
932 x_storage_type => NULL ,
933 x_usage_type => usage_type ,
934 x_language => l_lang ,
935 x_description => document_description ,
936 x_file_name => l_file_name ,
937 x_media_id => l_media_id ,
938 x_doc_attribute_category => NULL ,
939 x_doc_attribute1 => NULL ,
940 x_doc_attribute2 => NULL ,
941 x_doc_attribute3 => NULL ,
942 x_doc_attribute4 => NULL ,
943 x_doc_attribute5 => NULL ,
944 x_doc_attribute6 => NULL ,
945 x_doc_attribute7 => NULL ,
946 x_doc_attribute8 => NULL ,
947 x_doc_attribute9 => NULL ,
948 x_doc_attribute10 => NULL ,
949 x_doc_attribute11 => NULL ,
950 x_doc_attribute12 => NULL ,
951 x_doc_attribute13 => NULL ,
952 x_doc_attribute14 => NULL ,
953 x_doc_attribute15 => NULL ,
954 x_create_doc => 'N' ,
955 x_url => url ,
956 x_title => title ,
957 x_dm_node => dm_node ,
958 x_dm_folder_path => dm_folder_path ,
959 x_dm_type => dm_type ,
960 x_dm_document_id => dm_document_id ,
961 x_dm_version_number => dm_version_number
962 );
963
964 -- Commit the transaction
965 commit;
966
967 -- After the data is inserted into fnd_attached_documents, fnd_documents and
968 -- fnd_documents_tl table using the above procedure we get the media_id
969 -- which will be used to insert the text into fnd_document_short_text table.
970 if (to_number(datatype_id) = 2 ) then -- Text Datatype
971 INSERT INTO fnd_documents_long_text(
972 media_id,
973 long_text) VALUES (
974 l_media_id,
975 text);
976
977 -- Commit the transaction
978 commit;
979 elsif (to_number(datatype_id) = 1 ) then -- Short text Type Documents.
980 INSERT INTO fnd_documents_short_text(
981 media_id,
982 short_text) VALUES (
983 l_media_id,
984 text);
985
986 -- Commit the transaction
987 commit;
988 end if;
989
990 exception
991 when others then
992 rollback;
993
994 end Add_Attachment;
995
996 PROCEDURE update_attachment_gfm_wrapper(
997 seq_num varchar2,
998 category_id varchar2,
999 document_description varchar2 DEFAULT NULL,
1000 text varchar2 DEFAULT NULL,
1001 file_name varchar2 DEFAULT NULL,
1002 url varchar2 DEFAULT NULL,
1003 attached_document_id varchar2 DEFAULT NULL,
1004 datatype_id varchar2,
1005 function_name varchar2 DEFAULT NULL,
1006 entity_name varchar2 DEFAULT NULL,
1007 pk1_value varchar2 DEFAULT NULL,
1008 pk2_value varchar2 DEFAULT NULL,
1009 pk3_value varchar2 DEFAULT NULL,
1010 pk4_value varchar2 DEFAULT NULL,
1011 pk5_value varchar2 DEFAULT NULL,
1012 from_url varchar2 DEFAULT NULL,
1013 query_only varchar2 DEFAULT NULL,
1014 dmid VARCHAR2 DEFAULT NULL,
1015 dmname VARCHAR2 DEFAULT NULL,
1016 package_name varchar2,
1017 dm_node NUMBER DEFAULT NULL,
1018 dm_folder_path VARCHAR2 DEFAULT NULL,
1019 dm_type VARCHAR2 DEFAULT NULL,
1020 dm_document_id NUMBER DEFAULT NULL,
1021 dm_version_number VARCHAR2 DEFAULT NULL,
1022 title VARCHAR2 DEFAULT NULL
1023 ) AS
1024 l_media_id NUMBER;
1025 l_file_name VARCHAR2(255);
1026 l_user_id VARCHAR2(24);
1027 l_package_name VARCHAR2(64);
1028 l_access_id NUMBER;
1029 l_start_pos NUMBER :=1;
1030 l_length NUMBER := 0 ;
1031 BEGIN
1032
1033 -- Parse the packagename into package name, access_id and user_id.
1034 l_length := instr(package_name,';',l_start_pos) - l_start_pos;
1035 l_user_id := substr(package_name,l_start_pos,l_length);
1036
1037 l_start_pos := l_start_pos + l_length + 1 ;
1038 l_length := instr(package_name,';',l_start_pos) - l_start_pos;
1039 l_package_name := substr(package_name,l_start_pos,l_length);
1040
1041
1042 l_start_pos := l_start_pos + l_length + 1 ;
1043 l_length := instr(package_name,';',l_start_pos) - l_start_pos;
1044 l_access_id := to_number(substr(package_name,l_start_pos,l_length));
1045
1046 IF TO_NUMBER(datatype_id) = 6 THEN
1047 l_media_id := fnd_gfm.confirm_upload(access_id => l_access_id,
1048 file_name => file_name,
1049 program_name => 'UPDATE_ATTACHMENT');
1050 l_file_name := 'INTERNAL';
1051 ELSIF TO_NUMBER(datatype_id) = 7 THEN
1052 l_file_name := dmid;
1053 END IF;
1054
1055 Update_Attachment(seq_num => seq_num,
1056 category_id => category_id,
1057 document_description => document_description,
1058 text => text,
1059 file_name => l_file_name,
1060 url => url,
1061 attached_document_id => attached_document_id,
1062 datatype_id => datatype_id,
1063 function_name => function_name,
1064 entity_name => entity_name,
1065 pk1_value => pk1_value,
1066 pk2_value => pk2_value,
1067 pk3_value => pk3_value,
1068 pk4_value => pk4_value,
1069 pk5_value => pk5_value,
1070 media_id => l_media_id,
1071 user_id => l_user_id,
1072 dm_node => dm_node,
1073 dm_folder_path => dm_folder_path,
1074 dm_type => dm_type,
1075 dm_document_id => dm_document_id,
1076 dm_version_number => dm_version_number,
1077 title => title);
1078
1079
1080 -- This htp call is required for webDB implementation.
1081 htp.p('');
1082
1083 END;
1084
1085 -- Update_Attachment
1086 -- IN
1087 -- seq_num - Attachment Seq Number.
1088 -- category_description
1089 -- document_description
1090 -- datatype_name - Datatype identifier
1091 -- document_text - Document Text Input.
1092 -- file_name - File name
1093 -- URL - URL
1094 -- function_name --Function name of the form
1095 -- entity_name - Entity name for which attachment is made.
1096 -- pk1_value - First Primary Key value of the entity.
1097 -- to
1098 -- pk5_value - Fifth Primary key value of the entity.
1099 -- user_id - Login id of the user
1100 -- media_id - Document Content reference.
1101 --
1102
1103 procedure Update_Attachment (
1104 seq_num in varchar2 ,
1105 category_id in varchar2 ,
1106 document_description in varchar2 ,
1107 text in CLOB ,
1108 file_name in varchar2 ,
1109 url in varchar2 ,
1110 attached_document_id in varchar2 ,
1111 datatype_id in varchar2 ,
1112 function_name in varchar2 ,
1113 entity_name in varchar2 ,
1114 pk1_value in varchar2 ,
1115 pk2_value in varchar2 ,
1116 pk3_value in varchar2 ,
1117 pk4_value in varchar2 ,
1118 pk5_value in varchar2 ,
1119 media_id in number ,
1120 user_id in varchar2 ,
1121 dm_node in NUMBER DEFAULT NULL ,
1122 dm_folder_path in VARCHAR2 DEFAULT NULL ,
1123 dm_type in VARCHAR2 DEFAULT NULL ,
1124 dm_document_id in NUMBER DEFAULT NULL ,
1125 dm_version_number in VARCHAR2 DEFAULT NULL ,
1126 title in VARCHAR2 DEFAULT NULL
1127 ) as
1128 cursor update_att_cursor (x_attached_document_id varchar2,
1129 x_function_name varchar2) is
1130 select row_id, document_id, media_id, start_date_active,
1131 end_date_active, datatype_id
1132 from fnd_attached_docs_form_vl
1133 where attached_document_id = to_number(x_attached_document_id)
1134 and function_name= x_function_name
1135 and function_type = 'F';
1136
1137 upddatarec update_att_cursor%ROWTYPE;
1138
1139 l_datatype_id number;
1140 l_file_name varchar2(255);
1141 l_last_update_date date := SYSDATE;
1142 l_last_updated_by number;
1143
1144 l_document_id number;
1145 l_media_id number;
1146 l_attached_document_id varchar2(16):= update_attachment.attached_document_id;
1147 l_function_name varchar2(32):= update_attachment.function_name;
1148 l_lang varchar2(40);
1149
1150 begin
1151
1152 -- Reterive the data for the attachment.
1153 open update_att_cursor (l_attached_document_id,l_function_name);
1154 fetch update_att_cursor into upddatarec;
1155 if update_att_cursor%NOTFOUND then
1156 close update_att_cursor;
1157 return;
1158 end if;
1159
1160 -- Set file name and media id depending on datatype id.
1161 if (to_number(datatype_id) = 5 ) then
1162 l_file_name := url;
1163 l_media_id := null;
1164 elsif (to_number(datatype_id) = 6) then
1165 l_media_id := update_attachment.media_id;
1166 l_file_name := update_attachment.file_name;
1167 elsif (to_number(datatype_id) = 7 ) then
1168 l_file_name := update_attachment.file_name;
1169 l_media_id := null;
1170 else
1171 l_file_name := update_attachment.file_name;
1172 l_media_id := upddatarec.media_id;
1173 end if;
1174
1175 -- Set the WHO Columns.
1176 l_last_updated_by := to_number(Update_Attachment.user_id);
1177
1178 -- Set the language
1179 select USERENV('LANG')
1180 into l_lang
1181 from dual;
1182
1183 -- Call the server side package for adding the attachment and documents.
1184 fnd_attached_documents_pkg.update_row (
1185 x_rowid => upddatarec.row_id ,
1186 x_attached_document_id => attached_document_id ,
1187 x_document_id => upddatarec.document_id ,
1188 x_last_update_date => l_last_update_date ,
1189 x_last_updated_by => l_last_updated_by ,
1190 x_last_update_login => NULL ,
1191 x_seq_num => to_number(seq_num) ,
1192 x_entity_name => entity_name ,
1193 x_column1 => NULL ,
1194 x_pk1_value => pk1_value ,
1195 x_pk2_value => pk2_value ,
1196 x_pk3_value => pk3_value ,
1197 x_pk4_value => pk4_value ,
1198 x_pk5_value => pk5_value ,
1199 x_automatically_added_flag => 'N' ,
1200 x_request_id => NULL ,
1201 x_program_application_id =>NULL ,
1202 x_program_id => NULL ,
1203 x_program_update_date => NULL ,
1204 x_attribute_category => NULL ,
1205 x_attribute1 => NULL ,
1206 x_attribute2 => NULL ,
1207 x_attribute3 => NULL ,
1208 x_attribute4 => NULL ,
1209 x_attribute5 => NULL ,
1210 x_attribute6 => NULL ,
1211 x_attribute7 => NULL ,
1212 x_attribute8 => NULL ,
1213 x_attribute9 => NULL ,
1214 x_attribute10 => NULL ,
1215 x_attribute11 => NULL ,
1216 x_attribute12 => NULL ,
1217 x_attribute13 => NULL ,
1218 x_attribute14 => NULL ,
1219 x_attribute15 => NULL ,
1220 x_datatype_id => datatype_id ,
1221 x_category_id => to_number(category_id) ,
1222 x_security_type => 4 ,
1223 x_security_id => NULL ,
1224 x_publish_flag => 'Y' ,
1225 x_image_type => NULL ,
1226 x_storage_type => NULL ,
1227 x_usage_type => 'O' ,
1228 x_start_date_active => upddatarec.start_date_active ,
1229 x_end_date_active => upddatarec.end_date_active ,
1230 x_language => l_lang ,
1231 x_description => document_description ,
1232 x_file_name => l_file_name ,
1233 x_media_id => l_media_id ,
1234 x_doc_attribute_category => NULL ,
1235 x_doc_attribute1 => NULL ,
1236 x_doc_attribute2 => NULL ,
1237 x_doc_attribute3 => NULL ,
1238 x_doc_attribute4 => NULL ,
1239 x_doc_attribute5 => NULL ,
1240 x_doc_attribute6 => NULL ,
1241 x_doc_attribute7 => NULL ,
1242 x_doc_attribute8 => NULL ,
1243 x_doc_attribute9 => NULL ,
1244 x_doc_attribute10 => NULL ,
1245 x_doc_attribute11 => NULL ,
1246 x_doc_attribute12 => NULL ,
1247 x_doc_attribute13 => NULL ,
1248 x_doc_attribute14 => NULL ,
1249 x_doc_attribute15 => NULL ,
1250 x_url => url ,
1251 x_title => title ,
1252 x_dm_node => dm_node ,
1253 x_dm_folder_path => dm_folder_path ,
1254 x_dm_type => dm_type ,
1255 x_dm_document_id => dm_document_id ,
1256 x_dm_version_number => dm_version_number
1257 );
1258
1259 -- Commit the transaction.
1260 commit;
1261
1262 -- When the text is altered the the fnd_documents_short_text
1263 -- needs to be updated. When the file type is altered we have to
1264 -- upload the file.
1265 if (datatype_id = 1 ) then -- Short Text Datatype
1266 UPDATE fnd_documents_short_text
1267 set short_text = text
1268 where media_id = l_media_id;
1269
1270 -- Commit the transaction.
1271 commit;
1272
1273 elsif (datatype_id = 2 ) then -- Long Text Document
1274 UPDATE fnd_documents_long_text
1275 set long_text = text
1276 where media_id = l_media_id;
1277
1278 -- Commit the transaction.
1279 commit;
1280 end if;
1281
1282 exception
1283 when others then
1284 rollback;
1285 if (update_att_cursor%ISOPEN) then
1286 close update_att_cursor;
1287 end if;
1288 end Update_Attachment;
1289
1290 -- ReloadSummary
1291 -- IN
1292 -- package_name - Calling package name.
1293 -- function_name - Function name of the form
1294 -- entity_name - Entity name for which attachment is made.
1295 -- pk1_value - First Primary Key value of the entity.
1296 -- to
1297 -- pk5_value - Fifth Primary key value of the entity.
1298 -- from_url - URL from which the attachments is invoked from.
1299 -- This is required to set the back link.
1300 -- query_only - Query flag is set 'Y' when called in query only
1301 -- mode.
1302 --
1303
1304 procedure ReloadSummary(
1305 package_name in varchar2 default 'FND_WEBATTCH',
1306 function_name in varchar2,
1307 entity_name in varchar2,
1308 pk1_value in varchar2,
1309 pk2_value in varchar2 default NULL,
1310 pk3_value in varchar2 default NULL,
1311 pk4_value in varchar2 default NULL,
1312 pk5_value in varchar2 default NULL,
1313 from_url in varchar2 ,
1314 query_only in varchar2 default 'N'
1315 ) as
1316
1317 begin
1318
1319 -- Redirect the URL to the file location
1320 owa_util.redirect_url (curl => owa_util.get_owa_service_path|| package_name||
1321 '.Summary?function_name='|| icx_call.encrypt2(function_name)
1322 ||'&'||'entity_name='||icx_call.encrypt2(entity_name)
1323 ||'&'||'pk1_value='||icx_call.encrypt2(pk1_value)
1324 ||'&'||'pk2_value='||icx_call.encrypt2(pk2_value)
1325 ||'&'||'pk3_value='||icx_call.encrypt2(pk3_value)
1326 ||'&'||'pk4_value='||icx_call.encrypt2(pk4_value)
1327 ||'&'||'pk5_value='||icx_call.encrypt2(pk5_value)
1328 ||'&'||'from_url=' ||icx_call.encrypt2(from_url)
1329 ||'&'||'query_only='||icx_call.encrypt2(query_only));
1330
1331 end ReloadSummary;
1332
1333 -- Header
1334 -- Creates Header for Attachment pages.
1335 -- IN
1336 -- Title - Title of the page.
1337 -- Lang - Language of the Title.
1338 --
1339 procedure Header( Lang in varchar2
1340 ) as
1341 begin
1342
1343 -- Validate the session
1344 if NOT (icx_sec.ValidateSession(null)) then
1345 return;
1346 end if;
1347
1348 htp.htmlOpen;
1349 htp.bodyOpen;
1350 -- Body background color.
1351 htp.p('<BODY bgcolor="#cccccc">');
1352
1353 icx_admin_sig.toolbar(language_code => Header.Lang);
1354
1355 -- Style sheet declaration.
1356 htp.p('<LINK REL=STYLESHEET HREF="/OA_HTML/US/osswa.css" TYPE="text/css">');
1357
1358 htp.bodyClose;
1359 htp.htmlClose;
1360
1361 end Header;
1362
1363 -- PrintSummary
1364 -- Prints the attachment summary page body (No Titles and Links).
1365 -- IN
1366 -- package_name - Calling package name.
1367 -- function_name - Function name of the web function
1368 -- entity_name - Entity name to which the attachment is made.
1369 -- pk1_value - First primary key of the entity.
1370 -- through
1371 -- pk5_value - Fifth primary key value of the entity.
1372 -- from_url - URL from which the attachments is invoked from.
1373 -- This is required to set the back link.
1374 -- query_only - Query flag is set 'Y' when called in query only
1375 -- mode.
1376 --
1377
1378 procedure PrintSummary(
1379 package_name in varchar2 default 'FND_WEBATTCH',
1380 function_name in varchar2,
1381 entity_name in varchar2,
1382 pk1_value in varchar2,
1383 pk2_value in varchar2 default NULL,
1384 pk3_value in varchar2 default NULL,
1385 pk4_value in varchar2 default NULL,
1386 pk5_value in varchar2 default NULL,
1387 from_url in varchar2,
1388 query_only in varchar2 default 'N'
1389 ) as
1390 cursor al_cursor is
1391 select SEQ_NUM ,
1392 CATEGORY_DESCRIPTION,
1393 DOCUMENT_DESCRIPTION,
1394 DATATYPE_NAME,
1395 DATATYPE_ID,
1396 FILE_NAME,
1397 USAGE_TYPE,
1398 USER_ENTITY_NAME,
1399 MEDIA_ID,
1400 ATTACHED_DOCUMENT_ID
1401 from FND_ATTACHED_DOCS_FORM_VL
1402 where FUNCTION_NAME =printsummary.function_name
1403 and FUNCTION_TYPE ='F'
1404 and (SECURITY_TYPE = 4 OR PUBLISH_FLAG = 'Y')
1405 and (ENTITY_NAME= printsummary.entity_name and
1406 PK1_VALUE=printsummary.pk1_value and
1407 decode(printsummary.pk2_value,null,'*',PK2_VALUE)=
1408 decode(printsummary.pk2_value,null,'*',printsummary.pk2_value) and
1409 decode(printsummary.pk3_value,null,'*',PK3_VALUE)=
1410 decode(printsummary.pk3_value,null,'*',printsummary.pk3_value) and
1411 decode(printsummary.pk4_value,null,'*',PK4_VALUE)=
1412 decode(printsummary.pk4_value,null,'*',printsummary.pk4_value) and
1413 decode(printsummary.pk5_value,null,'*',PK5_VALUE)=
1414 decode(printsummary.pk5_value,null,'*',printsummary.pk5_value))
1415 order by USER_ENTITY_NAME,SEQ_NUM;
1416
1417 atlstrec al_cursor%ROWTYPE;
1418 link_string varchar2(2000);
1419 l_del_msg varchar2(255);
1420 l_title varchar2(164);
1421 l_lang varchar2(24);
1422 l_username varchar2(80);
1423 j number := 1.0;
1424
1425 begin
1426
1427 -- Validate the session
1428 if NOT (icx_sec.ValidateSession(null)) then
1429 return;
1430 end if;
1431
1432 -- Set the language
1433 l_lang := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
1434 l_username := UPPER(ICX_SEC.GetID(99));
1435
1436 -- Retrive the delete message from the message dictionary
1437 l_del_msg := fnd_message.get_string('FND','ATCHMT-DELETE-ATCHMT');
1438
1439 -- Set the title
1440 l_title := fnd_message.get_string('FND','FND-WEBATCH-SUMMARY-TITLE');
1441
1442 htp.htmlOpen;
1443 htp.headOpen;
1444 htp.p( '<SCRIPT LANGUAGE="JavaScript">');
1445 htp.p( ' function delete_attachment (del_url) {
1446 if (confirm('||'"'||l_del_msg||'"'||'))
1447 {
1448 parent.location=del_url
1449 }
1450 }');
1451 htp.print('function help_window(){
1452 help_win = window.open('||
1453 fnd_help.get_url('ICX','@T_ATTACH')||
1454 ', "help_win","resizable=yes,scrollbars=yes,toolbar=yes,width=450,'||
1455 'height=250");
1456 help_win = window.open('||
1457 fnd_help.get_url('ICX','@T_ATTACH')||
1458 ', "help_win","resizable=yes,scrollbars=yes,toolbar=yes,width=450,'||
1459 'height=250")}');
1460 htp.print( '</SCRIPT>' );
1461 htp.title(l_title);
1462
1463 -- Add the java script to the header to open the dm window for
1464 -- any DM function that is executed.
1465 fnd_document_management.get_open_dm_attach_window;
1466
1467 -- Add java script to the header to open display window
1468 fnd_document_management.get_open_dm_display_window;
1469
1470 -- Style sheet declaration.
1471 htp.p('<LINK REL=STYLESHEET HREF="/OA_HTML/US/osswa.css" TYPE="text/css">');
1472
1473 htp.headClose;
1474 htp.bodyOpen;
1475
1476 -- Body background color.
1477 htp.p('<BODY bgcolor="#cccccc">');
1478 htp.br;
1479
1480
1481 -- Process the cursor
1482 open al_cursor;
1483 fetch al_cursor into atlstrec;
1484 if al_cursor%NOTFOUND then
1485 close al_cursor;
1486 htp.bold(fnd_message.get_string('FND','FND-WEBATCH-SUMMARY-NOATCHMTS'));
1487 htp.br;
1488 htp.print( '</LEFT>' );
1489 htp.br;
1490 htp.br;
1491 --htp.tableOpen( cattributes => ' border=1 cellpadding=3 bgcolor=white' );
1492 -- Branch to the bottom header
1493 GOTO bottom_header;
1494 end if;
1495
1496 -- Create a header.
1497 htp.p('<table width=98% cellpadding=0 cellspacing=0 border=0>');
1498 htp.p('<tr bgcolor=#336699>');
1499 htp.p('<td><font color=#336699>.</font></td>');
1500 htp.p('<TD width=100% nowrap><FONT CLASS=containertitle>'||
1501 fnd_message.get_string('FND','FND-WEBATCH-SUMMARY-HEADING')
1502 ||' : '||atlstrec.user_entity_name||'</FONT></TD>');
1503 htp.tableRowClose;
1504 htp.tableClose;
1505 htp.br;
1506
1507 -- There are some attachments for the entity. Construct the page.
1508 htp.p('<table width=98% bgcolor=#999999 cellpadding=2 '||
1509 'cellspacing=0 border=0>');
1510 htp.p('<tr><td>');
1511
1512 htp.p('<table width=100% cellpadding=2 cellspacing=1 border=0>');
1513 htp.p('<TR BGColor="336699">');
1514
1515 --Top Column Headings
1516 htp.p('<TD align=center valign=bottom bgcolor="336699"> '||
1517 '<FONT class=promptwhite>'||
1518 fnd_message.get_string('FND','FND-WEBATCH-DOCUMENT-DETAILS')||
1519 '</TD>');
1520 htp.p('<TD align=center valign=bottom bgcolor="336699"> '||
1521 '<FONT class=promptwhite>'||
1522 fnd_message.get_string('FND','FND-WEBATCH-DOCUMENT-SEQUENCE')||
1523 '</TD>');
1524 htp.p('<TD align=center valign=bottom bgcolor="336699"> '||
1525 '<FONT class=promptwhite>'||
1526 fnd_message.get_string('FND','FND-WEBATCH-DOCUMENT-DESCRIPTI')||
1527 '</TD>');
1528 htp.p('<TD align=center valign=bottom bgcolor="336699"> '||
1529 '<FONT class=promptwhite>'||
1530 fnd_message.get_string('FND','FND-WEBATCH-DOCUMENT-CATEGORY')||
1531 '</TD>');
1532 htp.p('<TD align=center valign=bottom bgcolor="336699"> '||
1533 '<FONT class=promptwhite>'||
1534 fnd_message.get_string('FND','FND-WEBATCH-DOCUMENT-DATATYPE')||
1535 '</TD>');
1536 if (query_only <> 'Y') then
1537 htp.p('<TD align=center valign=bottom bgcolor="336699"> '||
1538 '<FONT class=promptwhite>'||
1539 fnd_message.get_string('FND','FND-WEBATCH-EDIT-ATCHMT')||
1540 '</TD>');
1541 htp.p('<TD align=center valign=bottom bgcolor="336699"> '||
1542 '<FONT class=promptwhite>'||
1543 fnd_message.get_string('FND','FND-WEBATCH-REMOVE-ATCHMT')||
1544 '</TD>');
1545 end if;
1546
1547 -- Create Attachment List to displayed.
1548 loop
1549
1550 -- Make altenate rows with different background.
1551 if (round(j/2) = j/2) then
1552 htp.p('<TR BGColor="ffffff">');
1553 else
1554 htp.p('<TR BGColor="99ccff">');
1555 end if;
1556
1557 --Construct the one html line per row fetched.
1558 if (atlstrec.datatype_id = 6) then
1559 htp.p('<TD ><FONT class=tabledata>'||
1560 htf.anchor2(owa_util.get_owa_service_path
1561 ||'fnd_webattch.ViewFileDocument?attached_document_id='
1562 ||icx_call.encrypt2(to_char(atlstrec.attached_document_id)),
1563 htf.img2( '/OA_MEDIA/FNDIITMD.gif',
1564 calt => fnd_message.get_string('FND','HE_VIEW')
1565 ||' '||atlstrec.datatype_name,
1566 cattributes => 'border=no'),
1567 ctarget=>'document_frame') ||'</TD>');
1568 elsif(atlstrec.datatype_id = 5) then
1569 htp.p('<TD ><FONT class=tabledata>'||
1570 htf.anchor2(atlstrec.file_name,
1571 htf.img2( '/OA_MEDIA/FNDIITMD.gif',
1572 calt => fnd_message.get_string('FND','HE_VIEW')
1573 ||' '||atlstrec.datatype_name,
1574 cattributes => 'border=no'),
1575 ctarget=>'document_frame')
1576 ||'</TD>');
1577 elsif(atlstrec.datatype_id = 7) then
1578 -- Get the HTML text for displaying the document
1579 fnd_document_management.get_launch_document_url (
1580 l_username,
1581 atlstrec.file_name,
1582 FALSE,
1583 link_string);
1584 htp.p('<TD ><FONT class=tabledata>'||
1585 htf.anchor2(link_string, htf.img2( '/OA_MEDIA/FNDIITMD.gif',
1586 calt => fnd_message.get_string('FND','HE_VIEW')
1587 ||' '||atlstrec.datatype_name,
1588 cattributes => 'border=no'),
1589 ctarget=>'document_frame')
1590 ||'</TD>');
1591 elsif(atlstrec.datatype_id = 1) OR
1592 (atlstrec.datatype_id = 2) then
1593 htp.p('<TD ><FONT class=tabledata>'||
1594 htf.anchor2(owa_util.get_owa_service_path|| package_name
1595 ||'.ViewTextDocument?attached_document_id='||
1596 icx_call.encrypt2(to_char(atlstrec.attached_document_id))
1597 ||'&'||'function_name='||icx_call.encrypt2(function_name)
1598 ||'&'||'entity_name='||icx_call.encrypt2(entity_name)
1599 ||'&'||'pk1_value='||icx_call.encrypt2(pk1_value)
1600 ||'&'||'pk2_value='||icx_call.encrypt2(pk2_value)
1601 ||'&'||'pk3_value='||icx_call.encrypt2(pk3_value)
1602 ||'&'||'pk4_value='||icx_call.encrypt2(pk4_value)
1603 ||'&'||'pk5_value='||icx_call.encrypt2(pk5_value)
1604 ||'&'||'from_url='||icx_call.encrypt2(from_url)
1605 ||'&'||'query_only='||icx_call.encrypt2(query_only),
1606 htf.img2( '/OA_MEDIA/FNDIITMD.gif',
1607 calt => fnd_message.get_string('FND','HE_VIEW')
1608 ||' '||atlstrec.datatype_name,
1609 cattributes => 'border=no'),
1610 ctarget=>'document_frame')
1611 ||'</TD>');
1612 end if;
1613 htp.p('<TD ><FONT class=tabledata>'|| atlstrec.seq_num|| '</TD>');
1614 htp.p('<TD ><FONT class=tabledata>'|| atlstrec.document_description||
1615 '</TD>');
1616 htp.p('<TD ><FONT class=tabledata>'|| atlstrec.category_description ||
1617 '</TD>');
1618 htp.p('<TD ><FONT class=tabledata>'|| atlstrec.datatype_name|| '</TD>');
1619
1620 if (atlstrec.usage_type <> 'S') and
1621 (query_only <> 'Y') then
1622 htp.p('<TD ><FONT class=tabledata>'||
1623 htf.anchor2(owa_util.get_owa_service_path|| package_name
1624 ||'.UpdateAttachment?attached_document_id='||
1625 icx_call.encrypt2(to_char(atlstrec.attached_document_id))
1626 ||'&'||'function_name='||icx_call.encrypt2(function_name)
1627 ||'&'||'entity_name='||icx_call.encrypt2(entity_name)
1628 ||'&'||'pk1_value='||icx_call.encrypt2(pk1_value)
1629 ||'&'||'pk2_value='||icx_call.encrypt2(pk2_value)
1630 ||'&'||'pk3_value='||icx_call.encrypt2(pk3_value)
1631 ||'&'||'pk4_value='||icx_call.encrypt2(pk4_value)
1632 ||'&'||'pk5_value='||icx_call.encrypt2(pk5_value)
1633 ||'&'||'from_url='|| icx_call.encrypt2
1634 (replace(from_url,'&','%26'))
1635 ||'&'||'query_only='||icx_call.encrypt2(query_only),
1636 htf.img2( '/OA_MEDIA/FNDIEDIT.gif', calign => 'CENTER',
1637 calt => '''Edit Attachment''',
1638 cattributes => 'border=yes width=17 height=16'),
1639 cattributes=>'target="_top"')
1640 ||'</TD>');
1641 end if;
1642
1643 if (query_only <> 'Y' ) then
1644 htp.p('<TD ><FONT class=tabledata>'||
1645 htf.anchor2('javascript:delete_attachment('''
1646 || owa_util.get_owa_service_path
1647 ||'fnd_webattch.DeleteAttachment?attached_document_id='
1648 ||icx_call.encrypt2(to_char(atlstrec.attached_document_id))
1649 ||'&'||'function_name='||icx_call.encrypt2(function_name)
1650 ||'&'||'entity_name='||icx_call.encrypt2(entity_name)
1651 ||'&'||'pk1_value='||icx_call.encrypt2(pk1_value)
1652 ||'&'||'pk2_value='||icx_call.encrypt2(pk2_value)
1653 ||'&'||'pk4_value='||icx_call.encrypt2(pk4_value)
1654 ||'&'||'pk5_value='||icx_call.encrypt2(pk5_value)
1655 ||'&'||'from_url='||
1656 icx_call.encrypt2(replace(from_url,'&','%26'))
1657 ||'&'||'query_only='||icx_call.encrypt2(query_only)||''')',
1658 htf.img2( '/OA_MEDIA/FNDIDELR.gif',
1659 calign => 'CENTER', calt => '''Delete Attachment''',
1660 cattributes => 'border=yes width=17 height=16'))
1661 ||'</TD>');
1662 end if;
1663 htp.tableRowClose;
1664
1665 j := j + 1 ;
1666
1667 fetch al_cursor into atlstrec;
1668 exit when al_cursor%NOTFOUND;
1669 end loop;
1670 close al_cursor;
1671
1672 htp.tableClose;
1673 htp.p('</TD>');
1674 htp.p('</TR>');
1675 htp.p('</TABLE>');
1676
1677 <<bottom_header>>
1678 htp.br;
1679 htp.p ('<LEFT>');
1680 if (query_only <> 'Y' ) then
1681 -- Create buttons for adding and back links.
1682 htp.p('<!-- This is a button table containing 2 buttons. The first'||
1683 ' row defines the edges and tops-->');
1684 htp.p('<TD ALIGN="LEFT" WIDTH="100%">');
1685 htp.p('<table cellpadding=0 cellspacing=0 border=0>');
1686 htp.p('<tr>');
1687 htp.p('<!-- left hand button, round left side and square right side-->');
1688 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDL.gif></td>');
1689 htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
1690 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBSQRR.gif></td>');
1691 htp.p('<!-- standard spacer between square button images--> ');
1692 htp.p('<td width=2 rowspan=5></td>');
1693
1694 htp.p('<!-- right hand button, square left side and round right side-->');
1695 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBSQRL.gif></td>');
1696 htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
1697 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDR.gif></td>');
1698 htp.p('</tr>');
1699 htp.p('<tr>');
1700 htp.p('<!-- one cell of this type required for every button -->');
1701 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
1702 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
1703 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
1704 htp.p('</tr>');
1705 htp.p('<tr>');
1706 htp.p('<!-- Text and links for each button are listed here-->');
1707 htp.p('<td bgcolor=#cccccc height=20 nowrap><a href="'
1708 ||owa_util.get_owa_service_path ||package_name
1709 ||'.AddAttachment?function_name='||icx_call.encrypt2(function_name)
1710 ||'&'||'entity_name='||icx_call.encrypt2(entity_name)
1711 ||'&'||'pk1_value='||icx_call.encrypt2(pk1_value)
1712 ||'&'||'pk2_value='||icx_call.encrypt2(pk2_value)
1713 ||'&'||'pk3_value='||icx_call.encrypt2(pk3_value)
1714 ||'&'||'pk4_value='||icx_call.encrypt2(pk4_value)
1715 ||'&'||'pk5_value='||icx_call.encrypt2(pk5_value)
1716 ||'&'||'from_url='||icx_call.encrypt2(replace(from_url,'&','%26'))
1717 ||'&'||'query_only='||icx_call.encrypt2(query_only)
1718 ||'"target="_parent"><font class=button>'
1719 ||fnd_message.get_string('FND','FND-WEBATCH-SUMMARY-ADD'));
1720 htp.p('</FONT></TD>');
1721 htp.p('<TD bgcolor=#cccccc height=20 nowrap><A href="'
1722 || from_url|| '" target="_parent" ><FONT class=button>'
1723 || fnd_message.get_string('FND','FND-WEBATCH-SUMMARY-EXIT'));
1724 htp.p('</FONT></TD>');
1725 htp.p('</FONT></A></TD>');
1726 htp.p('</TR>');
1727
1728 htp.p('<TR>');
1729 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1730 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1731 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1732 htp.p('</TR>');
1733 htp.p('<TR>');
1734 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1735 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1736 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1737 htp.p('</TR>');
1738 htp.p('</TABLE>');
1739 else
1740 htp.p('<!-- This is a button table containing 1 buttons. The first'||
1741 ' row defines the edges and tops-->');
1742 htp.p('<TD ALIGN="LEFT" WIDTH="100%">');
1743 htp.p('<table cellpadding=0 cellspacing=0 border=0>');
1744 htp.p('<tr>');
1745 htp.p('<!-- button, round left side and right side-->');
1746 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDL.gif></td>');
1747 htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
1748 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDR.gif></td>');
1749
1750 htp.p('<tr>');
1751 htp.p('<!-- one cell of this type required for every button -->');
1752 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
1753 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
1754 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
1755 htp.p('</tr>');
1756 htp.p('<tr>');
1757 htp.p('<!-- Text and links for each button are listed here-->');
1758 htp.p('<TD bgcolor=#cccccc height=20 nowrap><A href="'
1759 || from_url|| '"><FONT class=button>'
1760 || fnd_message.get_string('FND','FND-WEBATCH-SUMMARY-EXIT'));
1761 htp.p('</FONT></TD>');
1762 htp.p('</FONT></A></TD>');
1763 htp.p('</TR>');
1764
1765 htp.p('<TR>');
1766 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1767 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1768 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
1769 htp.p('</TR>');
1770 htp.p('</TABLE>');
1771 end if;
1772
1773 htp.bodyClose;
1774 htp.htmlClose;
1775
1776 exception
1777 when others then
1778 rollback;
1779 if (al_cursor%isopen) then
1780 close al_cursor;
1781 end if;
1782 end PrintSummary;
1783
1784 -- PrintTextDocument
1785 -- Print the web page that displays text document information.
1786 -- IN
1787 -- package_name - Calling package name.
1788 -- attached_document_id - Reference to the attached document
1789 -- function_name - Function name of the web function
1790 -- entity_name - Entity name to which the attachment is made.
1791 -- pk1_value - First primary key of the entity.
1792 -- through
1793 -- pk5_value - Fifth primary key value of the entity.
1794 -- from_url - URL from which the attachments is invoked from.
1795 -- This is required to set the back link.
1796 -- query_only - Query flag is set 'Y' when called in query only
1797 -- mode.
1798 --
1799
1800 procedure PrintTextDocument(
1801 package_name in varchar2 default 'FND_WEBATTCH',
1802 attached_document_id in varchar2,
1803 function_name in varchar2 ,
1804 entity_name in varchar2 ,
1805 pk1_value in varchar2 ,
1806 pk2_value in varchar2 default NULL,
1807 pk3_value in varchar2 default NULL,
1808 pk4_value in varchar2 default NULL,
1809 pk5_value in varchar2 default NULL,
1810 from_url in varchar2,
1811 query_only in varchar2 default 'N'
1812 ) as
1813
1814
1815 l_seq_num number;
1816 l_datatype_id number;
1817 l_text CLOB;
1818 l_category_description varchar2(255);
1819 l_document_description varchar2(255);
1820 l_html_text varchar2(32000);
1821 l_function_name varchar2(30) :=
1822 icx_call.decrypt2(PrintTextDocument.function_name);
1823 l_attached_document_id varchar2(16):=
1824 icx_call.decrypt2(PrintTextDocument.attached_document_id);
1825
1826 begin
1827
1828 -- Find out the datatype of text being displayed.
1829 select fd.datatype_id
1830 into l_datatype_id
1831 from fnd_documents fd, fnd_attached_documents fad
1832 where fd.document_id = fad.document_id
1833 and fad.attached_document_id = to_number(l_attached_document_id);
1834
1835 -- Get the document text for the attachment.
1836 if (l_datatype_id = 2) then
1837 select fdfv.seq_num, fdfv.category_description,
1838 fdfv.document_description, fdlt.long_text
1839 into l_seq_num,l_category_description,l_document_description,l_text
1840 from fnd_attached_docs_form_vl fdfv, fnd_documents_long_text fdlt
1841 where fdfv.media_id = fdlt.media_id
1842 and fdfv.attached_document_id = to_number(l_attached_document_id)
1843 and fdfv.function_name = l_function_name
1844 and fdfv.function_type = 'F';
1845 else
1846 select fdfv.seq_num, fdfv.category_description,
1847 fdfv.document_description, fdst.short_text
1848 into l_seq_num,l_category_description,l_document_description,l_text
1849 from fnd_attached_docs_form_vl fdfv, fnd_documents_short_text fdst
1850 where fdfv.media_id = fdst.media_id
1851 and fdfv.attached_document_id = to_number(l_attached_document_id)
1852 and fdfv.function_name = l_function_name
1853 and fdfv.function_type = 'F';
1854 end if;
1855
1856 -- Replace all newline character with <BR> and newline character.
1857 l_html_text := substrb(replace(l_text, fnd_webattch.g_chr_newline,
1858 '<BR>'||fnd_webattch.g_chr_newline),
1859 1, 32000);
1860
1861 htp.bodyClose;
1862 htp.htmlClose;
1863 htp.p('<BODY bgcolor="#cccccc">');
1864
1865 -- Display the text
1866 htp.formOpen('','','','','NAME="displaytext"');
1867 htp.tableOpen( cattributes => ' border=0 cellpadding=2 cellspacing=0' );
1868 htp.tableRowOpen;
1869 htp.p('<TD>');
1870 htp.p('</TD>');
1871 htp.tableRowClose;
1872 htp.tableRowOpen;
1873 htp.tableData( l_html_text);
1874 htp.tableRowClose;
1875 htp.tableClose;
1876
1877 htp.formClose;
1878 htp.bodyClose;
1879 htp.htmlClose;
1880
1881 exception
1882
1883 when NO_DATA_FOUND then
1884 htp.p(fnd_message.get_string('FND','FND-WEBATCH-ERROR-RETRIEVING'));
1885 htp.bodyClose;
1886 htp.htmlClose;
1887
1888 end PrintTextDocument;
1889
1890 -- PrintUpdateAttachment
1891 -- Prints the HTML form to update attachment and document information.
1892 -- IN
1893 -- package_name - Calling package name.
1894 -- seq_num - Attachment Seq Number.
1895 -- attached_document_id
1896 -- function_name - Function name of the web function
1897 -- entity_name - Entity name to which the attachment is made.
1898 -- pk1_value - First primary key of the entity.
1899 -- through
1900 -- pk5_value - Fifth primary key value of the entity.
1901 -- from_url - URL from which the attachments is invoked from.
1902 -- This is required to set the back link.
1903 -- query_only - Query flag is set 'Y' when called in query only
1904 -- mode.
1905 --
1906
1907 procedure PrintUpdateAttachment (
1908 package_name in varchar2 default 'FND_WEBATTCH',
1909 attached_document_id in varchar2,
1910 function_name in varchar2,
1911 entity_name in varchar2,
1912 pk1_value in varchar2,
1913 pk2_value in varchar2 default NULL,
1914 pk3_value in varchar2 default NULL,
1915 pk4_value in varchar2 default NULL,
1916 pk5_value in varchar2 default NULL,
1917 from_url in varchar2,
1918 query_only in varchar2 default 'N'
1919 ) as
1920 cursor att_doc_cursor is
1921 select seq_num,
1922 category_description,
1923 document_description,
1924 datatype_id,
1925 media_id,
1926 file_name
1927 from fnd_attached_docs_form_vl
1928 where attached_document_id = PrintUpdateAttachment.attached_document_id;
1929
1930 cursor doc_cat_cursor is
1931 select user_name,category_id,default_datatype_name,default_datatype_id
1932 from fnd_doc_categories_active_vl
1933 where category_id in
1934 (select fdcu.category_id
1935 from fnd_doc_category_usages fdcu, fnd_attachment_functions af
1936 where af.attachment_function_id = fdcu.attachment_function_id
1937 and af.function_name = PrintUpdateAttachment.function_name
1938 and af.function_type = 'F'
1939 and fdcu.enabled_flag = 'Y')
1940 order by user_name;
1941
1942 attdocrec att_doc_cursor%ROWTYPE;
1943
1944 document_short_text varchar2(2000);
1945 document_long_text CLOB;
1946 x_seq_num number;
1947 x_category_description varchar2(255);
1948 x_document_description varchar2(255);
1949 x_datatype_id number;
1950 x_media_id number;
1951 x_file_name varchar2(255);
1952 l_lang varchar2(24);
1953 access_id number;
1954 upload_action varchar2(2000);
1955 l_username varchar2(80);
1956 l_reload_url varchar2(2000);
1957
1958 begin
1959
1960 -- Validate the session
1961 if NOT (icx_sec.ValidateSession(null)) then
1962 return;
1963 end if;
1964
1965 -- Set the language
1966 l_lang := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
1967 l_username := UPPER(ICX_SEC.GetID(99));
1968
1969 -- Construct reload URL.
1970 l_reload_url := owa_util.get_owa_service_path|| package_name||
1971 '.Summary?function_name='|| icx_call.encrypt2(function_name)
1972 ||'&'||'entity_name='||icx_call.encrypt2(entity_name)
1973 ||'&'||'pk1_value='||icx_call.encrypt2(pk1_value)
1974 ||'&'||'pk2_value='||icx_call.encrypt2(pk2_value)
1975 ||'&'||'pk3_value='||icx_call.encrypt2(pk3_value)
1976 ||'&'||'pk4_value='||icx_call.encrypt2(pk4_value)
1977 ||'&'||'pk5_value='||icx_call.encrypt2(pk5_value)
1978 ||'&'||'from_url=' ||icx_call.encrypt2(from_url)
1979 ||'&'||'query_only='||icx_call.encrypt2(query_only);
1980
1981 htp.htmlOpen;
1982 htp.headOpen;
1983
1984 -- Add the java script to the header to open the dm window for
1985 -- any DM function that is executed.
1986 fnd_document_management.get_open_dm_attach_window;
1987
1988 -- Add java script to the header to open display window
1989 fnd_document_management.get_open_dm_display_window;
1990
1991 -- Add java script to open the summary window.
1992 htp.p( '<SCRIPT LANGUAGE="JavaScript">');
1993 htp.p( ' function applySubmit(url) {
1994 document.UPDATE_ATCHMT.submit();
1995 top.location.href = url;
1996 }');
1997 htp.print( '</SCRIPT>' );
1998
1999 -- Style sheet declaration.
2000 htp.p('<LINK REL=STYLESHEET HREF="/OA_HTML/US/osswa.css" '||
2001 'TYPE="text/css">');
2002
2003 htp.headClose;
2004 htp.bodyOpen;
2005
2006 -- Body background color.
2007 htp.p('<BODY bgcolor="#cccccc">');
2008 htp.br;
2009
2010 -- Print the Page Header.
2011 htp.p('<table width=98% cellpadding=0 cellspacing=0 border=0>');
2012 htp.p('<tr bgcolor=#336699>');
2013 htp.p('<td><font color=#336699>.</font></td>');
2014 htp.p('<TD width=100% nowrap><FONT CLASS=containertitle>'||
2015 fnd_message.get_string('FND','FND-WEBATCH-EDIT-ATCHMT-HEADIN')
2016 ||'</FONT></TD>');
2017 htp.tableRowClose;
2018 htp.tableClose;
2019 htp.br;
2020
2021 -- Select the updatable information.
2022 open att_doc_cursor;
2023 fetch att_doc_cursor into attdocrec;
2024 if att_doc_cursor%NOTFOUND then
2025 close att_doc_cursor;
2026 htp.p(fnd_message.get_string('FND','FND-WEBATCH-ERROR-RETRIEVING')
2027 ||'for update');
2028 htp.print( '</LEFT>' );
2029 htp.bodyClose;
2030 htp.htmlclose;
2031 return;
2032 end if;
2033
2034 loop
2035 x_seq_num := attdocrec.seq_num;
2036 x_datatype_id:= attdocrec.datatype_id;
2037 x_media_id := attdocrec.media_id;
2038 x_file_name := attdocrec.file_name;
2039 x_category_description := attdocrec.category_description;
2040 x_document_description := attdocrec.document_description;
2041
2042 fetch att_doc_cursor into attdocrec;
2043 exit when att_doc_cursor%NOTFOUND;
2044 end loop;
2045 close att_doc_cursor;
2046
2047 -- GFM Preparation
2048 access_id := fnd_gfm.authorize(NULL);
2049 upload_action := 'fnd_webattch.update_attachment_gfm_wrapper';
2050
2051 htp.formOpen( curl => upload_action, cattributes=>'NAME="UPDATE_ATCHMT"',
2052 cmethod => 'POST',cenctype=> 'multipart/form-data');
2053
2054 -- Set the Attachment Information.
2055 htp.p('<table width=97% cellpadding=0 cellspacing=0 border=0>');
2056 htp.p('<!-- This row contains the help text -->');
2057 htp.p('<tr bgcolor=#cccccc>');
2058
2059 htp.p('<td valign=top>');
2060 htp.p('<FONT CLASS=helptext>'||'&'||'nbsp; '||
2061 '<IMG src=/OA_MEDIA/FNDIREQD.gif align=top>'||
2062 fnd_message.get_string('FND', 'FND-WEBATCH-REQ-FIELDS')||
2063 '</FONT>');
2064 htp.p('</TD>');
2065 htp.p('</TR>');
2066 htp.p('</TABLE>');
2067 htp.br;
2068
2069 --Set the Attachment Information.
2070 htp.tableOpen( cattributes => ' border=0 cellpadding=0 '||
2071 'width=97% cellspacing=0' );
2072 htp.tableRowOpen;
2073 htp.p('<TD align=right valign=top height=5 width=15%>'||
2074 '<IMG src=/OA_MEDIA/FNDIREQD.gif border=no>'||
2075 '<FONT class=promptblack>'||
2076 fnd_message.get_string('FND', 'FND-WEBATCH-DOCUMENT-SEQUENCE')
2077 || ' </FONT></TD>');
2078
2079 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>'||
2080 '<FONT class=datablack><INPUT NAME='||'"seq_num"'||
2081 ' TYPE='||'"text"'||' VALUE='|| to_char(x_seq_num)||
2082 ' SIZE=4 MAXLENGTH=20></FONT></TD>');
2083 htp.tableRowClose;
2084
2085 --Process the category poplist.
2086 htp.tableRowOpen;
2087 htp.p('<TD align=right valign=top>'||
2088 '<IMG src=/OA_MEDIA/FNDIREQD.gif border=no>'||
2089 '<FONT class=promptblack>'||
2090 fnd_message.get_string('FND', 'FND-WEBATCH-DOCUMENT-CATEGORY')
2091 || ' </FONT></TD>');
2092 htp.p('<TD><font class=datablack>');
2093 htp.formSelectOpen( cname => 'category_id' );
2094 FOR dc in doc_cat_cursor LOOP
2095 if (dc.user_name <> ' ' ) then
2096 if (dc.user_name <> x_category_description ) then
2097 htp.p('<OPTION value='||to_char(dc.category_id)||'>'||dc.user_name);
2098 else
2099 htp.p('<OPTION SELECTED value='||to_char(dc.category_id)||
2100 '>'||dc.user_name);
2101 end if;
2102 else
2103 htp.p('<OPTION value>'||x_category_description);
2104 end if;
2105 END LOOP;
2106 htp.formSelectClose;
2107 htp.p('</FONT></TD>');
2108 htp.tableRowClose;
2109
2110 -- Display Document Description.
2111 htp.tableRowOpen;
2112 htp.p('<TD align=right valign=top>'||
2113 '<IMG src=/OA_MEDIA/FNDIREQD.gif border=no>'||
2114 '<FONT class=promptblack>'||
2115 fnd_message.get_string('FND', 'FND-WEBATCH-DOCUMENT-DESCRIPTI')
2116 || ' </FONT></TD>');
2117 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>'||
2118 '<FONT class=datablack><INPUT NAME='||'"document_description"'||
2119 ' TYPE='||'"text"'|| ' VALUE="'|| x_document_description ||
2120 '" SIZE=25 MAXLENGTH=80></FONT></TD>');
2121 htp.tableRowClose;
2122 htp.tableRowOpen;
2123
2124 htp.p('<td colspan=5 valign=bottom height=30 VALIGN=CENTER ALIGN=LEFT>');
2125 htp.p('<FONT CLASS=datablack>'||
2126 fnd_message.get_string('FND', 'FND-WEBATCH-DOC-INFO-HEADING')||
2127 '</FONT></TD></TR>');
2128 htp.p('<TR><TD colspan=5 height=1 bgcolor=black>'||
2129 '<IMG src=/OA_MEDIA/FNDPX1.gif></TD></TR>');
2130 htp.p('<TR><TD height=10></TD></TR>');
2131 --htp.tableClose;
2132
2133 -- Query the text from the database.
2134 if (x_datatype_id = 1 ) then
2135 select short_text
2136 into document_short_text
2137 from fnd_documents_short_text
2138 where media_id = x_media_id;
2139
2140 -- Display the blank text information for Update.
2141 DocumentInformation (x_datatype_id => x_datatype_id,
2142 x_short_text => document_short_text);
2143
2144 elsif (x_datatype_id = 2) then
2145 select long_text
2146 into document_long_text
2147 from fnd_documents_long_text
2148 where media_id = x_media_id;
2149
2150 -- Display the blank text information for Update.
2151 DocumentInformation (x_datatype_id => x_datatype_id,
2152 x_long_text => document_long_text);
2153
2154 elsif (x_datatype_id = 6) then
2155
2156 -- Display the File Information for update.
2157 DocumentInformation (x_datatype_id => x_datatype_id,
2158 x_file_name => x_file_name);
2159
2160 elsif (x_datatype_id = 5) then
2161
2162 -- Display blank URL document Information for Update
2163 DocumentInformation (x_datatype_id => x_datatype_id,
2164 x_file_name => x_file_name);
2165 elsif (x_datatype_id = 7) then
2166
2167 -- Display blank URL document Information for Update
2168 DocumentInformation (x_datatype_id => x_datatype_id,
2169 x_file_name => x_file_name);
2170 else
2171 htp.formHidden ( cname =>'text', cvalue=>'');
2172 htp.formHidden ( cname =>'file_name', cvalue=>'');
2173 htp.formHidden ( cname =>'url', cvalue=>'');
2174 end if;
2175
2176 -- Set the data needed for displaying summary as hidden field.
2177 htp.formHidden ( cname =>'attached_document_id',
2178 cvalue=> attached_document_id );
2179 htp.formHidden ( cname =>'datatype_id', cvalue=> to_char(x_datatype_id));
2180 htp.formHidden ( cname =>'function_name', cvalue=> function_name );
2181
2182 htp.formHidden ( cname =>'entity_name', cvalue=> entity_name);
2183 htp.formHidden ( cname =>'pk1_value', cvalue=> pk1_value);
2184 htp.formHidden ( cname =>'pk2_value', cvalue=> pk2_value);
2185 htp.formHidden ( cname =>'pk3_value', cvalue=> pk3_value);
2186 htp.formHidden ( cname =>'pk4_value', cvalue=> pk4_value);
2187 htp.formHidden ( cname =>'pk5_value', cvalue=> pk5_value);
2188 htp.formHidden ( cname =>'from_url', cvalue=> from_url);
2189 htp.formHidden ( cname =>'query_only', cvalue=> query_only);
2190 htp.formHidden ( cname =>'package_name', cvalue=>
2191 icx_sec.getID(icx_sec.PV_WEB_USER_ID)||';'
2192 || PrintUpdateAttachment.package_name ||';'||to_char(access_id)||';');
2193 htp.br;
2194
2195 -- Create buttons for adding and back links.
2196 htp.p('<!-- This is a button table containing 2 buttons. The first'||
2197 ' row defines the edges and tops-->');
2198 htp.p('<TD ALIGN="LEFT" WIDTH="100%">');
2199 htp.p('<table cellpadding=0 cellspacing=0 border=0>');
2200 htp.p('<tr>');
2201 htp.p('<!-- left hand button, round left side and square right side-->');
2202 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDL.gif></td>');
2203 htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
2204 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBSQRR.gif></td>');
2205 htp.p('<!-- standard spacer between square button images--> ');
2206 htp.p('<td width=2 rowspan=5></td>');
2207
2208 htp.p('<!-- right hand button, square left side and round right side-->');
2209 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBSQRL.gif></td>');
2210 htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
2211 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDR.gif></td>');
2212 htp.p('</tr>');
2213 htp.p('<tr>');
2214 htp.p('<!-- one cell of this type required for every button -->');
2215 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
2216 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
2217 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
2218 htp.p('</tr>');
2219 htp.p('<tr>');
2220 htp.p('<!-- Text and links for each button are listed here-->');
2221 htp.p('<td bgcolor=#cccccc height=20 nowrap>'||
2222 '<A href="javascript:applySubmit('''||l_reload_url||''')"'||
2223 ' OnMouseOver="window.status='''||'OK'||''';return true">'||
2224 '<font class=button>'||
2225 fnd_message.get_string('FND','FND-WEBATCH-UPDATE-ATTACHMENT'));
2226 htp.p('</FONT></TD>');
2227 htp.p('<td bgcolor=#cccccc height=20 nowrap>'||
2228 '<A href="javascript:document.UPDATE_ATCHMT.reset()"'||
2229 ' OnMouseOver="window.status='''||'Reset'||''';return true">'||
2230 '<font class=button>'||
2231 fnd_message.get_string('FND','FND-WEBATCH-FORM-RESET'));
2232 htp.p('</FONT></TD>');
2233 htp.p('</FONT></A></TD>');
2234 htp.p('</TR>');
2235
2236 htp.p('<TR>');
2237 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2238 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2239 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2240 htp.p('</TR>');
2241 htp.p('<TR>');
2242 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2243 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2244 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2245 htp.p('</TR>');
2246 htp.p('</TABLE>');
2247
2248 htp.formClose;
2249 htp.bodyClose;
2250 htp.htmlClose;
2251
2252 exception
2253 when others then
2254 rollback;
2255 if (doc_cat_cursor%isopen) then
2256 close doc_cat_cursor;
2257 end if;
2258 if (att_doc_cursor%isopen) then
2259 close att_doc_cursor;
2260 end if;
2261 end PrintUpdateAttachment;
2262
2263 -- PrintAddAttachment
2264 -- Prints the HTML form to add attachment and document information.
2265 -- IN
2266 -- package_name - Calling package name.
2267 -- function_name - Function name of the web function
2268 -- entity_name - Entity name to which the attachment is made.
2269 -- pk1_value - First primary key of the entity.
2270 -- through
2271 -- pk5_value - Fifth primary key value of the entity.
2272 -- from_url - URL from which the attachments is invoked from.
2273 -- This is required to set the back link.
2274 -- query_only - Query flag is set 'Y' when called in query only
2275 -- mode.
2276 --
2277
2278 Procedure PrintAddAttachment(
2279 package_name in varchar2 default 'FND_WEBATTCH',
2280 function_name in varchar2,
2281 entity_name in varchar2,
2282 pk1_value in varchar2,
2283 pk2_value in varchar2 default NULL,
2284 pk3_value in varchar2 default NULL,
2285 pk4_value in varchar2 default NULL,
2286 pk5_value in varchar2 default NULL,
2287 from_url in varchar2,
2288 query_only in varchar2 default 'N'
2289 ) as
2290 cursor dc_cursor is
2291 select user_name,category_id,default_datatype_name,default_datatype_id
2292 from fnd_doc_categories_active_vl
2293 where category_id in
2294 (select fdcu.category_id
2295 from fnd_doc_category_usages fdcu, fnd_attachment_functions af
2296 where af.attachment_function_id = fdcu.attachment_function_id
2297 and af.function_name = PrintAddAttachment.function_name
2298 and af.function_type = 'F'
2299 and fdcu.enabled_flag = 'Y')
2300 order by user_name;
2301
2302 cursor sm_cursor is
2303 select NVL(max(seq_num),0) + 10
2304 from fnd_attached_documents
2305 where entity_name = PrintAddAttachment.entity_name
2306 and pk1_value = PrintAddAttachment.pk1_value
2307 and decode(PrintAddAttachment.pk2_value,null,'*',PK2_VALUE) =
2308 decode(PrintAddAttachment.pk2_value,null,'*',PrintAddAttachment.pk2_value)
2309 and decode(PrintAddAttachment.pk3_value,null,'*',PK3_VALUE)=
2310 decode(PrintAddAttachment.pk3_value,null,'*',PrintAddAttachment.pk3_value)
2311 and decode(PrintAddAttachment.pk4_value,null,'*',PK4_VALUE)=
2312 decode(PrintAddAttachment.pk4_value,null,'*', PrintAddAttachment.pk4_value)
2313 and decode(PrintAddAttachment.pk5_value,null,'*',PK5_VALUE)=
2314 decode(PrintAddAttachment.pk5_value,null,'*',PrintAddAttachment.pk5_value);
2315
2316 seq_num number := 10;
2317 l_lang varchar2(24);
2318 access_id number;
2319 upload_action varchar2(2000);
2320 l_callback_url varchar2(4000);
2321 l_search_document_url varchar2(4000);
2322 l_username varchar2(80);
2323 l_reload_url varchar2(2000);
2324
2325 begin
2326
2327 -- Validate the session
2328 if NOT (icx_sec.ValidateSession(null)) then
2329 return;
2330 end if;
2331
2332 -- Set the language
2333 l_lang := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
2334 l_username := UPPER(ICX_SEC.GetID(99));
2335
2336 l_reload_url := owa_util.get_owa_service_path|| package_name||
2337 '.Summary?function_name='|| icx_call.encrypt2(function_name)
2338 ||'&'||'entity_name='||icx_call.encrypt2(entity_name)
2339 ||'&'||'pk1_value='||icx_call.encrypt2(pk1_value)
2340 ||'&'||'pk2_value='||icx_call.encrypt2(pk2_value)
2341 ||'&'||'pk3_value='||icx_call.encrypt2(pk3_value)
2342 ||'&'||'pk4_value='||icx_call.encrypt2(pk4_value)
2343 ||'&'||'pk5_value='||icx_call.encrypt2(pk5_value)
2344 ||'&'||'from_url=' ||icx_call.encrypt2(from_url)
2345 ||'&'||'query_only='||icx_call.encrypt2(query_only);
2346
2347 htp.htmlOpen;
2348 htp.headOpen;
2349
2350 -- Add the java script to the header to open the dm window for
2351 -- any DM function that is executed.
2352 fnd_document_management.get_open_dm_attach_window;
2353
2354 -- Add java script to the header to open display window
2355 fnd_document_management.get_open_dm_display_window;
2356
2357 htp.p( '<SCRIPT LANGUAGE="JavaScript">');
2358 htp.p( ' function applySubmit(url) {
2359 document.ADD_ATCHMT.submit();
2360 top.location.href = url;
2361 }');
2362 htp.print( '</SCRIPT>' );
2363
2364 -- Style sheet declaration.
2365 htp.p('<LINK REL=STYLESHEET HREF="/OA_HTML/US/osswa.css" '||
2366 'TYPE="text/css">');
2367
2368 htp.headClose;
2369 htp.bodyOpen;
2370
2371 -- Body background color.
2372 htp.p('<BODY bgcolor="#cccccc">');
2373 htp.br;
2374
2375 -- Print the Page Header.
2376 htp.p('<table width=98% cellpadding=0 cellspacing=0 border=0>');
2377 htp.p('<tr bgcolor=#336699>');
2378 htp.p('<td><font color=#336699>.</font></td>');
2379 htp.p('<TD width=100% nowrap><FONT CLASS=containertitle>'||
2380 fnd_message.get_string('FND','FND-WEBATCH-ADDATCHMT-HEADING')
2381 ||'</FONT></TD>');
2382 htp.tableRowClose;
2383 htp.tableClose;
2384 htp.br;
2385
2386 -- GFM Preparation
2387 access_id := fnd_gfm.authorize(NULL);
2388 upload_action := 'fnd_webattch.add_attachment_gfm_wrapper';
2389
2390 htp.formOpen( curl => upload_action , cattributes=>'NAME="ADD_ATCHMT"',
2391 cmethod => 'POST',cenctype=> 'multipart/form-data');
2392
2393 htp.p('<table width=97% cellpadding=0 cellspacing=0 border=0>');
2394 htp.p('<!-- This row contains the help text -->');
2395 htp.p('<tr bgcolor=#cccccc>');
2396
2397 htp.p('<td valign=top>');
2398 htp.p('<FONT CLASS=helptext>'||'&'||'nbsp; '||
2399 fnd_message.get_string('FND', 'FND-WEBATCH-ATCHMT-INFO-HEADIN')||' '
2400 ||'<IMG src=/OA_MEDIA/FNDIREQD.gif align=top>'||
2401 fnd_message.get_string('FND', 'FND-WEBATCH-REQ-FIELDS')||' '||
2402 '</FONT>');
2403 htp.p('</TD>');
2404 htp.p('</TR>');
2405 htp.p('</TABLE>');
2406 htp.br;
2407
2408 --Set the Attachment Information.
2409 htp.tableOpen( cattributes => ' border=0 cellpadding=0 '||
2410 'width=97% cellspacing=0' );
2411
2412 -- Get the max Sequence Number and set it seq_num.
2413 open sm_cursor;
2414 fetch sm_cursor into seq_num;
2415 close sm_cursor;
2416
2417 htp.tableRowOpen;
2418 htp.p('<TD align=right valign=top height=5 width=35%>'||
2419 '<IMG src=/OA_MEDIA/FNDIREQD.gif border=no>'||
2420 '<FONT class=promptblack>'||
2421 fnd_message.get_string('FND', 'FND-WEBATCH-DOCUMENT-SEQUENCE')
2422 || ' </FONT></TD>');
2423
2424 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>'||
2425 '<FONT class=datablack><INPUT NAME='||'"seq_num"'||
2426 ' TYPE='||'"text"'||' VALUE='||
2427 to_char(seq_num)||' SIZE=4 MAXLENGTH=20></FONT></TD>');
2428 htp.tableRowClose;
2429
2430 --Process the category poplist.
2431 htp.tableRowOpen;
2432 htp.p('<TD align=right valign=top>'||
2433 '<IMG src=/OA_MEDIA/FNDIREQD.gif border=no>'||
2434 '<FONT class=promptblack>'||
2435 fnd_message.get_string('FND', 'FND-WEBATCH-DOCUMENT-CATEGORY')
2436 || ' </FONT></TD>');
2437 htp.p('<TD><FONT class=datablack>');
2438 htp.formSelectOpen( cname => 'category_id' );
2439 FOR dc in dc_cursor LOOP
2440 if (dc.user_name <> ' ' ) then
2441 htp.p('<OPTION value='||to_char(dc.category_id)||'>'|| dc.user_name);
2442 else
2443 htp.p('<OPTION value>'||dc.user_name);
2444 end if;
2445 END LOOP;
2446 htp.formSelectClose;
2447 htp.p('</FONT></TD>');
2448 htp.tableRowClose;
2449
2450 -- Display Document Description.
2451 htp.tableRowOpen;
2452 htp.p('<TD align=right valign=top>'||
2453 '<IMG src=/OA_MEDIA/FNDIREQD.gif border=no>'||
2454 '<FONT class=promptblack>'||
2455 fnd_message.get_string('FND', 'FND-WEBATCH-DOCUMENT-DESCRIPTI')
2456 || ' </FONT></TD>');
2457 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>'||
2458 '<FONT class=datablack><INPUT NAME='||'"document_description"'||
2459 ' TYPE='||'"text"'|| ' SIZE=25 MAXLENGTH=80></FONT></TD>');
2460 htp.tableRowClose;
2461
2462 -- Construct the Document Information area.
2463 -- Text datatype
2464 htp.tableRowOpen;
2465
2466 htp.p('<td colspan=5 valign=bottom height=30 VALIGN=CENTER ALIGN=LEFT>');
2467 htp.p('<FONT CLASS=datablack>'||
2468 fnd_message.get_string('FND', 'FND-WEBATCH-DOC-INFO-HEADING')||
2469 '</FONT></TD></TR>');
2470 htp.p('<TR><TD colspan=5 height=1 bgcolor=black>'||
2471 '<IMG src=/OA_MEDIA/FNDPX1.gif></TD></TR>');
2472 htp.p('<TR><TD height=10></TD></TR>');
2473
2474 htp.tableRowOpen;
2475 htp.p('<TD align=left valign=top>');
2476 htp.p('<FONT class=promptblack><INPUT name="datatype_id"'||
2477 'type=radio checked value="2">'||
2478 fnd_message.get_string('FND','FND-WEBATCH-TEXT-DATATYPE')||'</TD>');
2479 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>');
2480 htp.p('<FONT class=datablack><TEXTAREA NAME ="text" ROWS=4 + COLS=38>'||
2481 '</TEXTAREA></FONT>');
2482 htp.tableRowClose;
2483
2484 -- File Datatype
2485 htp.tableRowOpen;
2486 htp.p('<TD align=left>');
2487 htp.p('<FONT class=promptblack><INPUT name="datatype_id"'||
2488 'type=radio value="6">'||
2489 fnd_message.get_string('FND','FND-WEBATCH-FILE-DATATYPE')||'</TD>');
2490 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>');
2491 htp.p('<FONT class=datablack><INPUT TYPE="File" NAME="file_name"'||
2492 ' SIZE="32"></FONT>');
2493 htp.tableRowClose;
2494
2495 -- URL Datatype
2496 htp.tableRowOpen;
2497 htp.p('<TD align=left>');
2498 htp.p('<FONT class=promptblack><INPUT name="datatype_id"'||
2499 'type=radio value="5">'||
2500 fnd_message.get_string('FND','FND-WEBATCH-WEBPAGE-DATATYPE')||'</TD>');
2501 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>');
2502 htp.p('<FONT class=datablack><INPUT TYPE="Text" NAME="url"'||
2503 ' SIZE="40"></FONT>');
2504 htp.tableRowClose;
2505
2506 /*
2507 ** Create the callback syntax to update the local fields
2508 */
2509 fnd_document_management.set_document_id_html (
2510 null,
2511 'FNDATTACH',
2512 'dmid',
2513 'dmname',
2514 l_callback_url);
2515
2516 -- Get the url syntax for performing a search
2517 fnd_document_management.get_launch_attach_url (
2518 l_username,
2519 l_callback_url,
2520 TRUE,
2521 l_search_document_URL);
2522
2523 -- DM Datatype
2524 htp.tableRowOpen;
2525 htp.p('<TD align=left width=35% NOWRAP>');
2526 htp.p('<FONT class=promptblack><INPUT name="datatype_id"'||
2527 'type=radio value="5">'||
2528 fnd_message.get_string('FND','FND-WEBATCH-DM-DATATYPE')||'</TD>');
2529 htp.p('<TD VALIGN=CENTER ALIGN=LEFT>');
2530 htp.p('<FONT class=datablack><INPUT TYPE="Text" NAME="dmid"'||
2531 ' SIZE="40"></FONT>'||l_search_document_URL);
2532 htp.tableRowClose;
2533 htp.tableClose;
2534
2535 -- Set the data needed for add attachment as hidden field.
2536 htp.formHidden (cname =>'access_id', cvalue=> to_char(access_id));
2537 htp.formHidden (cname =>'function_name', cvalue=> function_name);
2538 htp.formHidden (cname =>'entity_name', cvalue=> entity_name);
2539 htp.formHidden (cname =>'pk1_value', cvalue=> pk1_value);
2540 htp.formHidden (cname =>'pk2_value', cvalue=> pk2_value);
2541 htp.formHidden (cname =>'pk3_value', cvalue=> pk3_value);
2542 htp.formHidden (cname =>'pk4_value', cvalue=> pk4_value);
2543 htp.formHidden (cname =>'pk5_value', cvalue=> pk5_value);
2544 htp.formHidden (cname =>'from_url', cvalue=> from_url);
2545 htp.formHidden (cname =>'query_only',cvalue=> query_only);
2546 htp.formHidden (cname =>'user_id',
2547 cvalue=> icx_sec.getID(icx_sec.PV_WEB_USER_ID));
2548 htp.formHidden (cname =>'package_name',cvalue=>
2549 PrintAddAttachment.package_name );
2550
2551 -- Submit and Reset Buttons.
2552 -- Create buttons for adding and back links.
2553 htp.br;
2554 htp.p('<!-- This is a button table containing 2 buttons. The first'||
2555 ' row defines the edges and tops-->');
2556 htp.p('<TD ALIGN="LEFT" WIDTH="100%">');
2557 htp.p('<table cellpadding=0 cellspacing=0 border=0>');
2558 htp.p('<tr>');
2559 htp.p('<!-- left hand button, round left side and square right side-->');
2560 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDL.gif></td>');
2561 htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
2562 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBSQRR.gif></td>');
2563 htp.p('<!-- standard spacer between square button images--> ');
2564 htp.p('<td width=2 rowspan=5></td>');
2565
2566 htp.p('<!-- right hand button, square left side and round right side-->');
2567 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBSQRL.gif></td>');
2568 htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
2569 htp.p('<td rowspan=5><img src=/OA_MEDIA/FNDBRNDR.gif></td>');
2570 htp.p('</tr>');
2571 htp.p('<tr>');
2572 htp.p('<!-- one cell of this type required for every button -->');
2573 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
2574 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
2575 htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
2576 htp.p('</tr>');
2577 htp.p('<tr>');
2578 htp.p('<!-- Text and links for each button are listed here-->');
2579 htp.p('<td bgcolor=#cccccc height=20 nowrap>'||
2580 '<A href="javascript:applySubmit('''||l_reload_url||''')"'||
2581 ' OnMouseOver="window.status='''||'OK'||''';return true">'||
2582 '<font class=button>'||
2583 fnd_message.get_string('FND','FND-WEBATCH-ADD-ATTACHMENT'));
2584 htp.p('</FONT></TD>');
2585 htp.p('<td bgcolor=#cccccc height=20 nowrap>'||
2586 '<A href="javascript:document.ADD_ATCHMT.reset()"'||
2587 ' OnMouseOver="window.status='''||'Reset'||''';return true">'||
2588 '<font class=button>'||
2589 fnd_message.get_string('FND','FND-WEBATCH-FORM-RESET'));
2590 htp.p('</FONT></TD>');
2591 htp.p('</FONT></A></TD>');
2592 htp.p('</TR>');
2593
2594 htp.p('<TR>');
2595 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2596 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2597 htp.p('<TD bgcolor=#666666><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2598 htp.p('</TR>');
2599 htp.p('<TR>');
2600 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2601 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2602 htp.p('<TD bgcolor=#333333><IMG src=/OA_MEDIA/FNDPX3.gif></TD>');
2603 htp.p('</TR>');
2604 htp.p('</TABLE>');
2605 htp.formClose;
2606 htp.bodyClose;
2607 htp.htmlClose;
2608
2609 exception
2610 when others then
2611 htp.print('Error occured and control in exception');
2612 rollback;
2613 if (dc_cursor%isopen) then
2614 close dc_cursor;
2615 end if;
2616 end PrintAddAttachment;
2617
2618 PROCEDURE PrintBlankPage
2619 IS
2620 BEGIN
2621 htp.htmlOpen;
2622 htp.bodyOpen;
2623
2624 -- Body background color.
2625 htp.p('<BODY bgcolor="#cccccc">');
2626
2627 htp.bodyClose;
2628 htp.htmlClose;
2629 END PrintBlankPage;
2630
2631 /*===========================================================================
2632
2633 Function set_document_identifier
2634
2635 Purpose This is call back implemented to pass the document reference
2636 identifier to the attachments.
2637
2638
2639 file_id - A unique access key for document reference attributes
2640 being attached to a application entity.
2641
2642 document_identifier - full concatenated document attribute strings.
2643 nodeid:libraryid:documentid:version:document_name
2644
2645 ============================================================================*/
2646 PROCEDURE set_document_identifier (
2647 p_file_id IN VARCHAR2,
2648 p_document_id IN VARCHAR2)
2649
2650 IS
2651
2652 BEGIN
2653 /*
2654 ** Update FND_TEMP_FILE_PARAMETERS
2655 */
2656 IF (p_file_id IS NOT NULL) THEN
2657 UPDATE fnd_temp_file_parameters
2658 SET FILE_PARAMETERS = p_document_id
2659 WHERE FILE_ID = p_file_id;
2660
2661 if (SQL%NOTFOUND) then
2662 RAISE NO_DATA_FOUND;
2663 end if;
2664 END IF;
2665
2666
2667 htp.headOpen;
2668 htp.title(wf_core.translate('WFDM_TRANSPORT_WINDOW'));
2669 htp.headClose;
2670
2671 htp.htmlopen;
2672
2673 htp.p('<body bgcolor="#CCCCCC" onLoad="javascript:top.window.close();'||
2674 'return true;">');
2675
2676 htp.htmlclose;
2677
2678
2679 END set_document_identifier;
2680
2681 /*===========================================================================
2682
2683 Function authorizeDMTransaction
2684
2685 Purpose This will provide a secure key for DM transaction from forms.
2686
2687
2688 file_id - A unique access key for document reference attributes
2689 being attached to a application entity.
2690
2691 ============================================================================*/
2692 procedure authorizeDMTransaction(
2693 file_id OUT NOCOPY VARCHAR2)
2694 IS
2695 pragma AUTONOMOUS_TRANSACTION;
2696 l_file_id varchar2(32);
2697 BEGIN
2698 -- Generate Random Number for secured access key
2699 fnd_random_pkg.init(7);
2700 fnd_random_pkg.seed(to_number(to_char(sysdate, 'JSSSSS')), 10, false);
2701 l_file_id := fnd_random_pkg.get_next;
2702
2703 -- Store the file attributes for secured access and commit the
2704 -- transaction.
2705 insert into fnd_temp_file_parameters (file_id, file_parameters)
2706 values (l_file_id, null);
2707
2708 -- Commit the transaction
2709 COMMIT;
2710
2711 -- Set the file id to the ouput parameter
2712 file_id := l_file_id;
2713
2714 END;
2715
2716 end FND_WEBATTCH;