DBA Data[Home] [Help]

PACKAGE BODY: APPS.POS_ASBN

Source


1 PACKAGE BODY POS_ASBN AS
2 /* $Header: POSASBNB.pls 115.3.1156.1 2001/08/27 16:39:15 pkm ship  $ */
3 
4   /* Build_Buttons
5    * ------------
6    */
7 
8   PROCEDURE Build_Buttons(p_button1Name VARCHAR2, p_button1Function VARCHAR2,
9                          p_button2Name VARCHAR2, p_button2Function VARCHAR2,
10                          p_button3Name VARCHAR2, p_button3Function VARCHAR2)
11   IS
12   BEGIN
13 
14     htp.htmlOpen;
15     htp.linkRel('STYLESHEET', '/OA_HTML/US/POSSTYLE.css');
16 
17     htp.headOpen;
18     htp.headClose;
19     htp.bodyOpen(NULL, 'bgcolor=#336699');
20 
21     htp.p('
22       <table width=100% bgcolor=#336699 cellpadding=0 cellspacing=0 border=0>
23       <tr><td height=3><img src=/OA_MEDIA/FNDPX3.gif></td></tr>
24       <TR>
25       <TD align=right>');
26 
27     -- This is a button table containing 3 buttons.
28     -- The first row defines the edges and tops
29     htp.p('
30       <table cellpadding=0 cellspacing=0 border=0>
31       <tr>
32       <!-- left hand button, round left side and square right side-->
33       <td rowspan=5><img src=/OA_MEDIA/FNDBRNDL.gif></td>
34       <td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>
35       <td rowspan=5><img src=/OA_MEDIA/FNDBSQRR.gif></td>');
36 
37     htp.p('<!-- standard spacer between square button images-->
38            <td width=2 rowspan=5></td>');
39 
40     IF (p_button2Name is NOT NULL) THEN
41       htp.p('
42          <!-- middle button with squared ends on both left and right-->
43          <td rowspan=5><img src=/OA_MEDIA/FNDBSQRL.gif></td>
44          <td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>
45          <td rowspan=5><img src=/OA_MEDIA/FNDBSQRR.gif></td>
46          <!-- standard spacer between square button images-->
47          <td width=2 rowspan=5></td>');
48     ELSE
49       htp.p('
50          <!-- middle button with squared ends on both left and right-->
51          <td rowspan=5></td>
52          <td></td>
53          <td rowspan=5></td>
54          <!-- standard spacer between square button images-->
55          <td width=2 rowspan=5></td>');
56     END IF;
57 
58     htp.p('
59       <!-- right hand button, square left side and round right side-->
60       <td rowspan=5><img src=/OA_MEDIA/FNDBSQRL.gif></td>
61       <td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>
62       <td rowspan=5><img src=/OA_MEDIA/FNDBRNDR.gif></td>
63       <td width=10 rowspan=5></td>
64       </tr>
65       <tr>');
66 
67     htp.p('<!-- one cell of this type required for every button -->');
68     htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
69     IF (p_button2Name is NOT NULL) THEN
70       htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
71     ELSE
72       htp.p('<td></td>');
73     END IF;
74     htp.p('<td bgcolor=#ffffff><img src=/OA_MEDIA/FNDPX6.gif></td>');
75     htp.p('</tr>');
76     htp.p('<tr>');
77 
78     htp.p('<!-- Text and links for each button are listed here-->');
79     htp.p('<td bgcolor=#cccccc height=20 nowrap>');
80     htp.p('<a href="javascript:top.getTop().' || p_button1Function || ';">');
81     htp.p('<font class=button>');
82     htp.p('<SCRIPT>');
83     htp.p('document.write(window.top.getTop().FND_MESSAGES["' ||
84           p_button1Name || '"])');
85     htp.p('</SCRIPT></font></td>');
86 
87 
88     IF (p_button2Name is NOT NULL) THEN
89       htp.p('<td bgcolor=#cccccc height=20 nowrap>');
90       htp.p('<a href="javascript:top.getTop().' || p_button2Function || ';">');
91       htp.p('<font class=button>');
92       htp.p('<SCRIPT>');
93       htp.p('document.write(window.top.getTop().FND_MESSAGES["' ||
94              p_button2Name || '"])');
95       htp.p('</SCRIPT></font></td>');
96     ELSE
97       htp.p('<td></td>');
98     END IF;
99 
100     htp.p('<td bgcolor=#cccccc height=20 nowrap>');
101     htp.p('<a href="javascript:top.getTop().' || p_button3Function || ';">');
102     htp.p('<font class=button>');
103     htp.p('<SCRIPT>');
104     htp.p('document.write(window.top.getTop().FND_MESSAGES["' ||
105           p_button3Name || '"])');
106     htp.p('</SCRIPT></font></td>');
107 
108     htp.p('
109       </tr>
110       <tr>');
111 
112     htp.p('<!-- one cell of this type required for every button -->');
113     htp.p('<td bgcolor=#666666><img src=/OA_MEDIA/FNDPX3.gif></td>');
114     IF (p_button2Name is NOT NULL) THEN
115       htp.p('<td bgcolor=#666666><img src=/OA_MEDIA/FNDPX3.gif></td>');
116     ELSE
117       htp.p('<td></td>');
118     END IF;
119     htp.p('<td bgcolor=#666666><img src=/OA_MEDIA/FNDPX3.gif></td>');
120     htp.p('</tr>');
121 
122     htp.p('<tr>');
123     htp.p('<!-- one cell of this type required for every button -->');
124     htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
125     IF (p_button2Name is NOT NULL) THEN
126       htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
127     ELSE
128       htp.p('<td></td>');
129     END IF;
130     htp.p('<td bgcolor=#333333><img src=/OA_MEDIA/FNDPX3.gif></td>');
131     htp.p('</tr>');
132 
133     htp.p('</table>');
134 
135     htp.p('
136       </td>
137       </tr>
138       <TR><td height=30><img src=/OA_MEDIA/FNDPX3.gif></td></TR>
139       </table>
140       </body>
141       </html>
142       ');
143 
144   END Build_Buttons;
145 
146 
147 
148 FUNCTION item_halign(l_index in number) RETURN VARCHAR2 IS
149 BEGIN
150 
151    RETURN ' align=' ||
152            ak_query_pkg.g_items_table(l_index).horizontal_alignment;
153 
154 END item_halign;
155 
156 
157 FUNCTION item_lov(l_index in number) RETURN VARCHAR2 IS
158 BEGIN
159 
160   IF ((ak_query_pkg.g_items_table(l_index).lov_region_code IS NOT NULL) AND
161       (ak_query_pkg.g_items_table(l_index).lov_attribute_code IS NOT NULL))
162   THEN
163 
164     return '<A HREF="javascript:call_LOV('''||
165              item_code(l_index) || ''')"' ||
166              '><IMG SRC="/OA_MEDIA/FNDLSTOV.gif" BORDER=0 WIDTH=23 ' ||
167              'HEIGHT=21 border=no align=absmiddle></A>';
168   ELSE
169     return '';
170   END IF;
171 
172 END item_lov;
173 
174 
175 FUNCTION item_valign(l_index in number) RETURN VARCHAR2 IS
176 BEGIN
177 
178    RETURN ' valign=' ||
179           ak_query_pkg.g_items_table(l_index).vertical_alignment;
180 
181 END item_valign;
182 
183 FUNCTION item_name(l_index in number) RETURN VARCHAR2 IS
184 BEGIN
185 
186    RETURN ak_query_pkg.g_items_table(l_index).attribute_label_long;
187 
188 END item_name;
189 
190 FUNCTION item_code(l_index in number) RETURN VARCHAR2 IS
191 BEGIN
192 
193    RETURN ak_query_pkg.g_items_table(l_index).attribute_code;
194 
195 END item_code;
196 
197 FUNCTION item_style(l_index in number) RETURN VARCHAR2 IS
198 BEGIN
199 
200   RETURN ak_query_pkg.g_items_table(l_index).item_style;
201 
202 END item_style;
203 
204 FUNCTION item_displayed(l_index in number) RETURN BOOLEAN IS
205 BEGIN
206 
207   RETURN (ak_query_pkg.g_items_table(l_index).node_display_flag = 'Y');
208 
209 END item_displayed;
210 
211 FUNCTION item_updateable(l_index in number) RETURN BOOLEAN IS
212 BEGIN
213 
214  RETURN (ak_query_pkg.g_items_table(l_index).update_flag = 'Y');
215 
216 END item_updateable;
217 
218 FUNCTION item_maxlength (l_index in number) RETURN VARCHAR2 IS
219 BEGIN
220 
221   RETURN ' maxlength=' ||
222          to_char(ak_query_pkg.g_items_table(l_index).attribute_value_length);
223 
224 END item_maxlength;
225 
226 
227 FUNCTION item_size (l_index in number) RETURN VARCHAR2 IS
228 BEGIN
229 
230   RETURN ' size='  || to_char(ak_query_pkg.g_items_table(l_index).display_value_length);
231 
232 END item_size;
233 
234 FUNCTION set_session_info RETURN BOOLEAN is
235 BEGIN
236 
237   IF NOT icx_sec.validatesession THEN
238     RETURN FALSE;
239   END IF;
240 
241   POS_ASBN.g_org_id := icx_sec.getID(icx_sec.PV_ORG_ID);
242   POS_ASBN.g_language := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
243   POS_ASBN.g_script_name := owa_util.get_cgi_env('SCRIPT_NAME');
244   POS_ASBN.g_user_id := icx_sec.getID(icx_sec.PV_WEB_USER_ID);
245   POS_ASBN.g_session_id := icx_sec.getID(icx_sec.PV_SESSION_ID);
246   POS_ASBN.g_responsibility_id := icx_sec.getID(icx_sec.PV_RESPONSIBILITY_ID);
247 
248   fnd_client_info.set_org_context(g_org_id);
249 
250   RETURN TRUE;
251 
252 END set_session_info;
253 
254 
255 function get_result_value(p_index in number, p_col in number) return varchar2 is
256     sql_statement   VARCHAR2(300);
257     l_cursor       INTEGER;
258     l_execute      INTEGER;
259     l_result       VARCHAR2(2000);
260 BEGIN
261 
262   if ak_query_pkg.g_results_table.count = 0 then
263 	 return '';
264   end if;
265   if p_col = 1 then
266     return ak_query_pkg.g_results_table(p_index).value1;
267   elsif p_col = 2 then
268     return ak_query_pkg.g_results_table(p_index).value2;
269   elsif p_col = 3 then
270     return ak_query_pkg.g_results_table(p_index).value3;
271   elsif p_col = 4 then
272     return ak_query_pkg.g_results_table(p_index).value4;
273   elsif p_col = 5 then
274     return ak_query_pkg.g_results_table(p_index).value5;
275   elsif p_col = 6 then
276     return ak_query_pkg.g_results_table(p_index).value6;
277   elsif p_col = 7 then
278     return ak_query_pkg.g_results_table(p_index).value7;
279   elsif p_col = 8 then
280     return ak_query_pkg.g_results_table(p_index).value8;
281   elsif p_col = 9 then
282     return ak_query_pkg.g_results_table(p_index).value9;
283   elsif p_col = 10 then
284     return ak_query_pkg.g_results_table(p_index).value10;
285   elsif p_col = 11 then
286     return ak_query_pkg.g_results_table(p_index).value11;
287   elsif p_col = 12 then
288     return ak_query_pkg.g_results_table(p_index).value12;
289   elsif p_col = 13 then
290     return ak_query_pkg.g_results_table(p_index).value13;
291   elsif p_col = 14 then
292     return ak_query_pkg.g_results_table(p_index).value14;
293   elsif p_col = 15 then
294     return ak_query_pkg.g_results_table(p_index).value15;
295   elsif p_col = 16 then
296     return ak_query_pkg.g_results_table(p_index).value16;
297   elsif p_col = 17 then
298     return ak_query_pkg.g_results_table(p_index).value17;
299   elsif p_col = 18 then
300     return ak_query_pkg.g_results_table(p_index).value18;
301   elsif p_col = 19 then
302     return ak_query_pkg.g_results_table(p_index).value19;
303   elsif p_col = 20 then
304     return ak_query_pkg.g_results_table(p_index).value20;
305   elsif p_col = 21 then
306     return ak_query_pkg.g_results_table(p_index).value21;
307   elsif p_col = 22 then
308     return ak_query_pkg.g_results_table(p_index).value22;
309   elsif p_col = 23 then
310     return ak_query_pkg.g_results_table(p_index).value23;
311   elsif p_col = 24 then
312     return ak_query_pkg.g_results_table(p_index).value24;
313   elsif p_col = 25 then
314     return ak_query_pkg.g_results_table(p_index).value25;
315   elsif p_col = 26 then
316     return ak_query_pkg.g_results_table(p_index).value26;
317   elsif p_col = 27 then
318     return ak_query_pkg.g_results_table(p_index).value27;
319   elsif p_col = 28 then
320     return ak_query_pkg.g_results_table(p_index).value28;
321   elsif p_col = 29 then
322     return ak_query_pkg.g_results_table(p_index).value29;
323   elsif p_col = 30 then
324     return ak_query_pkg.g_results_table(p_index).value30;
325   end if;
326 
327 END get_result_value;
328 
329 PROCEDURE ASBN_Details IS
330 BEGIN
331 
332 	IF NOT set_session_info THEN
333 		RETURN;
334 	END IF;
335 
336 
337      htp.htmlOpen;
338      htp.linkRel('STYLESHEET', '/OA_HTML/US/POSSTYLE.css');
339 
340      htp.headOpen;
341 
342      htp.p('<script src="/OA_HTML/POSWUTIL.js"></script>');
343 
344      htp.p('<SCRIPT>
345            document.write("<title>" +
346            top.getTop().FND_MESSAGES["ICX_POS_ASBN_DETAILS"] + "</title>")
347            </SCRIPT>');
348 
349      js.scriptOpen;
350 
351      js.scriptClose;
352 
353      htp.headClose;
354 
355      htp.p('<frameset cols="3,*,3" border=0 framespacing=0>');
356 
357        -- blue border frame
358        htp.p('<frame src="/OA_HTML/US/POSBLBOR.htm"
359                      name=borderLeft
360                      marginwidth=0
361                      frameborder=no
362                      scrolling=no>');
363 
364 
365 	htp.p('<frameset rows = "50, 10, *, 8, 45" border=1>');
366 
367          -- title bar and logo
368          htp.p('<frame src="' || POS_ASBN.g_script_name || '/pos_upper_banner_sv.ModalWindowTitle?p_title=ICX_POS_ASBN_DETAILS"');
369          htp.p('       name=titlebar');
370          htp.p('       marginwidth=0');
371          htp.p('       marginheight=0');
372          htp.p('       scrolling=no>');
373 
374  	-- upper banner with the curved edge
375 	htp.p('<frame src="/OA_HTML/US/POSUPBAN.htm"' ||
376         '   name=upperbanner'||
377         '   marginwidth=0'   ||
378         '   marginheight=0'  ||
379         '   scrolling=no>');
380 
381 	htp.p('<frame src="' || POS_ASBN.g_script_name ||
382         '/POS_ASBN.EDIT_HEADER"' ||
383         '   name=header'     ||
384         '   marginwidth=0'   ||
385         '   marginheight=0'  ||
386         '   scrolling=auto>');
387 
388 	 -- lower banner with curved edge
389 	htp.p('<frame src="' || POS_ASBN.g_script_name ||
390         '/pos_lower_banner_sv.PaintLowerBanner"' ||
391         '   name=lowerbanner'||
392         '   marginwidth=0'   ||
393         '   marginheight=0'  ||
394         '   scrolling=no>');
395 
396          -- lower button frame
397 
398          htp.p('<frame src="' || POS_ASBN.g_script_name ||
399                '/POS_ASBN.BUILD_BUTTONS?p_button1Name=ICX_POS_BTN_OK&p_button1Function=ASBNSubmit(top)&p_button2Name=&p_button2Function=cancelShipmentDetails&p_button3Name=ICX_POS_BTN_CANCEL&p_button3Function=ASBNCancel(top)"');
400          htp.p('       name=controlregion');
401          htp.p('       marginwidth=0');
402          htp.p('       frameborder=no');
403          htp.p('       scrolling=no>');
404 
405 
406      htp.p('</frameset>');
407 
408        -- blue border frame
409        htp.p('<frame src="/OA_HTML/US/POSBLBOR.htm"
410                      name=borderRight
411                      marginwidth=0
412                      frameborder=no
413                      scrolling=no>');
414 
415      htp.p('</frameset>');
416 
417     htp.htmlClose;
418 
419 END ASBN_Details;
420 
421 PROCEDURE edit_header IS
422 BEGIN
423 
424   POS_ASBN.g_script_name := owa_util.get_cgi_env('SCRIPT_NAME');
425   htp.htmlOpen;
426   htp.headOpen;
427 
428   htp.linkRel('STYLESHEET', '/OA_HTML/US/POSSTYLE.css');
429 
430   js.scriptOpen;
431 
432   htp.p('
433 
434   function closeWindow(p)
435   {
436     if (p != "")
437     {
438       top.close();
439     }
440   }
441 
442   ');
443 
444 
445   js.scriptClose;
446 
447   htp.headClose;
448   htp.bodyOpen(null, 'onLoad="javascript:closeWindow(' || '''' ||
449                g_flag  || '''' || ')"' ||
450                ' bgcolor=#cccccc link=blue vlink=blue alink=#ff0000');
451 --  htp.bodyOpen(null,'bgcolor=#cccccc link=blue vlink=blue alink=#ff0000');
452 
453   htp.p('<form name="POS_ASBN_HEADER" action="' || POS_ASBN.g_script_name ||
454         '/POS_ASBN.UPDATE_HEADER" target="header" method=GET">');
455 
456   paint_edit_header;
457 
461   htp.htmlClose;
458   htp.p('</form>');
459 
460   htp.bodyClose;
462 
463 END edit_header;
464 
465 PROCEDURE Paint_Edit_Header IS
466   l_attribute_index  NUMBER;
467   l_result_index     NUMBER;
468   l_current_col      NUMBER;
469   l_current_row      NUMBER;
470   l_session_id NUMBER := icx_sec.getID(icx_sec.PV_SESSION_ID);
471   l_where_clause     VARCHAR2(2000) := 'SESSION_ID = ' || to_char(l_session_id);
472 BEGIN
473 
474    htp.p('<table width=100% cellpadding=0 cellspacing=0 border=0>');
475 
476    htp.p('<!-- This row contains the help text -->');
477    htp.p('<tr bgcolor=#cccccc>');
478    htp.p('<td valign=top>' ||
479          '<font class=helptext> ' ||
480          ' ' ||
481          '</font></td>');
482    htp.p('</tr>');
483    htp.p('</table>');
484 
485    ak_query_pkg.exec_query(p_parent_region_appl_id   =>  178,
486                           p_parent_region_code      =>  'POS_ASBN_HEADERS_R',
487                           p_where_clause            =>  l_where_clause,
488                           p_responsibility_id       =>  g_responsibility_id,
489                           p_user_id                 =>  g_user_id,
490                           p_return_parents          =>  'T',
491                           p_return_children         =>  'F');
492 
493    l_attribute_index := ak_query_pkg.g_items_table.FIRST;
494    l_result_index    := ak_query_pkg.g_results_table.FIRST;
495 
496    htp.p('<table width=100% cellpadding=0 cellspacing=0 border=0>');
497 
498    htp.p('<tr bgcolor=#cccccc>');
499 
500    l_current_col := 0;
501 
502    WHILE (l_attribute_index IS NOT NULL) LOOP
503 
504      l_current_col := l_current_col + 1;
505 
506     IF (item_style(l_attribute_index) = 'HIDDEN') THEN
507 
508        htp.p('<!-- ' || item_code(l_attribute_index) ||
509              ' - '   || item_style(l_attribute_index) || ' -->');
510 
511        htp.p('<input name="' || item_code(l_attribute_index) ||
512              '" type="HIDDEN" VALUE="' ||
513                get_result_value(l_result_index, l_current_col) ||
514              '">');
515     ELSIF item_displayed(l_attribute_index)  THEN
516         IF (item_style(l_attribute_index) = 'TEXT') THEN
517           IF item_updateable(l_attribute_index) THEN
518 
519               htp.p('<td bgcolor=#cccccc' ||
520                      item_halign(l_attribute_index) ||
521                      item_valign(l_attribute_index) ||
522                     '>' ||
523                     '<font class=promptblack>' ||
524                      item_name(l_attribute_index) ||
525                     '</font>' ||
526                     ' ' ||
527                     '</td>');
528 
529               htp.p('<td nowrap' ||
530                     ' align=LEFT' ||
531                     ' valign=CENTER' ||
532                     '>' ||
533                     '<font class=datablack>'||
534                     '<input type=text ' ||
535                     item_size(l_attribute_index) ||
536                     item_maxlength(l_attribute_index) ||
537                     ' name="' || item_code(l_attribute_index) || '"' ||
538                     ' value="' ||
539                     get_result_value(l_result_index, l_current_col) ||
540                     '" ></font>' ||
541                     item_lov(l_attribute_index) ||
542                     '</td>');
543 /*
544               htp.p('<td nowrap' ||
545                     ' align=LEFT' ||
546                     ' valign=CENTER' ||
547                     '>' ||
548                     '<B><font class=datablack>'||
549                     '<input type=text size=10 name="' ||
550                       item_code(l_attribute_index) || '"' ||
551                     ' value="' ||
552                      get_result_value(l_result_index, l_current_col) ||
553                     '" ></font></B></td>');
554 */
555             ELSE
556 
557              htp.p('<td bgcolor=#cccccc ' ||
558                     item_halign(l_attribute_index) ||
559                     item_valign(l_attribute_index) ||
560                    '>' ||
561                    '<font class=promptblack>' ||
562                     item_name(l_attribute_index) ||
563                    '</font>' ||
564                    ' ' ||
565                    '</td>');
566 
567              htp.p('<td ' ||
568                    ' align=LEFT' ||
569                    ' valign=CENTER' ||
570                    '>' ||
571                    '<B><font class=tabledata>' ||
572                    nvl(get_result_value(l_result_index, l_current_col), ' ') ||
573                    '</font></B></td>');
574 
575             END IF;
576         END IF;
577 
578       END IF;
579 
580     l_attribute_index := ak_query_pkg.g_items_table.NEXT(l_attribute_index);
581 
582 --    if ((l_current_col mod 2) = 0) THEN
583          htp.p('</tr>');
584          htp.p('<tr bgcolor=#cccccc>');
585 --    end if;
586 
587    END LOOP;
588 
589    htp.p('</tr>');
590    htp.p('</table>');
591 
592 END Paint_Edit_Header;
593 
594 PROCEDURE UPDATE_HEADER  ( pos_invoice_number     IN VARCHAR2 DEFAULT null,
595                            pos_invoice_date       IN VARCHAR2 DEFAULT null,
596 			   pos_freight_amount	  IN VARCHAR2 DEFAULT null
597 		         )
598 IS
599 l_invoice_date DATE;
600 l_date_format  VARCHAR2(100);
601 BEGIN
602 
603   IF NOT icx_sec.validatesession THEN
604     RETURN;
605   END IF;
606 
607   l_date_format := icx_sec.getID(icx_sec.PV_DATE_FORMAT);
608 
609   begin
610    l_invoice_date    := to_date(pos_invoice_date, l_date_format);
611       EXCEPTION
612         WHEN OTHERS THEN
613          null; /* need error reporting here */
614   end;
615 
616   update pos_asn_shop_cart_headers  set
617     invoice_num    = pos_invoice_number,
618     invoice_date   = l_invoice_date,
619     freight_amount = fnd_number.canonical_to_number(rtrim(ltrim(pos_freight_amount)))
620   where session_id = icx_sec.getID(icx_sec.PV_SESSION_ID);
621 
622   COMMIT;
623 
624 g_flag := 'Y';
625   edit_header;
626 
627 END update_header;
628 
629 END POS_ASBN;