DBA Data[Home] [Help]

PACKAGE BODY: APPS.PON_AUCTION_PKG

Source


1 PACKAGE BODY PON_AUCTION_PKG as
2 /* $Header: PONAUCTB.pls 120.125.12020000.4 2013/03/21 05:10:49 pamaniko ship $ */
3 
4 g_module_prefix         CONSTANT VARCHAR2(50) := 'pon.plsql.PON_AUCTION_PKG.';
5 g_userName    varchar2(2000);
6 g_phoneNumber varchar2(2000);
7 g_faxNumber   varchar2(2000);
8 g_eMail       varchar2(2000);
9 p_t_zone_temp varchar2(20) := '243';
10 g_module      varchar2(200) := 'pon.plsql.pon_auction_pkg';
11 g_original_language  FND_LANGUAGES.nls_language%TYPE;
12 g_original_lang_code FND_LANGUAGES.language_code%TYPE;
13 g_tp_cache_rec two_part_cache_rec; -- bug 6374353
14 
15 -------------------------------------------------------------------------------
16 --------------------------  HELPER FUNCTIONS ----------------------------------
17 -------------------------------------------------------------------------------
18 
19 PROCEDURE EMAIL_LIST(p_itemtype      IN  VARCHAR2,
20          p_itemkey      IN  VARCHAR2,
21             p_actid      IN  NUMBER,
22          p_notification_id    OUT NOCOPY NUMBER);
23 
24 PROCEDURE EMAIL_BIDDERS(p_itemtype      IN  VARCHAR2,
25            p_itemkey      IN  VARCHAR2,
26                p_actid        IN  NUMBER,
27            p_message_name      IN  VARCHAR2,
28            p_notification_id    OUT NOCOPY NUMBER);
29 
30 
31 PROCEDURE SET_PREVIEW_DATE(
32           p_itemtype      IN  VARCHAR2,
33            p_itemkey      IN  VARCHAR2,
34            p_preview_date  IN DATE,
35           p_publish_auction_now_flag IN VARCHAR2,
36           p_timezone_disp  IN VARCHAR2,
37           p_msg_suffix  IN VARCHAR2);
38 
39 PROCEDURE SET_OPEN_DATE(
40           p_itemtype      IN  VARCHAR2,
41            p_itemkey      IN  VARCHAR2,
42            p_auction_start_date  IN DATE,
43           p_open_auction_now_flag IN VARCHAR2,
44           p_timezone_disp  IN VARCHAR2,
45           p_msg_suffix  IN VARCHAR2);
46 
47 PROCEDURE SET_CLOSE_DATE(
48           p_itemtype      IN  VARCHAR2,
49            p_itemkey      IN  VARCHAR2,
50            p_auction_end_date  IN DATE,
51           p_timezone_disp  IN VARCHAR2);
52 
53 
54 PROCEDURE ADD_BIDDER_TO_ROLE(p_user_name  VARCHAR2,
55            p_role_name  VARCHAR2);
56 
57 
58 PROCEDURE LAUNCH_NOTIF_PROCESS(p_itemtype    in varchar2,
59              p_itemkey    in varchar2,
60              p_actid                  IN NUMBER,
61              p_process   IN VARCHAR2);
62 
63 FUNCTION IS_EVENT_AUCTION(p_auction_number IN NUMBER) RETURN VARCHAR2;
64 
65 FUNCTION getTokenMessage (msg VARCHAR2) RETURN VARCHAR2;
66 
67 PROCEDURE init_two_part_cache; -- bug 6374353
68 PROCEDURE update_cache_rec; -- bug 6374353
69 
70 PO_SUCCESS NUMBER := 1;
71 DUPLICATE_PO_NUMBER NUMBER := 2;
72 PO_SYSTEM_ERROR NUMBER := 3;
73 SOURCING_SYSTEM_ERROR NUMBER := 4;
74 
75 TYPE MsgTokensType IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER;
76 TYPE MsgTokenValuesType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;
77 
78 MsgTokens MsgTokensType;
79 MsgTokenValues MsgTokenValuesType;
80 
81 FUNCTION GET_USER_NAME (p_user_id NUMBER) RETURN VARCHAR2;
82 
83 FUNCTION MEMBER_USER(p_user_name VARCHAR2) RETURN BOOLEAN;
84 FUNCTION ADDITIONAL_BIDDER(p_user_name VARCHAR2, p_doc_id int, p_preparer_tp_contact_name varchar2,
85 x_profile_user IN OUT NOCOPY VARCHAR2) return BOOLEAN;
86 
87 FUNCTION differentStrings(st1 VARCHAR2, st2 VARCHAR2) return BOOLEAN;
88 
89 PROCEDURE NOTIFY_MEMBER(p_userPartyId           IN NUMBER,
90                         p_auctioneer_user_name  IN VARCHAR2,
91                         p_auction_start_date    IN DATE,
92                         p_auction_end_date      IN DATE,
93                         p_preview_date          IN DATE,
94                         p_msg_sent_date         IN DATE,
95                         p_msg_suffix            IN VARCHAR2,
96                         p_doc_number            IN VARCHAR2,
97                         p_auction_title         IN VARCHAR2,
98                         p_entryid               IN NUMBER,
99                         p_auction_header_id     IN NUMBER,
100                         p_fromFirstName         IN VARCHAR2,
101                         p_fromLastName          IN VARCHAR2,
102                         p_from_id               IN NUMBER,
103                         p_notif_performer       IN VARCHAR2,
104                         p_subject               IN VARCHAR2,
105                         p_message_type          IN VARCHAR2,
106                         p_fromCompanyName       IN VARCHAR2,
107                         p_discussion_id         IN NUMBER,
108                         p_stagger_closing_interval IN NUMBER,
109                         p_open_auction_now_flag IN VARCHAR2,
110                         p_publish_auction_now_flag IN VARCHAR2
111                         );
112 
113 -- Bug 8992789
114 FUNCTION IS_INTERNAL_ONLY(p_auction_header_id NUMBER) RETURN BOOLEAN;
115 
116 -- Bug 9309785
117 FUNCTION GET_SUPPLIER_REG_URL(p_supp_reg_id NUMBER) RETURN VARCHAR2;
118 
119 -- Bug 10075648
120 PROCEDURE UPDATE_SUPPLIER_REG_STATUS(p_supp_reg_id IN NUMBER);
121 
122 -------------------------------------------------------------------------------
123 --------------------------  PACKAGE BODY --------------------------------------
124 -------------------------------------------------------------------------------
125 -- FPK: CPA Function to check if negotiation has lines or not
126 FUNCTION NEG_HAS_LINES (p_auction_number IN NUMBER) RETURN VARCHAR2 AS
127       x_has_items_flag       VARCHAR2(1);
128 BEGIN
129      BEGIN
130          select has_items_flag
131          into x_has_items_flag
132          from pon_auction_headers_all
133          where auction_header_id = p_auction_number;
134      EXCEPTION
135        WHEN NO_DATA_FOUND THEN
136         x_has_items_flag := 'Y';
137      END;
138          return(x_has_items_flag);
139 END NEG_HAS_LINES;
140 
141 
142 PROCEDURE EMAIL_LIST(p_itemtype      IN  VARCHAR2,
143          p_itemkey      IN  VARCHAR2,
144             p_actid      IN  NUMBER,
145          p_notification_id    OUT NOCOPY  NUMBER) IS
146 
147 x_auction_header_id  NUMBER;
148 x_open_bidding_date  DATE;
149 x_close_bidding_date  DATE;
150 x_original_close_bidding_date DATE;
151 x_newpreviewtime     DATE;
152 x_progress     VARCHAR2(3);
153 x_sequence    NUMBER;
154 x_itemtype    VARCHAR2(8) := 'PONPBLSH';
155 x_itemkey    VARCHAR2(50);
156 x_user_name    VARCHAR2(100);
157 x_contact_id    NUMBER;
158 x_timezone    VARCHAR2(80);
159 x_timezone1    VARCHAR2(80);
160 x_newstarttime    DATE;
161 x_newendtime    DATE;
162 x_startdate    DATE;
163 x_enddate    DATE;
164 x_auction_type          Varchar2(30);
165 x_auction_type_name     Varchar2(30) := '';
166 x_auctioneer_tag        Varchar2(30);
167 x_event_id              NUMBER;
168 x_event_title           VARCHAR2(80);
169 x_language_code    VARCHAR2(3) := null;
170 x_auctioneer_user_name  FND_USER.USER_NAME%TYPE;
171 x_preview_message       VARCHAR2(100);
172 x_article_doc_type      VARCHAR2(100);
173 
174 x_doctype_group_name    VARCHAR2(100);
175 x_msg_suffix     VARCHAR2(3) := '';
176 x_doc_number_dsp   VARCHAR2(30);
177 x_auction_contact_id    NUMBER;
178 x_oex_timezone          VARCHAR2(80);
179 x_oex_timezone1          VARCHAR2(80);
180 
181 x_wf_role_name          VARCHAR2(30);
182 x_app                   VARCHAR2(20);
183 
184 x_oex_header            VARCHAR2(2000);
185 x_oex_footer            VARCHAR2(2000);
186 x_status                VARCHAR2(10);
187 x_exception_msg         VARCHAR2(100);
188 x_operation_url   VARCHAR2(300);
189 x_oex_operation    VARCHAR2(2000);
190 x_auction_owner_tp_name VARCHAR2(300);
191 x_tp_display_name  VARCHAR2(300);
192 x_tp_id      NUMBER;
193 x_auction_title    VARCHAR2(2000);
194 x_note_to_new_supplier_type  VARCHAR2(30);
195 x_appstr                VARCHAR2(20);
196 x_auction_creator_contact_id  NUMBER;
197 x_timezone_disp                VARCHAR2(240);
198 x_timezone1_disp               VARCHAR2(240);
199 x_oex_timezone1_disp           VARCHAR2(240);
200 x_registration_key             VARCHAR2(100);
201 x_neg_summary_url_supplier     VARCHAR2(2000);
202 x_net_changes_url_supplier     VARCHAR2(2000);
203 x_isp_supplier_register_url    VARCHAR2(2000);
204 x_ack_part_url_supplier        VARCHAR2(2000);
205 x_amendment_number             NUMBER;
206 x_isAmendment                  VARCHAR(1) := 'N';
207 x_auction_round_number                 NUMBER;
208 x_auction_header_id_encrypted  varchar2(2000);
209 x_auction_header_id_orig_amend NUMBER;
210 x_orig_document_number PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
211 x_preview_date        DATE;
212 x_preview_date_notspec VARCHAR2(240);
213 l_origin_user_name             FND_USER.USER_NAME%TYPE;
214 
215 x_staggered_closing_interval   NUMBER;
216 x_staggered_close_note         VARCHAR2(1000);
217 x_exempt_flag                  VARCHAR2(1);
218 
219 -- bug 8613271
220 x_supplier_sequence            NUMBER;
221 x_emd_received_flag         VARCHAR2(1) := 'N';
222 x_new_round_flag         VARCHAR2(1) := 'N';
223 x_new_amend_flag         VARCHAR2(1) := 'N';
224 x_refund_supplier_msg    VARCHAR2(2000);
225 
226 -- Bug 3824928: Removed obsolete columns from the SELECT below
227 CURSOR bidder_list IS
228     select pbp.trading_partner_name,
229      pbp.trading_partner_id,
230      pbp.trading_partner_contact_id,
231      pbp.trading_partner_contact_name,
232      pbp.additional_contact_email,
233      pbp.wf_user_name,
234            pbp.registration_id,
235            pbp.vendor_site_id,
236            decode(pbp.vendor_site_code, '-1', null, pbp.vendor_site_code) vendor_site_code,
237            pbp.requested_supplier_id,
238            pbp.requested_supplier_name,
239            pbp.requested_supplier_contact_id,
240            pbp.requested_supp_contact_name,
241            pcr.email_address rs_contact_email
242 -- lxchen
243     from pon_bidding_parties pbp,
244          pos_contact_requests pcr
245     where pbp.auction_header_id = x_auction_header_id and
246           pbp.requested_supplier_contact_id = pcr.contact_request_id (+)
247     union
248     select distinct trading_partner_name,
249            trading_partner_id,
250            trading_partner_contact_id,
251            pon_locale_pkg.get_party_display_name(trading_partner_contact_id) trading_partner_contact_name,
252            null additional_contact_email,
253            null wf_user_name,
254            to_number(null) registration_id,
255            vendor_site_id,
256            decode(vendor_site_code, '-1', null, vendor_site_code) vendor_site_code,
257            null requested_supplier_id,
258            null requested_supplier_name,
259            null requested_supplier_contact_id,
260            null requested_supp_contact_name,
261            null rs_contact_email
262      from  pon_bid_headers
263      where x_isAmendment = 'Y' and
264            auction_header_id in (select auction_header_id
265                                  from   pon_auction_headers_all
266                                  where  auction_header_id_orig_amend = (select auction_header_id_orig_amend
267                                                                         from   pon_auction_headers_all
268                                                                         where  auction_header_id = x_auction_header_id)) and
269            bid_status in ('ACTIVE', 'RESUBMISSION', 'DISQUALIFIED', 'DRAFT') and
270            trading_partner_contact_id NOT IN
271                        (SELECT nvl(trading_partner_contact_id, -1)
272                         FROM   pon_bidding_parties
273                         WHERE  auction_header_id = x_auction_header_id);
274 
275 
276 CURSOR c1_auction_type IS
277     select auction_header_id_orig_amend, nvl(amendment_number,0), nvl(auction_round_number, 1), auction_type,
278     event_id, event_title, trading_partner_id,
279     trading_partner_contact_id, original_close_bidding_date, trading_partner_contact_name,
280     staggered_closing_interval
281     from pon_auction_headers_all
282     where auction_header_id = x_auction_header_id;
283 
284 BEGIN
285 
286     x_progress := '010';
287 
288     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
289                                                         itemkey  => p_itemkey,
290                                                        aname    => 'AUCTION_ID');
291 
292 
293     -- Bug 8992789
294     IF (IS_INTERNAL_ONLY(x_auction_header_id)) THEN
295       RETURN;
296     END IF;
297 
298     l_origin_user_name := wf_engine.GetItemAttrText   (itemtype => p_itemtype,
299                                                         itemkey  => p_itemkey,
300                                                        aname    => 'ORIGIN_USER_NAME');
301 
302     x_auction_header_id_encrypted := wf_engine.GetItemAttrText (itemtype => p_itemtype,
303                                                          itemkey  => p_itemkey,
304                                                          aname    => 'AUCTION_ID_ENCRYPTED');
305 
306 --    x_auctioneer_user_name := wf_engine.GetItemAttrText (itemtype => p_itemtype,
307 --                                             itemkey  => p_itemkey,
308 --                                               aname    => 'PREPARER_TP_CONTACT_NAME');
309 
310     x_doctype_group_name := wf_engine.GetItemAttrText   (itemtype => p_itemtype,
311                                                          itemkey  => p_itemkey,
312                                                         aname    => 'DOC_INTERNAL_NAME');
313 
314     x_doc_number_dsp     := wf_engine.GetItemAttrText   (itemtype => p_itemtype,
315                                                          itemkey  => p_itemkey,
316                                                         aname    => 'DOC_NUMBER');
317 
318     x_preview_date := wf_engine.GetItemAttrDate (itemtype   => p_itemtype,
319                                                  itemkey    => p_itemkey,
320                                                  aname      => 'PREVIEW_DATE');
321 
322 
323     x_progress := '020';
324     open c1_auction_type;
325     fetch c1_auction_type
326     into x_auction_header_id_orig_amend,
327          x_amendment_number,
328          x_auction_round_number,
329          x_auction_type,
330          x_event_id,
331          x_event_title,
332    x_tp_id,
333    x_auction_creator_contact_id,
334          x_original_close_bidding_date,
335          x_auctioneer_user_name,
336          x_staggered_closing_interval;
337     close c1_auction_type;
338 
339     x_msg_suffix := GET_MESSAGE_SUFFIX (x_doctype_group_name);
340 
341     if (x_amendment_number > 0) then
342        x_isAmendment := 'Y';
343     end if;
344 
345     FOR bidder IN bidder_list LOOP
346 
347       --
348       -- Get next value in sequence for itemkey
349       --
350 
351       SELECT pon_auction_wf_publish_s.nextval
352       INTO   x_sequence
353       FROM   dual;
354 
355 
356       x_itemkey := (p_itemkey||'-'||to_char(x_sequence));
357 
358       wf_engine.CreateProcess(itemtype => x_itemtype,
359                             itemkey  => x_itemkey,
360                             process  => 'PUBLISH_MAIN');
361 
362       --
363       -- Set all the item attributes
364       --
365 
366       x_progress := '022';
367 
368 
369       wf_engine.SetItemAttrDate   (itemtype   => x_itemtype,
370                                    itemkey    => x_itemkey,
371                                    aname      => 'ORIGINAL_AUCTION_CLOSE_DATE',
372                                    avalue     => x_original_close_bidding_date);
373 
374       wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
375                                    itemkey    => x_itemkey,
376                                    aname      => 'AUCTION_ID',
377                                    avalue     => x_auction_header_id); /* using auction_id instead of
378                                                                          auction_number as a standard
379                                                                          across item types */
380 
381       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
382                                  itemkey    => x_itemkey,
383                                  aname      => 'DOC_NUMBER',
384                                  avalue     => x_doc_number_dsp);
385 
386       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
387                                  itemkey    => x_itemkey,
388                                  aname      => 'ORIGIN_USER_NAME',
389                                  avalue     => l_origin_user_name);
390 
391       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
392                                  itemkey    => x_itemkey,
393                                  aname      => 'NOTE_TO_BIDDERS',
394                                  avalue     => replaceHtmlChars(wf_engine.GetItemAttrText (itemtype => p_itemtype,
395                     itemkey  => p_itemkey,
396                     aname    => 'NOTE_TO_BIDDERS')));
397 
398       x_auction_title := wf_engine.GetItemAttrText(itemtype => p_itemtype,
399                                  itemkey  => p_itemkey,
400                                  aname    => 'AUCTION_TITLE');
401 
402       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
403                                  itemkey    => x_itemkey,
404                                  aname      => 'AUCTION_TITLE',
405                                  avalue     => replaceHtmlChars(x_auction_title));
406 
407       x_auction_owner_tp_name := wf_engine.GetItemAttrText(itemtype => p_itemtype,
408                                    itemkey  => p_itemkey,
409                                    aname    => 'PREPARER_TP_NAME');
410 
411       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
412                                  itemkey    => x_itemkey,
413                                  aname      => 'PREPARER_TP_NAME',
414                              avalue     => x_auction_owner_tp_name);
415 
416       wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
417                                    itemkey    => x_itemkey,
418                                    aname      => 'NUMBER_OF_ITEMS',
419                              avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
420                                                                  itemkey  => p_itemkey,
421                                                                 aname    => 'NUMBER_OF_ITEMS'));
422       wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
423                                    itemkey    => x_itemkey,
424                                    aname      => 'TRADING_PARTNER_ID',
425                              avalue     => bidder.trading_partner_id);
426 
427       wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
428                                    itemkey    => x_itemkey,
429                                    aname      => 'DOC_ROUND_NUMBER',
430                              avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
431                                                                   itemkey  => p_itemkey,
432                                                                  aname    => 'DOC_ROUND_NUMBER'));
433 
434 
435       wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
436                                    itemkey    => x_itemkey,
437                                    aname      => 'DOC_AMENDMENT_NUMBER',
438                                                    avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
439                                                                               itemkey  => p_itemkey,
440                                                                               aname    => 'DOC_AMENDMENT_NUMBER'));
441 
442       begin
443 
444         wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
445                                          itemkey    => x_itemkey,
446                                          aname      => '#WFM_HTMLAGENT',
447                                          avalue     => pon_wf_utl_pkg.get_base_external_supplier_url);
448       exception when others then
449         null;
450       end;
451 
452 
453       wf_engine.setItemAttrNumber  (itemtype =>  x_itemtype,
454                                     itemkey    => x_itemkey,
455                                     aname      => 'VENDOR_SITE_ID',
456                                     avalue     => bidder.vendor_site_id);
457 
458 
459      wf_engine.SetItemAttrText (itemtype  => x_itemtype,
460                              itemkey  => x_itemkey,
461                              aname  => 'PREPARER_TP_CONTACT_NAME',
462                              avalue  => x_auctioneer_user_name);
463 
464      BEGIN
465           x_staggered_close_note := NULL;
466           IF x_staggered_closing_interval IS NOT NULL THEN
467                x_staggered_close_note := wf_core.newline || wf_core.newline ||
468                                          getMessage('PON_STAGGERED_CLOSE_NOTIF_MSG') ||
469                                          wf_core.newline || wf_core.newline;
470           END IF;
471           wf_engine.SetItemAttrText( itemtype => x_itemtype,
472                                      itemkey  => x_itemkey,
473                                      aname    => 'STAGGERED_CLOSE_NOTE',
474                                      avalue   => x_staggered_close_note);
475                                                                                                                                                                EXCEPTION
476           WHEN OTHERS THEN
477                NULL;
478      END;
479 
480       begin
481         if (x_event_id is not null) then
482          wf_engine.SetItemAttrText (itemtype   => x_itemtype,
483                                     itemkey    => x_itemkey,
484                                     aname      => 'EVENT_TITLE',
485                               avalue     => replaceHtmlChars(wf_engine.GetItemAttrText (itemtype => p_itemtype,
486                                                                  itemkey  => p_itemkey,
487                                                                    aname    => 'EVENT_TITLE')));
488   end if;
489       exception
490    when others then
491     null;  -- if event title attr. does not exist in the workflow item then it is an older version
492       end;
493 
494        x_oex_timezone := Get_Oex_Time_Zone;
495 
496          --
497          -- Get the dates from the auction workflow
498          --
499 
500        x_startdate := wf_engine.GetItemAttrDate (itemtype => p_itemtype,
501                                                  itemkey  => p_itemkey,
502                                                  aname    => 'AUCTION_START_DATE');
503 
504        x_enddate   := wf_engine.GetItemAttrDate (itemtype => p_itemtype,
505                                                  itemkey  => p_itemkey,
506                                                  aname    => 'AUCTION_END_DATE');
507 
508 
509           x_progress := '030';
510 
511     -- Try and send the notification to the Auction Contact user for the company.
512     -- If no such person exists, then just send the noification to the Default
513     -- Admin for the company.  Every company should have a Default Admin relationship
514     -- and we do not allow users to invite companies that do not have a Defualt Admin
515     -- relationship.
516     -- FPH: bidder.trading_partner_contact_id should never be null and thus no need
517     -- for this if.
518 
519     x_auction_contact_id := bidder.trading_partner_contact_id;
520 
521      -- Bug 3824928: Contact id may be null.  Added IF below to prevent a
522      -- no data found error
523      IF x_auction_contact_id IS NOT NULL
524      THEN
525       BEGIN
526     select user_name,
527                  person_party_id
528     into x_user_name,
529                x_contact_id
530     from fnd_user
531           where person_party_id = x_auction_contact_id
532           and nvl(end_date, sysdate+1) > sysdate;
533       EXCEPTION
534        WHEN TOO_MANY_ROWS THEN
535           IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
536                IF (FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level) THEN
537                          FND_LOG.string(log_level => FND_LOG.level_unexpected,
538                                         module    => 'pon.plsql.pon_auction_pkg.email_list',
539                                         message   => 'Multiple Users found for person_party_id:'|| x_auction_contact_id);
540                END IF;
541          END IF;
542          select user_name,
543                 person_party_id
544           into x_user_name,
545                x_contact_id
546           from fnd_user
547           where person_party_id = x_auction_contact_id
548           and nvl(end_date, sysdate+1) > sysdate
549           and rownum=1;
550 
551       END;
552 
553 
554       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
555                          itemkey  => x_itemkey,
556                          aname  => 'BIDDER_TP_CONTACT_NAME',
557                          avalue  => x_user_name);
558 
559     -- Get the user's time zone
560     --
561     x_timezone := Get_Time_Zone(x_auction_contact_id);
562 
563     if (x_timezone is null or x_timezone = '') then
564     x_timezone := x_oex_timezone;
565     end if;
566 
567 
568     --
569       -- Convert the dates to the user's timezone.
570     -- If the timezone is not recognized, just use PST
571     --
572 
573     IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
574        x_newstarttime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_startdate,x_oex_timezone,x_timezone);
575        x_newendtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_enddate,x_oex_timezone,x_timezone);
576        x_newpreviewtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone);
577     ELSE
578        x_newstarttime := x_startdate;
579        x_newendtime := x_enddate;
580          x_newpreviewtime := x_preview_date;
581        x_timezone := x_oex_timezone;
582       END IF;
583 
584     PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(x_user_name,x_language_code);
585    ELSE -- auction_contact_id is null -- Bug 3824928: added this
586 
587              --
588              -- Get the auctioneer's time zone
589              --
590              x_timezone := Get_Time_Zone(x_auctioneer_user_name);
591 
592              if (x_timezone is null or x_timezone = '') then
593                    x_timezone := x_oex_timezone;
594              end if;
595 
596 
597              --
598              -- Convert the dates to the auctioneer's timezone.
599              -- If the timezone is not recognized, just use PST
600              --
601 
602              IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
603 
604                 x_newstarttime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_startdate,x_oex_timezone,x_timezone);
605                 x_newendtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_enddate,x_oex_timezone,x_timezone);
606                 x_newpreviewtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone);
607              ELSE
608 
609                 x_newstarttime := x_startdate;
610                 x_newendtime := x_enddate;
611                 x_newpreviewtime := x_preview_date;
612                 x_timezone := x_oex_timezone;
613             END IF;
614          -- Get the auctioneer's language
615             PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(x_auctioneer_user_name,x_language_code);
616 
617         -- add requested supplier info if specified
618         if (bidder.requested_supplier_contact_id is not null) then --{
619         wf_engine.SetItemAttrText (itemtype => x_itemtype,
620                                    itemkey  => x_itemkey,
621                                    aname    => 'REQ_SUPPLIER_CONTACT_NAME',
622                                    avalue   => bidder.requested_supp_contact_NAME);
623 
624           wf_engine.SetItemAttrNumber (itemtype => x_itemtype,
625                                      itemkey  => x_itemkey,
626                                      aname    => 'REQ_SUPPLIER_CONTACT_ID',
627                                      avalue   => bidder.requested_supplier_contact_id);
628 
629           wf_engine.SetItemAttrText (itemtype => x_itemtype,
630                                    itemkey  => x_itemkey,
631                                    aname    => 'BIDDER_TP_CONTACT_NAME',
632                                    avalue   => bidder.requested_supp_contact_name);
633 
634       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
635                                      itemkey    => x_itemkey,
636                                      aname      => 'REQ_SUPPLIER_USERNAME',
637                                      avalue   => bidder.wf_user_name); --(performer)
638 
639         end if; --} bidder.requested_supplier_contact_id is not null
640 
641       END IF; -- IF x_auction_contact_id IS NOT NULL
642 
643 
644     --
645      --Set the dates based on the user's time zone or auctioneer's time zone if bidder contact id is null
646     --
647 
648      x_timezone_disp := Get_TimeZone_Description(x_timezone, x_language_code);
649 
650 
651     wf_engine.SetItemAttrText (itemtype  => x_itemtype,
652                          itemkey  => x_itemkey,
653                          aname  => 'TP_TIME_ZONE',
654                          avalue  => x_timezone_disp);
655 
656           IF (x_preview_date IS NULL) THEN
657              x_timezone1_disp := null;
658           ELSE
659             x_timezone1_disp := x_timezone_disp;
660           END IF;
661 
662  -- Bug 4304399: Set the values of AUCTION_START_DATE and AUCTION_END_DATE
663  -- as the end_date is used to determine the timeout for the notifications
664  -- sent to the supplier
665           wf_engine.SetItemAttrDate     (itemtype   => x_itemtype,
666                                      itemkey    => x_itemkey,
667                                    aname      => 'AUCTION_START_DATE',
668                                    avalue     => x_startdate);
669 
670           wf_engine.SetItemAttrDate     (itemtype   => x_itemtype,
671                                      itemkey    => x_itemkey,
672                                    aname      => 'AUCTION_END_DATE',
673                                    avalue     => x_enddate);
674 
675           wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
676                                      itemkey    => x_itemkey,
677                                    aname      => 'AUCTION_START_DATE_TZ',
678                                    avalue     => x_newstarttime);
679 
680 
681           wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
682                                      itemkey    => x_itemkey,
683                                    aname      => 'AUCTION_END_DATE_TZ',
684                                    avalue     => x_newendtime);
685 
686           --
687           -- Set the Languague code base on the user's language or auctioneer's language if bidder contact id is null
688         --
689 
690     wf_engine.SetItemAttrText (itemtype  => x_itemtype,
691              itemkey  => x_itemkey,
692              aname  => 'TP_LANGUAGE_CODE',
693              avalue  => x_language_code);
694 
695           -- Set the userenv language so the message token (attribute) values that we retrieve using the
696           -- getMessage call return the message in the correct language => x_language_code
697      IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
698        FND_LOG.string(log_level => FND_LOG.level_statement,
699           module => g_module_prefix || 'EMAIL_LIST',
700           message  => '1. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
701      END IF; --}
702 
703 	  SET_SESSION_LANGUAGE(null, x_language_code);
704 
705       --Bug 6472383 : Shifted the setting of preview date to this place so that the recipient's language, instead
706       --of the sender's language is taken into account when setting the preview date to 'Not Specified'
707 
708       IF (x_newpreviewtime is not null) THEN
709             wf_engine.SetItemAttrDate (itemtype    => x_itemtype,
710                                                        itemkey        => x_itemkey,
711                                                        aname        => 'PREVIEW_DATE_TZ',
712                                                        avalue        => x_newpreviewtime);
713 
714             wf_engine.SetItemAttrText (itemtype    => x_itemtype,
715                                                        itemkey        => x_itemkey,
716                                                        aname        => 'TP_TIME_ZONE1',
717                                                        avalue        => x_timezone1_disp);
718 
719             wf_engine.SetItemAttrText (itemtype    => x_itemtype,
720                                                       itemkey        => x_itemkey,
721                                                       aname        => 'PREVIEW_DATE_NOTSPECIFIED',
722                                                       avalue        => null);
723       ELSE
724             wf_engine.SetItemAttrDate (itemtype    => x_itemtype,
725                                                        itemkey        => x_itemkey,
726                                                        aname        => 'PREVIEW_DATE_TZ',
727                                                        avalue        => null);
728 
729             wf_engine.SetItemAttrText (itemtype    => x_itemtype,
730                                                         itemkey        => x_itemkey,
731                                                        aname        => 'TP_TIME_ZONE1',
732                                                         avalue        => x_timezone1_disp);
733 
734            wf_engine.SetItemAttrText (itemtype     => x_itemtype,
735                                                       itemkey        => x_itemkey,
736                                                       aname        => 'PREVIEW_DATE_NOTSPECIFIED',
737                                                       avalue        => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
738       END IF;
739 
740       --Bug 6268467 : Shifted the operation of setting of the attribute NET_CHANGES_URL to this place (i.e. after call to SET_SESSION_LANGUAGE) so that the
741       --logged in user will be able to login to the application in the language that is set in his preferences.
742       if (x_amendment_number > 0) then
743          -- call to notification utility package to get the redirect page url that
744          -- is responsible for getting the Net Changes page url and forward to it.
745          x_net_changes_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
746 		                          p_dest_func => 'PONINQ_VIEW_NET_CHNG'
747                                  ,p_notif_performer  => 'SUPPLIER');
748       elsif (x_auction_round_number > 1 and x_amendment_number = 0) then
749          -- call to notification utility package to get the redirect page url that
750          -- is responsible for getting the Round Modifications page url and forward to it.
751          x_net_changes_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
752 		                          p_dest_func => 'PONINQ_NEW_ROUND_SUM'
753                                  ,p_notif_performer  => 'SUPPLIER');
754       end if;
755 
756       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
757                                  itemkey    => x_itemkey,
758                                  aname      => 'NET_CHANGES_URL',
759                                  avalue     => x_net_changes_url_supplier);
760 
761       --Bug 6268467 : Shifted the operation of setting of the attribute NEG_SUMMARY_URL to this place (i.e. after call to SET_SESSION_LANGUAGE) so that the
762       --logged in user will be able to login to the application in the language that is set in his preferences.
763 
764        -- call to notification utility package to get the redirect page url that
765        -- is responsible for getting the Negotiation Summary url and forward to it.
766        x_neg_summary_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
767 		                          p_dest_func => 'PON_NEG_SUMMARY'
768                                  ,p_notif_performer  => 'SUPPLIER');
769 
770 
771       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
772                                  itemkey    => x_itemkey,
773                                  aname      => 'NEG_SUMMARY_URL',
774                                  avalue     => x_neg_summary_url_supplier);
775 
776       --Bug 6268467 : Shifted the operation of setting of the attribute ACK_PARTICIPATION_URL to this place (i.e. after call to SET_SESSION_LANGUAGE) so that the
777       --logged in user will be able to login to the application in the language that is set in his preferences.
778 
779        -- call to notification utility package to get the redirect page url that
780        -- is responsible for getting the Acknowledge participation url and forward to it.
781        x_ack_part_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
782 		                          p_dest_func => 'PONRESAPN_ACKPARTICIPATN'
783                                  ,p_notif_performer  => 'SUPPLIER');
784 
785        wf_engine.SetItemAttrText (itemtype   => x_itemtype,
786                                  itemkey    => x_itemkey,
787                                  aname      => 'ACK_PARTICIPATION_URL',
788                                  avalue     => x_ack_part_url_supplier);
789 
790 
791       x_tp_display_name := nvl(bidder.trading_partner_name, bidder.requested_supplier_name);
792 
793       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
794         itemkey  => x_itemkey,
795         aname   => 'TP_DISPLAY_NAME',
796         avalue  => x_tp_display_name);
797 
798       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
799                                         itemkey    => x_itemkey,
800                                         aname      => 'BIDDER_TP_NAME',
801                                         avalue     => x_tp_display_name);
802 
803       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
804         itemkey  => x_itemkey,
805         aname      => 'BIDDER_TP_ADDRESS_NAME',
806         avalue     => bidder.vendor_site_code);
807 
808 
809       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
810                                itemkey    => x_itemkey,
811                                aname      => 'DOC_INTERNAL_NAME',
812                                avalue     => x_doctype_group_name);
813 
814 
815       -- New messages for complete customization
816 
817       select document_number
818       into   x_orig_document_number
819       from   pon_auction_headers_all
820       where  auction_header_id = x_auction_header_id_orig_amend;
821 
822 
823       wf_engine.SetItemAttrText (itemtype       => x_itemtype,
824                                  itemkey        => x_itemkey,
825                                  aname          => 'AMENDMENT_START_SUB',
826                                  avalue         => getMessage('PON_AUC_WF_PUB_AMEND_RG_S', x_msg_suffix,
827                                                                       'AMENDMENT_NUMBER', x_amendment_number,
828                                                                       'ORIG_NUMBER', x_orig_document_number,
829                                           'AUCTION_TITLE', replaceHtmlChars(x_auction_title)));
830 
831 
832       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
833          itemkey  => x_itemkey,
834          aname    => 'INVITE_NEW_ROUND_START_SUB',
835          avalue    => getMessage('PON_AUC_WF_PUB_NEWRND_RG_S', x_msg_suffix,
836                             'DOC_NUMBER', x_doc_number_dsp,
837                                           'AUCTION_TITLE', replaceHtmlChars(x_auction_title)));
838 
839       -- Begin Bug 9309785
840       -- Use a different subject for Supplier Hub
841       IF (fnd_profile.value('POS_SM_ENABLE_SPM_EXTENSION') = 'Y' AND bidder.requested_supplier_id IS NOT NULL) THEN
842         wf_engine.SetItemAttrText (itemtype       => x_itemtype,
843                                    itemkey        => x_itemkey,
844                                    aname          => 'INVITE_RESPONSE_SUB',
845                                    avalue         => getMessage('PON_SM_AUC_WF_PUB_OPEN_RG_S'));
846 
847         wf_engine.SetItemAttrText (itemtype       => x_itemtype,
848                                    itemkey        => x_itemkey,
849                                    aname          => 'ISP_NEW_SUPPLIER_REG_URL',
850                                    avalue         => get_supplier_reg_url(bidder.requested_supplier_id));
851 
852         -- Begin Supplier Management: Bug 10378806 / 11071755
853         -- RFI amendment / new round e-mail for prospective supplier
854         wf_engine.SetItemAttrText (itemtype       => x_itemtype,
855                                    itemkey        => x_itemkey,
856                                    aname          => 'REQ_SUPP_AMEND_START_SUB',
857                                    avalue         => getMessage('PON_SM_REQ_SUPP_AMEND_S'));
858 
859         wf_engine.SetItemAttrText (itemtype       => x_itemtype,
860                                    itemkey        => x_itemkey,
861                                    aname          => 'INV_REQ_SUPP_NEWRND_SUB',
862                                    avalue         => getMessage('PON_SM_INV_REQ_SUPP_NEWRND_S'));
863         -- End Supplier Management: Bug 10378806 / 11071755
864 
865         -- Bug 10075648
866         -- Update supplier registration status to 'Supplier to Provide Details' when sending notification.
867         update_supplier_reg_status(bidder.requested_supplier_id);
868       ELSE
869         wf_engine.SetItemAttrText (itemtype       => x_itemtype,
870                                    itemkey        => x_itemkey,
871                                    aname          => 'INVITE_RESPONSE_SUB',
872                                    avalue         => getMessage('PON_AUC_WF_PUB_OPEN_RG_S', x_msg_suffix,
873                                                                 'DOC_NUMBER', x_doc_number_dsp,
874                                                                 'AUCTION_TITLE', replaceHtmlChars(x_auction_title)));
875       END IF;
876       -- End Bug 9309785
877 
878 
879       --
880       -- Start the publish notification
881       --
882 
883       -- IF (bidder.additional_contact_email is not null) then we need to send a notification
884       -- to the additional contact as well
885       -- Populate the ADDITIONAL_CONTACT_USERNAME attribute so that a notification is sent to this local
886       -- use as well
887       -- In FPH, we provide a registration link to the additional contact.
888 
889       if (bidder.additional_contact_email is not null) then
890 
891         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
892                                     itemkey    => x_itemkey,
893                                     aname      => 'ADDITIONAL_CONTACT_USERNAME',
894                            avalue    => bidder.wf_user_name);
895 
896 
897               begin
898                 select registration_key
899                   into x_registration_key
900                   from fnd_registrations
901                  where registration_id  = bidder.registration_id;
902               exception
903                   WHEN NO_DATA_FOUND THEN
904                        x_registration_key := '';
905               end;
906 
907            -- call to notification utility package to get the iSupplier registration page url
908            x_isp_supplier_register_url := pon_wf_utl_pkg.get_isp_supplier_register_url(p_registration_key => x_registration_key
909                                                                                       ,p_language_code => x_language_code);
910 
911            wf_engine.SetItemAttrText (itemtype   => x_itemtype,
912                                       itemkey    => x_itemkey,
913                                       aname      => 'ISP_SUPPLIER_REG_URL',
914                                       avalue     => x_isp_supplier_register_url);
915 
916       end if;
917       --choli for SUPPLIER_EXEMPTED_INFO
918  BEGIN
919    select exempt_flag
920      into x_exempt_flag
921      from pon_bidding_parties b
922     where auction_header_id = x_auction_header_id
923       and trading_partner_id = bidder.trading_partner_id
924       and rownum = 1;
925  EXCEPTION
926    WHEN NO_DATA_FOUND THEN
927      x_exempt_flag := 'N';
928    WHEN OTHERS THEN
929      x_exempt_flag := 'N';
930  END;
931  IF(x_exempt_flag = 'Y') THEN
932  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
933                                  itemkey    => x_itemkey,
934                                  aname      => 'SUPPLIER_EXEMPTED_INFO',
935                                  avalue     => 'You are exempted from paying the EMD/Bank Guarantee for this Negotiation');
936 ELSE
937  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
938                                  itemkey    => x_itemkey,
939                                  aname      => 'SUPPLIER_EXEMPTED_INFO',
940                                  avalue     => ' ');
941 END IF;
942 
943     /*
944     * Added below code for bug 8613271
945     * When a new round or amendment is created,
946     * notification sent to suppliers should include message
947     * that EMD paid earlier will be refunded.
948     */
949     BEGIN
950 
951     -- determine whether new round or new amendment.
952     SELECT Decode(Nvl(auction_header_id_prev_round,0),0,'N','Y'),
953            Decode(Nvl(auction_header_id_prev_amend,0),0,'N','Y')
954     INTO x_new_round_flag, x_new_amend_flag
955     FROM pon_auction_headers_all
956     WHERE auction_header_id = x_auction_header_id;
957 
958     IF(x_new_round_flag = 'Y') THEN
959       x_refund_supplier_msg :=  getMessage('PON_EMD_REFUND_SUP_NEW_RND');
960     ELSIF(x_new_amend_flag = 'Y') THEN
961       x_refund_supplier_msg :=  getMessage('PON_EMD_REFUND_SUP_NEW_AMEND');
962     END IF;
963 
964     SELECT sequence INTO x_supplier_sequence FROM pon_bidding_parties
965     WHERE auction_header_id = (SELECT Decode(Nvl(auction_header_id_prev_round,0),0,Nvl(auction_header_id_prev_amend,0),auction_header_id_prev_round)
966     FROM pon_auction_headers_all
967     WHERE auction_header_id = x_auction_header_id)
968     --x_auction_header_id_orig_amend
969     AND TRADING_PARTNER_ID = bidder.trading_partner_id
970     AND vendor_site_id = bidder.vendor_site_id;
971 
972 
973     SELECT 'Y' INTO x_emd_received_flag FROM pon_emd_transactions
974     WHERE auction_header_id = (SELECT Decode(Nvl(auction_header_id_prev_round,0),0,Nvl(auction_header_id_prev_amend,0),auction_header_id_prev_round)
975     FROM pon_auction_headers_all
976     WHERE auction_header_id = x_auction_header_id)
977     AND SUPPLIER_SEQUENCE = x_supplier_sequence
978      AND STATUS_LOOKUP_CODE = 'RECEIVED';
979 
980     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
981                                  itemkey    => x_itemkey,
982                                  aname      => 'REFUND_SUPPLIER',
983                                  avalue     => x_refund_supplier_msg);
984     EXCEPTION
985     WHEN OTHERS THEN
986       NULL;
987     END;
988     -- end of change for bug 8613271
989 
990         --Bug 8446265 Modifications
991     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
992                                itemkey    => x_itemkey,
993                                aname      => 'PON_AMENDMENT_START_BODY',
994                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_AUC_AMEND_BODY/'||x_itemtype ||':' ||x_itemkey
995                                );
996 
997     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
998                                itemkey    => x_itemkey,
999                                aname      => 'PON_INV_NEW_RND_START_BODY',
1000                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INV_NEWRND_START_BODY/'||x_itemtype ||':' ||x_itemkey
1001                                );
1002 
1003 
1004     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1005                                itemkey    => x_itemkey,
1006                                aname      => 'PON_INV_NEW_RND_START_AD_BODY',
1007                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INV_NEWRND_START_AD_BODY/'||x_itemtype ||':' ||x_itemkey
1008                                );
1009 
1010 
1011     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1012                                itemkey    => x_itemkey,
1013                                aname      => 'PON_INVITE_REQ_SUPP_RESP_BODY',
1014                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INVITE_REQ_SUPP_RESP_BODY/'||x_itemtype ||':' ||x_itemkey
1015                                );
1016 
1017 
1018     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1019                                itemkey    => x_itemkey,
1020                                aname      => 'PON_INVITE_RESPONSE_BODY',
1021                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INVITE_CONT_RESP_BODY/'||x_itemtype ||':' ||x_itemkey
1022                                );
1023 
1024 
1025     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1026                                itemkey    => x_itemkey,
1027                                aname      => 'PON_INV_RESP_ADD_CONT_BODY',
1028                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INVITE_ADD_CONT_RESP_BODY/'||x_itemtype ||':' ||x_itemkey
1029                                );
1030     --Bug 8446265 Modifications
1031 
1032     -- Begin Supplier Management: Bug 10378806 / 11071755
1033     -- RFI amendment / new round e-mail for prospective supplier
1034     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1035                                itemkey    => x_itemkey,
1036                                aname      => 'PON_REQ_SUPP_AMEND_START_BODY',
1037                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_REQ_SUPP_AUC_AMEND_BODY/'||x_itemtype ||':' ||x_itemkey
1038                                );
1039 
1040     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1041                                itemkey    => x_itemkey,
1042                                aname      => 'PON_INV_REQ_SUPP_NEWRND_BODY',
1043                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INV_REQ_SUPP_NEWRND_BODY/'||x_itemtype ||':' ||x_itemkey
1044                                );
1045     -- End Supplier Management: Bug 10378806 / 11071755
1046 
1047     -- Bug 4295915: Set the  workflow owner
1048       wf_engine.SetItemOwner(itemtype => x_itemtype,
1049                              itemkey  => x_itemkey,
1050                              owner    => fnd_global.user_name);
1051 
1052       wf_engine.StartProcess(itemtype => x_itemtype,
1053                              itemkey  => x_itemkey );
1054 
1055       update pon_bidding_parties
1056          set wf_item_key = x_itemkey
1057       where  auction_header_id = x_auction_header_id and
1058              ((trading_partner_id = bidder.trading_partner_id and
1059                vendor_site_id = bidder.vendor_site_id) or
1060                requested_supplier_id = bidder.requested_supplier_id);
1061 
1062    END LOOP;
1063 
1064    UNSET_SESSION_LANGUAGE;
1065 
1066 END;
1067 
1068 -- choli update for emd
1069 PROCEDURE NotifyEmdAdminNegCancel(p_auction_header_id           NUMBER,    --  2
1070                 p_emd_admin_name         VARCHAR2,  --  3
1071                 p_auction_tp_name            VARCHAR2,  --  4
1072                 p_auction_title               VARCHAR2,  --  5
1073                 x_doc_number_dsp    VARCHAR2,
1074                 x_cancel_date       DATE,
1075                 x_cancel_reason    VARCHAR2,
1076                 x_event_title      VARCHAR2,
1077                 x_start_date       DATE) IS
1078 
1079 
1080 
1081 x_number_awarded  NUMBER;
1082 x_number_rejected  NUMBER;
1083 x_sequence  NUMBER;
1084 x_itemtype  VARCHAR2(8) := 'PONAUCT';
1085 x_itemkey  VARCHAR2(50);
1086 x_bid_list  VARCHAR2(1);
1087 x_progress  VARCHAR2(3);
1088 x_bid_contact_tp_dp_name varchar2(240);
1089 x_auction_type varchar2(30);
1090 x_auction_type_name varchar2(30) := '';
1091 
1092 x_event_id          NUMBER;
1093 x_auction_open_bidding_date DATE;
1094 x_auction_close_bidding_date DATE;
1095 x_language_code VARCHAR2(3) := null;
1096 x_timezone  VARCHAR2(80);
1097 x_newstarttime  DATE;
1098 x_newendtime  DATE;
1099 x_newawardtime  DATE;
1100 x_doctype_group_name   VARCHAR2(60);
1101 x_msg_suffix     VARCHAR2(3) := '';
1102 
1103 x_auction_round_number    NUMBER;
1104 x_doctype_id_value    NUMBER;
1105 x_oex_timezone VARCHAR2(80);
1106 x_bidder_contact_id   NUMBER;
1107 x_timezone_disp VARCHAR2(240);
1108 x_bid           VARCHAR2(10);
1109 x_bid_caps      VARCHAR2(10);
1110 x_note_to_supplier PON_BID_HEADERS.NOTE_TO_SUPPLIER%TYPE;
1111 x_view_quote_url_supplier VARCHAR2(2000);
1112 x_award_date PON_AUCTION_HEADERS_ALL.AWARD_DATE%TYPE;
1113 x_trading_partner_contact_name PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_NAME%TYPE;
1114 x_tp_display_name PON_BID_HEADERS.TRADING_PARTNER_NAME%TYPE;
1115 x_tp_address_name PON_BID_HEADERS.VENDOR_SITE_CODE%TYPE;
1116 x_preview_date             DATE;
1117 x_preview_date_in_tz             DATE;
1118 x_timezone1_disp                VARCHAR2(240);
1119 x_has_items_flag                PON_AUCTION_HEADERS_ALL.HAS_ITEMS_FLAG%TYPE;
1120 x_staggered_closing_interval    NUMBER;
1121 x_staggered_close_note          VARCHAR2(1000);
1122 x_bid_award_status PON_BID_HEADERS.AWARD_STATUS%TYPE;
1123 
1124 
1125 
1126 BEGIN
1127 
1128     IF ( fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) THEN
1129         fnd_log.string(log_level => fnd_log.level_unexpected
1130                       ,module    => 'pon_auction_pkg.NotifyEmdAdminNegCancel'
1131                       ,message   => 'Start calling NotifyEmdAdminNegCancel');
1132       END IF;
1133     x_progress := '010';
1134 
1135     --
1136     -- Get the bidder's language code so that the c1_bid_info
1137     -- has right value for x_language_code
1138     --
1139     IF p_emd_admin_name is not null THEN
1140        PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(p_emd_admin_name,x_language_code);
1141     END IF;
1142 
1143     -- Set the userenv language so the message token (attribute) values that we retrieve using the
1144     -- getMessage call return the message in the correct language => x_language_code
1145 
1146 
1147     pon_auction_pkg.SET_SESSION_LANGUAGE(null, x_language_code);
1148 
1149     --
1150     -- Get next value in sequence for itemkey
1151     --
1152 
1153     SELECT pon_auction_wf_acbid_s.nextval
1154     INTO   x_sequence
1155     FROM   dual;
1156 
1157     --
1158     -- get the contact name and auction type
1159     --
1160 
1161 
1162     x_progress := '020';
1163 
1164 
1165 
1166     x_itemkey := (to_char(p_emd_admin_name)||'-'||to_char(x_sequence));
1167 
1168     x_progress := '022';
1169 
1170     --
1171     -- Create the wf process
1172     --
1173 
1174     wf_engine.CreateProcess(itemtype => x_itemtype,
1175                             itemkey  => x_itemkey,
1176                             process  => 'NOTIFY_EMD_NOG_CANCEL');
1177 
1178     --
1179     -- Set all the item attributes
1180     --
1181     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1182                                  itemkey    => x_itemkey,
1183                                  aname      => 'AUCTION_ID',
1184                                  avalue     => p_auction_header_id);
1185     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1186                                  itemkey    => x_itemkey,
1187                                  aname      => 'AUCTION_NUMBER',
1188                                  avalue     => p_auction_header_id);
1189 	      /* Setting the Company header attribute */
1190     wf_engine.SetItemAttrText(itemtype   => x_itemtype
1191                              ,itemkey    => x_itemkey
1192                              ,aname      => 'AUCTION_TP_NAME'
1193 	                         ,avalue     => p_auction_tp_name);
1194     wf_engine.SetItemAttrDate(itemtype   => x_itemtype
1195                              ,itemkey    => x_itemkey
1196                              ,aname      => 'AUCTION_END_DATE'
1197 	                         ,avalue     => x_cancel_date);
1198     wf_engine.SetItemAttrText(itemtype   => x_itemtype
1199                              ,itemkey    => x_itemkey
1200                              ,aname      => 'CANCEL_REASON'
1201 	                         ,avalue     => x_cancel_reason);
1202     wf_engine.SetItemAttrText(itemtype   => x_itemtype
1203                              ,itemkey    => x_itemkey
1204                              ,aname      => 'EVENT_TITLE'
1205 	                         ,avalue     => x_event_title);
1206     wf_engine.SetItemAttrDate(itemtype   => x_itemtype
1207                              ,itemkey    => x_itemkey
1208                              ,aname      => 'AUCTION_START_DATE'
1209 	                         ,avalue     => x_start_date);
1210               /* Setting the negotiation title header attribute */
1211     wf_engine.SetItemAttrText(itemtype   => x_itemtype
1212 	                         ,itemkey    => x_itemkey
1213                              ,aname      => 'AUCTION_TITLE'
1214                              ,avalue     =>  pon_auction_pkg.replaceHtmlChars(p_auction_title));
1215     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1216                                itemkey    => x_itemkey,
1217                                aname      => 'AUCTION_TYPE_NAME',
1218                                avalue     => x_auction_type_name);
1219 
1220     wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
1221                                  itemkey    => x_itemkey,
1222                                  aname      => 'EMD_ADMIN_NAME',
1223                                  avalue     => p_emd_admin_name);
1224         -- Bug 4295915: Set the  workflow owner
1225 
1226     wf_engine.SetItemAttrText  (itemtype    => x_itemtype,
1227                              itemkey    => x_itemkey,
1228                              aname      => 'ORIGIN_USER_NAME',
1229                              avalue     => fnd_global.user_name);
1230 
1231     wf_engine.SetItemOwner(itemtype => x_itemtype,
1232                            itemkey  => x_itemkey,
1233                            owner    => fnd_global.user_name);
1234 
1235 
1236     --
1237     -- Start the workflow
1238     --
1239 
1240     wf_engine.StartProcess(itemtype => x_itemtype,
1241                            itemkey  => x_itemkey );
1242     pon_auction_pkg.UNSET_SESSION_LANGUAGE;
1243 
1244     x_progress := '029';
1245         IF ( fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) THEN
1246         fnd_log.string(log_level => fnd_log.level_unexpected
1247                       ,module    => 'pon_auction_pkg.NotifyEmdAdminNegCancel'
1248                       ,message   => 'End calling NotifyEmdAdminNegCancel');
1249       END IF;
1250 
1251 END;
1252 
1253 
1254 -- choli update for emd
1255 PROCEDURE email_emd_admins(p_auction_header_id IN NUMBER) IS
1256 
1257 x_cancel_reason PON_ACTION_HISTORY.ACTION_NOTE%TYPE := '';
1258 x_cancel_date   PON_AUCTION_HEADERS_ALL.CANCEL_DATE%TYPE;
1259 x_event_title   PON_AUCTION_HEADERS_ALL.Event_Title%TYPE;
1260 x_start_date    PON_AUCTION_HEADERS_ALL.PUBLISH_DATE%TYPE;
1261 x_emd_admin_name fnd_user.user_name%TYPE;
1262 x_auction_tp_name PON_AUCTION_HEADERS_ALL.trading_partner_name%TYPE;
1263 x_doc_number_dsp  PON_AUCTION_HEADERS_ALL.document_number%TYPE;
1264 x_auction_title   PON_AUCTION_HEADERS_ALL.auction_title%TYPE;
1265 CURSOR all_emdAdmins(p_auction_header_id NUMBER) IS
1266        select u.user_name,
1267               a.trading_partner_name,
1268               a.auction_title,
1269               a.document_number, a.cancel_date, a.event_title, a.publish_date
1270          from pon_neg_team_members b, pon_auction_headers_all a, fnd_user u
1271         where b.menu_name = 'EMD_ADMIN'
1272           and b.approver_flag = 'Y'
1273           and a.auction_header_id = b.auction_header_id
1274           and u.user_id = b.user_id
1275           and a.auction_header_id = p_auction_header_id;
1276 
1277 BEGIN
1278     IF ( fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) THEN
1279         fnd_log.string(log_level => fnd_log.level_unexpected
1280                       ,module    => 'pon_auction_pkg.email_emd_admins'
1281                       ,message   => 'Start calling email_emd_admins');
1282       END IF;
1283   BEGIN
1284     select action_note
1285       into x_cancel_reason
1286       from pon_action_history
1287      where object_id = p_auction_header_id
1288        and object_type_code = 'PON_AUCTION'
1289        and action_type = 'CANCEL' and rownum=1;
1290   EXCEPTION
1291     WHEN NO_DATA_FOUND THEN
1292       x_cancel_reason := '';
1293   END;
1294 
1295        open all_emdAdmins(p_auction_header_id);
1296        loop
1297             fetch all_emdAdmins
1298              into x_emd_admin_name,
1299                   x_auction_tp_name,
1300                   x_auction_title,
1301                   x_doc_number_dsp,
1302                   x_cancel_date,
1303                   x_event_title,
1304                   x_start_date;
1305             exit when all_emdAdmins%notfound;
1306 
1307 
1308 
1309             NotifyEmdAdminNegCancel(p_auction_header_id,
1310                                       x_emd_admin_name,
1311                                       x_auction_tp_name,
1312                                       x_auction_title,
1313                                       x_doc_number_dsp,
1314                                       x_cancel_date,
1315                                       x_cancel_reason,
1316                                       x_event_title,
1317                                       x_start_date);
1318        end loop;
1319        close all_emdAdmins;
1320     IF ( fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) THEN
1321         fnd_log.string(log_level => fnd_log.level_unexpected
1322                       ,module    => 'pon_auction_pkg.email_emd_admins'
1323                       ,message   => 'End calling email_emd_admins');
1324       END IF;
1325 
1326 END;
1327 
1328 
1329 PROCEDURE EMAIL_BIDDERS(p_itemtype      IN  VARCHAR2,
1330            p_itemkey      IN  VARCHAR2,
1331                p_actid        IN  NUMBER,
1332            p_message_name      IN  VARCHAR2,
1333            p_notification_id    OUT NOCOPY NUMBER) IS
1334 
1335 x_auction_header_id  NUMBER;
1336 x_progress     VARCHAR2(3);
1337 
1338 CURSOR bidder_list IS
1339     select trading_partner_contact_name
1340     from pon_bid_headers
1341     where auction_header_id = x_auction_header_id;
1342 
1343 BEGIN
1344 
1345     x_progress := '010';
1346 
1347     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
1348                                                         itemkey  => p_itemkey,
1349                                                        aname    => 'AUCTION_ID');
1350 
1351     x_progress := '020';
1352 
1353     FOR bidder IN bidder_list LOOP
1354 
1355        x_progress := '030';
1356 
1357           wf_engine.SetItemAttrText (itemtype   => p_itemtype,
1358                                   itemkey    => p_itemkey,
1359                                     aname      => 'BIDDER_DISPLAY_NAME',
1360                                      avalue     => bidder.trading_partner_contact_name);
1361 
1362 
1363     p_notification_id := WF_NOTIFICATION.send(role   => bidder.trading_partner_contact_name,
1364                  context  => p_itemtype||':'||p_itemkey||':'||to_char(p_actid),
1365                        msg_type   => 'PONAUCT',
1366                 msg_name   => p_message_name);
1367    END LOOP;
1368 
1369 
1370 END;
1371 
1372 PROCEDURE START_AUCTION(p_auction_header_id_encrypted   VARCHAR2,   --  1
1373                         p_auction_header_id            NUMBER,    --  2
1374                   p_trading_partner_contact_name  VARCHAR2,  --  3
1375                       p_trading_partner_contact_id  NUMBER,    --  4
1376                     p_trading_partner_name        VARCHAR2,  --  5
1377                       p_trading_partner_id        NUMBER,    --  6
1378                      p_open_bidding_date            DATE,    --  7
1379                     p_close_bidding_date        DATE,    --  8
1380                   p_award_by_date                 DATE,       --  9
1381                   p_reminder_date              DATE,    -- 10
1382                   p_bid_list_type              VARCHAR2,  -- 11
1383                      p_note_to_bidders            VARCHAR2,  -- 12
1384                   p_number_of_items            NUMBER,    -- 13
1385                   p_auction_title              VARCHAR2,  -- 14
1386                         p_event_id                      NUMBER) IS   -- 15
1387 
1388 
1389 
1390 x_sequence  NUMBER;
1391 x_itemtype  VARCHAR2(7) := 'PONAUCT';
1392 x_itemkey  VARCHAR2(50);
1393 x_bid_list  VARCHAR2(1);
1394 x_progress  VARCHAR2(3);
1395 x_new_bidders_flag  VARCHAR2(1) := 'N';
1396 x_timezone  VARCHAR2(80);
1397 x_newstarttime  DATE;
1398 x_newendtime  DATE;
1399 x_preparer_contact_dp_name varchar2(240);
1400 x_event_title   varchar2(80);
1401 x_notification_date DATE;
1402 x_language_code VARCHAR2(3) := null;
1403 x_reminder_date DATE;
1404 x_auction_round_number NUMBER;
1405 x_amendment_number NUMBER;
1406 x_auction_header_id_orig_amend NUMBER;
1407 x_preview_date DATE;
1408 x_difference NUMBER;
1409 
1410 x_doctype_group_name VARCHAR2(60);
1411 x_doc_number_dsp     PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
1412 x_neg_summary_url_buyer       VARCHAR2(2000);
1413 x_net_changes_url_buyer       VARCHAR2(2000);
1414 x_msg_suffix VARCHAR2(3);
1415 
1416 x_oex_timezone VARCHAR2(80);
1417 
1418 x_timezone_disp VARCHAR2(240);
1419 x_doctype_display_name  VARCHAR2(10);
1420 x_notif_subject VARCHAR2(300);
1421 x_orig_document_number PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
1422 
1423 x_timezone1    VARCHAR2(80); -- preview timezone
1424 x_newpreviewtime  DATE;
1425 x_timezone1_disp        VARCHAR2(240);
1426 
1427 x_return_status   VARCHAR2(20);
1428 x_msg_count       NUMBER;
1429 x_msg_data         VARCHAR2(2000);
1430 
1431 x_is_doc_federal    VARCHAR2(1) := 'N'; --Added for FBO project
1432 
1433 CURSOR c1_auction_info(x_lang VARCHAR2) IS
1434     select document_number, auction_header_id_orig_amend, dt.doctype_group_name,
1435            nvl(auction_round_number, 1), nvl(amendment_number, 0),
1436      hz.person_first_name || ' ' ||  hz.person_last_name,
1437        decode(sign(close_bidding_date - nvl(view_by_date, open_bidding_date) - 7), 1, nvl(view_by_date, open_bidding_date)+3,
1438                   decode(sign(close_bidding_date - nvl(view_by_date, open_bidding_date) - 1), 1, nvl(view_by_date, open_bidding_date) + 1,
1439                   nvl(view_by_date, open_bidding_date) + 1/24)) reminder_time
1440     from pon_auction_headers_all auh, hz_parties hz, pon_auc_doctypes dt
1441     where hz.party_id = auh.trading_partner_contact_id
1442     and auh.doctype_id = dt.doctype_id
1443     and auction_header_id = p_auction_header_id;
1444 BEGIN
1445 
1446     --
1447     -- Get the auctioneer's language code so that the c1_auction_info
1448     -- has right value for x_language_code
1449     --
1450     IF p_trading_partner_contact_name is not null THEN
1451       PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(p_trading_partner_contact_name,x_language_code);
1452     END IF;
1453 
1454     x_progress := '010';
1455 
1456     --
1457     -- Get next value in sequence for itemkey
1458     --
1459     SELECT pon_auction_wf_s.nextval
1460     INTO   x_sequence
1461     FROM   dual;
1462     -- get the contact name and auction type
1463     -- to fix bug 2797825, overwritting reminder_date, which is null up to
1464     -- this point
1465     open c1_auction_info(x_language_code);
1466     fetch c1_auction_info
1467     into x_doc_number_dsp, x_auction_header_id_orig_amend, x_doctype_group_name, x_auction_round_number, x_amendment_number, x_preparer_contact_dp_name, x_reminder_date;
1468 
1469     x_progress := '020';
1470 
1471     x_itemkey := (to_char(p_auction_header_id)||'-'||to_char(x_sequence));
1472 
1473     --
1474     -- Create the wf process
1475     --
1476 
1477     wf_engine.CreateProcess(itemtype => x_itemtype,
1478                             itemkey  => x_itemkey,
1479                             process  => 'AUCTION_ENGINE');
1480 
1481 
1482     -- Set the userenv language so the message token (attribute) values that we retrieve using the
1483     -- getMessage call return the message in the correct language => x_language_code
1484     IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
1485        FND_LOG.string(log_level => FND_LOG.level_statement,
1486          module => g_module_prefix || 'START_AUCTION',
1487          message  => '2. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
1488     END IF; --}
1489 
1490     SET_SESSION_LANGUAGE(null, x_language_code);
1491 
1492 
1493     --
1494     -- Set all the item attributes
1495     --
1496 
1497     x_progress := '022';
1498 
1499 
1500     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1501                                itemkey    => x_itemkey,
1502                                aname      => 'AUCTION_REMINDER_DATE',
1503                                avalue     => x_reminder_date);
1504 
1505     wf_engine.SetItemAttrText(itemtype   => x_itemtype,
1506                               itemkey    => x_itemkey,
1507                               aname      => 'AUCTION_ID_ENCRYPTED',
1508                               avalue     => p_auction_header_id_encrypted);
1509 
1510     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1511                                itemkey    => x_itemkey,
1512                                aname      => 'AUCTION_ID',
1513                                avalue     => p_auction_header_id);
1514 
1515 
1516     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1517                                itemkey    => x_itemkey,
1518                                aname      => 'ORIGIN_USER_NAME',
1519                                avalue     => fnd_global.user_name);
1520 
1521 
1522     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1523                                itemkey    => x_itemkey,
1524                                aname      => 'PREPARER_TP_CONTACT_ID',
1525                                avalue     => p_trading_partner_contact_id);
1526 
1527     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1528                                itemkey    => x_itemkey,
1529                                aname      => 'PREPARER_TP_ID',
1530                                avalue     => p_trading_partner_id);
1531 
1532     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1533                                itemkey    => x_itemkey,
1534                                aname      => 'AUCTION_START_DATE',
1535                                avalue     => p_open_bidding_date);
1536 
1537     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1538                                itemkey    => x_itemkey,
1539                                aname      => 'AUCTION_END_DATE',
1540                                avalue     => p_close_bidding_date);
1541 
1542     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1543                                itemkey    => x_itemkey,
1544                                aname      => 'AUCTION_AWARD_DATE',
1545                                avalue     => p_award_by_date);
1546 
1547 
1548    select nvl(view_by_date,open_bidding_date)
1549    into x_notification_date
1550    from pon_auction_headers_all where auction_header_id = p_auction_header_id;
1551 
1552     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1553                                itemkey    => x_itemkey,
1554                                aname      => 'AUCTION_NOTIFICATION_DATE',
1555                                avalue     => x_notification_date);
1556 
1557     IF (p_bid_list_type IS NULL) THEN
1558   x_bid_list := 'N';
1559     ELSE
1560   x_bid_list := 'Y';
1561     END IF;
1562 
1563     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1564                                itemkey    => x_itemkey,
1565                                aname      => 'BIDDER_LIST_FLAG',
1566                                avalue     => x_bid_list);
1567 
1568     IF(x_bid_list = 'Y') THEN
1569   BEGIN
1570           select 'Y' into x_new_bidders_flag from pon_bidding_parties
1571           where auction_header_id = p_auction_header_id
1572           and trading_partner_id is null group by auction_header_id;
1573   EXCEPTION
1574          WHEN NO_DATA_FOUND THEN
1575       x_new_bidders_flag := 'N';
1576     END;
1577 
1578     END IF;
1579 
1580     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1581                                itemkey    => x_itemkey,
1582                                aname      => 'NEW_BIDDERS_FLAG',
1583                                avalue     => x_new_bidders_flag);
1584 
1585     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1586                                itemkey    => x_itemkey,
1587                                aname      => 'NOTE_TO_BIDDERS',
1588                                avalue     => replaceHtmlChars(p_note_to_bidders));
1589 
1590     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1591                                itemkey    => x_itemkey,
1592                                aname      => 'NUMBER_OF_ITEMS',
1593                                avalue     => p_number_of_items);
1594 
1595     -- call to notification utility package to set the message header common attributes and #from_role
1596     pon_wf_utl_pkg.set_hdr_attributes (p_itemtype        => x_itemtype
1597                                   ,p_itemkey        => x_itemkey
1598                                       ,p_auction_tp_name  => p_trading_partner_name
1599                                     ,p_auction_title    => p_auction_title
1600                                     ,p_document_number  => x_doc_number_dsp
1601                                       ,p_auction_tp_contact_name => p_trading_partner_contact_name
1602                                       );
1603 
1604     -- added the contact display name
1605     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1606                                itemkey    => x_itemkey,
1607                                aname      => 'PREPARER_CONTACT_DP_NAME',
1608                                avalue     => x_preparer_contact_dp_name);
1609 
1610 
1611     -- 000001
1612 
1613    select view_by_date
1614    into x_preview_date
1615    from pon_auction_headers_all where auction_header_id = p_auction_header_id;
1616 
1617    if ((x_preview_date is not null) AND (p_open_bidding_date is not null)) then
1618       x_difference := p_open_bidding_date - x_preview_date;
1619    else
1620       x_difference := 0;
1621    end if;
1622 
1623    wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1624                               itemkey    => x_itemkey,
1625                               aname      => 'PREVIEW_DATE',
1626                               avalue     => x_preview_date);
1627 
1628     --
1629     -- Get the exchange's time zone
1630     --
1631 
1632          x_oex_timezone := Get_Oex_Time_Zone;
1633 
1634     --
1635     -- Get the user's time zone
1636     --
1637   x_timezone := Get_Time_Zone(p_trading_partner_contact_id);
1638 
1639     --
1640     -- Make sure that it is a valid time zone
1641     --
1642 
1643     IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 0) THEN
1644   x_timezone := x_oex_timezone;
1645     END IF;
1646 
1647     --
1648     -- Convert the dates to the user's timezone.
1649     --
1650     IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
1651        x_newstarttime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(p_open_bidding_date,x_oex_timezone,x_timezone);
1652        x_newendtime   := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(p_close_bidding_date,x_oex_timezone,x_timezone);
1653        x_newpreviewtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone);
1654     ELSE
1655      x_newstarttime := p_open_bidding_date;
1656      x_newendtime := p_close_bidding_date;
1657        x_newpreviewtime := x_preview_date;
1658     END IF;
1659 
1660     IF (x_preview_date IS NULL) THEN
1661         x_timezone1 := ' ';
1662     ELSE
1663         x_timezone1 := x_timezone;
1664     END IF;
1665 
1666     x_timezone_disp:= Get_TimeZone_Description(x_timezone, x_language_code);
1667 
1668     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1669                                itemkey    => x_itemkey,
1670                                aname      => 'TP_TIME_ZONE',
1671                                avalue     => x_timezone_disp);
1672 
1673     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1674                                itemkey    => x_itemkey,
1675                                aname      => 'AUCTION_START_DATE_TZ',
1676                                avalue     => x_newstarttime);
1677 
1678     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1679                                itemkey    => x_itemkey,
1680                                aname      => 'AUCTION_END_DATE_TZ',
1681                                avalue     => x_newendtime);
1682 
1683     IF (x_newpreviewtime is not null) THEN
1684       wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
1685                            itemkey  => x_itemkey,
1686                            aname  => 'PREVIEW_DATE_TZ',
1687                            avalue   => x_newpreviewtime);
1688 
1689       x_timezone1_disp := Get_TimeZone_Description(x_timezone1, x_language_code);
1690 
1691       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
1692                            itemkey   => x_itemkey,
1693                            aname     => 'TP_TIME_ZONE1',
1694                            avalue    => x_timezone1_disp);
1695 
1696         wf_engine.SetItemAttrText (itemtype  => x_itemtype,
1697                            itemkey  => x_itemkey,
1698                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
1699                            avalue  => null);
1700     ELSE
1701         wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
1702                            itemkey  => x_itemkey,
1703                            aname  => 'PREVIEW_DATE_TZ',
1704                            avalue     => null);
1705 
1706       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
1707                            itemkey  => x_itemkey,
1708                              aname  => 'TP_TIME_ZONE1',
1709                              avalue     => null);
1710 
1711         wf_engine.SetItemAttrText (itemtype  => x_itemtype,
1712                            itemkey  => x_itemkey,
1713                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
1714                            avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
1715     END IF;
1716 
1717 
1718     if (p_event_id is not null) then
1719         x_event_title := getEventTitle (p_auction_header_id);
1720       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1721                                    itemkey    => x_itemkey,
1722                                    aname      => 'EVENT_TITLE',
1723                                    avalue     => replaceHtmlChars(x_event_title));
1724     end if;
1725 
1726     -- new 6.2 attributes.
1727 
1728     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1729                                itemkey    => x_itemkey,
1730                                aname      => 'DOC_INTERNAL_NAME',
1731                                avalue     => x_doctype_group_name);
1732 
1733     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1734                                  itemkey    => x_itemkey,
1735                                  aname      => 'DOC_ROUND_NUMBER',
1736                                  avalue     => x_auction_round_number);
1737 
1738     -- amendment attribute
1739 
1740     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1741                                  itemkey    => x_itemkey,
1742                                  aname      => 'DOC_AMENDMENT_NUMBER',
1743                                  avalue     => x_amendment_number);
1744 
1745     --  New attribute to hold the vendor site id. Attribute value is going
1746   -- to be used as a parameter to access Negotiation Summary page
1747     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1748                                itemkey    => x_itemkey,
1749                                aname      => 'VENDOR_SITE_ID',
1750                                avalue     => -1);
1751 
1752 
1753     x_msg_suffix := GET_MESSAGE_SUFFIX (x_doctype_group_name);
1754 
1755        -- call to notification utility package to get the redirect page url that
1756        -- is responsible for getting the Negotiation Summary url and forward to it.
1757        x_neg_summary_url_buyer := pon_wf_utl_pkg.get_dest_page_url (
1758                               p_dest_func => 'PON_NEG_SUMMARY'
1759                                  ,p_notif_performer  => 'BUYER');
1760 
1761     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1762                                itemkey    => x_itemkey,
1763                                aname      => 'NEG_SUMMARY_URL',
1764                                avalue     => x_neg_summary_url_buyer);
1765 
1766     -- call to notification utility package to get the Net Changes url accessed by buyer.
1767 
1768     if (x_amendment_number > 0) then
1769       -- call to notification utility package to get the redirect page url that
1770        -- is responsible for getting the Net Changes page url and forward to it.
1771        x_net_changes_url_buyer := pon_wf_utl_pkg.get_dest_page_url (
1772                               p_dest_func => 'PONINQ_VIEW_NET_CHNG'
1773                                  ,p_notif_performer  => 'BUYER');
1774     elsif (x_auction_round_number > 1 and x_amendment_number = 0) then
1775        -- call to notification utility package to get the redirect page url that
1776        -- is responsible for getting the Round Modifications page url and forward to it.
1777        x_net_changes_url_buyer := pon_wf_utl_pkg.get_dest_page_url (
1778                               p_dest_func => 'PONINQ_NEW_ROUND_SUM'
1779                                  ,p_notif_performer  => 'BUYER');
1780     end if;
1781 
1782 
1783     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1784                                itemkey    => x_itemkey,
1785                                aname      => 'NET_CHANGES_URL',
1786                                avalue     => x_net_changes_url_buyer);
1787 
1788 
1789    select document_number
1790    into   x_orig_document_number
1791    from   pon_auction_headers_all
1792    where  auction_header_id = x_auction_header_id_orig_amend;
1793 
1794 
1795 --- 000001
1796 
1797    if (x_amendment_number = 0) then -- first round negotiaton
1798      if (x_difference > 0 and sysdate < p_open_bidding_date) then -- preview mode
1799        if (x_event_title is not null) then -- part of event
1800          x_notif_subject := getMessage('PON_AUC_WF_PSTART_EVENT_SUB', x_msg_suffix, 'DOC_NUMBER', x_doc_number_dsp, 'AUCTION_TITLE', replaceHtmlChars(p_auction_title), 'EVENT_TITLE', x_event_title);
1801        else -- NOT part of event
1802          x_notif_subject := getMessage('PON_AUC_WF_AUC_PSTART_SUB', x_msg_suffix,'DOC_NUMBER', x_doc_number_dsp,'AUCTION_TITLE', replaceHtmlChars(p_auction_title));
1803        end if;
1804      else -- open mode
1805        if (x_event_title is not null) then -- part of event
1806          x_notif_subject := getMessage('PON_AUC_WF_START_EVENT_SUB', x_msg_suffix, 'DOC_NUMBER', x_doc_number_dsp, 'AUCTION_TITLE', replaceHtmlChars(p_auction_title), 'EVENT_TITLE', x_event_title);
1807        else
1808          x_notif_subject := getMessage('PON_AUC_WF_AUC_START_SUB', x_msg_suffix, 'DOC_NUMBER', x_doc_number_dsp, 'AUCTION_TITLE', replaceHtmlChars(p_auction_title));
1809        end if;
1810      end if;
1811    else -- amendment
1812      if (x_difference > 0 and sysdate < p_open_bidding_date) then -- preview mode
1813        if (x_event_title is not null) then -- part of event
1814          x_notif_subject := getMessage('PON_AUC_AM_PSTART_EVENT_SUB', x_msg_suffix, 'AMENDMENT_NUMBER', x_amendment_number, 'ORIG_NUMBER', x_orig_document_number, 'AUCTION_TITLE', replaceHtmlChars(p_auction_title), 'EVENT_TITLE', x_event_title);
1815        else -- NOT part of event
1816          x_notif_subject := getMessage('PON_AUC_AM_AUC_PSTART_SUB', x_msg_suffix, 'AMENDMENT_NUMBER', x_amendment_number, 'ORIG_NUMBER', x_orig_document_number, 'AUCTION_TITLE', replaceHtmlChars(p_auction_title));
1817        end if;
1818      else -- open mode
1819        if (x_event_title is not null) then -- part of event
1820          x_notif_subject := getMessage('PON_AUC_AM_START_EVENT_SUB', x_msg_suffix, 'AMENDMENT_NUMBER', x_amendment_number, 'ORIG_NUMBER', x_orig_document_number, 'AUCTION_TITLE', replaceHtmlChars(p_auction_title), 'EVENT_TITLE', x_event_title);
1821        else
1822          x_notif_subject := getMessage('PON_AUC_AM_AUC_START_SUB', x_msg_suffix, 'AMENDMENT_NUMBER', x_amendment_number, 'ORIG_NUMBER', x_orig_document_number, 'AUCTION_TITLE', replaceHtmlChars(p_auction_title));
1823        end if;
1824      end if;
1825    end if;
1826 
1827 
1828    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1829                               itemkey    => x_itemkey,
1830                               aname      => 'AUCTION_STARTED_SUB',
1831                               avalue     => x_notif_subject);
1832 
1833     /*
1834     * Added for FBO project
1835     */
1836     BEGIN
1837     select decode(PON_CLM_UTIL_PKG.IS_NEG_DOCUMENT_FEDERAL(p_auction_header_id), 1, 'Y', 'N')
1838     into x_is_doc_federal
1839     from dual;
1840 
1841     wf_engine.SetItemAttrText(itemtype => x_itemtype
1842                            ,itemkey  => x_itemkey
1843                            ,aname    => 'DOCUMENT_FEDERAL'
1844                            ,avalue   => x_is_doc_federal);
1845 
1846     EXCEPTION
1847     WHEN OTHERS THEN
1848       NULL;
1849     END;
1850 
1851    UNSET_SESSION_LANGUAGE;
1852 
1853    --
1854    -- Start the workflow
1855    --
1856 
1857    -- Bug 4295915: Set the  workflow owner
1858    wf_engine.SetItemOwner(itemtype => x_itemtype,
1859                           itemkey  => x_itemkey,
1860                           owner    => fnd_global.user_name);
1861 
1862    wf_engine.StartProcess(itemtype => x_itemtype,
1863                           itemkey  => x_itemkey );
1864 
1865 
1866    UPDATE pon_auction_headers_all set
1867           wf_item_key = x_itemkey,
1868           reminder_date = x_reminder_date
1869    WHERE auction_header_id = p_auction_header_id;
1870 
1871    -- Raise Business Event
1872    PON_BIZ_EVENTS_PVT.RAISE_NEG_PUB_EVENT (
1873       p_api_version  => 1.0 ,
1874       p_init_msg_list => FND_API.G_FALSE,
1875       p_commit         => FND_API.G_FALSE,
1876       p_auction_header_id => p_auction_header_id,
1877       x_return_status  => x_return_status,
1878       x_msg_count      => x_msg_count,
1879       x_msg_data        => x_msg_data);
1880 
1881 END;
1882 
1883 PROCEDURE START_BID(    p_bid_id               NUMBER,    --  1
1884       p_auction_header_id    NUMBER,    --  2
1885       p_bid_tp_contact_name    VARCHAR2,  --  3
1886       p_auction_tp_name      VARCHAR2,  --  4
1887          p_auction_open_bidding_date  DATE,    --  5
1888         p_auction_close_bidding_date  DATE,     --  6
1889       p_visibility_code    VARCHAR2,  --  7
1890       p_item_description    VARCHAR2,   --  8
1891       p_old_price      NUMBER,    --  9
1892       p_new_price      NUMBER,    -- 10
1893       p_auction_title      VARCHAR2,  -- 11
1894       p_oex_operation      VARCHAR2,  -- 12
1895       p_oex_operation_url    VARCHAR2) IS  -- 13
1896 
1897 
1898 x_sequence  NUMBER;
1899 x_itemtype  VARCHAR2(7) := 'PONABID';
1900 x_itemkey  VARCHAR2(50);
1901 x_progress  VARCHAR2(3);
1902 x_sealed_flag  VARCHAR2(1) := 'N';
1903 x_winning_bid   VARCHAR2(1) := 'N';
1904 
1905 BEGIN
1906 
1907 
1908     x_progress := '010';
1909 
1910     --
1911     -- Get next value in sequence for itemkey
1912     --
1913     SELECT pon_auction_wf_bid_s.nextval
1914     INTO   x_sequence
1915     FROM   dual;
1916 
1917     x_progress := '020';
1918 
1919 
1920     x_itemkey := (to_char(p_bid_id)||'-'||to_char(x_sequence));
1921 
1922     x_progress := '022';
1923 
1924 
1925     --
1926     -- Create the wf process
1927     --
1928 
1929     wf_engine.CreateProcess(itemtype => x_itemtype,
1930                             itemkey  => x_itemkey,
1931                             process  => 'PON_AUCTION_BID');
1932 
1933     --
1934     -- Set all the item attributes
1935     --
1936 
1937     x_progress := '025';
1938 
1939 
1940     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1941                                  itemkey    => x_itemkey,
1942                                  aname      => 'BID_ID',
1943                                  avalue     => p_bid_id);
1944 
1945     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1946                                   itemkey    => x_itemkey,
1947                                  aname      => 'AUCTION_ID',
1948                                  avalue     => p_auction_header_id);
1949 
1950     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1951                                itemkey    => x_itemkey,
1952                                aname      => 'AUCTION_TP_NAME',
1953                                avalue     => p_auction_tp_name);
1954 
1955 
1956     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1957                                itemkey    => x_itemkey,
1958                                aname      => 'AUCTION_START_DATE',
1959                                avalue     => p_auction_open_bidding_date);
1960 
1961     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
1962                                itemkey    => x_itemkey,
1963                                aname      => 'AUCTION_END_DATE',
1964                                avalue     => p_auction_close_bidding_date);
1965 
1966 
1967     IF (p_visibility_code = 'SEALED_BIDDING') THEN
1968   x_sealed_flag := 'Y';
1969     END IF;
1970 
1971     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1972                                itemkey    => x_itemkey,
1973                                aname      => 'SEALED_FLAG',
1974                                avalue     => x_sealed_flag);
1975 
1976     x_progress := '028';
1977 
1978 
1979     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1980                                 itemkey    => x_itemkey,
1981                                aname      => 'OUTBID_TP_CONTACT_NAME',
1982                          avalue     => p_bid_tp_contact_name);
1983 
1984 
1985 
1986     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
1987                                itemkey    => x_itemkey,
1988                                aname      => 'ITEM_DESCRIPTION',
1989                                avalue     => replaceHtmlChars(p_item_description));
1990 
1991     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1992                                   itemkey    => x_itemkey,
1993                                  aname      => 'OLD_BID',
1994                            avalue     => p_old_price);
1995 
1996     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
1997                                   itemkey    => x_itemkey,
1998                                  aname      => 'NEW_BID',
1999                            avalue     => p_new_price);
2000 
2001     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2002                                itemkey    => x_itemkey,
2003                                aname      => 'AUCTION_TITLE',
2004                                avalue     => replaceHtmlChars(p_auction_title));
2005 /*
2006     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2007                                itemkey    => x_itemkey,
2008                                aname      => 'OEX_OPERATION',
2009                                avalue     => p_oex_operation);
2010 */
2011     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2012                                itemkey    => x_itemkey,
2013                                aname      => 'OEX_OPERATION_URL',
2014                                avalue     => p_oex_operation_url);
2015 
2016     -- Bug 4295915: Set the  workflow owner
2017     wf_engine.SetItemOwner(itemtype => x_itemtype,
2018                            itemkey  => x_itemkey,
2019                            owner    => fnd_global.user_name);
2020 
2021     --
2022     -- Start the workflow
2023     --
2024     wf_engine.StartProcess(itemtype => x_itemtype,
2025                            itemkey  => x_itemkey );
2026 
2027     x_progress := '029';
2028 
2029 
2030 END;
2031 
2032 
2033 PROCEDURE DISQUALIFY_BID(p_auction_header_id_encrypted   VARCHAR2,  --  1
2034                          p_bid_id                        NUMBER,  --  2
2035                    p_auction_header_id         NUMBER,    --  3
2036                          p_bid_tp_contact_name           VARCHAR2,  --  4
2037                    p_auction_tp_name               VARCHAR2,  --  5
2038                      p_auction_title               VARCHAR2,  --  6
2039                        p_disqualify_date                DATE,    --  7
2040                    p_disqualify_reason           VARCHAR2  --  8
2041                   ) IS
2042 
2043 
2044 
2045 x_sequence    NUMBER;
2046 x_itemtype    VARCHAR2(8) := 'PONDQBID';
2047 x_itemkey    VARCHAR2(50);
2048 x_bid_list    VARCHAR2(1);
2049 x_progress    VARCHAR2(3);
2050 x_role_name    VARCHAR2(30);
2051 x_sealed_flag    VARCHAR2(1) := 'N';
2052 x_bid_contact_dp_name   VARCHAR2(240);
2053 x_auction_type_name   VARCHAR2(30) := '';
2054 x_auctioneer_tag        VARCHAR2(30);
2055 x_timezone        VARCHAR2(80);
2056 x_new_disqualify_date   DATE;
2057 x_language_code VARCHAR2(3) := null;
2058 x_newstarttime    DATE;
2059 x_newendtime    DATE;
2060 x_startdate    DATE;
2061 x_enddate    DATE;
2062 x_doctype_group_name   VARCHAR2(60);
2063 x_msg_suffix     VARCHAR2(3) := '';
2064 p_doc_number_dsp   PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
2065 p_view_quote_url    VARCHAR2(2000);
2066 x_auction_tp_contact_name PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_NAME%TYPE;
2067 p_bid_name           VARCHAR2(2000); --Bug15903246 - changing the variable length same as MESSAGE_TEXT in FND_NEW_MESSAGES
2068 x_bidder_contact_id             NUMBER;
2069 x_auctioneer_contact_id NUMBER;
2070 x_oex_timezone VARCHAR2(80);
2071 x_timezone_disp VARCHAR2(240);
2072 
2073 -- bidder specific time zone related values
2074 x_timezone_bidder VARCHAR2(80);
2075 x_timezone_disp_bidder VARCHAR2(240);
2076 x_newstarttime_bidder    DATE;
2077 x_newendtime_bidder    DATE;
2078 x_new_disqualify_date_bidder   DATE;
2079 
2080 x_newendtime1    VARCHAR2(80);
2081 x_newstarttime1    VARCHAR2(80);
2082 p_view_quote_url_supplier VARCHAR2(2000);
2083 x_tp_display_name PON_BID_HEADERS.TRADING_PARTNER_NAME%TYPE;
2084 x_tp_address_name PON_BID_HEADERS.VENDOR_SITE_CODE%TYPE;
2085 x_auction_tp_name PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_NAME%TYPE;
2086 x_preview_date           DATE;
2087 x_preview_date_in_tz       DATE;
2088 x_timezone1_disp          VARCHAR2(240);
2089 
2090 -- Bisuness Events Related Changes
2091 x_return_status   VARCHAR2(20);
2092 x_msg_count       NUMBER;
2093 x_msg_data         VARCHAR2(2000);
2094 
2095 x_staggered_closing_interval NUMBER;
2096 x_staggered_close_note       VARCHAR2(1000);
2097 
2098 CURSOR c1_bid_info(x_lang VARCHAR2) IS
2099     select ah.document_number, ah.trading_partner_name, dt.doctype_group_name,
2100      nvl(substr(bhz.attribute2,0,3),''),
2101      bhz.person_first_name || ' ' ||  bhz.person_last_name,
2102        bih.trading_partner_name, decode(bih.vendor_site_code, '-1', null, bih.vendor_site_code) vendor_site_code,
2103        ah.view_by_date, ah.staggered_closing_interval
2104     from hz_parties bhz, pon_bid_headers bih, pon_auction_headers_all ah, pon_auc_doctypes dt
2105     where bhz.party_id = bih.trading_partner_contact_id
2106     and   bih.bid_number = p_bid_id
2107     and   ah.auction_header_id = bih.auction_header_id
2108     and   ah.doctype_id = dt.doctype_id;
2109 
2110 BEGIN
2111 
2112 
2113     x_progress := '010';
2114 
2115     --
2116     -- Get the bidder's language code so that the c1_bid_info
2117     -- has right value for x_language_code
2118     --
2119     IF p_bid_tp_contact_name is not null THEN
2120        PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(p_bid_tp_contact_name,x_language_code);
2121     END IF;
2122 
2123     -- Set the userenv language so the message token (attribute) values that we retrieve using the
2124     -- getMessage call return the message in the correct language => x_language_code
2125 
2126     IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
2127      FND_LOG.string(log_level => FND_LOG.level_statement,
2128        module => g_module_prefix || 'DISQUALIFY_BID',
2129        message  => '3. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
2130     END IF; --}
2131 
2132     SET_SESSION_LANGUAGE(null, x_language_code);
2133 
2134     --
2135     -- Get next value in sequence for itemkey
2136     --
2137 
2138     SELECT pon_auction_wf_dqbid_s.nextval
2139     INTO   x_sequence
2140     FROM   dual;
2141 
2142         -- lxchen why???
2143     --
2144     -- Get the exchange's time zone
2145     --
2146 
2147   select trading_partner_contact_id
2148   into x_bidder_contact_id
2149   from pon_bid_headers
2150   where bid_number = p_bid_id ;
2151 
2152     x_oex_timezone := Get_Oex_Time_Zone;
2153 
2154     --
2155     -- Get the contact name, bidder's timezone and auction type
2156     --
2157 
2158     open c1_bid_info(x_language_code);
2159     fetch c1_bid_info
2160     into p_doc_number_dsp, x_auction_tp_name, x_doctype_group_name,
2161        x_timezone_bidder, x_bid_contact_dp_name,
2162          x_tp_display_name, x_tp_address_name, x_preview_date,
2163          x_staggered_closing_interval;
2164 
2165 
2166     x_timezone_bidder:= Get_Time_Zone(x_bidder_contact_id);
2167 
2168     x_progress := '020';
2169 
2170     x_itemkey := (to_char(p_bid_id)||'-'||to_char(x_sequence));
2171 
2172     x_progress := '022';
2173 
2174     --
2175     -- Create the wf process
2176     --
2177 
2178     wf_engine.CreateProcess(itemtype => x_itemtype,
2179                             itemkey  => x_itemkey,
2180                             process  => 'PON_DISQUALIFY_BID');
2181 
2182     --
2183     -- Set all the item attributes
2184     --
2185 
2186     x_progress := '025';
2187 
2188     x_msg_suffix := GET_MESSAGE_SUFFIX (x_doctype_group_name);
2189 
2190     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2191                                  itemkey    => x_itemkey,
2192                                  aname      => 'DOC_NUMBER',
2193                                  avalue     => p_doc_number_dsp);
2194 
2195     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2196                                  itemkey    => x_itemkey,
2197                                  aname      => 'AUCTION_ID',
2198                                  avalue     => p_auction_header_id);
2199 
2200     wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
2201                                  itemkey    => x_itemkey,
2202                                  aname      => 'ORIGIN_USER_NAME',
2203                                  avalue     => fnd_global.user_name);
2204 
2205     -- Item attribute value is going to be used as a parameter to View Quote page
2206     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2207                                  itemkey    => x_itemkey,
2208                                  aname      => 'BID_ID',
2209                                  avalue     => p_bid_id);
2210 
2211     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2212                                itemkey    => x_itemkey,
2213                                aname      => 'BIDDER_TP_NAME',
2214                                avalue     => x_tp_display_name);
2215 
2216     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2217                                itemkey    => x_itemkey,
2218                                aname      => 'BIDDER_TP_ADDRESS_NAME',
2219                                avalue     => x_tp_address_name);
2220 
2221     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2222                                itemkey    => x_itemkey,
2223                                aname      => 'DOC_INTERNAL_NAME',
2224                                avalue     => x_doctype_group_name);
2225 
2226     BEGIN
2227         x_staggered_close_note := NULL;
2228         IF x_staggered_closing_interval IS NOT NULL THEN
2229              x_staggered_close_note := wf_core.newline || wf_core.newline ||
2230                                        getMessage('PON_STAGGERED_CLOSE_NOTIF_MSG') ||
2231                                        wf_core.newline || wf_core.newline;
2232         END IF;
2233         wf_engine.SetItemAttrText( itemtype => x_itemtype,
2234                                    itemkey  => x_itemkey,
2235                                    aname    => 'STAGGERED_CLOSE_NOTE',
2236                                    avalue   => x_staggered_close_note);
2237     EXCEPTION
2238         WHEN OTHERS THEN
2239              NULL;
2240     END;
2241 
2242     BEGIN
2243       wf_engine.SetItemAttrText(itemtype   => x_itemtype,
2244                                 itemkey    => x_itemkey,
2245                                 aname      => '#WFM_HTMLAGENT',
2246                                 avalue     => pon_wf_utl_pkg.get_base_external_supplier_url);
2247     EXCEPTION
2248           WHEN OTHERS THEN
2249         NULL;
2250     END;
2251 
2252     -- Bug 7156205. Get the value for p_bid_name from getMessage instead of hardcoding the message
2253     p_bid_name := getMessage('PON_AUC_BID_L', x_msg_suffix);
2254 
2255      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2256                                itemkey    => x_itemkey,
2257                                aname      => 'BID',
2258                                avalue     => p_bid_name);
2259 
2260      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2261                                itemkey    => x_itemkey,
2262                                aname      => 'BIDDER_TP_CONTACT_NAME',
2263                                avalue     => p_bid_tp_contact_name);
2264 
2265 
2266     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2267                               itemkey    => x_itemkey,
2268                                aname      => 'DISQUALIFY_REASON',
2269                                avalue     => replaceHtmlChars(p_disqualify_reason));
2270     --
2271     -- Get the dates from the auction header table
2272     --
2273 
2274     select open_bidding_date, close_bidding_date, trading_partner_contact_name
2275     into x_startdate, x_enddate, x_auction_tp_contact_name
2276     from pon_auction_headers_all
2277     where auction_header_id = p_auction_header_id;
2278 
2279     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2280                                 itemkey    => x_itemkey,
2281                               aname      => 'AUCTION_START_DATE',
2282                               avalue     => x_startdate);
2283 
2284     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2285                               itemkey    => x_itemkey,
2286                               aname      => 'AUCTION_END_DATE',
2287                              avalue     => x_enddate);
2288 
2289     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2290                                 itemkey    => x_itemkey,
2291                               aname      => 'PREVIEW_DATE',
2292                              avalue     => x_preview_date);
2293 
2294     --
2295     -- Convert the dates to the bidder's timezone.
2296     -- If the timezone is not recognized, just use PST
2297     --
2298 
2299     IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone_bidder) = 1) THEN
2300       x_newstarttime_bidder := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_startdate,x_oex_timezone,x_timezone_bidder);
2301        x_newendtime_bidder := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_enddate,x_oex_timezone,x_timezone_bidder);
2302        x_new_disqualify_date_bidder := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(p_disqualify_date,x_oex_timezone,x_timezone_bidder);
2303         x_preview_date_in_tz := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone_bidder);
2304     ELSE
2305        x_newstarttime_bidder := x_startdate;
2306        x_newendtime_bidder := x_enddate;
2307        x_new_disqualify_date_bidder := p_disqualify_date;
2308        x_timezone_bidder := x_oex_timezone;
2309         x_preview_date_in_tz := x_preview_date;
2310     END IF;
2311 
2312     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2313                                itemkey    => x_itemkey,
2314                                aname      => 'BIDDER_DISQUALIFY_DATE',
2315                                avalue     => x_new_disqualify_date_bidder);
2316 
2317     x_timezone_disp_bidder := Get_TimeZone_Description(x_timezone_bidder, x_language_code);
2318 
2319     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2320                                itemkey    => x_itemkey,
2321                                aname      => 'TP_TIME_ZONE',
2322                                avalue     => x_timezone_disp_bidder);
2323 
2324     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2325                             itemkey    => x_itemkey,
2326                           aname      => 'AUCTION_START_DATE_BIDDER',
2327                           avalue     => x_newstarttime_bidder);
2328 
2329     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2330                             itemkey    => x_itemkey,
2331                           aname      => 'AUCTION_END_DATE_BIDDER',
2332                           avalue     => x_newendtime_bidder);
2333 
2334     --
2335     -- Get the role name for this auction and the bid visibilty code
2336     -- to see if other bidders should be notified of this bid disqualification
2337     --
2338 
2339     select wf_role_name, decode(bid_visibility_code,'OPEN_BIDDING','N','SEALED_BIDDING','Y','N')
2340     into x_role_name, x_sealed_flag
2341     from pon_auction_headers_all
2342     where auction_header_id = p_auction_header_id;
2343 
2344     --
2345     -- Set the attributes
2346     --
2347 
2348     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2349                                 itemkey    => x_itemkey,
2350                                aname      => 'NEW_BIDDER_ROLE',
2351                              avalue     => x_role_name);
2352 
2353     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2354                                itemkey    => x_itemkey,
2355                                aname      => 'SEALED_FLAG',
2356                                avalue     => x_sealed_flag);
2357 
2358     -- added the contact display name and the auction type ( sellers or buyers)
2359 
2360     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2361                                itemkey    => x_itemkey,
2362                                aname      => 'BID_CONTACT_DP_NAME',
2363                                avalue     => x_bid_contact_dp_name);
2364 
2365 
2366     IF (x_preview_date_in_tz IS NULL) THEN
2367         x_timezone1_disp := null;
2368 
2369         wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
2370                            itemkey  => x_itemkey,
2371                            aname  => 'PREVIEW_DATE_TZ',
2372                            avalue  => null);
2373 
2374         wf_engine.SetItemAttrText (itemtype  => x_itemtype,
2375                            itemkey  => x_itemkey,
2376                            aname  => 'TP_TIME_ZONE1',
2377                            avalue  => null);
2378 
2379         wf_engine.SetItemAttrText (itemtype  => x_itemtype,
2380                            itemkey  => x_itemkey,
2381                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
2382                            avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
2383     ELSE
2384         x_timezone1_disp := x_timezone_disp;
2385 
2386         wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
2387                              itemkey  => x_itemkey,
2388                            aname  => 'PREVIEW_DATE_TZ',
2389                            avalue  => x_preview_date_in_tz);
2390 
2391         wf_engine.SetItemAttrText (itemtype  => x_itemtype,
2392                            itemkey  => x_itemkey,
2393                            aname  => 'TP_TIME_ZONE1',
2394                            avalue  => x_timezone1_disp);
2395 
2396         wf_engine.SetItemAttrText (itemtype  => x_itemtype,
2397                            itemkey  => x_itemkey,
2398                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
2399                            avalue  => null);
2400     END IF;
2401 
2402 
2403 
2404 
2405      -- call to notification utility package to set the message header common attributes and #from_role
2406     pon_wf_utl_pkg.set_hdr_attributes (p_itemtype        => x_itemtype
2407                                   ,p_itemkey        => x_itemkey
2408                                       ,p_auction_tp_name  => x_auction_tp_name
2409                                     ,p_auction_title    => p_auction_title
2410                                     ,p_document_number  => p_doc_number_dsp
2411                                       ,p_auction_tp_contact_name => x_auction_tp_contact_name
2412                                       );
2413 
2414     -- call to notification utility package to get the redirect page url that
2415     -- is responsible for getting the View Quote url and forward to it.
2416        p_view_quote_url := pon_wf_utl_pkg.get_dest_page_url (
2417                               p_dest_func => 'PONRESENQ_VIEWBID'
2418                                  ,p_notif_performer  => 'SUPPLIER');
2419 
2420     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2421                                itemkey    => x_itemkey,
2422                                aname      => 'VIEW_QUOTE_URL',
2423                                avalue     => p_view_quote_url);
2424 
2425 
2426 
2427        x_newstarttime1 := to_char(x_newstarttime_bidder,'Month dd, yyyy hh:mi am');
2428        x_newendtime1   := to_char(x_newendtime_bidder,'Month dd, yyyy hh:mi am');
2429 
2430 
2431 
2432 
2433 --- 000001
2434     wf_engine.SetItemAttrText ( itemtype => x_itemtype,
2435                                 itemkey   => x_itemkey,
2436                                 aname     => 'PON_WF_AUC_DSQBID_SUB',
2437                                 avalue     => getMessage('PON_WF_AUC_DSQBID_SUB', x_msg_suffix,
2438                                                 'BID_ID', p_bid_id,
2439                                                'DOC_NUMBER', p_doc_number_dsp,
2440                                                'AUCTION_TITLE', replaceHtmlChars(p_auction_title)));
2441 
2442     -- Bug 8446265 Modification
2443     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2444                                itemkey    => x_itemkey,
2445                                aname      => 'PON_DSQBID_BODY',
2446                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_PON_DSQBID_BODY/'||x_itemtype ||':' ||x_itemkey
2447                                );
2448 
2449 
2450 
2451     UNSET_SESSION_LANGUAGE;
2452 
2453     x_progress := '027';
2454 
2455     -- Bug 4295915: Set the  workflow owner
2456     wf_engine.SetItemOwner(itemtype => x_itemtype,
2457                            itemkey  => x_itemkey,
2458                            owner    => fnd_global.user_name);
2459 
2460     --
2461     -- Start the workflow
2462     --
2463 
2464     wf_engine.StartProcess(itemtype => x_itemtype,
2465                            itemkey  => x_itemkey );
2466 
2467     x_progress := '029';
2468 
2469     -- Raise Business Event
2470     PON_BIZ_EVENTS_PVT.RAISE_RESPNSE_DISQ_EVENT (
2471       p_api_version  => 1.0 ,
2472       p_init_msg_list => FND_API.G_FALSE,
2473       p_commit         => FND_API.G_FALSE,
2474       p_bid_number => p_bid_id,
2475       x_return_status  => x_return_status,
2476       x_msg_count      => x_msg_count,
2477       x_msg_data        => x_msg_data);
2478 
2479 END;
2480 
2481 
2482 PROCEDURE RETRACT_BID(   p_bid_id               NUMBER,    --  1
2483        p_auction_header_id    NUMBER,    --  2
2484        p_bid_tp_contact_name    VARCHAR2,  --  3
2485        p_bid_tp_contact_id    NUMBER,    --  4
2486        p_auction_tp_contact_name    VARCHAR2,  --  5
2487           p_auction_tp_contact_id  NUMBER,    --  6
2488           p_auction_open_bidding_date  DATE,    --  7
2489          p_auction_close_bidding_date  DATE,     --  8
2490        p_oex_operation_url    VARCHAR2) IS  -- 9
2491 
2492 x_sequence  NUMBER;
2493 x_itemtype  VARCHAR2(7) := 'PONBCAN';
2494 x_itemkey  VARCHAR2(50);
2495 x_bid_list  VARCHAR2(1);
2496 x_progress  VARCHAR2(3);
2497 
2498 BEGIN
2499 
2500 
2501     x_progress := '010';
2502 
2503 
2504     --
2505     -- Get next value in sequence for itemkey
2506     --
2507     SELECT pon_auction_wf_rtbid_s.nextval
2508     INTO   x_sequence
2509     FROM   dual;
2510 
2511     x_progress := '020';
2512 
2513 
2514     x_itemkey := (to_char(p_bid_id)||'-'||to_char(x_sequence));
2515 
2516     x_progress := '022';
2517 
2518 
2519     --
2520     -- Create the wf process
2521     --
2522 
2523     wf_engine.CreateProcess(itemtype => x_itemtype,
2524                             itemkey  => x_itemkey,
2525                             process  => 'PON_BID_CANCEL');
2526 
2527     --
2528     -- Set all the item attributes
2529     --
2530 
2531     x_progress := '025';
2532 
2533 
2534     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2535                                itemkey    => x_itemkey,
2536                                aname      => 'AUCTION_ID',
2537                                avalue     => p_auction_header_id);
2538 
2539 
2540     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2541                                itemkey    => x_itemkey,
2542                                aname      => 'BID_ID',
2543                                avalue     => p_bid_id);
2544 
2545     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2546                                itemkey    => x_itemkey,
2547                                aname      => 'PREPARER_TP_CONTACT_NAME',
2548                                avalue     => p_auction_tp_contact_name);
2549 
2550     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2551                                itemkey    => x_itemkey,
2552                                aname      => 'PREPARER_TP_CONTACT_ID',
2553                                avalue     => p_auction_tp_contact_id);
2554 
2555     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2556                                itemkey    => x_itemkey,
2557                                aname      => 'ORIGIN_USER_NAME',
2558                                avalue     => fnd_global.user_name);
2559     x_progress := '026';
2560 
2561 
2562     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2563                                itemkey    => x_itemkey,
2564                                aname      => 'BIDDER_TP_CONTACT_NAME',
2565                                avalue     => p_bid_tp_contact_name);
2566 
2567     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2568                                itemkey    => x_itemkey,
2569                                aname      => 'BIDDER_TP_CONTACT_ID',
2570                                avalue     => p_bid_tp_contact_id);
2571 
2572 
2573     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2574                                itemkey    => x_itemkey,
2575                                aname      => 'AUCTION_START_DATE',
2576                                avalue     => p_auction_open_bidding_date);
2577 
2578     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2579                                itemkey    => x_itemkey,
2580                                aname      => 'AUCTION_END_DATE',
2581                                avalue     => p_auction_close_bidding_date);
2582 
2583 
2584 --    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2585 --                               itemkey    => x_itemkey,
2586 --                               aname      => 'OEX_OPERATION',
2587 --                               avalue     => p_oex_operation);
2588 
2589     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2590                                itemkey    => x_itemkey,
2591                                aname      => 'OEX_OPERATION_URL',
2592                                avalue     => 'p_oex_operation_url');
2593     x_progress := '027';
2594 
2595 
2596     -- Bug 4295915: Set the  workflow owner
2597     wf_engine.SetItemOwner(itemtype => x_itemtype,
2598                            itemkey  => x_itemkey,
2599                            owner    => fnd_global.user_name);
2600 
2601     --
2602     -- Start the workflow
2603     --
2604     wf_engine.StartProcess(itemtype => x_itemtype,
2605                            itemkey  => x_itemkey );
2606 
2607     x_progress := '029';
2608 
2609 END;
2610 
2611 
2612 PROCEDURE AWARD_BID(p_bid_id                      NUMBER,    --  1
2613                 p_auction_header_id           NUMBER,    --  2
2614                 p_bid_tp_contact_name         VARCHAR2,  --  3
2615                 p_auction_tp_name            VARCHAR2,  --  4
2616                 p_auction_title               VARCHAR2,  --  5
2617                 p_auction_header_id_encrypted  VARCHAR2    --  6
2618                 ) IS
2619 
2620 
2621 
2622 x_number_awarded  NUMBER;
2623 x_number_rejected  NUMBER;
2624 x_sequence  NUMBER;
2625 x_itemtype  VARCHAR2(8) := 'PONAWARD';
2626 x_itemkey  VARCHAR2(50);
2627 x_bid_list  VARCHAR2(1);
2628 x_progress  VARCHAR2(3);
2629 x_bid_contact_tp_dp_name varchar2(240);
2630 x_auction_type varchar2(30);
2631 x_auction_type_name varchar2(30) := '';
2632 x_event_title       varchar2(80);
2633 x_event_id          NUMBER;
2634 x_auction_open_bidding_date DATE;
2635 x_auction_close_bidding_date DATE;
2636 x_language_code VARCHAR2(3) := null;
2637 x_timezone  VARCHAR2(80);
2638 x_newstarttime  DATE;
2639 x_newendtime  DATE;
2640 x_newawardtime  DATE;
2641 x_doctype_group_name   VARCHAR2(60);
2642 x_msg_suffix     VARCHAR2(3) := '';
2643 x_doc_number_dsp    PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
2644 x_auction_round_number    NUMBER;
2645 x_doctype_id_value    NUMBER;
2646 x_oex_timezone VARCHAR2(80);
2647 x_bidder_contact_id   NUMBER;
2648 x_timezone_disp VARCHAR2(240);
2649 x_bid           VARCHAR2(10);
2650 x_bid_caps      VARCHAR2(10);
2651 x_note_to_supplier PON_BID_HEADERS.NOTE_TO_SUPPLIER%TYPE;
2652 x_view_quote_url_supplier VARCHAR2(2000);
2653 x_award_date PON_AUCTION_HEADERS_ALL.AWARD_DATE%TYPE;
2654 x_trading_partner_contact_name PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_NAME%TYPE;
2655 x_tp_display_name PON_BID_HEADERS.TRADING_PARTNER_NAME%TYPE;
2656 x_tp_address_name PON_BID_HEADERS.VENDOR_SITE_CODE%TYPE;
2657 x_preview_date             DATE;
2658 x_preview_date_in_tz             DATE;
2659 x_timezone1_disp                VARCHAR2(240);
2660 x_has_items_flag                PON_AUCTION_HEADERS_ALL.HAS_ITEMS_FLAG%TYPE;
2661 x_staggered_closing_interval    NUMBER;
2662 x_staggered_close_note          VARCHAR2(1000);
2663 x_bid_award_status PON_BID_HEADERS.AWARD_STATUS%TYPE;
2664 
2665 l_note_to_supplier PON_BID_HEADERS.NOTE_TO_SUPPLIER%TYPE :='';
2666 
2667 
2668 CURSOR c1_bid_info(x_lang VARCHAR2) IS
2669     select bid_type, nvl(ah.auction_round_number, 1) auction_round_number, bih.note_to_supplier,
2670      ah.document_number, dt.doctype_group_name, dt.doctype_id,
2671      bhz.person_first_name || ' ' ||  bhz.person_last_name, ah.trading_partner_contact_name,
2672        bih.trading_partner_name, decode(bih.vendor_site_code, '-1', null, bih.vendor_site_code) vendor_site_code,
2673        view_by_date, nvl(ah.has_items_flag, 'Y'), ah.staggered_closing_interval,bih.award_status
2674     from hz_parties bhz, pon_bid_headers bih, pon_auction_headers_all ah, pon_auc_doctypes dt
2675     where bhz.party_id = bih.trading_partner_contact_id
2676     and   bih.bid_number = p_bid_id
2677     and   ah.auction_header_id = bih.auction_header_id
2678     and   ah.doctype_id = dt.doctype_id;
2679 
2680         CURSOR note_to_supplier IS
2681          select LINE_NUMBER,REASON
2682           FROM pon_acceptances
2683           WHERE auction_header_id = p_auction_header_id
2684           and bid_number = p_bid_id;
2685 
2686       l_note note_to_supplier%ROWTYPE;
2687 
2688 BEGIN
2689 
2690 
2691     x_progress := '010';
2692 
2693     --
2694     -- Get the bidder's language code so that the c1_bid_info
2695     -- has right value for x_language_code
2696     --
2697     IF p_bid_tp_contact_name is not null THEN
2698        PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(p_bid_tp_contact_name,x_language_code);
2699     END IF;
2700 
2701     -- Set the userenv language so the message token (attribute) values that we retrieve using the
2702     -- getMessage call return the message in the correct language => x_language_code
2703     IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
2704      FND_LOG.string(log_level => FND_LOG.level_statement,
2705        module => g_module_prefix || 'AWARD_BID',
2706        message  => '4. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
2707     END IF; --}
2708 
2709     SET_SESSION_LANGUAGE(null, x_language_code);
2710 
2711     --
2712     -- Get next value in sequence for itemkey
2713     --
2714 
2715     SELECT pon_auction_wf_acbid_s.nextval
2716     INTO   x_sequence
2717     FROM   dual;
2718 
2719     --
2720     -- get the contact name and auction type
2721     --
2722 
2723     open c1_bid_info(x_language_code);
2724     fetch c1_bid_info
2725     into x_auction_type, x_auction_round_number, x_note_to_supplier, x_doc_number_dsp,
2726    x_doctype_group_name, x_doctype_id_value,
2727    x_bid_contact_tp_dp_name, x_trading_partner_contact_name, x_tp_display_name,
2728          x_tp_address_name, x_preview_date, x_has_items_flag, x_staggered_closing_interval,x_bid_award_status;
2729 
2730  -- bug 6020309 : Get rejection note if any at the line level, if the buyer has
2731  -- not specified rejection note at the bid level. Though the buyer enters a
2732  -- single note in case of rejecting all the bids, the note is stored at the line level.
2733  	--Bug 12654369
2734         --Added Code to Send Note to Supplier for Awarded, Partially Awarded and Rejected Suppliers
2735      if (x_note_to_supplier is null ) THEN
2736        begin
2737           FOR l_note in note_to_supplier
2738               LOOP
2739                 EXIT WHEN length(l_note_to_supplier||fnd_message.get_string('PON', 'PON_AUCTION_LINE_NUMBER')||' '||l_note.line_number||':'||RTRIM(LTRIM(l_note.reason))||'<br>') >1000;
2740                 IF(l_note.reason IS NOT NULL) then
2741                 l_note_to_supplier := l_note_to_supplier||fnd_message.get_string('PON', 'PON_AUCTION_LINE_NUMBER')||' '||l_note.line_number||':'||RTRIM(LTRIM(l_note.reason))||'<br>';
2742                 END IF;
2743               END LOOP;
2744        exception
2745       when others then null;
2746      end;
2747 	x_note_to_supplier:= l_note_to_supplier;
2748      end if;
2749 
2750 
2751 
2752     IF (x_doctype_group_name = 'BUYER_AUCTION') THEN
2753       x_bid := 'bid';
2754         x_bid_caps := 'Bid';
2755     ELSIF (x_doctype_group_name = 'REQUEST_FOR_QUOTE') THEN
2756       x_bid := 'quote';
2757         x_bid_caps := 'Quote';
2758     ELSIF (x_doctype_group_name = 'REQUEST_FOR_INFORMATION') THEN
2759         x_bid := 'response';
2760         x_bid_caps := 'Response';
2761     END IF;
2762 
2763     x_progress := '020';
2764 
2765     x_msg_suffix := GET_MESSAGE_SUFFIX (x_doctype_group_name);
2766 
2767     x_itemkey := (to_char(p_bid_id)||'-'||to_char(x_sequence));
2768 
2769     x_progress := '022';
2770 
2771     --
2772     -- Create the wf process
2773     --
2774 
2775     wf_engine.CreateProcess(itemtype => x_itemtype,
2776                             itemkey  => x_itemkey,
2777                             process  => 'PON_AWARD_BID');
2778 
2779     --
2780     -- Set all the item attributes
2781     --
2782 
2783     wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
2784                                  itemkey    => x_itemkey,
2785                                  aname      => 'DOC_NUMBER',
2786                                  avalue     => x_doc_number_dsp);
2787 
2788 
2789     -- call to notification utility package to get the redirect page url that
2790     -- is responsible for getting the View Quote url and forward to it.
2791   x_view_quote_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
2792                               p_dest_func => 'PONRESENQ_VIEWBID'
2793                                  ,p_notif_performer  => 'SUPPLIER');
2794 
2795     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2796                                itemkey    => x_itemkey,
2797                                aname      => 'VIEW_QUOTE_URL',
2798                                avalue     => x_view_quote_url_supplier);
2799 
2800     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2801                                itemkey    => x_itemkey,
2802                                aname      => 'BIDDER_TP_NAME',
2803                                avalue     => x_tp_display_name);
2804 
2805     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2806                                itemkey    => x_itemkey,
2807                                aname      => 'HAS_ITEMS_FLAG',
2808                                avalue     => x_has_items_flag);
2809 
2810     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2811                                itemkey    => x_itemkey,
2812                                aname      => 'BIDDER_TP_ADDRESS_NAME',
2813                                avalue     => x_tp_address_name);
2814 
2815     BEGIN
2816         x_staggered_close_note := NULL;
2817         IF x_staggered_closing_interval IS NOT NULL THEN
2818              x_staggered_close_note := wf_core.newline || wf_core.newline ||
2819                                        getMessage('PON_STAGGERED_CLOSE_NOTIF_MSG') ||
2820                                        wf_core.newline || wf_core.newline;
2821         END IF;
2822         wf_engine.SetItemAttrText( itemtype => x_itemtype,
2823                                    itemkey  => x_itemkey,
2824                                    aname    => 'STAGGERED_CLOSE_NOTE',
2825                                    avalue   => x_staggered_close_note);
2826     EXCEPTION
2827         WHEN OTHERS THEN
2828               NULL;
2829     END;
2830 
2831     BEGIN
2832       wf_engine.SetItemAttrText(itemtype   => x_itemtype,
2833                                 itemkey    => x_itemkey,
2834                                 aname      => '#WFM_HTMLAGENT',
2835                                 avalue     => pon_wf_utl_pkg.get_base_external_supplier_url);
2836     EXCEPTION
2837           WHEN OTHERS THEN
2838         NULL;
2839     END;
2840 
2841     x_progress := '025';
2842 
2843 -- FPK: CPA Setting number of items awarded or rejected only when negotiation has lines.
2844 IF x_has_items_flag  = 'Y' THEN
2845 
2846     /* set these variables to a default zero */
2847     x_number_awarded  := 0;
2848     x_number_rejected := 0;
2849 
2850 
2851     select   count(pbip.line_number)
2852     into   x_number_awarded
2853     from   pon_bid_item_prices pbip,
2854     pon_auction_item_prices_all paip
2855     where   paip.auction_header_id   = p_auction_header_id
2856     and    paip.line_number   = pbip.line_number
2857     and    pbip.bid_number    = p_bid_id
2858     and    nvl(pbip.award_status,'NONE')= 'AWARDED'
2859     and    paip.group_type in ('LINE', 'LOT', 'GROUP_LINE');
2860 
2861     select   count(pbip.line_number)
2862     into   x_number_rejected
2863     from   pon_bid_item_prices pbip,
2864     pon_auction_item_prices_all paip
2865     where   paip.auction_header_id   = p_auction_header_id
2866     and    paip.line_number   = pbip.line_number
2867     and    pbip.bid_number    = p_bid_id
2868     and    nvl(pbip.award_status,'NONE')= 'REJECTED'
2869     and    paip.group_type in ('LINE', 'LOT', 'GROUP_LINE');
2870 
2871     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2872                                  itemkey    => x_itemkey,
2873                                  aname      => 'NUMBER_AWARDED',
2874                                  avalue     => x_number_awarded);
2875 
2876     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2877                                  itemkey    => x_itemkey,
2878                                  aname      => 'NUMBER_REJECTED',
2879                                  avalue     => x_number_rejected);
2880 END IF;
2881 
2882 
2883     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2884                                  itemkey    => x_itemkey,
2885                                  aname      => 'AUCTION_ID',
2886                                  avalue     => p_auction_header_id);
2887 
2888     -- Item attribute value is going to be used as a parameter to View Quote page
2889     wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
2890                                  itemkey    => x_itemkey,
2891                                  aname      => 'BID_ID',
2892                                  avalue     => p_bid_id);
2893 
2894     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2895                                itemkey    => x_itemkey,
2896                                aname      => 'BIDDER_TP_CONTACT_NAME',
2897                                avalue     => p_bid_tp_contact_name);
2898 
2899     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2900                                itemkey    => x_itemkey,
2901                                aname      => 'ORIGIN_USER_NAME',
2902                                avalue     => fnd_global.user_name);
2903 
2904      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2905                                itemkey    => x_itemkey,
2906                                aname      => 'BID',
2907                                avalue     => x_bid);
2908 
2909      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2910                                itemkey    => x_itemkey,
2911                                aname      => 'BID_CAPS',
2912                                avalue     => x_bid_caps);
2913 
2914      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2915                                itemkey    => x_itemkey,
2916                                aname      => 'NOTE_TO_SUPPLIER',
2917                                avalue     => x_note_to_supplier);
2918 
2919 -- added the contact display name and the auction type ( sellers or buyers)
2920 
2921     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2922                                itemkey    => x_itemkey,
2923                                aname      => 'BID_CONTACT_TP_DP_NAME',
2924                          avalue     => x_bid_contact_tp_dp_name);
2925 
2926     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2927                                itemkey    => x_itemkey,
2928                                aname      => 'AUCTION_TYPE_NAME',
2929                                avalue     => x_auction_type_name);
2930 
2931     select open_bidding_date, close_bidding_date, award_date, event_id
2932     into x_auction_open_bidding_date, x_auction_close_bidding_date, x_award_date, x_event_id
2933     from pon_auction_headers_all
2934     where auction_header_id = p_auction_header_id;
2935 
2936     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
2937                                itemkey    => x_itemkey,
2938                                aname      => 'AWARD_DATE',
2939                                avalue     => x_award_date);
2940 
2941     if (x_event_id is not null) then
2942         x_event_title := getEventTitle (p_auction_header_id);
2943       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
2944                              itemkey    => x_itemkey,
2945                              aname      => 'EVENT_TITLE',
2946                              avalue     => replaceHtmlChars(x_event_title));
2947     end if;
2948 
2949     --
2950     -- Get the exchange's time zone
2951     --
2952 
2953                 x_oex_timezone := Get_Oex_Time_Zone;
2954 
2955 
2956   select trading_partner_contact_id
2957   into x_bidder_contact_id
2958   from pon_bid_headers
2959   where bid_number = p_bid_id;
2960 
2961   begin
2962   x_timezone := Get_Time_Zone(x_bidder_contact_id);
2963    EXCEPTION
2964   WHEN OTHERS THEN
2965     x_timezone := x_oex_timezone;
2966         END;
2967 
2968 
2969     --
2970     -- Convert the dates to the user's timezone.
2971     -- If the timezone is not recognized, just use the default
2972     --
2973 
2974     IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
2975       x_newstarttime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_auction_open_bidding_date,x_oex_timezone,x_timezone);
2976        x_newendtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_auction_close_bidding_date,x_oex_timezone,x_timezone);
2977         x_newawardtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_award_date,x_oex_timezone,x_timezone);
2978         x_preview_date_in_tz := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone);
2979     ELSE
2980       x_newstarttime := x_auction_open_bidding_date;
2981       x_newendtime := x_auction_close_bidding_date;
2982         x_newawardtime := x_award_date;
2983       x_timezone := x_oex_timezone;
2984         x_preview_date_in_tz := x_preview_date;
2985     END IF;
2986 
2987     --
2988     -- Set the dates based on the user's time zone
2989     --
2990 
2991    x_timezone_disp := Get_TimeZone_Description(x_timezone, x_language_code);
2992 
2993 
2994     wf_engine.SetItemAttrText (itemtype  => x_itemtype,
2995              itemkey  => x_itemkey,
2996              aname  => 'TP_TIME_ZONE_AUCTION',
2997              avalue  => x_timezone_disp);
2998 
2999     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
3000                                  itemkey    => x_itemkey,
3001                                aname      => 'AUCTION_START_DATE_TZ',
3002                                avalue     => x_newstarttime);
3003 
3004     wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
3005                                  itemkey    => x_itemkey,
3006                                aname      => 'AUCTION_END_DATE_TZ',
3007                                avalue     => x_newendtime);
3008 
3009     wf_engine.SetItemAttrDate (itemtype     => x_itemtype,
3010                                  itemkey    => x_itemkey,
3011                                aname      => 'AWARD_DATE_TZ',
3012                                avalue     => x_newawardtime);
3013 
3014   IF (x_preview_date_in_tz IS NULL) THEN
3015 
3016      x_timezone1_disp := null;
3017 
3018      wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
3019                         itemkey  => x_itemkey,
3020                         aname  => 'PREVIEW_DATE_TZ',
3021                         avalue  => null);
3022 
3023      wf_engine.SetItemAttrText (itemtype  => x_itemtype,
3024                         itemkey  => x_itemkey,
3025                         aname  => 'TP_TIME_ZONE1',
3026                         avalue  => null);
3027 
3028      wf_engine.SetItemAttrText (itemtype  => x_itemtype,
3029                          itemkey  => x_itemkey,
3030                          aname  => 'PREVIEW_DATE_NOTSPECIFIED',
3031                          avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
3032  ELSE
3033      x_timezone1_disp := x_timezone_disp;
3034 
3035      wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
3036                         itemkey  => x_itemkey,
3037                         aname  => 'PREVIEW_DATE_TZ',
3038                         avalue  => x_preview_date_in_tz);
3039 
3040      wf_engine.SetItemAttrText (itemtype  => x_itemtype,
3041                         itemkey  => x_itemkey,
3042                         aname  => 'TP_TIME_ZONE1',
3043                         avalue  => x_timezone1_disp);
3044 
3045        wf_engine.SetItemAttrText (itemtype  => x_itemtype,
3046                           itemkey  => x_itemkey,
3047                           aname  => 'PREVIEW_DATE_NOTSPECIFIED',
3048                           avalue  => null);
3049  END IF;
3050 
3051     x_progress := '027';
3052 
3053     -- call to notification utility package to set the message header common attributes and #from_role
3054     pon_wf_utl_pkg.set_hdr_attributes (p_itemtype               => x_itemtype
3055                                   ,p_itemkey               => x_itemkey
3056                                       ,p_auction_tp_name         => p_auction_tp_name
3057                                     ,p_auction_title           => p_auction_title
3058                                     ,p_document_number         => x_doc_number_dsp
3059                                       ,p_auction_tp_contact_name => x_trading_partner_contact_name
3060                                       );
3061 
3062 
3063      if (x_event_title is not null) then
3064 
3065         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3066                                    itemkey    => x_itemkey,
3067                                    aname      => 'PON_AUC_WF_AWARD_SUBJECT',
3068                                    avalue     => getMessage('PON_AUC_WF_AWARD_EVENT_SUB', x_msg_suffix,
3069                     'DOC_NUMBER', x_doc_number_dsp,
3070                     'AUCTION_TITLE', replaceHtmlChars(p_auction_title),
3071                                   'EVENT_TITLE', x_event_title));
3072 
3073     else
3074 
3075        wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3076                                   itemkey    => x_itemkey,
3077                                   aname      => 'PON_AUC_WF_AWARD_SUBJECT',
3078                                   avalue     => getMessage('PON_AUC_WF_AWARD_SUBJECT', x_msg_suffix,
3079                    'DOC_NUMBER', x_doc_number_dsp,
3080                    'AUCTION_TITLE', replaceHtmlChars(p_auction_title)));
3081 
3082    end if;
3083 
3084    --Bug 8446265 Modifications
3085    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3086                                itemkey    => x_itemkey,
3087                                aname      => 'PON_AUC_WF_AWARD_L_BODY',
3088                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_AWARD_LINES_BODY/'||x_itemtype ||':' ||x_itemkey
3089                                );
3090 
3091 
3092    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3093                                itemkey    => x_itemkey,
3094                                aname      => 'PON_AUC_WF_AWARD_NL_BODY',
3095                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_AWARD_NOLINES_BODY/'||x_itemtype ||':' ||x_itemkey
3096                                );
3097 
3098    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3099                                itemkey    => x_itemkey,
3100                                aname      => 'PON_AUC_WF_AWARD_EVENT_L_BODY',
3101                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_AWARD_EVENT_LINES_BODY/'||x_itemtype ||':' ||x_itemkey
3102                                );
3103 
3104    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3105                                itemkey    => x_itemkey,
3106                                aname      => 'PON_AUC_WF_AWARD_EVENT_NL_BODY',
3107                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_AWARD_EVENT_NOLINES_BODY/'||x_itemtype ||':' ||x_itemkey
3108                                );
3109 
3110     UNSET_SESSION_LANGUAGE;
3111 
3112     -- Bug 4295915: Set the  workflow owner
3113     wf_engine.SetItemOwner(itemtype => x_itemtype,
3114                            itemkey  => x_itemkey,
3115                            owner    => fnd_global.user_name);
3116 
3117     --
3118     -- Start the workflow
3119     --
3120 
3121     wf_engine.StartProcess(itemtype => x_itemtype,
3122                            itemkey  => x_itemkey );
3123 
3124     x_progress := '029';
3125 
3126 END;
3127 
3128 PROCEDURE UNREGISTERED_BIDDERS(  itemtype    in varchar2,
3129            itemkey    in varchar2,
3130                        actid           in number,
3131                        uncmode    in varchar2,
3132                        resultout       out NOCOPY varchar2) IS
3133 
3134 x_flag   VARCHAR2(1);
3135 BEGIN
3136 
3137     x_flag := wf_engine.GetItemAttrText (itemtype => itemtype,
3138                                          itemkey  => itemkey,
3139                                          aname    => 'NEW_BIDDERS_FLAG');
3140 
3141 
3142     IF (x_flag = 'Y') THEN
3143   resultout := 'Y';
3144     ELSE
3145   resultout := 'N';
3146 
3147     END IF;
3148 
3149 END;
3150 
3151 PROCEDURE BIDDERS_LIST(  itemtype    in varchar2,
3152            itemkey    in varchar2,
3153                        actid           in number,
3154                        uncmode    in varchar2,
3155                        resultout       out NOCOPY varchar2) IS
3156 
3157 x_flag   VARCHAR2(1);
3158 BEGIN
3159 
3160     x_flag := wf_engine.GetItemAttrText (itemtype => itemtype,
3161                                          itemkey  => itemkey,
3162                                          aname    => 'BIDDER_LIST_FLAG');
3163 
3164 
3165     IF (x_flag = 'Y') THEN
3166   resultout := 'Y';
3167     ELSE
3168   resultout := 'N';
3169 
3170     END IF;
3171 
3172 END;
3173 
3174 
3175 PROCEDURE COMPLETE_PREV_ROUND_WF(  p_itemtype            in varchar2,
3176            p_itemkey             in varchar2,
3177            actid                 in number,
3178            uncmode               in varchar2,
3179            resultout             out NOCOPY varchar2) IS
3180   x_doc_header_id number;
3181   x_itemkey varchar2(240);
3182 BEGIN
3183 
3184     x_doc_header_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
3185                                              itemkey  => p_itemkey,
3186                                              aname    => 'AUCTION_ID');
3187 
3188     begin
3189       select wf_item_key into x_itemkey
3190   from pon_auction_headers_all
3191   where auction_header_id = (select auction_header_id_prev_round
3192            from pon_auction_headers_all where auction_header_id = x_doc_header_id);
3193 
3194   wf_engine.completeActivity('PONAUCT', x_itemkey, 'WAIT_FOR_AUCTION_COMPLETE', 'PREPARER_COMPLETE');
3195 
3196     exception
3197   when others then
3198   null;
3199     end;
3200 END;
3201 
3202 
3203 PROCEDURE COMPLETE_PREV_DOC_WF(  p_itemtype            in varchar2,
3204                                  p_itemkey             in varchar2,
3205                                  actid                 in number,
3206                                  uncmode               in varchar2,
3207                                  resultout             out NOCOPY varchar2) IS
3208         x_doc_header_id number;
3209         x_prev_doc_header_id number;
3210         x_prev_doc_amendment_number number;
3211         x_itemtype                VARCHAR2(7) := 'PONAUCT';
3212         x_itemkey varchar2(240);
3213         x_current_activity        VARCHAR2(30);
3214 BEGIN
3215 
3216     x_doc_header_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
3217                                                   itemkey  => p_itemkey,
3218                                                   aname    => 'AUCTION_ID');
3219 
3220     begin
3221 
3222         select auction_header_id_prev_amend
3223         into   x_prev_doc_header_id
3224         from pon_auction_headers_all
3225         where auction_header_id = x_doc_header_id;
3226 
3227         select wf_item_key, nvl(amendment_number, 0)
3228         into x_itemkey, x_prev_doc_amendment_number
3229         from pon_auction_headers_all
3230         where auction_header_id = x_prev_doc_header_id;
3231 
3232         -- need to complete first round supplier notifications (might be waiting on ack response)
3233         if (x_prev_doc_amendment_number = 0) then
3234           complete_prev_suppl_notifs(x_prev_doc_header_id);
3235         end if;
3236 
3237         --
3238         -- First, see what activity (if any) the workflow is on
3239         -- If none, then return.  Workflow has already completed??
3240         --
3241         BEGIN
3242            select activity_label
3243            into x_current_activity
3244            from wf_item_activity_statuses_v
3245            where item_type = x_itemtype
3246            AND item_key = x_itemkey
3247            and activity_status_code = 'NOTIFIED';
3248         EXCEPTION WHEN no_data_found THEN
3249            RETURN;
3250         END;
3251 
3252         wf_engine.CompleteActivity(x_itemtype,x_itemkey,x_current_activity,'PREPARER_COMPLETE');
3253 
3254     exception
3255         when others then
3256         null;
3257     end;
3258 END;
3259 
3260 PROCEDURE COMPLETE_PREV_SUPPL_NOTIFS(p_prev_doc_header_id IN NUMBER) IS
3261 
3262 x_itemtype         varchar2(8) := 'PONPBLSH';
3263 x_itemkey          varchar2(240);
3264 x_current_activity varchar2(30);
3265 
3266 CURSOR bidder_list_wf_keys IS
3267     select pbp.wf_item_key wf_item_key, act.activity_label activity_label
3268     from   pon_bidding_parties pbp,
3269            wf_item_activity_statuses_v act
3270     where  pbp.auction_header_id = p_prev_doc_header_id and
3271            act.item_type = x_itemtype and
3272            act.item_key = pbp.wf_item_key and
3273            act.activity_status_code = 'NOTIFIED';
3274 BEGIN
3275 
3276   FOR item_key IN bidder_list_wf_keys LOOP
3277 
3278 
3279      x_itemkey := item_key.wf_item_key;
3280      x_current_activity := item_key.activity_label;
3281 
3282      wf_engine.CompleteActivity(x_itemtype,x_itemkey,x_current_activity,'PREPARER_COMPLETE');
3283 
3284   END LOOP;
3285 
3286 END;
3287 
3288 PROCEDURE SEND_BIDDERS_NOTIFICATION(itemtype                      in varchar2,
3289                                     itemkey                       in varchar2,
3290                                     actid                         in number,
3291                                     p_action_code                 in varchar2,
3292                                     p_user                        in varchar2,
3293                                     p_bidder_tp_name              in varchar2,
3294                                     p_vendor_site_code            in varchar2,
3295                                     p_vendor_site_id              in number,
3296                                     p_message_name                in varchar2,
3297                                     p_doc_number_dsp              in varchar2,
3298                                     p_auction_title               in varchar2,
3299                                     p_auction_start_date          in date,
3300                                     p_auction_end_date            in date,
3301                                     p_preview_date                in date,
3302                                     p_language_code               in varchar2,
3303                                     p_timezone                    in varchar2,
3304                                     p_change_type                 in number,
3305                                     p_original_close_bidding_date in date,
3306                                     p_event_title                 in varchar2,
3307                                     p_auc_tp_contact_name         in varchar2,
3308                                     p_staggered_closing_interval  in number)
3309 IS
3310 
3311    x_auction_header_id_encrypted  varchar2(2000);
3312    x_neg_summary_url_supplier VARCHAR2(2000);
3313    x_nid number;
3314 
3315    x_msg_suffix varchar2(3) := '';
3316    x_tp_time_zone_auction varchar2(30);
3317    x_oex_timezone varchar2(80);
3318    x_timezone     varchar2(80);
3319    x_new_auction_start_date date;
3320    x_new_auction_end_date date;
3321 
3322    x_close_early_subject varchar2(200);
3323    x_close_early_reason  varchar2(2000);
3324    x_close_early_no_reason varchar2(2000);
3325    x_close_early_at varchar2(200);
3326 
3327    x_close_changed_message varchar2(2000);
3328    x_close_changed_subject varchar2(200);
3329    x_close_changed_reason varchar2(2000);
3330    x_close_changed_no_reason varchar2(2000);
3331 
3332    x_status                VARCHAR2(10);
3333    x_exception_msg         VARCHAR2(100);
3334    x_person_party_id       NUMBER;
3335 
3336    x_new_supplier_name     VARCHAR2(240) := '';
3337    x_additional_invitee_flag BOOLEAN;
3338    x_deleted_contact_flag    BOOLEAN;
3339    x_count       NUMBER;
3340 
3341    x_listed_company_user   VARCHAR2(240) := '';
3342    x_timezone_disp VARCHAR2(240);
3343 
3344    x_close_early_date  DATE;
3345    x_close_date_changed DATE;
3346    x_new_close_early_date date;
3347    x_new_close_changed_date date;
3348    x_new_auction_preview_date DATE;
3349    x_timezone1_disp  VARCHAR2(240);
3350 
3351    x_cancel_reason PON_ACTION_HISTORY.ACTION_NOTE%TYPE := '';
3352    x_cancel_date          DATE;
3353    x_new_cancel_date      DATE;
3354    x_new_disqualify_date  DATE;
3355    x_disqualify_reason varchar2(2000) := '';
3356    x_bid_number number;
3357    x_disqualify_date date;
3358    x_bid_name      VARCHAR2(10);
3359    x_staggered_close_note   VARCHAR2(1000);
3360 
3361    l_origin_user_name    fnd_user.user_name%TYPE;
3362 
3363 begin
3364 
3365     if (p_action_code = 'CANCEL') then
3366 
3367         x_cancel_reason := wf_engine.GetItemAttrText(itemtype => itemtype,
3368                                            itemkey  => itemkey,
3369                                          aname    => 'CANCEL_REASON');
3370 
3371         x_cancel_date := wf_engine.GetItemAttrDate(itemtype => itemtype,
3372                                            itemkey  => itemkey,
3373                                          aname    => 'CANCEL_DATE');
3374 
3375     elsif (p_action_code = 'DISQUALIFY_BID') then
3376 
3377         x_disqualify_reason := wf_engine.GetItemAttrText(itemtype => itemtype,
3378                                                        itemkey  => itemkey,
3379                                                        aname    => 'DISQUALIFY_REASON');
3380 
3381         x_bid_number := wf_engine.GetItemAttrNumber (itemtype => itemtype,
3382                                                      itemkey  => itemkey,
3383                                                      aname    => 'BID_ID');
3384 
3385 
3386         x_disqualify_date := wf_engine.GetItemAttrDate (itemtype => itemtype,
3387                                                         itemkey  => itemkey,
3388                                                         aname    => 'BIDDER_DISQUALIFY_DATE');
3389 
3390         x_bid_name := wf_engine.GetItemAttrText (itemtype => itemtype,
3391                                                  itemkey  => itemkey,
3392                                                aname    => 'BID');
3393 
3394     end if;
3395 
3396 
3397       l_origin_user_name := wf_engine.GetItemAttrText (itemtype => itemtype,
3398                                                        itemkey  => itemkey,
3399                                                  aname    => 'ORIGIN_USER_NAME');
3400 
3401       x_msg_suffix := GET_MESSAGE_SUFFIX (wf_engine.GetItemAttrText (itemtype  => itemtype,
3402                                                                      itemkey   => itemkey,
3403                                                                      aname      => 'DOC_INTERNAL_NAME'));
3404 
3405       UNSET_SESSION_LANGUAGE;
3406 
3407       x_nid := WF_NOTIFICATION.send(role      => p_user ,
3408                                     context   => itemtype||':'||itemkey||':'||actid,
3409                                     msg_type  => itemtype,
3410                                     msg_name  => p_message_name);
3411 
3412       IF (p_language_code is not null) THEN
3413 
3414          IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
3415          FND_LOG.string(log_level => FND_LOG.level_statement,
3416            module => g_module_prefix || 'SEND_BIDDERS_NOTIFICATION',
3417            message  => '5. Calling SET_SESSION_LANGUAGE with x_language_code : ' || p_language_code);
3418          END IF; --}
3419          SET_SESSION_LANGUAGE(null, p_language_code);
3420       END IF;
3421 
3422       -- Set the staggered closing attribute
3423       x_staggered_close_note := NULL;
3424       IF p_staggered_closing_interval IS NOT NULL THEN
3425            x_staggered_close_note := wf_core.newline || wf_core.newline ||
3426                                      getMessage('PON_STAGGERED_CLOSE_NOTIF_MSG') ||
3427                                      wf_core.newline || wf_core.newline;
3428       END IF;
3429       wf_Notification.setAttrText(x_nid, 'STAGGERED_CLOSE_NOTE', x_staggered_close_note);
3430 
3431       BEGIN
3432         wf_Notification.setAttrText(x_nid,'#WFM_HTMLAGENT', pon_wf_utl_pkg.get_base_external_supplier_url);
3433       EXCEPTION
3434             WHEN OTHERS THEN
3435           NULL;
3436       END;
3437 
3438       if (p_action_code = 'CLOSEEARLY') then
3439 
3440         x_close_early_date := p_auction_end_date;
3441         x_close_early_subject := getMessage('PON_AUC_CLOSE_WF_1', x_msg_suffix,
3442                                             'DOC_NUMBER', p_doc_number_dsp,
3443                                             'AUCTION_TITLE', replaceHtmlChars(p_auction_title));
3444 
3445       elsif (p_action_code = 'CLOSECHANGED') then
3446 
3447        x_close_date_changed := p_auction_end_date;
3448 
3449        x_auction_header_id_encrypted := wf_engine.GetItemAttrText (itemtype => itemtype,
3450                                                                    itemkey  => itemkey,
3451                                                                    aname    => 'AUCTION_ID_ENCRYPTED');
3452 
3453      -- call to notification utility package to get the redirect page url that
3454      -- is responsible for getting the Negotiation Summary url and forward to it.
3455         x_neg_summary_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
3456                                   p_dest_func => 'PON_NEG_SUMMARY'
3457                                      ,p_notif_performer  => 'SUPPLIER');
3458 
3459        -- auctioneer extends the auction
3460         if (p_change_type = 1) then
3461 
3462            x_close_changed_subject := getMessage('PON_AUC_EXTEND_WF_1', x_msg_suffix,
3463                                                  'DOC_NUMBER', p_doc_number_dsp,
3464                                                  'AUCTION_TITLE', replaceHtmlChars(p_auction_title));
3465 
3466         -- auctioneer shortens the auction
3467         else
3468            x_close_changed_subject := getMessage('PON_AUC_SHORTEN_WF_1', x_msg_suffix,
3469                                                  'DOC_NUMBER', p_doc_number_dsp,
3470                                                  'AUCTION_TITLE', replaceHtmlChars(p_auction_title));
3471         end if;
3472      end if;
3473 
3474       x_oex_timezone := Get_Oex_Time_Zone;
3475       x_timezone     := p_timezone;
3476 
3477       IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
3478           x_new_auction_start_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(p_auction_start_date,x_oex_timezone,x_timezone);
3479           x_new_auction_preview_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(p_preview_date,x_oex_timezone,x_timezone);
3480 
3481           if (p_action_code = 'CLOSEEARLY' or p_action_code = 'CLOSECHANGED') then
3482               x_new_auction_end_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME  (p_original_close_bidding_date,x_oex_timezone,x_timezone);
3483           else
3484              x_new_auction_end_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(p_auction_end_date,x_oex_timezone,x_timezone);
3485          end if;
3486 
3487           if (p_action_code = 'CLOSEEARLY') then
3488               x_new_close_early_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_close_early_date,x_oex_timezone,x_timezone);
3489               x_new_close_changed_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_close_date_changed,x_oex_timezone,x_timezone);
3490           elsif (p_action_code = 'CLOSECHANGED') then
3491                  x_new_close_changed_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_close_date_changed,x_oex_timezone,x_timezone);
3492           elsif (p_action_code = 'CANCEL') then
3493                  x_new_cancel_date := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_cancel_date,x_oex_timezone,x_timezone);
3494           end if;
3495       ELSE
3496           x_new_auction_start_date := p_auction_start_date;
3497         x_new_auction_end_date := p_original_close_bidding_date;
3498           x_new_auction_preview_date := p_preview_date;
3499           if (p_action_code = 'CLOSEEARLY') then
3500              x_new_close_early_date := x_close_early_date;
3501           elsif (p_action_code = 'CLOSECHANGED') then
3502              x_new_close_changed_date := x_close_date_changed;
3503         end if;
3504         x_timezone := x_oex_timezone;
3505       END IF;
3506 
3507     x_timezone_disp := Get_TimeZone_Description(x_timezone, p_language_code);
3508       IF x_new_auction_preview_date IS NOT NULL THEN
3509          x_timezone1_disp := x_timezone_disp;
3510       ELSE
3511          x_timezone1_disp := null;
3512       END IF;
3513 
3514       -- Setup common attributes
3515       wf_Notification.setAttrDate(x_nid, 'AUCTION_START_DATE', x_new_auction_start_date);
3516       wf_Notification.setAttrDate(x_nid, 'AUCTION_END_DATE', x_new_auction_end_date);
3517       wf_Notification.SetAttrDate(x_nid, 'PREVIEW_DATE', x_new_auction_preview_date);
3518       wf_Notification.SetAttrText(x_nid, 'TP_TIME_ZONE1', x_timezone1_disp);
3519       wf_Notification.setAttrText(x_nid, '#HDR_NEG_TITLE', p_auction_title);
3520       wf_Notification.setAttrText(x_nid, '#HDR_NEG_NUMBER', p_doc_number_dsp);
3521       wf_Notification.setAttrText(x_nid, '#HDR_NEG_TP_NAME', wf_engine.GetItemAttrText (itemtype  => itemtype,
3522                                                                                         itemkey   => itemkey,
3523                                                                                         aname     =>'PREPARER_TP_NAME'));
3524 
3525       wf_Notification.setAttrText(x_nid, '#FROM_ROLE', l_origin_user_name);
3526 
3527       IF (x_new_auction_preview_date is null) THEN
3528             wf_Notification.SetAttrText(x_nid, 'PREVIEW_DATE_NOTSPECIFIED', PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
3529 
3530       ELSE
3531             wf_Notification.SetAttrText(x_nid, 'PREVIEW_DATE_NOTSPECIFIED', wf_engine.GetItemAttrText (itemtype => itemtype,
3532                                                                                                  itemkey  => itemkey,
3533                                                                                                  aname    => 'PREVIEW_DATE_NOTSPECIFIED'));
3534       END IF;
3535 
3536       if (p_action_code <> 'DISQUALIFY_BID') then
3537           wf_Notification.setAttrText(x_nid, 'BIDDER_TP_NAME', p_bidder_tp_name);
3538           wf_Notification.setAttrText(x_nid, 'BIDDER_TP_ADDRESS_NAME', p_vendor_site_code);
3539       end if;
3540 
3541       IF (p_action_code is not null and p_action_code = 'CLOSEEARLY') THEN
3542 
3543           wf_Notification.setAttrText(x_nid, 'TP_TIME_ZONE_AUCTION', x_timezone_disp);
3544           wf_Notification.SetAttrText(x_nid, 'AUCTION_CLOSE_EARLY_SUB', x_close_early_subject);
3545           wf_Notification.SetAttrDate(x_nid, 'AUCTION_CLOSE_EARLY_DATE', x_new_close_early_date);
3546           wf_Notification.SetAttrText(x_nid, 'CLOSECHANGED_REASON', wf_engine.GetItemAttrText (itemtype => itemtype,
3547                                                                                                itemkey  => itemkey,
3548                                                                                                aname => 'CLOSECHANGED_REASON'));
3549       ELSIF (p_action_code = 'CLOSECHANGED') then
3550 
3551           wf_Notification.setAttrText(x_nid, 'TP_TIME_ZONE_AUCTION', x_timezone_disp);
3552           wf_Notification.SetAttrText(x_nid, 'CLOSE_DATE_CHANGED_SUBJECT', x_close_changed_subject);
3553           wf_Notification.SetAttrDate(x_nid, 'CLOSE_DATE_CHANGED', x_new_close_changed_date);
3554           wf_Notification.SetAttrText(x_nid, 'NEG_SUMMARY_URL_SUPPLIER', x_neg_summary_url_supplier);
3555           wf_Notification.SetAttrNumber(x_nid, 'VENDOR_SITE_ID', p_vendor_site_id);
3556 
3557           IF p_change_type <> 1  THEN --i.e if it is 'NEGOTIATION_SHORTENED'
3558             wf_Notification.SetAttrText(x_nid, 'CLOSECHANGED_REASON', wf_engine.GetItemAttrText (itemtype => itemtype,
3559                                                                                                itemkey  => itemkey,
3560                                                                                                aname => 'CLOSECHANGED_REASON'));
3561           END IF;
3562 
3563       ELSIF (p_action_code = 'CANCEL') THEN
3564 
3565             wf_Notification.SetAttrText(x_nid, 'TP_TIME_ZONE',x_timezone_disp);
3566             wf_Notification.SetAttrDate(x_nid, 'CANCEL_DATE', x_new_cancel_date);
3567 
3568            IF (p_event_title is not null) THEN
3569                     wf_Notification.SetAttrText(x_nid, 'EVENT_TITLE', p_event_title);
3570                     wf_Notification.SetAttrText(x_nid, 'AUCTION_CANCELED_SUB',
3571                                                 getMessage('PON_AUC_WF_CANCEL_EVENT_SUB', x_msg_suffix,
3572                                        'DOC_NUMBER', p_doc_number_dsp,
3573                                      'AUCTION_TITLE', p_auction_title,
3574                                                  'EVENT_TITLE', p_event_title));
3575             ELSE
3576                     wf_Notification.SetAttrText(x_nid, 'AUCTION_CANCELED_SUB',
3577                                                 getMessage('PON_AUC_WF_AUC_CANCEL_SUB', x_msg_suffix,
3578                                                    'DOC_NUMBER', p_doc_number_dsp,
3579                                                'AUCTION_TITLE', p_auction_title));
3580             END IF;
3581 
3582           IF (empty_reason(x_cancel_reason) = 'N') then
3583               wf_Notification.SetAttrText(x_nid, 'CANCEL_REASON', x_cancel_reason);
3584           END IF;
3585 
3586        ELSIF (p_action_code = 'DISQUALIFY_BID') then
3587 
3588             wf_Notification.SetAttrText(x_nid, 'TP_TIME_ZONE', x_timezone_disp);
3589 
3590             -- convert the disqualify date to user's timezone
3591         x_new_disqualify_date :=  PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_disqualify_date,x_oex_timezone,x_timezone);
3592 
3593         wf_Notification.SetAttrDate(x_nid, 'DISQUALIFY_DATE', x_new_disqualify_date);
3594             wf_Notification.SetAttrText(x_nid, 'BID', x_bid_name);
3595           wf_Notification.SetAttrText ( x_nid, 'PON_WF_AUC_DSQ_OTH_SUB',
3596                                           getMessage('PON_WF_AUC_DSQ_OTH_SUB', x_msg_suffix,
3597                                             'DOC_NUMBER', p_doc_number_dsp,
3598                                            'AUCTION_TITLE', p_auction_title));
3599      END IF;
3600 
3601 END;
3602 
3603 
3604 PROCEDURE NEW_ROUND_BIDDERS_NOT_INVITED(p_itemtype    in varchar2, -- {
3605                                  p_itemkey    in varchar2,
3606                                      actid           in number,
3607                                      uncmode        in varchar2,
3608                                      resultout       out NOCOPY varchar2) IS
3609 
3610 -- Bug 3824928: Added outer join to get previous invited bidder that does
3611 -- not have a contact specified and did not place a bid or previous
3612 -- invited bidder that has a contact specified and did not place a bid.
3613 --
3614 -- This cursor now returns all the previous round bidders to send this notifn.
3615 CURSOR c_prev_round_bidders (x_doc_header_id_prev_round NUMBER, x_role_name VARCHAR2)
3616 IS
3617 -- First pick all the invited suppliers from bidding parties table.
3618 
3619 --
3620 -- First sql of the cursor can have multiple fnd_user entries for a given trading
3621 -- partner contact id and thus it has virtually no way to remove the rows with
3622 -- duplicate TPC Ids. We are assuming that only one fnd_user will be alive after
3623 -- a party merge
3624 --
3625 SELECT fu.user_name user_name,
3626        trading_partner_id   party_id,
3627        trading_partner_name party_name,
3628        DECODE(vendor_site_code, '-1', NULL, vendor_site_code) vendor_site_code,
3629        vendor_site_id
3630 FROM   pon_bidding_parties pbp,
3631      fnd_user fu
3632 WHERE  auction_header_id = x_doc_header_id_prev_round
3633 AND    fu.person_party_id = pbp.trading_partner_contact_id
3634 AND    nvl(fu.end_date, sysdate+1) > sysdate
3635 UNION
3636 -- Then pick all the additional contacts from bidding parties table.
3637 SELECT DISTINCT(wlur.user_name)  user_name,
3638        pbp.trading_partner_id   party_id,
3639        pbp.trading_partner_name party_name,
3640        DECODE(pbp.vendor_site_code, '-1', NULL, pbp.vendor_site_code) vendor_site_code,
3641        pbp.vendor_site_id
3642 FROM   pon_bidding_parties pbp,
3643      wf_local_user_roles wlur
3644 WHERE  pbp.auction_header_id = x_doc_header_id_prev_round
3645 AND    wlur.role_name = x_role_name
3646 AND    wlur.user_name = pbp.wf_user_name
3647 AND pbp.trading_partner_id is not null --leave out requested suppliers
3648 UNION
3649 -- Then pick all the suppliers who have bid.
3650 -- The responses for negotiation may or may not be invited.
3651 SELECT DISTINCT(wlur.user_name)  user_name,
3652        pbh.trading_partner_id    party_id,
3653      pbh.trading_partner_name  party_name,
3654        DECODE(pbh.vendor_site_code, '-1', NULL, pbh.vendor_site_code) vendor_site_code,
3655        pbh.vendor_site_id
3656 FROM   wf_local_user_roles wlur,
3657        pon_bid_headers pbh
3658 WHERE  wlur.role_name = x_role_name
3659 AND    x_doc_header_id_prev_round  = pbh.auction_header_id
3660 AND    wlur.user_name = pbh.trading_partner_contact_name(+);
3661 
3662 CURSOR c2_inv_list (x_doc_header_id NUMBER) IS
3663     select trading_partner_id,vendor_site_id
3664     from   pon_bidding_parties pbp
3665     where  auction_header_id = x_doc_header_id;
3666 
3667 x_itemtype                 VARCHAR2(20) := 'PONPBLSH';
3668 x_itemkey                 VARCHAR2(60);
3669 x_process_name              VARCHAR2(30) := 'NEW_ROUND_NOT_INVITED_BIDDERS';
3670 x_flag                    VARCHAR2(1);
3671 x_doc_header_id            NUMBER;
3672 x_doc_header_id_prev_round NUMBER;
3673 x_bidder_found             BOOLEAN;
3674 x_member                 BOOLEAN;
3675 x_new_member               BOOLEAN;
3676 x_user_name              VARCHAR2(100);
3677 x_bidder_name              VARCHAR2(440);
3678 x_contact_id               NUMBER;
3679 x_language_code            VARCHAR2(60);
3680 x_doctype_group_name       VARCHAR2(80);
3681 x_app                      VARCHAR2(20);
3682 x_msg_suffix            VARCHAR2(3) := '';
3683 x_progress               VARCHAR2(3);
3684 x_sequence             NUMBER;
3685 
3686 x_role_name              VARCHAR2(240);
3687 x_trading_partner_id     NUMBER;
3688 l_vendor_site_id        NUMBER;
3689 x_invitation_id           NUMBER;
3690 
3691 x_oex_header              VARCHAR2(2000);
3692 x_oex_footer              VARCHAR2(2000);
3693 x_status                  VARCHAR2(10);
3694 x_exception_msg           VARCHAR2(100);
3695 x_prev_supplier_name      VARCHAR2(240);
3696 x_prev_supplier_site_code PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
3697 x_prev_supplier_site_id   PO_VENDOR_SITES_ALL.VENDOR_SITE_ID%TYPE;
3698 x_prev_trading_partner_id NUMBER;
3699 x_bidder_username         VARCHAR2(60);
3700 x_oex_operation           VARCHAR2(640);
3701 x_auction_title           VARCHAR2(640);
3702 x_auction_owner_tp_name   VARCHAR2(640);
3703 x_tp_display_name         VARCHAR2(640);
3704 x_auction_contact_id      NUMBER;
3705 x_person_party_id         NUMBER;
3706 x_language             VARCHAR2(60) := null;
3707 x_territory_code          VARCHAR2(30) := 'AMERICA';
3708 x_doc_number_dsp          PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
3709 x_startdate               DATE;
3710 x_enddate                 DATE;
3711 x_auctioneer_user_name    PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_NAME%TYPE;
3712 x_add_contact_email       PON_BIDDING_PARTIES.ADDITIONAL_CONTACT_EMAIL%TYPE;
3713 x_preview_date       DATE;
3714 x_preview_date_notspec    VARCHAR2(240);
3715 x_timezone1_disp          VARCHAR2(240);
3716 x_newstarttime            DATE;
3717 x_newendtime              DATE;
3718 x_newpreviewtime          DATE;
3719 x_oex_timezone          VARCHAR2(80);
3720 x_timezone    VARCHAR2(80);
3721 x_timezone_disp VARCHAR2(240);
3722 x_staggered_closing_interval NUMBER;
3723 x_staggered_close_note   VARCHAR2(1000);
3724 
3725 l_origin_user_name       fnd_user.user_name%TYPE;
3726 
3727 -- bug 8613271
3728 x_supplier_sequence NUMBER;
3729 x_emd_received_flag VARCHAR2(1);
3730 x_refund_supplier_msg VARCHAR2(2000);
3731 
3732 
3733 BEGIN
3734 
3735     x_doc_header_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
3736                                              itemkey  => p_itemkey,
3737                                              aname    => 'AUCTION_ID');
3738 
3739     -- Bug 8992789
3740     IF (IS_INTERNAL_ONLY(x_doc_header_id)) THEN
3741       RETURN;
3742     END IF;
3743 
3744     l_origin_user_name := wf_engine.GetItemAttrText (itemtype => p_itemtype,
3745                                                 itemkey  => p_itemkey,
3746                                                 aname    => 'ORIGIN_USER_NAME');
3747 
3748     x_doctype_group_name := wf_engine.GetItemAttrText (itemtype => p_itemtype,
3749                                                        itemkey  => p_itemkey,
3750                                                       aname    => 'DOC_INTERNAL_NAME');
3751 
3752     x_startdate := wf_engine.GetItemAttrDate (itemtype => p_itemtype,
3753                                       itemkey  => p_itemkey,
3754                                     aname    => 'AUCTION_START_DATE');
3755 
3756   x_enddate   := wf_engine.GetItemAttrDate (itemtype => p_itemtype,
3757                                     itemkey  => p_itemkey,
3758                                     aname    => 'AUCTION_END_DATE');
3759 
3760 --    x_auctioneer_user_name := wf_engine.GetItemAttrText (itemtype => p_itemtype,
3761 --                                                     itemkey  => p_itemkey,
3762 --                                                       aname    => 'PREPARER_TP_CONTACT_NAME');
3763 
3764     x_preview_date := wf_engine.GetItemAttrDate (itemtype   => p_itemtype,
3765                                                  itemkey    => p_itemkey,
3766                                                  aname      => 'PREVIEW_DATE');
3767 
3768     select auction_header_id_prev_round, trading_partner_contact_name,
3769            staggered_closing_interval
3770     into x_doc_header_id_prev_round, x_auctioneer_user_name,
3771          x_staggered_closing_interval
3772     from pon_auction_headers_all where auction_header_id = x_doc_header_id;
3773 
3774     select wf_role_name
3775     into x_role_name
3776     from pon_auction_headers_all
3777     where auction_header_id = x_doc_header_id_prev_round;
3778 
3779     FOR prevBidder IN c_prev_round_bidders(x_doc_header_id_prev_round, x_role_name) LOOP
3780 
3781   x_bidder_found := false;
3782   x_prev_supplier_name := prevBidder.party_name;
3783     x_prev_supplier_site_code := prevBidder.vendor_site_code;
3784     x_prev_supplier_site_id := prevBidder.vendor_site_id;
3785   x_prev_trading_partner_id := prevBidder.party_id;
3786 
3787   open c2_inv_list(x_doc_header_id);
3788   LOOP
3789 
3790       fetch c2_inv_list into  x_trading_partner_id, l_vendor_site_id;
3791 
3792       if c2_inv_list%NOTFOUND then
3793     exit;
3794       end if;
3795 
3796         -- Check if the combination of Trading-Partner-Id and Vendor-Site-Id
3797         -- are not existing in the current round.
3798     if (x_prev_trading_partner_id = x_trading_partner_id AND
3799             x_prev_supplier_site_id = l_vendor_site_id  ) then
3800       x_bidder_found := true;
3801       exit;
3802     end if;
3803 
3804       END LOOP;
3805 
3806   if (NOT x_bidder_found) then
3807 
3808       -- this bidder has not been invited to the new round
3809       -- Get next value in sequence for itemkey
3810 
3811       SELECT pon_auction_wf_publish_s.nextval
3812       INTO   x_sequence
3813       FROM   dual;
3814 
3815       x_itemkey := (p_itemkey||'-'||to_char(x_sequence));
3816 
3817       wf_engine.CreateProcess(itemtype => x_itemtype,
3818                               itemkey  => x_itemkey,
3819                               process  => x_process_name);
3820 
3821       --
3822       -- Set all the item attributes
3823       --
3824 
3825         wf_engine.SetItemAttrDate   (itemtype   => x_itemtype,
3826                                    itemkey    => x_itemkey,
3827                                    aname      => 'AUCTION_START_DATE',
3828                                    avalue     => x_startdate);
3829 
3830         wf_engine.SetItemAttrDate   (itemtype   => x_itemtype,
3831                                    itemkey    => x_itemkey,
3832                                    aname      => 'AUCTION_END_DATE',
3833                                    avalue     => x_enddate);
3834 
3835         wf_engine.SetItemAttrDate   (itemtype   => x_itemtype,
3836                                    itemkey    => x_itemkey,
3837                                    aname      => 'PREVIEW_DATE',
3838                                    avalue     => x_preview_date);
3839 
3840         wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
3841                                    itemkey    => x_itemkey,
3842                                    aname      => 'PREPARER_TP_CONTACT_NAME',
3843                                    avalue     => x_auctioneer_user_name);
3844 
3845         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3846                                    itemkey    => x_itemkey,
3847                                    aname      => 'BIDDER_TP_NAME',
3848                                    avalue     => x_prev_supplier_name);
3849 
3850         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3851                                    itemkey    => x_itemkey,
3852                                    aname      => 'BIDDER_TP_ADDRESS_NAME',
3853                                    avalue     => x_prev_supplier_site_code);
3854 
3855         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3856                              itemkey    => x_itemkey,
3857                              aname      => 'ORIGIN_USER_NAME',
3858                              avalue     => l_origin_user_name);
3859 
3860 
3861       wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
3862                                    itemkey    => x_itemkey,
3863                                    aname      => 'AUCTION_ID',
3864                                    avalue     => x_doc_header_id); /* using auction_id instead of
3865                                                                        auction_number as a standard
3866                                                                        across item types */
3867 
3868         x_doc_number_dsp := wf_engine.GetItemAttrText (itemtype => p_itemtype,
3869                                                  itemkey  => p_itemkey,
3870                                                  aname    => 'DOC_NUMBER');
3871 
3872       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3873                                  itemkey    => x_itemkey,
3874                                  aname      => 'DOC_NUMBER',
3875                                  avalue     => x_doc_number_dsp);
3876 
3877       x_auction_title := wf_engine.GetItemAttrText (itemtype => p_itemtype,
3878                                         itemkey  => p_itemkey,
3879                                         aname    => 'AUCTION_TITLE');
3880 
3881 
3882       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3883                                  itemkey    => x_itemkey,
3884                                  aname      => 'AUCTION_TITLE',
3885                                  avalue     => replaceHtmlChars(x_auction_title));
3886 
3887       x_auction_owner_tp_name := wf_engine.GetItemAttrText (itemtype => p_itemtype,
3888                                           itemkey  => p_itemkey,
3889                                           aname    => 'PREPARER_TP_NAME');
3890 
3891       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3892                                  itemkey    => x_itemkey,
3893                                  aname      => 'PREPARER_TP_NAME',
3894                                  avalue     => x_auction_owner_tp_name);
3895 
3896       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3897                                itemkey    => x_itemkey,
3898                                aname      => 'DOC_INTERNAL_NAME',
3899                                avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
3900                                                                           itemkey  => p_itemkey,
3901                                                                           aname    => 'DOC_INTERNAL_NAME'));
3902 
3903 
3904             BEGIN
3905                  x_staggered_close_note := NULL;
3906                  IF x_staggered_closing_interval IS NOT NULL THEN
3907                       x_staggered_close_note := wf_core.newline || wf_core.newline ||
3908                                                 getMessage('PON_STAGGERED_CLOSE_NOTIF_MSG') ||
3909                                                 wf_core.newline || wf_core.newline;
3910                  END IF;
3911                  wf_engine.SetItemAttrText( itemtype => x_itemtype,
3912                                             itemkey  => x_itemkey,
3913                                             aname    => 'STAGGERED_CLOSE_NOTE',
3914                                             avalue   => x_staggered_close_note);
3915             EXCEPTION
3916                  WHEN OTHERS THEN
3917                         NULL;
3918             END;
3919 
3920             begin
3921 
3922               wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
3923                                                itemkey    => x_itemkey,
3924                                                aname      => '#WFM_HTMLAGENT',
3925                                                avalue     => pon_wf_utl_pkg.get_base_external_supplier_url);
3926             exception when others then
3927               null;
3928             end;
3929 
3930         -- Use the language of the user to send the notification.
3931 
3932         x_bidder_username := prevBidder.user_name;
3933 
3934         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
3935                                  itemkey    => x_itemkey,
3936                                  aname      => 'BIDDER_TP_CONTACT_NAME',
3937                                  avalue     => x_bidder_username);
3938 
3939 
3940         IF x_bidder_username is not null THEN
3941          PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(x_bidder_username,x_language_code);
3942       END IF;
3943 
3944         -- Bug 3824928 Added code below
3945         begin
3946               if(x_language_code = null) then
3947                            select language into x_language_code
3948                            from wf_users where name = x_bidder_username;
3949               end if;
3950         exception
3951               when others then
3952                    x_language_code := null;
3953 
3954         end;
3955 
3956         x_oex_timezone := Get_Oex_Time_Zone;
3957 
3958         --
3959         -- Get the user's time zone
3960         --
3961       x_timezone := Get_Time_Zone(x_bidder_username);
3962 
3963         --
3964         -- Make sure that it is a valid time zone
3965         --
3966 
3967         IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 0) THEN
3968           x_timezone := x_oex_timezone;
3969         END IF;
3970 
3971         -- Create new timezone
3972         IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
3973             x_newstarttime   := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_startdate,x_oex_timezone,x_timezone);
3974             x_newendtime     := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_enddate,x_oex_timezone,x_timezone);
3975             x_newpreviewtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone);
3976         ELSE
3977             x_newstarttime   := x_startdate;
3978           x_newendtime     := x_enddate;
3979             x_newpreviewtime := x_preview_date;
3980         END IF;
3981 
3982         x_timezone_disp := Get_TimeZone_Description(x_timezone, x_language_code);
3983 
3984         IF (x_preview_date IS NULL) THEN
3985             x_timezone1_disp := null;
3986         ELSE
3987             x_timezone1_disp := x_timezone_disp;
3988         END IF;
3989 
3990       wf_engine.SetItemAttrDate   (itemtype   => x_itemtype,
3991                                    itemkey    => x_itemkey,
3992                                    aname      => 'AUCTION_START_DATE_TZ',
3993                                    avalue     => x_newstarttime);
3994 
3995         wf_engine.SetItemAttrDate   (itemtype   => x_itemtype,
3996                                    itemkey    => x_itemkey,
3997                                    aname      => 'AUCTION_END_DATE_TZ',
3998                                    avalue     => x_newendtime);
3999 
4000         wf_engine.SetItemAttrDate   (itemtype   => x_itemtype,
4001                                    itemkey    => x_itemkey,
4002                                    aname      => 'PREVIEW_DATE_TZ',
4003                                    avalue     => x_newpreviewtime);
4004 
4005 
4006         -- IF (x_add_contact_email is not null) then we need to send a notification
4007         -- to the additional contact as well (Bug 3824928: this can be deleted. We don't need to check separately
4008         -- for additional contact as prev_round_bidders cursor will return additional contact even when he is
4009         -- not associated to a tp contact id (new outer joins added to the query)
4010 
4011       x_bidder_name := null;
4012           x_member := true;
4013 
4014       begin
4015         -- Bug 3824928: Deleted IF condition that tested if trading_partner_id is not null
4016             -- since the condition is always true.
4017       select party_name into x_bidder_name
4018       from hz_parties where party_id = x_prev_trading_partner_id;
4019 
4020       exception
4021     when others then
4022     null;
4023       end;
4024 
4025       if (x_bidder_name is null or x_bidder_name = '') then
4026         begin
4027     select party_name into x_bidder_name
4028     from hz_parties where
4029     party_id = (select person_party_id from fnd_user where user_name = prevBidder.user_name);
4030         exception
4031     when others then
4032     x_bidder_name := prevBidder.user_name;
4033         end;
4034       end if;
4035 
4036       if (x_bidder_name is null or x_bidder_name = '') then
4037     x_bidder_name := prevBidder.user_name;
4038       end if;
4039 
4040       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
4041                            itemkey    => x_itemkey,
4042                            aname      => 'TP_DISPLAY_NAME',
4043                            avalue     => x_bidder_name);
4044 
4045       x_tp_display_name := x_bidder_name;
4046 
4047         -- Set the userenv language so the message token (attribute) values that we retrieve
4048       -- using the getMessage call return the message in the correct language => x_language_code
4049 
4050      SET_SESSION_LANGUAGE(null, x_language_code);
4051 
4052      --Bug 6472383 : Shifted the setting of preview date to this place so that the recipient's language, instead
4053      --of the sender's language is taken into account when setting the preview date to 'Not Specified'
4054 
4055      IF (x_newpreviewtime is not null) THEN
4056         wf_engine.SetItemAttrDate (itemtype        => x_itemtype,
4057                                                    itemkey        => x_itemkey,
4058                                                    aname        => 'PREVIEW_DATE_TZ',
4059                                                    avalue        => x_newpreviewtime);
4060 
4061         wf_engine.SetItemAttrText (itemtype        => x_itemtype,
4062                                                    itemkey        => x_itemkey,
4063                                                    aname        => 'TP_TIME_ZONE1',
4064                                                    avalue        => x_timezone1_disp);
4065 
4066         wf_engine.SetItemAttrText (itemtype        => x_itemtype,
4067                                                    itemkey        => x_itemkey,
4068                                                    aname        => 'PREVIEW_DATE_NOTSPECIFIED',
4069                                                    avalue        => null);
4070      ELSE
4071         wf_engine.SetItemAttrDate (itemtype        => x_itemtype,
4072                                                    itemkey        => x_itemkey,
4073                                                    aname        => 'PREVIEW_DATE_TZ',
4074                                                    avalue        => null);
4075 
4076         wf_engine.SetItemAttrText (itemtype        => x_itemtype,
4077                                                     itemkey        => x_itemkey,
4078                                                    aname        => 'TP_TIME_ZONE1',
4079                                                     avalue        => x_timezone1_disp);
4080 
4081         wf_engine.SetItemAttrText (itemtype        => x_itemtype,
4082                                                    itemkey        => x_itemkey,
4083                                                    aname        => 'PREVIEW_DATE_NOTSPECIFIED',
4084                                                    avalue        => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
4085       END IF;
4086 
4087       x_msg_suffix := GET_MESSAGE_SUFFIX (x_doctype_group_name);
4088 
4089      /*added for bug 8613271
4090      * notification sent to non invited suppliers should
4091      * contain message that previously paid EMD amount will
4092      * be repaid.
4093      */
4094       BEGIN
4095           x_refund_supplier_msg :=  getMessage('PON_EMD_REFUND_N_RND_NOINV');
4096 
4097     SELECT sequence INTO x_supplier_sequence FROM pon_bidding_parties
4098     WHERE auction_header_id = x_doc_header_id_prev_round
4099     AND TRADING_PARTNER_ID = x_prev_trading_partner_id
4100     AND vendor_site_id = x_prev_supplier_site_id;
4101 
4102 
4103     SELECT 'Y' INTO x_emd_received_flag FROM pon_emd_transactions
4104     WHERE auction_header_id = x_doc_header_id_prev_round
4105     AND SUPPLIER_SEQUENCE = x_supplier_sequence
4106      AND STATUS_LOOKUP_CODE = 'RECEIVED';
4107 
4108     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
4109                                  itemkey    => x_itemkey,
4110                                  aname      => 'REFUND_SUPPLIER',
4111                                  avalue     => x_refund_supplier_msg);
4112     EXCEPTION
4113     WHEN OTHERS THEN
4114       NULL;
4115     END;
4116 
4117 
4118   --end of change for bug 8613271
4119 
4120 
4121       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
4122                                  itemkey    => x_itemkey,
4123                                  aname      => 'NON_INVITE_NEW_ROUND_START_SUB',
4124                                  avalue     => getMessage('PON_AUC_WF_PUB_NEWRND_NI_S', x_msg_suffix,
4125                                                             'DOC_NUMBER', x_doc_number_dsp,
4126                                       'AUCTION_TITLE', x_auction_title));
4127 
4128       --Bug 8446265 Modifications
4129             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
4130                                itemkey    => x_itemkey,
4131                                aname      => 'PON_NON_INV_NEW_RND_START_BODY',
4132                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_PON_ARI_UNINVITED_BODY/'||x_itemtype ||':' ||x_itemkey
4133                                );
4134 
4135 
4136     -- Bug 4295915: Set the  workflow owner
4137             wf_engine.SetItemOwner(itemtype => x_itemtype,
4138                                    itemkey  => x_itemkey,
4139                                    owner    => fnd_global.user_name);
4140 
4141       wf_engine.StartProcess(itemtype => x_itemtype,
4142                              itemkey  => x_itemkey);
4143         end if;
4144 
4145   close c2_inv_list;
4146 
4147     END LOOP;
4148 
4149     UNSET_SESSION_LANGUAGE;
4150 
4151 END;  -- NEW_ROUND_BIDDERS_NOT_INVITED }
4152 
4153 
4154 
4155 PROCEDURE REGISTERED_BIDDER(itemtype    in varchar2,
4156                  itemkey    in varchar2,
4157                             actid           in number,
4158                             uncmode    in varchar2,
4159                             resultout       out NOCOPY varchar2) IS
4160 
4161 x_flag   VARCHAR2(1);
4162 BEGIN
4163 
4164     x_flag := wf_engine.GetItemAttrText (itemtype => itemtype,
4165                                          itemkey  => itemkey,
4166                                          aname    => 'REGISTERED');
4167 
4168 
4169     IF (x_flag = 'Y') THEN
4170   resultout := 'Y';
4171     ELSE
4172   resultout := 'N';
4173 
4174     END IF;
4175 
4176 END;
4177 
4178 PROCEDURE CREATE_LOCAL_ROLES(   itemtype  in varchar2,
4179         itemkey    in varchar2,
4180                                 actid           in number,
4181                                 uncmode          in varchar2,
4182                                 resultout       out NOCOPY varchar2) IS
4183 
4184 x_role_name      VARCHAR2(30);
4185 x_user_name      VARCHAR2(100);
4186 x_role_display_name    VARCHAR2(30);
4187 x_user_display_name    VARCHAR2(30);
4188 x_note_to_new_bidder    VARCHAR2(2000);
4189 x_auction_header_id      NUMBER;
4190 x_progress      VARCHAR2(3);
4191 x_sequence      NUMBER;
4192 x_user_orig_system    VARCHAR2(30);
4193 x_user_orig_system_id    NUMBER;
4194 x_role_orig_system    VARCHAR2(30) := 'WF_LOCAL_ROLES';
4195 x_role_orig_system_id    NUMBER := 0;
4196 x_person_party_id               NUMBER;
4197 
4198 BEGIN
4199     x_progress := '010';
4200 
4201     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
4202                                              itemkey  => itemkey,
4203                                              aname    => 'AUCTION_ID');
4204 
4205     x_progress := '020';
4206 
4207     --
4208     -- Create a role for all bidders in this auction.
4209     --
4210 
4211            SELECT pon_auction_wf_role_s.nextval
4212     INTO   x_sequence
4213     FROM   dual;
4214 
4215     x_role_name := ('WF_PON_ROLE_'||to_char(x_auction_header_id)||'_'||to_char(x_sequence));
4216 
4217     x_progress := '021';
4218 
4219     WF_DIRECTORY.CreateAdHocRole(x_role_name,
4220          x_role_name,
4221                'AMERICAN',
4222                'AMERICA',
4223          'Oracle Exchange Bidder '||to_char(x_auction_header_id),
4224                'MAILHTML',
4225                null,
4226                null,
4227                null,
4228                'ACTIVE',
4229          null);
4230 
4231     UPDATE pon_auction_headers_all set
4232     wf_role_name = x_role_name
4233     WHERE auction_header_id = x_auction_header_id;
4234 
4235     wf_engine.SetItemAttrText (itemtype   => itemtype,
4236                                 itemkey    => itemkey,
4237                                aname      => 'NEW_BIDDER_ROLE',
4238                          avalue     => x_role_name);
4239    x_progress := '030';
4240 
4241 END;
4242 
4243 
4244 PROCEDURE POPULATE_ROLE_WITH_SUPPLIERS (itemtype         IN VARCHAR2,
4245                                         itemkey          IN VARCHAR2,
4246                                         actid            IN NUMBER,
4247                                         uncmode          IN VARCHAR2,
4248                                         resultout        OUT NOCOPY VARCHAR2) IS
4249 
4250 x_role_name            VARCHAR2(30);
4251 x_prev_doc_role_name       VARCHAR2(30);
4252 x_user_name            VARCHAR2(100);
4253 x_auction_header_id    NUMBER;
4254 x_progress             VARCHAR2(3);
4255 
4256 l_users   WF_DIRECTORY.UserTable;
4257 
4258 CURSOR suppliers IS
4259     select user_name
4260     from   wf_user_roles
4261     where  role_name = x_prev_doc_role_name;
4262 
4263 BEGIN
4264 
4265     x_progress := '010';
4266 
4267     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
4268                                              itemkey  => itemkey,
4269                                              aname    => 'AUCTION_ID');
4270 
4271     x_progress := '20';
4272 
4273     select wf_role_name
4274     into   x_prev_doc_role_name
4275     from   pon_auction_headers_all
4276     where  auction_header_id = (select auction_header_id_prev_amend
4277                                 from   pon_auction_headers_all
4278                                 where  auction_header_id = x_auction_header_id);
4279 
4280 
4281     x_progress := '30';
4282 
4283     x_role_name := wf_engine.GetItemAttrText (itemtype   => itemtype,
4284                                               itemkey    => itemkey,
4285                                               aname      => 'NEW_BIDDER_ROLE');
4286 
4287     x_progress := '40';
4288 
4289     FOR supplier IN suppliers LOOP
4290 
4291         x_user_name := supplier.user_name;
4292 
4293         /*WF_DIRECTORY.AddUsersToAdHocRole(x_role_name,
4294                                          x_user_name);*/
4295 		-- Modified from  AddUsersToAdHocRole to AddUsersToAdHocRole2 for bug 11067311
4296  	    if (x_user_name is NOT NULL) then
4297  	        string_to_userTable(x_user_name, l_users);
4298  	        WF_DIRECTORY.AddUsersToAdHocRole2(x_role_name,
4299 												l_users);
4300  	    end if;
4301 
4302     END LOOP;
4303 
4304     x_progress := '50';
4305 
4306 END;
4307 
4308 
4309 PROCEDURE POPULATE_ROLE_WITH_INVITEES (itemtype    IN VARCHAR2,
4310                     itemkey    IN VARCHAR2,
4311                     actid             IN NUMBER,
4312                     uncmode          IN VARCHAR2,
4313                     resultout         OUT NOCOPY VARCHAR2) IS
4314 
4315 x_role_name      VARCHAR2(30);
4316 x_user_name      VARCHAR2(100);
4317 x_role_display_name    VARCHAR2(30);
4318 x_user_display_name    VARCHAR2(30);
4319 x_note_to_new_bidder    VARCHAR2(2000);
4320 x_auction_header_id    NUMBER;
4321 x_progress      VARCHAR2(10);
4322 x_sequence      NUMBER;
4323 x_user_orig_system    VARCHAR2(30);
4324 x_user_orig_system_id    NUMBER;
4325 x_role_orig_system    VARCHAR2(30) := 'WF_LOCAL_ROLES';
4326 x_role_orig_system_id    NUMBER := 0;
4327 x_person_party_id               NUMBER;
4328 x_bidder_count      NUMBER;
4329 x_contact_notif_pref    VARCHAR2(4000);
4330 x_contact_lang      VARCHAR2(4000);
4331 x_contact_territory    VARCHAR2(4000);
4332 
4333 x_auctioneer_user_name         VARCHAR2(100);
4334 x_language_code                VARCHAR2(30) := null;
4335 x_nls_language                 VARCHAR2(60) := 'AMERICAN';
4336 x_territory_code               VARCHAR2(30) := 'AMERICA';
4337 x_nls_territory                VARCHAR2(60);
4338 
4339 l_auctioneer_nls_language      fnd_languages.nls_language%TYPE;
4340 l_auctioneer_nls_territory     fnd_territories.nls_territory%TYPE;
4341 l_users WF_DIRECTORY.UserTable;
4342 
4343 CURSOR new_bidders IS
4344     select pbp.trading_partner_contact_name,
4345      pbp.trading_partner_contact_id,
4346      pbp.trading_partner_name,
4347      pbp.trading_partner_id,
4348      pbp.additional_contact_email,
4349            pbp.vendor_site_id,
4350            pbp.requested_supplier_id,
4351            pbp.requested_supplier_contact_id,
4352            pcr.email_address rs_contact_email
4353     from pon_bidding_parties pbp, pos_contact_requests pcr
4354     where pbp.auction_header_id = x_auction_header_id
4355     and pbp.requested_supplier_contact_id = pcr.contact_request_id (+);
4356 
4357 CURSOR c_user_name IS
4358     select user_name
4359   from fnd_user where person_party_id = (select   trading_partner_contact_id
4360                                        from pon_auction_headers_all
4361                                        where auction_header_id = x_auction_header_id)
4362         and nvl(end_date,sysdate+1) > sysdate
4363         and rownum = 1;
4364 
4365 BEGIN
4366     x_progress := '010';
4367     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
4368                                              itemkey  => itemkey,
4369                                              aname    => 'AUCTION_ID');
4370 
4371     x_progress := '020';
4372     x_role_name := wf_engine.GetItemAttrText (itemtype   => itemtype,
4373                                           itemkey    => itemkey,
4374                                        aname      => 'NEW_BIDDER_ROLE');
4375     x_progress := '021';
4376 
4377     OPEN c_user_name;
4378     FETCH c_user_name
4379     INTO x_auctioneer_user_name;
4380     CLOSE c_user_name;
4381 
4382     IF x_auctioneer_user_name is not null THEN
4383        PON_PROFILE_UTIL_PKG.GET_WF_PREFERENCES(x_auctioneer_user_name,x_language_code,x_territory_code);
4384     END IF;
4385 
4386    -- Bug 3824928: Store the auctioneer's language and territory in new
4387    -- variables so that they can be used later.
4388 
4389     select NLS_LANGUAGE into l_auctioneer_nls_language
4390     from fnd_languages
4391     where language_code = x_language_code;
4392 
4393     select nls_territory into l_auctioneer_nls_territory
4394     from   fnd_territories
4395     where  territory_code = x_territory_code;
4396 
4397     FOR bidder IN new_bidders LOOP
4398 
4399         -- Bug 3824928: Handle the case where the contact is present (removed earlier
4400         -- if-else)
4401 
4402      IF bidder.trading_partner_contact_id IS NOT NULL  -- {
4403      THEN
4404 
4405     x_person_party_id := bidder.trading_partner_contact_id;
4406 
4407       BEGIN
4408         select user_name
4409       into x_user_name
4410       from fnd_user where person_party_id = x_person_party_id
4411             and nvl(end_date, sysdate+1) > sysdate;
4412       EXCEPTION
4413         when too_many_rows then
4414            if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
4415                if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
4416                          fnd_log.string(log_level => fnd_log.level_unexpected,
4417                                         module    => 'pon.plsql.pon_auction_pkg.populate_role_with_invitees',
4418                                         message   => 'Multiple Users found for person_party_id:'|| x_person_party_id);
4419                end if;
4420           end if;
4421 
4422            select user_name
4423            into x_user_name
4424            from fnd_user
4425            where person_party_id = x_person_party_id
4426            and nvl(end_date, sysdate+1) > sysdate
4427            and rownum=1;
4428 
4429       END;
4430 
4431 
4432     x_user_orig_system := 'FND_USR';
4433           begin
4434             select to_char(user_id)
4435             into x_user_orig_system_id
4436             from fnd_user
4437             where user_name = x_user_name;
4438           exception when others then
4439         x_user_orig_system_id := 0;
4440           end;
4441 
4442   select count(*)
4443   into x_bidder_count
4444   from wf_local_user_roles
4445   where role_name = x_role_name
4446   and user_name = x_user_name;
4447 
4448   if (x_bidder_count < 1) then
4449   -- Added for the bug#8847938 to remove the space as delimitter in user name
4450   if (x_user_name is NOT NULL) then
4451  	  string_to_userTable(x_user_name, l_users);
4452 
4453   /*WF_DIRECTORY.AddUsersToAdHocRole(x_role_name,
4454                  x_user_name);*/
4455 
4456 	WF_DIRECTORY.AddUsersToAdHocRole2(x_role_name,
4457  	                               l_users);
4458  	     end if;
4459 
4460   end if;
4461    END IF;-- end IF bidder.trading_partner_contact_id IS NOT NULL }
4462    IF (bidder.additional_contact_email IS NOT NULL) THEN
4463 
4464     -- add new user to local users and also add to the role.
4465 
4466     -- Bug 3824928: If trading partner contact is not there then prevent
4467     -- this SELECT from erroring out
4468     -- The steps below try to set up the user for the additional contact
4469     -- email so that they have the same settings as the existing contact.
4470     -- However, if the row in pon_bidding_parties does not have a contact,
4471     -- then the additional contact user inherits the settings of the
4472     -- auctioneer
4473 
4474     IF bidder.trading_partner_contact_id IS NOT NULL  --{
4475     THEN  --<
4476 
4477 
4478     select NOTIFICATION_PREFERENCE, LANGUAGE, TERRITORY
4479     into   x_contact_notif_pref, x_contact_lang, x_contact_territory
4480     from wf_users where name = x_user_name;
4481 
4482     -- Get NLS_LANGUAGE and NLS_TERRITORY for the user corresponding to additional contact
4483 
4484     IF x_user_name is not null THEN
4485              PON_PROFILE_UTIL_PKG.GET_WF_PREFERENCES(x_user_name ,x_language_code,x_territory_code);
4486           END IF;
4487 
4488          x_progress := '021';
4489 
4490 
4491          begin
4492          select NLS_LANGUAGE into x_nls_language
4493          from fnd_languages
4494          where language_code = x_language_code;
4495 
4496          select nls_territory into x_nls_territory
4497          from   fnd_territories
4498          where  territory_code = x_territory_code;
4499        exception
4500         when others then
4501              x_nls_language := 'AMERICAN';
4502              x_nls_territory := 'AMERICA';
4503           end;
4504 
4505      ELSE
4506       -- Get auctioneer's settings
4507 
4508                 x_nls_language := l_auctioneer_nls_language;
4509                 x_nls_territory:= l_auctioneer_nls_territory;
4510      END IF;--}
4511 
4512      SELECT pon_auction_wf_bidder_s.nextval
4513              INTO   x_sequence
4514              FROM   dual;
4515 
4516       x_user_name := ('WF_PON_ADD_USER_'||to_char(x_sequence));
4517 
4518        x_progress := '022';
4519 
4520        -- Create an adhoc user for the additional contact
4521 
4522     WF_DIRECTORY.CreateAdHocUser(x_user_name,
4523                      bidder.additional_contact_email,
4524                      x_nls_language,
4525                      x_nls_territory,
4526                      'Oracle Exchange Additional Bidder '||to_char(x_auction_header_id),
4527                      'MAILHTML',
4528                      bidder.additional_contact_email,
4529                      null,
4530                      'ACTIVE',
4531                      null);
4532     x_progress := '023';
4533     UPDATE pon_bidding_parties set
4534         wf_user_name = x_user_name
4535     WHERE auction_header_id = x_auction_header_id
4536     AND   trading_partner_id = bidder.trading_partner_id
4537       AND   vendor_site_id     = bidder.vendor_site_id;
4538 
4539     -- Also insert into the role
4540  -- Added for the bug#8847938 to remove the space as delimitter in user name
4541     /*WF_DIRECTORY.AddUsersToAdHocRole(x_role_name,
4542                    x_user_name);*/
4543       if (x_user_name is NOT NULL) then
4544  	       string_to_userTable(x_user_name, l_users);
4545 
4546  	    WF_DIRECTORY.AddUsersToAdHocRole2(x_role_name,
4547  	                                          l_users);
4548  	   end if;
4549   end if;  -- (bidder.additional_contact_email IS NOT NULL)
4550 
4551     -- add requested suppliers
4552     if (bidder.trading_partner_id is null and
4553         bidder.requested_supplier_contact_id is not null) then
4554    -- {
4555       -- Get auctioneer's settings
4556       x_nls_language := l_auctioneer_nls_language;
4557       x_nls_territory:= l_auctioneer_nls_territory;
4558 
4559       -- Get next bidder from sequence
4560       SELECT pon_auction_wf_bidder_s.nextval
4561       INTO x_sequence
4562       FROM dual;
4563 
4564       x_user_name := ('WF_PON_ADD_USER_'||to_char(x_sequence));
4565       x_progress := '022_REQ';
4566 
4567       -- Create an adhoc user for the requested_supplier
4568       WF_DIRECTORY.CreateAdHocUser(x_user_name,
4569                                  x_user_name,
4570                                  x_nls_language,
4571                                  x_nls_territory,
4572                                  'Oracle Exchange Requested Bidder'||to_char(x_auction_header_id),
4573                                  'MAILHTML',
4574                                  bidder.rs_contact_email,
4575                                  null,
4576                                  'ACTIVE',
4577                                  null);
4578       x_progress := '023_REQ';
4579 
4580       -- record wf_user_name in pon_bidding_parties
4581       UPDATE pon_bidding_parties
4582          set wf_user_name = x_user_name
4583        WHERE auction_header_id = x_auction_header_id
4584          AND requested_supplier_id = bidder.requested_supplier_id;
4585 
4586       x_progress := '024_REQ';
4587 
4588       -- Also insert into the role
4589       --WF_DIRECTORY.AddUsersToAdHocRole(x_role_name, x_user_name);
4590 
4591 	   -- Added for the bug#8847938 to remove the space as delimitter in user name
4592  	    if (x_user_name is NOT NULL) then
4593  	            string_to_userTable(x_user_name, l_users);
4594 
4595  	     WF_DIRECTORY.AddUsersToAdHocRole2(x_role_name,
4596  	                                     l_users);
4597  	     end if;
4598 
4599     end if; --} tp_id == null and requested_supplier_contact_id != null
4600 
4601    END LOOP;
4602 
4603    x_progress := '030';
4604 
4605 END;
4606 
4607 
4608 
4609 PROCEDURE REACHED_AUCTION_START_DATE (  itemtype  in varchar2,
4610           itemkey    in varchar2,
4611                                   actid           in number,
4612                                   uncmode          in varchar2,
4613                                   resultout       out NOCOPY varchar2) IS
4614 x_start_date  DATE;
4615 x_progress  VARCHAR2(3);
4616 x_reached_date  VARCHAR2(1) := 'N';
4617 
4618 BEGIN
4619 
4620     x_progress := '010';
4621 
4622     x_start_date := wf_engine.GetItemAttrDate (itemtype => itemtype,
4623                                                itemkey  => itemkey,
4624                                                aname    => 'AUCTION_NOTIFICATION_DATE');
4625     x_progress := '020';
4626 
4627     IF x_start_date <= SYSDATE
4628     THEN
4629        x_reached_date := 'Y';
4630     END IF;
4631 
4632     x_progress := '030';
4633 
4634     IF (x_reached_date = 'Y') THEN
4635   resultout := 'Y';
4636     ELSE
4637   resultout := 'N';
4638 
4639     END IF;
4640 
4641 END;
4642 
4643 PROCEDURE REACHED_AUCTION_END_DATE (  itemtype  in varchar2,
4644           itemkey    in varchar2,
4645                                   actid           in number,
4646                                   uncmode          in varchar2,
4647                                   resultout       out NOCOPY varchar2) IS
4648 
4649 x_end_date  DATE;
4650 x_progress  VARCHAR2(3);
4651 x_reached_date  VARCHAR2(1) := 'N';
4652 
4653 BEGIN
4654 
4655     x_progress := '010';
4656 
4657     x_end_date := wf_engine.GetItemAttrDate (itemtype => itemtype,
4658                                                itemkey  => itemkey,
4659                                                aname    => 'AUCTION_END_DATE');
4660     x_progress := '020';
4661 
4662     IF x_reached_date <= SYSDATE
4663     THEN
4664       x_reached_date := 'Y';
4665     END IF;
4666 
4667     x_progress := '030';
4668 
4669     IF (x_reached_date = 'Y') THEN
4670   resultout := 'Y';
4671     ELSE
4672   resultout := 'N';
4673 
4674     END IF;
4675 
4676 END;
4677 
4678 PROCEDURE DOES_BIDDER_LIST_EXIT(  itemtype  in varchar2,
4679           itemkey  in varchar2,
4680                              actid         in number,
4681                                 uncmode  in varchar2,
4682                                   resultout     out NOCOPY varchar2) IS
4683 
4684 x_flag     VARCHAR2(1);
4685 x_progress  VARCHAR2(3);
4686 
4687 BEGIN
4688 
4689    x_progress := '010';
4690 
4691    x_flag := wf_engine.GetItemAttrText (itemtype => itemtype,
4692                                         itemkey  => itemkey,
4693                                         aname    => 'BIDDER_LIST_FLAG');
4694 
4695    x_progress := '020';
4696 
4697    IF (x_flag = 'Y') THEN
4698      resultout := 'Y';
4699    ELSE
4700      resultout := 'N';
4701    END IF;
4702 
4703 END;
4704 
4705 
4706 PROCEDURE NON_BID_LIST_BIDDERS(  itemtype    in varchar2,
4707            itemkey    in varchar2,
4708                        actid           in number,
4709                        uncmode    in varchar2,
4710                        resultout       out NOCOPY varchar2) IS
4711 
4712 BEGIN
4713 null;
4714 END;
4715 
4716 
4717 
4718 PROCEDURE NOTIFY_BIDDER_LIST_START(itemtype  in varchar2,
4719         itemkey    in varchar2,
4720                          actid           in number,
4721                             uncmode    in varchar2,
4722                               resultout       out NOCOPY varchar2) IS
4723 
4724 x_notification_id  NUMBER;
4725 x_progress    VARCHAR2(3);
4726 
4727 BEGIN
4728 
4729     x_progress := '010';
4730 
4731 
4732     email_list(p_itemtype    => itemtype,
4733          p_itemkey    => itemkey,
4734          p_actid      => actid,
4735          p_notification_id  => x_notification_id);
4736 
4737     x_progress := '020';
4738 
4739 END;
4740 
4741 PROCEDURE NOTIFY_BIDDER_LIST_CANCEL(  itemtype  in varchar2,
4742         itemkey    in varchar2,
4743                          actid           in number,
4744                             uncmode    in varchar2,
4745                               resultout       out NOCOPY varchar2) IS
4746 BEGIN
4747 null;
4748 END;
4749 
4750 
4751 PROCEDURE NOTIFY_NON_BIDDER_LIST_CANCEL(  itemtype  in varchar2,
4752         itemkey    in varchar2,
4753                          actid           in number,
4754                             uncmode    in varchar2,
4755                               resultout       out NOCOPY varchar2) IS
4756 
4757 x_notification_id  NUMBER;
4758 x_progress    VARCHAR2(3);
4759 
4760 BEGIN
4761 
4762     x_progress := '010';
4763 
4764 
4765     email_bidders(p_itemtype    => itemtype,
4766              p_itemkey    => itemkey,
4767                p_actid    => actid,
4768             p_message_name  => 'AUCTION_CANCELLED',
4769            p_notification_id  => x_notification_id);
4770 
4771     x_progress := '020';
4772 
4773 END;
4774 
4775 PROCEDURE NOTIFY_BIDDER_LIST_END(  itemtype  in varchar2,
4776         itemkey    in varchar2,
4777                          actid           in number,
4778                             uncmode    in varchar2,
4779                               resultout       out NOCOPY varchar2) IS
4780 
4781 BEGIN
4782 null;
4783 END;
4784 
4785 PROCEDURE NOTIFY_NON_BIDDER_LIST_END(  itemtype  in varchar2,
4786         itemkey    in varchar2,
4787                          actid           in number,
4788                             uncmode    in varchar2,
4789                               resultout       out NOCOPY varchar2) IS
4790 
4791 
4792 x_notification_id  NUMBER;
4793 x_progress    VARCHAR2(3);
4794 
4795 BEGIN
4796 
4797     x_progress := '010';
4798 
4799 
4800     email_bidders(p_itemtype    => itemtype,
4801              p_itemkey    => itemkey,
4802                p_actid    => actid,
4803             p_message_name  => 'AUCTION_ENDED',
4804            p_notification_id  => x_notification_id);
4805 
4806     x_progress := '020';
4807 
4808 END;
4809 
4810 PROCEDURE CHECK_AUCTION_BIDDER
4811           (p_trading_partner_contact_id IN NUMBER,
4812            p_auction_header_id IN NUMBER,
4813            x_return_status OUT NOCOPY NUMBER)
4814 IS
4815 
4816 x_progress              VARCHAR2(3);
4817 x_bidder_user_name      VARCHAR2(100);
4818 x_role_name             VARCHAR2(30);
4819 
4820 BEGIN
4821 
4822     x_progress := '010';
4823 
4824     select wf_role_name
4825     into   x_role_name
4826     from   pon_auction_headers_all
4827     where  auction_header_id = p_auction_header_id;
4828 
4829     BEGIN
4830       select user_name
4831       into   x_bidder_user_name
4832       from   fnd_user
4833       where  person_party_id= p_trading_partner_contact_id
4834       and nvl(end_date, sysdate+1) > sysdate;
4835     EXCEPTION
4836        when too_many_rows then
4837           if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
4838                if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
4839                          fnd_log.string(log_level => fnd_log.level_unexpected,
4840                                         module    => 'pon.plsql.pon_auction_pkg.check_auction_bidder',
4841                                         message   => 'Multiple Users found for person_party_id:'|| p_trading_partner_contact_id);
4842                end if;
4843          end if;
4844 
4845          select user_name
4846          into x_bidder_user_name
4847          from fnd_user
4848          where person_party_id = p_trading_partner_contact_id
4849          and nvl(end_date, sysdate+1) > sysdate
4850          and rownum=1;
4851 
4852     END;
4853 
4854     x_progress := '020';
4855 
4856     add_bidder_to_role(x_bidder_user_name,x_role_name);
4857 
4858     x_return_status := 0;
4859 
4860 EXCEPTION
4861 
4862     WHEN OTHERS THEN
4863        x_return_status := 1;
4864 
4865 END;
4866 
4867 
4868 PROCEDURE BIDDER_IN_LIST    (  itemtype  in varchar2,
4869         itemkey    in varchar2,
4870                          actid           in number,
4871                             uncmode    in varchar2,
4872                               resultout       out NOCOPY varchar2)  IS
4873 
4874 x_flag   VARCHAR2(1) := 'N';
4875 x_auction_header_id  NUMBER;
4876 x_bidder_contact_id   NUMBER;
4877 x_progress    VARCHAR2(3);
4878 
4879 BEGIN
4880 
4881     x_progress := '010';
4882 
4883     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
4884                                                       itemkey  => itemkey,
4885                                                      aname    => 'AUCTION_ID');
4886 
4887     x_bidder_contact_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
4888                                                       itemkey  => itemkey,
4889                                                      aname    => 'PREPARER_TP_CONTACT_ID');
4890 
4891     x_progress := '020';
4892 
4893   begin
4894     select 'Y' into x_flag
4895     from pon_bidding_parties
4896     where auction_header_id = x_auction_header_id
4897     and trading_partner_contact_id = x_bidder_contact_id
4898     group by trading_partner_contact_id;
4899         exception when NO_DATA_FOUND then
4900      x_flag := 'N';
4901   end;
4902 
4903     x_progress := '030';
4904 
4905    IF (x_flag = 'Y') THEN
4906      resultout := 'Y';
4907    ELSE
4908      resultout := 'N';
4909    END IF;
4910 
4911 END;
4912 
4913 
4914 PROCEDURE ADD_BIDDER_TO_ROLE(p_user_name  VARCHAR2,
4915            p_role_name  VARCHAR2) IS
4916 
4917 x_progress      VARCHAR2(3);
4918 x_user_orig_system    VARCHAR2(30) := 'FND_USR';
4919 x_user_orig_system_id    NUMBER := 0;
4920 x_role_orig_system    VARCHAR2(30) := 'WF_LOCAL_ROLES';
4921 x_role_orig_system_id    NUMBER := 0;
4922 x_bidder_count      NUMBER;
4923 l_users WF_DIRECTORY.UserTable;
4924 
4925 BEGIN
4926     x_progress := '010';
4927 
4928   select count(*)
4929   into x_bidder_count
4930   from wf_local_user_roles
4931   where role_name = p_role_name
4932   and user_name = p_user_name;
4933 
4934   if (x_bidder_count < 1) then
4935     /*WF_DIRECTORY.AddUsersToAdHocRole(p_role_name,
4936                    p_user_name);*/
4937      -- -- Added for the bug#8847938 to remove the space as delimitter in user name
4938  	 if (p_user_name is NOT NULL) then
4939  	     string_to_userTable(p_user_name, l_users);
4940 
4941 
4942  	 WF_DIRECTORY.AddUsersToAdHocRole2(p_role_name,
4943  	                                 l_users);
4944  	    end if;
4945   end if;
4946 END;
4947 
4948 PROCEDURE SEALED_BIDS(  itemtype  in varchar2,
4949         itemkey    in varchar2,
4950                          actid           in number,
4951                             uncmode    in varchar2,
4952                               resultout       out NOCOPY varchar2) IS
4953 
4954 x_flag       VARCHAR2(1);
4955 x_progress    VARCHAR2(3);
4956 
4957 BEGIN
4958 
4959     x_progress := '010';
4960 
4961     x_flag := wf_engine.GetItemAttrText (itemtype => itemtype,
4962                                                       itemkey  => itemkey,
4963                                                      aname    => 'SEALED_FLAG');
4964 
4965     x_progress := '020';
4966 
4967    IF (x_flag = 'Y') THEN
4968      resultout := 'Y';
4969    ELSE
4970      resultout := 'N';
4971    END IF;
4972 
4973 END;
4974 
4975 ----------------------------------------------------------------
4976 -- Procedure call to cancel an auction                        --
4977 ----------------------------------------------------------------
4978 PROCEDURE CANCEL_AUCTION (p_auction_header_id  IN NUMBER) IS
4979 
4980 x_itemtype   VARCHAR2(7) := 'PONAUCT';
4981 x_itemkey  VARCHAR2(30);
4982 x_notification_date  DATE;
4983 x_now    DATE;
4984 x_cancel_reason PON_ACTION_HISTORY.ACTION_NOTE%TYPE := '';
4985 x_cancel_date   PON_AUCTION_HEADERS_ALL.CANCEL_DATE%TYPE;
4986 x_current_activity VARCHAR2(30);
4987 
4988 
4989 BEGIN
4990    -- choli update for emd
4991    email_emd_admins(p_auction_header_id);
4992    --
4993    -- Get the workflow item key and the current time so that we
4994    -- can complete the workflow
4995    --
4996    x_now := SYSDATE;
4997 
4998    select wf_item_key, sysdate, cancel_date
4999      into x_itemkey, x_now, x_cancel_date
5000      from pon_auction_headers_all
5001      where auction_header_id = p_auction_header_id;
5002 
5003 
5004    --
5005    -- First, see what activity (if any) the workflow is on
5006    -- If none, then return.  Workflow has already completed??
5007    --
5008    BEGIN
5009       select activity_label
5010   into x_current_activity
5011   from wf_item_activity_statuses_v
5012   where item_type = x_itemtype
5013   AND item_key = x_itemkey
5014   and activity_status_code = 'NOTIFIED';
5015    EXCEPTION WHEN no_data_found THEN
5016      RETURN;
5017    END;
5018    --
5019    -- Get the cancel reason from the action history table
5020    --
5021    BEGIN
5022       select action_note
5023   into   x_cancel_reason
5024   from pon_action_history
5025   where object_id = p_auction_header_id
5026   and   object_type_code = 'PON_AUCTION'
5027   and action_type = 'CANCEL';
5028    EXCEPTION WHEN NO_DATA_FOUND THEN
5029       x_cancel_reason := '';
5030    END;
5031 
5032 
5033    --
5034    -- Set the workflow attribute
5035    --
5036 
5037    if (x_cancel_reason is null) then
5038      wf_engine.SetItemAttrText(itemtype => x_itemtype,
5039           itemkey  => x_itemkey,
5040           aname    => 'CANCEL_REASON',
5041           avalue   => getMessage('PON_AUC_WF_NO_REASON', ''));
5042    else
5043      wf_engine.SetItemAttrText(itemtype => x_itemtype,
5044                itemkey  => x_itemkey,
5045                aname    => 'CANCEL_REASON',
5046                avalue   => x_cancel_reason);
5047    end if;
5048 
5049 
5050    if (x_cancel_date is not null) then
5051           wf_engine.SetItemAttrDate(itemtype => x_itemtype,
5052           itemkey  => x_itemkey,
5053           aname    => 'CANCEL_DATE',
5054           avalue   => x_cancel_date);
5055 
5056    end if;
5057 
5058    --
5059    -- Complete the workflow with a cancel action.
5060    -- This should either be
5061    --   1) Waiting for the start of the auction
5062    --   2) Pre  6.1 - waiting for the end of the auction
5063    --      Post 6.1 - waiting for user to complete the auction
5064    --
5065 
5066    wf_engine.CompleteActivity(x_itemtype,x_itemkey,x_current_activity,'PREPARER_CANCEL');
5067 
5068 END;
5069 
5070 FUNCTION GET_CLOSE_BIDDING_DATE(p_auction_header_id IN NUMBER) RETURN DATE
5071 
5072 IS
5073 
5074   v_end_date DATE;
5075 
5076 BEGIN
5077 
5078 
5079      select pah.close_bidding_date
5080      into   v_end_date
5081      from   pon_auction_headers_all pah
5082      where  pah.auction_header_id = p_auction_header_id;
5083 
5084      RETURN v_end_date;
5085 
5086 END;
5087 
5088 
5089 FUNCTION TIME_REMAINING_ORDER(p_auction_header_id IN NUMBER) RETURN NUMBER
5090 
5091 IS
5092 
5093   v_auction_status     VARCHAR2(25);
5094   v_creation_date      DATE;
5095   v_end_date           DATE;
5096   v_time_left_order    NUMBER;
5097   v_is_paused         VARCHAR2(1);
5098   v_last_pause_date    DATE;
5099   v_auction_header_id_orig_round NUMBER;
5100   v_auction_round_number NUMBER;
5101   v_amendment_number NUMBER;
5102 
5103 BEGIN
5104 
5105      select pah.auction_status, pah.creation_date, pah.close_bidding_date, nvl( pah.is_paused, 'N' ), nvl( pah.last_pause_date, sysdate )
5106             , auction_header_id_orig_round, nvl(auction_round_number,0),
5107 nvl(amendment_number,0)
5108      into   v_auction_status, v_creation_date, v_end_date, v_is_paused, v_last_pause_date
5109             , v_auction_header_id_orig_round, v_auction_round_number,
5110 v_amendment_number
5111      from   pon_auction_headers_all pah
5112      where  pah.auction_header_id = p_auction_header_id;
5113 
5114    RETURN TIME_REMAINING_ORDER( v_auction_status, v_creation_date , v_end_date, v_is_paused, v_last_pause_date, v_auction_header_id_orig_round, v_auction_round_number, v_amendment_number );
5115 
5116 END;
5117 
5118 
5119 -- Overloaded function to calculate time_remaining.
5120 -- This function will not make any database call,
5121 -- since all the necessary parameters are passed as an arguments.
5122 FUNCTION TIME_REMAINING_ORDER( p_auction_status      IN VARCHAR2,
5123                                p_creation_date       IN DATE,
5124                                p_close_bidding_date  IN DATE,
5125                                p_is_paused           IN VARCHAR2,
5126                                p_last_pause_date     IN DATE,
5127                                p_auction_header_id_orig_round IN NUMBER,
5128                                p_auction_round_number IN NUMBER,
5129                                p_amendment_number IN NUMBER) RETURN NUMBER
5130 
5131 IS
5132 
5133   v_time_left_order    NUMBER;
5134 
5135 BEGIN
5136 
5137    -- Check the dates are having valid inputs. If the dates are null,
5138    -- we will return output as Zero (0), since those records will be displayed at the top
5139    -- and the users can easily find out the problems.
5140    IF ( p_creation_date IS NULL OR  p_close_bidding_date IS NULL ) THEN
5141       v_time_left_order := 0;
5142       RETURN v_time_left_order;
5143    END IF;
5144 
5145    --
5146    -- If cancelled
5147    --
5148    IF ( p_auction_status = 'CANCELLED') THEN
5149       v_time_left_order := (2000*365) + (p_close_bidding_date - sysdate);
5150       RETURN v_time_left_order;
5151    END IF;
5152 
5153    --
5154    -- If amended or completed
5155    --
5156    IF (p_auction_status = 'AMENDED' or p_auction_status = 'AUCTION_CLOSED') THEN
5157       v_time_left_order := (1500*365) - (p_auction_header_id_orig_round +
5158                            nvl(p_auction_round_number,0)*0.0001 +
5159                            nvl(p_amendment_number,0)*0.00000001)/10000000000000000;
5160       --v_time_left_order := (1500*365) + (sysdate - p_creation_date);
5161       RETURN v_time_left_order;
5162    END IF;
5163 
5164    --
5165    -- If the negotiation is paused, return the constant time remaining.
5166    --
5167    IF ( p_is_paused = 'Y' ) THEN
5168       IF p_last_pause_date IS NOT NULL THEN
5169         v_time_left_order :=  p_close_bidding_date - p_last_pause_date;
5170         RETURN v_time_left_order;
5171       ELSE
5172         v_time_left_order := 0;
5173         RETURN v_time_left_order;
5174       END IF;
5175    END IF;
5176 
5177    --
5178    -- If closed
5179    --
5180    IF (p_close_bidding_date < sysdate) THEN
5181       v_time_left_order := (1000*365) + (p_close_bidding_date - sysdate);
5182       RETURN v_time_left_order;
5183    END IF;
5184 
5185    v_time_left_order := p_close_bidding_date - sysdate;
5186    return v_time_left_order;
5187 
5188 END;
5189 
5190 
5191 --
5192 -- Bug 3283581 and Bug 3275373
5193 --
5194 -- TIME_REMAINING has been revamped to always return the time left in
5195 -- days, hours, and minutes.  The actual date will never be returned to avoid
5196 -- any date formatting and translation issues.
5197 --
5198 
5199 
5200 FUNCTION TIME_REMAINING(p_auction_header_id IN NUMBER) RETURN VARCHAR2
5201 
5202 IS
5203 
5204 BEGIN
5205 
5206   RETURN TIME_REMAINING(p_auction_header_id, null);
5207 
5208 END;
5209 
5210 FUNCTION TIME_REMAINING(p_auction_header_id IN NUMBER, p_line_number IN NUMBER) RETURN VARCHAR2
5211 
5212 IS
5213 
5214   v_auction_status     VARCHAR2(25);
5215   v_startdate          DATE;
5216   v_enddate            DATE;
5217   v_difference         NUMBER := 0;
5218   v_days               NUMBER := 0;
5219   v_hours              NUMBER := 0;
5220   v_minutes            NUMBER := 0;
5221   v_time_left          VARCHAR2(50) := null;
5222   v_opens_in_suffix    VARCHAR2(2)  := '';
5223   v_pausedate          DATE;
5224   v_ispaused           VARCHAR2(1);
5225   v_staggered_closing_interval NUMBER := NULL;
5226 
5227 BEGIN
5228 
5229   IF (p_line_number is null) THEN
5230 
5231      select auction_status, open_bidding_date, close_bidding_date, nvl( last_pause_date, sysdate ), nvl( is_paused, 'N' ), staggered_closing_interval
5232      into   v_auction_status, v_startdate, v_enddate, v_pausedate, v_ispaused, v_staggered_closing_interval
5233      from   pon_auction_headers_all
5234      where  auction_header_id = p_auction_header_id;
5235 
5236   ELSE
5237 
5238      select pah.auction_status, pah.open_bidding_date, nvl(paip.close_bidding_date, pah.close_bidding_date),
5239             nvl( pah.last_pause_date, sysdate ), nvl( pah.is_paused, 'N' )
5240      into   v_auction_status, v_startdate, v_enddate, v_pausedate, v_ispaused
5241      from   pon_auction_headers_all pah, pon_auction_item_prices_all paip
5242      where  pah.auction_header_id = p_auction_header_id and
5243             paip.auction_header_id = pah.auction_header_id and
5244             paip.line_number = p_line_number;
5245 
5246   END IF;
5247 
5248   RETURN TIME_REMAINING( v_auction_status, v_startdate, v_enddate, v_ispaused, v_pausedate, v_staggered_closing_interval);
5249 
5250 END;
5251 
5252 -- Overloaded function to calculate time_remaining.
5253 -- This function will not make any database call,
5254 -- since all the necessary parameters are passed as an arguments.
5255 FUNCTION TIME_REMAINING( p_auction_status      IN VARCHAR2,
5256                          p_open_bidding_date   IN DATE,
5257                          p_close_bidding_date  IN DATE,
5258                          p_is_paused           IN VARCHAR2,
5259                          p_last_pause_date     IN DATE,
5260                          p_staggered_closing_interval IN NUMBER ) RETURN VARCHAR2
5261 IS
5262 
5263   v_difference         NUMBER := 0;
5264   v_days               NUMBER := 0;
5265   v_hours              NUMBER := 0;
5266   v_minutes            NUMBER := 0;
5267   v_seconds            NUMBER := 0;
5268   v_time_left          VARCHAR2(50) := null;
5269   v_opens_in_suffix    VARCHAR2(2)  := '';
5270 
5271 BEGIN
5272 
5273    --
5274    -- If cancelled, then return "Cancelled"
5275    --
5276    IF (p_auction_status = 'CANCELLED') THEN
5277       v_time_left :=  fnd_message.get_string('PON', 'PON_AUC_CANCELLED');
5278       RETURN v_time_left;
5279    END IF;
5280 
5281    --
5282    -- If amended or applied, then return "N/A"
5283    -- Changed by amundhra for federal CLM
5284    --
5285    IF (p_auction_status = 'AMENDED' or p_auction_status = 'APPLIED') THEN
5286      v_time_left := fnd_message.get_string('PON', 'PON_NOT_APPLICABLE');
5287      RETURN v_time_left;
5288    END IF;
5289 
5290    -- We will check the dates are valid.
5291    -- If the dates are null, then we will return, BLANK message as time left.
5292    IF p_open_bidding_date IS NULL OR p_close_bidding_date IS NULL THEN
5293       v_time_left :=  ' ';
5294       RETURN v_time_left;
5295    END IF;
5296 
5297    --
5298    -- If the negotiation is paused, return the constant time remaining.
5299    --
5300    IF ( p_is_paused = 'Y' ) THEN
5301 
5302             IF p_last_pause_date IS NULL THEN
5303                 v_time_left :=  ' ';
5304                 RETURN v_time_left;
5305             ELSE
5306                 -- if a staggered  auction
5307                 --then show STAGGERED CLOSING for close date
5308                 IF p_staggered_closing_interval IS NOT NULL THEN
5309                   return fnd_message.get_string('PON','PON_STAGGERED_CLOSING_MSG');
5310                 END IF;
5311                 v_difference := to_number( p_close_bidding_date - p_last_pause_date );
5312             END IF;
5313 
5314    ELSE
5315 
5316      --
5317      -- If closed, then return "0 seconds"
5318      --
5319      IF (p_close_bidding_date < sysdate) THEN
5320         fnd_message.clear;
5321         fnd_message.set_name('PON','PON_AUC_INTERVAL_SEC');
5322         fnd_message.set_token('SECONDS',0);
5323         v_time_left := fnd_message.get;
5324         RETURN v_time_left;
5325      END IF;
5326 
5327      -- if a staggered  auction
5328      --then show STAGGERED CLOSING for close date
5329      IF p_staggered_closing_interval IS NOT NULL THEN
5330        return fnd_message.get_string('PON','PON_STAGGERED_CLOSING_MSG');
5331      END IF;
5332      --
5333      -- If the start date is in the future, then
5334      -- calculate the difference from sysdate to start date and
5335      -- use "Opens in XXXX" messages
5336      --
5337      IF(p_open_bidding_date > Sysdate) THEN
5338         v_opens_in_suffix := '_F';
5339         v_difference := to_number(p_open_bidding_date - sysdate);
5340       --
5341       -- Otherwise, calculate the difference from sysdate to end date
5342       --
5343       ELSE
5344         v_difference := to_number(p_close_bidding_date - sysdate);
5345      END IF;
5346    END IF;
5347 
5348    --
5349    -- Calculate time components
5350    --
5351    v_days := trunc(v_difference);
5352    v_hours := trunc(mod(v_difference*24,24));
5353    v_minutes := trunc(mod(v_difference*(24*60),60));
5354    v_seconds := trunc(mod(v_difference*(24*60*60),60));
5355 
5356     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
5357       FND_LOG.string(log_level => FND_LOG.level_statement,
5358         module  =>  g_module_prefix || 'TIME_REMAINING',
5359         message  => 'v_days = ' || v_days
5360                     || ' v_hours = ' || v_hours
5361                     || ' v_minutes = ' || v_minutes
5362                     || ' v_seconds = ' || v_seconds
5363             );
5364     END IF;
5365 
5366    --
5367    -- If we have less than one minute
5368    --
5369    IF(v_days < 1 AND v_hours < 1 AND v_minutes < 1 AND 0 < v_seconds) THEN
5370       v_time_left :=  fnd_message.get_string('PON', 'PON_LESS_MINUTE'||v_opens_in_suffix);
5371    --
5372    -- If we have less than one second, display 0 minutes
5373    --
5374    ELSIF(v_days < 1 AND v_hours < 1 AND v_minutes < 1 AND v_seconds < 1) THEN
5375       fnd_message.clear;
5376       IF (v_opens_in_suffix is not null) THEN
5377         fnd_message.set_name('PON','PON_MINUTES'||v_opens_in_suffix);
5378         fnd_message.set_token('NUM_MINUTES',0);
5379       ELSE
5380         fnd_message.set_name('PON','PON_AUC_INTERVAL_SEC');
5381         fnd_message.set_token('SECONDS',0);
5382       END IF;
5383       v_time_left := fnd_message.get;
5384     --
5385     -- If we have just one minute
5386     --
5387     ELSIF(v_days < 1 AND v_hours < 1 AND v_minutes = 1) THEN
5388       v_time_left :=  fnd_message.get_string('PON', 'PON_MINUTE'||v_opens_in_suffix);
5389     --
5390     -- If we have just minutes
5391     --
5392     ELSIF(v_days < 1 AND v_hours < 1 AND v_minutes > 1 ) THEN
5393       fnd_message.clear;
5394       fnd_message.set_name('PON','PON_MINUTES'||v_opens_in_suffix);
5395       fnd_message.set_token('NUM_MINUTES',v_minutes);
5396       v_time_left := fnd_message.get;
5397     --
5398     -- If we have one hour
5399     --
5400     ELSIF(v_days < 1 AND v_hours = 1 AND v_minutes < 1) THEN
5401       v_time_left := fnd_message.get_string('PON','PON_HOUR'||v_opens_in_suffix);
5402     --
5403     -- If we have one hour and one minute
5404     --
5405     ELSIF(v_days < 1 AND v_hours = 1 AND v_minutes = 1) THEN
5406       v_time_left := fnd_message.get_string('PON','PON_HOUR_MINUTE'||v_opens_in_suffix);
5407     --
5408     -- If we have one hour and minutes
5409     --
5410     ELSIF(v_days < 1 AND v_hours = 1 AND v_minutes > 1) THEN
5411       fnd_message.clear;
5412       fnd_message.set_name('PON','PON_HOUR_MINUTES'||v_opens_in_suffix);
5413       fnd_message.set_token('NUM_MINUTES',v_minutes);
5414       v_time_left := fnd_message.get;
5415     --
5416     -- If we have hours
5417     --
5418     ELSIF(v_days < 1 AND v_hours > 1 AND v_minutes < 1) THEN
5419       fnd_message.clear;
5420       fnd_message.set_name('PON','PON_HOURS'||v_opens_in_suffix);
5421       fnd_message.set_token('NUM_HOURS',v_hours);
5422       v_time_left := fnd_message.get;
5423     --
5424     -- If we have hours and one minute
5425     --
5426     ELSIF(v_days < 1 AND v_hours > 1 AND v_minutes = 1) THEN
5427       fnd_message.clear;
5428       fnd_message.set_name('PON','PON_HOURS_MINUTE'||v_opens_in_suffix);
5429       fnd_message.set_token('NUM_HOURS',v_hours);
5430       v_time_left := fnd_message.get;
5431     --
5432     -- If we have hours and minutes
5433     --
5434     ELSIF(v_days < 1 AND v_hours > 1 AND v_minutes > 1) THEN
5435       fnd_message.clear;
5436       fnd_message.set_name('PON','PON_HOURS_MINUTES'||v_opens_in_suffix);
5437       fnd_message.set_token('NUM_HOURS',v_hours);
5438       fnd_message.set_token('NUM_MINUTES',v_minutes);
5439       v_time_left := fnd_message.get;
5440     --
5441     -- If we have one day
5442     --
5443     ELSIF(v_days = 1 AND v_hours < 1) THEN
5444       v_time_left := fnd_message.get_string('PON','PON_DAY'||v_opens_in_suffix);
5445     --
5446     -- If we have one day and one hour
5447     --
5448     ELSIF(v_days = 1 AND v_hours = 1) THEN
5449       v_time_left := fnd_message.get_string('PON','PON_DAY_HOUR'||v_opens_in_suffix);
5450     --
5451     -- If we have one day and hours
5452     --
5453     ELSIF(v_days = 1 AND v_hours > 1) THEN
5454       fnd_message.clear;
5455       fnd_message.set_name('PON','PON_DAY_HOURS'||v_opens_in_suffix);
5456       fnd_message.set_token('NUM_HOURS',v_hours);
5457       v_time_left := fnd_message.get;
5458     --
5459     -- If we have days
5460     --
5461     ELSIF(v_days > 1 AND v_hours < 1) THEN
5462       fnd_message.clear;
5463       fnd_message.set_name('PON','PON_DAYS'||v_opens_in_suffix);
5464       fnd_message.set_token('NUM_DAYS',v_days);
5465       v_time_left := fnd_message.get;
5466     --
5467     -- If we have days and one hour
5468     --
5469     ELSIF(v_days > 1 AND v_hours = 1) THEN
5470       fnd_message.clear;
5471       fnd_message.set_name('PON','PON_DAYS_HOUR'||v_opens_in_suffix);
5472       fnd_message.set_token('NUM_DAYS',v_days);
5473       v_time_left := fnd_message.get;
5474     --
5475     -- If we have days and hours
5476     --
5477     ELSIF(v_days > 1 AND v_hours > 1) THEN
5478       fnd_message.clear;
5479       fnd_message.set_name('PON','PON_DAYS_HOURS'||v_opens_in_suffix);
5480       fnd_message.set_token('NUM_DAYS',v_days);
5481       fnd_message.set_token('NUM_HOURS',v_hours);
5482       v_time_left := fnd_message.get;
5483    END IF;
5484    --
5485    -- Return the time left
5486    --
5487    RETURN v_time_left;
5488 
5489 END;
5490 
5491 
5492 
5493 PROCEDURE AUCTION_OPEN(   itemtype  IN VARCHAR2,
5494         itemkey    IN VARCHAR2,
5495                                 actid           IN NUMBER,
5496                                 uncmode          IN VARCHAR2,
5497                                 resultout       OUT NOCOPY VARCHAR2) IS
5498 
5499 x_auction_header_id  NUMBER;
5500 x_progress    VARCHAR2(3);
5501 
5502 BEGIN
5503 
5504     x_progress := '010';
5505 
5506     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
5507                                                       itemkey  => itemkey,
5508                                                      aname    => 'AUCTION_ID');
5509 
5510     x_progress := '020';
5511 
5512     update pon_auction_headers_all
5513     set    auction_status = 'OPEN_FOR_BIDDING',
5514      auction_status_name = (select meaning from fnd_lookups
5515           where lookup_type = 'PON_AUCTION_STATUS' and
5516           lookup_code = 'OPEN_FOR_BIDDING')
5517     where auction_header_id = x_auction_header_id;
5518 
5519 
5520     x_progress := '030';
5521 
5522 END AUCTION_OPEN;
5523 
5524 PROCEDURE AUCTION_CLOSED(   itemtype  IN VARCHAR2,
5525         itemkey    IN VARCHAR2,
5526                                 actid           IN NUMBER,
5527                                 uncmode          IN VARCHAR2,
5528                                 resultout       OUT NOCOPY VARCHAR2) IS
5529 x_auction_header_id  NUMBER;
5530 x_progress    VARCHAR2(3);
5531 
5532 BEGIN
5533 
5534     x_progress := '010';
5535 
5536     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
5537                                                       itemkey  => itemkey,
5538                                                      aname    => 'AUCTION_ID');
5539 
5540     x_progress := '020';
5541 
5542     update pon_auction_headers_all
5543     set    auction_status = 'CLOSED_FOR_BIDDING',
5544      auction_status_name = (select meaning from fnd_lookups
5545           where lookup_type = 'PON_AUCTION_STATUS' and
5546           lookup_code = 'CLOSED_FOR_BIDDING')
5547     where auction_header_id = x_auction_header_id;
5548 
5549 
5550     x_progress := '030';
5551 
5552 END AUCTION_CLOSED;
5553 
5554 
5555 
5556 ----------------------------------------------------------------
5557 -- getLookupMeaning returns the description of a lookup code
5558 -- in the language mentioaned as a parameter.
5559 -- PL/SQL equivalent of Lookups.getMeaning() (in services package)
5560 ----------------------------------------------------------------
5561 Function getLookupMeaning(lookupType in varchar2,
5562                           langCode   in varchar2,
5563                           lookupCode in varchar2) return varchar2 AS
5564 lookupMeaning varchar2(8000) :=  '';
5565 Begin
5566  begin
5567 if  nvl(lookupCode,'!') <> '!' then
5568 select meaning into lookupMeaning
5569 from fnd_lookup_values
5570 where lookup_type = lookupType and
5571       language    = langCode   and
5572       lookup_code = lookupCode;
5573 end if;
5574 end;
5575 return (lookupMeaning);
5576 End getLookupMeaning;
5577 
5578 ----------------------------------------------------------------
5579 -- GetPoTotal returns the sum of the extend amount for the lines
5580 -- including with this PO
5581 ----------------------------------------------------------------
5582 Function GetPOTotal( p_po_id    IN number) return Number AS
5583 x_amount number;
5584 cursor c1(p_po_id number) is
5585 select sum(AWARD_QUANTITY * BID_CURRENCY_PRICE)
5586 from pon_bid_item_prices
5587 where bid_number = p_po_id
5588 and award_status = 'AWARDED';
5589 Begin
5590  begin
5591     open c1(p_po_id);
5592     fetch c1
5593        into x_amount;
5594     close c1;
5595  exception When others then
5596    x_amount := 0;
5597  end;
5598  return(x_amount);
5599 End GetPOTotal;
5600 
5601 ----------------------------------------------------------------
5602 -- Replace HTML entity characters to actual characters    --
5603 -- This is required to pass proper string to workflow
5604 -- Example : <amp>quot;Test<amp>quit; is converted to "Test"
5605 ----------------------------------------------------------------
5606 function replaceHtmlChars(html_in varchar2) return varchar2 is
5607 html_out1 varchar2(4000);
5608 html_out2 varchar2(4000);
5609 html_out3 varchar2(4000);
5610 begin
5611 html_out1 := replace(html_in,concat(fnd_global.local_chr(38),'quot;'),fnd_global.local_chr(34));
5612 html_out2 := replace(html_out1,concat(fnd_global.local_chr(38),'lt;'),fnd_global.local_chr(60));
5613 html_out3 := replace(html_out2,concat(fnd_global.local_chr(38),'gt;'),fnd_global.local_chr(62));
5614 return(html_out3);
5615 end;
5616 
5617 
5618 ----------------------------------------------------------------
5619 -- Tells if a particular auction is part of an event using    --
5620 -- the auction id                                             --
5621 ----------------------------------------------------------------
5622 PROCEDURE EVENT_AUCTION    (itemtype    in varchar2,
5623                  itemkey    in varchar2,
5624                             actid           in number,
5625                             uncmode    in varchar2,
5626                             resultout       out NOCOPY varchar2) IS
5627 
5628 x_auction_number  NUMBER;
5629 
5630 BEGIN
5631 
5632     x_auction_number := wf_engine.GetItemAttrNumber (itemtype => itemtype,
5633                                                         itemkey  => itemkey,
5634                                                        aname    => 'AUCTION_NUMBER');
5635 
5636 
5637     resultout := is_event_auction(x_auction_number);
5638 END;
5639 
5640 ----------------------------------------------------------------
5641 -- Tells if a particular auction is part of an event using    --
5642 -- the auction id                                             --
5643 ----------------------------------------------------------------
5644 PROCEDURE EVENT_AUCTION_ID(itemtype    in varchar2,
5645          itemkey    in varchar2,
5646          actid           in number,
5647          uncmode    in varchar2,
5648          resultout       out NOCOPY varchar2) IS
5649 
5650 x_auction_number  NUMBER;
5651 
5652 BEGIN
5653 
5654     x_auction_number := wf_engine.GetItemAttrNumber (itemtype => itemtype,
5655                  itemkey  => itemkey,
5656                  aname    => 'AUCTION_ID');
5657 
5658     resultout := is_event_auction(x_auction_number);
5659 END;
5660 
5661 ----------------------------------------------------------------
5662 -- Local function which returns a flag 'Y' if an auction is   --
5663 -- part of an event and 'N' if it is not                      --
5664 ----------------------------------------------------------------
5665 FUNCTION IS_EVENT_AUCTION (p_auction_number IN NUMBER) RETURN VARCHAR2 AS
5666 
5667 x_flag       VARCHAR2(1);
5668 
5669 BEGIN
5670    BEGIN
5671       select 'Y'
5672   into x_flag
5673   from pon_auction_headers_all
5674   where auction_header_id = p_auction_number
5675   and   event_id is not null;
5676    EXCEPTION
5677       WHEN NO_DATA_FOUND THEN
5678    x_flag := 'N';
5679    END;
5680 
5681    return(x_flag);
5682 END;
5683 
5684 
5685 ----------------------------------------------------------------
5686 -- Tells if the cancel reason is empty                        --
5687 ----------------------------------------------------------------
5688 PROCEDURE EMPTY_CANCEL_REASON(itemtype    in varchar2,
5689             itemkey    in varchar2,
5690             actid           in number,
5691             uncmode    in varchar2,
5692             resultout       out NOCOPY varchar2) IS
5693 
5694 x_cancel_reason PON_ACTION_HISTORY.ACTION_NOTE%TYPE;
5695 
5696 BEGIN
5697 
5698     x_cancel_reason := wf_engine.GetItemAttrText (itemtype => itemtype,
5699               itemkey  => itemkey,
5700               aname    => 'CANCEL_REASON');
5701 
5702 
5703     resultout := empty_reason(x_cancel_reason);
5704 END;
5705 
5706 ----------------------------------------------------------------
5707 -- Tells if the auction close date changed reason is empty                      --
5708 ----------------------------------------------------------------
5709 PROCEDURE EMPTY_CLOSECHANGED_REASON(itemtype          in varchar2,
5710                               itemkey           in varchar2,
5711                               actid             in number,
5712                               uncmode           in varchar2,
5713                               resultout         out NOCOPY varchar2) IS
5714 
5715 x_closechanged_reason VARCHAR2(2000);
5716 
5717 BEGIN
5718 
5719     x_closechanged_reason := wf_engine.GetItemAttrText (itemtype => itemtype,
5720                                             itemkey  => itemkey,
5721                                             aname    => 'CLOSECHANGED_REASON');
5722 
5723     resultout := empty_reason(x_closechanged_reason);
5724 END;
5725 
5726 ----------------------------------------------------------------
5727 -- Tells if the disqualify reason is empty                    --
5728 ----------------------------------------------------------------
5729 PROCEDURE EMPTY_DISQUALIFY_REASON(itemtype    in varchar2,
5730           itemkey    in varchar2,
5731           actid           in number,
5732           uncmode    in varchar2,
5733           resultout       out NOCOPY varchar2) IS
5734 
5735 x_disqualify_reason VARCHAR2(2000);
5736 
5737 BEGIN
5738 
5739     x_disqualify_reason := wf_engine.GetItemAttrText (itemtype => itemtype,
5740                   itemkey  => itemkey,
5741                   aname    => 'DISQUALIFY_REASON');
5742 
5743 
5744     resultout := empty_reason(x_disqualify_reason);
5745 END;
5746 
5747 ----------------------------------------------------------------
5748 -- Local function which returns a flag 'Y' if a string is     --
5749 -- empty and 'N' if it not                                    --
5750 ----------------------------------------------------------------
5751 FUNCTION EMPTY_REASON(p_reason IN VARCHAR2) RETURN VARCHAR2 AS
5752 
5753 x_flag  VARCHAR2(1) := 'Y';
5754 
5755 BEGIN
5756 
5757    IF(p_reason IS NOT NULL) THEN
5758       x_flag := 'N';
5759    END IF;
5760 
5761    return(x_flag);
5762 END;
5763 
5764 ----------------------------------------------------------------
5765 -- Procedure to call to end an auction workflow.              --
5766 -- Once called, no more notifications for the auction can be  --
5767 -- sent.  Has the same effect as canceling an auction         --
5768 ----------------------------------------------------------------
5769 PROCEDURE COMPLETE_AUCTION(p_auction_header_id  IN NUMBER) IS
5770 
5771 x_now    DATE;
5772 x_itemtype   VARCHAR2(7) := 'PONAUCT';
5773 x_itemkey  VARCHAR2(30);
5774 x_notification_date  DATE;
5775 x_current_activity VARCHAR2(30);
5776 
5777 BEGIN
5778    --
5779    -- Get the workflow item key and the current time so that we
5780    -- can complete the workflow
5781    --
5782    select wf_item_key, sysdate
5783      into x_itemkey, x_now
5784      from pon_auction_headers_all
5785      where auction_header_id = p_auction_header_id;
5786 
5787    --
5788    -- First, see what activity (if any) the workflow is on
5789    -- If none, then return.  Workflow has already completed??
5790    --
5791    BEGIN
5792       select activity_label
5793   into x_current_activity
5794   from wf_item_activity_statuses_v
5795   where item_type = x_itemtype
5796   AND item_key = x_itemkey
5797   and activity_status_code = 'NOTIFIED';
5798    EXCEPTION WHEN no_data_found THEN
5799      RETURN;
5800    END;
5801 
5802    --
5803    -- Otherwise we have an active workflow, so go ahead and complete it
5804    --
5805    -- Get the notification date from the workflow
5806    --
5807    x_notification_date := wf_engine.GetItemAttrDate (itemtype => x_itemtype,
5808                  itemkey  => x_itemkey,
5809                  aname    => 'AUCTION_NOTIFICATION_DATE');
5810 
5811    --
5812    -- Only complete the workflow if it is in a 'completeable' state.
5813    -- That is, if we have passed the notification date for the auction.
5814    -- If we try and complete the auction before that, we will get a workflow
5815    -- exception.
5816    --
5817 
5818    IF(x_now > x_notification_date AND x_current_activity = 'WAIT_FOR_AUCTION_COMPLETE') THEN
5819       wf_engine.CompleteActivity(x_itemtype,x_itemkey,'WAIT_FOR_AUCTION_COMPLETE','PREPARER_COMPLETE');
5820    END IF;
5821 
5822 END;
5823 
5824 FUNCTION sub_token(msg IN OUT NOCOPY varchar2, msgdata IN varchar2)
5825   RETURN VARCHAR2
5826   IS
5827 
5828   TOK_NAM   varchar2(30);
5829   TOK_VAL   varchar2(2000);
5830   SRCH      varchar2(2000);
5831   FLAG      varchar2(1);
5832   POS       NUMBER;
5833   NEXTPOS   NUMBER;
5834   DATA_SIZE NUMBER;
5835   TSLATE    BOOLEAN;
5836 
5837 BEGIN
5838         POS := 1;
5839         DATA_SIZE := LENGTH(MSGDATA);
5840         while POS < DATA_SIZE loop
5841             FLAG := SUBSTR(MSGDATA, POS, 1);
5842             POS := POS + 2;
5843             /* Note that we are intentionally using chr(0) rather than */
5844             /* FND_GLOBAL.LOCAL_CHR() for a performance bug (982909) */
5845             NEXTPOS := INSTR(MSGDATA, chr(0), POS);
5846             TOK_NAM := SUBSTR(MSGDATA, POS, NEXTPOS - POS);
5847             POS := NEXTPOS + 1;
5848             NEXTPOS := INSTR(MSGDATA, chr(0), POS);
5849             TOK_VAL := SUBSTR(MSGDATA, POS, NEXTPOS - POS);
5850             POS := NEXTPOS + 1;
5851 
5852             SRCH := '&' || TOK_NAM;
5853             if (INSTR(MSG, SRCH) <> 0) then
5854                 MSG := substrb(REPLACE(MSG, SRCH, TOK_VAL),1,2000);
5855             else
5856                 /* try the uppercased version of the token name in case */
5857                 /* the caller is (wrongly) passing a mixed case token name */
5858                 /* Because now (July 99) all tokens in msg text should be */
5859                 /* uppercase. */
5860                 SRCH := '&' || UPPER(TOK_NAM);
5861                 if (INSTR(MSG, SRCH) <> 0) then
5862                    MSG := substrb(REPLACE(MSG, SRCH, TOK_VAL),1,2000);
5863                 else
5864                    MSG :=substrb(MSG||' ('||TOK_NAM||'='||TOK_VAL||')',1,2000);
5865               end if;
5866             end if;
5867         END LOOP;
5868         RETURN MSG;
5869 END sub_token;
5870 
5871 FUNCTION get_string(appin IN VARCHAR2,
5872         namein IN VARCHAR2,
5873         langin IN VARCHAR2)
5874   RETURN VARCHAR2
5875   IS
5876      MSG  varchar2(2000) := NULL;
5877      MSGDATA  varchar2(2000) := NULL;
5878 
5879 BEGIN
5880    /* In the PON_PROFILE_UTIL_PKG there is a three var input fn.*/
5881    MSG := PON_PROFILE_UTIL_PKG.get_string(appin,namein,langin);
5882    FOR i in 1 .. MsgTokens.COUNT LOOP
5883   MSGDATA := MSGDATA||'N'||chr(0)||MsgTokens(i)||chr(0)||MsgTokenValues(i)||chr(0);
5884    END LOOP;
5885    return sub_token(MSG, MSGDATA);
5886 
5887 END get_string;
5888 
5889 ----------------------------------------------------------------
5890 -- Procedure call to close an auction early                   --
5891 ----------------------------------------------------------------
5892 PROCEDURE CLOSEEARLY_AUCTION (p_auction_header_id   IN NUMBER,
5893                               p_new_close_date      IN DATE,
5894                               p_closeearly_reason   IN VARCHAR2) IS
5895 
5896 x_itemtype                VARCHAR2(7) := 'PONAUCT';
5897 x_itemkey                 VARCHAR2(30);
5898 x_current_activity        VARCHAR2(30);
5899 x_contact_id              NUMBER;
5900 x_timezone                VARCHAR2(80);
5901 x_oex_timezone            VARCHAR2(80);
5902 x_auctioneer_contact_id   NUMBER ;
5903 x_timezone_disp VARCHAR2(240);
5904 x_user_name         VARCHAR2(100);
5905 x_language_code     VARCHAR2(3);
5906 
5907 -------------------------------
5908 
5909 --select user_name, person_party_id
5910 --    into x_user_name, x_contact_id
5911 --    from fnd_user where person_party_id = x_auction_contact_id;
5912 --
5913 
5914 BEGIN
5915    --
5916    -- Get the workflow item key and the current time so that we
5917    -- can complete the workflow
5918    --
5919    select wf_item_key, trading_partner_contact_id
5920      into x_itemkey, x_contact_id
5921      from pon_auction_headers_all
5922      where auction_header_id = p_auction_header_id;
5923 
5924   BEGIN
5925     select user_name
5926     into x_user_name
5927     from fnd_user
5928     where  person_party_id = x_contact_id
5929     and nvl(end_date, sysdate+1) > sysdate;
5930   EXCEPTION
5931     WHEN TOO_MANY_ROWS THEN
5932          if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
5933                if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
5934                          fnd_log.string(log_level => fnd_log.level_unexpected,
5935                                         module    => 'pon.plsql.pon_auction_pkg.closeearly_auction',
5936                                         message   => 'Multiple Users found for person_party_id:'|| x_contact_id);
5937                end if;
5938          end if;
5939 
5940          select user_name
5941          into x_user_name
5942          from fnd_user
5943          where person_party_id = x_contact_id
5944          and nvl(end_date, sysdate+1) > sysdate
5945          and rownum=1;
5946 
5947   END;
5948           IF x_user_name is not null THEN
5949        PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(x_user_name,x_language_code);
5950     END IF;
5951 
5952 
5953    --
5954    -- First, see what activity (if any) the workflow is on
5955    -- If none, then return.  Workflow has already completed??
5956    --
5957    BEGIN
5958       select activity_label
5959         into x_current_activity
5960         from wf_item_activity_statuses_v
5961         where item_type = x_itemtype
5962         AND item_key = x_itemkey
5963         and activity_status_code = 'NOTIFIED';
5964    EXCEPTION WHEN no_data_found THEN
5965      RETURN;
5966    END;
5967 
5968    --
5969    -- Get the exchange's time zone
5970    --
5971 
5972 
5973    --
5974    -- Set the auction end date
5975    --
5976    wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
5977                               itemkey    => x_itemkey,
5978                               aname      => 'AUCTION_END_DATE',
5979                               avalue     => p_new_close_date);
5980 
5981 
5982    wf_engine.SetItemAttrText(itemtype => x_itemtype,
5983                              itemkey  => x_itemkey,
5984                              aname    => 'CLOSECHANGED_REASON',
5985                              avalue   => replaceHtmlChars(p_closeearly_reason));
5986 
5987 
5988    complete_prev_suppl_notifs(p_auction_header_id);
5989 
5990    --
5991    -- Complete the workflow with a close early action.
5992    -- This should either be
5993    --   1) Waiting for the start of the auction
5994    --   2) Pre  6.1 - waiting for the end of the auction
5995    --      Post 6.1 - waiting for user to complete the auction
5996    --
5997    wf_engine.CompleteActivity(x_itemtype,x_itemkey,x_current_activity,'PREPARER_CLOSEEARLY');
5998 
5999 END;
6000 
6001 
6002 
6003 ----------------------------------------------------------------
6004 -- Procedure call to extend or shorten an auction             --
6005 ----------------------------------------------------------------
6006 PROCEDURE CLOSECHANGED_AUCTION (p_auction_header_id   IN NUMBER,
6007                                 p_change_type         IN NUMBER,
6008                                 p_new_close_date      IN DATE,
6009                                 p_closechanged_reason   IN VARCHAR2) IS
6010 
6011 x_itemtype                VARCHAR2(7) := 'PONAUCT';
6012 x_itemkey                 VARCHAR2(30);
6013 x_current_activity        VARCHAR2(30);
6014 x_contact_id              NUMBER;
6015 x_timezone                VARCHAR2(80);
6016 x_oex_timezone            VARCHAR2(80);
6017 x_auctioneer_contact_id   NUMBER;
6018 x_timezone_disp VARCHAR2(240);
6019 x_user_name         VARCHAR2(100);
6020 x_language_code     VARCHAR2(3);
6021 
6022 
6023 
6024 
6025 
6026 BEGIN
6027    --
6028    -- Get the workflow item key and the current time so that we
6029    -- can complete the workflow
6030    --
6031 
6032    select wf_item_key, trading_partner_contact_id
6033      into x_itemkey, x_contact_id
6034      from pon_auction_headers_all
6035      where auction_header_id = p_auction_header_id;
6036 
6037    BEGIN
6038      select user_name
6039      into x_user_name
6040      from fnd_user
6041      where  person_party_id = x_contact_id
6042      and nvl(end_date, sysdate+1) > sysdate;
6043    EXCEPTION
6044     WHEN TOO_MANY_ROWS THEN
6045           if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
6046                if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
6047                          fnd_log.string(log_level => fnd_log.level_unexpected,
6048                                         module    => 'pon.plsql.pon_auction_pkg.closechanged_auction',
6049                                         message   => 'Multiple Users found for person_party_id:'|| x_contact_id);
6050                end if;
6051          end if;
6052 
6053          select user_name
6054          into x_user_name
6055          from fnd_user
6056          where person_party_id = x_contact_id
6057          and nvl(end_date, sysdate+1) > sysdate
6058          and rownum=1;
6059 
6060    END;
6061           IF x_user_name is not null THEN
6062        PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(x_user_name,x_language_code);
6063     END IF;
6064 
6065    --
6066    -- First, see what activity (if any) the workflow is on
6067    -- If none, then return.  Workflow has already completed??
6068    --
6069    BEGIN
6070       select activity_label
6071         into x_current_activity
6072         from wf_item_activity_statuses_v
6073         where item_type = x_itemtype
6074         AND item_key = x_itemkey
6075         and activity_status_code = 'NOTIFIED';
6076    EXCEPTION WHEN no_data_found THEN
6077         RETURN;
6078    END;
6079 
6080    --
6081    -- Set the auction end date
6082    --
6083    wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
6084                               itemkey    => x_itemkey,
6085                               aname      => 'AUCTION_END_DATE',
6086                               avalue     => p_new_close_date);
6087 
6088 begin
6089 
6090    wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
6091                               itemkey    => x_itemkey,
6092                               aname      => 'CHANGE_TYPE',
6093                               avalue     => p_change_type);
6094 
6095 exception
6096    when others then
6097       null; -- for auctions created before version 115.20 of ponwfau1.wft this attribute did not exist
6098 end;
6099 
6100   IF p_closechanged_reason IS NOT NULL THEN
6101     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
6102                                itemkey    => x_itemkey,
6103              aname      => 'CLOSECHANGED_REASON',
6104              avalue     => replaceHtmlChars(p_closechanged_reason));
6105   END IF;
6106 
6107    --
6108    -- Complete the workflow with a close early action.
6109    -- This should either be
6110    --   1) Waiting for the start of the auction
6111    --   2) Pre  6.1 - waiting for the end of the auction
6112    --      Post 6.1 - waiting for user to complete the auction
6113    --
6114    wf_engine.CompleteActivity(x_itemtype,x_itemkey,x_current_activity,'PREPARER_CLOSECHANGED');
6115 
6116 
6117 
6118 
6119 END;
6120 
6121 
6122 ----------------------------------------------------------------
6123 -- Function which returns EVENT_TITLE if an auction is   --
6124 -- part of an event and '' if it is not                 --
6125 ----------------------------------------------------------------
6126 FUNCTION getEventTitle (p_auction_number IN NUMBER) RETURN VARCHAR2 AS
6127 
6128 eventTitle    VARCHAR2(80);
6129 
6130 BEGIN
6131    BEGIN
6132       select event.event_title
6133  into eventTitle
6134  from pon_auction_headers_all ah,pon_auction_events event
6135  where auction_header_id = p_auction_number
6136  and  ah.event_id=event.event_id;
6137    EXCEPTION
6138       WHEN NO_DATA_FOUND THEN
6139  eventTitle := '';
6140    END;
6141 
6142    return(eventTitle);
6143 END;
6144 
6145 --
6146 -- Retrieves message for the specific document type based on the msg_suffix (_B, _R etc.)
6147 --
6148 
6149 FUNCTION getMessage (msg VARCHAR2) RETURN VARCHAR2 AS
6150 message VARCHAR2(2000);
6151 BEGIN
6152    BEGIN
6153 
6154         -- In ERP only three arguements.
6155   --message := PON_PROFILE_UTIL_PKG.GET_STRING(PON_AUCTION_PKG.OperationId, 'PON', msg, PON_AUCTION_PKG.SessionLanguage);
6156   message := PON_PROFILE_UTIL_PKG.GET_STRING('PON', msg, PON_AUCTION_PKG.SessionLanguage);
6157 
6158   if (message is null) then
6159     message := fnd_message.get_string('PON', msg);
6160   end if;
6161 
6162    EXCEPTION
6163       WHEN others THEN
6164       message := null;
6165    END;
6166 
6167    if (message is null) then
6168   message := msg;
6169    end if;
6170 
6171    return(message);
6172 END;
6173 
6174 --
6175 -- Retrieves tokenized message for the specific document type based on the msg_suffix (_B, _R etc.)
6176 --
6177 
6178 FUNCTION getMessage (msg VARCHAR2, msg_suffix VARCHAR2) RETURN VARCHAR2 AS
6179 message VARCHAR2(2000);
6180 BEGIN
6181     message := getMessage(substrb(msg,1,28)||msg_suffix);
6182    if ( message = substrb(msg,1,28)||msg_suffix) then
6183       return getMessage (msg);
6184    else
6185       return(message);
6186    end if;
6187 
6188 END;
6189 
6190 --
6191 -- Retrieves tokenized message for the specific document type based on the msg_suffix (_B, _R etc.)
6192 --
6193 
6194 FUNCTION getMessage (msg VARCHAR2, msg_suffix VARCHAR2, token VARCHAR2, token_value VARCHAR2) RETURN VARCHAR2 AS
6195    message VARCHAR2(2000);
6196    application_code VARCHAR2(5) := 'PON';
6197    ind NUMBER := 1;
6198 BEGIN
6199 
6200    MsgTokens.DELETE;
6201    MsgTokenValues.DELETE;
6202    MsgTokens(ind) := token;
6203    MsgTokenValues(ind) := token_value;
6204 
6205    message := getMessage(substrb(msg,1,28)||msg_suffix);
6206    if ( message = substrb(msg,1,28)||msg_suffix) then
6207       return getTokenMessage(msg);
6208    else
6209       return getTokenMessage(substrb(msg,1,28)||msg_suffix);
6210    end if;
6211 END;
6212 
6213 
6214 FUNCTION getTokenMessage (msg VARCHAR2) RETURN
6215  VARCHAR2 AS
6216    message VARCHAR2(1000);
6217    application_code VARCHAR2(5) := 'PON';
6218 BEGIN
6219    BEGIN
6220       message := GET_STRING('PON', msg, PON_AUCTION_PKG.SessionLanguage);
6221    EXCEPTION
6222       WHEN others THEN
6223       message := null;
6224    END;
6225 
6226    if (message is null) then
6227       return msg;
6228    else
6229       return(message);
6230    end if;
6231 END;
6232 
6233 FUNCTION getMessage (msg VARCHAR2, msg_suffix VARCHAR2, token1 VARCHAR2,
6234       token1_value VARCHAR2, token2 VARCHAR2, token2_value VARCHAR2) RETURN VARCHAR2 AS
6235    message VARCHAR2(2000);
6236    application_code VARCHAR2(5) := 'PON';
6237    ind NUMBER := 1;
6238 BEGIN
6239    message := getMessage(substrb(msg,1,28)||msg_suffix);
6240 
6241    MsgTokens.DELETE;
6242    MsgTokenValues.DELETE;
6243    MsgTokens(ind) := token1;
6244    MsgTokenValues(ind) := token1_value;
6245    MsgTokens(ind+1) := token2;
6246    MsgTokenValues(ind+1) := token2_value;
6247 
6248    if ( message = substrb(msg,1,28)||msg_suffix) then
6249       return getTokenMessage(msg);
6250    else
6251       return getTokenMessage(substrb(msg,1,28)||msg_suffix);
6252    end if;
6253 END;
6254 
6255 FUNCTION getMessage (msg VARCHAR2, msg_suffix VARCHAR2, token1 VARCHAR2, token1_value VARCHAR2,
6256          token2 VARCHAR2, token2_value VARCHAR2, token3 VARCHAR2,
6257          token3_value VARCHAR2) RETURN VARCHAR2 AS
6258    message VARCHAR2(2000);
6259    application_code VARCHAR2(5) := 'PON';
6260    ind NUMBER := 1;
6261 BEGIN
6262    message := getMessage(substrb(msg,1,28)||msg_suffix);
6263 
6264    MsgTokens.DELETE;
6265    MsgTokenValues.DELETE;
6266    MsgTokens(ind) := token1;
6267    MsgTokenValues(ind) := token1_value;
6268    MsgTokens(ind+1) := token2;
6269    MsgTokenValues(ind+1) := token2_value;
6270    MsgTokens(ind+2) := token3;
6271    MsgTokenValues(ind+2) := token3_value;
6272 
6273    if ( message = substrb(msg,1,28)||msg_suffix) then
6274       return getTokenMessage(msg);
6275    else
6276       return getTokenMessage(substrb(msg,1,28)||msg_suffix);
6277    end if;
6278 END;
6279 
6280 FUNCTION getMessage (msg VARCHAR2, msg_suffix VARCHAR2, token1 VARCHAR2, token1_value VARCHAR2,
6281          token2 VARCHAR2, token2_value VARCHAR2, token3 VARCHAR2, token3_value VARCHAR2,
6282          token4 VARCHAR2, token4_value VARCHAR2) RETURN VARCHAR2 AS
6283    message VARCHAR2(2000);
6284    application_code VARCHAR2(5) := 'PON';
6285    ind NUMBER := 1;
6286 BEGIN
6287    message := getMessage(substrb(msg,1,28)||msg_suffix);
6288 
6289    MsgTokens.DELETE;
6290    MsgTokenValues.DELETE;
6291    MsgTokens(ind) := token1;
6292    MsgTokenValues(ind) := token1_value;
6293    MsgTokens(ind+1) := token2;
6294    MsgTokenValues(ind+1) := token2_value;
6295    MsgTokens(ind+2) := token3;
6296    MsgTokenValues(ind+2) := token3_value;
6297    MsgTokens(ind+3) := token4;
6298    MsgTokenValues(ind+3) := token4_value;
6299 
6300    if ( message = substrb(msg,1,28)||msg_suffix) then
6301       return getTokenMessage(msg);
6302    else
6303       return getTokenMessage(substrb(msg,1,28)||msg_suffix);
6304    end if;
6305 END;
6306 
6307 FUNCTION getMessage (msg VARCHAR2, msg_suffix VARCHAR2, token1 VARCHAR2, token1_value VARCHAR2,
6308          token2 VARCHAR2, token2_value VARCHAR2, token3 VARCHAR2, token3_value VARCHAR2,
6309          token4 VARCHAR2, token4_value VARCHAR2, token5 VARCHAR2, token5_value VARCHAR2) RETURN VARCHAR2 AS
6310    message VARCHAR2(2000);
6311    application_code VARCHAR2(5) := 'PON';
6312    ind NUMBER := 1;
6313 BEGIN
6314    message := getMessage(substrb(msg,1,28)||msg_suffix);
6315 
6316    MsgTokens.DELETE;
6317    MsgTokenValues.DELETE;
6318    MsgTokens(ind) := token1;
6319    MsgTokenValues(ind) := token1_value;
6320    MsgTokens(ind+1) := token2;
6321    MsgTokenValues(ind+1) := token2_value;
6322    MsgTokens(ind+2) := token3;
6323    MsgTokenValues(ind+2) := token3_value;
6324    MsgTokens(ind+3) := token4;
6325    MsgTokenValues(ind+3) := token4_value;
6326    MsgTokens(ind+4) := token5;
6327    MsgTokenValues(ind+4) := token5_value;
6328 
6329    if ( message = substrb(msg,1,28)||msg_suffix) then
6330       return getTokenMessage(msg);
6331    else
6332       return getTokenMessage(substrb(msg,1,28)||msg_suffix);
6333    end if;
6334 END;
6335 
6336 FUNCTION GET_MESSAGE_SUFFIX (x_doctype_group_name VARCHAR2) RETURN VARCHAR2 AS
6337 
6338 x_msg_suffix PON_AUC_DOCTYPES.MESSAGE_SUFFIX%TYPE := '';
6339 
6340 BEGIN
6341    BEGIN
6342       SELECT message_suffix
6343       INTO x_msg_suffix
6344       FROM pon_auc_doctypes
6345       WHERE doctype_group_name = x_doctype_group_name;
6346    EXCEPTION WHEN NO_DATA_FOUND THEN
6347       x_msg_suffix := '';
6348    END;
6349    IF(x_msg_suffix IS null) THEN
6350       RETURN '';
6351    ELSE
6352       RETURN ('_'||x_msg_suffix);
6353    END IF;
6354 END;
6355 
6356 FUNCTION GET_TRANSACTION_TYPE (p_doctype_group_name PON_AUC_DOCTYPES.INTERNAL_NAME%TYPE)
6357   RETURN PON_AUC_DOCTYPES.TRANSACTION_TYPE%TYPE AS
6358 
6359 x_trans_type PON_AUC_DOCTYPES.TRANSACTION_TYPE%TYPE;
6360 
6361 BEGIN
6362    BEGIN
6363       SELECT transaction_type
6364       INTO x_trans_type
6365       FROM pon_auc_doctypes
6366       WHERE doctype_group_name = p_doctype_group_name;
6367    EXCEPTION WHEN NO_DATA_FOUND THEN
6368       x_trans_type := '';
6369    END;
6370    return x_trans_type;
6371 END;
6372 
6373 
6374 --
6375 -- must provide at least one of the two arguments. both cannot be null.
6376 --
6377 
6378 PROCEDURE SET_SESSION_LANGUAGE(p_language VARCHAR2, p_language_code VARCHAR2) is
6379 
6380   x_language_code VARCHAR2(60);
6381   x_language VARCHAR2(60);
6382 BEGIN
6383      IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6384        FND_LOG.string(log_level => FND_LOG.level_statement,
6385          module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6386          message  => 'Entered procedure : p_language_code ' || p_language_code);
6387      END IF; --}
6388 
6389      g_original_lang_code := fnd_global.current_language;
6390 
6391      IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6392         FND_LOG.string(log_level => FND_LOG.level_statement,
6393           module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6394           message  => 'g_original_lang_code ' || g_original_lang_code);
6395      END IF; --}
6396 
6397    if (g_original_lang_code  is not null) then
6398 
6399            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6400             FND_LOG.string(log_level => FND_LOG.level_statement,
6401                module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6402                message  => 'g_original_lang_code is not null so selecting g_original_language from the DB ');
6403            END IF; --}
6404 
6405          select nls_language
6406          into g_original_language
6407          from fnd_languages
6408          where language_code = g_original_lang_code;
6409 
6410            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6411             FND_LOG.string(log_level => FND_LOG.level_statement,
6412               module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6413               message  => 'g_original_lang_code is : ' || g_original_lang_code || ' after selecting it from the DB ');
6414            END IF; --}
6415 
6416 
6417    else
6418            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6419            FND_LOG.string(log_level => FND_LOG.level_statement,
6420              module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6421              message  => 'g_original_lang_code is null, so defaulting the language to US');
6422            END IF; --}
6423 
6424           g_original_lang_code := 'US';
6425         g_original_language := 'AMERICAN';
6426 
6427      end if;
6428 
6429           begin
6430        IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6431          FND_LOG.string(log_level => FND_LOG.level_statement,
6432            module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6433            message  => 'p_language_code : ' || p_language_code);
6434          END IF; --}
6435 
6436     if (p_language_code is null) then
6437 
6438          IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6439                FND_LOG.string(log_level => FND_LOG.level_statement,
6440                  module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6441                  message  => 'p_language_code is NULL so selecting it from fnd_language ');
6442          END IF; --}
6443 
6444       select language_code
6445       into x_language_code
6446       from fnd_languages
6447       where nls_language = p_language;
6448 
6449             IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6450              FND_LOG.string(log_level => FND_LOG.level_statement,
6451                module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6452                message  => 'x_language_code : ' || x_language_code);
6453             END IF; --}
6454 
6455     else
6456 
6457             IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6458              FND_LOG.string(log_level => FND_LOG.level_statement,
6459                module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6460                message  => 'p_language_code is NOT NULL so assigning it to x_language_code');
6461             END IF; --}
6462 
6463       x_language_code := p_language_code;
6464 
6465 
6466             IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6467               FND_LOG.string(log_level => FND_LOG.level_statement,
6468                 module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6469                 message  => 'x_language_code : ' || x_language_code);
6470             END IF; --}
6471     end if;
6472 
6473        IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6474         FND_LOG.string(log_level => FND_LOG.level_statement,
6475           module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6476           message  => 'p_language : ' || p_language);
6477         END IF; --}
6478 
6479     if (p_language is not null) then
6480 
6481            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6482               FND_LOG.string(log_level => FND_LOG.level_statement,
6483                 module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6484                 message  => 'p_language is not NULL so calling the dbms_session.set_nls with p_language : '|| p_language);
6485            END IF; --}
6486 
6487        dbms_session.set_nls('NLS_LANGUAGE', p_language);
6488     else
6489 
6490            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6491              FND_LOG.string(log_level => FND_LOG.level_statement,
6492                module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6493                message  => 'p_language is NULL so selecting it from fnd_languages');
6494            END IF; --}
6495 
6496       select nls_language
6497       into x_language
6498       from fnd_languages
6499       where language_code = x_language_code;
6500 
6501       dbms_session.set_nls('NLS_LANGUAGE', x_language);
6502 
6503             IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6504              FND_LOG.string(log_level => FND_LOG.level_statement,
6505                module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6506                message  => 'x_language : ' || x_language ||'; calling dbms_session.set_nls with x_language : '|| x_language);
6507             END IF; --}
6508 
6509     end if;
6510           exception
6511     when others then
6512 
6513           IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6514               FND_LOG.string(log_level => FND_LOG.level_statement,
6515                 module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6516                 message  => 'Exception when running the procedure; doing nothing');
6517           END IF; --}
6518 
6519     null;
6520           end;
6521 
6522         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6523             FND_LOG.string(log_level => FND_LOG.level_statement,
6524                 module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6525                 message  => 'Setting PON_AUCTION_PKG.SessionLanguage to x_language_code : ' || x_language_code);
6526         END IF; --}
6527 
6528     -- set this package variable to be used with the get_message calls.
6529     PON_AUCTION_PKG.SessionLanguage := x_language_code;
6530 
6531         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6532             FND_LOG.string(log_level => FND_LOG.level_statement,
6533                module => g_module_prefix || 'SET_SESSION_LANGUAGE',
6534                message  => 'Setting PON_AUCTION_PKG.SessionLanguage : ' || PON_AUCTION_PKG.SessionLanguage);
6535         END IF; --}
6536 
6537 END;
6538 
6539 
6540 PROCEDURE UNSET_SESSION_LANGUAGE is
6541 BEGIN
6542         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6543             FND_LOG.string(log_level => FND_LOG.level_statement,
6544                 module => g_module_prefix || 'UNSET_SESSION_LANGUAGE',
6545                 message  => 'Entered the procedure; g_original_language : ' || g_original_language);
6546         END IF; --}
6547 
6548           begin
6549     --dbms_session.set_nls('NLS_LANGUAGE', 'AMERICAN');
6550         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6551             FND_LOG.string(log_level => FND_LOG.level_statement,
6552                 module => g_module_prefix || 'UNSET_SESSION_LANGUAGE',
6553                 message  => 'calling  dbms_session.set_nls with g_original_language : ' || g_original_language);
6554         END IF; --}
6555 
6556         dbms_session.set_nls('NLS_LANGUAGE', g_original_language);
6557           exception
6558     when others then
6559         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6560         FND_LOG.string(log_level => FND_LOG.level_statement,
6561           module => g_module_prefix || 'UNSET_SESSION_LANGUAGE',
6562           message  => 'Exception when running the procedure; doing nothing');
6563         END IF; --}
6564 
6565     null;
6566           end;
6567 
6568         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6569             FND_LOG.string(log_level => FND_LOG.level_statement,
6570                 module => g_module_prefix || 'UNSET_SESSION_LANGUAGE',
6571                 message  => 'Setting PON_AUCTION_PKG.SessionLanguage to g_original_lang_code : ' || g_original_lang_code);
6572         END IF; --}
6573     -- unset this package variable (used by the get_message calls).
6574    -- PON_AUCTION_PKG.SessionLanguage := 'US';
6575       PON_AUCTION_PKG.SessionLanguage := g_original_lang_code;
6576 
6577         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
6578             FND_LOG.string(log_level => FND_LOG.level_statement,
6579                 module => g_module_prefix || 'UNSET_SESSION_LANGUAGE',
6580                 message  => 'Setting PON_AUCTION_PKG.SessionLanguage : ' || PON_AUCTION_PKG.SessionLanguage);
6581         END IF; --}
6582 
6583 END;
6584 
6585 
6586 PROCEDURE NOTIFY_BIDDERS_OF_CANCEL (itemtype    in varchar2,
6587             itemkey    in varchar2,
6588             actid           in number,
6589             uncmode    in varchar2,
6590             resultout       out NOCOPY varchar2)
6591 IS
6592    x_action_code varchar2(40) := 'CANCEL';
6593 BEGIN
6594 
6595   NOTIFY_BIDDERS_AUC_CHANGED(itemtype,
6596            itemkey,
6597            actid,
6598            uncmode,
6599            x_action_code);
6600 END;
6601 
6602 
6603 --
6604 -- Called to notify other bidders that a bid has been disqualified
6605 --
6606 
6607 PROCEDURE NOTIFY_OTHER_BIDDERS_OF_DISQ(itemtype    in varchar2,
6608                itemkey    in varchar2,
6609                actid           in number,
6610                uncmode    in varchar2,
6611                resultout       out NOCOPY varchar2)
6612 IS
6613         x_action_code varchar2(40) := 'DISQUALIFY_BID';
6614 BEGIN
6615 
6616   NOTIFY_BIDDERS_AUC_CHANGED(itemtype,
6617            itemkey,
6618            actid,
6619            uncmode,
6620            x_action_code);
6621 END;
6622 
6623 
6624 PROCEDURE NOTIFY_BIDDERS_AUC_CHANGED(itemtype    in varchar2,
6625              itemkey    in varchar2,
6626              actid           in number,
6627              uncmode    in varchar2,
6628              action_code    in varchar2)
6629 IS
6630 
6631    x_doc_number                  number;
6632    x_profile_user               VARCHAR2(240) := '';
6633    x_bidder_tp_name              PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
6634    x_vendor_site_code            PON_BIDDING_PARTIES.VENDOR_SITE_CODE%TYPE;
6635    x_vendor_site_id              NUMBER;
6636    x_trading_partner_contact_id  PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_ID%TYPE;
6637    x_wf_role_name                varchar2(100) := '';
6638    x_language_code               varchar2(30);
6639    x_message_name                varchar2(80);
6640    x_doc_number_dsp              varchar2(60);
6641    x_auction_title               PON_AUCTION_HEADERS_ALL.AUCTION_TITLE%TYPE;
6642    x_auction_start_date          date;
6643    x_auction_end_date            date;
6644    x_preview_date              DATE;
6645    x_timezone                    VARCHAR2(80);
6646    x_wf_item_key               VARCHAR2(240);
6647    x_change_type                 number; -- extend: 1, shorten: 2
6648    x_original_close_bidding_date PON_AUCTION_HEADERS_ALL.ORIGINAL_CLOSE_BIDDING_DATE%TYPE;
6649    x_event_title                 varchar2(240) := '';
6650    x_event_id                    NUMBER;
6651    x_bad_bidder                  varchar2(80) := null;
6652    x_tp_contact_name PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_NAME%TYPE; -- Bug 3824928 added
6653    x_staggered_closing_interval  NUMBER;
6654 
6655 
6656     CURSOR bidders IS
6657       select wfu.user_name user_name, person_party_id
6658       from wf_user_roles wfu, fnd_user fnd
6659       where role_name = x_wf_role_name
6660       and fnd.user_name (+) =  wfu.user_name
6661       AND wfu.user_name NOT IN (SELECT wf_user_name FROM pon_bidding_parties
6662         WHERE auction_header_id = x_doc_number AND trading_partner_id IS NULL);
6663 
6664     CURSOR bidders_info IS
6665       select trading_partner_name, decode(vendor_site_code, '-1', null, vendor_site_code) vendor_site_code, nvl(vendor_site_id, -1) vendor_site_id
6666       from pon_bidding_parties
6667       where trading_partner_contact_id = x_trading_partner_contact_id
6668       and auction_header_id = x_doc_number
6669       union
6670       select trading_partner_name, decode(vendor_site_code, '-1', null, vendor_site_code) vendor_site_code, nvl(vendor_site_id, -1) vendor_site_id
6671       from pon_bid_headers
6672       where trading_partner_contact_id = x_trading_partner_contact_id
6673       and auction_header_id = x_doc_number;
6674 
6675 
6676 begin
6677 
6678       x_doc_number := wf_engine.GetItemAttrNumber (itemtype   => itemtype,
6679                                                    itemkey    => itemkey,
6680                                                    aname      => 'AUCTION_ID');
6681 
6682       x_doc_number_dsp := wf_engine.GetItemAttrText (itemtype   => itemtype,
6683                                                      itemkey    => itemkey,
6684                                                   aname      => 'DOC_NUMBER');
6685 
6686       x_auction_title := wf_engine.GetItemAttrText (itemtype   => itemtype,
6687                                                     itemkey    => itemkey,
6688                                                     aname      => 'AUCTION_TITLE');
6689 
6690       x_auction_start_date  := wf_engine.GetItemAttrDate (itemtype   => itemtype,
6691                                                           itemkey    => itemkey,
6692                                                           aname      => 'AUCTION_START_DATE');
6693 
6694       x_auction_end_date  := wf_engine.GetItemAttrDate (itemtype   => itemtype,
6695                                                         itemkey    => itemkey,
6696                                                         aname      => 'AUCTION_END_DATE');
6697 
6698       -- Bug 3824928: added below
6699 --      x_tp_contact_name := wf_engine.GetItemAttrText (itemtype => itemtype,
6700 --                                                         itemkey  => itemkey,
6701 --                                                         aname    => 'PREPARER_TP_CONTACT_NAME');
6702 
6703 
6704 
6705       x_preview_date := wf_engine.GetItemAttrDate (itemtype   => itemtype,
6706                                                    itemkey    => itemkey,
6707                                                    aname      => 'PREVIEW_DATE_TZ');
6708 
6709 
6710     begin
6711         select wf_role_name, wf_item_key, original_close_bidding_date, event_id, trading_partner_contact_name,
6712                staggered_closing_interval
6713         into  x_wf_role_name, x_wf_item_key, x_original_close_bidding_date, x_event_id, x_tp_contact_name,
6714               x_staggered_closing_interval
6715         from pon_auction_headers_all
6716         where auction_header_id = x_doc_number;
6717     exception
6718         when others then
6719         x_wf_role_name := '';
6720     end;
6721 
6722     if (x_wf_role_name = '') then
6723         return;
6724     end if;
6725 
6726     if (action_code is not null and action_code = 'CLOSEEARLY') then
6727         x_message_name := 'NEGOTIATION_CLOSED_EARLY';
6728     elsif (action_code = 'CLOSECHANGED') then
6729 
6730         begin
6731           x_change_type := wf_engine.GetItemAttrNumber (itemtype => itemtype,
6732                                         itemkey  => itemkey,
6733                                         aname => 'CHANGE_TYPE');
6734         exception
6735         when others then
6736           x_change_type := 1; -- for auctions created before version 115.20 of ponwfau1.wft this attribute did not exist
6737         end;
6738 
6739         -- auctioneer extends the auction
6740         if (x_change_type = 1) then
6741             x_message_name := 'NEGOTIATION_EXTENDED';
6742         -- auctioneer shortens the auction
6743         else
6744             x_message_name := 'NEGOTIATION_SHORTENED';
6745         end if;
6746     elsif (action_code = 'CANCEL') then
6747       IF (x_event_id is not null) THEN
6748           x_event_title := getEventTitle (x_doc_number);
6749           IF x_event_title IS NOT NULL THEN
6750              x_message_name := 'NEGOTIATION_CANCELED_EVENT';
6751           END IF;
6752       ELSE
6753           x_message_name := 'NEGOTIATION_CANCELED';
6754       END IF;
6755     elsif (action_code = 'DISQUALIFY_BID') then
6756         x_message_name := 'BID_DISQUALIFY_NOTIFY_OTHER';
6757 
6758     end if;
6759 
6760    FOR bidder IN bidders LOOP
6761 
6762       if (member_user(bidder.user_name)) then
6763 
6764          PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(bidder.user_name,x_language_code);
6765          x_trading_partner_contact_id := bidder.person_party_id;
6766 
6767          -- Get the timezone for the user
6768          x_timezone := Get_Time_Zone(bidder.person_party_id);
6769 
6770          FOR bidder_info IN bidders_info LOOP
6771 
6772           x_bidder_tp_name := bidder_info.trading_partner_name;
6773           x_vendor_site_code := bidder_info.vendor_site_code;
6774           x_vendor_site_id := bidder_info.vendor_site_id;
6775 
6776           -- send a notification to bidders
6777           SEND_BIDDERS_NOTIFICATION(itemtype                   => itemtype,
6778                                  itemkey                       => itemkey,
6779                                  actid                         => actid,
6780                                  p_action_code                 => action_code,
6781                                  p_user                        => bidder.user_name,
6782                                  p_bidder_tp_name              => x_bidder_tp_name,
6783                                  p_vendor_site_code            => x_vendor_site_code,
6784                                  p_vendor_site_id              => x_vendor_site_id,
6785                                  p_message_name                => x_message_name,
6786                                  p_doc_number_dsp              => x_doc_number_dsp,
6787                                  p_auction_title               => x_auction_title,
6788                                  p_auction_start_date          => x_auction_start_date,
6789                                  p_auction_end_date            => x_auction_end_date,
6790                                  p_preview_date                => x_preview_date,
6791                                  p_language_code               => x_language_code,
6792                                  p_timezone                    => x_timezone,
6793                                  p_change_type                 => x_change_type,
6794                                  p_original_close_bidding_date => x_original_close_bidding_date,
6795                                  p_event_title                 => x_event_title,
6796                                  p_auc_tp_contact_name         => x_tp_contact_name,
6797                                  p_staggered_closing_interval  => x_staggered_closing_interval);
6798 
6799 
6800          END LOOP;
6801       elsif (additional_bidder(bidder.user_name, x_doc_number, x_tp_contact_name, x_profile_user)) then
6802          -- Bug 3824928: logic here will handle additional contact users
6803          -- associated to a trading partner contact id or not.
6804 
6805         PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(x_profile_user,x_language_code);
6806 
6807        select trading_partner_name, decode(vendor_site_code, '-1', null, vendor_site_code) vendor_site_code, nvl(vendor_site_id, -1) vendor_site_id
6808        into x_bidder_tp_name, x_vendor_site_code, x_vendor_site_id
6809        from pon_bidding_parties
6810        where wf_user_name = bidder.user_name
6811        and auction_header_id = x_doc_number;
6812 
6813        -- Get the timezone for the user
6814        x_timezone := Get_Time_Zone(x_profile_user);
6815 
6816        -- send a notification to additional bidder contact
6817        SEND_BIDDERS_NOTIFICATION(itemtype                      => itemtype,
6818                                  itemkey                       => itemkey,
6819                                  actid                         => actid,
6820                                  p_action_code                 => action_code,
6821                                  p_user                        => bidder.user_name,
6822                                  p_bidder_tp_name              => x_bidder_tp_name,
6823                                  p_vendor_site_code            => x_vendor_site_code,
6824                                  p_vendor_site_id              => x_vendor_site_id,
6825                                  p_message_name                => x_message_name,
6826                                  p_doc_number_dsp              => x_doc_number_dsp,
6827                                  p_auction_title               => x_auction_title,
6828                                  p_auction_start_date          => x_auction_start_date,
6829                                  p_auction_end_date            => x_auction_end_date,
6830                                  p_preview_date                => x_preview_date,
6831                                  p_language_code               => x_language_code,
6832                                  p_timezone                    => x_timezone,
6833                                  p_change_type                 => x_change_type,
6834                                  p_original_close_bidding_date => x_original_close_bidding_date,
6835                                  p_event_title                 => x_event_title,
6836                                  p_auc_tp_contact_name         => x_tp_contact_name,
6837                                  p_staggered_closing_interval  => x_staggered_closing_interval);
6838 
6839 
6840     end if;
6841 
6842   END LOOP;
6843   UNSET_SESSION_LANGUAGE;
6844 
6845 end;
6846 
6847 PROCEDURE NOTIFY_BIDDERS_OF_CLOSEEARLY (itemtype            in varchar2,
6848                                     itemkey             in varchar2,
6849                                     actid               in number,
6850                                     uncmode             in varchar2,
6851                                     resultout           out NOCOPY varchar2)
6852 IS
6853    x_action_code varchar2(40) := 'CLOSEEARLY';
6854 BEGIN
6855 
6856         NOTIFY_BIDDERS_AUC_CHANGED(itemtype,
6857                                    itemkey,
6858                                    actid,
6859                                    uncmode,
6860                                    x_action_code);
6861 END;
6862 
6863 PROCEDURE NOTIFY_BIDDERS_OF_CLOSECHANGED (itemtype            in varchar2,
6864                                     itemkey             in varchar2,
6865                                     actid               in number,
6866                                     uncmode             in varchar2,
6867                                     resultout           out NOCOPY varchar2)
6868 IS
6869    x_action_code varchar2(40) := 'CLOSECHANGED';
6870 BEGIN
6871 
6872         NOTIFY_BIDDERS_AUC_CHANGED(itemtype,
6873                                    itemkey,
6874                                    actid,
6875                                    uncmode,
6876                                    x_action_code);
6877 END;
6878 
6879 
6880 PROCEDURE  NOTIFY_NEW_INVITEES (p_auction_id  NUMBER) IS -- 1
6881 
6882 x_auction_header_id  NUMBER;
6883 x_preview_date     DATE;
6884 x_progress     VARCHAR2(3);
6885 x_sequence    NUMBER;
6886 x_itemtype    VARCHAR2(8) := 'PONPBLSH';
6887 x_itemkey    VARCHAR2(50);
6888 x_user_name    VARCHAR2(100);
6889 x_contact_id    NUMBER;
6890 x_timezone    VARCHAR2(80);
6891 x_timezone1    VARCHAR2(80);
6892 x_newstarttime    DATE;
6893 x_newendtime    DATE;
6894 x_startdate    DATE;
6895 x_enddate    DATE;
6896 x_auctioneer_tag        Varchar2(30);
6897 x_event_id              NUMBER;
6898 x_event_title           VARCHAR2(80);
6899 x_language_code    VARCHAR2(3);
6900 x_auctioneer_user_name  VARCHAR2(100);
6901 x_preview_message       VARCHAR2(100);
6902 x_article_doc_type      VARCHAR2(100);
6903 
6904 x_doctype_group_name    VARCHAR2(100);
6905 x_msg_suffix     VARCHAR2(3) := '';
6906 x_doc_number_dsp   VARCHAR2(30);
6907 x_auction_contact_id    NUMBER;
6908 x_oex_timezone          VARCHAR2(80);
6909 x_oex_timezone1          VARCHAR2(80);
6910 
6911 x_wf_role_name          VARCHAR2(30);
6912 x_app                   VARCHAR2(20);
6913 
6914 x_oex_header            VARCHAR2(2000);
6915 x_oex_footer            VARCHAR2(2000);
6916 x_status                VARCHAR2(10);
6917 x_exception_msg         VARCHAR2(100);
6918 x_oex_operation    VARCHAR2(2000);
6919 x_auction_owner_tp_name VARCHAR2(300);
6920 x_tp_display_name  VARCHAR2(300);
6921 x_auction_title    VARCHAR2(2000);
6922 --lxchen
6923 x_note_to_new_supplier_type  VARCHAR2(30);
6924 
6925 p_itemtype varchar2(20) := 'PONAUCT';
6926 p_itemkey varchar2(360);
6927 x_timezone_disp VARCHAR2(240);
6928 x_auction_header_id_encrypted VARCHAR2(2000);
6929 x_vendor_site_id     NUMBER;
6930 x_preview_date_notspec VARCHAR2(240);
6931 
6932 
6933 BEGIN
6934 
6935       select wf_item_key into p_itemkey
6936       from pon_auction_headers_all
6937       where auction_header_id = p_auction_id;
6938 
6939       x_progress := '010';
6940 
6941       x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
6942                                                           itemkey  => p_itemkey,
6943                                                           aname    => 'AUCTION_ID');
6944 
6945 
6946       -- Bug 8992789
6947       IF (IS_INTERNAL_ONLY(x_auction_header_id)) THEN
6948         RETURN;
6949       END IF;
6950 
6951       x_auction_header_id_encrypted := wf_engine.GetItemAttrText (itemtype => p_itemtype,
6952                                                          itemkey  => p_itemkey,
6953                                                          aname    => 'AUCTION_ID_ENCRYPTED');
6954 
6955       x_preview_date := wf_engine.GetItemAttrDate (itemtype   => p_itemtype,
6956                                                    itemkey    => p_itemkey,
6957                                                    aname      => 'PREVIEW_DATE');
6958 
6959       x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => p_itemtype,
6960                                                            itemkey  => p_itemkey,
6961                                                            aname    => 'PREVIEW_DATE_NOTSPECIFIED');
6962 
6963       BEGIN
6964             x_doctype_group_name := wf_engine.GetItemAttrText   (itemtype => p_itemtype,
6965                                                                  itemkey  => p_itemkey,
6966                                                                  aname    => 'DOC_INTERNAL_NAME');
6967       EXCEPTION
6968       WHEN OTHERS THEN
6969             select dt.doctype_group_name
6970             into x_doctype_group_name
6971             from pon_auction_headers_all auh, pon_auc_doctypes dt
6972             where auh.auction_header_id = x_auction_header_id
6973             and auh.doctype_id = dt.doctype_id;
6974       END;
6975 
6976       BEGIN
6977             x_doc_number_dsp     := wf_engine.GetItemAttrText   (itemtype => p_itemtype,
6978                                                                  itemkey  => p_itemkey,
6979                                                                  aname    => 'DOC_NUMBER');
6980       EXCEPTION
6981       WHEN OTHERS THEN
6982             x_doc_number_dsp   := to_char(x_auction_header_id);
6983       END;
6984 
6985 
6986 
6987       --
6988       -- Get next value in sequence for itemkey
6989       --
6990 
6991       SELECT pon_auction_wf_publish_s.nextval
6992       INTO   x_sequence
6993       FROM   dual;
6994 
6995 
6996       x_itemkey := (p_itemkey||'-'||to_char(x_sequence));
6997 
6998       wf_engine.CreateProcess(itemtype => x_itemtype,
6999                               itemkey  => x_itemkey,
7000                               process  => 'ADDED_INVITEES_MESSAGE');
7001 
7002       --
7003       -- Set all the item attributes
7004       --
7005 
7006       x_progress := '022';
7007 
7008       wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
7009                                    itemkey    => x_itemkey,
7010                                    aname      => 'AUCTION_ID',
7011                                    avalue     => x_auction_header_id); /* using auction_id instead of
7012                                                                          auction_number as a standard
7013                                                                          across item types */
7014 
7015       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
7016                                  itemkey    => x_itemkey,
7017                                  aname      => 'DOC_NUMBER',
7018                                  avalue     => x_doc_number_dsp);
7019 
7020       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
7021                                  itemkey    => x_itemkey,
7022                                  aname      => 'ORIGIN_USER_NAME',
7023                                  avalue     => fnd_global.user_name);
7024 
7025       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
7026                                  itemkey    => x_itemkey,
7027                                  aname      => 'NOTE_TO_BIDDERS',
7028                                  avalue     => replaceHtmlChars(wf_engine.GetItemAttrText (itemtype => p_itemtype,
7029                     itemkey  => p_itemkey,
7030                     aname    => 'NOTE_TO_BIDDERS')));
7031 
7032       select view_by_date
7033       into x_preview_date
7034       from pon_auction_headers_all where auction_header_id = x_auction_header_id;
7035 
7036       x_auction_title := wf_engine.GetItemAttrText(itemtype => p_itemtype,
7037                                  itemkey  => p_itemkey,
7038                                  aname    => 'AUCTION_TITLE');
7039 
7040       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
7041                                  itemkey    => x_itemkey,
7042                                  aname      => 'AUCTION_TITLE',
7043                                  avalue     => replaceHtmlChars(x_auction_title));
7044 
7045       x_auction_owner_tp_name := wf_engine.GetItemAttrText(itemtype => p_itemtype,
7046                                    itemkey  => p_itemkey,
7047                                    aname    => 'PREPARER_TP_NAME');
7048 
7049       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
7050                                  itemkey    => x_itemkey,
7051                                  aname      => 'PREPARER_TP_NAME',
7052                              avalue     => x_auction_owner_tp_name);
7053 
7054       wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
7055                                    itemkey    => x_itemkey,
7056                                    aname      => 'NUMBER_OF_ITEMS',
7057                              avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
7058                                                                  itemkey  => p_itemkey,
7059                                                                 aname    => 'NUMBER_OF_ITEMS'));
7060       wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
7061                                  itemkey    => x_itemkey,
7062                                  aname      => 'PREVIEW_DATE',
7063                              avalue     => x_preview_date);
7064 
7065       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
7066                                  itemkey    => x_itemkey,
7067                                  aname      => 'PREVIEW_DATE_NOTSPECIFIED',
7068                              avalue     => x_preview_date_notspec);
7069 
7070       BEGIN
7071             wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
7072                                          itemkey    => x_itemkey,
7073                                          aname      => 'DOC_ROUND_NUMBER',
7074                                          avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
7075                                                                                     itemkey  => p_itemkey,
7076                                                                                     aname    => 'DOC_ROUND_NUMBER'));
7077       EXCEPTION
7078       WHEN OTHERS THEN
7079             wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
7080                                          itemkey    => x_itemkey,
7081                                          aname      => 'DOC_ROUND_NUMBER',
7082                                          avalue     => 1);
7083       END;
7084 
7085       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
7086                                itemkey    => x_itemkey,
7087                                aname      => 'DOC_INTERNAL_NAME',
7088                                avalue     => x_doctype_group_name);
7089 
7090       begin
7091 
7092         wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
7093                                          itemkey    => x_itemkey,
7094                                          aname      => '#WFM_HTMLAGENT',
7095                                          avalue     => pon_wf_utl_pkg.get_base_external_supplier_url);
7096       exception when others then
7097         null;
7098       end;
7099 
7100      -- Bug 4295915: Set the  workflow owner
7101       wf_engine.SetItemOwner(itemtype => x_itemtype,
7102                              itemkey  => x_itemkey,
7103                              owner    => fnd_global.user_name);
7104 
7105       --
7106       -- Start the workflow
7107       --
7108 
7109       wf_engine.StartProcess(itemtype => x_itemtype,
7110                              itemkey  => x_itemkey );
7111 
7112 END;
7113 
7114 PROCEDURE NOTIFY_ADDED_INVITEES(x_itemtype          in varchar2,
7115                                x_itemkey           in varchar2,
7116                                actid               in number,
7117                                uncmode             in varchar2,
7118                                resultout           out NOCOPY varchar2) IS
7119 
7120 x_role_name VARCHAR2(240);
7121 x_user_name VARCHAR2(100);
7122 x_additional_user_name          VARCHAR2(100);
7123 x_progress      VARCHAR2(3);
7124 x_sequence      NUMBER;
7125 x_user_orig_system    VARCHAR2(30);
7126 x_stringa                       VARCHAR2(30);
7127 x_user_orig_system_id    NUMBER;
7128 x_role_orig_system    VARCHAR2(30) := 'WF_LOCAL_ROLES';
7129 x_role_orig_system_id    NUMBER := 0;
7130 x_person_party_id               NUMBER;
7131 x_bidder_count      NUMBER;
7132 x_message      VARCHAR2(80);
7133 x_language_code      VARCHAR2(3);
7134 x_nid         NUMBER;
7135 x_auction_header_id    NUMBER;
7136 p_itemtype      VARCHAR2(8) := 'PONAUCT';
7137 p_itemkey      VARCHAR2(240);
7138 x_member      VARCHAR2(8) := 'None';
7139 x_doctype_group_name    VARCHAR2(80);
7140 x_msg_suffix      VARCHAR2(8);
7141 x_oex_timezone          VARCHAR2(80);
7142 x_oex_timezone1          VARCHAR2(80);
7143 x_timezone    VARCHAR2(80);
7144 x_timezone1    VARCHAR2(80);
7145 x_tp_display_name  VARCHAR2(300);
7146 x_startdate    DATE;
7147 x_enddate    DATE;
7148 x_newstarttime    DATE;
7149 x_newendtime    DATE;
7150 x_preview_date     DATE;
7151 x_newpreviewtime     DATE;
7152 x_open_bidding_date  DATE;
7153 
7154 x_auctioneer_user_name  VARCHAR2(100);
7155 x_preview_message       VARCHAR2(100);
7156 x_article_doc_type      VARCHAR2(100);
7157 
7158 x_wf_role_name          VARCHAR2(30);
7159 x_app                   VARCHAR2(20);
7160 x_invitation_id    NUMBER;
7161 
7162 x_oex_header            VARCHAR2(2000);
7163 x_oex_footer            VARCHAR2(2000);
7164 x_status                VARCHAR2(10);
7165 x_exception_msg         VARCHAR2(100);
7166 x_operation_url   VARCHAR2(300);
7167 x_oex_operation    VARCHAR2(2000);
7168 x_auction_owner_tp_name VARCHAR2(300);
7169 x_auction_title    VARCHAR2(2000);
7170 x_note_to_new_supplier_type  VARCHAR2(30);
7171 x_doc_number_dsp   VARCHAR2(30);
7172 
7173 x_auction_type          Varchar2(30);
7174 x_auction_type_name     Varchar2(30) := '';
7175 x_event_id              NUMBER;
7176 x_event_title           VARCHAR2(80);
7177 flag       BOOLEAN;
7178 t_itemtype    VARCHAR2(8) := 'PONPBLSH';
7179 t_itemkey    VARCHAR2(50);
7180 x_appstr                VARCHAR2(20);
7181 x_auction_creator_contact_id  NUMBER;
7182 x_timezone1_disp VARCHAR2(240);
7183 x_timezone_disp VARCHAR2(240);
7184 
7185 -- Added the following declaration for Affiliate ID related changes
7186 -- Auctioneer's trading partner id
7187 x_tp_id                      NUMBER;
7188 
7189 x_nls_language               VARCHAR2(60);
7190 x_territory_code             VARCHAR2(30);
7191 x_nls_territory              VARCHAR2(60);
7192 
7193 x_nls_addnl_language         VARCHAR2(60);
7194 x_nls_addnl_territory        VARCHAR2(30);
7195 x_registration_key           VARCHAR2(100);
7196 x_neg_summary_url_supplier   VARCHAR2(2000);
7197 x_isp_supplier_register_url  VARCHAR2(2000);
7198 x_ack_part_url_supplier      VARCHAR2(2000);
7199 x_vendor_site_code           PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
7200 x_vendor_site_id       NUMBER;
7201 x_auction_header_id_encrypted VARCHAR2(2000);
7202 x_preview_date_notspec VARCHAR2(240);
7203 x_staggered_closing_interval NUMBER;
7204 x_staggered_close_note       VARCHAR2(1000);
7205 
7206 
7207 -- added following for requested suppliers project
7208 l_requested_supplier      BOOLEAN;
7209 x_rs_user_name            VARCHAR2(100);
7210 x_nls_rs_language         VARCHAR2(60);
7211 x_nls_rs_territory        VARCHAR2(30);
7212 
7213 l_users WF_DIRECTORY.UserTable;
7214 
7215 cursor newInvitees is
7216     select
7217      trading_partner_contact_name,
7218      trading_partner_contact_id,
7219      trading_partner_name,
7220      trading_partner_id,
7221      wf_user_name,
7222      additional_contact_email,
7223        registration_id,
7224        decode(pbp.vendor_site_code, '-1', null, pbp.vendor_site_code) vendor_site_code,
7225        pbp.vendor_site_id,
7226        pbp.requested_supplier_id,
7227        pbp.requested_supplier_name,
7228        pbp.requested_supplier_contact_id,
7229        pbp.requested_supp_contact_name,
7230        pcr.email_address rs_contact_email
7231     from pon_bidding_parties pbp,
7232          pos_contact_requests pcr
7233     where auction_header_id = x_auction_header_id
7234     and pbp.requested_supplier_contact_id = pcr.contact_request_id(+)
7235     and wf_item_key IS NULL;
7236 
7237 CURSOR c1_auction_type IS
7238     select auction_type, event_id, event_title, open_bidding_date, trading_partner_id,
7239            staggered_closing_interval
7240     from pon_auction_headers_all
7241     where auction_header_id = x_auction_header_id;
7242 
7243 BEGIN
7244     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype   => x_itemtype,
7245                                                        itemkey    => x_itemkey,
7246                                                        aname      => 'AUCTION_ID'); /* using auction_id instead of
7247                                                                                      auction_number as a standard
7248                                                                                      across item types */
7249 
7250     -- Bug 8992789
7251     IF (IS_INTERNAL_ONLY(x_auction_header_id)) THEN
7252       RETURN;
7253     END IF;
7254 
7255     select wf_item_key , trading_partner_contact_name into p_itemkey, x_auctioneer_user_name
7256       from pon_auction_headers_all
7257       where auction_header_id = x_auction_header_id;
7258 
7259 --    x_auctioneer_user_name := wf_engine.GetItemAttrText (itemtype => p_itemtype,
7260 --                                               itemkey  => p_itemkey,
7261 --                                                     aname    => 'PREPARER_TP_CONTACT_NAME');
7262 
7263     x_auction_header_id_encrypted := wf_engine.GetItemAttrText (itemtype => p_itemtype,
7264                                                          itemkey  => p_itemkey,
7265                                                          aname    => 'AUCTION_ID_ENCRYPTED');
7266 
7267     x_doc_number_dsp :=  wf_engine.GetItemAttrText (itemtype   => x_itemtype,
7268                                          itemkey    => x_itemkey,
7269                                          aname      => 'DOC_NUMBER');
7270 
7271     x_auction_owner_tp_name := wf_engine.GetItemAttrText (itemtype => x_itemtype,
7272                                                           itemkey  => x_itemkey,
7273                                                           aname    => 'PREPARER_TP_NAME');
7274 
7275     x_auction_title := wf_engine.GetItemAttrText(itemtype => x_itemtype,
7276                                                  itemkey  => x_itemkey,
7277                                                  aname    => 'AUCTION_TITLE');
7278 
7279 
7280     x_preview_date := wf_engine.GetItemAttrDate (itemtype => x_itemtype,
7281                                       itemkey  => x_itemkey,
7282                                        aname    => 'PREVIEW_DATE');
7283 
7284      x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => x_itemtype,
7285                                                            itemkey  => x_itemkey,
7286                                                            aname    => 'PREVIEW_DATE_NOTSPECIFIED');
7287 
7288 
7289     x_doctype_group_name := wf_engine.GetItemAttrText   (itemtype => x_itemtype,
7290                                                          itemkey  => x_itemkey,
7291                                                          aname    => 'DOC_INTERNAL_NAME');
7292 
7293     x_startdate := wf_engine.GetItemAttrDate (itemtype => p_itemtype,
7294                                               itemkey  => p_itemkey,
7295                                               aname    => 'AUCTION_START_DATE');
7296 
7297     x_enddate   := wf_engine.GetItemAttrDate (itemtype => p_itemtype,
7298                                               itemkey  => p_itemkey,
7299                                               aname    => 'AUCTION_END_DATE');
7300 
7301     x_msg_suffix := GET_MESSAGE_SUFFIX (x_doctype_group_name);
7302 
7303     IF x_auctioneer_user_name is not null THEN
7304        PON_PROFILE_UTIL_PKG.GET_WF_PREFERENCES(x_auctioneer_user_name,x_language_code,x_territory_code);
7305     END IF;
7306 
7307     select NLS_LANGUAGE into x_nls_language
7308     from fnd_languages
7309     where language_code = x_language_code;
7310 
7311     select nls_territory into x_nls_territory
7312     from   fnd_territories
7313     where  territory_code = x_territory_code;
7314 
7315     open c1_auction_type;
7316     fetch c1_auction_type
7317     into x_auction_type,
7318          x_event_id,
7319          x_event_title,
7320    x_open_bidding_date,
7321          x_tp_id,
7322          x_staggered_closing_interval;
7323     close c1_auction_type;
7324 
7325 
7326     select wf_role_name, wf_item_key into x_role_name, p_itemkey
7327     from pon_auction_headers_all
7328     where auction_header_id = x_auction_header_id;
7329 
7330     x_oex_timezone := Get_Oex_Time_Zone;
7331 
7332    -- Get the auctioneer's language
7333      PON_PROFILE_UTIL_PKG.GET_WF_PREFERENCES(x_auctioneer_user_name,x_language_code,x_territory_code);
7334      for bidder in newInvitees loop
7335 
7336        -- Bug 3824928: Removed unnecessary statements from this version
7337 
7338     -- If we have a contact name, use it.
7339       -- Bug 3824928: Trading partner contact id can be null
7340       IF bidder.trading_partner_contact_id IS NOT NULL THEN -- {
7341 
7342       x_person_party_id := bidder.trading_partner_contact_id;
7343 
7344          -- check if the contact is in the role - if not this is a new invitee
7345       x_user_name := GET_USER_NAME(x_person_party_id);
7346 
7347        select count(*) into x_bidder_count
7348      from wf_local_user_roles
7349      where role_name = x_role_name
7350      and user_name = x_user_name;
7351 
7352 
7353      if (x_bidder_count < 1) then
7354 
7355         -- Add new user and send notification.
7356 
7357         /*WF_DIRECTORY.AddUsersToAdHocRole(x_role_name,
7358                      x_user_name);*/
7359 		-- Modified from  AddUsersToAdHocRole to AddUsersToAdHocRole2 for bug 11067311
7360  	    if (x_user_name is NOT NULL) then
7361  	        string_to_userTable(x_user_name, l_users);
7362  	        WF_DIRECTORY.AddUsersToAdHocRole2(x_role_name,
7363  	                                            l_users);
7364  	    end if;
7365        end if; -- Bug 3824928: Added end if
7366 
7367       -- send notfication to this bidder.
7368 
7369 
7370       -- Set bidder specific attributes
7371 
7372      -- Bug 3824928: calling get_wf_preferences instead of get_wf_language
7373 
7374        PON_PROFILE_UTIL_PKG.GET_WF_PREFERENCES(x_user_name,x_language_code,x_territory_code);
7375 
7376     --
7377     -- Get the user's time zone
7378     --
7379      x_timezone := Get_Time_Zone(x_person_party_id);
7380      ELSE  -- Bug 3824928: bidder.trading_partner_contact_id IS NULL
7381 
7382     --
7383     -- Get the auctioneer's time zone
7384 
7385         x_timezone := Get_Time_Zone(x_auctioneer_user_name);
7386               if (x_timezone is null or x_timezone = '') then
7387                              x_timezone := x_oex_timezone;
7388               end if;
7389 
7390      END IF; -- } IF bidder.trading_partner_contact_id IS NOT NULL
7391 
7392         -- Convert the dates to the user's or auctioneer's timezone
7393     -- If the timezone is not recognized, just use PST
7394     --
7395 
7396     IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
7397        x_newstarttime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_startdate,x_oex_timezone,x_timezone);
7398        x_newendtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_enddate,x_oex_timezone,x_timezone);
7399            if x_preview_date is not null then
7400          x_newpreviewtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone);
7401            end if;
7402     ELSE
7403        x_newstarttime := x_startdate;
7404        x_newendtime := x_enddate;
7405            x_newpreviewtime := x_preview_date;
7406        x_timezone := x_oex_timezone;
7407     END IF;
7408 
7409         -- check if supplier is requested supplier
7410         IF (bidder.trading_partner_id is null
7411             AND bidder.requested_supplier_id is not null)THEN
7412            l_requested_supplier := TRUE;
7413         END IF;
7414 
7415         x_tp_display_name := nvl(bidder.trading_partner_name, bidder.requested_supplier_name);
7416 
7417         x_vendor_site_code := bidder.vendor_site_code;
7418 
7419         x_vendor_site_id := bidder.vendor_site_id;
7420 
7421 
7422       -- this is needed here because of a bug in wf (fixed in 2.6)
7423       UNSET_SESSION_LANGUAGE;
7424 
7425       SELECT pon_auction_wf_publish_s.nextval
7426       INTO   x_sequence
7427       FROM   dual;
7428 
7429       t_itemkey := (x_itemkey||'-'||to_char(x_sequence));
7430 
7431       wf_engine.CreateProcess(itemtype => t_itemtype,
7432                               itemkey  => t_itemkey,
7433                         process  => 'SEND_ADDED_INVITEES');
7434 
7435       IF (l_requested_supplier) THEN
7436 
7437             wf_engine.SetItemAttrText (itemtype => t_itemtype,
7438                                        itemkey    => t_itemkey,
7439                                        aname    => 'REQ_SUPPLIER_CONTACT_NAME',
7440                                        avalue   => bidder.requested_supp_contact_name);
7441       ELSE
7442             wf_engine.SetItemAttrText (itemtype => t_itemtype,
7443                                        itemkey  => t_itemkey,
7444                                        aname    => 'BIDDER_TP_CONTACT_NAME',
7445                                        avalue   => x_user_name);
7446       END IF;
7447 
7448       wf_engine.SetItemAttrNumber (itemtype  => t_itemtype,
7449              itemkey  => t_itemkey,
7450                aname  => 'TRADING_PARTNER_ID',
7451                avalue   => bidder.trading_partner_id);
7452 
7453             wf_engine.SetItemAttrNumber (itemtype  => t_itemtype,
7454              itemkey  => t_itemkey,
7455                aname  => 'AUCTION_ID',
7456                avalue   => x_auction_header_id); /* using auction_id instead of
7457                                                            auction_number as a standard
7458                                                            across item types */
7459 
7460             BEGIN
7461                  x_staggered_close_note := NULL;
7462                  IF x_staggered_closing_interval IS NOT NULL THEN
7463                      x_staggered_close_note := wf_core.newline || wf_core.newline ||
7464                                                getMessage('PON_STAGGERED_CLOSE_NOTIF_MSG') ||
7465                                                wf_core.newline || wf_core.newline;
7466                  END IF;
7467                  wf_engine.SetItemAttrText( itemtype     => t_itemtype,
7468                                             itemkey      => t_itemkey,
7469                                             aname        => 'STAGGERED_CLOSE_NOTE',
7470                                             avalue       => x_staggered_close_note);
7471             EXCEPTION                                                                                                                                                       WHEN OTHERS THEN NULL;
7472                                                                                                                                                                       END;
7473 
7474             IF (x_language_code is not null) THEN
7475 
7476                 IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
7477                 FND_LOG.string(log_level => FND_LOG.level_statement,
7478                   module => g_module_prefix || 'NOTIFY_ADDED_INVITEES',
7479                   message  => '7. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
7480                 END IF; --}
7481 
7482         SET_SESSION_LANGUAGE(null, x_language_code);
7483             END IF;
7484 
7485 
7486       --- 000001
7487 
7488       -- Begin Bug 9309785
7489       -- Use a different subject for Supplier Hub
7490       IF (fnd_profile.value('POS_SM_ENABLE_SPM_EXTENSION') = 'Y' AND l_requested_supplier) THEN
7491         wf_engine.SetItemAttrText (itemtype       => t_itemtype,
7492                                    itemkey        => t_itemkey,
7493                                    aname          => 'INVITE_RESPONSE_SUB',
7494                                    avalue         => getMessage('PON_SM_AUC_WF_PUB_OPEN_RG_S'));
7495 
7496         wf_engine.SetItemAttrText (itemtype       => t_itemtype,
7497                                    itemkey        => t_itemkey,
7498                                    aname          => 'ISP_NEW_SUPPLIER_REG_URL',
7499                                    avalue         => get_supplier_reg_url(bidder.requested_supplier_id));
7500 
7501         -- Bug 10075648
7502         -- Update supplier registration status to 'Supplier to Provide Details' when sending notification.
7503         update_supplier_reg_status(bidder.requested_supplier_id);
7504       ELSE
7505             wf_engine.SetItemAttrText (itemtype       => t_itemtype,
7506                                        itemkey        => t_itemkey,
7507                                        aname          => 'INVITE_RESPONSE_SUB',
7508                                        avalue         => getMessage('PON_AUC_WF_PUB_OPEN_RG_S', x_msg_suffix,
7509                                                                     'DOC_NUMBER', x_doc_number_dsp,
7510                                                                     'AUCTION_TITLE', replaceHtmlChars(x_auction_title)));
7511       END IF;
7512       -- End Bug 9309785
7513 
7514       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7515                            itemkey  => t_itemkey,
7516                            aname  => 'PREPARER_TP_CONTACT_NAME',
7517                            avalue   => x_auctioneer_user_name);
7518 
7519       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7520                            itemkey  => t_itemkey,
7521                            aname  => 'TP_DISPLAY_NAME',
7522                            avalue   => x_tp_display_name);
7523 
7524         wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7525                                    itemkey    => t_itemkey,
7526                                    aname      => 'BIDDER_TP_NAME',
7527                                    avalue     => x_tp_display_name);
7528 
7529         wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7530                                itemkey    => t_itemkey,
7531                                aname      => 'BIDDER_TP_ADDRESS_NAME',
7532                                avalue     => x_vendor_site_code);
7533 
7534     -- Item attribute value is going to be used as a parameter to Acknowledge Participation page
7535         wf_engine.SetItemAttrNumber (itemtype   => t_itemtype,
7536                                itemkey    => t_itemkey,
7537                                aname      => 'VENDOR_SITE_ID',
7538                                avalue     => x_vendor_site_id);
7539 
7540         -- call to notification utility package to get the redirect page url that
7541         -- is responsible for getting the Negotiation Summary url and forward to it.
7542         	x_neg_summary_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
7543                               p_dest_func => 'PON_NEG_SUMMARY'
7544                                  ,p_notif_performer  => 'SUPPLIER');
7545         --Bug 11898698
7546 	--Modifying the language_code in the URL with that of the recipient
7547 	--The profile "ICX_LANGUAGE" needs to be set for the recipient for this fix
7548 	x_neg_summary_url_supplier:=regexp_replace(x_neg_summary_url_supplier , 'language_code='||fnd_global.current_language, 'language_code='||x_language_code);
7549 
7550         wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7551                                itemkey    => t_itemkey,
7552                                aname      => 'NEG_SUMMARY_URL',
7553                                avalue     => x_neg_summary_url_supplier);
7554 
7555         begin
7556           wf_engine.SetItemAttrText   (itemtype   => t_itemtype,
7557                                          itemkey    => t_itemkey,
7558                                          aname      => '#WFM_HTMLAGENT',
7559                                          avalue     => pon_wf_utl_pkg.get_base_external_supplier_url);
7560         exception
7561           when others then
7562             null;
7563         end;
7564 
7565       if (x_open_bidding_date < sysdate) then
7566 
7567 
7568       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7569              itemkey  => t_itemkey,
7570                aname  => 'PON_AUC_WF_DOC_IN_PR0G',
7571                avalue   => getMessage('PON_AUC_WF_DOC_IN_PR0G', x_msg_suffix));
7572 
7573       end if;
7574 
7575 
7576       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7577              itemkey  => t_itemkey,
7578                aname  => 'PREPARER_TP_NAME',
7579                avalue   => x_auction_owner_tp_name);
7580 
7581 
7582       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7583              itemkey  => t_itemkey,
7584                aname  => 'AUCTION_TITLE',
7585                avalue   => replaceHtmlChars(x_auction_title));
7586 
7587 
7588       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7589              itemkey  => t_itemkey,
7590                aname  => 'DOC_NUMBER',
7591                avalue   => x_doc_number_dsp);
7592 
7593         x_timezone_disp := Get_TimeZone_Description(x_timezone, x_language_code);
7594         IF (x_preview_date IS NULL) THEN
7595         x_timezone1_disp := null;
7596     ELSE
7597         x_timezone1_disp := x_timezone_disp;
7598     END IF;
7599 
7600   IF (x_preview_date is not null) THEN
7601          wf_engine.SetItemAttrDate (itemtype  => t_itemtype,
7602                    itemkey  => t_itemkey,
7603                    aname  => 'PREVIEW_DATE',
7604                    avalue   => x_newpreviewtime);
7605 
7606          wf_engine.SetItemAttrDate (itemtype  => t_itemtype,
7607                    itemkey  => t_itemkey,
7608                    aname  => 'PREVIEW_DATE_TZ',
7609                    avalue   => x_newpreviewtime);
7610 
7611          wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7612                    itemkey  => t_itemkey,
7613                    aname  => 'TP_TIME_ZONE1',
7614                    avalue   => x_timezone1_disp);
7615 
7616          wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7617                            itemkey  => t_itemkey,
7618                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
7619                            avalue  => null);
7620     ELSE
7621          wf_engine.SetItemAttrDate (itemtype  => t_itemtype,
7622                   itemkey  => t_itemkey,
7623                   aname  => 'PREVIEW_DATE',
7624                   avalue   => null);
7625 
7626          wf_engine.SetItemAttrDate (itemtype  => t_itemtype,
7627                    itemkey  => t_itemkey,
7628                    aname  => 'PREVIEW_DATE_TZ',
7629                    avalue   => null);
7630 
7631          wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7632                    itemkey  => t_itemkey,
7633                    aname  => 'TP_TIME_ZONE1',
7634                    avalue   => x_timezone1_disp);
7635 
7636          wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7637                            itemkey  => t_itemkey,
7638                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
7639                            avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
7640 
7641   END IF;
7642 
7643       wf_engine.SetItemAttrDate (itemtype  => t_itemtype,
7644              itemkey  => t_itemkey,
7645                aname  => 'AUCTION_START_DATE_TZ',
7646                avalue   => x_newstarttime);
7647 
7648       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7649              itemkey  => t_itemkey,
7650                aname  => 'TP_TIME_ZONE',
7651                avalue   => x_timezone_disp);
7652 
7653 
7654       wf_engine.SetItemAttrDate (itemtype  => t_itemtype,
7655              itemkey  => t_itemkey,
7656                aname  => 'AUCTION_END_DATE_TZ',
7657                avalue   => x_newendtime);
7658 
7659       wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7660                itemkey  => t_itemkey,
7661                aname  => 'ORIGIN_USER_NAME',
7662                avalue   => fnd_global.user_name);
7663 
7664 
7665   -- Bug 3824928: Deleted unwanted lines here
7666 
7667 
7668   -- end if;
7669     -- Bug 3824928: Checking if additional_contact_email is not null
7670 
7671    if bidder.additional_contact_email is not NULL THEN --{
7672 
7673          SELECT pon_auction_wf_bidder_s.nextval
7674       INTO   x_sequence
7675       FROM   dual;
7676         -- Bug 3824928 - check if the additional contact is in the role - if
7677         -- not this is the additional contact of a new invitee
7678 
7679 
7680          select count(*) into x_bidder_count
7681          from wf_local_user_roles
7682          where role_name = x_role_name
7683         and user_name = bidder.wf_user_name;
7684 
7685        if (x_bidder_count < 1) then
7686 
7687 
7688       x_additional_user_name := ('WF_PON_USER_'||to_char(x_sequence));
7689 
7690          wf_engine.SetItemAttrText (itemtype  => t_itemtype,
7691              itemkey  => t_itemkey,
7692                aname  => 'ADDITIONAL_CONTACT_USERNAME',
7693                avalue   => x_additional_user_name);
7694 
7695               -- add a registration link in FPH for additional contact
7696               begin
7697                  select registration_key
7698                   into x_registration_key
7699                   from fnd_registrations
7700                  where registration_id = bidder.registration_id;
7701               exception
7702                   WHEN NO_DATA_FOUND THEN
7703                        x_registration_key := '';
7704               end;
7705 
7706         -- call to notification utility package to get the iSupplier registration page url
7707         x_isp_supplier_register_url := pon_wf_utl_pkg.get_isp_supplier_register_url(p_registration_key => x_registration_key
7708                                                                                    ,p_language_code => x_language_code);
7709 
7710 
7711         wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7712                                    itemkey    => t_itemkey,
7713                                    aname      => 'ISP_SUPPLIER_REG_URL',
7714                                    avalue     => x_isp_supplier_register_url);
7715 
7716            -- call to notification utility package to get the redirect page url that
7717            -- is responsible for getting the Acknowledge participation url and forward to it.
7718            x_ack_part_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
7719                               p_dest_func => 'PONRESAPN_ACKPARTICIPATN'
7720                                  ,p_notif_performer  => 'SUPPLIER');
7721 
7722         wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7723                                    itemkey    => t_itemkey,
7724                                    aname      => 'ACK_PARTICIPATION_URL',
7725                                    avalue     => x_ack_part_url_supplier);
7726 
7727     -- Bug 3824928: if tpcontactid is not null use language and territory
7728         -- from tp contact id else use auctioneer's language and territory
7729 
7730         select NLS_LANGUAGE into x_nls_addnl_language
7731         from fnd_languages
7732         where language_code = x_language_code;
7733 
7734         select nls_territory into x_nls_addnl_territory
7735         from   fnd_territories
7736         where  territory_code = x_territory_code;
7737 
7738 
7739       WF_DIRECTORY.CreateAdHocUser(x_additional_user_name,
7740                                          x_additional_user_name,
7741                                          x_nls_addnl_language,
7742                                          x_nls_addnl_territory,
7743                                          'Oracle Exchange Additional Bidder '||to_char(x_auction_header_id),
7744                                              'MAILHTML',
7745                                          bidder.additional_contact_email,
7746                                          null,
7747                                          'ACTIVE',
7748                                              null);
7749 
7750     /*WF_DIRECTORY.AddUsersToAdHocRole(x_role_name,
7751                    x_additional_user_name);*/
7752 	-- Modified from  AddUsersToAdHocRole to AddUsersToAdHocRole2 for bug 11067311
7753  	if (x_additional_user_name is NOT NULL) then
7754  	    string_to_userTable(x_additional_user_name, l_users);
7755  	    WF_DIRECTORY.AddUsersToAdHocRole2(x_role_name,
7756  	                                        l_users);
7757  	end if;
7758 
7759          -- Bug 3709564
7760          -- If this update is not performed here, it will error out
7761          -- in notify_bidder_list_reminder as wf_user_name will be null
7762             UPDATE pon_bidding_parties set
7763             wf_user_name = x_additional_user_name
7764             WHERE auction_header_id = x_auction_header_id
7765             AND  trading_partner_id = bidder.trading_partner_id
7766             AND  vendor_site_id = bidder.vendor_site_id;
7767 
7768       end if; -- if (x_bidder_count < 1)
7769 
7770    end if; -- } if bidder.additional_contact_email is not NULL
7771 
7772 -- create adhoc user for this rs contact
7773 if (l_requested_supplier and bidder.rs_contact_email is not NULL) THEN
7774 -- {
7775        SELECT pon_auction_wf_bidder_s.nextval
7776                 INTO   x_sequence
7777                 FROM   dual;
7778 
7779        SELECT count(*) INTO x_bidder_count
7780        FROM wf_local_user_roles
7781        WHERE role_name = x_role_name
7782           AND user_name = bidder.wf_user_name;
7783 
7784        IF (x_bidder_count < 1) THEN  --{
7785 
7786           x_rs_user_name := ('WF_PON_USER_'||to_char(x_sequence));
7787           wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7788                                      itemkey    => t_itemkey,
7789                                      aname      => 'REQ_SUPPLIER_USERNAME',
7790                                      avalue   => x_rs_user_name); --(performer)
7791 
7792           x_ack_part_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
7793                                           p_dest_func => 'PONRESAPN_ACKPARTICIPATN'
7794                                          ,p_notif_performer  => 'SUPPLIER');
7795 
7796           wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7797                                    itemkey    => t_itemkey,
7798                                    aname      => 'ACK_PARTICIPATION_URL',
7799                                    avalue     => x_ack_part_url_supplier);
7800 
7801           -- create user
7802 
7803           WF_DIRECTORY.CreateAdHocUser(x_rs_user_name,
7804                      x_rs_user_name,
7805                      x_nls_rs_language,
7806                      x_nls_rs_territory,
7807                      'Oracle Exchange Requested Bidder'||to_char(x_auction_header_id),
7808                      'MAILHTML',
7809                      bidder.rs_contact_email,
7810                      null,
7811                      'ACTIVE',
7812                      null);
7813 
7814           /*WF_DIRECTORY.AddUsersToAdHocRole(x_role_name,
7815                                            x_rs_user_name);*/
7816 		  -- Modified from  AddUsersToAdHocRole to AddUsersToAdHocRole2 for bug 11067311
7817  	      if ( x_rs_user_name is NOT NULL) then
7818  	          string_to_userTable( x_rs_user_name, l_users);
7819  	          WF_DIRECTORY.AddUsersToAdHocRole2(x_role_name,
7820  	                                               l_users);
7821  	      end if;
7822 
7823           UPDATE pon_bidding_parties SET
7824             wf_user_name = x_rs_user_name
7825             WHERE auction_header_id = x_auction_header_id
7826             AND  (trading_partner_id = bidder.trading_partner_id
7827                              or requested_supplier_id = bidder.requested_supplier_id)
7828             AND  vendor_site_id = bidder.vendor_site_id;
7829 
7830       END IF; --} if (x_bidder_count < 1)
7831 
7832    END IF; --} if requested supplier
7833 
7834   --Bug 8446265 Modifications
7835     wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7836                                itemkey    => t_itemkey,
7837                                aname      => 'PON_INVITE_REQ_SUPP_RESP_BODY',
7838                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INVITE_REQ_SUPP_RESP_BODY/'||t_itemtype ||':' ||t_itemkey
7839                                );
7840 
7841     wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7842                                itemkey    => t_itemkey,
7843                                aname      => 'PON_INVITE_RESPONSE_BODY',
7844                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INVITE_CONT_RESP_BODY/'||t_itemtype ||':' ||t_itemkey
7845                                );
7846 
7847     wf_engine.SetItemAttrText (itemtype   => t_itemtype,
7848                                itemkey    => t_itemkey,
7849                                aname      => 'PON_INV_RESP_ADD_CONT_BODY',
7850                                avalue     => 'PLSQLCLOB:pon_auction_pkg.GEN_INVITE_ADD_CONT_RESP_BODY/'||t_itemtype ||':' ||t_itemkey
7851                                );
7852 
7853     -- Bug 4295915: Set the  workflow owner
7854        wf_engine.SetItemOwner(itemtype => t_itemtype,
7855                               itemkey  => t_itemkey,
7856                               owner    => fnd_global.user_name);
7857 
7858   wf_engine.StartProcess(itemtype => t_itemtype,
7859                                itemkey  => t_itemkey );
7860 
7861     -- Bug 3709564
7862     -- If this update is not performed here, wf_engine.abort_process call
7863     -- in notify_bidder_list_reminder will fail, as wf_item_key will be null
7864        update pon_bidding_parties
7865        set wf_item_key = t_itemkey
7866        where  auction_header_id = x_auction_header_id and
7867               (trading_partner_id = bidder.trading_partner_id
7868                or requested_supplier_id = bidder.requested_supplier_Id) and
7869               vendor_site_id = bidder.vendor_site_id and
7870               wf_item_key is null;
7871 
7872     -- end if;  -- if newly added invitee check Bug 3824928 commenting this
7873 
7874     end loop;
7875 
7876     UNSET_SESSION_LANGUAGE;
7877 
7878 END;
7879 
7880 
7881 PROCEDURE SET_INVITATION_LIST_FLAG(p_auction_header_id  NUMBER) IS
7882   x_item_key VARCHAR2(240);
7883 BEGIN
7884 
7885   select wf_item_key into x_item_key
7886   from pon_auction_headers_all
7887   where auction_header_id = p_auction_header_id;
7888 
7889         wf_engine.SetItemAttrText (itemtype   => 'PONAUCT',
7890                                    itemkey    => x_item_key,
7891                                    aname      => 'BIDDER_LIST_FLAG',
7892                                    avalue     => 'Y');
7893 END;
7894 
7895 
7896 FUNCTION GET_USER_NAME (p_user_id NUMBER) RETURN VARCHAR2
7897 IS
7898 x_user_name varchar2(100);
7899 BEGIN
7900       begin
7901   select user_name
7902         into x_user_name
7903   from fnd_user
7904         where person_party_id = p_user_id
7905         and nvl(end_date,sysdate+1) > sysdate;
7906       exception
7907        when too_many_rows then
7908           if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
7909                if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
7910                          fnd_log.string(log_level => fnd_log.level_unexpected,
7911                                         module    => 'pon.plsql.pon_auction_pkg.get_user_name',
7912                                         message   => 'Multiple Users found for person_party_id:'|| p_user_id);
7913                end if;
7914          end if;
7915 
7916          select user_name
7917          into x_user_name
7918          from fnd_user
7919          where person_party_id = p_user_id
7920          and nvl(end_date, sysdate+1) > sysdate
7921          and rownum=1;
7922       end;
7923       return x_user_name;
7924 END;
7925 
7926 
7927 FUNCTION MEMBER_USER(p_user_name VARCHAR2) RETURN BOOLEAN
7928 IS
7929 x_count int := 0;
7930 BEGIN
7931   select count(*) into x_count
7932   from fnd_user where user_name = p_user_name;
7933 
7934   if (x_count > 0) then return true; else return false; end if;
7935 END;
7936 
7937 
7938 FUNCTION ADDITIONAL_BIDDER(p_user_name VARCHAR2, p_doc_id int, p_preparer_tp_contact_name varchar2,
7939 x_profile_user IN OUT NOCOPY VARCHAR2)
7940 RETURN BOOLEAN
7941 IS
7942 x_found BOOLEAN;
7943 x_user_name VARCHAR2(100);
7944 x_user_id   int;
7945 BEGIN
7946   begin
7947     select trading_partner_contact_id
7948         into x_user_id
7949     from pon_bidding_parties
7950     where auction_header_id = p_doc_id
7951     and wf_user_name = p_user_name;
7952 
7953          if x_user_id is null then -- it means the additional contact is not associated to any
7954                                     -- tp_contact_id
7955              x_profile_user := p_preparer_tp_contact_name;
7956          else
7957 
7958        x_profile_user := GET_USER_NAME(x_user_id);
7959 
7960        if (x_profile_user is null) then -- this condition should not occur. It may
7961                                             -- occur if user is deleted from fnd_user table
7962        x_profile_user := p_preparer_tp_contact_name; -- Bug 3824928: changed from p_user_name to
7963                                                           -- default to the auctioneer name
7964        end if;
7965         end if;
7966     x_found := true;
7967   exception
7968     when no_data_found then
7969     -- no additional contact
7970     x_found := false;
7971   end;
7972   return x_found;
7973 
7974 END;
7975 
7976 FUNCTION Get_TimeZone_Description(p_timezone_id varchar2, lang varchar2) return varchar2
7977 is
7978 x_timezone_desc  varchar2(80) := '';
7979 begin
7980 
7981   begin
7982     select name
7983     into x_timezone_desc
7984     from fnd_timezones_tl tl, fnd_timezones_b b
7985     where b.upgrade_tz_id = p_timezone_id
7986     and b.timezone_code = tl.timezone_code
7987           and tl.language = lang;
7988   exception
7989     when others  then
7990             null;
7991         end;
7992 
7993   return x_timezone_desc  ;
7994 end;
7995 
7996 
7997 FUNCTION Get_Oex_Time_Zone return varchar2
7998 is
7999 x_oex_timezone  varchar2(80) := '';
8000 begin
8001     --
8002     -- Get the exchange time zone
8003     --
8004                 x_oex_timezone :=  fnd_profile.value_specific('SERVER_TIMEZONE_ID');
8005     return x_oex_timezone;
8006 end;
8007 
8008 
8009 FUNCTION Get_Time_Zone(contact_id number) return varchar2
8010 is
8011 x_timezone  varchar2(80) := '';
8012 x_user_id NUMBER;
8013 begin
8014     --
8015     -- Get the contact/tp time zone
8016     --
8017 
8018   begin
8019     select user_id
8020     into  x_user_id
8021     from fnd_user
8022     where person_party_id = contact_id
8023                 and nvl(end_date, sysdate+1) > sysdate;
8024     x_timezone := fnd_profile.value_specific('CLIENT_TIMEZONE_ID',x_user_id);
8025   exception
8026                when too_many_rows then
8027                   if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
8028                        if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
8029                                  fnd_log.string(log_level => fnd_log.level_unexpected,
8030                                                 module    => 'pon.plsql.pon_auction_pkg.get_time_zone',
8031                                                 message   => 'Multiple Users found for person_party_id:'|| contact_id);
8032                        end if;
8033                  end if;
8034 
8035                  select user_id
8036                  into x_user_id
8037                  from fnd_user
8038                  where person_party_id = contact_id
8039                  and nvl(end_date, sysdate+1) > sysdate
8040                  and rownum=1;
8041 
8042                  x_timezone := fnd_profile.value_specific('CLIENT_TIMEZONE_ID',x_user_id);
8043 
8044                when NO_DATA_FOUND then
8045                   if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
8046                        if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
8047                                  fnd_log.string(log_level => fnd_log.level_unexpected,
8048                                                 module    => 'pon.plsql.pon_auction_pkg.get_time_zone',
8049                                                 message   => 'No Active Users found for person_party_id:'|| contact_id);
8050                        end if;
8051                  end if;
8052 
8053                  select user_id
8054                  into x_user_id
8055                  from fnd_user
8056                  where person_party_id = contact_id
8057                  and rownum=1;
8058 
8059                  x_timezone := fnd_profile.value_specific('CLIENT_TIMEZONE_ID',x_user_id);
8060 
8061                when OTHERS then
8062                   if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
8063                        if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
8064                                  fnd_log.string(log_level => fnd_log.level_unexpected,
8065                                                 module    => 'pon.plsql.pon_auction_pkg.get_time_zone',
8066                                                 message   => 'Unknown exception for person_party_id:'|| contact_id);
8067                        end if;
8068                  end if;
8069                  x_timezone := Get_Oex_Time_Zone;
8070 
8071   end;
8072 
8073   return x_timezone;
8074 
8075 
8076 end;
8077 
8078 
8079 FUNCTION Get_Time_Zone(contact_name varchar2) return varchar2
8080 is
8081 x_timezone  varchar2(80) := null;
8082 x_contact_id number;
8083 begin
8084          begin
8085     SELECT person_party_id
8086     INTO x_contact_id
8087     FROM fnd_user
8088     WHERE user_name = contact_name;
8089   exception
8090     when others then
8091     x_contact_id := null;
8092   end;
8093 
8094   if (x_contact_id is null) then
8095     return '';
8096   end if;
8097 
8098   --
8099   -- Get the contact/tp time zone
8100   --
8101   x_timezone := Get_Time_Zone(x_contact_id);
8102 
8103   return x_timezone;
8104 end;
8105 
8106 
8107 FUNCTION differentStrings(st1 VARCHAR2, st2 VARCHAR2) return BOOLEAN
8108 IS
8109 BEGIN
8110   if (st1 is not null and st2 is not null) then
8111     if (st1 = st2) then
8112       return false;
8113     else
8114       return true;
8115     end if;
8116   else
8117     return false;
8118   end if;
8119 END;
8120 
8121 ----------------------------------------------------------------
8122 -- getNeedByDatesToPrint
8123 -- XTANG: in FPJ, we added timestamp to need-by dates.
8124 ----------------------------------------------------------------
8125 Function getNeedByDatesToPrint(auctionID IN number, lineNumber IN number,userDateFormat IN varchar2) return varchar2 AS
8126 outputString varchar2(8000) := '';
8127 x_msg_suffix varchar2(3) := '';
8128 needByFromDate Date := null;
8129 needByToDate Date := null;
8130 /* CLM Offer Enhancement */
8131 clmNeedByDate Date := null;
8132 sLanguage varchar2(10) := 'US';
8133 cursor c1(auctionID number,lineNumber number) is
8134 select clm_need_by_date,need_by_start_date,need_by_date
8135 from   pon_auction_item_prices_all
8136 where  auction_header_id = auctionID and
8137       line_number = lineNumber;
8138 Begin
8139  begin
8140 sLanguage := USERENV('LANG');
8141 PON_AUCTION_PKG.SessionLanguage := sLanguage;
8142 
8143  open c1(auctionID,lineNumber);
8144     loop
8145        fetch c1 into clmNeedByDate,needByFromDate,needByToDate;
8146      EXIT WHEN c1%NOTFOUND;
8147 end loop;
8148 
8149 /* CLM Offer Enhancement Start */
8150 if clmNeedByDate is not null and (PON_CLM_UTIL_PKG.IS_NEG_DOCUMENT_FEDERAL(auctionID) = 1)
8151 then
8152 return (getMessage('PON_AUC_NEEDBY_ONLY_START_DATE',x_msg_suffix,'FROMDATE',PON_OA_UTIL_PKG.DISPLAY_DATE_TIME(clmNeedByDate,fnd_profile.value('CLIENT_TIMEZONE_ID'),fnd_profile.value('SERVER_TIMEZONE_ID'),userDateFormat,'N')));
8153 end if;
8154 /* CLM Offer Enhancement End   */
8155 if needByFromDate IS NOT NULL and needByToDate IS NULL then
8156 return (getMessage('PON_AUC_NEEDBY_ONLY_START_DATE',x_msg_suffix,'FROMDATE',PON_OA_UTIL_PKG.DISPLAY_DATE_TIME(needByFromDate,fnd_profile.value('CLIENT_TIMEZONE_ID'),fnd_profile.value('SERVER_TIMEZONE_ID'),userDateFormat,'N')));
8157 else
8158 if needByFromDate IS NULL and needByToDate IS NOT NULL then
8159 return (getMessage('PON_AUC_NEEDBY_ONLY_END_DATE',x_msg_suffix,'TODATE',PON_OA_UTIL_PKG.DISPLAY_DATE_TIME(needByToDate,fnd_profile.value('CLIENT_TIMEZONE_ID'),fnd_profile.value('SERVER_TIMEZONE_ID'),userDateFormat,'N')));
8160 else
8161 if needByFromDate IS NOT NULL and needByToDate IS NOT NULL then
8162 return (getMessage('PON_AUC_NEEDBY_RANGE',x_msg_suffix,'FROMDATE',PON_OA_UTIL_PKG.DISPLAY_DATE_TIME(needByFromDate,fnd_profile.value('CLIENT_TIMEZONE_ID'),fnd_profile.value('SERVER_TIMEZONE_ID'),userDateFormat,'N'),
8163 'TODATE',PON_OA_UTIL_PKG.DISPLAY_DATE_TIME(needByToDate,fnd_profile.value('CLIENT_TIMEZONE_ID'),fnd_profile.value('SERVER_TIMEZONE_ID'),userDateFormat,'N')));
8164 else return (outputString);
8165           end if;
8166        end if;
8167 end if;
8168     close c1;
8169  exception When others then
8170    return (outputString);
8171  end;
8172 End getNeedByDatesToPrint;
8173 
8174 
8175 
8176 
8177 PROCEDURE AUCTION_PO_SEND (
8178         transaction_code        IN     VARCHAR2,
8179         document_id             IN     NUMBER,
8180   party_id    IN     NUMBER,
8181         debug_mode              IN     PLS_INTEGER,
8182   trigger_id    OUT    NOCOPY  PLS_INTEGER,
8183   retcode            OUT    NOCOPY  PLS_INTEGER,
8184   errmsg      OUT    NOCOPY  VARCHAR2
8185 )
8186 IS
8187 l_seq varchar2(10);
8188 l_ItemType     VARCHAR2(8) := 'PONAUCT';
8189 l_ItemKey      VARCHAR2(240) ;
8190 l_debug_level varchar2(3);
8191 
8192 BEGIN
8193 
8194 trigger_id := 1;
8195 retcode := 0;
8196 errmsg := null;
8197 
8198 l_debug_level := '0';
8199 /* Hardcoded for present
8200 begin
8201   select parameter_value into l_debug_level from pon_operator_parameters where parameter_name ='xmlDebugLevel' ;
8202   exception when others then
8203   l_debug_level := '0';
8204 end;
8205 
8206  select to_char(PON_PO_WF_ITEMKEY_S.NEXTVAL)
8207  into l_seq from sys.dual;
8208 */
8209 -- Hardcoded sequence number not acceptable
8210 l_seq := 9999;
8211 l_itemkey := to_char (document_id)|| '-' || l_seq;
8212 
8213 wf_engine.createProcess     ( ItemType  => l_ItemType,
8214                                   ItemKey   => l_ItemKey,
8215                                   Process   => 'MAIN_AUCTION_PROCESS');
8216 
8217 wf_engine.SetItemAttrText (   itemtype   => l_ItemType,
8218                                         itemkey    => l_ItemKey,
8219                                         aname      => 'XML_EVENT_KEY',
8220                                         avalue     => l_itemkey);
8221 
8222 wf_engine.SetItemAttrText (      itemtype => l_ItemType,
8223                      itemkey  => l_ItemKey,
8224                      aname    => 'ECX_TRANSACTION_TYPE',
8225                      avalue   => 'PON_AUPO');
8226 wf_engine.SetItemAttrText (      itemtype => l_ItemType,
8227                      itemkey  => l_ItemKey,
8228                      aname    => 'ECX_TRANSACTION_SUBTYPE',
8229                      avalue   => 'AUPO');
8230 
8231 wf_engine.SetItemAttrText (      itemtype => l_ItemType,
8232                      itemkey  => l_ItemKey,
8233                      aname    => 'ECX_DOCUMENT_ID',
8234                      avalue   => document_id);
8235 
8236 wf_engine.SetItemAttrText (      itemtype => l_ItemType,
8237                      itemkey  => l_ItemKey,
8238                      aname    => 'ECX_PARTY_ID',
8239                      avalue   => party_id);
8240 
8241 wf_engine.SetItemAttrText (      itemtype => l_ItemType,
8242                      itemkey  => l_ItemKey,
8243                      aname    => 'ECX_PARTY_SITE_ID',
8244                      avalue   => party_id);
8245 
8246 wf_engine.SetItemAttrText (   itemtype => l_ItemType,
8247                           itemkey => l_ItemKey,
8248         aname  => 'ECX_DEBUG_LEVEL',
8249         avalue => l_debug_level );
8250 
8251     -- Bug 4295915: Set the  workflow owner
8252 wf_engine.SetItemOwner(itemtype => l_itemtype,
8253                        itemkey  => l_itemkey,
8254                        owner    => fnd_global.user_name);
8255 
8256 wf_engine.StartProcess ( ItemType  => l_ItemType,
8257                                   ItemKey   => l_ItemKey );
8258 
8259 END AUCTION_PO_SEND;
8260 
8261 PROCEDURE SET_NEW_ITEM_KEY(  itemtype        in varchar2,
8262                                itemkey         in varchar2,
8263                                actid           in number,
8264                                funcmode        in varchar2,
8265                                resultout       out NOCOPY varchar2)
8266 IS
8267 l_doc_id number;
8268 l_xml_event_key varchar2(100);
8269 l_wf_item_seq number;
8270 BEGIN
8271 if (funcmode <> wf_engine.eng_run) then
8272        resultout := wf_engine.eng_null;
8273        return;  --do not raise the exception, as it would end the wflow.
8274 end if;
8275 l_doc_id := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actid,
8276 'ECX_DOCUMENT_ID');
8277 /* sequence number hardcoded
8278 select PON_PO_WF_ITEMKEY_S.nextval into l_wf_item_seq from dual;
8279 */
8280 l_wf_item_seq := 9999;
8281 
8282  l_xml_event_key := to_char(l_doc_id) || '-' || to_char(l_wf_item_seq);
8283 
8284 wf_engine.SetItemAttrText (   itemtype   => itemType,
8285                               itemkey    => itemkey,
8286                               aname      => 'XML_EVENT_KEY',
8287                               avalue     => l_xml_event_key);
8288 
8289 END SET_NEW_ITEM_KEY;
8290 
8291 
8292 
8293 
8294 
8295 
8296  PROCEDURE CLOSEDATE_EARLIER_REMINDERDATE(  itemtype    in varchar2,
8297            itemkey    in varchar2,
8298                        actid           in number,
8299                        uncmode    in varchar2,
8300              resultout       out NOCOPY varchar2)
8301   IS
8302 
8303      x_closedate   DATE;
8304      x_reminderdate     DATE;
8305      x_this_auction_header_id   NUMBER;
8306 
8307 BEGIN
8308 
8309     x_this_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
8310                                                         itemkey  => itemkey,
8311                                                        aname    => 'AUCTION_ID');
8312 
8313    SELECT close_bidding_date, reminder_date
8314      INTO x_closedate, x_reminderdate
8315      FROM pon_auction_headers_all
8316      WHERE auction_header_id=x_this_auction_header_id;
8317 
8318 
8319     IF (x_closedate<x_reminderdate) THEN
8320   resultout := 'Y';
8321     ELSE
8322   resultout := 'N';
8323 
8324     END IF;
8325 
8326 END;
8327 
8328 PROCEDURE  update_ack_to_YES (        itemtype    in varchar2,
8329              itemkey    in varchar2,
8330              actid           in number,
8331              uncmode    in varchar2,
8332              resultout          out NOCOPY varchar2)
8333 
8334   IS
8335 
8336      x_trading_partner_id     NUMBER;
8337      x_wf_user_name    VARCHAR2(100);
8338      x_doc_number NUMBER;
8339      x_note     VARCHAR2(4000);
8340      x_closedate DATE;
8341      x_now DATE;
8342      x_auction_status VARCHAR2(100);
8343      x_vendor_site_id NUMBER;
8344 
8345 BEGIN
8346 
8347 
8348     x_wf_user_name := wf_engine.GetItemAttrText (itemtype => itemtype,
8349                                              itemkey  => itemkey,
8350              aname    => 'BIDDER_TP_CONTACT_NAME');
8351 
8352     x_trading_partner_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
8353                                              itemkey  => itemkey,
8354                                                aname    => 'TRADING_PARTNER_ID');
8355 
8356     x_vendor_site_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
8357                                              itemkey  => itemkey,
8358                                                aname    => 'VENDOR_SITE_ID');
8359 
8360     x_doc_number := wf_engine.GetItemAttrNumber (itemtype => itemtype,
8361                                              itemkey  => itemkey,
8362                                      aname    => 'AUCTION_ID'); /* using auction_id instead of
8363                                                                               auction_number as a standard
8364                                                                               across item types */
8365 
8366 
8367         x_note :=  wf_engine.GetItemAttrText (itemtype => itemtype,
8368                                              itemkey  => itemkey,
8369              aname    => 'NOTE_TO_BUYER');
8370 
8371    SELECT close_bidding_date,auction_status
8372      INTO x_closedate, x_auction_status
8373      FROM pon_auction_headers_all
8374      WHERE auction_header_id=x_doc_number;
8375 
8376    x_now := SYSDATE;
8377 
8378    IF (x_closedate>x_now AND x_auction_status<>'CANCELLED' AND x_auction_status<>'DELETED') then
8379 
8380         UPDATE pon_bidding_parties
8381   SET supp_acknowledgement='Y',
8382     ack_note_to_auctioneer = x_note,
8383           ack_partner_contact_id = trading_partner_contact_id,
8384           acknowledgement_time = x_now
8385         WHERE (trading_partner_id= x_trading_partner_id
8386          or  wf_user_name= x_wf_user_name )
8387          and nvl(vendor_site_id, -1) = nvl(x_vendor_site_id , -1)
8388          and auction_header_id=x_doc_number;
8389 
8390        x_doc_number :=x_doc_number;
8391 
8392    END IF;
8393 
8394    END update_ack_to_yes;
8395 
8396 
8397 
8398 
8399 PROCEDURE  UPDATE_ACK_TO_NO (        itemtype    in varchar2,
8400              itemkey    in varchar2,
8401              actid           in number,
8402              uncmode    in varchar2,
8403              resultout          out NOCOPY varchar2)
8404 
8405   IS
8406 
8407      x_trading_partner_id     NUMBER;
8408      x_wf_user_name    VARCHAR2(100);
8409      x_doc_number NUMBER;
8410      x_note     VARCHAR2(4000);
8411      x_closedate DATE;
8412      x_now DATE;
8413      x_auction_status VARCHAR2(100);
8414      x_vendor_site_id NUMBER;
8415 
8416 
8417    BEGIN
8418 
8419 
8420     x_wf_user_name := wf_engine.GetItemAttrText (itemtype => itemtype,
8421                                              itemkey  => itemkey,
8422              aname    => 'BIDDER_TP_CONTACT_NAME');
8423 
8424     x_trading_partner_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
8425                                              itemkey  => itemkey,
8426                                                aname    => 'TRADING_PARTNER_ID');
8427 
8428     x_vendor_site_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
8429                                              itemkey  => itemkey,
8430                                                aname    => 'VENDOR_SITE_ID');
8431 
8432     x_doc_number := wf_engine.GetItemAttrNumber (itemtype => itemtype,
8433                                              itemkey  => itemkey,
8434                                      aname    => 'AUCTION_ID'); /* using auction_id instead of
8435                                                                               auction_number as a standard
8436                                                                               across item types */
8437 
8438         x_note :=  wf_engine.GetItemAttrText (itemtype => itemtype,
8439                                              itemkey  => itemkey,
8440              aname    => 'NOTE_TO_BUYER');
8441 
8442   SELECT close_bidding_date,auction_status
8443      INTO x_closedate, x_auction_status
8444      FROM pon_auction_headers_all
8445      WHERE auction_header_id=x_doc_number;
8446 
8447    x_now := SYSDATE;
8448 
8449    IF (x_closedate>x_now AND x_auction_status<>'CANCELLED' AND x_auction_status<>'DELETED') then
8450 
8451 
8452         UPDATE pon_bidding_parties
8453   SET supp_acknowledgement='N',
8454     ack_note_to_auctioneer = x_note,
8455           ack_partner_contact_id = trading_partner_contact_id,
8456           acknowledgement_time = x_now
8457        WHERE (trading_partner_id= x_trading_partner_id
8458          or  wf_user_name= x_wf_user_name )
8459          and nvl(vendor_site_id,-1) = nvl(x_vendor_site_id,-1)
8460          and auction_header_id=x_doc_number;
8461 
8462        x_doc_number :=x_doc_number;
8463 
8464    END IF;
8465 
8466    END update_ack_to_no;
8467 
8468 
8469    PROCEDURE launch_init_notif_proc(itemtype IN VARCHAR2,
8470             itemkey  IN VARCHAR2,
8471             actid    IN NUMBER,
8472             uncmode  IN VARCHAR2,
8473             resultout OUT NOCOPY VARCHAR2)
8474      IS
8475 
8476 --  x_process VARCHAR2;
8477   x_progress VARCHAR2(3);
8478 --  x_notification_id NUMBER;
8479 
8480    BEGIN
8481 
8482  --     x_process :='NOT_BIDDERS_AUC_START';
8483       x_progress :='010';
8484 
8485 
8486       launch_notif_process(p_itemtype => itemtype,
8487          p_itemkey => itemkey,
8488          p_actid => actid,
8489          p_process => 'NOT_BIDDERS_AUC_START');
8490       x_progress :='020';
8491 
8492    END launch_init_notif_proc;
8493 
8494      PROCEDURE launch_init_notif_p_add(itemtype IN VARCHAR2,
8495             itemkey  IN VARCHAR2,
8496             actid    IN NUMBER,
8497             uncmode  IN VARCHAR2,
8498             resultout OUT NOCOPY VARCHAR2)
8499      IS
8500 
8501 --  x_process VARCHAR2;
8502   x_progress VARCHAR2(3);
8503 --  x_notification_id NUMBER;
8504 
8505    BEGIN
8506 
8507  --     x_process :='NOT_BIDDERS_AUC_START';
8508       x_progress :='010';
8509 
8510 
8511       launch_notif_process(p_itemtype => itemtype,
8512          p_itemkey => itemkey,
8513          p_actid => actid,
8514          p_process => 'NOT_BIDDER_AUC_START_ADD');
8515       x_progress :='020';
8516 
8517      END launch_init_notif_p_add;
8518 
8519         PROCEDURE launch_new_round_notif(itemtype IN VARCHAR2,
8520             itemkey  IN VARCHAR2,
8521             actid    IN NUMBER,
8522             uncmode  IN VARCHAR2,
8523             resultout OUT NOCOPY VARCHAR2)
8524      IS
8525 
8526 --  x_process VARCHAR2;
8527   x_progress VARCHAR2(3);
8528 --  x_notification_id NUMBER;
8529 
8530    BEGIN
8531 
8532  --     x_process :='NOT_BIDDERS_AUC_START';
8533       x_progress :='010';
8534 
8535 
8536       launch_notif_process(p_itemtype => itemtype,
8537          p_itemkey => itemkey,
8538          p_actid => actid,
8539          p_process => 'NOT_NEW_ROUND_START');
8540       x_progress :='020';
8541 
8542    END launch_new_round_notif;
8543 
8544       PROCEDURE launch_new_round_notif_add(itemtype IN VARCHAR2,
8545             itemkey  IN VARCHAR2,
8546             actid    IN NUMBER,
8547             uncmode  IN VARCHAR2,
8548             resultout OUT NOCOPY VARCHAR2)
8549      IS
8550 
8551 --  x_process VARCHAR2;
8552   x_progress VARCHAR2(3);
8553 --  x_notification_id NUMBER;
8554 
8555    BEGIN
8556 
8557  --     x_process :='NOT_BIDDERS_AUC_START';
8558       x_progress :='010';
8559 
8560 
8561       launch_notif_process(p_itemtype => itemtype,
8562          p_itemkey => itemkey,
8563          p_actid => actid,
8564          p_process => 'NOT_NEW_ROUND_START_ADD');
8565       x_progress :='020';
8566 
8567    END launch_new_round_notif_add;
8568 
8569     PROCEDURE launch_added_notif_proc(itemtype IN VARCHAR2,
8570             itemkey  IN VARCHAR2,
8571             actid    IN NUMBER,
8572             uncmode  IN VARCHAR2,
8573             resultout OUT NOCOPY VARCHAR2)
8574      IS
8575 
8576 --  x_process VARCHAR2;
8577   x_progress VARCHAR2(3);
8578 --  x_notification_id NUMBER;
8579 
8580    BEGIN
8581 
8582  --     x_process :='NOT_BIDDERS_AUC_START';
8583       x_progress :='010';
8584 
8585 
8586       launch_notif_process(p_itemtype => itemtype,
8587          p_itemkey => itemkey,
8588          p_actid => actid,
8589          p_process => 'NOT_ADD_BIDDERS_AUC_START');
8590       x_progress :='020';
8591 
8592    END launch_added_notif_proc;
8593 
8594 
8595 PROCEDURE LAUNCH_NOTIF_PROCESS(p_itemtype    in varchar2,
8596              p_itemkey    in varchar2,
8597              p_actid                  IN NUMBER,
8598              p_process   IN VARCHAR2)
8599 
8600 
8601   IS
8602 
8603      x_itemtype    VARCHAR2(8) := 'PONPBLSH';
8604      x_sequence    NUMBER;
8605      x_itemkey    VARCHAR2(50);
8606      x_auction_header_id          NUMBER;
8607      x_tp_id                      NUMBER;
8608      x_supplier_exampt_count  NUMBER;    --choli
8609      x_exempt_flag VARCHAR2(1);          --choli
8610 BEGIN
8611 
8612       SELECT pon_auction_wf_publish_s.nextval
8613       INTO   x_sequence
8614       FROM   dual;
8615       x_itemkey := (p_itemkey||'-'||to_char(x_sequence));
8616 
8617       wf_engine.CreateProcess(itemtype => x_itemtype,
8618                             itemkey  => x_itemkey,
8619             process  => p_process);
8620 
8621       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8622                                  itemkey    => x_itemkey,
8623                                  aname      => 'BIDDER_TP_CONTACT_NAME',
8624                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8625                     itemkey  => p_itemkey,
8626                     aname    => 'BIDDER_TP_CONTACT_NAME'));
8627 
8628       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8629                                  itemkey    => x_itemkey,
8630                                  aname      => 'ORIGIN_USER_NAME',
8631                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8632                     itemkey  => p_itemkey,
8633                     aname    => 'ORIGIN_USER_NAME'));
8634 
8635        wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
8636                                  itemkey    => x_itemkey,
8637                                  aname      => 'AUCTION_ID',
8638                                  avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
8639                     itemkey  => p_itemkey,
8640                     aname    => 'AUCTION_ID')); /* using auction_id instead of
8641                                                                     auction_number as a standard
8642                                                                     across item types */
8643 
8644        wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
8645                                  itemkey    => x_itemkey,
8646                                  aname      => 'INVITATION_ID',
8647                                  avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
8648                     itemkey  => p_itemkey,
8649                     aname    => 'INVITATION_ID'));
8650 
8651        wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8652                                   itemkey    => x_itemkey,
8653                                   aname      => 'EVENT_TITLE',
8654                                   avalue     => replaceHtmlChars(wf_engine.GetItemAttrText (itemtype => p_itemtype,
8655                                                                              itemkey  => p_itemkey,
8656                                                                              aname    => 'EVENT_TITLE')));
8657 
8658       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8659                                  itemkey    => x_itemkey,
8660                                  aname      => 'AUCTION_DESCRIPTION',
8661                                  avalue     => replaceHtmlChars(wf_engine.GetItemAttrText (itemtype => p_itemtype,
8662                     itemkey  => p_itemkey,
8663                     aname    => 'AUCTION_DESCRIPTION')));
8664 
8665       wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
8666                                  itemkey    => x_itemkey,
8667                                  aname      => 'AUCTION_START_DATE',
8668                                  avalue     => wf_engine.GetItemAttrDate (itemtype => p_itemtype,
8669                     itemkey  => p_itemkey,
8670                     aname    => 'AUCTION_START_DATE'));
8671 
8672       wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
8673                                  itemkey    => x_itemkey,
8674                                  aname      => 'AUCTION_END_DATE',
8675                                  avalue     => wf_engine.GetItemAttrDate (itemtype => p_itemtype,
8676                     itemkey  => p_itemkey,
8677                     aname    => 'AUCTION_END_DATE'));
8678 
8679       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8680                                  itemkey    => x_itemkey,
8681                                  aname      => 'NOTE_TO_BIDDERS',
8682                                  avalue     => replaceHtmlChars(wf_engine.GetItemAttrText (itemtype => p_itemtype,
8683                     itemkey  => p_itemkey,
8684                     aname    => 'NOTE_TO_BIDDERS')));
8685 
8686       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8687                                  itemkey    => x_itemkey,
8688                                  aname      => 'TP_DISPLAY_NAME',
8689                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8690                     itemkey  => p_itemkey,
8691                     aname    => 'TP_DISPLAY_NAME'));
8692 
8693 
8694       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8695                                  itemkey    => x_itemkey,
8696                                  aname      => 'PON_AUC_WF_DOC_TYPE_OPEN',
8697                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8698                     itemkey  => p_itemkey,
8699                     aname    => 'PON_AUC_WF_DOC_TYPE_OPEN'));
8700 
8701        wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8702                                  itemkey    => x_itemkey,
8703                                  aname      => 'PON_AUC_WF_DOC_TYPE_CLOSE',
8704                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8705                     itemkey  => p_itemkey,
8706                     aname    => 'PON_AUC_WF_DOC_TYPE_CLOSE'));
8707 
8708         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8709                                  itemkey    => x_itemkey,
8710                                  aname      => 'PON_AUC_WF_PUB_OPEN_RG_S',
8711                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8712                     itemkey  => p_itemkey,
8713                     aname    => 'PON_AUC_WF_PUB_OPEN_RG_S'));
8714 
8715    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8716                                  itemkey    => x_itemkey,
8717                                  aname      => 'PON_AUC_WF_PUB_OPEN_RG_M1',
8718                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8719                     itemkey  => p_itemkey,
8720                     aname    => 'PON_AUC_WF_PUB_OPEN_RG_M1'));
8721 
8722    wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8723                                  itemkey    => x_itemkey,
8724                                  aname      => 'PLACE_BID',
8725                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8726                     itemkey  =>p_itemkey,
8727                     aname    => 'PLACE_BID'));
8728 
8729     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8730                                  itemkey    => x_itemkey,
8731                                  aname      => 'PON_AUC_WF_TOACKNOWLEDGE',
8732                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8733                     itemkey  => p_itemkey,
8734                     aname    => 'PON_AUC_WF_TOACKNOWLEDGE'));
8735 
8736      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8737                                  itemkey    => x_itemkey,
8738                                  aname      => 'PREPARER_TP_NAME',
8739                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8740                     itemkey  => p_itemkey,
8741                     aname    => 'PREPARER_TP_NAME'));
8742 
8743 
8744       wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
8745                                  itemkey    => x_itemkey,
8746                                  aname      => 'NUMBER_OF_ITEMS',
8747                                  avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
8748                     itemkey  => p_itemkey,
8749                       aname    => 'NUMBER_OF_ITEMS'));
8750       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8751                                  itemkey    => x_itemkey,
8752                                  aname      => 'AUCTION_TITLE',
8753                                  avalue     => replaceHtmlChars(wf_engine.GetItemAttrText (itemtype => p_itemtype,
8754                     itemkey  => p_itemkey,
8755                     aname    => 'AUCTION_TITLE')));
8756 
8757 --      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8758 --                                 itemkey    => x_itemkey,
8759 --                                 aname      => 'OEX_OPERATION',
8760 --                                 avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8761 --                    itemkey  => p_itemkey,
8762 --                    aname    => 'OEX_OPERATION'));
8763 
8764       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8765                                  itemkey    => x_itemkey,
8766                                  aname      => 'OEX_OPERATION_URL',
8767                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8768                     itemkey  => p_itemkey,
8769                     aname    => 'OEX_OPERATION_URL'));
8770         wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8771                                  itemkey    => x_itemkey,
8772                                  aname      => 'TP_TIME_ZONE',
8773                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8774                     itemkey  => p_itemkey,
8775                     aname    => 'TP_TIME_ZONE'));
8776 
8777       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8778                                  itemkey    => x_itemkey,
8779                                  aname      => 'AUCTION_TYPE_NAME',
8780                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8781                     itemkey  => p_itemkey,
8782                     aname    => 'AUCTION_TYPE_NAME'));
8783 
8784 /*
8785       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8786                                  itemkey    => x_itemkey,
8787                                  aname      => 'OEX_OPERATION_START',
8788                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8789                     itemkey  => p_itemkey,
8790                     aname    => 'OEX_OPERATION_START'));
8791 
8792 
8793       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8794                                  itemkey    => x_itemkey,
8795                                  aname      => 'TEXT_HEADER',
8796                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8797                     itemkey  => p_itemkey,
8798                     aname    => 'TEXT_HEADER'));
8799 
8800       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8801                                  itemkey    => x_itemkey,
8802                                  aname      => 'TEXT_FOOTER',
8803                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8804                     itemkey  => p_itemkey,
8805                     aname    => 'TEXT_FOOTER'));
8806 
8807 
8808       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8809                                  itemkey    => x_itemkey,
8810                                  aname      => 'HTML_HEADER',
8811                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8812                     itemkey  => p_itemkey,
8813                     aname    => 'HTML_HEADER'));
8814 
8815       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8816                                  itemkey    => x_itemkey,
8817                                  aname      => 'HTML_FOOTER',
8818                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8819                     itemkey  => p_itemkey,
8820                     aname    => 'HTML_FOOTER'));
8821 */
8822       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8823                                  itemkey    => x_itemkey,
8824                                  aname      => 'TP_LANGUAGE_CODE',
8825                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8826                     itemkey  => p_itemkey,
8827                     aname    => 'TP_LANGUAGE_CODE'));
8828 
8829       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8830                                  itemkey    => x_itemkey,
8831                                  aname      => 'PON_AUC_WF_DOC_TITLE',
8832                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8833                     itemkey  => p_itemkey,
8834                     aname    => 'PON_AUC_WF_DOC_TITLE'));
8835 
8836 
8837       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8838                                  itemkey    => x_itemkey,
8839                                  aname      => 'PON_AUC_WF_DOC_NUM',
8840                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8841                     itemkey  => p_itemkey,
8842                     aname    => 'PON_AUC_WF_DOC_NUM'));
8843 
8844       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8845                                  itemkey    => x_itemkey,
8846                                  aname      => 'PON_AUC_WF_DOC_EVENT',
8847                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8848                     itemkey  => p_itemkey,
8849                     aname    => 'PON_AUC_WF_DOC_EVENT'));
8850 
8851       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8852                                  itemkey    => x_itemkey,
8853                                  aname      => 'PON_AUC_WF_PUB_NEWRND_M1',
8854                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8855                     itemkey  => p_itemkey,
8856                     aname    => 'PON_AUC_WF_PUB_NEWRND_M1'));
8857 
8858       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8859                                  itemkey    => x_itemkey,
8860                                  aname      => 'PON_AUC_WF_PUB_NEWRND_M2',
8861                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8862                     itemkey  => p_itemkey,
8863                     aname    => 'PON_AUC_WF_PUB_NEWRND_M2'));
8864 
8865      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8866                                  itemkey    => x_itemkey,
8867                                  aname      => 'PON_AUC_WF_PUB_NEWRND_RG_S',
8868                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8869                     itemkey  => p_itemkey,
8870                     aname    => 'PON_AUC_WF_PUB_NEWRND_RG_S'));
8871 
8872       wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8873                                  itemkey    => x_itemkey,
8874                                  aname      => 'PON_AUC_WF_AUCTIONEER',
8875                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8876                     itemkey  => p_itemkey,
8877                     aname    => 'PON_AUC_WF_AUCTIONEER'));
8878 
8879  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8880                                  itemkey    => x_itemkey,
8881                                  aname      => 'PREVIEW_MESSAGE',
8882                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8883                     itemkey  => p_itemkey,
8884                     aname    => 'PREVIEW_MESSAGE'));
8885 
8886    wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
8887                                  itemkey    => x_itemkey,
8888                                  aname      => 'AUCTION_NOTIFICATION_DATE',
8889                                  avalue     => wf_engine.GetItemAttrDate (itemtype => p_itemtype,
8890                     itemkey  => p_itemkey,
8891                     aname    => 'AUCTION_NOTIFICATION_DATE'));
8892 
8893     wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8894                                  itemkey    => x_itemkey,
8895                                  aname      => 'TP_TIME_ZONE1',
8896                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8897                     itemkey  => p_itemkey,
8898                     aname    => 'TP_TIME_ZONE1'));
8899 
8900      wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8901                                  itemkey    => x_itemkey,
8902                                  aname      => 'ARTICLE_DOC_TYPE',
8903                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8904                     itemkey  => p_itemkey,
8905                     aname    => 'ARTICLE_DOC_TYPE'));
8906  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8907                                  itemkey    => x_itemkey,
8908                                  aname      => 'APPSTR',
8909                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8910                     itemkey  => p_itemkey,
8911                     aname    => 'APPSTR'));
8912 
8913 
8914  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8915                                  itemkey    => x_itemkey,
8916                                  aname      => 'APP',
8917                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8918                     itemkey  => p_itemkey,
8919                     aname    => 'APP'));
8920 
8921  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8922                                  itemkey    => x_itemkey,
8923                                  aname      => 'DOC_NUMBER',
8924                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8925                     itemkey  => p_itemkey,
8926                     aname    => 'DOC_NUMBER'));
8927 
8928        wf_engine.SetItemAttrNumber (itemtype   => x_itemtype,
8929                                  itemkey    => x_itemkey,
8930                                  aname      => 'TRADING_PARTNER_ID',
8931                                  avalue     => wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
8932                     itemkey  => p_itemkey,
8933                     aname    => 'TRADING_PARTNER_ID'));
8934 
8935  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8936                                  itemkey    => x_itemkey,
8937                                  aname      => 'ADDITIONAL_CONTACT_USERNAME',
8938                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8939                     itemkey  => p_itemkey,
8940                     aname    => 'ADDITIONAL_CONTACT_USERNAME'));
8941 
8942  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8943                                  itemkey    => x_itemkey,
8944                                  aname      => 'PON_AUC_WF_DOC_IN_PR0G',
8945                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8946                     itemkey  => p_itemkey,
8947                     aname    => 'PON_AUC_WF_DOC_IN_PR0G'));
8948 
8949  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8950                                  itemkey    => x_itemkey,
8951                                  aname      => 'PON_AUC_WF_LOGON_BEFORE',
8952                                  avalue     => wf_engine.GetItemAttrText (itemtype => p_itemtype,
8953                     itemkey  => p_itemkey,
8954                     aname    => 'PON_AUC_WF_LOGON_BEFORE'));
8955 
8956     -- Bug 4295915: Set the  workflow owner
8957  wf_engine.SetItemOwner(itemtype => x_itemtype,
8958                         itemkey  => x_itemkey,
8959                         owner    => fnd_global.user_name);
8960 
8961 -- choli update for emd
8962  -- For members, store item key in pom_bidding_parties
8963  x_auction_header_id := wf_engine.GetItemAttrNumber(itemtype => p_itemtype,
8964                                                     itemkey  => p_itemkey,
8965                                                     aname    => 'AUCTION_ID'); /* using auction_id instead of
8966                                                                                  auction_number as a standard
8967                                                                                  across item types */
8968 
8969  x_tp_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
8970                                     itemkey  => p_itemkey,
8971                                          aname    => 'TRADING_PARTNER_ID');
8972 
8973       --choli for SUPPLIER_EXEMPTED_INFO
8974  BEGIN
8975    select exempt_flag
8976      into x_exempt_flag
8977      from pon_bidding_parties b
8978     where auction_header_id = x_auction_header_id
8979       and trading_partner_id = x_tp_id
8980       and rownum = 1;
8981  EXCEPTION
8982    WHEN NO_DATA_FOUND THEN
8983      x_exempt_flag := 'N';
8984    WHEN OTHERS THEN
8985      x_exempt_flag := 'N';
8986  END;
8987  IF(x_exempt_flag = 'Y') THEN
8988  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8989                                  itemkey    => x_itemkey,
8990                                  aname      => 'SUPPLIER_EXEMPTED_INFO',
8991                                  avalue     => 'You are exampted from paying the EMD/Bank Guarantee for this Negotiation');
8992 ELSE
8993  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
8994                                  itemkey    => x_itemkey,
8995                                  aname      => 'SUPPLIER_EXEMPTED_INFO',
8996                                  avalue     => ' ');
8997 END IF;
8998 
8999  wf_engine.StartProcess(itemtype => x_itemtype,
9000                         itemkey  => x_itemkey );
9001 
9002 
9003 
9004  UPDATE pon_bidding_parties set
9005  wf_item_key = x_itemkey
9006  WHERE trading_partner_id = x_tp_id
9007  AND auction_header_id = x_auction_header_id;
9008 
9009 
9010 END LAUNCH_NOTIF_PROCESS;
9011 
9012 PROCEDURE NOTIFY_BIDDER_LIST_REMINDER(itemtype    in varchar2,
9013                               itemkey    in varchar2,
9014                               actid           in number,
9015                               uncmode    in varchar2,
9016                               resultout          out NOCOPY varchar2)
9017 IS
9018 
9019     x_doc_number                   NUMBER;
9020     x_neg_summary_url_supplier     VARCHAR2(2000);
9021     x_isp_supplier_register_url    VARCHAR2(2000);
9022     x_ack_part_url_supplier        VARCHAR2(2000);
9023     x_auction_tp_contact_name      PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_NAME%TYPE;
9024     x_preview_date                DATE;
9025     x_preview_date_notspec         VARCHAR2(240);
9026     x_timezone1_disp               VARCHAR2(240);
9027 -- Bug 3824928: Removed obsolete columns
9028 CURSOR bidders IS
9029    select
9030      fu.user_name my_user_name,
9031      pbd.trading_partner_id,
9032      pbd.trading_partner_name my_user_display_name,
9033      decode(pbd.vendor_site_code, '-1', null, pbd.vendor_site_code) vendor_site_code,
9034      pbd.wf_user_name additional_name,
9035      pbd.wf_item_key,
9036      pbd.additional_contact_email,
9037      pbd.registration_id,
9038      pbd.trading_partner_contact_id, -- Bug 3824928 added
9039      pbd.vendor_site_id
9040    from pon_bidding_parties pbd,
9041         fnd_user fu
9042    WHERE pbd.trading_partner_contact_id=fu.person_party_id (+) AND -- Bug 3824928: added outer join
9043           nvl(fu.end_date, sysdate+1) > sysdate  AND                                -- Added for TCA project
9044           pbd.auction_header_id=x_doc_number AND
9045           nvl(pbd.supp_acknowledgement,'havenot')= 'havenot'
9046           and pbd.trading_partner_id is not null;
9047 
9048    -- Bug 3824928: Removed union below
9049 
9050     x_language_code varchar2(30);
9051   x_auctioneer_user_name VARCHAR2(60);
9052     x_profile_user VARCHAR2(60);
9053   x_member_flag VARCHAR2(3);
9054     x_message_name varchar2(80);
9055   x_process_name VARCHAR2(80);
9056   x_text_header varchar2(540) := '';
9057   x_text_footer varchar2(540) := '';
9058   x_doc_internal_name varchar2(60) := '';
9059   x_msg_suffix varchar2(3) := '';
9060   x_nid number;
9061   x_newendtime          DATE;
9062   x_itemtype    VARCHAR2(8) := 'PONPBLSH';
9063     x_itemkey    VARCHAR2(50);
9064   x_sequence    NUMBER;
9065   x_auction_tp_name PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_NAME%TYPE := '';
9066     x_auction_contact_dp_name varchar2(240) := '';
9067   x_tp_display_name varchar2(240) :='';
9068   x_auction_title varchar2(240) := '';
9069   x_auction_start_date date;
9070   x_auction_end_date date;
9071   x_operation_url   VARCHAR2(300);
9072   x_invitation_id number;
9073   x_oex_operation   VARCHAR2(640);
9074   x_wf_item_key VARCHAR2(240);
9075   x_appstr VARCHAR2(20);
9076   x_app VARCHAR2(20);
9077   x_oex_timezone VARCHAR2(80);
9078   x_person_party_id NUMBER(15);
9079   x_timezone    VARCHAR2(80);
9080   x_newstarttime          DATE;
9081   x_doc_number_dsp   VARCHAR2(30);
9082   x_bids_by_company NUMBER;
9083   x_commits_by_company NUMBER;
9084   x_total_participations NUMBER;
9085   x_timezone_disp  VARCHAR2(240);
9086     x_timezone1    VARCHAR2(80); -- preview timezone
9087     x_newpreviewtime  DATE;
9088     x_timezone1_dsp         VARCHAR2(240);
9089 
9090     -- Added the following declaration for Affiliate ID related changes
9091     -- Auctioneer's trading partner id
9092     x_tp_id NUMBER;
9093 
9094     x_registration_key VARCHAR2(100);
9095 
9096     l_origin_user_name   fnd_user.user_name%TYPE;
9097 
9098 BEGIN
9099 
9100             x_doc_number := wf_engine.GetItemAttrNumber (itemtype   => itemtype,
9101                                                    itemkey    => itemkey,
9102                                                    aname      => 'AUCTION_ID');
9103 
9104     -- Bug 8992789
9105     IF (IS_INTERNAL_ONLY(x_doc_number)) THEN
9106       RETURN;
9107     END IF;
9108 
9109           x_doc_internal_name := wf_engine.GetItemAttrText (itemtype   => itemtype,
9110                                                               itemkey    => itemkey,
9111                                                 aname      => 'DOC_INTERNAL_NAME');
9112 
9113              BEGIN
9114                  x_preview_date := wf_engine.GetItemAttrDate (itemtype   => itemtype,
9115                                                               itemkey    => itemkey,
9116                                                      aname      => 'PREVIEW_DATE');
9117 
9118                  x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => itemtype,
9119                                                                       itemkey  => itemkey,
9120                                                                       aname    => 'PREVIEW_DATE_NOTSPECIFIED');
9121              EXCEPTION
9122            WHEN NO_DATA_FOUND
9123            THEN
9124            -- Assigning null to the item attributes
9125                x_preview_date := null;
9126                  x_preview_date_notspec := null;
9127              WHEN OTHERS
9128            THEN
9129                RAISE;
9130            END;
9131 
9132         x_msg_suffix := GET_MESSAGE_SUFFIX (x_doc_internal_name);
9133 
9134       x_doc_number_dsp     := wf_engine.GetItemAttrText   (itemtype => itemtype,
9135                                                              itemkey  => itemkey,
9136                                                             aname    => 'DOC_NUMBER');
9137         x_oex_timezone := Get_Oex_Time_Zone;
9138 
9139 --        x_auction_tp_contact_name  := wf_engine.GetItemAttrText (itemtype   => itemtype,
9140 --                                                                 itemkey    => itemkey,
9141 --                                                                 aname      => 'PREPARER_TP_CONTACT_NAME');
9142 
9143 
9144       x_auction_tp_name := wf_engine.GetItemAttrText (itemtype   => itemtype,
9145                                                         itemkey    => itemkey,
9146                                           aname      => 'PREPARER_TP_NAME');
9147 
9148       x_auction_contact_dp_name := wf_engine.GetItemAttrText (itemtype   => itemtype,
9149                                                         itemkey    => itemkey,
9150                                           aname      => 'PREPARER_CONTACT_DP_NAME');
9151 
9152        x_auction_title := wf_engine.GetItemAttrText (itemtype   => itemtype,
9153                                                     itemkey    => itemkey,
9154                                                     aname      => 'AUCTION_TITLE');
9155 
9156        l_origin_user_name := wf_engine.GetItemAttrText (itemtype   => itemtype,
9157                                                           itemkey    => itemkey,
9158                                                           aname      => 'ORIGIN_USER_NAME');
9159 
9160       x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => itemtype,
9161                                                     itemkey    => itemkey,
9162                                                     aname      => 'AUCTION_START_DATE');
9163 
9164       x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => itemtype,
9165                                                     itemkey    => itemkey,
9166                                                     aname      => 'AUCTION_END_DATE');
9167 
9168      begin
9169     SELECT wf_item_key
9170     INTO x_wf_item_key
9171     FROM pon_auction_headers_all
9172     WHERE auction_header_id=x_doc_number;
9173 
9174        select trading_partner_id, trading_partner_contact_name
9175           into x_tp_id, x_auction_tp_contact_name
9176           from pon_auction_headers_all
9177           where auction_header_id = x_doc_number;
9178 
9179      END;
9180 
9181 
9182      FOR bidder IN bidders LOOP --{
9183 
9184   SELECT COUNT(bid_number)
9185     INTO x_bids_by_company
9186     FROM pon_bid_headers
9187     WHERE auction_header_id=x_doc_number
9188     AND trading_partner_id=bidder.trading_partner_id;
9189 
9190   x_total_participations :=x_bids_by_company;
9191 
9192 
9193   IF(x_total_participations=0) then
9194 
9195       x_member_flag :='Y';
9196       x_process_name :='REMIND_MEMBERS_PROCESS';
9197      -- Bug 3824928: Trading partner contact id can be null
9198        IF bidder.trading_partner_contact_id is not null then -- {
9199          PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(bidder.my_user_name,x_language_code);
9200 
9201 
9202           BEGIN
9203             SELECT person_party_id
9204         INTO x_person_party_id
9205         FROM fnd_user
9206         WHERE user_name = bidder.my_user_name;
9207           EXCEPTION
9208           WHEN TOO_MANY_ROWS THEN
9209             null;  -- This can never throw too many row exception
9210           END;
9211 
9212       -- Get the user's time zone
9213       --
9214     x_timezone := Get_Time_Zone(x_person_party_id);
9215 
9216       --
9217       -- Make sure that it is a valid time zone
9218       --
9219 
9220       IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 0) THEN
9221        x_timezone := x_oex_timezone;
9222       END IF;
9223 
9224       -- Create new timezone
9225       IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 1) THEN
9226         x_newstarttime   := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_auction_start_date,x_oex_timezone,x_timezone);
9227         x_newendtime     := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_auction_end_date,x_oex_timezone,x_timezone);
9228         x_newpreviewtime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_preview_date,x_oex_timezone,x_timezone);
9229       ELSE
9230         x_newstarttime   := x_auction_start_date;
9231       x_newendtime     := x_auction_end_date;
9232         x_newpreviewtime := x_preview_date;
9233       END IF;
9234     END IF; -- IF bidder.trading_partner_contact_id is not null
9235 
9236     -- Bug 3824928: Checking if additional_contact_email is not null
9237     if bidder.additional_contact_email is not null then -- {
9238 
9239            if bidder.trading_partner_contact_id is null then -- {
9240                          -- use auctioneer's language
9241                          --x_auctioneer_user_name := wf_engine.GetItemAttrText (itemtype => 'PONAUCT',
9242                          --                                                     itemkey  => x_wf_item_key,
9243                          --                                                     aname    => 'PREPARER_TP_CONTACT_NAME');
9244                          x_auctioneer_user_name := x_auction_tp_contact_name;
9245 
9246                          PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(x_auctioneer_user_name,x_language_code);
9247 
9248                          -- get auctioneer's timezone
9249                          x_timezone := Get_Time_Zone(x_auctioneer_user_name);
9250 
9251                          --
9252                          -- Make sure that it is a valid time zone
9253                          --
9254 
9255                          IF (PON_OEX_TIMEZONE_PKG.VALID_ZONE(x_timezone) = 0) THEN
9256                             x_timezone := x_oex_timezone;
9257                          END IF;
9258 
9259                          -- Create new timezone
9260                          x_newstarttime := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_auction_start_date,x_oex_timezone,x_timezone);
9261                          x_newendtime   := PON_OEX_TIMEZONE_PKG.CONVERT_TIME(x_auction_end_date,x_oex_timezone,x_timezone);
9262 
9263 
9264              end if; -- }
9265 
9266       end if; -- }
9267 
9268        -- For bug#8353407
9269 	   --IF (x_language_code is not null) THEN
9270            --IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
9271                -- FND_LOG.string(log_level => FND_LOG.level_statement,
9272                  -- module => g_module_prefix || 'NOTIFY_BIDDER_LIST_REMINDER',
9273                   --message  => '8. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
9274            --END IF; --}
9275 
9276         --SET_SESSION_LANGUAGE(null, x_language_code);
9277        --END IF;
9278 	   UNSET_SESSION_LANGUAGE;
9279 
9280     SELECT pon_auction_wf_publish_s.nextval
9281       INTO   x_sequence
9282       FROM   dual;
9283 
9284       x_tp_display_name := bidder.my_user_display_name;
9285 
9286       x_itemkey := (itemkey||'-'||to_char(x_sequence));
9287 
9288       wf_engine.CreateProcess(itemtype => x_itemtype,
9289                               itemkey  => x_itemkey,
9290                         process  => x_process_name);
9291 
9292       -- For bug#8353407
9293 	  IF (x_language_code is not null) THEN
9294 
9295  	            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
9296  	                 FND_LOG.string(log_level => FND_LOG.level_statement,
9297  	                   module => g_module_prefix || 'NOTIFY_BIDDER_LIST_REMINDER',
9298  	                   message  => '8. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
9299  	            END IF; --}
9300 
9301  	               SET_SESSION_LANGUAGE(null, x_language_code);
9302  	           END IF;
9303 
9304       wf_engine.SetItemAttrText (itemtype => x_itemtype,
9305                                itemkey    => x_itemkey,
9306                                aname      => 'PREPARER_TP_CONTACT_NAME',
9307                                avalue     => x_auction_tp_contact_name);
9308 
9309       wf_engine.SetItemAttrText (itemtype => x_itemtype,
9310                                itemkey    => x_itemkey,
9311                                aname      => 'ORIGIN_USER_NAME',
9312                                avalue     => l_origin_user_name);
9313 
9314       wf_engine.SetItemAttrText (itemtype => x_itemtype,
9315                                itemkey    => x_itemkey,
9316                                aname      => 'BIDDER_TP_NAME',
9317                                avalue     => bidder.my_user_display_name);
9318 
9319      wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9320                                itemkey    => x_itemkey,
9321                                aname      => 'BIDDER_TP_ADDRESS_NAME',
9322                                avalue     => bidder.vendor_site_code);
9323 
9324 
9325      wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9326              itemkey  => x_itemkey,
9327              aname  => 'REGISTERED',
9328         avalue  => x_member_flag);
9329 
9330      wf_engine.SetItemAttrText   (itemtype => x_itemtype,
9331           itemkey  => x_itemkey,
9332           aname    => 'DOC_NUMBER',
9333           avalue   => x_doc_number_dsp);
9334 
9335 
9336       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9337              itemkey  => x_itemkey,
9338              aname  => 'BIDDER_TP_CONTACT_NAME',
9339          avalue  => bidder.my_user_name);
9340 
9341 
9342      wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9343                                   itemkey  => x_itemkey,
9344                            aname=> 'PREPARER_TP_NAME',
9345          avalue  => x_auction_tp_name);
9346 
9347 
9348               wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
9349              itemkey  => x_itemkey,
9350              aname  => 'TRADING_PARTNER_ID',
9351            avalue  => bidder.trading_partner_id);
9352 
9353 
9354             wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9355              itemkey  => x_itemkey,
9356              aname  => 'PREPARER_CONTACT_DP_NAME',
9357          avalue  => x_auction_contact_dp_name);
9358 
9359 
9360               wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9361              itemkey  => x_itemkey,
9362              aname  => 'INVITE_REMINDER_SUB',
9363              avalue  => getMessage('PON_AUC_WF_REQA', x_msg_suffix,
9364                                           'DOC_NUMBER', x_doc_number_dsp,
9365                                           'AUCTION_TITLE', replaceHtmlChars(x_auction_title)));
9366 -- Bug 6965954: START of Code Fix
9367 -- Set the values of AUCTION_START_DATE and AUCTION_END_DATE
9368 -- as the end_date is used to determine the timeout for the notifications
9369 -- sent to the supplier
9370 
9371              wf_engine.SetItemAttrDate     (itemtype   => x_itemtype,
9372                                      itemkey    => x_itemkey,
9373                                      aname      => 'AUCTION_START_DATE',
9374                                      avalue     => x_auction_start_date);
9375 
9376              wf_engine.SetItemAttrDate     (itemtype   => x_itemtype,
9377                                      itemkey    => x_itemkey,
9378                                      aname      => 'AUCTION_END_DATE',
9379                                      avalue     => x_auction_end_date);
9380 
9381 -- Bug 6965954: End of Code Fix
9382 
9383            wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9384              itemkey  => x_itemkey,
9385              aname  => 'TP_DISPLAY_NAME',
9386          avalue  => x_tp_display_name);
9387 
9388 
9389            wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9390              itemkey  => x_itemkey,
9391              aname  => 'AUCTION_TITLE',
9392          avalue  => replaceHtmlChars(x_auction_title));
9393 
9394 
9395            wf_engine.SetItemAttrNumber (itemtype  => x_itemtype,
9396              itemkey  => x_itemkey,
9397              aname  => 'AUCTION_ID',
9398              avalue  => x_doc_number); /* using auction_id instead of
9399                                                auction_number as a standard
9400                                                across item types */
9401 
9402 
9403               wf_engine.SetItemAttrDate(itemtype  => x_itemtype,
9404              itemkey  => x_itemkey,
9405              aname  => 'AUCTION_END_DATE_TZ',
9406          avalue  => x_newendtime);
9407 
9408            wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
9409              itemkey  => x_itemkey,
9410              aname  => 'AUCTION_START_DATE_TZ',
9411          avalue  => x_newstarttime);
9412 
9413        -- call to notification utility package to get the redirect page url that
9414        -- is responsible for getting the Neg. Summary url and forward to it.
9415        x_neg_summary_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
9416                               p_dest_func => 'PON_NEG_SUMMARY'
9417                                  ,p_notif_performer  => 'SUPPLIER');
9418 
9419       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9420                         itemkey    => x_itemkey,
9421                         aname      => 'NEG_SUMMARY_URL',
9422                         avalue      => x_neg_summary_url_supplier);
9423 
9424      -- call to notification utility package to get the redirect page url that
9425        -- is responsible for getting the Acknowledge participation url and forward to it.
9426        x_ack_part_url_supplier := pon_wf_utl_pkg.get_dest_page_url (
9427                               p_dest_func => 'PONRESAPN_ACKPARTICIPATN'
9428                                  ,p_notif_performer  => 'SUPPLIER');
9429 
9430        begin
9431         wf_engine.SetItemAttrText   (itemtype   => x_itemtype,
9432                                          itemkey    => x_itemkey,
9433                                          aname      => '#WFM_HTMLAGENT',
9434                                          avalue     => pon_wf_utl_pkg.get_base_external_supplier_url);
9435         exception
9436           when others then
9437             null;
9438         end;
9439 
9440 
9441       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9442                         itemkey    => x_itemkey,
9443                         aname      => 'ACK_PARTICIPATION_URL',
9444                         avalue      => x_ack_part_url_supplier);
9445 
9446    x_timezone_disp := Get_TimeZone_Description(x_timezone, x_language_code);
9447      IF (x_preview_date IS NULL) THEN
9448          x_timezone1_disp := null;
9449      ELSE
9450          x_timezone1_disp := x_timezone_disp;
9451      END IF;
9452 
9453            wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9454              itemkey  => x_itemkey,
9455              aname  => 'TP_TIME_ZONE',
9456          avalue  => x_timezone_disp);
9457 
9458   IF (x_preview_date is not null) THEN
9459         wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
9460              itemkey  => x_itemkey,
9461              aname  => 'PREVIEW_DATE_TZ',
9462              avalue   => x_newpreviewtime);
9463 
9464       wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9465                  itemkey   => x_itemkey,
9466                  aname     => 'TP_TIME_ZONE1',
9467                  avalue    => x_timezone1_disp);
9468 
9469         wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9470                            itemkey  => x_itemkey,
9471                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
9472                            avalue  => null);
9473 
9474   ELSE
9475           wf_engine.SetItemAttrDate (itemtype  => x_itemtype,
9476              itemkey  => x_itemkey,
9477              aname  => 'PREVIEW_DATE_TZ',
9478              avalue     => null);
9479 
9480           wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9481              itemkey  => x_itemkey,
9482              aname  => 'TP_TIME_ZONE1',
9483              avalue     => x_timezone1_disp);
9484 
9485          wf_engine.SetItemAttrText (itemtype  => x_itemtype,
9486                            itemkey  => x_itemkey,
9487                            aname  => 'PREVIEW_DATE_NOTSPECIFIED',
9488                            avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
9489 
9490 
9491     END IF;
9492 
9493 
9494            if (bidder.additional_contact_email is not null) then
9495 
9496                  wf_engine.SetItemAttrText (itemtype   => x_itemtype,
9497                                            itemkey    => x_itemkey,
9498                                    aname      => 'ADDITIONAL_CONTACT_USERNAME',
9499                                    avalue     => bidder.additional_name);
9500 
9501               begin
9502                 select registration_key
9503                   into x_registration_key
9504                   from fnd_registrations
9505                  where registration_id = bidder.registration_id;
9506               exception
9507                   WHEN NO_DATA_FOUND THEN
9508                        x_registration_key := '';
9509               end;
9510 
9511 
9512              -- call to notification utility package to get the iSupplier registration page url
9513              x_isp_supplier_register_url := pon_wf_utl_pkg.get_isp_supplier_register_url(p_registration_key => x_registration_key
9514                                                                                         ,p_language_code => x_language_code);
9515 
9516              wf_engine.SetItemAttrText (itemtype   => x_itemtype,
9517                                         itemkey    => x_itemkey,
9518                                         aname      => 'ISP_SUPPLIER_REG_URL',
9519                                         avalue     => x_isp_supplier_register_url);
9520 
9521            end if;
9522 
9523 
9524     -- Bug 4295915: Set the  workflow owner
9525       wf_engine.SetItemOwner(itemtype => x_itemtype,
9526                              itemkey  => x_itemkey,
9527                              owner    => fnd_global.user_name);
9528 
9529       wf_engine.StartProcess(itemtype => x_itemtype,
9530                              itemkey  => x_itemkey );
9531 
9532       -- Bug 3824928: replacing if x_member_flag ='Y' with IF trading
9533       -- partner contact id is not null
9534 
9535       IF bidder.trading_partner_contact_id IS NOT NULL THEN -- {
9536 
9537         -- For members, store item key in pon_bidding_parties
9538         -- End the previous waiting process
9539         Wf_Engine.AbortProcess(x_itemtype, bidder.wf_item_key, '', null);
9540 
9541         UPDATE pon_bidding_parties set
9542             wf_item_key = x_itemkey
9543         WHERE trading_partner_id = bidder.trading_partner_id
9544         AND auction_header_id = x_doc_number
9545         AND vendor_site_id = bidder.vendor_site_id; -- Supplier/supplier site combination can be different in 11.5.10
9546 
9547        END IF; -- } IF bidder.trading_partner_contact_id IS NOT NULL
9548 
9549        END IF; -- } participation already check
9550 
9551      END LOOP; --}
9552 
9553 	 -- For bug#8353407
9554 	 UNSET_SESSION_LANGUAGE;
9555 
9556 
9557 END notify_bidder_list_reminder;
9558 
9559 procedure retrieve_user_info(param1 varchar2) is
9560 type refCurType is Ref Cursor;
9561 param2 integer;
9562 param3  varchar2(2000);
9563 param4  varchar2(2000);
9564 param5  varchar2(2000);
9565 param6  varchar2(2000);
9566 param7  varchar2(2000);
9567 param8  varchar2(2000);
9568 param9  varchar2(2000);
9569 param11  varchar2(2000);
9570 param12  varchar2(2000);
9571 param14  varchar2(2000);
9572 param15  varchar2(2000);
9573 param16  varchar2(2000);
9574 param18  varchar2(2000);
9575 param19  varchar2(2000);
9576 param20  varchar2(2000);
9577 param21  refCurType;
9578 param22  integer;
9579 param23  integer;
9580 param24  integer;
9581 param25  integer;
9582 param26  varchar2(2000);
9583 param27  varchar2(2000);
9584 param28  varchar2(2000);
9585 param29  integer;
9586 param30  varchar2(2000);
9587 param31  varchar2(2000);
9588 param32  varchar2(2000);
9589 param33  refCurType;
9590 param34  varchar2(2000);
9591 param35  varchar2(2000);
9592 param36  varchar2(2000);
9593 param37  varchar2(2000);
9594 
9595 begin
9596 -- this is tricky there are just 20 vars as input in the new fn.
9597 
9598 g_userName := param1;
9599 end retrieve_user_info;
9600 
9601 /*======================================================================
9602  PROCEDURE :  DELETE_NEGOTIATION_LINE_REF    PUBLIC
9603  PARAMETERS:
9604   x_negotiation_id        in      auction header id
9605   x_negotiation_line_num  in      negotiation line number
9606   x_org_id                in      organization id
9607 x  x_error_code            out     internal code for error
9608 
9609  COMMENT   : delete negotiation line references
9610 ======================================================================*/
9611 PROCEDURE DELETE_NEGOTIATION_LINE_REF (
9612     x_negotiation_id        in   number,
9613     x_negotiation_line_num  in   number,
9614     x_org_id                in   number,
9615     x_error_code            out  NOCOPY varchar2) is
9616 
9617 BEGIN
9618 
9619       -- first, remove records in pon_backing_requisitions
9620       delete
9621         from  pon_backing_requisitions
9622        where  auction_header_id = x_negotiation_id
9623          and  line_number = x_negotiation_line_num;
9624 
9625       -- remove negotiation references in po_requisition_lines
9626       -- and return the requisitions to the req pool
9627       PO_NEGOTIATIONS_SV1.DELETE_NEGOTIATION_REF(
9628   X_NEGOTIATION_ID  =>  x_negotiation_id,
9629   X_NEGOTIATION_LINE_NUM  =>  x_negotiation_line_num,
9630   X_ERROR_CODE    =>  x_error_code);
9631 
9632 END DELETE_NEGOTIATION_LINE_REF;
9633 
9634 /*======================================================================
9635  PROCEDURE :  DELETE_NEGOTIATION_REF    PUBLIC
9636  PARAMETERS:
9637   x_negotiation_id        in      auction header id
9638   x_error_code            out     internal code for error
9639 
9640  COMMENT   : delete negotiation references
9641 ======================================================================*/
9642 PROCEDURE DELETE_NEGOTIATION_REF (
9643    x_negotiation_id in  number,
9644    x_error_code     out NOCOPY varchar2) is
9645 
9646 BEGIN
9647 
9648       PO_NEGOTIATIONS_SV1.DELETE_NEGOTIATION_REF(
9649   X_NEGOTIATION_ID  =>  x_negotiation_id,
9650   X_NEGOTIATION_LINE_NUM  =>  null,
9651   X_ERROR_CODE    =>  x_error_code);
9652 
9653 END DELETE_NEGOTIATION_REF;
9654 
9655 /*======================================================================
9656  PROCEDURE :  CANCEL_NEGOTIATION_REF   PUBLIC
9657  PARAMETERS:
9658   x_negotiation_id        in      auction header id
9659   x_error_code            out     internal code for error
9660 
9661  COMMENT   : cancel negotiation references
9662 ======================================================================*/
9663 PROCEDURE CANCEL_NEGOTIATION_REF (
9664    x_negotiation_id in  number,
9665    x_error_code     out NOCOPY varchar2) is
9666 
9667 BEGIN
9668 
9669       -- return backing requisitions to the req pool
9670       PO_NEGOTIATIONS_SV1.UPDATE_REQ_POOL(
9671   X_NEGOTIATION_ID  =>  x_negotiation_id,
9672   X_NEGOTIATION_LINE_NUM  =>  null,
9673   X_FLAG_VALUE    =>  'Y',
9674   X_ERROR_CODE    =>  x_error_code);
9675 
9676 END CANCEL_NEGOTIATION_REF;
9677 
9678 /*======================================================================
9679  PROCEDURE :  UPDATE_NEGOTIATION_REF   PUBLIC
9680  PARAMETERS:
9681   x_old_negotiation_id   in   old auction header id
9682   x_old_negotiation_num  in   old auction display number
9683   x_new_negotiation_id   in   new auction header id
9684   x_new_negotiation_num  in   new auction display number
9685   x_error_code           out  internal code for error
9686   x_error_message        out  error message
9687 
9688  COMMENT   : update negotiation references
9689 ======================================================================*/
9690 PROCEDURE UPDATE_NEGOTIATION_REF(
9691     x_old_negotiation_id   in   number,
9692     x_old_negotiation_num  in   varchar2,
9693     x_new_negotiation_id   in   number,
9694     x_new_negotiation_num  in   varchar2,
9695     x_error_code           out  NOCOPY varchar2,
9696     x_error_message        out  NOCOPY varchar2  ) is
9697 
9698 l_line_number number;
9699 l_amendment_flag pon_auction_headers_all.amendment_flag%TYPE;
9700 l_auction_header_id pon_auction_headers_all.auction_header_id%TYPE;
9701 l_requisition_line_id po_requisition_lines_all.requisition_line_id%TYPE;
9702 
9703 CURSOR deletedItems IS
9704      SELECT LINE_NUMBER
9705       FROM  PON_AUCTION_ITEM_PRICES_ALL
9706      WHERE  auction_header_id = x_old_negotiation_id and
9707             line_number not in ( select line_number
9708                                    from PON_AUCTION_ITEM_PRICES_ALL
9709                                   where auction_header_id = x_new_negotiation_id);
9710 
9711 BEGIN
9712 
9713       PO_NEGOTIATIONS_SV1.UPDATE_NEGOTIATION_REF(
9714   X_OLD_NEGOTIATION_ID  =>  x_old_negotiation_id,
9715   X_NEW_NEGOTIATION_ID  =>  x_new_negotiation_id,
9716   X_NEW_NEGOTIATION_NUM  =>  x_new_negotiation_num,
9717   X_ERROR_CODE    =>  x_error_code);
9718 
9719  /* bug#10295849: Added the code to update the negotiation references of amended requistions which are added to a solicitation amendment */
9720 -----------------------------------------------------------------------------------------------------------------------------------------------
9721 	  IF ( PON_CLM_UTIL_PKG.IS_NEG_DOCUMENT_FEDERAL(x_new_negotiation_id) = 1 ) THEN
9722 	      BEGIN
9723 	        SELECT amendment_flag, auction_header_id INTO l_amendment_flag,l_auction_header_id FROM pon_auction_headers_all WHERE amendment_flag = 'Y' AND auction_header_id_prev_amend = x_old_negotiation_id;
9724 	          EXCEPTION
9725 	            WHEN OTHERS THEN
9726 	              l_amendment_flag:= NULL;
9727 	      END;
9728 
9729 	    IF(l_amendment_flag='Y') THEN
9730 	      PO_NEGOTIATIONS_SV1.UPDATE_NEGOTIATION_REF(
9731 	      X_OLD_NEGOTIATION_ID  =>  l_auction_header_id,
9732 	      X_NEW_NEGOTIATION_ID  =>  x_new_negotiation_id,
9733 	      X_NEW_NEGOTIATION_NUM  =>  x_new_negotiation_num,
9734 	      X_ERROR_CODE    =>  x_error_code);
9735 
9736 	    END IF;
9737 	 END IF;
9738 -----------------------------------------------------------------------------------------------------------------------------------------------
9739       -- the above routine does't use FND constants,
9740       -- while UPDATE_NEGOTIATION_LINE_REF does, so convert it.
9741       IF (x_error_code = 'SUCCESS') THEN
9742    x_error_code := FND_API.G_RET_STS_SUCCESS;
9743       END IF;
9744 
9745       -- changes for FPI. For items that are carried over from previous round
9746       -- update the corresponding backing requisition references (no change
9747       -- from FPH).
9748       -- For items that are deleted between rounds, do nothing (ie, keep
9749       -- the references, references are cleared in FPH).
9750       -- We can either update only the carried over items or update all items
9751       -- and change deleted items back.
9752       -- Use the second approach here based on the assumption that a small
9753       -- number of items are deleted between rounds.
9754 
9755       -- some items may be deleted between rounds. Remove corresponding references
9756       -- and return requisition back to pool (FPH)
9757       OPEN deletedItems;
9758       LOOP
9759         FETCH deletedItems INTO
9760           l_line_number;
9761         EXIT WHEN deletedItems%NOTFOUND OR (x_error_code <> FND_API.G_RET_STS_SUCCESS);
9762 
9763       --  PO_NEGOTIATIONS_SV1.DELETE_NEGOTIATION_REF(x_new_negotiation_id, l_line_number, x_error_code);
9764 
9765         PO_NEGOTIATIONS_SV1.UPDATE_NEGOTIATION_LINE_REF(
9766     P_API_VERSION      =>  1.0,
9767     P_OLD_NEGOTIATION_ID    =>  x_new_negotiation_id,
9768     P_OLD_NEGOTIATION_LINE_NUM  =>  l_line_number,
9769     P_NEW_NEGOTIATION_ID    =>  x_old_negotiation_id,
9770     P_NEW_NEGOTIATION_LINE_NUM  =>  l_line_number,
9771     P_NEW_NEGOTIATION_NUM    =>  x_old_negotiation_num,
9772     X_RETURN_STATUS      =>  x_error_code,
9773     X_ERROR_MESSAGE      =>  x_error_message);
9774       END LOOP;
9775       CLOSE deletedItems;
9776       -- FPI: bug 2811671 still need to return the req back to pool
9777      /* IF (x_error_code = FND_API.G_RET_STS_SUCCESS) THEN
9778         PO_NEGOTIATIONS_SV1.UPDATE_REQ_POOL(
9779     X_NEGOTIATION_ID    =>  x_old_negotiation_id,
9780     X_NEGOTIATION_LINE_NUM     =>  null,
9781     X_FLAG_VALUE      =>  'Y',
9782     X_ERROR_CODE      =>  x_error_code);
9783       END IF;  */
9784 
9785 
9786       -- convert fnd constant to our own internal code
9787       IF (x_error_code = FND_API.G_RET_STS_SUCCESS) THEN
9788    x_error_code := 'SUCCESS';
9789       END IF;
9790 
9791 
9792 
9793      IF (x_error_code = 'SUCCESS') THEN
9794 
9795   /* bug#10295849: Added the code to check whether slin's are not returned to pool if the Clin is not returned */
9796        IF ( PON_CLM_UTIL_PKG.IS_NEG_DOCUMENT_FEDERAL(x_new_negotiation_id) = 1 ) THEN
9797         FOR rec IN deletedItems LOOP
9798         BEGIN
9799         /* check whether the delted line is Clin or Slin/Option */
9800 
9801           SELECT Nvl((SELECT REQUISITION_LINE_ID  FROM po_requisition_lines_all
9802           WHERE auction_header_id =  x_old_negotiation_id
9803           AND  auction_line_number = rec.line_number
9804           AND group_line_id IS NULL
9805           AND clm_base_line_num IS NULL),-1) INTO l_requisition_line_id FROM dual ;
9806 
9807 
9808 	  /* if Line is Clin then make complete structure to return the pool */
9809 
9810 	  IF(l_requisition_line_id <> -1)THEN
9811 		  UPDATE po_requisition_lines_all prla
9812 		  SET reqs_in_pool_flag = 'Y',
9813 		  at_sourcing_flag = NULL,
9814 		  auction_header_id  = null,
9815 		  auction_display_number = null,
9816 		  auction_line_number = NULL,
9817 		  last_update_date       = SYSDATE,
9818 		  last_updated_by        = FND_GLOBAL.USER_ID,
9819 		  last_update_login      = FND_GLOBAL.LOGIN_ID
9820 		  WHERE (REQUISITION_LINE_ID = l_requisition_line_id
9821 			  OR group_line_id=l_requisition_line_id
9822 			  OR clm_base_line_num=l_requisition_line_id)
9823 			  and nvl(modified_by_agent_flag,'N') <> 'Y'
9824 					    and NVL(cancel_flag,'N') NOT IN ('Y', 'I')
9825 					    and NVL(closed_code,'OPEN') <> 'FINALLY CLOSED'
9826 					    and source_type_code <> 'INVENTORY'
9827 					    and NVL(line_location_id, -999) = -999
9828 					    and not exists
9829 					    (select 'Req Header auth_status is not approved or contractor_status is pending'
9830 						  from po_requisition_headers_all prha
9831 						  where prha.requisition_header_id = prla.requisition_header_id
9832 						  and (NVL(prha.authorization_status,'INCOMPLETE') <> 'APPROVED'
9833 						  or NVL(prha.contractor_status,'NOT_APPLICABLE') = 'PENDING'));
9834                END IF;
9835         EXCEPTION
9836           WHEN OTHERS THEN
9837 		l_requisition_line_id:=NULL;
9838 
9839         END;
9840          x_error_code:=FND_API.G_RET_STS_SUCCESS;
9841 
9842         END LOOP;
9843 
9844         ELSE
9845          /* Non CLM things */
9846          PO_NEGOTIATIONS_SV1.UPDATE_REQ_POOL(
9847           X_NEGOTIATION_ID    =>  x_old_negotiation_id,
9848           X_NEGOTIATION_LINE_NUM     =>  null,
9849           X_FLAG_VALUE      =>  'Y',
9850           X_ERROR_CODE      =>  x_error_code);
9851 
9852 
9853 
9854        /* bug#10295849: Added the code to delete the negotiation references in po_requisition_lines_all table, if the requisition lines are deleted in the solicitation */
9855         IF (x_error_code = FND_API.G_RET_STS_SUCCESS) THEN
9856 		update po_requisition_lines_all
9857         set   auction_header_id  = null,
9858               auction_display_number = null,
9859               auction_line_number = null
9860         where auction_header_id =  x_old_negotiation_id;
9861 		END IF;
9862      END IF;
9863      END IF;
9864     -- convert fnd constant to our own internal code
9865       IF (x_error_code = FND_API.G_RET_STS_SUCCESS) THEN
9866    x_error_code := 'SUCCESS';
9867       END IF;
9868 
9869 
9870 END UPDATE_NEGOTIATION_REF;
9871 
9872 /*======================================================================
9873  PROCEDURE :  COPY_BACKING_REQ  PUBLIC
9874  PARAMETERS:
9875   x_old_negotiation_id   in   old auction header id
9876   x_new_negotiation_id   in   new auction header id
9877   x_error_code           out  internal code for error
9878 
9879  COMMENT   : update negotiation references
9880 ======================================================================*/
9881 PROCEDURE COPY_BACKING_REQ(x_old_negotiation_id in  number,
9882                            x_new_negotiation_id in  number,
9883                            x_error_code         out NOCOPY varchar2) is
9884 
9885 neg_item_count    NUMBER;
9886 l_count           NUMBER;
9887 
9888 l_line_number     NUMBER;
9889 l_req_header_id   NUMBER;
9890 l_req_line_id     NUMBER;
9891 l_req_quantity    NUMBER;
9892 l_req_number      pon_backing_requisitions.requisition_number%TYPE;
9893 
9894 CURSOR backingReqs IS
9895      SELECT LINE_NUMBER,
9896             REQUISITION_HEADER_ID,
9897             REQUISITION_LINE_ID,
9898             REQUISITION_QUANTITY,
9899             REQUISITION_NUMBER
9900       FROM  PON_BACKING_REQUISITIONS
9901      WHERE  auction_header_id = x_old_negotiation_id;
9902 
9903 BEGIN
9904    IF(x_new_negotiation_id IS NOT NULL) THEN
9905      OPEN backingReqs;
9906      LOOP
9907        FETCH backingReqs INTO
9908          l_line_number,
9909          l_req_header_id,
9910          l_req_line_id,
9911          l_req_quantity,
9912          l_req_number;
9913        EXIT WHEN backingReqs%NOTFOUND;
9914 
9915        SELECT count(*)
9916          INTO l_count
9917          FROM PON_BACKING_REQUISITIONS
9918         WHERE auction_header_id = x_new_negotiation_id and
9919               line_number = l_line_number and
9920               requisition_header_id = l_req_header_id and
9921               requisition_line_id = l_req_line_id;
9922 
9923        -- check if the item is still in the next round negotiation
9924        SELECT count(*)
9925    INTO neg_item_count
9926          FROM PON_AUCTION_ITEM_PRICES_ALL
9927         WHERE auction_header_id = x_new_negotiation_id and
9928               line_number = l_line_number;
9929 
9930        IF ((l_count = 0) AND (neg_item_count) = 1) THEN
9931           INSERT INTO PON_BACKING_REQUISITIONS(
9932             AUCTION_HEADER_ID,
9933             LINE_NUMBER,
9934             REQUISITION_HEADER_ID,
9935             REQUISITION_LINE_ID,
9936             REQUISITION_QUANTITY,
9937             REQUISITION_NUMBER)
9938           VALUES (
9939             x_new_negotiation_id,
9940             l_line_number,
9941             l_req_header_id,
9942             l_req_line_id,
9943             l_req_quantity,
9944             l_req_number);
9945        END IF;
9946      END LOOP;
9947   END IF;
9948 
9949   x_error_code := 'SUCCESS';
9950 
9951 EXCEPTION
9952 WHEN OTHERS THEN
9953     x_error_code := 'FAILURE';
9954 
9955 END COPY_BACKING_REQ;
9956 
9957 
9958 /*======================================================================
9959  PROCEDURE :  CANCEL_NEGOTIATION_REF_BY_LINE   PUBLIC
9960  PARAMETERS:
9961   x_negotiation_id        in      auction header id
9962   x_negotiation_line_id   in      line number
9963   x_error_code            out     internal code for error
9964 
9965  COMMENT   : cancel negotiation references
9966 ======================================================================*/
9967 PROCEDURE CANCEL_NEGOTIATION_REF_BY_LINE (
9968    x_negotiation_id in  number,
9969    x_negotiation_line_id number,
9970    x_error_code     out NOCOPY varchar2) is
9971 
9972 BEGIN
9973 
9974       -- return backing requisitions to the req pool
9975       PO_NEGOTIATIONS_SV1.UPDATE_REQ_POOL(
9976     X_NEGOTIATION_ID  =>  x_negotiation_id,
9977     X_NEGOTIATION_LINE_NUM   =>  x_negotiation_line_id,
9978     X_FLAG_VALUE    =>  'Y',
9979     X_ERROR_CODE    =>  x_error_code);
9980 
9981 END CANCEL_NEGOTIATION_REF_BY_LINE;
9982 
9983 
9984 --Added X_bid_number for bug 12344470 fix
9985 PROCEDURE Check_Unique_Wrapper(X_Segment1 In VARCHAR2,
9986                                X_rowid IN VARCHAR2,
9987                                X_Type_lookup_code IN VARCHAR2,
9988 							   X_bid_number IN NUMBER,
9989                                X_Unique OUT NOCOPY VARCHAR2) is
9990 BEGIN
9991   IF (PO_HEADERS_PKG_S2.Check_Unique(X_Segment1, X_rowid, X_Type_lookup_code, X_bid_number)) THEN
9992     X_Unique := 'T';
9993     RETURN;
9994   ELSE
9995     X_Unique := 'F';
9996     RETURN;
9997   END IF;
9998 EXCEPTION
9999   WHEN NO_DATA_FOUND THEN
10000     X_Unique := 'F';
10001     RETURN;
10002   WHEN OTHERS THEN
10003     raise;
10004 END Check_Unique_Wrapper;
10005 
10006 --Added p_bid_number for bug 12344470 fix
10007 FUNCTION CHECK_UNIQUE_ORDER_NUMBER (p_auction_id IN NUMBER,
10008                                 p_order_number IN VARCHAR2,
10009 								p_bid_number IN NUMBER)
10010 RETURN VARCHAR2 IS
10011   v_contract_type pon_auction_headers_all.contract_type%TYPE;
10012   v_org_id pon_auction_headers_all.org_id%TYPE;
10013   v_old_org_id NUMBER;
10014   v_old_policy VARCHAR2(1);
10015   v_is_unique VARCHAR2(1);
10016 
10017 BEGIN
10018    -- Get the current policy
10019    v_old_policy := mo_global.get_access_mode();
10020    v_old_org_id := mo_global.get_current_org_id();
10021 
10022    if (fnd_log.level_statement >= fnd_log.g_current_runtime_level) then
10023      fnd_log.string(
10024         fnd_log.level_statement,
10025         g_module || '.check_unique_order_number',
10026         'old_policy = ' || v_old_policy || ', old_org_id = ' || v_old_org_id);
10027    end if;
10028 
10029    -- Get the org id for the negotiation
10030    SELECT org_id, contract_type
10031    INTO   v_org_id, v_contract_type
10032    FROM   pon_auction_headers_all
10033    WHERE  auction_header_id = p_auction_id;
10034 
10035    -- Set the connection's policy context
10036    mo_global.set_policy_context('S', v_org_id);
10037 
10038    PON_AUCTION_PKG.Check_Unique_Wrapper(p_order_number, null,
10039                                         v_contract_type, p_bid_number, v_is_unique);
10040 
10041    -- Set the org context back
10042    mo_global.set_policy_context(v_old_policy, v_old_org_id);
10043 
10044    return v_is_unique;
10045 EXCEPTION
10046   WHEN NO_DATA_FOUND THEN
10047      return 'E';
10048         WHEN OTHERS THEN
10049            RETURN 'E';
10050 
10051 END CHECK_UNIQUE_ORDER_NUMBER;
10052 
10053 
10054 /* This procedure helps to send the response back to workflow for
10055    Acknowledgments.
10056 */
10057 
10058 PROCEDURE ACK_NOTIF_RESPONSE(p_wf_item_key VARCHAR2,
10059                              p_user_name   VARCHAR2,
10060                              p_supp_ack    VARCHAR2,
10061                              p_ack_note    VARCHAR2,
10062                              x_return_status OUT NOCOPY NUMBER)
10063 
10064 is
10065 
10066 l_supp_ack varchar2(10);
10067 l_notification_id number;
10068 l_activity_status wf_item_activity_statuses.ACTIVITY_STATUS%type;
10069 
10070 begin
10071 
10072     BEGIN
10073 
10074    select   notification_id,   ACTIVITY_STATUS
10075       into   l_notification_id, l_activity_status
10076     from   wf_item_activity_statuses
10077     where   item_key  = p_wf_item_key
10078     and   item_type  = 'PONPBLSH'
10079     and   notification_id is not null
10080   and   activity_status = 'NOTIFIED'
10081     and   rownum    = 1;
10082 
10083    EXCEPTION
10084   WHEN NO_DATA_FOUND THEN
10085     -- Do we want to fail this procedure if we there's no such email sent?
10086     -- x_return_status   := 1;
10087     l_notification_id := -9999;
10088    END;
10089 
10090   IF p_supp_ack ='Y' then
10091      l_supp_ack :='A-YES';
10092   ELSIF p_supp_ack='N' THEN
10093      l_supp_ack :='B-NO';
10094   END IF;
10095 
10096   if (l_notification_id > 0) then
10097      Wf_Notification.SetAttrText(l_notification_id, 'RESULT', l_supp_ack);
10098      Wf_Notification.SetAttrText(l_notification_id, 'NOTE_TO_BUYER', p_ack_note);
10099      Wf_Notification.Respond(l_notification_id, 'On-Line', p_user_name);
10100   end if;
10101 
10102   x_return_status := 0;
10103 
10104  EXCEPTION
10105 
10106   WHEN OTHERS THEN
10107           x_return_status := 1;
10108 
10109 end ACK_NOTIF_RESPONSE;
10110 
10111 PROCEDURE ACK_NOTIF_RESPONSE(p_wf_item_key VARCHAR2,
10112                              p_user_name   VARCHAR2,
10113                              p_supp_ack    VARCHAR2,
10114                              p_ack_note    VARCHAR2)
10115 IS
10116 
10117   v_temp NUMBER;
10118 
10119 BEGIN
10120 
10121     ACK_NOTIF_RESPONSE(p_wf_item_key, p_user_name, p_supp_ack, p_ack_note, v_temp);
10122 
10123 END;
10124 
10125 /* Implemented as part of bug 2809753.  Move logic for
10126    NegotiationDoc.getTimeRemaining() to pl/sql procedure to bypass binding
10127    of timestamps on sql arithmetic operations, which causes problems on
10128    certain jdbc versions */
10129 
10130 PROCEDURE GET_TIME_REMAINING(p_auction_header_id IN NUMBER,
10131                              p_time_remaining OUT NOCOPY FLOAT) is
10132 begin
10133   select (sysdate - close_bidding_date) into p_time_remaining
10134   from pon_auction_headers_all
10135   where auction_header_id = p_auction_header_id;
10136 
10137 EXCEPTION
10138   WHEN OTHERS THEN
10139       RAISE;
10140 end GET_TIME_REMAINING;
10141 
10142 FUNCTION get_product_install_status ( x_product_name IN VARCHAR2) RETURN VARCHAR2 IS
10143   x_progress     VARCHAR2(3) := NULL;
10144   x_app_id       NUMBER;
10145   x_install      BOOLEAN;
10146   x_status       VARCHAR2(1);
10147   x_org          VARCHAR2(1);
10148   x_temp_product_name varchar2(10);
10149 begin
10150   --Retreive product id from fnd_application based on product name
10151   x_progress := 10;
10152 
10153   select application_id
10154   into   x_app_id
10155   from   fnd_application
10156   where application_short_name = x_product_name ;
10157 
10158   --get product installation status
10159   x_progress := 20;
10160   x_install := fnd_installation.get(x_app_id,x_app_id,x_status,x_org);
10161 
10162   if (x_install)
10163   THEN
10164     x_status := 'Y';
10165   ELSE
10166     x_status := 'N';
10167   end if;
10168 
10169   RETURN(x_status);
10170 
10171   EXCEPTION
10172     WHEN NO_DATA_FOUND then
10173       null;
10174       RETURN(null);
10175     WHEN OTHERS THEN
10176       RAISE;
10177 
10178 end get_product_install_status;
10179 
10180 
10181 
10182 function getPhoneNumber(p_user_name varchar2) return varchar2 is
10183 begin
10184 if g_userName is null or g_userName <> p_user_name then
10185 retrieve_user_info(p_user_name);
10186 end if;
10187 return g_phoneNumber;
10188 end getPhoneNumber;
10189 
10190 function getFaxNumber(p_user_name varchar2) return varchar2 is
10191 begin
10192 if g_userName is null or g_userName <> p_user_name then
10193 retrieve_user_info(p_user_name);
10194 end if;
10195 return g_faxNumber;
10196 end getFaxNumber;
10197 
10198 function getEMail(p_user_name varchar2) return varchar2 is
10199 begin
10200 if g_userName is null or g_userName <> p_user_name then
10201 retrieve_user_info(p_user_name);
10202 end if;
10203 return g_eMail;
10204 end getEMail;
10205 
10206 
10207 procedure getTriangulationRate(toCurrency varchar2,
10208                               fromCurrency varchar2,
10209                               rateDate date,
10210                               rateType varchar2,
10211                               rollDays number,
10212                               rate out nocopy number
10213                               ) is
10214 denom number;
10215 num number;
10216 
10217 begin
10218 GL_CURRENCY_API.get_closest_triangulation_Rate(toCurrency,fromCurrency,rateDate,null,rollDays,denom,num,rate);
10219 
10220 end getTriangulationRate;
10221 
10222 
10223 function getClosestRate(fromCurrency varchar2,
10224                         toCurrency varchar2,
10225                         conversionDate date,
10226                         conversionType varchar2,
10227                         maxRollDays number) return varchar2 is
10228   x_rate number;
10229 begin
10230   x_rate := GL_CURRENCY_API.get_closest_rate(fromCurrency, toCurrency, conversionDate, conversionType, maxRollDays);
10231   return x_rate;
10232 end getClosestRate;
10233 
10234 
10235 /*======================================================================
10236  PROCEDURE :  DELETE_NEGOTIATION_AMENDMENTS    PUBLIC
10237  PARAMETERS:
10238   x_negotiation_id        in      auction header id
10239   x_error_code            out     internal code for error
10240 
10241  COMMENT   : delete negotiation amendments created
10242 ======================================================================*/
10243 PROCEDURE DELETE_NEGOTIATION_AMENDMENTS (
10244     x_negotiation_id        in   number,
10245     x_error_code            out  NOCOPY varchar2) is
10246 
10247 BEGIN
10248 
10249     x_error_code := 'SUCCESS';
10250 
10251     BEGIN
10252 
10253   UPDATE PON_AUCTION_HEADERS_ALL
10254   SET AUCTION_STATUS = 'DELETED'
10255   WHERE
10256     AUCTION_HEADER_ID_ORIG_AMEND IS NOT NULL
10257   AND  AUCTION_HEADER_ID_ORIG_AMEND = x_negotiation_id;
10258 
10259   UPDATE PON_AUCTION_HEADERS_ALL
10260   SET AUCTION_STATUS = 'DELETED'
10261   WHERE
10262     AUCTION_HEADER_ID  = x_negotiation_id;
10263 
10264      EXCEPTION
10265 
10266   WHEN OTHERS THEN
10267     x_error_code := 'FAILURE';
10268      END;
10269 
10270 END DELETE_NEGOTIATION_AMENDMENTS;
10271 
10272 /*======================================================================
10273  *  PROCEDURE :  GET_MOST_RECENT_AMENDMENT    PUBLIC
10274  *   PARAMETERS:
10275  *     x_negotiation_id        in      auction header id
10276  *
10277  *        COMMENT   : returns the auction header id of the most recent active
10278  *        amendment
10279  *        ======================================================================*/
10280 FUNCTION GET_MOST_RECENT_AMENDMENT(p_auction_header_id IN NUMBER) RETURN NUMBER
10281 
10282 IS
10283 
10284     v_auction_status               VARCHAR2(25);
10285     v_auction_header_id_orig_amend NUMBER;
10286     v_most_recent_amendment        NUMBER;
10287 
10288 
10289 BEGIN
10290 
10291     select auction_status
10292     into   v_auction_status
10293     from   pon_auction_headers_all
10294     where  auction_header_id = p_auction_header_id;
10295 
10296     IF (v_auction_status = 'AMENDED') THEN
10297 
10298       select auction_header_id_orig_amend
10299       into   v_auction_header_id_orig_amend
10300       from   pon_auction_headers_all
10301       where  auction_header_id = p_auction_header_id;
10302 
10303       select auction_header_id
10304       into   v_most_recent_amendment
10305       from   pon_auction_headers_all
10306       where  auction_header_id_orig_amend = v_auction_header_id_orig_amend and
10307              auction_status <> 'AMENDED' and auction_status <> 'DRAFT' and
10308              rownum = 1;  -- rownum = 1 is a sanity check
10309 
10310     ELSE
10311 
10312       v_most_recent_amendment := p_auction_header_id;
10313 
10314     END IF;
10315 
10316    RETURN v_most_recent_amendment;
10317 
10318 END GET_MOST_RECENT_AMENDMENT;
10319 
10320 FUNCTION GET_MEMBER_TYPE(p_auction_header_id IN NUMBER,p_user_id IN NUMBER) RETURN VARCHAR2
10321 IS
10322     v_member_type               VARCHAR2(1);
10323 BEGIN
10324     v_member_type   := 'X';
10325     select nvl(member_type,'X')
10326                 into v_member_type
10327                 from pon_neg_team_members
10328     where auction_header_id =p_auction_header_id
10329     and user_id = p_user_id;
10330 
10331                 return v_member_type;
10332 END GET_MEMBER_TYPE;
10333 
10334 
10335 -- this procedure is added for header price break default
10336 -- The procedure determines the price_break_response for pon_auction_headers_all table.
10337 -- It's used in plsql routines where new negotiation created,
10338 -- including negotiation copy/new round/amendment, autocreation and renegotiation.
10339 -- The logic is same as AuctionHeadersAllEO
10340 
10341 PROCEDURE get_default_hdr_pb_settings (p_doctype_id IN NUMBER,
10342                                        p_tp_id IN NUMBER,
10343                                        x_price_break_response OUT NOCOPY VARCHAR2) IS
10344 
10345         l_pref_unused_1       VARCHAR2(300);
10346         l_pref_unused_2       VARCHAR2(300);
10347         l_pref_unused_3       VARCHAR2(300);
10348 
10349         l_price_break_display_flag PON_AUC_DOCTYPE_RULES.display_flag%type;
10350 
10351 BEGIN
10352 
10353         select display_flag
10354           into l_price_break_display_flag
10355           from PON_AUC_DOCTYPE_RULES dr,
10356                PON_AUC_BIZRULES b
10357          where b.bizrule_id = dr.bizrule_id
10358            and dr.doctype_id = p_doctype_id
10359            and b.name = 'PRICE_BREAK';
10360 
10361         if (l_price_break_display_flag = 'N') then
10362            x_price_break_response := 'NONE';
10363         else
10364 
10365            BEGIN
10366                 PON_PROFILE_UTIL_PKG.RETRIEVE_PARTY_PREF_COVER(
10367                                 p_party_id        => p_tp_id,
10368                                 p_app_short_name  => 'PON',
10369                                 p_pref_name       => 'PRICE_BREAK_RESPONSE_TYPE',
10370                                 x_pref_value      => x_price_break_response,
10371                                 x_pref_meaning    => l_pref_unused_1,
10372                                 x_status          => l_pref_unused_2,
10373                                 x_exception_msg   => l_pref_unused_3);
10374 
10375                                 IF  (l_pref_unused_2 <> FND_API.G_RET_STS_SUCCESS) THEN
10376                                         x_price_break_response := 'NONE';
10377                                 END IF;
10378 
10379            EXCEPTION
10380                 WHEN OTHERS THEN
10381                         x_price_break_response := 'NONE';
10382            END;
10383 
10384         end if;
10385 
10386 END get_default_hdr_pb_settings;
10387 
10388 
10389 -- this procedure is added for header price break default
10390 -- The procedure determines the price_break_type and price_break_neg_flag
10391 -- for pon_auction_item_prices_all table.
10392 -- It assumes the auction header already exists.
10393 -- It's used in plsql routines where lines are inserted, including line spreadsheet upload,
10394 -- negotiation copy/new round/amendment, autocreation and renegotiation.
10395 
10396 PROCEDURE get_default_pb_settings (p_auction_header_id IN NUMBER,
10397                                    x_price_break_type OUT NOCOPY VARCHAR2,
10398                                    x_price_break_neg_flag OUT NOCOPY VARCHAR2) IS
10399 
10400 l_price_break_response                pon_auction_headers_all.price_break_response%type;
10401 l_contract_type                       pon_auction_headers_all.contract_type%type;
10402 l_doctype_id                          pon_auction_headers_all.doctype_id%type;
10403 l_po_style_id                         pon_auction_headers_all.po_style_id%type;
10404 l_template_id                         pon_auction_headers_all.template_id%type;
10405 l_template_pb_type                    pon_auction_item_prices_all.price_break_type%type;
10406 l_org_id                              pon_auction_headers_all.org_id%type;
10407 l_po_pb_type                          po_system_parameters_all.price_break_lookup_code%type;
10408 l_price_break_display_flag            PON_AUC_DOCTYPE_RULES.display_flag%type;
10409 l_price_break_enabled_flag            VARCHAR2(1);
10410 l_price_break_allowed                 VARCHAR2(1);
10411 l_price_tiers_indicator               pon_auction_headers_all.price_tiers_indicator%type;
10412 
10413 l_dummy1     VARCHAR2(240);
10414 l_dummy2     VARCHAR2(240);
10415 l_dummy3     VARCHAR2(30);
10416 l_dummy4     VARCHAR2(30);
10417 l_dummy5     VARCHAR2(1);
10418 l_dummy6     VARCHAR2(1);
10419 l_dummy7     VARCHAR2(1);
10420 l_dummy8     VARCHAR2(1);
10421 l_dummy9     VARCHAR2(1);
10422 l_dummy10    VARCHAR2(30);
10423 
10424 BEGIN
10425 
10426       select contract_type, doctype_id, price_break_response, po_style_id, template_id, org_id, price_tiers_indicator
10427         into l_contract_type, l_doctype_id, l_price_break_response, l_po_style_id, l_template_id, l_org_id, l_price_tiers_indicator
10428         from pon_auction_headers_all
10429        where auction_header_id = p_auction_header_id;
10430 
10431       select display_flag
10432         into l_price_break_display_flag
10433         from PON_AUC_DOCTYPE_RULES dr,
10434              PON_AUC_BIZRULES b
10435        where b.bizrule_id = dr.bizrule_id
10436          and dr.doctype_id = l_doctype_id
10437          and b.name = 'PRICE_BREAK';
10438 
10439 
10440       -- invoke po api to get price break setting for the po style
10441       BEGIN
10442                 PO_DOC_STYLE_GRP.GET_DOCUMENT_STYLE_SETTINGS(
10443                                                    P_API_VERSION => '1.0',
10444                                                    P_STYLE_ID    => l_po_style_id,
10445                                                    X_STYLE_NAME  => l_dummy1,
10446                                                    X_STYLE_DESCRIPTION => l_dummy2,
10447                                                    X_STYLE_TYPE  => l_dummy3,
10448                                                    X_STATUS => l_dummy4,
10449                                                    X_ADVANCES_FLAG => l_dummy5,
10450                                                    X_RETAINAGE_FLAG => l_dummy6,
10451                                                    X_PRICE_BREAKS_FLAG => l_price_break_enabled_flag,
10452                                                    X_PRICE_DIFFERENTIALS_FLAG => l_dummy7,
10453                                                    X_PROGRESS_PAYMENT_FLAG=> l_dummy8,
10454                                                    X_CONTRACT_FINANCING_FLAG=> l_dummy9,
10455                                                    X_LINE_TYPE_ALLOWED  => l_dummy10);
10456 
10457       EXCEPTION
10458                 WHEN OTHERS THEN
10459                     l_price_break_enabled_flag := 'Y';
10460       END;
10461 
10462 
10463       -- if price break doesn't apply, set to NONE
10464       -- check if price break is allowed
10465       if ( l_price_break_display_flag = 'Y' and
10466            (l_contract_type = 'BLANKET' or l_contract_type = 'CONTRACT') and
10467            l_price_break_enabled_flag = 'Y') then
10468 
10469             l_price_break_allowed := 'Y';
10470       else
10471             l_price_break_allowed := 'N';
10472             l_price_break_response := 'NONE';
10473       end if;
10474 
10475 
10476       if (l_price_break_allowed = 'N' or l_price_break_response = 'NONE' or l_price_tiers_indicator = 'QUANTITY_BASED' ) then
10477            -- not allowed by biz rule or header setting is NONE
10478            x_price_break_type := 'NONE';
10479       else
10480            x_price_break_type := 'NON-CUMULATIVE';
10481 
10482            -- if negotiation has template, use template setting if template is CUMULATIVE or NON CUMULATIVE
10483            if (l_template_id is not null) then
10484 
10485                    BEGIN
10486                        select price_break_type
10487                          into l_template_pb_type
10488                          from pon_auction_item_prices_all
10489                         where auction_header_id = l_template_id;
10490                    EXCEPTION
10491                          WHEN OTHERS THEN
10492                              l_template_pb_type := 'NONE';
10493                    END;
10494 
10495                    if (l_template_pb_type <> 'NONE') then
10496                         x_price_break_type := l_template_pb_type;
10497                    end if;
10498            else
10499            -- get the setting from po price break setting for the specified org
10500                    BEGIN
10501                         select decode(price_break_lookup_code, 'NON CUMULATIVE',
10502                                       'NON-CUMULATIVE', price_break_lookup_code)
10503                           into l_po_pb_type
10504                           from po_system_parameters_all
10505                          where org_id = l_org_id;
10506                    EXCEPTION
10507                          WHEN OTHERS THEN
10508                              l_po_pb_type := 'NON-CUMULATIVE';
10509                    END;
10510 
10511                    x_price_break_type := l_po_pb_type;
10512            end if;
10513       end if;
10514 
10515 
10516       if (l_price_break_response = 'REQUIRED') then
10517          x_price_break_neg_flag := 'N';
10518       else
10519          x_price_break_neg_flag := 'Y';
10520       end if;
10521 
10522 END get_default_pb_settings;
10523 
10524 
10525 -- Used in Complex work
10526 --returns whether Projects is installed for current org or not
10527 FUNCTION getPAOUInstalled (p_orgId IN NUMBER) RETURN VARCHAR2 IS
10528     l_progress     VARCHAR2(3) := NULL;
10529     l_app_id       NUMBER;
10530     l_install      BOOLEAN;
10531     l_status       VARCHAR2(1);
10532   begin
10533     l_progress := 10;
10534     --get Projects  installation status
10535     return  PA_UTILS4.IsProjectsImplemented(p_orgId);
10536 
10537 EXCEPTION
10538       WHEN OTHERS THEN
10539         RAISE;
10540 
10541 end getPAOUInstalled;
10542 
10543 -- Used in Complex work
10544 --returns whether Grants is installed for current org or not
10545 FUNCTION getGMSOUInstalled ( p_orgId IN NUMBER) RETURN VARCHAR2 IS
10546     l_progress     VARCHAR2(3) := NULL;
10547     l_app_id       NUMBER;
10548     l_install      BOOLEAN;
10549     l_status       VARCHAR2(1);
10550   begin
10551     l_progress := 10;
10552     --get Grants  installation status
10553       l_install := GMS_INSTALL.ENABLED(p_orgId);
10554 
10555          l_progress := 20;
10556     if (l_install)
10557     THEN
10558       l_status := 'Y';
10559     ELSE
10560       l_status := 'N';
10561     end if;
10562 
10563     RETURN(l_status);
10564 
10565 EXCEPTION
10566       WHEN OTHERS THEN
10567         RAISE;
10568 
10569 end getGMSOUInstalled;
10570 
10571 --------------------------------------------------------------------------------
10572 --                      IS_NEGOTIATION_REQ_BACKED                         --
10573 --------------------------------------------------------------------------------
10574 -- Start of Comments
10575 --
10576 -- API Name: IS_NEGOTIATION_REQ_BACKED
10577 --
10578 -- Type    : Private
10579 --
10580 -- Pre-reqs: None
10581 --
10582 -- Function: This API is called by the Negotiation Import Spreadsheet code.
10583 --           It determines if all the lines in the spreadsheet have a
10584 --           backing requisition or not.  If all the lines have a backing
10585 --           requisition, then project related attributes will not be downloaded
10586 --           into the spreasheet
10587 --
10588 -- Parameters:
10589 --
10590 --              p_auction_header_id       IN      NUMBER
10591 --                   Auction header id - required
10592 --
10593 --              x_req_backed OUT      VARCHAR2
10594 --                   Returns Y if all the lines that are eligible to have
10595 --                   payitems have a backing Requisition
10596 --
10597 -- End of Comments
10598 --------------------------------------------------------------------------------
10599 
10600 PROCEDURE  IS_NEGOTIATION_REQ_BACKED(
10601              p_auction_header_id       IN        NUMBER,
10602              x_req_backed              OUT NOCOPY VARCHAR2) IS
10603 BEGIN
10604   x_req_backed := 'Y';
10605 
10606     SELECT 'N'
10607       INTO x_req_backed
10608       FROM dual
10609      WHERE EXISTS (SELECT 1
10610        FROM pon_auction_item_prices_all al
10611       WHERE al.auction_header_id = p_auction_header_id
10612             AND al.group_type NOT IN ('GROUP','LOT_LINE')
10613             AND nvl(al.line_origination_code,'-9998') <> 'REQUISITION');
10614 EXCEPTION
10615   WHEN NO_DATA_FOUND
10616    THEN
10617      x_req_backed := 'N';
10618   WHEN OTHERS THEN
10619        RAISE;
10620 END IS_NEGOTIATION_REQ_BACKED;
10621 
10622 /*=========================================================================+
10623 -- 12.0 Enhancement
10624 -- New procedure to send Notification to the given Collaboration
10625 -- Team Member as requested by Negotiation Creator.
10626 -- Parameter :
10627 --
10628 --           p_auction_header_id IN NUMBER,
10629 --           p_user_id           IN NUMBER, This will be user id
10630 --                                          of Notification Recipient,
10631 --                                          i.e. Team Member.
10632 --           x_return_status     OUT NOCOPY VARCHAR2,
10633 --                                          flag to indicate if the copy procedure
10634 --                                          was successful or not; It can have
10635 --                                          following values -
10636 --                                              FND_API.G_RET_STS_SUCCESS (Success)
10637 --                                              FND_API.G_RET_STS_ERROR  (Success with warning)
10638 --                                              FND_API.G_RET_STS_UNEXP_ERROR (Failed due to error)
10639 --
10640 +=========================================================================*/
10641 
10642 
10643 PROCEDURE SEND_TASK_ASSIGN_NOTIF (p_auction_header_id IN     NUMBER,
10644                                   p_user_id           IN     NUMBER,
10645                                   x_return_status     OUT NOCOPY VARCHAR2)
10646 IS
10647     l_module_name constant VARCHAR2(40) := 'SEND_TASK_ASSIGN_NOTIF';
10648     l_progress                  VARCHAR2(3);
10649     l_language_code             VARCHAR2(20);
10650     l_lang_code                 VARCHAR2(4);
10651     l_doc_number                PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
10652     l_auction_start_date        DATE;
10653     l_auction_end_date          DATE;
10654     l_preview_date              DATE;
10655     l_msg_suffix                PON_AUC_DOCTYPES.MESSAGE_SUFFIX%TYPE;
10656     l_auction_title             PON_AUCTION_HEADERS_ALL.AUCTION_TITLE%TYPE;
10657     l_preparer_tp_name          HZ_PARTIES.PARTY_NAME%TYPE;
10658     l_task_name                 PON_NEG_TEAM_MEMBERS.TASK_NAME%TYPE;
10659     l_task_target_date          DATE;
10660     l_task_assignment_date      DATE;
10661     l_task_assigned_subject     VARCHAR2(2000);
10662     l_timezone_disp             VARCHAR2(240);
10663     l_auctioneer_user_name      VARCHAR2(244);
10664     l_user_name       VARCHAR2(244);
10665     l_person_party_id           NUMBER;
10666     l_sequence                  NUMBER;
10667     x_itemtype                  VARCHAR2(7);
10668     x_itemkey                  VARCHAR2(50);
10669     l_open_auction_now_flag VARCHAR2(1);
10670     l_publish_auction_now_flag VARCHAR2(1);
10671 
10672  BEGIN
10673       BEGIN
10674 
10675          l_progress := '000';
10676          x_return_status := FND_API.G_RET_STS_SUCCESS;
10677              IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
10678                           FND_LOG.string (log_level => FND_LOG.level_procedure,
10679                                        module => g_module || l_module_name,
10680                                        message  => 'Entering to Procedure ' || g_module || l_module_name
10681                                        || ', l_progress = ' || l_progress
10682                                        || ', p_auction_header_id = ' || p_auction_header_id
10683                                        || ', p_user_id = ' || p_user_id);
10684              END IF;
10685 
10686 
10687            l_language_code := fnd_profile.value_specific('ICX_LANGUAGE', p_user_id, NULL, NULL);
10688 
10689            l_progress := '010';
10690 
10691            SELECT LANGUAGE_CODE
10692            INTO l_lang_code
10693            FROM FND_LANGUAGES
10694            WHERE NLS_LANGUAGE = l_language_code;
10695 
10696            l_progress := '020';
10697 
10698            select auh.DOCUMENT_NUMBER,
10699                   auh.OPEN_BIDDING_DATE,
10700                   auh.CLOSE_BIDDING_DATE,
10701                   auh.VIEW_BY_DATE,
10702                   pad.MESSAGE_SUFFIX,
10703                   auh.AUCTION_TITLE,
10704                   hz.PARTY_NAME PREPARER_TP_NAME,
10705                   pntm.TASK_NAME,
10706                   pntm.TARGET_DATE TASK_TARGET_DATE,
10707                   pntm.LAST_NOTIFIED_DATE TASK_ASSIGNMENT_DATE,
10708                   auh.TRADING_PARTNER_CONTACT_NAME,
10709                   fu.person_party_id,
10710                   fu.user_name,
10711                   auh.open_auction_now_flag,
10712                   auh.publish_auction_now_flag
10713 
10714             into  l_doc_number,
10715                   l_auction_start_date,
10716                   l_auction_end_date,
10717                   l_preview_date,
10718                   l_msg_suffix,
10719                   l_auction_title,
10720                   l_preparer_tp_name,
10721                   l_task_name,
10722                   l_task_target_date,
10723                   l_task_assignment_date,
10724                   l_auctioneer_user_name,
10725                   l_person_party_id,
10726                   l_user_name,
10727                   l_open_auction_now_flag,
10728                   l_publish_auction_now_flag
10729 
10730            from pon_auction_headers_all auh,
10731                   hz_parties hz,
10732                   pon_neg_team_members pntm,
10733                   fnd_user fu,
10734                   pon_auc_doctypes pad
10735            where auh.auction_header_id = p_auction_header_id
10736                   AND hz.party_id = auh.trading_partner_id
10737                   AND pntm.auction_header_id = auh.auction_header_id
10738                   AND pntm.user_id = p_user_id
10739                   AND fu.user_id = pntm.user_id
10740                   AND pad.doctype_id = auh.doctype_id;
10741 
10742               l_progress := '030';
10743 
10744               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
10745                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
10746                                         module => g_module || l_module_name,
10747                                         message  => 'After query execution : ' || g_module || l_module_name
10748                                         || ', l_progress = ' || l_progress
10749                                         || ', l_doc_number          = ' || l_doc_number
10750                                         || ', l_language_code = ' || l_language_code
10751                                         || ', l_lang_code = ' || l_lang_code
10752                                         || ', l_auction_start_date      = ' || l_auction_start_date
10753                                         || ', l_auction_end_date        = ' || l_auction_end_date
10754                                         || ', l_preview_date            = ' || l_preview_date
10755                                         || ', l_msg_suffix          = ' || l_msg_suffix
10756                                         || ', l_auction_title           = ' || l_auction_title
10757                                         || ', l_preparer_tp_name        = ' || l_preparer_tp_name
10758                                         || ', l_task_name           = ' || l_task_name
10759                                         || ', l_task_target_date        = ' || l_task_target_date
10760                                         || ', l_task_assignment_date        = ' || l_task_assignment_date
10761                                         || ', l_auctioneer_user_name        = ' || l_auctioneer_user_name
10762                                         || ', l_user_name         = ' || l_user_name
10763                                         || ', l_open_auction_now_flag         = ' || l_open_auction_now_flag
10764                                         || ', l_publish_auction_now_flag         = ' || l_publish_auction_now_flag
10765                                         || ', l_person_party_id     = ' || l_person_party_id);
10766 
10767               END IF;
10768 
10769           -- Get the recipient user's language preference
10770           -- And set the session language so messages are
10771           -- retrieved in that language.
10772           IF p_user_id IS NOT NULL THEN
10773             PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE (p_user_id, l_lang_code);
10774 
10775             IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
10776             FND_LOG.string(log_level => FND_LOG.level_statement,
10777               module => g_module_prefix || 'SEND_TASK_ASSIGN_NOTIF',
10778               message  => '9. Calling SET_SESSION_LANGUAGE with l_lang_code : ' || l_lang_code);
10779             END IF; --}
10780 
10781             SET_SESSION_LANGUAGE (null, l_lang_code);
10782           END IF;
10783 
10784           --Subject should be retrieved from seed message
10785 
10786           PON_OEX_TIMEZONE_PKG.CONVERT_DATE_TO_USER_TZ(p_person_party_id => l_person_party_id,
10787                                                        p_auctioneer_user_name => l_auctioneer_user_name,
10788                                                        x_date_value1  => l_auction_start_date,
10789                                                        x_date_value2  => l_auction_end_date,
10790                                                        x_date_value3  => l_preview_date,
10791                                                        x_date_value4  => l_task_target_date,
10792                                                        x_date_value5  => l_task_assignment_date,
10793                                                        x_timezone_disp =>l_timezone_disp);
10794 
10795           l_progress := '040';
10796 
10797           l_task_assigned_subject :=  PON_AUCTION_PKG.getMessage( msg => 'PON_AUC_TASK_ASN_NOTIF_SUB',
10798                                                                  msg_suffix => '_'|| l_msg_suffix,
10799                                                                  token1 => 'DOC_NUMBER',
10800                                                                  token1_value => l_doc_number,
10801                                                                  token2 => 'AUCTION_TITLE',
10802                                                                  token2_value => replaceHtmlChars(l_auction_title));
10803           l_progress := '050';
10804 
10805 
10806               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
10807                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
10808                                         module => g_module || l_module_name,
10809                                         message  => 'After getting new time and subject : ' || g_module || l_module_name
10810                                         || ', l_progress = ' || l_progress
10811                                         || ', l_auction_start_date      = ' || l_auction_start_date
10812                                         || ', l_auction_end_date        = ' || l_auction_end_date
10813                                         || ', l_preview_date            = ' || l_preview_date
10814                                         || ', l_timezone_disp = ' || l_timezone_disp
10815                                         || ', l_task_assigned_subject = ' || l_task_assigned_subject);
10816               END IF;
10817 
10818           x_itemtype := 'PONAUCT';
10819 
10820           SELECT pon_auction_wf_publish_s.nextval
10821           INTO   l_sequence
10822           FROM   dual;
10823 
10824           x_itemkey := p_auction_header_id||'-'|| l_sequence;
10825 
10826           wf_engine.CreateProcess(itemtype => x_itemtype,
10827                                   itemkey  => x_itemkey,
10828                                   process  => 'TEAM_MEM_TASK_ASSIGNED');
10829           l_progress := '060';
10830 
10831               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
10832                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
10833                                         module => g_module || l_module_name,
10834                                         message  => 'After CreateProcess ' || g_module || l_module_name
10835                                         || ', l_progress = ' || l_progress
10836                                         || ', x_itemtype = ' || x_itemtype
10837                                         || ', x_itemkey = ' || x_itemkey);
10838               END IF;
10839 
10840 
10841               SET_PREVIEW_DATE(
10842                         p_itemtype => x_itemtype,
10843                         p_itemkey   => x_itemkey,
10844                         p_preview_date  => l_preview_date,
10845                         p_publish_auction_now_flag => l_publish_auction_now_flag,
10846                         p_timezone_disp  => l_timezone_disp,
10847                         p_msg_suffix => l_msg_suffix);
10848 
10849               SET_OPEN_DATE(
10850                         p_itemtype      => x_itemtype,
10851                         p_itemkey      => x_itemkey,
10852                         p_auction_start_date  => l_auction_start_date,
10853                         p_open_auction_now_flag => l_open_auction_now_flag,
10854                         p_timezone_disp  => l_timezone_disp,
10855                         p_msg_suffix => l_msg_suffix);
10856 
10857               SET_CLOSE_DATE(
10858                         p_itemtype  =>x_itemtype,
10859                         p_itemkey    =>x_itemkey,
10860                         p_auction_end_date  => l_auction_end_date,
10861                         p_timezone_disp  => l_timezone_disp);
10862 
10863              l_progress := '090';
10864 
10865              wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10866                                        itemkey    => x_itemkey,
10867                                        aname      => 'DOC_NUMBER',
10868                                        avalue     => l_doc_number);
10869 
10870             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10871                                        itemkey    => x_itemkey,
10872                                        aname      => 'AUCTION_TITLE',
10873                                        avalue     => l_auction_title);
10874 
10875             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10876                                        itemkey    => x_itemkey,
10877                                        aname      => 'PREPARER_TP_CONTACT_NAME',
10878                                        avalue     => l_auctioneer_user_name);
10879 
10880             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10881                                        itemkey    => x_itemkey,
10882                                        aname      => 'ORIGIN_USER_NAME',
10883                                        avalue     => fnd_global.user_name);
10884 
10885              wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10886                                         itemkey    => x_itemkey,
10887                                         aname      => 'RECIPIENT_ROLE',
10888                                         avalue     => l_user_name);
10889 
10890             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10891                                        itemkey    => x_itemkey,
10892                                        aname      => 'PREPARER_TP_NAME',
10893                                        avalue     => l_preparer_tp_name);
10894 
10895             wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
10896                                        itemkey    => x_itemkey,
10897                                        aname      => 'TASK_TARGET_DATE',
10898                                        avalue     => l_task_target_date);
10899 
10900             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10901                                        itemkey    => x_itemkey,
10902                                        aname      => 'TASK_NAME',
10903                                        avalue     => l_task_name);
10904 
10905             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10906                                        itemkey    => x_itemkey,
10907                                        aname      => 'TASK_ASSIGNED_SUBJECT',
10908                                        avalue     => l_task_assigned_subject);
10909 
10910             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
10911                                        itemkey    => x_itemkey,
10912                                        aname      => 'AUCTION_ID',
10913                                        avalue     => p_auction_header_id);
10914 
10915             l_progress := '100';
10916 
10917     -- Bug 4295915: Set the  workflow owner
10918             wf_engine.SetItemOwner(itemtype => x_itemtype,
10919                                    itemkey  => x_itemkey,
10920                                    owner    => fnd_global.user_name);
10921 
10922             wf_engine.StartProcess(itemtype => x_itemtype,
10923                                    itemkey  => x_itemkey );
10924 
10925 
10926             l_progress := 'END';
10927 
10928             IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
10929                          FND_LOG.string (log_level => FND_LOG.level_procedure,
10930                                       module => g_module || l_module_name,
10931                                        message  => 'Procedure Ends ' || g_module || l_module_name
10932                                       || ', l_progress = ' || l_progress);
10933             END IF;
10934 
10935             UNSET_SESSION_LANGUAGE;
10936 
10937         EXCEPTION WHEN OTHERS THEN
10938             IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
10939                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
10940                                         module => g_module || l_module_name,
10941                                         message  => 'In Exception Block : ' || g_module || l_module_name
10942                                         || ', l_progress = ' || l_progress
10943                                         || ', p_auction_header_id = ' || p_auction_header_id
10944                                         || ', p_user_id = ' || p_user_id);
10945             END IF;
10946             UNSET_SESSION_LANGUAGE;
10947             x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10948         END;
10949 
10950 END SEND_TASK_ASSIGN_NOTIF;
10951 
10952 /*===========================================================================================+
10953 --
10954 -- 12.0 Enhancement
10955 -- SEND_TASK_COMPL_NOTIF procedure will be responsible
10956 -- for sending notification from the Buyer user to the
10957 -- Negotiation Creator when the former completes a given
10958 -- task for a Collaboration Team Member.
10959 -- Parameter :
10960 --             p_auction_header_id IN NUMBER,
10961 --             p_user_id           IN NUMBER, This will be user id
10962 --                                            Notification sender,
10963 --                                            i.e.Team Member.
10964 --             x_return_status     OUT NOCOPY VARCHAR2,
10965 --                                          flag to indicate if the copy procedure
10966 --                                          was successful or not; It can have
10967 --                                          following values -
10968 --                                              FND_API.G_RET_STS_SUCCESS (Success)
10969 --                                              FND_API.G_RET_STS_ERROR  (Success with warning)
10970 --                                              FND_API.G_RET_STS_UNEXP_ERROR (Failed due to error)
10971 --
10972 +===========================================================================================*/
10973 
10974 PROCEDURE SEND_TASK_COMPL_NOTIF ( p_auction_header_id IN NUMBER,
10975                                   p_user_id           IN NUMBER,
10976                                   x_return_status     OUT NOCOPY VARCHAR2)
10977 IS
10978     l_module_name constant VARCHAR2(40) := 'SEND_TASK_COMPL_NOTIF';
10979     l_progress                  VARCHAR2(3);
10980     l_language_code             VARCHAR2(20);
10981     l_lang_code                 VARCHAR2(4);
10982     l_doc_number                PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
10983     l_auction_start_date        DATE;
10984     l_auction_end_date          DATE;
10985     l_preview_date              DATE;
10986     l_msg_suffix                PON_AUC_DOCTYPES.MESSAGE_SUFFIX%TYPE;
10987     l_auction_title             PON_AUCTION_HEADERS_ALL.AUCTION_TITLE%TYPE;
10988     l_preparer_tp_name          HZ_PARTIES.PARTY_NAME%TYPE;
10989     l_task_name                 PON_NEG_TEAM_MEMBERS.TASK_NAME%TYPE;
10990     l_task_target_date          DATE;
10991     l_task_completion_date      DATE;
10992     l_task_completed_subject     VARCHAR2(2000);
10993     l_timezone_disp             VARCHAR2(240);
10994     l_auctioneer_user_name      VARCHAR2(244);
10995     l_user_name                 VARCHAR2(244);
10996     l_tp_contact_id             NUMBER;
10997     l_tp_contact_usr_id         NUMBER;
10998     l_trading_partner_id        NUMBER;
10999     l_sequence                  NUMBER;
11000     x_itemtype                  VARCHAR2(7);
11001     x_itemkey                  VARCHAR2(50);
11002     l_open_auction_now_flag VARCHAR2(1);
11003     l_publish_auction_now_flag   VARCHAR2(1);
11004     l_doctype_group_name varchar2(100);
11005 
11006 
11007  BEGIN
11008       BEGIN
11009 
11010          l_progress := '000';
11011          x_return_status := FND_API.G_RET_STS_SUCCESS;
11012 
11013              IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11014                           FND_LOG.string (log_level => FND_LOG.level_procedure,
11015                                        module => g_module || l_module_name,
11016                                        message  => 'Entering to Procedure ' || g_module || l_module_name
11017                                        || ', l_progress = ' || l_progress
11018                                        || ', p_auction_header_id = ' || p_auction_header_id
11019                                        || ', p_user_id = ' || p_user_id);
11020              END IF;
11021 
11022              BEGIN
11023                    select auh.DOCUMENT_NUMBER,
11024                           auh.OPEN_BIDDING_DATE,
11025                           auh.CLOSE_BIDDING_DATE,
11026                           auh.VIEW_BY_DATE,
11027                           pad.MESSAGE_SUFFIX,
11028                           auh.AUCTION_TITLE,
11029                           auh.TRADING_PARTNER_CONTACT_NAME,
11030                           auh.TRADING_PARTNER_CONTACT_ID,
11031                           auh.TRADING_PARTNER_ID,
11032                           fu.user_id,
11033                           auh.open_auction_now_flag,
11034                           auh.publish_auction_now_flag
11035                     into  l_doc_number,
11036                           l_auction_start_date,
11037                           l_auction_end_date,
11038                           l_preview_date,
11039                           l_msg_suffix,
11040                           l_auction_title,
11041                           l_auctioneer_user_name,
11042                           l_tp_contact_id,
11043                           l_trading_partner_id,
11044                           l_tp_contact_usr_id,
11045                           l_open_auction_now_flag,
11046                           l_publish_auction_now_flag
11047                    from pon_auction_headers_all auh,
11048                           pon_auc_doctypes pad,
11049                           fnd_user fu
11050                    where auh.auction_header_id = p_auction_header_id
11051                           AND pad.doctype_id = auh.doctype_id
11052                           AND fu.person_party_id = auh.TRADING_PARTNER_CONTACT_ID
11053                           AND nvl(fu.end_date,sysdate+1) > sysdate;
11054 
11055            EXCEPTION
11056                    WHEN TOO_MANY_ROWS THEN
11057                      if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
11058                            if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
11059                                          fnd_log.string(log_level => fnd_log.level_unexpected,
11060                                                         module    => 'pon.plsql.pon_auction_pkg.send_task_compl_notif',
11061                                                         message   => 'Multiple Users found for auction_header_id:'|| p_auction_header_id);
11062                            end if;
11063                      end if;
11064 
11065                     select auh.DOCUMENT_NUMBER,
11066                           auh.OPEN_BIDDING_DATE,
11067                           auh.CLOSE_BIDDING_DATE,
11068                           auh.VIEW_BY_DATE,
11069                           pad.MESSAGE_SUFFIX,
11070                           auh.AUCTION_TITLE,
11071                           auh.TRADING_PARTNER_CONTACT_NAME,
11072                           auh.TRADING_PARTNER_CONTACT_ID,
11073                           auh.TRADING_PARTNER_ID,
11074                           fu.user_id,
11075                           auh.open_auction_now_flag,
11076                           auh.publish_auction_now_flag
11077                      into  l_doc_number,
11078                           l_auction_start_date,
11079                           l_auction_end_date,
11080                           l_preview_date,
11081                           l_msg_suffix,
11082                           l_auction_title,
11083                           l_auctioneer_user_name,
11084                           l_tp_contact_id,
11085                           l_trading_partner_id,
11086                           l_tp_contact_usr_id,
11087                           l_open_auction_now_flag,
11088                           l_publish_auction_now_flag
11089                     from pon_auction_headers_all auh,
11090                           pon_auc_doctypes pad,
11091                           fnd_user fu
11092                     where auh.auction_header_id = p_auction_header_id
11093                           AND pad.doctype_id = auh.doctype_id
11094                           AND fu.person_party_id = auh.TRADING_PARTNER_CONTACT_ID
11095                           AND nvl(fu.end_date,sysdate+1) > sysdate
11096                           AND rownum=1;
11097            END;
11098 
11099            l_progress := '005';
11100 
11101            IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11102                                    FND_LOG.string (log_level => FND_LOG.level_procedure,
11103                                      module => g_module || l_module_name,
11104                                      message  => 'Entering to Procedure ' || g_module || l_module_name
11105                                      || ', l_progress = ' || l_progress
11106                                      || ', l_doc_number           = ' || l_doc_number
11107                                      || ', l_auction_start_date       = ' || l_auction_start_date
11108                                      || ', l_auction_end_date     = ' || l_auction_end_date
11109                                      || ', l_preview_date         = ' || l_preview_date
11110                                      || ', l_msg_suffix           = ' || l_msg_suffix
11111                                      || ', l_auction_title            = ' || l_auction_title
11112                                      || ', l_auctioneer_user_name     = ' || l_auctioneer_user_name
11113                                      || ', l_user_name     = ' || l_user_name
11114                                      || ', l_tp_contact_id        = ' || l_tp_contact_id
11115                                      || ', l_tp_contact_usr_id = ' || l_tp_contact_usr_id
11116                                      || ', l_trading_partner_id       = ' || l_trading_partner_id
11117                                      || ', l_open_auction_now_flag  = ' || l_open_auction_now_flag
11118                                      || ', l_publish_auction_now_flag = ' || l_publish_auction_now_flag
11119                                      );
11120            END IF;
11121 
11122            l_language_code := fnd_profile.value_specific('ICX_LANGUAGE', l_tp_contact_usr_id, NULL, NULL);
11123 
11124            l_progress := '010';
11125 
11126            SELECT LANGUAGE_CODE
11127            INTO l_lang_code
11128            FROM FND_LANGUAGES
11129            WHERE NLS_LANGUAGE = l_language_code;
11130 
11131            l_progress := '020';
11132 
11133            select hz.PARTY_NAME PREPARER_TP_NAME,
11134                   pntm.TASK_NAME,
11135                   pntm.TARGET_DATE TASK_TARGET_DATE,
11136                   pntm.COMPLETION_DATE TASK_COMPLETION_DATE,
11137                   fu.user_name
11138             into  l_preparer_tp_name,
11139                   l_task_name,
11140                   l_task_target_date,
11141                   l_task_completion_date,
11142                   l_user_name
11143            from hz_parties hz,
11144                   pon_neg_team_members pntm,
11145                   fnd_user fu
11146            where pntm.auction_header_id = p_auction_header_id
11147                   AND hz.party_id = l_trading_partner_id
11148                   AND pntm.user_id = p_user_id
11149                   AND fu.user_id = pntm.user_id;
11150 
11151 
11152               l_progress := '030';
11153 
11154               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11155                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11156                                         module => g_module || l_module_name,
11157                                         message  => 'After query execution : ' || g_module || l_module_name
11158                                         || ', l_progress = ' || l_progress
11159                                         || ', l_language_code = ' || l_language_code
11160                                         || ', l_lang_code = ' || l_lang_code
11161                                         || ', l_preparer_tp_name        = ' || l_preparer_tp_name
11162                                         || ', l_task_name           = ' || l_task_name
11163                                         || ', l_task_target_date        = ' || l_task_target_date
11164                                         || ', l_task_completion_date = ' || l_task_completion_date);
11165               END IF;
11166 
11167           -- Get the recipient user's language preference
11168           -- And set the session language so messages are
11169           -- retrieved in that language.
11170           IF l_tp_contact_usr_id IS NOT NULL THEN
11171             PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE (l_tp_contact_usr_id, l_lang_code);
11172 
11173             IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
11174             FND_LOG.string(log_level => FND_LOG.level_statement,
11175               module => g_module_prefix || 'SEND_TASK_COMPL_NOTIF',
11176               message  => '10. Calling SET_SESSION_LANGUAGE with l_lang_code : ' || l_lang_code);
11177             END IF; --}
11178 
11179             SET_SESSION_LANGUAGE (null, l_lang_code);
11180           END IF;
11181 
11182 
11183           --Subject should be retrieved from seed message
11184 
11185           PON_OEX_TIMEZONE_PKG.CONVERT_DATE_TO_USER_TZ(p_person_party_id => l_tp_contact_id,
11186                                                        p_auctioneer_user_name => l_auctioneer_user_name,
11187                                                        x_date_value1  => l_auction_start_date,
11188                                                        x_date_value2  => l_auction_end_date,
11189                                                        x_date_value3  => l_preview_date,
11190                                                        x_date_value4  => l_task_target_date,
11191                                                        x_date_value5  => l_task_completion_date,
11192                                                        x_timezone_disp =>l_timezone_disp);
11193 
11194           l_progress := '040';
11195 
11196           l_task_completed_subject :=  PON_AUCTION_PKG.getMessage( msg => 'PON_AUC_TASK_COMPL_NOTIF_SUB',
11197                                                                  msg_suffix => '_'|| l_msg_suffix,
11198                                                                  token1 => 'DOC_NUMBER',
11199                                                                  token1_value => l_doc_number,
11200                                                                  token2 => 'AUCTION_TITLE',
11201                                                                  token2_value => replaceHtmlChars(l_auction_title));
11202 
11203           l_progress := '050';
11204 
11205 
11206               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11207                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11208                                         module => g_module || l_module_name,
11209                                         message  => 'After getting new time and subject : ' || g_module || l_module_name
11210                                         || ', l_progress = ' || l_progress
11211                                         || ', l_auction_start_date      = ' || l_auction_start_date
11212                                         || ', l_auction_end_date        = ' || l_auction_end_date
11213                                         || ', l_preview_date            = ' || l_preview_date
11214                                         || ', l_task_target_date = ' || l_task_target_date
11215                                         || ', l_task_completion_date = ' || l_task_completion_date
11216                                         || ', l_timezone_disp = ' || l_timezone_disp
11217                                         || ', l_task_completed_subject = ' || l_task_completed_subject);
11218               END IF;
11219 
11220           x_itemtype := 'PONAUCT';
11221 
11222           SELECT pon_auction_wf_publish_s.nextval
11223           INTO   l_sequence
11224           FROM   dual;
11225 
11226           x_itemkey := p_auction_header_id||'-'|| l_sequence;
11227 
11228           wf_engine.CreateProcess(itemtype => x_itemtype,
11229                                   itemkey  => x_itemkey,
11230                                   process  => 'TEAM_MEM_TASK_COMPLTD');
11231           l_progress := '060';
11232 
11233               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11234                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11235                                         module => g_module || l_module_name,
11236                                         message  => 'After CreateProcess ' || g_module || l_module_name
11237                                         || ', l_progress = ' || l_progress
11238                                         || ', x_itemtype = ' || x_itemtype
11239                                         || ', x_itemkey = ' || x_itemkey);
11240               END IF;
11241 
11242                 SET_PREVIEW_DATE(
11243                           p_itemtype => x_itemtype,
11244                           p_itemkey   => x_itemkey,
11245                           p_preview_date  => l_preview_date,
11246                           p_publish_auction_now_flag => l_publish_auction_now_flag,
11247                           p_timezone_disp  => l_timezone_disp,
11248                           p_msg_suffix => l_msg_suffix);
11249 
11250                 SET_OPEN_DATE(
11251                           p_itemtype      => x_itemtype,
11252                           p_itemkey      => x_itemkey,
11253                           p_auction_start_date  => l_auction_start_date,
11254                           p_open_auction_now_flag => l_open_auction_now_flag,
11255                           p_timezone_disp  => l_timezone_disp,
11256                           p_msg_suffix => l_msg_suffix);
11257 
11258                 SET_CLOSE_DATE(
11259                           p_itemtype  =>x_itemtype,
11260                           p_itemkey    =>x_itemkey,
11261                           p_auction_end_date  => l_auction_end_date,
11262                           p_timezone_disp  => l_timezone_disp);
11263 
11264             l_progress := '091';
11265 
11266             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11267                                        itemkey    => x_itemkey,
11268                                        aname      => 'DOC_NUMBER',
11269                                        avalue     => l_doc_number);
11270 
11271             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11272                                        itemkey    => x_itemkey,
11273                                        aname      => 'AUCTION_TITLE',
11274                                        avalue     => l_auction_title);
11275 
11276             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11277                                        itemkey    => x_itemkey,
11278                                        aname      => 'PREPARER_TP_CONTACT_NAME',
11279                                        avalue     => l_auctioneer_user_name);
11280 
11281              wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11282                                         itemkey    => x_itemkey,
11283                                         aname      => 'RECIPIENT_ROLE',
11284                                         avalue     => l_user_name);
11285 
11286             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11287                                        itemkey    => x_itemkey,
11288                                        aname      => 'PREPARER_TP_NAME',
11289                                        avalue     => l_preparer_tp_name);
11290 
11291             wf_engine.SetItemAttrDate (itemtype   => x_itemtype,
11292                                        itemkey    => x_itemkey,
11293                                        aname      => 'TASK_TARGET_DATE',
11294                                        avalue     => l_task_target_date);
11295 
11296             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11297                                        itemkey    => x_itemkey,
11298                                        aname      => 'TASK_NAME',
11299                                        avalue     => l_task_name);
11300 
11301             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11302                                        itemkey    => x_itemkey,
11303                                        aname      => 'TASK_COMPLETED_SUBJECT',
11304                                        avalue     => l_task_completed_subject);
11305 
11306             wf_engine.SetItemAttrText (itemtype   => x_itemtype,
11307                                        itemkey    => x_itemkey,
11308                                        aname      => 'AUCTION_ID',
11309                                        avalue     => p_auction_header_id);
11310 
11311     -- Bug 4295915: Set the  workflow owner
11312             wf_engine.SetItemOwner(itemtype => x_itemtype,
11313                                    itemkey  => x_itemkey,
11314                                    owner    => fnd_global.user_name);
11315 
11316             l_progress := '100';
11317 
11318             wf_engine.StartProcess(itemtype => x_itemtype,
11319                                    itemkey  => x_itemkey );
11320 
11321 
11322             l_progress := 'END';
11323 
11324             IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11325                          FND_LOG.string (log_level => FND_LOG.level_procedure,
11326                                       module => g_module || l_module_name,
11327                                        message  => 'Procedure Ends ' || g_module || l_module_name
11328                                       || ', l_progress = ' || l_progress);
11329             END IF;
11330 
11331             UNSET_SESSION_LANGUAGE;
11332 
11333         EXCEPTION WHEN OTHERS THEN
11334             IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11335                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11336                                         module => g_module || l_module_name,
11337                                         message  => 'In Exception Block : ' || g_module || l_module_name
11338                                         || ', l_progress = ' || l_progress
11339                                         || ', p_auction_header_id = ' || p_auction_header_id
11340                                         || ', p_user_id = ' || p_user_id);
11341             END IF;
11342             UNSET_SESSION_LANGUAGE;
11343             x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11344         END;
11345 
11346 END SEND_TASK_COMPL_NOTIF;
11347 
11348 
11349 /*=========================================================================+
11350 -- 12.0 Enhancement
11351 -- SEND_RESP_NOTIF procedure will be responsible for
11352 -- sending notification to the Buyer when a Seller
11353 -- submits a Response.
11354 -- Parameter :
11355 --            p_bid_number               IN NUMBER,
11356 --            x_return_status            OUT NOCOPY VARCHAR2
11357 --
11358 +=========================================================================*/
11359 
11360 PROCEDURE SEND_RESP_NOTIF ( p_bid_number               IN NUMBER,
11361                            x_return_status             OUT NOCOPY VARCHAR2)
11362 IS
11363     l_module_name constant VARCHAR2(40) := 'SEND_RESP_NOTIF';
11364     l_msg_suffix                PON_AUC_DOCTYPES.MESSAGE_SUFFIX%TYPE;
11365     l_progress                  VARCHAR2(3);
11366     l_lang_code                 VARCHAR2(4);
11367     l_itemtype                  VARCHAR2(7);
11368     l_language_code             VARCHAR2(20);
11369     l_itemkey                  VARCHAR2(50);
11370     l_auctioneer_user_name      VARCHAR2(244);
11371     l_bidder_user_name          VARCHAR2(244);
11372 
11373     l_doc_number                PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
11374     l_auction_header_id         PON_AUCTION_HEADERS_ALL.AUCTION_HEADER_ID%TYPE;
11375     l_auction_title             PON_AUCTION_HEADERS_ALL.AUCTION_TITLE%TYPE;
11376     l_tp_contact_id             PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_CONTACT_ID%TYPE;
11377     l_trading_partner_id        PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_ID%TYPE;
11378     l_preparer_tp_name          PON_AUCTION_HEADERS_ALL.TRADING_PARTNER_NAME%TYPE;
11379     l_response_number           PON_BID_HEADERS.BID_NUMBER%TYPE;
11380     l_bidder_tpc_id             PON_BID_HEADERS.TRADING_PARTNER_CONTACT_ID%TYPE;
11381     l_bidder_tp_name            HZ_PARTIES.PARTY_NAME%TYPE;
11382     l_tp_contact_usr_id         FND_USER.USER_ID%TYPE;
11383     l_timezone_disp             VARCHAR2(240);
11384     l_bid_contact_dp_name       VARCHAR2(350);
11385     l_bidder_dp_name            VARCHAR2(350);
11386     l_response_type_name        VARCHAR2(2000);
11387     l_supplier_site_name        VARCHAR2(2000);
11388     l_response_url              VARCHAR2(2000);
11389     l_resp_publish_sub          VARCHAR2(2000);
11390     l_preview_date              DATE;
11391     l_auction_start_date        DATE;
11392     l_auction_end_date          DATE;
11393     l_bid_publish_date          DATE;
11394     l_null_date                 DATE;
11395 
11396  BEGIN
11397       BEGIN
11398 
11399          l_progress := '000';
11400          x_return_status := FND_API.G_RET_STS_SUCCESS;
11401          l_null_date := null;
11402 
11403              IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11404                           FND_LOG.string (log_level => FND_LOG.level_procedure,
11405                                        module => g_module || l_module_name,
11406                                        message  => 'Entering to Procedure ' || g_module || l_module_name
11407                                        || ', l_progress = ' || l_progress
11408                                        || ', p_bid_number = ' || p_bid_number);
11409              END IF;
11410 
11411          BEGIN
11412            select auh.DOCUMENT_NUMBER,
11413                   auh.OPEN_BIDDING_DATE,
11414                   auh.CLOSE_BIDDING_DATE,
11415                   auh.VIEW_BY_DATE,
11416                   pad.MESSAGE_SUFFIX,
11417                   auh.AUCTION_TITLE,
11418                   auh.TRADING_PARTNER_CONTACT_NAME,
11419                   auh.TRADING_PARTNER_NAME PREPARER_TP_NAME,
11420                   auh.TRADING_PARTNER_CONTACT_ID,
11421                   auh.TRADING_PARTNER_ID,
11422                   fu.user_name,
11423                   decode(pbh.VENDOR_SITE_CODE, null, '', pbh.VENDOR_SITE_CODE) SUPPLIER_SITE_NAME,
11424                   pbh.TRADING_PARTNER_NAME BIDDER_TP_NAME,
11425                   pbh.PUBLISH_DATE BID_PUBLISH_DATE,
11426                   pbh.TRADING_PARTNER_CONTACT_ID BIDDER_TPC_ID,
11427                   auh.AUCTION_HEADER_ID
11428            into  l_doc_number,
11429                   l_auction_start_date,
11430                   l_auction_end_date,
11431                   l_preview_date,
11432                   l_msg_suffix,
11433                   l_auction_title,
11434                   l_auctioneer_user_name,
11435                   l_preparer_tp_name,
11436                   l_tp_contact_id,
11437                   l_trading_partner_id,
11438                   l_bidder_user_name,
11439                   l_supplier_site_name,
11440                   l_bidder_tp_name,
11441                   l_bid_publish_date,
11442                   l_bidder_tpc_id,
11443                   l_auction_header_id
11444            from pon_auction_headers_all auh,
11445                   pon_auc_doctypes pad,
11446                   pon_bid_headers pbh,
11447                   fnd_user fu
11448            where pbh.bid_number = p_bid_number
11449                   AND pad.doctype_id = auh.doctype_id
11450                   AND auh.auction_header_id = pbh.auction_header_id
11451                   AND fu.person_party_id = pbh.trading_partner_contact_id
11452                   AND nvl(fu.end_date, sysdate+1) > sysdate;
11453          EXCEPTION
11454              WHEN TOO_MANY_ROWS THEN
11455                   if (nvl(fnd_profile.value('AFLOG_ENABLED'),'N') = 'Y') then
11456                        if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
11457                                  fnd_log.string(log_level => fnd_log.level_unexpected,
11458                                                 module    => 'pon.plsql.pon_auction_pkg.send_resp_notif',
11459                                                 message   => 'Multiple Users found for bid number:'|| p_bid_number);
11460                        end if;
11461                  end if;
11462 
11463            select auh.DOCUMENT_NUMBER,
11464                   auh.OPEN_BIDDING_DATE,
11465                   auh.CLOSE_BIDDING_DATE,
11466                   auh.VIEW_BY_DATE,
11467                   pad.MESSAGE_SUFFIX,
11468                   auh.AUCTION_TITLE,
11469                   auh.TRADING_PARTNER_CONTACT_NAME,
11470                   auh.TRADING_PARTNER_NAME PREPARER_TP_NAME,
11471                   auh.TRADING_PARTNER_CONTACT_ID,
11472                   auh.TRADING_PARTNER_ID,
11473                   fu.user_name,
11474                   decode(pbh.VENDOR_SITE_CODE, null, '', pbh.VENDOR_SITE_CODE) SUPPLIER_SITE_NAME,
11475                   pbh.TRADING_PARTNER_NAME BIDDER_TP_NAME,
11476                   pbh.PUBLISH_DATE BID_PUBLISH_DATE,
11477                   pbh.TRADING_PARTNER_CONTACT_ID BIDDER_TPC_ID,
11478                   auh.AUCTION_HEADER_ID
11479            into  l_doc_number,
11480                   l_auction_start_date,
11481                   l_auction_end_date,
11482                   l_preview_date,
11483                   l_msg_suffix,
11484                   l_auction_title,
11485                   l_auctioneer_user_name,
11486                   l_preparer_tp_name,
11487                   l_tp_contact_id,
11488                   l_trading_partner_id,
11489                   l_bidder_user_name,
11490                   l_supplier_site_name,
11491                   l_bidder_tp_name,
11492                   l_bid_publish_date,
11493                   l_bidder_tpc_id,
11494                   l_auction_header_id
11495            from pon_auction_headers_all auh,
11496                   pon_auc_doctypes pad,
11497                   pon_bid_headers pbh,
11498                   fnd_user fu
11499            where pbh.bid_number = p_bid_number
11500                   AND pad.doctype_id = auh.doctype_id
11501                   AND auh.auction_header_id = pbh.auction_header_id
11502                   AND fu.person_party_id = pbh.trading_partner_contact_id
11503                   AND nvl(fu.end_date, sysdate+1) > sysdate
11504                   AND rownum = 1;
11505 
11506 
11507          END;
11508 
11509            l_progress := '010';
11510 
11511            IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11512                                FND_LOG.string (log_level => FND_LOG.level_procedure,
11513                                      module => g_module || l_module_name,
11514                                      message  => 'Entering to Procedure ' || g_module || l_module_name
11515                                      || ', l_progress = ' || l_progress
11516                                      || ', l_doc_number           = ' || l_doc_number
11517                                      || ', l_auction_start_date       = ' || l_auction_start_date
11518                                      || ', l_auction_end_date     = ' || l_auction_end_date
11519                                      || ', l_preview_date         = ' || l_preview_date
11520                                      || ', l_msg_suffix           = ' || l_msg_suffix
11521                                      || ', l_auction_title            = ' || l_auction_title
11522                                      || ', l_auctioneer_user_name     = ' || l_auctioneer_user_name
11523                                      || ', l_bidder_user_name = ' || l_bidder_user_name
11524                                      || ', l_tp_contact_id        = ' || l_tp_contact_id
11525                                      || ', l_trading_partner_id       = ' || l_trading_partner_id
11526                                      || ', l_supplier_site_name = ' || l_supplier_site_name
11527                                      || ', l_bidder_tp_name = ' || l_bidder_tp_name
11528                                      || ', l_bid_publish_date = ' || l_bid_publish_date
11529                                      || ', l_auction_header_id = ' || l_auction_header_id
11530                                      || ', l_bidder_tpc_id = ' || l_bidder_tpc_id);
11531            END IF;
11532 
11533            l_progress := '020';
11534 
11535      PON_PROFILE_UTIL_PKG.GET_WF_LANGUAGE(l_auctioneer_user_name,l_lang_code);
11536 
11537           IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
11538           FND_LOG.string(log_level => FND_LOG.level_statement,
11539             module => g_module_prefix ||l_module_name,
11540             message  => '11. Calling SET_SESSION_LANGUAGE with l_lang_code : ' || l_lang_code);
11541           END IF; --}
11542            SET_SESSION_LANGUAGE (null, l_lang_code);
11543 
11544            l_progress := '030';
11545 
11546               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11547                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11548                                         module => g_module || l_module_name,
11549                                         message  => 'After query execution : ' || g_module || l_module_name
11550                                         || ', l_progress = ' || l_progress
11551                                         || ', l_language_code = ' || l_language_code
11552                                         || ', l_lang_code = ' || l_lang_code);
11553               END IF;
11554 
11555           --Subject should be retrieved from seed message
11556 
11557           PON_OEX_TIMEZONE_PKG.CONVERT_DATE_TO_USER_TZ(p_person_party_id => l_tp_contact_id,
11558                                                        p_auctioneer_user_name => l_auctioneer_user_name,
11559                                                        x_date_value1  => l_auction_start_date,
11560                                                        x_date_value2  => l_auction_end_date,
11561                                                        x_date_value3  => l_preview_date,
11562                                                        x_date_value4  => l_bid_publish_date,
11563                                                        x_date_value5  => l_null_date,
11564                                                        x_timezone_disp =>l_timezone_disp);
11565 
11566           l_progress := '040';
11567 
11568           -- Submitted: <Quote> 4512 for <RFQ> 2759 (Equipment Renewal)
11569 
11570           l_resp_publish_sub :=  PON_AUCTION_PKG.getMessage( msg => 'PON_AUC_RESP_SUBM_NOTIF_SUB',
11571                                                                  msg_suffix => '_'||l_msg_suffix,
11572                                                                  token1 => 'RESPONSE_NUMBER',
11573                                                                  token1_value => p_bid_number,
11574                                                                  token2 => 'DOC_NUMBER',
11575                                                                  token2_value => l_doc_number,
11576                                                                  token3 => 'AUCTION_TITLE',
11577                                                                  token3_value => replaceHtmlChars(l_auction_title));
11578 
11579           l_progress := '050';
11580 
11581 
11582               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11583                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11584                                         module => g_module || l_module_name,
11585                                         message  => 'After getting new time and subject : ' || g_module || l_module_name
11586                                         || ', l_progress = ' || l_progress
11587                                         || ', l_auction_start_date      = ' || l_auction_start_date
11588                                         || ', l_auction_end_date        = ' || l_auction_end_date
11589                                         || ', l_preview_date            = ' || l_preview_date
11590                                         || ', l_bid_publish_date = ' ||l_bid_publish_date
11591                                         || ', l_timezone_disp = ' || l_timezone_disp
11592                                         || ', l_resp_publish_sub = ' || l_resp_publish_sub);
11593               END IF;
11594 
11595           l_itemtype := 'PONAUCT';
11596           l_itemkey := p_bid_number ||'-'|| l_bidder_tpc_id;
11597 
11598           l_response_url := pon_wf_utl_pkg.get_dest_page_url (p_dest_func => 'PONRESENQ_VIEWBID'
11599                                  ,p_notif_performer  => 'BUYER');
11600 
11601           l_response_type_name :=  PON_AUCTION_PKG.getMessage( msg => 'PON_AUCTS_BID',
11602                                                                  msg_suffix => '_'||l_msg_suffix);
11603 
11604           wf_engine.CreateProcess(itemtype => l_itemtype,
11605                                   itemkey  => l_itemkey,
11606                                   process  => 'RESPONSE_PUBLISH');
11607           l_progress := '060';
11608 
11609               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11610                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11611                                         module => g_module || l_module_name,
11612                                         message  => 'After CreateProcess ' || g_module || l_module_name
11613                                         || ', l_progress = ' || l_progress
11614                                         || ', l_itemtype = ' || l_itemtype
11615                                         || ', l_itemkey = ' || l_itemkey);
11616               END IF;
11617 
11618           IF (l_preview_date is not null) THEN
11619              l_progress := '070';
11620              wf_engine.SetItemAttrDate (itemtype  => l_itemtype,
11621                                 itemkey  => l_itemkey,
11622                                 aname  => 'PREVIEW_DATE',
11623                                 avalue  => l_preview_date);
11624 
11625              wf_engine.SetItemAttrText (itemtype  => l_itemtype,
11626                                 itemkey  => l_itemkey,
11627                                 aname  => 'TP_TIME_ZONE1',
11628                                 avalue  => l_timezone_disp);
11629 
11630              wf_engine.SetItemAttrText (itemtype  => l_itemtype,
11631                                itemkey  => l_itemkey,
11632                                aname  => 'PREVIEW_DATE_NOTSPECIFIED',
11633                                avalue  => null);
11634           ELSE
11635              l_progress := '080';
11636              wf_engine.SetItemAttrDate (itemtype  => l_itemtype,
11637                                 itemkey  => l_itemkey,
11638                                 aname  => 'PREVIEW_DATE',
11639                                 avalue  => null);
11640 
11641              wf_engine.SetItemAttrText (itemtype  => l_itemtype,
11642                                  itemkey  => l_itemkey,
11643                                 aname  => 'TP_TIME_ZONE1',
11644                                  avalue  => null);
11645 
11646             wf_engine.SetItemAttrText (itemtype  => l_itemtype,
11647                                itemkey  => l_itemkey,
11648                                aname  => 'PREVIEW_DATE_NOTSPECIFIED',
11649                                avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
11650           END IF;
11651 
11652             l_progress := '090';
11653 
11654             wf_engine.SetItemAttrNumber (itemtype       => l_itemtype,
11655                                                         itemkey => l_itemkey,
11656                                                         aname   => 'BID_ID',
11657                                                         avalue  => p_bid_number);
11658 
11659             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11660                                        itemkey    => l_itemkey,
11661                                        aname      => 'DOC_NUMBER',
11662                                        avalue     => l_doc_number);
11663 
11664             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11665                                        itemkey    => l_itemkey,
11666                                        aname      => 'TP_TIME_ZONE',
11667                                        avalue     => l_timezone_disp);
11668 
11669             wf_engine.SetItemAttrDate (itemtype   => l_itemtype,
11670                                        itemkey    => l_itemkey,
11671                                        aname      => 'AUCTION_START_DATE',
11672                                        avalue     => l_auction_start_date);
11673 
11674             wf_engine.SetItemAttrDate (itemtype   => l_itemtype,
11675                                        itemkey    => l_itemkey,
11676                                        aname      => 'AUCTION_END_DATE',
11677                                        avalue     => l_auction_end_date);
11678 
11679             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11680                                        itemkey    => l_itemkey,
11681                                        aname      => 'AUCTION_TITLE',
11682                                        avalue     => l_auction_title);
11683 
11684            /* Set value for Role - PREPARER_TP_CONTACT_NAME,
11685               this will be set as performer i.e. Notification Recipient
11686            */
11687             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11688                                        itemkey    => l_itemkey,
11689                                        aname      => 'PREPARER_TP_CONTACT_NAME',
11690                                        avalue     => l_auctioneer_user_name);
11691 
11692             /* Set value for Role - RECIPIENT_ROLE, this will
11693                be set as HDE_FROM_ID i.e. Notification Sender
11694             */
11695       -- Set the sender as the current logged in user
11696       -- This is so that if a surrogate bid is being created,
11697       -- then the sender is the buyer creating the surrogate bid
11698 
11699             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11700                                        itemkey    => l_itemkey,
11701                                        aname      => 'RECIPIENT_ROLE',
11702                                        avalue     => fnd_global.user_name);
11703 
11704 
11705             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11706                                        itemkey    => l_itemkey,
11707                                        aname      => 'PREPARER_TP_NAME',
11708                                        avalue     => l_preparer_tp_name);
11709 
11710             wf_engine.SetItemAttrDate (itemtype   => l_itemtype,
11711                                        itemkey    => l_itemkey,
11712                                        aname      => 'BID_PUBLISH_DATE',
11713                                        avalue     => l_bid_publish_date);
11714 
11715             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11716                                        itemkey    => l_itemkey,
11717                                        aname      => 'BIDDER_TP_NAME',
11718                                        avalue     => l_bidder_tp_name);
11719 
11720             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11721                                        itemkey    => l_itemkey,
11722                                        aname      => 'SUPPLIER_SITE_NAME',
11723                                        avalue     => l_supplier_site_name);
11724 
11725             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11726                                        itemkey    => l_itemkey,
11727                                        aname      => 'RESP_PUBLISH_SUBJECT',
11728                                        avalue     => l_resp_publish_sub);
11729 
11730              wf_engine.SetItemAttrText (itemtype  => l_itemtype,
11731                                 itemkey  => l_itemkey,
11732                                 aname  => 'RESPONSE_TYPE',
11733                                 avalue  => l_response_type_name);
11734 
11735              wf_engine.SetItemAttrText (itemtype  => l_itemtype,
11736                                 itemkey  => l_itemkey,
11737                                 aname  => 'RESPONSE_URL',
11738                                 avalue  => l_response_url);
11739 
11740             wf_engine.SetItemAttrText (itemtype   => l_itemtype,
11741                                        itemkey    => l_itemkey,
11742                                        aname      => 'AUCTION_ID',
11743                                        avalue     => l_auction_header_id);
11744 
11745     -- Bug 4295915: Set the  workflow owner
11746             wf_engine.SetItemOwner(itemtype => l_itemtype,
11747                                    itemkey  => l_itemkey,
11748                                    owner    => fnd_global.user_name);
11749 
11750             l_progress := '100';
11751 
11752             wf_engine.StartProcess(itemtype => l_itemtype,
11753                                    itemkey  => l_itemkey );
11754 
11755 
11756             l_progress := 'END';
11757 
11758             IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11759                          FND_LOG.string (log_level => FND_LOG.level_procedure,
11760                                       module => g_module || l_module_name,
11761                                        message  => 'Procedure Ends ' || g_module || l_module_name
11762                                       || ', l_progress = ' || l_progress);
11763             END IF;
11764 
11765             UNSET_SESSION_LANGUAGE;
11766 
11767         EXCEPTION WHEN OTHERS THEN
11768             IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
11769                                         FND_LOG.string (log_level => FND_LOG.level_procedure,
11770                                         module => g_module || l_module_name,
11771                                         message  => 'In Exception Block : ' || g_module || l_module_name
11772                                         || ', l_progress = ' || l_progress
11773                                         || ', l_auction_header_id = ' || l_auction_header_id);
11774             END IF;
11775             UNSET_SESSION_LANGUAGE;
11776             x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11777         END;
11778 
11779 END SEND_RESP_NOTIF;
11780 
11781 /*=========================================================================+
11782 -- 12.0 Enhancement
11783 -- SEND_MSG_SENT_NOTIF procedure will be responsible for
11784 -- sending notification to the Buyer when a Seller sends
11785 -- a message to Buyer or a Buyer sends an internal message
11786 -- to other Collaboration Team Members
11787 -- Parameter :
11788 --          p_toFirstName       IN VARCHAR2
11789 --          p_toLastName        IN VARCHAR2
11790 --          p_toCompanyName     IN VARCHAR2
11791 --          p_toCompanyId       IN NUMBER
11792 --          p_fromFirstName     IN VARCHAR2
11793 --          p_fromLastName      IN VARCHAR2
11794 --          p_fromCompanyName   IN VARCHAR2
11795 --          p_fromCompanyId     IN NUMBER
11796 --          p_creatorCompanyId  IN NUMBER
11797 --          p_userPartyId       IN NUMBER
11798 --          p_entryid           IN NUMBER
11799 --          p_message_type      IN VARCHAR2
11800 --          x_return_status     OUT NOCOPY VARCHAR2
11801 --
11802 +=========================================================================*/
11803 
11804 PROCEDURE SEND_MSG_SENT_NOTIF(
11805           p_toFirstName      IN VARCHAR2,
11806           p_toLastName       IN VARCHAR2,
11807           p_toCompanyName    IN VARCHAR2,
11808           p_toCompanyId      IN NUMBER,
11809           p_fromFirstName    IN VARCHAR2,
11810           p_fromLastName     IN VARCHAR2,
11811           p_fromCompanyName  IN VARCHAR2,
11812           p_fromCompanyId    IN NUMBER,
11813           p_creatorCompanyId IN NUMBER,
11814           p_userPartyId      IN NUMBER,
11815           p_entryid          IN NUMBER,
11816           p_message_type     IN VARCHAR2,
11817           x_return_status    OUT NOCOPY VARCHAR2
11818         )
11819 IS  -- {
11820 
11821     l_module_name CONSTANT   VARCHAR2(40) := 'SEND_MSG_SENT_NOTIF';
11822     l_progress               VARCHAR2(3);
11823     l_language               VARCHAR2(20);
11824     l_lang_code              VARCHAR2(4);
11825     l_doc_number             PON_AUCTION_HEADERS_ALL.DOCUMENT_NUMBER%TYPE;
11826     l_auction_header_id      PON_AUCTION_HEADERS_ALL.AUCTION_HEADER_ID%TYPE;
11827     l_auction_start_date     DATE;
11828     l_auction_end_date       DATE;
11829     l_preview_date           DATE;
11830     l_msg_sent_date          DATE;
11831     l_null_date              DATE;
11832     l_msg_suffix             PON_AUC_DOCTYPES.MESSAGE_SUFFIX%TYPE;
11833     l_auction_title          PON_AUCTION_HEADERS_ALL.AUCTION_TITLE%TYPE;
11834     l_subject                PON_THREADS.SUBJECT%TYPE;
11835     l_sender_name            VARCHAR2(350);
11836     l_recipient_name         VARCHAR2(350);
11837     l_preparer_tp_name       HZ_PARTIES.PARTY_NAME%TYPE;
11838     l_task_name              PON_NEG_TEAM_MEMBERS.TASK_NAME%TYPE;
11839     l_task_target_date       DATE;
11840     l_task_assignment_date   DATE;
11841     l_msg_sent_subject       VARCHAR2(2000);
11842     l_timezone_disp          VARCHAR2(240);
11843     l_timezone_disp1         VARCHAR2(240);
11844     l_timezone_nodisp        VARCHAR2(240);
11845     l_auctioneer_user_name   VARCHAR2(244);
11846     l_auctioneer_tpc_id      NUMBER;
11847     l_person_party_id        NUMBER;
11848     l_sequence               NUMBER;
11849     l_itemtype               VARCHAR2(7);
11850     l_itemkey               VARCHAR2(50);
11851     l_user_id                NUMBER;
11852     l_user_name              FND_USER.USER_NAME%TYPE;
11853     l_sender_user            FND_USER.USER_NAME%TYPE;
11854     l_from_id                NUMBER;
11855     l_from_company_id        NUMBER;
11856     l_page_url               VARCHAR2(500);
11857     l_discussion_id          NUMBER;
11858     l_is_sealed_neg          VARCHAR2(1);
11859     l_notif_performer        VARCHAR2(10); -- BUYER or SUPPLIER
11860     l_staggered_cls_intrvl   NUMBER;
11861     l_open_auction_now_flag VARCHAR2(1);
11862     l_publish_auction_now_flag   VARCHAR2(1);
11863 
11864 
11865     CURSOR INT_MEMBERS (p_sender_id               NUMBER,
11866                         p_auction_header_id       NUMBER,
11867                         p_discussion_id           NUMBER)
11868     IS
11869         SELECT
11870                 hz.party_id TO_PARTY_ID,
11871                 PON_LOCALE_PKG.get_party_display_name(hz.party_id,2, userenv('LANG')) TO_PARTY_NAME,
11872                 hz.person_first_name FIRST_NAME,
11873                 hz.person_last_name LAST_NAME
11874         FROM pon_neg_team_members  pntm,
11875                   HZ_PARTIES hz,
11876                   fnd_user fu
11877         WHERE hz.party_id=fu.person_party_id
11878         AND nvl(fu.end_date,sysdate+1) > sysdate
11879         AND fu.user_id=pntm.user_id
11880         AND fu.person_party_id <> p_sender_id
11881         AND pntm.auction_header_id = p_auction_header_id
11882         UNION
11883         SELECT
11884                 distinct pte.from_id TO_PARTY_ID,
11885                 PON_LOCALE_PKG.get_party_display_name(pte.from_id,2, userenv('LANG'))  TO_PARTY_NAME,
11886                 pte.from_first_name FIRST_NAME, pte.from_last_name LAST_NAME
11887         FROM pon_threads pt,
11888                   pon_thread_entries pte
11889         WHERE pt.discussion_id = p_discussion_id
11890         AND pt.discussion_id = pte.discussion_id
11891         AND pt.thread_number = pte.thread_number
11892         AND pte.from_id <> p_sender_id
11893         AND pte.vendor_id is null;
11894 
11895    CURSOR EXT_MEMBER (p_auction_header_id       NUMBER,
11896                       p_discussion_id           NUMBER,
11897                       p_auctioneer_tpc_id       NUMBER)
11898    IS
11899       SELECT DISTINCT
11900         PBP.TRADING_PARTNER_CONTACT_ID TO_PARTY_ID,
11901         PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(PBP.TRADING_PARTNER_CONTACT_ID, 2 , USERENV('LANG'))||' - '||NVL(HZ.PARTY_NAME,'')  TO_PARTY_NAME,
11902         HZ1.PERSON_FIRST_NAME FIRST_NAME,
11903         HZ1.PERSON_LAST_NAME LAST_NAME,
11904         HZ.PARTY_ID COMPANY_ID,
11905         HZ.PARTY_NAME COMPANY_NAME
11906       FROM PON_BIDDING_PARTIES PBP,
11907         HZ_PARTIES HZ,
11908         HZ_PARTIES HZ1
11909       WHERE PBP.AUCTION_HEADER_ID = p_auction_header_id
11910         AND HZ.PARTY_ID=PBP.TRADING_PARTNER_ID
11911         AND HZ1.PARTY_ID= PBP.TRADING_PARTNER_CONTACT_ID
11912       UNION
11913       SELECT DISTINCT
11914         PBH.TRADING_PARTNER_CONTACT_ID TO_PARTY_ID,
11915         PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(PBH.TRADING_PARTNER_CONTACT_ID,2,USERENV('LANG'))||' - '||NVL(HZ.PARTY_NAME,'')  TO_PARTY_NAME,
11916         HZ1.PERSON_FIRST_NAME FIRST_NAME,
11917         HZ1.PERSON_LAST_NAME LAST_NAME,
11918         HZ.PARTY_ID COMPANY_ID,
11919         HZ.PARTY_NAME COMPANY_NAME
11920       FROM PON_BID_HEADERS PBH,
11921         HZ_PARTIES HZ,
11922         HZ_PARTIES HZ1
11923       WHERE PBH.AUCTION_HEADER_ID = p_auction_header_id
11924         AND HZ.PARTY_ID=PBH.TRADING_PARTNER_ID
11925         AND HZ1.PARTY_ID=PBH.TRADING_PARTNER_CONTACT_ID
11926         AND PBH.BID_STATUS NOT IN ('ARCHIVED','DISQUALIFIED')
11927       UNION
11928       SELECT DISTINCT
11929         PTE.FROM_ID TO_PARTY_ID,
11930         PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(PTE.FROM_ID, 2,USERENV('LANG')) ||' - '||NVL(PTE.FROM_COMPANY_NAME,'')  TO_PARTY_NAME,
11931         PTE.FROM_FIRST_NAME FIRST_NAME,
11932         PTE.FROM_LAST_NAME LAST_NAME,
11933         PTE.FROM_COMPANY_ID COMPANY_ID,
11934         PTE.FROM_COMPANY_NAME COMPANY_NAME
11935       FROM PON_THREADS PT,
11936         PON_THREAD_ENTRIES PTE,
11937         PON_TE_RECIPIENTS PTR
11938       WHERE PT.DISCUSSION_ID = p_discussion_id
11939         AND PT.DISCUSSION_ID = PTE.DISCUSSION_ID
11940         AND PT.THREAD_NUMBER = PTE.THREAD_NUMBER
11941         AND PTE.ENTRY_ID = PTR.ENTRY_ID
11942         AND PTR.TO_ID = p_auctioneer_tpc_id
11943         AND PTE.VENDOR_ID IS NOT NULL;
11944 
11945 
11946             CURSOR SCORING_MEMBERS (p_sender_id               NUMBER,
11947                                 p_auction_header_id       NUMBER,
11948                                 p_team_id                        NUMBER)
11949             IS
11950                 SELECT
11951                         hz.party_id TO_PARTY_ID,
11952                         PON_LOCALE_PKG.get_party_display_name(hz.party_id,2, userenv('LANG')) TO_PARTY_NAME,
11953                         hz.person_first_name FIRST_NAME,
11954                         hz.person_last_name LAST_NAME
11955                 FROM pon_scoring_team_members  pntm,
11956                           HZ_PARTIES hz,
11957                           fnd_user fu
11958                 WHERE hz.party_id=fu.person_party_id
11959                 AND fu.user_id=pntm.user_id
11960                 AND nvl(fu.end_date,sysdate+1) > sysdate
11961                 AND fu.person_party_id <> p_sender_id
11962                 AND pntm.auction_header_id = p_auction_header_id
11963                 AND pntm.team_id = p_team_id;
11964 
11965             CURSOR ALL_SCORING_MEMBERS (p_sender_id               NUMBER,
11966                                 p_auction_header_id       NUMBER)
11967             IS
11968                 SELECT  distinct
11969                         hz.party_id TO_PARTY_ID,
11970                         PON_LOCALE_PKG.get_party_display_name(hz.party_id,2, userenv('LANG')) TO_PARTY_NAME,
11971                         hz.person_first_name FIRST_NAME,
11972                         hz.person_last_name LAST_NAME
11973                 FROM pon_scoring_team_members  pntm,
11974                           HZ_PARTIES hz,
11975                           fnd_user fu
11976                 WHERE hz.party_id=fu.person_party_id
11977                 AND fu.user_id=pntm.user_id
11978                 AND nvl(fu.end_date,sysdate+1) > sysdate
11979                 AND fu.person_party_id <> p_sender_id
11980                 AND pntm.auction_header_id = p_auction_header_id;
11981 
11982             CURSOR GROUP_MEMBERS (p_sender_id NUMBER,
11983                                   p_entryId   NUMBER)
11984             IS
11985                 SELECT ptr.to_id TO_PARTY_ID,
11986                        PON_LOCALE_PKG.get_party_display_name(ptr.to_id,2, userenv('LANG')) TO_PARTY_NAME,
11987                        ptr.to_first_name FIRST_NAME,
11988                        ptr.to_last_name LAST_NAME
11989                 FROM pon_te_recipients ptr
11990                 WHERE ptr.entry_id = p_entryId
11991                   AND ptr.to_id <> p_sender_id;
11992 
11993 
11994       --}
11995 
11996 BEGIN --{
11997        x_return_status := FND_API.G_RET_STS_ERROR;
11998 
11999         l_progress := '000';
12000         l_null_date := null;
12001 
12002         IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12003                       FND_LOG.string (log_level => FND_LOG.level_procedure,
12004                                    module => g_module || l_module_name,
12005                                    message  => 'Entering to Procedure ' || g_module || l_module_name
12006                                    || ', l_progress = ' || l_progress
12007                                    || ', p_entryid = ' || p_entryid
12008                                    || ', p_toFirstName = ' ||   p_toFirstName
12009                                    || ', p_toLastName = ' ||  p_toLastName
12010                                    || ', p_toCompanyName = ' || p_toCompanyName
12011                                    || ', p_toCompanyId  = ' || p_toCompanyId
12012                                    || ', p_fromFirstName = ' || p_fromFirstName
12013                                    || ', p_fromLastName = ' || p_fromLastName
12014                                    || ', p_fromCompanyName = ' || p_fromCompanyName
12015                                    || ', p_fromCompanyId = ' || p_fromCompanyId
12016                                    || ', p_creatorCompanyId = ' ||  p_creatorCompanyId
12017                                    || ', p_userPartyId = ' || p_userPartyId
12018                                    || ', p_entryid = ' || p_entryid  );
12019          END IF;
12020 
12021            l_progress := '001';
12022            SELECT
12023                 auh.DOCUMENT_NUMBER,
12024                 auh.AUCTION_HEADER_ID,
12025                 auh.OPEN_BIDDING_DATE,
12026                 auh.CLOSE_BIDDING_DATE,
12027                 auh.VIEW_BY_DATE,
12028                 pad.MESSAGE_SUFFIX,
12029                 auh.AUCTION_TITLE,
12030                 auh.TRADING_PARTNER_CONTACT_NAME,
12031                 auh.TRADING_PARTNER_CONTACT_ID,
12032                 auh.STAGGERED_CLOSING_INTERVAL,
12033                 decode(nvl(auh.bid_visibility_code,'N'),
12034                           'SEALED_AUCTION','Y',
12035                                            'N'),
12036                 SYSDATE,
12037                 pt.SUBJECT,
12038                 pte.FROM_ID,
12039                 pte.FROM_COMPANY_ID,
12040                 pd.discussion_id,
12041                 open_auction_now_flag,
12042                 publish_auction_now_flag
12043             INTO
12044                   l_doc_number,
12045                   l_auction_header_id,
12046                   l_auction_start_date,
12047                   l_auction_end_date,
12048                   l_preview_date,
12049                   l_msg_suffix,
12050                   l_auction_title,
12051                   l_auctioneer_user_name,
12052                   l_auctioneer_tpc_id,
12053                   l_staggered_cls_intrvl,
12054                   l_is_sealed_neg,
12055                   l_msg_sent_date,
12056                   l_subject,
12057                   l_from_id,
12058                   l_from_company_id,
12059                   l_discussion_id,
12060                   l_open_auction_now_flag ,
12061                   l_publish_auction_now_flag
12062             FROM pon_auction_headers_all auh,
12063                 pon_auc_doctypes pad,
12064                 pon_thread_entries pte,
12065                 pon_threads pt,
12066                 pon_discussions pd
12067             WHERE pte.entry_id = p_entryid
12068                 AND pd.discussion_id = pte.discussion_id
12069                 AND pt.discussion_id = pte.discussion_id
12070                 AND pt.thread_number = pte.thread_number
12071                 AND auh.auction_header_id = pd.pk1_value
12072                 AND pad.doctype_id = auh.doctype_id;
12073 
12074           l_progress := '002';
12075           IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12076                       FND_LOG.string (log_level => FND_LOG.level_procedure,
12077                                    module => g_module || l_module_name,
12078                                    message  => 'Negotiation Data retrieved for Document Number: ' || l_doc_number);
12079           END IF;
12080 
12081 
12082 
12083           IF (p_toCompanyId = 0 ) THEN --{
12084                 --
12085                 -- Group Message / Multiselect Case
12086                 --
12087 
12088                 l_progress := '020';
12089 
12090                 IF ('EXTERNAL' = p_message_type) THEN
12091                     l_notif_performer := 'SUPPLIER';
12092                 ELSE
12093                     l_notif_performer := 'BUYER';
12094                 END IF;
12095 
12096 
12097                 FOR member IN  GROUP_MEMBERS(l_from_id, p_entryid)
12098                 LOOP
12099                 --{
12100                                NOTIFY_MEMBER(   p_userPartyId                => member.to_party_id,
12101                                                 p_auctioneer_user_name       => l_auctioneer_user_name,
12102                                                 p_auction_start_date         => l_auction_start_date,
12103                                                 p_auction_end_date           => l_auction_end_date,
12104                                                 p_preview_date               => l_preview_date,
12105                                                 p_msg_sent_date              => l_msg_sent_date,
12106                                                 p_msg_suffix                 => l_msg_suffix,
12107                                                 p_doc_number                 => l_doc_number,
12108                                                 p_auction_title              => l_auction_title,
12109                                                 p_entryid                    => p_entryid,
12110                                                 p_auction_header_id          => l_auction_header_id,
12111                                                 p_fromFirstName              => p_fromFirstName,
12112                                                 p_fromLastName               => p_fromLastName,
12113                                                 p_from_id                    => l_from_id,
12114                                                 p_notif_performer            => l_notif_performer,
12115                                                 p_subject                    => l_subject,
12116                                                 p_message_type               => p_message_type,
12117                                                 p_fromCompanyName            => p_fromCompanyName,
12118                                                 p_discussion_id              => l_discussion_id,
12119                                                 p_stagger_closing_interval   => l_staggered_cls_intrvl,
12120                                                 p_open_auction_now_flag      => l_open_auction_now_flag,
12121                                                 p_publish_auction_now_flag   => l_publish_auction_now_flag);
12122                 --}
12123                 END LOOP;
12124 
12125           -- } End of If it is group / multiSelect message
12126           --
12127           --  If it is a point to point message then we need to send the notification
12128           --  to the Recipient of the message only
12129           --
12130           ELSIF (p_toCompanyId > 0 ) THEN --{
12131                 --
12132                 -- Point to point messaging
12133                 --
12134 
12135                 l_progress := '030';
12136                 IF ( p_creatorCompanyId = l_from_company_id ) THEN
12137                     l_notif_performer := 'SUPPLIER';
12138                 ELSE
12139                     l_notif_performer := 'BUYER';
12140                 END IF;
12141 
12142                 IF ('EXTERNAL' = p_message_type AND p_creatorCompanyId = l_from_company_id) THEN
12143                     --
12144                     -- So, this is a message to Supplier hence make the From
12145                     -- id to that of the Negotiation Creator
12146                     --
12147                     l_from_id := l_auctioneer_tpc_id;
12148 
12149                 END IF;
12150 
12151                 NOTIFY_MEMBER(                  p_userPartyId                => p_userPartyId,
12152                                                 p_auctioneer_user_name       => l_auctioneer_user_name,
12153                                                 p_auction_start_date         => l_auction_start_date,
12154                                                 p_auction_end_date           => l_auction_end_date,
12155                                                 p_preview_date               => l_preview_date,
12156                                                 p_msg_sent_date              => l_msg_sent_date,
12157                                                 p_msg_suffix                 => l_msg_suffix,
12158                                                 p_doc_number                 => l_doc_number,
12159                                                 p_auction_title              => l_auction_title,
12160                                                 p_entryid                    => p_entryid,
12161                                                 p_auction_header_id          => l_auction_header_id,
12162                                                 p_fromFirstName              => p_fromFirstName,
12163                                                 p_fromLastName               => p_fromLastName,
12164                                                 p_from_id                    => l_from_id,
12165                                                 p_notif_performer            => l_notif_performer,
12166                                                 p_subject                    => l_subject,
12167                                                 p_message_type               => p_message_type,
12168                                                 p_fromCompanyName            => p_fromCompanyName,
12169                                                 p_discussion_id              => l_discussion_id,
12170                                                 p_stagger_closing_interval   => l_staggered_cls_intrvl,
12171                                                 p_open_auction_now_flag      => l_open_auction_now_flag,
12172                                                 p_publish_auction_now_flag   => l_publish_auction_now_flag);
12173 
12174           -- } End of If it is not a broadcast msg
12175           --
12176           -- The next block is meant for - Sealed Negotiation
12177           --                               And External Broadcast
12178           --                               And Seller initiated message
12179           -- Then only Buyer will get a notification from the seller
12180           -- and other sellers will NOT get any notification to protect
12181           -- the seller's identity
12182           --
12183           ELSIF ('Y' = l_is_sealed_neg
12184                  AND 'EXTERNAL' = p_message_type
12185                  AND p_toCompanyId < 0
12186                  AND p_creatorCompanyId <> l_from_company_id) THEN --{
12187 
12188                 --
12189                 -- It is the case of Sealed  External Broadcast
12190                 -- where we will be sending point to point notification
12191                 -- It will be always a Seller to Buyer notification
12192                 --
12193 
12194                 l_progress := '040';
12195 
12196                 l_notif_performer := 'BUYER'; -- As Buyer is the only reciever of this notification
12197 
12198                 NOTIFY_MEMBER(                  p_userPartyId                => l_auctioneer_tpc_id,
12199                                                 p_auctioneer_user_name       => l_auctioneer_user_name,
12200                                                 p_auction_start_date         => l_auction_start_date,
12201                                                 p_auction_end_date           => l_auction_end_date,
12202                                                 p_preview_date               => l_preview_date,
12203                                                 p_msg_sent_date              => l_msg_sent_date,
12204                                                 p_msg_suffix                 => l_msg_suffix,
12205                                                 p_doc_number                 => l_doc_number,
12206                                                 p_auction_title              => l_auction_title,
12207                                                 p_entryid                    => p_entryid,
12208                                                 p_auction_header_id          => l_auction_header_id,
12209                                                 p_fromFirstName              => p_fromFirstName,
12210                                                 p_fromLastName               => p_fromLastName,
12211                                                 p_from_id                    => l_from_id,
12212                                                 p_notif_performer            => l_notif_performer,
12213                                                 p_subject                    => l_subject,
12214                                                 p_message_type               => p_message_type,
12215                                                 p_fromCompanyName            => p_fromCompanyName,
12216                                                 p_discussion_id              => l_discussion_id,
12217                                                 p_stagger_closing_interval   => l_staggered_cls_intrvl,
12218                                                 p_open_auction_now_flag      => l_open_auction_now_flag,
12219                                                 p_publish_auction_now_flag   => l_publish_auction_now_flag);
12220 
12221 
12222           ELSE  --} End of If it is not a Selaed broadcast msg
12223           --{
12224                 --
12225                 -- Broadcast messaging
12226                 --
12227                 l_progress := '050';
12228                 --
12229                 -- Check if it is the internal broadcast
12230                 --
12231                 IF ('INTERNAL' = p_message_type ) THEN --{
12232                         --
12233                         -- Get the list of the team members and post them the
12234                         -- notifications
12235                         --
12236                         l_progress := '060';
12237 
12238                         l_notif_performer := 'BUYER'; -- As Buyer users are the only recievers of this notification
12239 
12240       --
12241       -- Now this broadcast can be three simple varieties namely -
12242       --  All Team Members Broadcast          (p_toCompanyId = -2)
12243       --  All Scoring Team Members Broadcast  (p_toCompanyId = -3)
12244       --   Specific Scoring Team Broadcast     (p_toCompanyId = -X), where X is the Scoring Team Id
12245       --
12246       -- We, need handle those cases in the following if else blocks
12247       --
12248 
12249                         IF  (p_toCompanyId = -2) THEN  --{
12250 
12251                                 l_progress := '062';
12252 
12253                           FOR member IN  INT_MEMBERS (l_from_id, l_auction_header_id,l_discussion_id)
12254                           LOOP
12255                           --{
12256 
12257                                 NOTIFY_MEMBER(  p_userPartyId                => member.to_party_id,
12258                                                     p_auctioneer_user_name       => l_auctioneer_user_name,
12259                                                     p_auction_start_date         => l_auction_start_date,
12260                                                     p_auction_end_date           => l_auction_end_date,
12261                                                     p_preview_date               => l_preview_date,
12262                                                     p_msg_sent_date              => l_msg_sent_date,
12263                                                     p_msg_suffix                 => l_msg_suffix,
12264                                                     p_doc_number                 => l_doc_number,
12265                                                     p_auction_title              => l_auction_title,
12266                                                     p_entryid                    => p_entryid,
12267                                                     p_auction_header_id          => l_auction_header_id,
12268                                                     p_fromFirstName              => p_fromFirstName,
12269                                                     p_fromLastName               => p_fromLastName,
12270                                                     p_from_id                    => l_from_id,
12271                                                     p_notif_performer            => l_notif_performer,
12272                                                     p_subject                    => l_subject,
12273                                                     p_message_type               => p_message_type,
12274                                                     p_fromCompanyName            => p_fromCompanyName,
12275                                                     p_discussion_id              => l_discussion_id,
12276                                                     p_stagger_closing_interval   => l_staggered_cls_intrvl,
12277                                                     p_open_auction_now_flag      => l_open_auction_now_flag,
12278                                                     p_publish_auction_now_flag   => l_publish_auction_now_flag);
12279 
12280                           --}
12281                           END LOOP;
12282       --}
12283                         ELSIF (p_toCompanyId = -3) THEN --{
12284 
12285         l_progress := '065';
12286 
12287         FOR member IN  ALL_SCORING_MEMBERS (l_from_id, l_auction_header_id)
12288                                 LOOP
12289                                 --{
12290 
12291                                         NOTIFY_MEMBER(      p_userPartyId                => member.to_party_id,
12292                                                             p_auctioneer_user_name       => l_auctioneer_user_name,
12293                                                             p_auction_start_date         => l_auction_start_date,
12294                                                             p_auction_end_date           => l_auction_end_date,
12295                                                             p_preview_date               => l_preview_date,
12296                                                             p_msg_sent_date              => l_msg_sent_date,
12297                                                             p_msg_suffix                 => l_msg_suffix,
12298                                                             p_doc_number                 => l_doc_number,
12299                                                             p_auction_title              => l_auction_title,
12300                                                             p_entryid                    => p_entryid,
12301                                                             p_auction_header_id          => l_auction_header_id,
12302                                                             p_fromFirstName              => p_fromFirstName,
12303                                                             p_fromLastName               => p_fromLastName,
12304                                                             p_from_id                    => l_from_id,
12305                                                             p_notif_performer            => l_notif_performer,
12306                                                             p_subject                    => l_subject,
12307                                                             p_message_type               => p_message_type,
12308                                                             p_fromCompanyName            => p_fromCompanyName,
12309                                                             p_discussion_id              => l_discussion_id,
12310                                                             p_stagger_closing_interval   => l_staggered_cls_intrvl,
12311                                                             p_open_auction_now_flag      => l_open_auction_now_flag,
12312                                                             p_publish_auction_now_flag   => l_publish_auction_now_flag);
12313 
12314                                 --}
12315                                 END LOOP;
12316 
12317       --}
12318       ELSIF (p_toCompanyId < -3) THEN --{
12319 
12320         l_progress := '067';
12321 
12322              FOR member IN  SCORING_MEMBERS (l_from_id, l_auction_header_id, -1*p_toCompanyId)
12323                                 LOOP
12324                                 --{
12325 
12326                                         NOTIFY_MEMBER(      p_userPartyId                => member.to_party_id,
12327                                                             p_auctioneer_user_name       => l_auctioneer_user_name,
12328                                                             p_auction_start_date         => l_auction_start_date,
12329                                                             p_auction_end_date           => l_auction_end_date,
12330                                                             p_preview_date               => l_preview_date,
12331                                                             p_msg_sent_date              => l_msg_sent_date,
12332                                                             p_msg_suffix                 => l_msg_suffix,
12333                                                             p_doc_number                 => l_doc_number,
12334                                                             p_auction_title              => l_auction_title,
12335                                                             p_entryid                    => p_entryid,
12336                                                             p_auction_header_id          => l_auction_header_id,
12337                                                             p_fromFirstName              => p_fromFirstName,
12338                                                             p_fromLastName               => p_fromLastName,
12339                                                             p_from_id                    => l_from_id,
12340                                                             p_notif_performer            => l_notif_performer,
12341                                                             p_subject                    => l_subject,
12342                                                             p_message_type               => p_message_type,
12343                                                             p_fromCompanyName            => p_fromCompanyName,
12344                                                             p_discussion_id              => l_discussion_id,
12345                                                               p_stagger_closing_interval   => l_staggered_cls_intrvl,
12346                                                             p_open_auction_now_flag      => l_open_auction_now_flag,
12347                                                             p_publish_auction_now_flag   => l_publish_auction_now_flag);
12348 
12349                                 --}
12350                                 END LOOP;
12351 
12352       --}
12353       END IF;
12354          --}
12355                 ELSIF ('EXTERNAL' = p_message_type ) THEN --{
12356                         --
12357                         -- So, it is an external broadcast
12358                         --
12359 
12360                         l_notif_performer := 'SUPPLIER'; -- As Supplier users are the only recievers of this notification
12361 
12362                         l_progress := '070';
12363 
12364                         FOR member IN  EXT_MEMBER (l_auction_header_id,l_discussion_id, l_from_id)
12365                         LOOP
12366                         --{
12367 
12368                             NOTIFY_MEMBER(      p_userPartyId                => member.to_party_id,
12369                                                 p_auctioneer_user_name       => l_auctioneer_user_name,
12370                                                 p_auction_start_date         => l_auction_start_date,
12371                                                 p_auction_end_date           => l_auction_end_date,
12372                                                 p_preview_date               => l_preview_date,
12373                                                 p_msg_sent_date              => l_msg_sent_date,
12374                                                 p_msg_suffix                 => l_msg_suffix,
12375                                                 p_doc_number                 => l_doc_number,
12376                                                 p_auction_title              => l_auction_title,
12377                                                 p_entryid                    => p_entryid,
12378                                                 p_auction_header_id          => l_auction_header_id,
12379                                                 p_fromFirstName              => p_fromFirstName,
12380                                                 p_fromLastName               => p_fromLastName,
12381                                                 p_from_id                    => l_from_id,
12382                                                 p_notif_performer            => l_notif_performer,
12383                                                 p_subject                    => l_subject,
12384                                                 p_message_type               => p_message_type,
12385                                                 p_fromCompanyName            => p_fromCompanyName,
12386                                                 p_discussion_id              => l_discussion_id,
12387                                                 p_stagger_closing_interval   => l_staggered_cls_intrvl,
12388                                                 p_open_auction_now_flag      => l_open_auction_now_flag,
12389                                                 p_publish_auction_now_flag   => l_publish_auction_now_flag);
12390 
12391                         --}
12392                         END LOOP;
12393                 END IF;
12394                 --}
12395           END IF;
12396           --}
12397 
12398           l_progress := '090';
12399 
12400           x_return_status := FND_API.G_RET_STS_SUCCESS;
12401 
12402 EXCEPTION
12403       WHEN OTHERS THEN
12404            WF_CORE.CONTEXT ('PONAUCT','SEND_MSG_SENT_NOTIF','Process:'||l_progress||'SQL error:' || sqlcode|| ', error message:' ||substr(sqlerrm,1,512));
12405            RAISE;
12406 
12407 END SEND_MSG_SENT_NOTIF;  -- }
12408 
12409 /*=========================================================================+
12410 --
12411 -- 12.0 Enhancement
12412 -- IS_NOTIF_SUBSCRIBED  is a wrapper over the GET_NOTIF_PREFERENCE
12413 -- of PON_WF_UTL_PKG. It will call the procedure GET_NOTIF_PREFERENCE with
12414 -- appropriate message type and auction header id.
12415 --
12416 -- Parameter :
12417 --             itemtype  IN VARCHAR2
12418 --             itemkey   IN VARCHAR2
12419 --             actid     IN NUMBER
12420 --         funcmode  IN VARCHAR2
12421 --         resultout OUT NOCOPY VARCHAR2
12422 --
12423 +=========================================================================*/
12424 
12425 
12426 PROCEDURE IS_NOTIF_SUBSCRIBED(itemtype        in varchar2,
12427                               itemkey         in varchar2,
12428                               actid           in number,
12429                               funcmode        in varchar2,
12430                               resultout       out NOCOPY varchar2)
12431 IS
12432      l_negotiation_id   NUMBER;
12433      l_wf_message_name  VARCHAR2(100);
12434      l_tp_type          VARCHAR2(20); -- TO indicate if it is a buyer or a seller
12435      l_module_name      CONSTANT VARCHAR2(30) := 'IS_NOTIF_SUBSCRIBED';
12436      l_change_type      NUMBER;
12437      l_is_event_auction VARCHAR2(1);
12438      l_notif_group_type VARCHAR(30);  -- Bug 8992789
12439 
12440 BEGIN --{
12441           --
12442           -- Get the auction_header_id depending on the different itemtype possible
12443           --
12444           IF (itemtype = 'PONAPPRV' OR itemtype = 'PONAWAPR') THEN
12445                 l_negotiation_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
12446                                                                  itemkey  => itemkey,
12447                                                                  aname    => 'AUCTION_HEADER_ID');
12448           ELSE
12449                 l_negotiation_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
12450                                                                  itemkey  => itemkey,
12451                                                                  aname    => 'AUCTION_ID');
12452           END IF;
12453 
12454           --
12455           -- Get the Function Attribute for this call. It will pass the
12456           -- WF_MESSAGE_NAME attribute associated with a notification
12457           --
12458     l_wf_message_name := Wf_Engine.GetActivityAttrText( itemtype,
12459                     itemkey,
12460                     actid,
12461                     'PON_WF_MESSAGE_NAME');
12462 
12463 
12464     IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12465       FND_LOG.string (log_level => FND_LOG.level_procedure,
12466       module => g_module || l_module_name,
12467       message  => 'In ' || g_module || l_module_name
12468             || ', itemtype = ' || itemtype
12469             || ', itemkey = ' || itemkey
12470             || ', actid = ' || actid
12471             || ', funcmode = ' || funcmode
12472             || ', resultout = ' || resultout
12473             || ', l_negotiation_id = ' || l_negotiation_id
12474             || ', l_wf_message_name = ' || l_wf_message_name);
12475     END IF;
12476 
12477           --
12478           -- CLOSECHANGED Block, responsible for finding the exact message name for
12479           -- CLOSECHANGED process. The process starts with a different message name and
12480           -- can change the message name as the workflow progresses
12481           --
12482           IF (l_wf_message_name= 'CLOSECHANGED') THEN
12483               BEGIN
12484                    l_change_type := wf_engine.GetItemAttrNumber (itemtype => itemtype,
12485                                                                  itemkey  => itemkey,
12486                                                                  aname => 'CHANGE_TYPE');
12487               EXCEPTION
12488                    WHEN OTHERS THEN
12489                        l_change_type := 1; -- for auctions created before version 115.20 of ponwfau1.wft this attribute did not exist
12490               END;
12491 
12492 
12493               IF (l_change_type = 1) THEN
12494                     --
12495                     -- auctioneer has extended the auction
12496                     --
12497                     l_wf_message_name := 'NEGOTIATION_EXTENDED';
12498               ELSE
12499                      --
12500                      -- auctioneer has shortened the auction
12501                      --
12502                     l_wf_message_name := 'NEGOTIATION_SHORTENED';
12503               END IF;
12504           END IF; -- END OF CLOSECHANGED Block
12505 
12506           --
12507           -- CALCEL Block
12508           --
12509 
12510           IF (l_wf_message_name = 'CANCEL') THEN
12511             l_is_event_auction := IS_EVENT_AUCTION(l_negotiation_id);
12512 
12513             IF (l_is_event_auction = 'Y') THEN
12514                l_wf_message_name := 'NEGOTIATION_CANCELED_EVENT';
12515             ELSE
12516                l_wf_message_name := 'NEGOTIATION_CANCELED';
12517             END IF;
12518 
12519           END IF;  -- END OF CANCEL Block
12520 
12521           --
12522           -- Online Discussion Message Sent Block
12523           --
12524 
12525           IF (l_wf_message_name = 'DISCUSSIONMESSAGE') THEN
12526 
12527             l_tp_type := wf_engine.GetItemAttrText (itemtype => itemtype,
12528                                                     itemkey  => itemkey,
12529                                                     aname    => 'TRADING_PARTNER_TYPE');
12530 
12531             IF (l_tp_type = 'BUYER') THEN
12532                l_wf_message_name := 'BUYER_DISC_MESSAGE_SENT_MSG';
12533             ELSE
12534                l_wf_message_name := 'SUPPLIER_DISC_MESSAGE_SENT_MSG';
12535             END IF;
12536 
12537           END IF;  -- END of Disc. Meg Sent Block
12538 
12539    -- Begin Bug 8992789
12540    IF (IS_INTERNAL_ONLY(l_negotiation_id)) THEN
12541 
12542      SELECT notifGroups.notif_group_type
12543      INTO l_notif_group_type
12544      FROM PON_NOTIF_SUBSCRIPTION_GROUPS notifGroups,
12545           PON_NOTIF_GROUP_MEMBERS notifMessages
12546      WHERE notifGroups.NOTIF_GROUP_CODE = notifMessages.NOTIF_GROUP_CODE
12547        AND notifMessages.NOTIF_MESSAGE_NAME = l_wf_message_name;
12548 
12549      IF (l_notif_group_type = 'TO_SUPPLIER') THEN
12550        resultout := 'N';
12551        RETURN;
12552      END IF;
12553 
12554    END IF;
12555    -- End Bug 8992789
12556 
12557    resultout := PON_WF_UTL_PKG.GET_NOTIF_PREFERENCE(l_wf_message_name,l_negotiation_id);
12558 
12559 EXCEPTION  --}
12560       WHEN OTHERS THEN
12561               resultout := PON_WF_UTL_PKG.G_NO;
12562               IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12563           FND_LOG.string (log_level => FND_LOG.level_procedure,
12564           module => g_module || l_module_name,
12565           message  => 'Exception Block ' || g_module || l_module_name
12566            || ', l_negotiation_id = ' || l_negotiation_id
12567                || ', l_wf_message_name = ' || l_wf_message_name
12568                            ||', sql error code'||sqlcode);
12569         END IF;
12570       RAISE;
12571 END IS_NOTIF_SUBSCRIBED;
12572 
12573 PROCEDURE NOTIFY_MEMBER(p_userPartyId           IN NUMBER,
12574                         p_auctioneer_user_name  IN VARCHAR2,
12575                         p_auction_start_date    IN DATE,
12576                         p_auction_end_date      IN DATE,
12577                         p_preview_date          IN DATE,
12578                         p_msg_sent_date         IN DATE,
12579                         p_msg_suffix            IN VARCHAR2,
12580                         p_doc_number            IN VARCHAR2,
12581                         p_auction_title         IN VARCHAR2,
12582                         p_entryid               IN NUMBER,
12583                         p_auction_header_id     IN NUMBER,
12584                         p_fromFirstName         IN VARCHAR2,
12585                         p_fromLastName          IN VARCHAR2,
12586                         p_from_id               IN NUMBER,
12587                         p_notif_performer       IN VARCHAR2,
12588                         p_subject               IN VARCHAR2,
12589                         p_message_type          IN VARCHAR2,
12590                         p_fromCompanyName       IN VARCHAR2,
12591                         p_discussion_id         IN NUMBER,
12592                         p_stagger_closing_interval IN NUMBER,
12593                         p_open_auction_now_flag  IN VARCHAR2,
12594                         p_publish_auction_now_flag IN VARCHAR2
12595                         )
12596 IS
12597         l_null_date           DATE;
12598         l_progress            VARCHAR2(3);
12599         l_module_name         CONSTANT VARCHAR2(20) := '.NOTIFY_MEMBER';
12600 
12601         l_language            VARCHAR2(20);
12602         l_lang_code           VARCHAR2(4);
12603         l_sender_name         VARCHAR2(350);
12604         l_recipient_name      VARCHAR2(350);
12605 
12606         l_msg_sent_subject    VARCHAR2(2000);
12607         l_timezone_disp       VARCHAR2(240);
12608         l_timezone_disp1      VARCHAR2(240);
12609         l_timezone_nodisp     VARCHAR2(240);
12610 
12611         l_itemtype        VARCHAR2(7);
12612         l_itemkey        VARCHAR2(50);
12613         l_user_id             NUMBER;
12614         l_user_name           FND_USER.USER_NAME%TYPE;
12615         l_sender_user         FND_USER.USER_NAME%TYPE;
12616         l_page_url            VARCHAR2(500);
12617         l_wfm_htmlagent       VARCHAR2(500);
12618         l_discussion_id       NUMBER;
12619         l_auction_start_date  DATE;
12620         l_auction_end_date    DATE;
12621         l_preview_date        DATE;
12622         l_msg_sent_date       DATE;
12623         l_staggered_close_note VARCHAR2(1000);
12624 
12625         x_language_code       VARCHAR2(60);
12626         x_territory_code      VARCHAR2(30);
12627 
12628 BEGIN
12629 --{
12630                 l_null_date := NULL;
12631                 l_auction_start_date  := p_auction_start_date;
12632                 l_auction_end_date   := p_auction_end_date;
12633                 l_preview_date          := p_preview_date;
12634                 l_msg_sent_date       := p_msg_sent_date;
12635                 l_progress  := '010';
12636 
12637                 BEGIN
12638 
12639                   BEGIN
12640 
12641                     SELECT
12642                         USER_ID,
12643                         USER_NAME
12644                     INTO
12645                         l_user_id,
12646                         l_user_name
12647                     FROM FND_USER
12648                     WHERE PERSON_PARTY_ID = p_userPartyId
12649                     AND NVL(END_DATE, SYSDATE+1) > SYSDATE;
12650 
12651                  EXCEPTION
12652                        WHEN TOO_MANY_ROWS THEN
12653                           IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
12654                                IF (FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level) THEN
12655                                          FND_LOG.string(log_level => FND_LOG.level_unexpected,
12656                                                         module    => 'pon.plsql.pon_auction_pkg.notify_member 1',
12657                                                         message   => 'Multiple Users found for person_party_id:'|| p_userPartyId);
12658                                END IF;
12659                          END IF;
12660 
12661                      SELECT
12662                         USER_ID,
12663                         USER_NAME
12664                     INTO
12665                         l_user_id,
12666                         l_user_name
12667                     FROM FND_USER
12668                     WHERE PERSON_PARTY_ID = p_userPartyId
12669                     AND NVL(END_DATE, SYSDATE+1) > SYSDATE
12670                     AND ROWNUM=1;
12671 
12672                  END;
12673 
12674                  BEGIN
12675 
12676                     SELECT
12677                         USER_NAME
12678                     INTO
12679                         l_sender_user
12680                     FROM FND_USER
12681                     WHERE PERSON_PARTY_ID = p_from_id
12682                     AND NVL(END_DATE, SYSDATE+1) > SYSDATE;
12683 
12684                  EXCEPTION
12685                        WHEN TOO_MANY_ROWS THEN
12686                           IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
12687                                IF (FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level) THEN
12688                                          FND_LOG.string(log_level => FND_LOG.level_unexpected,
12689                                                         module    => 'pon.plsql.pon_auction_pkg.notify_member 2',
12690                                                         message   => 'Multiple Users found for person_party_id:'|| p_from_id);
12691                                END IF;
12692                          END IF;
12693 
12694                     SELECT
12695                         USER_NAME
12696                     INTO
12697                         l_sender_user
12698                     FROM FND_USER
12699                     WHERE PERSON_PARTY_ID = p_from_id
12700                     AND NVL(END_DATE, SYSDATE+1) > SYSDATE
12701                     AND ROWNUM=1;
12702 
12703                  END;
12704 
12705                     -- Get the language of the Recipient of the message
12706                    l_language := fnd_profile.value_specific('ICX_LANGUAGE', l_user_id, NULL, NULL);
12707                EXCEPTION
12708                     WHEN NO_DATA_FOUND THEN
12709                         l_language := 'AMERICAN';
12710                END;
12711 
12712                SELECT LANGUAGE_CODE
12713                        INTO l_lang_code
12714                FROM FND_LANGUAGES
12715                WHERE NLS_LANGUAGE = l_language;
12716 
12717                 l_recipient_name := PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(p_userPartyId, 2 ,l_lang_code) ;
12718                 l_sender_name := PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(p_from_id, 2 ,l_lang_code);
12719 
12720                 --
12721                 -- Subject should be retrieved from seed message
12722                 --
12723                 IF l_user_name is not null THEN
12724                         PON_PROFILE_UTIL_PKG.GET_WF_PREFERENCES(l_user_name ,x_language_code,x_territory_code);
12725                 END IF;
12726 
12727                 IF (x_language_code is not null) THEN
12728                         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
12729                         FND_LOG.string(log_level => FND_LOG.level_statement,
12730                           module => g_module_prefix || 'EMAIL_LIST',
12731                           message  => '12. Calling SET_SESSION_LANGUAGE with x_language_code : ' || x_language_code);
12732                         END IF; --}
12733                         SET_SESSION_LANGUAGE(null, x_language_code);
12734                 END IF;
12735 
12736                 PON_OEX_TIMEZONE_PKG.CONVERT_DATE_TO_USER_TZ(p_person_party_id => p_userPartyId,
12737                                                                p_auctioneer_user_name => p_auctioneer_user_name,
12738                                                                x_date_value1  => l_auction_start_date,
12739                                                                x_date_value2  => l_auction_end_date,
12740                                                                x_date_value3  => l_preview_date,
12741                                                                x_date_value4  => l_msg_sent_date,
12742                                                                x_date_value5  => l_null_date,
12743                                                                x_timezone_disp =>l_timezone_disp);
12744 
12745 
12746                 l_progress := '020';
12747                 IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12748                               FND_LOG.string (log_level => FND_LOG.level_procedure,
12749                                            module => g_module || l_module_name,
12750                                            message  => 'Negotiation Dates are converted to destination timezone: ' || l_timezone_disp);
12751                 END IF;
12752 
12753                 l_msg_sent_subject :=  PON_AUCTION_PKG.getMessage(msg => 'PON_DISC_MESSAGE_SENT_MSG',
12754                                                                     msg_suffix => '_'|| p_msg_suffix,
12755                                                                     token1 => 'DOC_NUMBER',
12756                                                                     token1_value => p_doc_number,
12757                                                                     token2 => 'NEG_TITLE',
12758                                                                     token2_value => replaceHtmlChars(p_auction_title));
12759 
12760 
12761                 l_progress := '030';
12762                 IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12763                               FND_LOG.string (log_level => FND_LOG.level_procedure,
12764                                            module => g_module || l_module_name,
12765                                            message  => 'Disc. Message Subject: ' || l_msg_sent_subject);
12766                 END IF;
12767 
12768                 l_itemtype := 'PONAUCT';
12769                 l_itemkey := p_auction_header_id||'-'|| p_entryid||'-'||p_userPartyId;
12770 
12771                 IF (p_preview_date is not null) THEN
12772                         l_timezone_disp1 := l_timezone_disp;
12773                         l_timezone_nodisp := NULL;
12774                 ELSE
12775                         l_timezone_disp1 := NULL;
12776                         l_timezone_nodisp := PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC');
12777                 END IF;
12778 
12779                 l_progress := '040';
12780                 IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12781                               FND_LOG.string (log_level => FND_LOG.level_procedure,
12782                                            module => g_module || l_module_name,
12783                                            message  => 'Negotiation Preview Date is: ' || p_preview_date);
12784                 END IF;
12785 
12786                 l_progress := '050';
12787                 IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12788                           FND_LOG.string (log_level => FND_LOG.level_procedure,
12789                                        module => g_module || l_module_name,
12790                                        message  => 'This is a Point to Point Message');
12791                 END IF;
12792 
12793 
12794                 l_progress := '060';
12795                 IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12796                           FND_LOG.string (log_level => FND_LOG.level_procedure,
12797                                        module => g_module || l_module_name,
12798                                        message  => 'Fetched the Formatted To Name:'|| l_recipient_name ||' , '||'and From Name:'|| l_sender_name);
12799                 END IF;
12800 
12801                 IF p_notif_performer = 'BUYER' THEN
12802    	            l_wfm_htmlagent := pon_wf_utl_pkg.get_base_internal_buyer_url;
12803 	        ELSE
12804 	            l_wfm_htmlagent := pon_wf_utl_pkg.get_base_external_supplier_url;
12805 	        END IF;
12806 
12807                 l_page_url := pon_wf_utl_pkg.get_dest_page_url (p_dest_func => 'PON_VIEW_MESSAGE_DETAILS'
12808                                  ,p_notif_performer  => p_notif_performer);
12809 
12810                 --
12811                 -- Stagger Closing Note is to be shown for ONLY Supplier
12812                 -- facing notification ONLY with staggered line Negotiation
12813                 --
12814                 l_staggered_close_note := NULL;
12815                 IF (p_notif_performer IS NOT NULL AND
12816                     p_notif_performer = 'SUPPLIER' AND
12817                     p_stagger_closing_interval IS NOT NULL ) THEN
12818                          l_staggered_close_note := wf_core.newline || wf_core.newline ||
12819                                                    getMessage('PON_STAGGERED_CLOSE_NOTIF_MSG') ||
12820                                                    wf_core.newline || wf_core.newline;
12821 
12822                 END IF;
12823 
12824 
12825                 wf_engine.CreateProcess(itemtype => l_itemtype,
12826                       itemkey  => l_itemkey,
12827                       process  => 'DISC_MESSAGE_SENT');
12828 
12829                 l_progress := '070';
12830                 IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12831                           FND_LOG.string (log_level => FND_LOG.level_procedure,
12832                                        module => g_module || l_module_name,
12833                                        message  => 'Created the DISC_MESSAGE_SENT Workflow process');
12834                 END IF;
12835 
12836               SET_PREVIEW_DATE(
12837                         p_itemtype => l_itemtype,
12838                         p_itemkey   => l_itemkey,
12839                         p_preview_date  => l_preview_date,
12840                         p_publish_auction_now_flag => p_publish_auction_now_flag,
12841                         p_timezone_disp  => l_timezone_disp,
12842                         p_msg_suffix => p_msg_suffix);
12843 
12844               SET_OPEN_DATE(
12845                         p_itemtype      => l_itemtype,
12846                         p_itemkey      => l_itemkey,
12847                         p_auction_start_date  => l_auction_start_date,
12848                         p_open_auction_now_flag => p_open_auction_now_flag,
12849                         p_timezone_disp  => l_timezone_disp,
12850                         p_msg_suffix => p_msg_suffix);
12851 
12852               SET_CLOSE_DATE(
12853                         p_itemtype  =>l_itemtype,
12854                         p_itemkey    =>l_itemkey,
12855                         p_auction_end_date  => l_auction_end_date,
12856                         p_timezone_disp  => l_timezone_disp);
12857 
12858                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12859                            itemkey    => l_itemkey,
12860                            aname      => 'DOC_NUMBER',
12861                            avalue     => p_doc_number);
12862 
12863                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12864                                            itemkey    => l_itemkey,
12865                                            aname      => 'STAGGERED_CLOSE_NOTE',
12866                                            avalue     => l_staggered_close_note);
12867 
12868                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12869                            itemkey    => l_itemkey,
12870                            aname      => 'AUCTION_TITLE',
12871                            avalue     => p_auction_title);
12872 
12873                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12874                            itemkey    => l_itemkey,
12875                            aname      => 'MSG_RECIPIENT_NAME',
12876                            avalue     => l_recipient_name);
12877 
12878                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12879                            itemkey    => l_itemkey,
12880                            aname      => 'MSG_SENDER_NAME',
12881                            avalue     => l_sender_name);
12882 
12883                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12884                                  itemkey    => l_itemkey,
12885                                  aname      => 'VIEW_MESSAGE_URL',
12886                                  avalue     => l_page_url);
12887 
12888                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12889                                  itemkey    => l_itemkey,
12890                                  aname      => 'MESSAGE_TYPE',
12891                                  avalue     => p_message_type);
12892 
12893                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12894                            itemkey    => l_itemkey,
12895                            aname      => 'MSG_SENDER_COMP_NAME',
12896                            avalue     => p_fromCompanyName);
12897 
12898                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12899                            itemkey    => l_itemkey,
12900                            aname      => 'MESSAGE_SENT_SUBJECT',
12901                            avalue     => l_msg_sent_subject);
12902 
12903                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12904                            itemkey    => l_itemkey,
12905                            aname      => 'MESSAGE_POSTED_DATE',
12906                            avalue     => p_msg_sent_date);
12907 
12908                wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12909                            itemkey    => l_itemkey,
12910                            aname      => 'MESSAGE_SUBJECT',
12911                            avalue     => p_subject);
12912 
12913                wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12914                            itemkey    => l_itemkey,
12915                            aname      => 'PREPARER_TP_CONTACT_NAME',
12916                            avalue     => l_sender_user);
12917 
12918                wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12919                            itemkey    => l_itemkey,
12920                            aname      => 'RECIPIENT_ROLE',
12921                            avalue     => l_user_name);
12922 
12923                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12924                            itemkey    => l_itemkey,
12925                            aname      => 'TRADING_PARTNER_TYPE',
12926                            avalue     => p_notif_performer);
12927 
12928                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12929                            itemkey    => l_itemkey,
12930                            aname      => 'AUCTION_ID',
12931                            avalue     => p_auction_header_id);
12932 
12933                 wf_engine.SetItemAttrNumber (itemtype   => l_itemtype,
12934                            itemkey    => l_itemkey,
12935                            aname      => 'MESSAGE_ENTRY_ID',
12936                            avalue     => p_entryid);
12937 
12938                 wf_engine.SetItemAttrNumber (itemtype   => l_itemtype,
12939                            itemkey    => l_itemkey,
12940                            aname      => 'DISCUSSION_ID',
12941                            avalue     => p_discussion_id);
12942 
12943                 wf_engine.SetItemAttrText (itemtype   => l_itemtype,
12944                            itemkey    => l_itemkey,
12945                            aname      => 'ORIGIN_USER_NAME',
12946                            --avalue     => fnd_global.user_name);--Bug: 13609915 :set FROM as creator of doc
12947                            avalue     => l_sender_user);
12948 
12949              -- Bug 4295915: Set the  workflow owner
12950                 wf_engine.SetItemOwner(itemtype => l_itemtype,
12951                                        itemkey  => l_itemkey,
12952                                        owner    => fnd_global.user_name);
12953 
12954                 BEGIN
12955 
12956                     wf_engine.SetItemAttrText   (itemtype   => l_itemtype,
12957                                                  itemkey    => l_itemkey,
12958                                                  aname      => '#WFM_HTMLAGENT',
12959                                                  avalue     => l_wfm_htmlagent);
12960                 EXCEPTION
12961                   WHEN OTHERS THEN
12962                      null;
12963                 END;
12964 
12965                 wf_engine.StartProcess(itemtype => l_itemtype,
12966                        itemkey  => l_itemkey );
12967 
12968                 l_progress := '080';
12969 
12970 
12971                 IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN
12972                     FND_LOG.string (log_level => FND_LOG.level_procedure,
12973                               module => g_module || l_module_name,
12974                                message  => 'Procedure Ends ' || g_module || l_module_name
12975                               || ', l_progress = ' || l_progress);
12976                 END IF;
12977 
12978 EXCEPTION
12979       WHEN OTHERS THEN
12980            WF_CORE.CONTEXT ('PONAUCT','NOTIFY_MEMBER','Progress:'|| l_progress ||', SQL error:' || sqlcode|| ', error message:' ||substr(sqlerrm,1,512));
12981            RAISE;
12982 --}
12983 END NOTIFY_MEMBER;
12984 
12985 /*=========================================================================+
12986 --
12987 -- 12.0 Enhancement
12988 -- GET_MAPPED_IP_CATEGORY takes in a po category id as a parameter and
12989 -- returns an ip category if mapping exists else returns -2
12990 --
12991 --
12992 -- Parameter :
12993 --             p_po_category_id  IN NUMBER
12994 --
12995 +=========================================================================*/
12996 
12997 
12998 FUNCTION GET_MAPPED_IP_CATEGORY(p_po_category_id  IN NUMBER) return NUMBER AS
12999 
13000 v_ip_category_id NUMBER;
13001 
13002 BEGIN
13003 
13004   BEGIN
13005     select nvl(shopping_category_id, -2)
13006     into   v_ip_category_id
13007     from   icx_cat_purchasing_cat_map_v
13008     where  po_category_id = p_po_category_id and
13009            rownum = 1;
13010 
13011   EXCEPTION
13012 
13013     WHEN OTHERS THEN
13014 
13015       v_ip_category_id := -2;
13016 
13017   END;
13018 
13019   RETURN v_ip_category_id;
13020 
13021 END GET_MAPPED_IP_CATEGORY;
13022 
13023 /*=========================================================================+
13024 --
13025 -- 12.0 Enhancement
13026 -- GET_MAPPED_PO_CATEGORY takes in an ip category id as a parameter and
13027 -- returns a po category if mapping exists else returns -2
13028 --
13029 --
13030 -- Parameter :
13031 --             p_ip_category_id  IN NUMBER
13032 --
13033 +=========================================================================*/
13034 
13035 
13036 FUNCTION GET_MAPPED_PO_CATEGORY(p_ip_category_id  IN NUMBER) return NUMBER AS
13037 
13038 v_po_category_id NUMBER;
13039 
13040 BEGIN
13041 
13042   BEGIN
13043     select nvl(po_category_id, -2)
13044     into   v_po_category_id
13045     from   icx_cat_shopping_cat_map_v
13046     where  shopping_category_id = p_ip_category_id and
13047            rownum = 1;
13048 
13049   EXCEPTION
13050 
13051     WHEN OTHERS THEN
13052 
13053       v_po_category_id := -2;
13054 
13055   END;
13056 
13057   RETURN v_po_category_id;
13058 
13059 END GET_MAPPED_PO_CATEGORY;
13060 
13061 PROCEDURE SET_PREVIEW_DATE(
13062           p_itemtype      IN  VARCHAR2,
13063            p_itemkey      IN  VARCHAR2,
13064            p_preview_date  IN DATE,
13065           p_publish_auction_now_flag IN VARCHAR2,
13066           p_timezone_disp  IN VARCHAR2,
13067           p_msg_suffix IN VARCHAR2) IS
13068 
13069 BEGIN
13070 
13071         IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
13072              IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13073                        FND_LOG.string(log_level => FND_LOG.level_statement,
13074                                       module    => 'pon.plsql.pon_auction_pkg.set_preview_date',
13075                                       message   => 'Entered the procedure with params --- ' ||
13076                                                     'p_itemtype : ' || p_itemtype||
13077                                                     ',p_itemkey : ' ||p_itemkey||
13078                                                     ',p_preview_date : '||p_preview_date||
13079                                                     ',p_publish_auction_now_flag : '||p_publish_auction_now_flag||
13080                                                     ',p_timezone_disp : '||p_timezone_disp||
13081                                                     ',p_msg_suffix : '||p_msg_suffix);
13082              END IF;
13083        END IF;
13084 
13085       IF (p_publish_auction_now_flag = 'Y') THEN --if Immediately is selected
13086 
13087         wf_engine.SetItemAttrDate (itemtype  => p_itemtype,
13088                     itemkey  => p_itemkey,
13089                     aname  => 'PREVIEW_DATE',
13090                     avalue  => null);
13091 
13092         wf_engine.SetItemAttrText (itemtype  => p_itemtype,
13093                     itemkey  => p_itemkey,
13094                     aname  => 'TP_TIME_ZONE1',
13095                     avalue  => null);
13096 
13097         wf_engine.SetItemAttrText (itemtype  => p_itemtype,
13098                        itemkey  => p_itemkey,
13099                        aname  => 'PREVIEW_DATE_NOTSPECIFIED',
13100                        avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_OPEN_IMM_AFTER_PUB',p_msg_suffix));
13101 
13102       ELSIF (p_preview_date is NULL) THEN --if Not specified
13103 
13104         wf_engine.SetItemAttrDate (itemtype  => p_itemtype,
13105                     itemkey  => p_itemkey,
13106                     aname  => 'PREVIEW_DATE',
13107                     avalue  => null);
13108 
13109         wf_engine.SetItemAttrText (itemtype  => p_itemtype,
13110                         itemkey  => p_itemkey,
13111                         aname  => 'TP_TIME_ZONE1',
13112                         avalue  => null);
13113 
13114         wf_engine.SetItemAttrText (itemtype  => p_itemtype,
13115                        itemkey  => p_itemkey,
13116                        aname  => 'PREVIEW_DATE_NOTSPECIFIED',
13117                        avalue  => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
13118 
13119       ELSE
13120         wf_engine.SetItemAttrDate (itemtype  => p_itemtype,
13121                     itemkey  => p_itemkey,
13122                     aname  => 'PREVIEW_DATE',
13123                     avalue  => p_preview_date);
13124 
13125         wf_engine.SetItemAttrText (itemtype  => p_itemtype,
13126                     itemkey  => p_itemkey,
13127                     aname  => 'TP_TIME_ZONE1',
13128                     avalue  => p_timezone_disp);
13129 
13130         wf_engine.SetItemAttrText (itemtype  => p_itemtype,
13131                    itemkey  => p_itemkey,
13132                    aname  => 'PREVIEW_DATE_NOTSPECIFIED',
13133                    avalue  => null);
13134       END IF;
13135 
13136       IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
13137            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13138                      FND_LOG.string(log_level => FND_LOG.level_statement,
13139                                     module    => 'pon.plsql.pon_auction_pkg.set_preview_date',
13140                                     message   => 'Exiting the procedure');
13141            END IF;
13142      END IF;
13143 
13144 END;
13145 
13146 PROCEDURE SET_OPEN_DATE(
13147           p_itemtype      IN  VARCHAR2,
13148            p_itemkey      IN  VARCHAR2,
13149            p_auction_start_date  IN DATE,
13150           p_open_auction_now_flag IN VARCHAR2,
13151           p_timezone_disp  IN VARCHAR2,
13152           p_msg_suffix IN VARCHAR2) IS
13153 
13154 BEGIN
13155 
13156       IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
13157            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13158                      FND_LOG.string(log_level => FND_LOG.level_statement,
13159                                     module    => 'pon.plsql.pon_auction_pkg.set_open_date',
13160                                     message   => 'Entered the procedure with params --- ' ||
13161                                                   'p_itemtype : ' || p_itemtype||
13162                                                   ',p_itemkey : ' ||p_itemkey||
13163                                                   ',p_auction_start_date : '||p_auction_start_date||
13164                                                   ',p_open_auction_now_flag : '||p_open_auction_now_flag||
13165                                                   ',p_timezone_disp : '||p_timezone_disp||
13166                                                   ',p_msg_suffix : '||p_msg_suffix);
13167            END IF;
13168        END IF;
13169 
13170       IF (p_open_auction_now_flag = 'Y') THEN --if Immediately  is selected
13171 
13172         wf_engine.SetItemAttrDate (itemtype   => p_itemtype,
13173                    itemkey    => p_itemkey,
13174                    aname      => 'AUCTION_START_DATE',
13175                    avalue     => null);
13176 
13177         wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13178                    itemkey    => p_itemkey,
13179                    aname      => 'TP_TIME_ZONE',
13180                    avalue     => null);
13181 
13182         wf_engine.SetItemAttrText (itemtype     => p_itemtype,
13183                    itemkey  => p_itemkey,
13184                    aname    => 'OPEN_DATE_NOT_SPECIFIED',
13185                    avalue   => PON_AUCTION_PKG.getMessage('PON_AUC_OPEN_IMM_AFTER_PUB',p_msg_suffix));
13186 
13187       ELSIF(p_auction_start_date is NULL) THEN --if not specified
13188         wf_engine.SetItemAttrDate (itemtype   => p_itemtype,
13189                    itemkey    => p_itemkey,
13190                    aname      => 'AUCTION_START_DATE',
13191                    avalue     => null);
13192 
13193         wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13194                    itemkey    => p_itemkey,
13195                    aname      => 'TP_TIME_ZONE',
13196                    avalue     => null);
13197 
13198         wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13199                    itemkey  => p_itemkey,
13200                    aname    => 'OPEN_DATE_NOT_SPECIFIED',
13201                    avalue   => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
13202 
13203       ELSE
13204         wf_engine.SetItemAttrDate (itemtype   => p_itemtype,
13205                    itemkey    => p_itemkey,
13206                    aname      => 'AUCTION_START_DATE',
13207                    avalue     => p_auction_start_date);
13208 
13209         wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13210                    itemkey    => p_itemkey,
13211                    aname      => 'TP_TIME_ZONE',
13212                    avalue     => p_timezone_disp);
13213 
13214         wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13215                    itemkey  => p_itemkey,
13216                    aname    => 'OPEN_DATE_NOT_SPECIFIED',
13217                    avalue   => null);
13218 
13219       END IF;
13220 
13221       IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
13222            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13223                      FND_LOG.string(log_level => FND_LOG.level_statement,
13224                                     module    => 'pon.plsql.pon_auction_pkg.set_open_date',
13225                                     message   => 'Exiting the procedure');
13226            END IF;
13227      END IF;
13228 
13229 END;
13230 
13231 
13232 PROCEDURE SET_CLOSE_DATE(
13233           p_itemtype      IN  VARCHAR2,
13234            p_itemkey      IN  VARCHAR2,
13235            p_auction_end_date  IN DATE,
13236           p_timezone_disp  IN VARCHAR2) IS
13237 
13238 BEGIN
13239 
13240         IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
13241              IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13242                        FND_LOG.string(log_level => FND_LOG.level_statement,
13243                                       module    => 'pon.plsql.pon_auction_pkg.set_close_date',
13244                                       message   => 'Entered the procedure with params --- ' ||
13245                                                     'p_itemtype : ' || p_itemtype||
13246                                                     ',p_itemkey : ' ||p_itemkey||
13247                                                     ',p_auction_end_date : '||p_auction_end_date||
13248                                                     ',p_timezone_disp : '||p_timezone_disp);
13249              END IF;
13250        END IF;
13251 
13252 
13253        IF (p_auction_end_date is NULL) THEN --if not specified
13254           wf_engine.SetItemAttrDate (itemtype   => p_itemtype,
13255                      itemkey    => p_itemkey,
13256                      aname      => 'AUCTION_END_DATE',
13257                      avalue     => null);
13258 
13259           wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13260                      itemkey    => p_itemkey,
13261                      aname      => 'TP_TIME_ZONE2',
13262                      avalue     => null);
13263 
13264           wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13265                      itemkey  => p_itemkey,
13266                      aname    => 'CLOSE_DATE_NOT_SPECIFIED',
13267                      avalue   => PON_AUCTION_PKG.getMessage('PON_AUC_PREVIEW_DATE_NOTSPEC'));
13268 
13269 
13270         ELSE
13271           wf_engine.SetItemAttrDate (itemtype   => p_itemtype,
13272                      itemkey    => p_itemkey,
13273                      aname      => 'AUCTION_END_DATE',
13274                      avalue     => p_auction_end_date);
13275 
13276           wf_engine.SetItemAttrText (itemtype   => p_itemtype,
13277                      itemkey    => p_itemkey,
13278                      aname      => 'TP_TIME_ZONE2',
13279                      avalue     => p_timezone_disp);
13280 
13281           wf_engine.SetItemAttrText (itemtype     => p_itemtype,
13282                      itemkey  => p_itemkey,
13283                      aname    => 'CLOSE_DATE_NOT_SPECIFIED',
13284                      avalue   => null);
13285 
13286         END IF;
13287 
13288 
13289       IF (NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N') = 'Y') THEN
13290            IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13291                      FND_LOG.string(log_level => FND_LOG.level_statement,
13292                                     module    => 'pon.plsql.pon_auction_pkg.set_close_date',
13293                                     message   => 'Exiting the procedure');
13294            END IF;
13295      END IF;
13296 
13297 END;
13298 
13299 --
13300 -- This procedure is added as part of bug fix for 4914024.
13301 -- Some attributes were removed from the AuctionHeadersAllVO query
13302 -- to prevent the shared memory from going higher. These attributes
13303 -- are now obtained from this PL/SQL API instead.
13304 --
13305 PROCEDURE GET_NEGOTIATION_DETAILS( p_auction_header_id            NUMBER,
13306                                    p_user_trading_partner_id      NUMBER,
13307                                    x_time_left                    OUT NOCOPY VARCHAR2,
13308                                    x_buyer_display                OUT NOCOPY VARCHAR2,
13309                                    x_carrier                      OUT NOCOPY VARCHAR2,
13310                                    x_unlocked_by_display          OUT NOCOPY VARCHAR2,
13311                                    x_unsealed_by_display          OUT NOCOPY VARCHAR2,
13312                                    x_has_active_company_bid       OUT NOCOPY VARCHAR2,
13313                                    x_is_multi_site                OUT NOCOPY VARCHAR2,
13314                                    x_all_site_bid_on              OUT NOCOPY VARCHAR2,
13315                                    x_is_paused                    OUT NOCOPY VARCHAR2,
13316                                    x_outcome_display              OUT NOCOPY VARCHAR2,
13317                                    x_advances_flag                OUT NOCOPY VARCHAR2,
13318                                    x_retainage_flag               OUT NOCOPY VARCHAR2,
13319                                    x_payment_rate_rype_enabled    OUT NOCOPY VARCHAR2
13320                                  ) IS
13321 
13322 v_org_id NUMBER;
13323 v_carrier_code PON_AUCTION_HEADERS_ALL.CARRIER_CODE%TYPE;
13324 v_sealed_unlock_tp_contact_id NUMBER;
13325 v_sealed_unseal_tp_contact_id NUMBER;
13326 v_is_paused VARCHAR2(1);
13327 v_trading_partner_contact_id NUMBER;
13328 v_staggered_closing_interval NUMBER;
13329 v_temp NUMBER;
13330 
13331 BEGIN
13332 
13333   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13334     FND_LOG.string(log_level => FND_LOG.level_statement,
13335       module    => g_module_prefix || '.get_negotiation_details',
13336       message   => 'Entered the procedure ' ||
13337                    'p_auction_header_id = ' || p_auction_header_id ||
13338                    ', p_trading_partner_contact_id = ' || p_user_trading_partner_id);
13339   END IF;
13340 
13341   SELECT
13342     org_id,
13343     carrier_code,
13344     decode(two_part_flag,'Y',decode(sealed_auction_status,'LOCKED',technical_unlock_tp_contact_id,sealed_unlock_tp_contact_id),sealed_unlock_tp_contact_id),
13345     decode(two_part_flag,'Y',decode(sealed_auction_status,'ACTIVE', sealed_unseal_tp_contact_id,technical_unseal_tp_contact_id),sealed_unseal_tp_contact_id),
13346     is_paused,
13347     staggered_closing_interval,
13348     trading_partner_contact_id
13349   INTO
13350     v_org_id,
13351     v_carrier_code,
13352     v_sealed_unlock_tp_contact_id,
13353     v_sealed_unseal_tp_contact_id,
13354     v_is_paused,
13355     v_staggered_closing_interval,
13356     v_trading_partner_contact_id
13357   FROM
13358     pon_auction_headers_all_v
13359   WHERE
13360     auction_header_id = p_auction_header_id;
13361 
13362   x_time_left            :=  TIME_REMAINING(p_auction_header_id);
13363   x_buyer_display        :=  PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(v_trading_partner_contact_id);
13364   x_carrier              :=  PON_PRINTING_PKG.GET_CARRIER_DESCRIPTION(v_org_id,v_carrier_code);
13365   x_unlocked_by_display  :=  PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(v_sealed_unlock_tp_contact_id);
13366   x_unsealed_by_display  :=  PON_LOCALE_PKG.GET_PARTY_DISPLAY_NAME(v_sealed_unseal_tp_contact_id);
13367 
13368   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13369     FND_LOG.string( log_level => FND_LOG.level_statement,
13370       module  =>  g_module_prefix || '.get_negotiation_details',
13371       message  => 'x_time_left = ' || x_time_left
13372                   || ', x_buyer_display = ' || x_buyer_display
13373                   || ', x_carrier = ' || x_carrier
13374                   || ', x_unlocked_by_display = ' || x_unlocked_by_display
13375                   || ', x_unsealed_by_display = ' || x_unsealed_by_display);
13376   END IF;
13377 
13378   BEGIN
13379     SELECT
13380       a.auction_header_id
13381     INTO
13382       v_temp
13383     FROM
13384       pon_auction_headers_all a,
13385       pon_bid_headers b
13386     WHERE
13387       a.auction_header_id = b.auction_header_id
13388       and a.auction_header_id =  p_auction_header_id
13389       and b.trading_partner_id = p_user_trading_partner_id
13390       and b.bid_status = 'ACTIVE'
13391       AND rownum = 1;
13392 
13393     x_has_active_company_bid := 'Y';
13394 
13395     EXCEPTION WHEN NO_DATA_FOUND THEN
13396       x_has_active_company_bid := 'N';
13397   END;
13398 
13399   BEGIN
13400     SELECT
13401       ppbp.auction_header_id
13402     INTO
13403       v_temp
13404     FROM
13405       pon_bidding_parties ppbp
13406     WHERE
13407       ppbp.auction_header_id = p_auction_header_id
13408       and ppbp.trading_partner_id = p_user_trading_partner_id
13409       AND rownum = 1;
13410 
13411     x_is_multi_site := 'Y';
13412 
13413     EXCEPTION WHEN NO_DATA_FOUND THEN
13414       x_is_multi_site := 'N';
13415   END;
13416 
13417   SELECT
13418     DECODE(
13419       (SELECT
13420          count(distinct vendor_site_id)
13421        FROM
13422          pon_bid_headers ppbh
13423        WHERE
13424          ppbh.auction_header_id = p_auction_header_id
13425          and ppbh.trading_partner_id = p_user_trading_partner_id
13426          and ppbh.bid_status = 'ACTIVE'
13427          and nvl(ppbh.evaluation_flag, 'N') = 'N'    -- Added for ER: Supplier Management: Supplier Evaluation
13428       ),
13429       (SELECT
13430          count(pbp.auction_header_id)
13431        FROM
13432          pon_bidding_parties pbp
13433        WHERE
13434          pbp.auction_header_id = p_auction_header_id
13435          and pbp.trading_partner_id = p_user_trading_partner_id
13436       ), 'Y', 'N')
13437   INTO
13438     x_all_site_bid_on
13439   FROM
13440     DUAL;
13441 
13442   SELECT
13443     DECODE( nvl(v_is_paused, 'N'), 'Y', 'Y', nvl2(v_staggered_closing_interval, 'S', 'N'))
13444   INTO
13445     x_is_paused
13446   FROM
13447     DUAL;
13448 
13449   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13450     FND_LOG.string (log_level => FND_LOG.level_statement,
13451       module  =>  g_module_prefix || '.get_negotiation_details',
13452       message  => 'x_has_active_company_bid = ' || x_has_active_company_bid
13453         || ' x_is_multi_site = ' || x_is_multi_site
13454         || ' x_all_site_bid_on = ' || x_all_site_bid_on
13455         || ' x_is_paused = ' || x_is_paused);
13456   END IF;
13457 
13458   SELECT
13459     ps.display_name,
13460     pdsh.advances_flag,
13461     pdsh.retainage_flag,
13462     nvl2(pspay.pay_item_type , 'Y','N')
13463   INTO
13464     x_outcome_display,
13465     x_advances_flag,
13466     x_retainage_flag,
13467     x_payment_rate_rype_enabled
13468   FROM
13469     po_all_doc_style_lines ps,
13470     pon_auction_headers_all_v ah,
13471     po_doc_style_headers pdsh,
13472     po_style_enabled_pay_items pspay,
13473     po_lookup_codes fl_pay_item
13474   WHERE
13475     ah.auction_header_id = p_auction_header_id
13476     AND ah.po_style_id = ps.style_id(+)
13477     AND ah.contract_type = ps.document_subtype(+)
13478     AND USERENV('LANG') = ps.language(+)
13479     AND ah.po_style_id = pdsh.style_id(+)
13480     AND ah.po_style_id = pspay.style_id(+)
13481     AND pspay.pay_item_type(+) ='RATE'
13482     AND fl_pay_item.lookup_type(+)  =  'PAYMENT TYPE'
13483     AND fl_pay_item.lookup_code(+) = pspay.pay_item_type;
13484 
13485   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13486        FND_LOG.string (log_level => FND_LOG.level_statement,
13487          module  =>  g_module_prefix || '.get_negotiation_details',
13488          message  => 'x_outcome_display = ' || x_outcome_display
13489          || ' x_advances_flag = ' || x_advances_flag
13490          || ' x_retainage_flag = ' || x_retainage_flag
13491          || ' x_payment_rate_rype_enabled = ' || x_payment_rate_rype_enabled);
13492   END IF;
13493 
13494 END GET_NEGOTIATION_DETAILS;
13495 
13496 ---------------------------------------------------------------------------------------
13497 --      R12 Rollup1 Enhancement - Countdown Clock Project (adsahay)
13498 --
13499 --      Start of comments
13500 --      API Name:               SHOW_COUNTDOWN
13501 --      Function:               Given an auction id, returns "Y" if the auction is active or paused and
13502 --                              closing within next 24 hours. Auctions that are in preview mode,
13503 --                              cancelled or amended, or closing in more than 24 hours return "N".
13504 --      Parameters:
13505 --      IN:     p_auction_header_id IN NUMBER           - Auction header id
13506 --      OUT:    x_return_status OUT NOCOPY VARCHAR2     - Return status
13507 --              x_error_code OUT NOCOPY VARCHAR2        - Error code
13508 --              x_error_message OUT NOCOPY VARCHAR2     - Error message
13509 --
13510 --      End of Comments
13511 --      Return : l_show_countdown VARCHAR2
13512 ----------------------------------------------------------------------------------------
13513 
13514 FUNCTION SHOW_COUNTDOWN(x_result OUT NOCOPY VARCHAR2,
13515                         x_error_code OUT NOCOPY VARCHAR2,
13516                         x_error_message OUT NOCOPY VARCHAR2,
13517                         p_auction_header_id IN NUMBER)
13518 RETURN VARCHAR2
13519 AS
13520 v_auction_status pon_auction_headers_all.auction_status%TYPE;  -- to store auction status
13521 v_time_remaining number;  -- to store the time remaining for auction to close
13522 l_show_countdown varchar2(1) := 'N';    -- return value, default 'N'
13523 
13524 BEGIN
13525         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13526                 FND_LOG.string (log_level => FND_LOG.level_statement,
13527                 module  =>  g_module_prefix || '.show_countdown',
13528                 message  => 'Entered show_countdown with p_auction_header_id = ' || p_auction_header_id);
13529         END IF;
13530 
13531         x_result := FND_API.G_RET_STS_SUCCESS;
13532 
13533         -- adsahay: bug 6319438 - replace sysdate with last_pause_date for paused auctions,
13534         -- since close_bidding_date can be in the past (lesser than sysdate).
13535         SELECT (close_bidding_date - decode(is_paused, 'Y', last_pause_date, sysdate)), auction_status
13536         INTO v_time_remaining, v_auction_status
13537         FROM pon_auction_headers_all
13538         WHERE auction_header_id = p_auction_header_id
13539         AND open_bidding_date < sysdate;
13540 
13541         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13542         FND_LOG.string (log_level => FND_LOG.level_statement,
13543         module  =>  g_module_prefix || '.show_countdown',
13544         message  => 'p_auction_header_id = ' || p_auction_header_id
13545           || ', v_auction_status = ' || v_auction_status
13546           || ', v_time_remaining = ' || v_time_remaining);
13547         END IF;
13548 
13549 -- v_time_remaining will be in days, 1.0 being full 24 hours.
13550 IF (v_time_remaining > 0 AND v_time_remaining <= 1.0) then
13551         IF(v_auction_status = 'CANCELLED') THEN   -- auction is cancelled
13552                 l_show_countdown := 'N';
13553         --changed by amundhra for federal CLM,
13554         ELSIF (v_auction_status = 'AMENDED' OR v_auction_status = 'APPLIED') THEN -- auction is amended and applied
13555                 l_show_countdown := 'N';
13556         ELSE
13557                 l_show_countdown := 'Y';        -- looks good if reached here.
13558         END IF;
13559 
13560 ELSE    -- more than 24 hours left
13561         l_show_countdown := 'N';
13562 END IF;
13563 
13564 IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13565         FND_LOG.string (log_level => FND_LOG.level_statement,
13566         module  =>  g_module_prefix || '.show_countdown',
13567         message  => 'Returning l_show_countdown = ' || l_show_countdown);
13568 END IF;
13569 
13570 -- return l_show_countdown
13571 RETURN l_show_countdown;
13572 
13573 EXCEPTION
13574   WHEN NO_DATA_FOUND THEN       -- auction is in preview mode, return 'N'
13575         l_show_countdown := 'N';
13576         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13577                 FND_LOG.string (log_level => FND_LOG.level_statement,
13578                 module  =>  g_module_prefix || '.show_countdown',
13579                 message  => 'Returning l_show_countdown = ' || l_show_countdown);
13580         END IF;
13581         Return l_show_countdown;
13582 
13583   WHEN OTHERS THEN
13584         x_result := FND_API.G_RET_STS_UNEXP_ERROR;
13585         x_error_code := SQLCODE;
13586         x_error_message := SUBSTR(SQLERRM, 1, 100);
13587 
13588         IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13589                 FND_LOG.string (log_level => FND_LOG.level_exception,
13590                 module  => g_module_prefix || '.show_countdown',
13591                 message => 'Exception occured in show_countdown'
13592                 || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13593         END IF;
13594 
13595 END SHOW_COUNTDOWN; -- end of function definition.
13596 
13597 -----------------------------------------------------------------------------------
13598 --      R12 Rollup1 Enhancement - Countdown Clock Project (adsahay)
13599 --
13600 --      Start of comments
13601 --      API Name:       HAS_DISTINCT_CLOSING_LINES
13602 --      Function:       Given an auction id, Returns 'Y' if the auction has lines
13603 --                      closing in different times, else 'N'. This means that either the auction is
13604 --                      staggered or has "auto extend" feature enabled such that it extends one line
13605 --                      instead of all lines.
13606 --
13607 --      Parameters:
13608 --      IN:     p_auction_header_id IN NUMBER   - The auction header id
13609 --      OUT:    x_return_status OUT NOCOPY VARCHAR2     - Return status
13610 --              x_error_code OUT NOCOPY VARCHAR2        - Error code
13611 --              x_error_message OUT NOCOPY VARCHAR2     - Error message
13612 --
13613 --      End of Comments
13614 --
13615 --      Return : l_flag VARCHAR2
13616 ------------------------------------------------------------------------------------
13617 
13618 FUNCTION HAS_DISTINCT_CLOSING_DATES(x_result OUT NOCOPY VARCHAR2,
13619                                 x_error_code OUT NOCOPY VARCHAR2,
13620                                 x_error_message OUT NOCOPY VARCHAR2,
13621                                 p_auction_header_id IN NUMBER)
13622 RETURN VARCHAR2
13623 AS
13624 v_time_left number;        --gets the time left for auction to close
13625 v_is_staggered varchar2(1);     -- whether auction is staggered
13626 v_ext_all_lines varchar2(1);    -- whether auto extend all lines
13627 l_flag varchar2(1) := 'N';      -- Return value defaulted to 'N'
13628 BEGIN
13629 
13630         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13631                 FND_LOG.string (log_level => FND_LOG.level_statement,
13632                 module  =>  g_module_prefix || '.has_distinct_closing_dates',
13633                 message  => 'Entered has_distinct_closing_dates with p_auction_header_id = ' || p_auction_header_id);
13634         END IF;
13635 
13636         x_result := FND_API.G_RET_STS_SUCCESS;
13637 
13638         -- adsahay: bug 6319438 - replace sysdate with last_pause_date for paused auctions,
13639         -- since close_bidding_date can be in the past (lesser than sysdate).
13640         SELECT (close_bidding_date-decode(is_paused, 'Y', last_pause_date, sysdate)), nvl2(staggered_closing_interval, 'Y', 'N'),
13641         -- if auto extend is enabled and auto extends all lines, 'N' else 'Y'
13642         decode(auto_extend_flag, 'Y', decode(auto_extend_all_lines_flag, 'N', 'Y', 'N'), 'N')
13643         INTO v_time_left, v_is_staggered, v_ext_all_lines
13644         FROM pon_auction_headers_all
13645         WHERE auction_header_id = p_auction_header_id;
13646 
13647         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13648         FND_LOG.string (log_level => FND_LOG.level_statement,
13649         module  =>  g_module_prefix || '.has_distinct_closing_dates',
13650         message  => 'p_auction_header_id = ' || p_auction_header_id
13651           || ', v_time_left = ' || v_time_left
13652           || ', v_is_staggered = ' || v_is_staggered
13653           || ', v_ext_all_lines = ' || v_ext_all_lines);
13654         END IF;
13655 
13656         -- negative time left means auction already closed
13657         IF (v_time_left < 0) THEN
13658         l_flag := 'N';
13659         -- staggered or auto extend allows different lines to close differently
13660         ELSIF (v_is_staggered = 'Y' OR v_ext_all_lines = 'Y') THEN
13661                 l_flag := 'Y';
13662         ELSE
13663                 l_flag := 'N';
13664         END IF;
13665 
13666         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13667                 FND_LOG.string (log_level => FND_LOG.level_statement,
13668                 module  =>  g_module_prefix || '.has_distinct_closing_dates',
13669                 message  => 'Returning l_flag = ' || l_flag);
13670         END IF;
13671 
13672         RETURN l_flag;
13673 
13674 EXCEPTION
13675   WHEN OTHERS THEN
13676         x_result := FND_API.G_RET_STS_UNEXP_ERROR;
13677         x_error_code := SQLCODE;
13678         x_error_message := SUBSTR(SQLERRM, 1, 100);
13679 
13680         IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13681                 FND_LOG.string (log_level => FND_LOG.level_exception,
13682                 module  => g_module_prefix || '.has_distinct_closing_dates',
13683                 message => 'Exception occured in has_distinct_closing_dates'
13684                 || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13685         END IF;
13686 
13687 END HAS_DISTINCT_CLOSING_DATES; -- end of function definition
13688 
13689 -----------------------------------------------------------------------------------
13690 --      R12 Rollup1 Enhancement - Two Part RFQ Project (adsahay)
13691 --
13692 --      Start of comments
13693 --      API Name:       GET_TECHNICAL_MEANING
13694 --      Function:       Returns meaning of 'TECHNICAL' from lookups.
13695 --
13696 --      Parameters:
13697 --      IN:
13698 --      OUT:
13699 --
13700 --      End of Comments
13701 --
13702 --      Return : g_technical_meaning VARCHAR2
13703 ------------------------------------------------------------------------------------
13704 FUNCTION get_technical_meaning
13705 RETURN VARCHAR2 AS
13706 BEGIN
13707         -- adsahay: bug 6374353 - caching should take care of language too.
13708         -- if cache is empty first populate the cache
13709         IF (g_two_part_cache.COUNT = 0) then -- {
13710           init_two_part_cache;
13711         END IF; -- }
13712 
13713         -- update g_tp_cache_rec from the cache
13714         update_cache_rec;
13715 
13716         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13717                 FND_LOG.string (log_level => FND_LOG.level_statement,
13718                 module  =>  g_module_prefix || '.get_technical_meaning',
13719                 message  => 'Returning technical_meaning = ' || g_tp_cache_rec.technical_meaning);
13720         END IF;
13721 
13722         -- return technical_meaning
13723         return g_tp_cache_rec.technical_meaning;
13724 EXCEPTION
13725   WHEN OTHERS THEN
13726         IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13727                 FND_LOG.string (log_level => FND_LOG.level_exception,
13728                 module  => g_module_prefix || '.get_technical_meaning',
13729                 message => 'Exception occured in get_technical_meaning'
13730                 || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13731         END IF;
13732 
13733 END get_technical_meaning;
13734 
13735 -----------------------------------------------------------------------------------
13736 --      R12 Rollup1 Enhancement - Two Part RFQ Project (adsahay)
13737 --
13738 --      Start of comments
13739 --      API Name:       GET_COMMERCIAL_MEANING
13740 --      Function:       Returns meaning of 'COMMERCIAL' from lookups.
13741 --
13742 --      Parameters:
13743 --      IN:
13744 --      OUT:
13745 --
13746 --      End of Comments
13747 --
13748 --      Return : g_commercial_meaning VARCHAR2
13749 ------------------------------------------------------------------------------------
13750 FUNCTION get_commercial_meaning
13751 RETURN VARCHAR2 AS
13752 BEGIN
13753         -- adsahay: bug 6374353 - caching should take care of language too.
13754         -- if cache is empty first populate the cache
13755         IF (g_two_part_cache.COUNT = 0) then -- {
13756           init_two_part_cache;
13757         END IF; -- }
13758 
13759         -- update g_tp_cache_rec from the cache
13760         update_cache_rec;
13761 
13762         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13763                 FND_LOG.string (log_level => FND_LOG.level_statement,
13764                 module  =>  g_module_prefix || '.get_commercial_meaning',
13765                 message  => 'Returning commercial_meaning = ' || g_tp_cache_rec.commercial_meaning);
13766         END IF;
13767 
13768         -- return commercial_meaning
13769         return g_tp_cache_rec.commercial_meaning;
13770 EXCEPTION
13771   WHEN OTHERS THEN
13772         IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13773                 FND_LOG.string (log_level => FND_LOG.level_exception,
13774                 module  => g_module_prefix || '.get_commercial_meaning',
13775                 message => 'Exception occured in get_commercial_meaning'
13776                 || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13777         END IF;
13778 
13779 END get_commercial_meaning;
13780 
13781 -----------------------------------------------------------------------------------
13782 --      R12 Rollup1 Enhancement - Two Part RFQ Project (adsahay)
13783 --
13784 --      Start of comments
13785 --      API Name:       NOTIFY_BIDDERS_TECH_COMPLETE
13786 --      Procedure:      Notify bidders that their bids have/have not been short listed
13787 --      in technical evaluation.
13788 --
13789 --      Parameters:
13790 --      IN:        p_auction_header_id IN NUMBER - The auction header id.
13791 --      OUT:       x_return_status OUT NOCOPY VARCHAR2     - Return status
13792 --        This is a flag to indicate if the procedure
13793 --                              was successful or not; It can have
13794 --                              following values -
13795 --                                              FND_API.G_RET_STS_SUCCESS (Success)
13796 --                                              FND_API.G_RET_STS_ERROR  (Success with warning)
13797 --                                              FND_API.G_RET_STS_UNEXP_ERROR (Failed due to error)
13798 --
13799 --                x_error_code OUT NOCOPY VARCHAR2        - Error code
13800 --                x_error_message OUT NOCOPY VARCHAR2     - Error message
13801 --
13802 --      End of Comments
13803 ------------------------------------------------------------------------------------
13804 PROCEDURE NOTIFY_BIDDERS_TECH_COMPLETE(x_return_status OUT NOCOPY VARCHAR2,
13805           x_error_code OUT NOCOPY VARCHAR2 ,
13806           x_error_message OUT NOCOPY VARCHAR2,
13807           p_auction_header_id IN NUMBER)
13808 AS
13809   -- get list of bidders, along with the shortlist flags.
13810   CURSOR bidder_list IS
13811     SELECT bid_number, trading_partner_contact_name, nvl(shortlist_flag, 'Y') as shortlist_flag
13812     FROM pon_bid_headers
13813     WHERE   auction_header_id = p_auction_header_id
13814       AND bid_status = 'ACTIVE'
13815       AND nvl(evaluation_flag, 'N') = 'N';
13816 
13817   -- other local variables
13818   x_item_key VARCHAR2(15);  -- workflow item key
13819   x_item_type VARCHAR2(8) := 'PONTEVAL';  -- workflow item type
13820   l_bidder_name pon_bid_headers.trading_partner_contact_name%TYPE;
13821   l_auction_title pon_auction_headers_all.auction_title%TYPE;
13822   l_document_number pon_auction_headers_all.document_number%TYPE;
13823   l_trading_partner_name pon_auction_headers_all.trading_partner_name%TYPE;
13824 
13825 BEGIN
13826         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13827                 FND_LOG.string (log_level => FND_LOG.level_statement,
13828                 module  =>  g_module_prefix || '.notify_bidders_tech_complete',
13829                 message  => 'Entered notify_bidders_tech_complete with p_auction_header_id = ' || p_auction_header_id);
13830         END IF;
13831 
13832         x_return_status := FND_API.G_RET_STS_SUCCESS;
13833 
13834   BEGIN
13835     -- get auction information
13836     SELECT   auction_title, document_number, trading_partner_name
13837     INTO  l_auction_title, l_document_number, l_trading_partner_name
13838     FROM  pon_auction_headers_all
13839     WHERE  auction_header_id = p_auction_header_id;
13840   EXCEPTION
13841     WHEN NO_DATA_FOUND THEN
13842       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13843       x_error_code := SQLCODE;
13844       x_error_message := SUBSTR(SQLERRM, 1, 100);
13845 
13846       IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13847         FND_LOG.string (log_level => FND_LOG.level_exception,
13848         module  => g_module_prefix || '.notify_bidders_tech_complete',
13849         message => 'NO_DATA_FOUND in pon_auction_headers_all for p_auction_header_id :'
13850         || p_auction_header_id || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13851       END IF;
13852 
13853     WHEN TOO_MANY_ROWS THEN
13854       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13855       x_error_code := SQLCODE;
13856       x_error_message := SUBSTR(SQLERRM, 1, 100);
13857 
13858       IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13859         FND_LOG.string (log_level => FND_LOG.level_exception,
13860         module  => g_module_prefix || '.notify_bidders_tech_complete',
13861         message => 'TOO_MANY_ROWS in pon_auction_headers_all for p_auction_header_id :'
13862         || p_auction_header_id || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13863       END IF;
13864 
13865       WHEN OTHERS THEN
13866       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13867       x_error_code := SQLCODE;
13868       x_error_message := SUBSTR(SQLERRM, 1, 100);
13869 
13870       IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13871         FND_LOG.string (log_level => FND_LOG.level_exception,
13872         module  => g_module_prefix || '.notify_bidders_tech_complete',
13873         message => 'Exception occured in notify_bidders_tech_complete'
13874         || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13875       END IF;
13876   END;
13877 
13878   -- for every bidder,
13879   FOR bidder IN bidder_list LOOP
13880 
13881     -- get unique item key by a combination of sequence and bid number.
13882     SELECT   pon_auction_wf_dqbid_s.nextval
13883     INTO   x_item_key
13884     FROM   dual;
13885     x_item_key := bidder.bid_number || '-' || x_item_key;
13886 
13887     -- bidder name: this is the person who gets the notification
13888     l_bidder_name := bidder.trading_partner_contact_name;
13889 
13890     -- create workflow process
13891     wf_engine.CreateProcess(itemtype => x_item_type,
13892               itemkey => x_item_key,
13893           process => 'PON_TECH_SHORTLIST_NOTIFY');
13894 
13895     IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13896       FND_LOG.string (log_level => FND_LOG.level_statement,
13897       module  =>  g_module_prefix || '.notify_bidders_tech_complete',
13898       message  => 'Created workflow process with itemtype = ' || x_item_type || ' and itemkey = '
13899           || x_item_key);
13900     END IF;
13901 
13902     -- bidder trading party contact name
13903     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13904                   itemkey => x_item_key,
13905                   aname => 'BIDDER_TP_CONTACT_NAME',
13906                   avalue => l_bidder_name);
13907 
13908         -- auctioneer trading party name
13909     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13910                   itemkey => x_item_key,
13911                   aname => 'PREPARER_TP_NAME',
13912                   avalue => l_trading_partner_name);
13913 
13914         -- auction header id
13915     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13916                   itemkey => x_item_key,
13917                   aname => 'AUCTION_ID',
13918                   avalue => p_auction_header_id);
13919 
13920         -- bid id
13921     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13922                   itemkey => x_item_key,
13923                   aname => 'BID_ID',
13924                   avalue => bidder.bid_number);
13925 
13926         -- auction title
13927     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13928                   itemkey => x_item_key,
13929                   aname => 'AUCTION_TITLE',
13930                   avalue => l_auction_title);
13931 
13932         -- bid technically shortlisted flag
13933     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13934                   itemkey => x_item_key,
13935                   aname => 'BID_TECH_SHORTLISTED',
13936                   avalue => bidder.shortlist_flag);
13937 
13938         -- document number (display value)
13939     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13940                   itemkey => x_item_key,
13941                   aname => 'DOC_NUMBER',
13942                   avalue => l_document_number);
13943 
13944         -- meaning of Technical
13945     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13946                   itemkey => x_item_key,
13947                   aname => 'TECHNICAL',
13948                   avalue => get_technical_meaning);
13949 
13950         -- meaning of Commercial
13951     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13952                   itemkey => x_item_key,
13953                   aname => 'COMMERCIAL',
13954                   avalue => get_commercial_meaning);
13955 
13956         -- origin user name
13957     wf_engine.SetItemAttrText(  itemtype => x_item_type,
13958                   itemkey => x_item_key,
13959                   aname => 'ORIGIN_USER_NAME',
13960                   avalue => fnd_global.user_name);
13961 
13962     IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13963       FND_LOG.string (log_level => FND_LOG.level_statement,
13964       module  =>  g_module_prefix || '.notify_bidders_tech_complete',
13965       message  =>    ' Passed these attributes -- BIDDER_TP_CONTACT_NAME :' || l_bidder_name  ||
13966           ' PREPARER_TP_NAME :' || l_trading_partner_name || ' AUCTION_ID :' || p_auction_header_id ||
13967           ' BID_ID :' || bidder.bid_number || ' AUCTION_TITLE :' || l_auction_title ||
13968           ' BID_TECH_SHORTLISTED :' || bidder.shortlist_flag || ' DOC_NUMBER :' || l_document_number ||
13969           ' TECHNICAL :' || get_technical_meaning || ' COMMERCIAL :' || get_commercial_meaning);
13970     END IF;
13971 
13972     -- start the workflow
13973     wf_engine.StartProcess(  itemtype => x_item_type,
13974              itemkey => x_item_key);
13975 
13976     IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
13977       FND_LOG.string (log_level => FND_LOG.level_statement,
13978       module  =>  g_module_prefix || '.notify_bidders_tech_complete',
13979       message  =>  ' Workflow process started');
13980     END IF;
13981 
13982     END LOOP;
13983 
13984 EXCEPTION
13985   WHEN OTHERS THEN
13986         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13987         x_error_code := SQLCODE;
13988         x_error_message := SUBSTR(SQLERRM, 1, 100);
13989 
13990         IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.g_current_runtime_level) THEN
13991                 FND_LOG.string (log_level => FND_LOG.level_exception,
13992                 module  => g_module_prefix || '.notify_bidders_tech_complete',
13993                 message => 'Exception occured in notify_bidders_tech_complete'
13994                 || ' Error Number :' || SQLCODE || ' Exception Message :' || SUBSTR(SQLERRM, 1, 200) );
13995         END IF;
13996 
13997 END notify_bidders_tech_complete;
13998 
13999 FUNCTION GET_AUCTION_STATUS_DISPLAY(
14000 p_auction_header_id IN pon_auction_headers_all.AUCTION_HEADER_ID%TYPE,
14001 p_user_trading_partner_id IN pon_auction_headers_all.TRADING_PARTNER_ID%TYPE)
14002 RETURN VARCHAR2
14003 AS
14004 
14005 l_is_buyer BOOLEAN;
14006 l_two_part_flag pon_auction_headers_all.TWO_PART_FLAG%type;
14007 l_technical_lock_status pon_auction_headers_all.TECHNICAL_LOCK_STATUS%type;
14008 l_technical_evaluation_status pon_auction_headers_all.TECHNICAL_EVALUATION_STATUS%type;
14009 l_message VARCHAR2(100);
14010 l_commercial_lock_status pon_auction_headers_all.sealed_auction_status%type;
14011 l_auction_status pon_auction_headers_all.auction_status%type;
14012 l_auction_status2 pon_auction_headers_all.auction_status%type;
14013 l_award_status pon_auction_headers_all.award_status%type;
14014 
14015 l_auction_trading_partner_id pon_auction_headers_all.trading_partner_id%type;
14016 l_technical_lock_meaning VARCHAR2(30);
14017 l_commercial_lock_meaning VARCHAR2(30);
14018 
14019 BEGIN
14020 
14021     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14022       FND_LOG.string(log_level => FND_LOG.level_statement,
14023         module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14024         message  => 'Entering the function with params -- p_auction_header_id = ' || p_auction_header_id
14025                     || ' p_user_trading_partner_id = ' || p_user_trading_partner_id
14026             );
14027     END IF;
14028 
14029     l_message := 'NO MESSAGE FORMED YET FOR THIS AUCTION';
14030 
14031    SELECT nvl(two_part_flag,'N'),
14032           nvl(technical_lock_status,''),
14033           nvl(technical_evaluation_status,''),
14034           nvl(sealed_auction_status, ''),
14035           decode(nvl(is_paused, 'N'), 'Y', 'NOTCLOSED',
14036               decode(SIGN(close_bidding_date - sysdate) , -1, 'CLOSED', 'NOTCLOSED')), --auction status
14037           trading_partner_id,
14038           auction_status,
14039           award_status
14040    INTO
14041           l_two_part_flag,
14042           l_technical_lock_status,
14043           l_technical_evaluation_status,
14044           l_commercial_lock_status,
14045           l_auction_status,
14046           l_auction_trading_partner_id,
14047           l_auction_status2,
14048           l_award_status
14049     FROM pon_auction_headers_all
14050     WHERE auction_header_id = p_auction_header_id;
14051 
14052     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14053       FND_LOG.string(log_level => FND_LOG.level_statement,
14054         module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14055         message  => 'l_two_part_flag = ' || l_two_part_flag
14056                     || ' l_technical_lock_status = ' || l_technical_lock_status
14057                     || ' l_technical_evaluation_status = ' || l_technical_evaluation_status
14058                     || ' l_commercial_lock_status = ' || l_commercial_lock_status
14059                     || ' l_auction_status = ' || l_auction_status
14060                     || ' l_auction_trading_partner_id = ' || l_auction_trading_partner_id
14061                     || ' l_auction_status2 = ' || l_auction_status2
14062                     || ' l_award_status = ' || l_award_status
14063             );
14064     END IF;
14065 
14066     -- buyer or supplier?
14067     if p_user_trading_partner_id = l_auction_trading_partner_id then
14068       l_is_buyer := true;
14069     else l_is_buyer := false;
14070     end if;
14071 
14072     -- if it is not a two part flag,
14073     IF l_two_part_flag <> 'Y'
14074         -- or two-part rfq with technical status locked
14075         OR l_technical_lock_status = 'LOCKED'
14076         -- or two-part for supplier with commercial part not locked
14077         OR (not l_is_buyer and l_commercial_lock_status <> 'LOCKED')
14078         -- or it is not closed yet
14079         OR l_auction_status <> 'CLOSED'
14080         -- or the award scenario is saved i.e award process has started
14081         -- or the award status is Completed
14082         -- or the award status is Qualified
14083         -- Note: though we need not check for the QUALIFIED because it's used only
14084         -- for RFIs, I add it here for readability
14085         OR l_award_status in ('AWARDED', 'PARTIAL', 'COMPLETED', 'QUALIFIED')
14086         -- or if the RFQ is cancelled
14087         OR (l_auction_status2 in ('CANCELLED') and l_commercial_lock_status in ('ACTIVE','UNLOCKED') )
14088 
14089     THEN --{
14090       -- comes here when we should show the status old style.
14091       -- check if it is buyer
14092       IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14093         FND_LOG.string(log_level => FND_LOG.level_statement,
14094           module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14095           message  => 'Old style status has to be shown for this auction'
14096               );
14097       END IF;
14098 
14099       IF (l_is_buyer) THEN
14100 
14101           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14102             FND_LOG.string(log_level => FND_LOG.level_statement,
14103               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14104               message  => '1. Buyer Status'
14105                   );
14106           END IF;
14107 
14108         DECLARE
14109           l_buyer_meaning fnd_lookups.meaning%type;
14110           l_buyer_sealed_meaning fnd_lookups.meaning%type;
14111 
14112         BEGIN
14113           SELECT fl.meaning,
14114                  nvl2(pav.sealed_auction_status,
14115                       ' (' ||
14116                               (select meaning
14117                               from fnd_lookups
14118                               where lookup_type = 'PON_SEALED_AUCTION_STATUS'
14119                               and (
14120                                   (nvl(pav.two_part_flag, 'N') <> 'Y' and lookup_code = pav.sealed_auction_status)
14121                                   or lookup_code = pav.technical_lock_status))
14122                        ||')', '')
14123           INTO l_buyer_meaning, l_buyer_sealed_meaning
14124           FROM fnd_lookups fl, pon_auction_headers_all_v pav
14125           WHERE pav.auction_header_id = p_auction_header_id
14126             AND fl.lookup_type = 'PON_AUCTION_STATUS'
14127             AND fl.lookup_code = pav.negotiation_status;
14128 
14129           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14130             FND_LOG.string(log_level => FND_LOG.level_statement,
14131               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14132               message  => 'l_buyer_meaning : ' || l_buyer_meaning
14133                           || '; l_buyer_sealed_meaning = ' || l_buyer_sealed_meaning
14134                   );
14135           END IF;
14136           -- set up message
14137           l_message := l_buyer_meaning || l_buyer_sealed_meaning;
14138 
14139           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14140             FND_LOG.string(log_level => FND_LOG.level_statement,
14141               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14142               message  => 'l_message : ' || l_message
14143                   );
14144           END IF;
14145 
14146         END;
14147 
14148       -- not a buyer, generate message for supplier
14149       ELSE
14150 
14151           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14152             FND_LOG.string(log_level => FND_LOG.level_statement,
14153               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14154               message  => '3. Supplier Status'
14155                   );
14156           END IF;
14157 
14158         DECLARE
14159           l_supp_meaning fnd_lookups.meaning%type;
14160           l_supp_sealed_meaning fnd_lookups.meaning%type;
14161 
14162         BEGIN
14163           SELECT fl.meaning, nvl2(pav.sealed_auction_status,
14164                               ' (' || (select meaning
14165                               from fnd_lookups
14166                               where lookup_type = 'PON_SEALED_AUCTION_STATUS'
14167                               and (
14168                                   (nvl(pav.two_part_flag, 'N') <> 'Y' and lookup_code = pav.sealed_auction_status)
14169                                   or lookup_code = decode(pav.sealed_auction_status, 'UNLOCKED', pav.sealed_auction_status,pav.technical_lock_status)) )
14170                               ||')', '')
14171           INTO l_supp_meaning, l_supp_sealed_meaning
14172           FROM fnd_lookups fl, pon_auction_headers_all_v pav
14173           WHERE pav.auction_header_id = p_auction_header_id
14174             AND fl.lookup_type = 'PON_AUCTION_STATUS'
14175             AND fl.lookup_code = pav.suppl_negotiation_status;
14176 
14177           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14178             FND_LOG.string(log_level => FND_LOG.level_statement,
14179               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14180               message  => 'l_supp_meaning : ' || l_supp_meaning
14181                           || '; l_supp_sealed_meaning : ' || l_supp_sealed_meaning
14182                   );
14183           END IF;
14184 
14185           -- set up message
14186           l_message := l_supp_meaning || l_supp_sealed_meaning;
14187 
14188           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14189             FND_LOG.string(log_level => FND_LOG.level_statement,
14190               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14191               message  => '4. l_message : ' || l_message
14192                   );
14193           END IF;
14194 
14195         END;
14196 
14197       END IF;
14198     --}
14199     ELSE  -- it is a two part RFQ, conditions for new-style messages are met
14200     --{
14201 
14202       IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14203         FND_LOG.string(log_level => FND_LOG.level_statement,
14204           module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14205           message  => '5. This is a Two Part RFQ'
14206               );
14207       END IF;
14208 
14209 
14210       -- get the meanings of the technical and commercial locks for use later
14211       SELECT  (SELECT meaning from fnd_lookups
14212        WHERE lookup_type = 'PON_SEALED_AUCTION_STATUS' and
14213         lookup_code = nvl(technical_lock_status,'')), --technical status
14214        (SELECT meaning from fnd_lookups
14215        WHERE lookup_type = 'PON_SEALED_AUCTION_STATUS' and
14216        lookup_code = nvl(sealed_auction_status,'')) --commercial status
14217       INTO l_technical_lock_meaning, l_commercial_lock_meaning
14218       FROM pon_auction_headers_all
14219       WHERE auction_header_id = p_auction_header_id;
14220 
14221       IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14222         FND_LOG.string(log_level => FND_LOG.level_statement,
14223           module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14224           message  => 'l_technical_lock_meaning : ' || l_technical_lock_meaning
14225                       || ';l_commercial_lock_meaning : ' || l_commercial_lock_meaning
14226               );
14227       END IF;
14228 
14229       -- Bug 6445077 : If the RFQ is cancelled after technically
14230       --unlocking or unsealing it, then the status has to be Cancelled (Technical Unlocked)
14231       --or Cancelled (Technical Unsealed)
14232       IF (l_auction_status2 in ('CANCELLED') ) THEN
14233 
14234         fnd_message.set_name('PON', 'PON_TWO_PART_CANCELLED');
14235 
14236         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14237             FND_LOG.string(log_level => FND_LOG.level_statement,
14238               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14239               message  => 'The auction is cancelled after technically unlocking/unsealing it');
14240         END IF;
14241 
14242         fnd_message.set_token('LOCK_STATUS', l_technical_lock_meaning);
14243         fnd_message.set_token('ROUND',get_technical_meaning);
14244 
14245         l_message := fnd_message.get;
14246 
14247       ELSE
14248 
14249               -- check if it is buyer
14250               if (l_is_buyer) then
14251 
14252                 IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14253                   FND_LOG.string(log_level => FND_LOG.level_statement,
14254                     module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14255                     message  => '6. Buyer Status '
14256                         );
14257                 END IF;
14258 
14259 
14260                 -- if auction_status is AUCTION_CLOSED and AWARD_STATUS is NO
14261                 -- it means round is completed
14262                 -- show Round Completed (Unlocked/Unsealed: Technical)
14263                 if l_auction_status2 = 'AUCTION_CLOSED' and l_award_status = 'NO' then
14264 
14265                   IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14266                     FND_LOG.string(log_level => FND_LOG.level_statement,
14267                       module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14268                       message  => 'l_auction_status2 :  '|| l_auction_status2
14269                                   ||'l_award_status :  '|| l_award_status
14270                                   ||'That is Round is complete. So showing Round Completed (Unlocked/Unsealed: Technical)'
14271                                   ||'; l_commercial_lock_status : ' || l_commercial_lock_status
14272                           );
14273                   END IF;
14274 
14275                   if l_commercial_lock_status = 'LOCKED' then
14276 
14277                     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14278                       FND_LOG.string(log_level => FND_LOG.level_statement,
14279                         module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14280                         message  => 'Auction has a commercial lock on it'
14281                             );
14282                     END IF;
14283 
14284                     fnd_message.set_name('PON', 'PON_TWO_PART_ROUNDCOMP');
14285                     fnd_message.set_token('SEALED_STATUS', l_technical_lock_meaning);
14286                     fnd_message.set_token('ROUND',get_technical_meaning);
14287                     l_message := fnd_message.get;
14288 
14289                     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14290                       FND_LOG.string(log_level => FND_LOG.level_statement,
14291                         module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14292                         message  => '7. l_message : '|| l_message
14293                             );
14294                     END IF;
14295 
14296                   else
14297                        fnd_message.set_name('PON', 'PON_AUC_ROUNDCOMP');
14298                       l_message := fnd_message.get || ' (' || l_commercial_lock_meaning || ')';
14299 
14300                       IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14301                         FND_LOG.string(log_level => FND_LOG.level_statement,
14302                           module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14303                           message  => '8. l_message : '|| l_message
14304                               );
14305                       END IF;
14306 
14307                   end if;
14308                       -- if technical evaluation is complete,
14309                       elsif l_technical_evaluation_status = 'COMPLETED' and l_commercial_lock_status = 'LOCKED' then
14310 
14311                         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14312                           FND_LOG.string(log_level => FND_LOG.level_statement,
14313                             module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14314                             message  => 'Technical evaluation is completed and the commercial lock is still on'
14315                                 );
14316                         END IF;
14317 
14318                         -- show Evaluation Complete: Technical
14319                         fnd_message.set_name('PON', 'PON_EVALUATION_COMPLETE');
14320                         --fnd_message.set_token('EVALUATION_COMPLETE', eval_complete_meaning);
14321                         fnd_message.set_token('ROUND',get_technical_meaning);
14322                         l_message := fnd_message.get;
14323 
14324                         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14325                           FND_LOG.string(log_level => FND_LOG.level_statement,
14326                             module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14327                             message  => '9. l_message : ' ||l_message
14328                                 );
14329                         END IF;
14330 
14331 
14332                       -- technical evaluation is in progress, check commercial seal status
14333                       elsif l_commercial_lock_status = 'LOCKED' then
14334 
14335                         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14336                           FND_LOG.string(log_level => FND_LOG.level_statement,
14337                             module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14338                             message  => 'Technical evaluation is in progress  and the commercial lock is still on'
14339                                 );
14340                         END IF;
14341 
14342                         if l_technical_lock_status = 'ACTIVE' then
14343 
14344                           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14345                             FND_LOG.string(log_level => FND_LOG.level_statement,
14346                               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14347                               message  => 'Technical lock status is ACTIVE'
14348                                   );
14349                           END IF;
14350 
14351                           -- show Evaluation in Progress: Technical (Unsealed)
14352                           fnd_message.set_name('PON','PON_EVALUATION_IN_PROGRESS');
14353                           --fnd_message.set_token('EVALUATION_IN_PROGRESS',eval_in_prog_meaning);
14354                           fnd_message.set_token('ROUND',get_technical_meaning);
14355                           --fnd_message.set_token('SEALED_AUCTION_STATUS', l_commercial_lock_meaning);
14356                           l_message := fnd_message.get || ' (' || l_technical_lock_meaning || ')';
14357 
14358                           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14359                             FND_LOG.string(log_level => FND_LOG.level_statement,
14360                               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14361                               message  => '10. l_message : ' || l_message
14362                                   );
14363                           END IF;
14364 
14365                         else  -- technical unlocked, commercial locked
14366                           -- show Evaluation in Progress: Technical
14367                           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14368                             FND_LOG.string(log_level => FND_LOG.level_statement,
14369                               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14370                               message  => 'Technical unclocked but commercially locked '
14371                                   );
14372                           END IF;
14373 
14374                           fnd_message.set_name('PON', 'PON_EVALUATION_IN_PROGRESS');
14375                           --fnd_message.set_token('EVALUATION_IN_PROGRESS', eval_in_prog_meaning);
14376                           fnd_message.set_token('ROUND',get_technical_meaning);
14377                           l_message := fnd_message.get;
14378 
14379                           IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14380                             FND_LOG.string(log_level => FND_LOG.level_statement,
14381                               module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14382                               message  => '11. l_message : ' ||l_message
14383                                   );
14384                           END IF;
14385 
14386                         end if;
14387 
14388                       -- commercial part unlocked
14389                       elsif l_commercial_lock_status = 'UNLOCKED' then
14390                         -- show Evaluation in Progress: Commercial
14391 
14392                         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14393                           FND_LOG.string(log_level => FND_LOG.level_statement,
14394                             module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14395                             message  => 'commercial part unlocked'
14396                                 );
14397                         END IF;
14398 
14399                         fnd_message.set_name('PON', 'PON_EVALUATION_IN_PROGRESS');
14400                         --fnd_message.set_token('EVALUATION_IN_PROGRESS', eval_in_prog_meaning);
14401                         fnd_message.set_token('ROUND',get_commercial_meaning);
14402                         l_message := fnd_message.get;
14403 
14404                         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14405                           FND_LOG.string(log_level => FND_LOG.level_statement,
14406                             module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14407                             message  => '12. l_message'
14408                                 );
14409                         END IF;
14410 
14411                 -- commercial part unsealed
14412                       else
14413                   -- if auction_status is AUCTION_CLOSED and AWARD_STATUS is NO
14414                   -- it means round is completed
14415                   -- show Round Completed (Unsealed)
14416                         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14417                           FND_LOG.string(log_level => FND_LOG.level_statement,
14418                             module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14419                             message  => 'commercial unsealed ; Auction Statuses : '||
14420                             'l_auction_status2 ' || l_auction_status2 || '; l_award_status : ' || l_award_status
14421                             );
14422                         END IF;
14423 
14424                         -- show Evaluation in Progress: Commercial (Unsealed)
14425                         fnd_message.set_name('PON', 'PON_EVALUATION_IN_PROGRESS');
14426                         --fnd_message.set_token('EVALUATION_IN_PROGRESS', eval_in_prog_meaning);
14427                         fnd_message.set_token('ROUND',get_commercial_meaning);
14428                         l_message := fnd_message.get || ' (' || l_commercial_lock_meaning || ')';
14429 
14430                         IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14431                           FND_LOG.string(log_level => FND_LOG.level_statement,
14432                             module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14433                             message  => 'l_message : ' || l_message);
14434                         END IF;
14435 
14436                       end if;
14437 
14438               -- is a supplier
14439               else
14440 
14441                   IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14442                     FND_LOG.string(log_level => FND_LOG.level_statement,
14443                       module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14444                       message  => '14. Supplier Status');
14445                   END IF;
14446 
14447                 declare
14448                   l_closed_meaning VARCHAR2(30);
14449                 begin
14450                   -- show Closed (Unlocked: Technical) or Closed (Unsealed: Technical)
14451                   fnd_message.set_name('PON','PON_AUC_CLOSED_ROUND');
14452                   --fnd_message.set_token('CLOSED', l_closed_meaning);
14453                   fnd_message.set_token('SEALED_STATUS',l_technical_lock_meaning);
14454                   fnd_message.set_token('ROUND',get_technical_meaning);
14455                   l_message := fnd_message.get;
14456 
14457                   IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14458                     FND_LOG.string(log_level => FND_LOG.level_statement,
14459                       module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14460                       message  => '15. l_message  : ' || l_message );
14461                   END IF;
14462 
14463                 END;
14464               END IF; -- if  is_buyer
14465     --}
14466       END IF;
14467 
14468     END IF;
14469 
14470     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14471       FND_LOG.string(log_level => FND_LOG.level_statement,
14472         module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14473         message  => 'Returning l_message : ' || l_message );
14474     END IF;
14475 
14476     return l_message;
14477 
14478   EXCEPTION
14479     WHEN OTHERS THEN
14480 
14481       IF (FND_LOG.level_unexpected>= FND_LOG.g_current_runtime_level) THEN
14482         FND_LOG.string(log_level => FND_LOG.level_unexpected,
14483           module  =>  g_module_prefix || 'GET_AUCTION_STATUS_DISPLAY',
14484           message  => 'Exception encountered for auction : ' || p_auction_header_id
14485                       ||'and p_user_trading_partner_id : ' || p_user_trading_partner_id
14486                       ||' Returning l_message : ' || l_message);
14487       END IF;
14488       return l_message;
14489 
14490 END GET_AUCTION_STATUS_DISPLAY;
14491 
14492 
14493 PROCEDURE GET_MONITOR_IMAGE_AND_STATUS(
14494       p_auction_header_id     IN NUMBER,
14495       p_doctype_id IN NUMBER,
14496       p_bid_visibility         IN VARCHAR2,
14497       p_sealed_auction_status  IN VARCHAR2,
14498       p_auctioneer_id          IN NUMBER,
14499       p_viewer_id              IN NUMBER,
14500       p_has_items              IN VARCHAR2,
14501       p_doc_type               IN VARCHAR2,
14502       p_auction_status         IN VARCHAR2,
14503       p_view_by_date           IN DATE,
14504       p_open_bidding_date      IN DATE,
14505       p_has_scoring_teams_flag IN VARCHAR2,
14506       p_user_trading_partner_id IN NUMBER,
14507       x_buyer_monitor_image OUT NOCOPY VARCHAR2,
14508       x_auction_status_display OUT NOCOPY VARCHAR2)
14509 AS
14510 BEGIN
14511 
14512     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14513       FND_LOG.string(log_level => FND_LOG.level_statement,
14514         module  =>  g_module_prefix || 'GET_MONITOR_IMAGE_AND_STATUS',
14515         message  => 'Entering the function with params --'
14516                     || 'p_auction_header_id = ' || p_auction_header_id
14517                     || ';p_doctype_id = ' || p_doctype_id
14518                     || ';p_bid_visibility = ' || p_bid_visibility
14519                     || ';p_sealed_auction_status = ' || p_sealed_auction_status
14520                     || ';p_auctioneer_id = ' || p_auctioneer_id
14521                     || ';p_viewer_id = ' || p_viewer_id
14522                     || ';p_has_items = ' || p_has_items
14523                     || ';p_doc_type = ' || p_doc_type
14524                     || ';p_auction_status = ' || p_auction_status
14525                     || ';p_view_by_date = ' || p_view_by_date
14526                     || ';p_open_bidding_date = ' || p_open_bidding_date
14527                     || ';p_has_scoring_teams_flag = ' || p_has_scoring_teams_flag
14528                     || ';p_user_trading_partner_id = ' || p_user_trading_partner_id
14529             );
14530     END IF;
14531 
14532     x_buyer_monitor_image := PON_OA_UTIL_PKG.BUYER_MONITOR_IMAGE (p_doctype_id,
14533               p_bid_visibility         ,
14534               p_sealed_auction_status  ,
14535               p_auctioneer_id          ,
14536               p_viewer_id              ,
14537               p_has_items              ,
14538               p_doc_type               ,
14539               p_auction_status         ,
14540               p_view_by_date           ,
14541               p_open_bidding_date      ,
14542               p_auction_header_id     ,
14543               p_has_scoring_teams_flag);
14544 
14545 
14546     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14547       FND_LOG.string(log_level => FND_LOG.level_statement,
14548         module  =>  g_module_prefix || 'GET_MONITOR_IMAGE_AND_STATUS',
14549         message  => 'x_buyer_monitor_image = ' || x_buyer_monitor_image);
14550     END IF;
14551 
14552     x_auction_status_display := GET_AUCTION_STATUS_DISPLAY(p_auction_header_id,
14553                       p_user_trading_partner_id);
14554 
14555     IF (FND_LOG.level_statement>= FND_LOG.g_current_runtime_level) THEN
14556       FND_LOG.string(log_level => FND_LOG.level_statement,
14557         module  =>  g_module_prefix || 'GET_MONITOR_IMAGE_AND_STATUS',
14558         message  => 'x_auction_status_display = ' || x_auction_status_display);
14559     END IF;
14560 
14561   EXCEPTION
14562     WHEN OTHERS THEN
14563 
14564       IF (FND_LOG.level_unexpected>= FND_LOG.g_current_runtime_level) THEN
14565         FND_LOG.string(log_level => FND_LOG.level_unexpected,
14566           module  =>  g_module_prefix || 'GET_MONITOR_IMAGE_AND_STATUS',
14567           message  => 'Exception encountered for auction : ' || p_auction_header_id);
14568       END IF;
14569 
14570 END GET_MONITOR_IMAGE_AND_STATUS;
14571 
14572 --========================================================================
14573 -- PROCEDURE : GET_SUPPL_NEGOTIATION_STATUS
14574 -- PARAMETERS:
14575 --             p_auction_status - The auction_status column
14576 --             p_is_paused - is_paused column
14577 --             p_view_by_date - view_by_date column
14578 --             p_open_bidding_date - open_bidding_date column
14579 --             p_close_bidding_date - close_bidding_date column
14580 --
14581 -- COMMENT   : This procedure will be used in the pon_auction_headers_all_v
14582 --             view to get the value for the suppl_negotiation_status
14583 --             column in the view. Prior to the use of this function the
14584 --             same code existed as decodes in the view itself.
14585 --========================================================================
14586 FUNCTION GET_SUPPL_NEGOTIATION_STATUS (
14587   p_auction_status IN VARCHAR2,
14588   p_is_paused IN VARCHAR2,
14589   p_view_by_date IN DATE,
14590   p_open_bidding_date IN DATE,
14591   p_close_bidding_date IN DATE
14592 ) RETURN VARCHAR2 IS -- {
14593 
14594 l_module_name VARCHAR2(40) := 'GET_SUPPL_NEGOTIATION_STATUS';
14595 l_return_value VARCHAR2(40);
14596 
14597 BEGIN
14598 
14599   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14600     FND_LOG.string(log_level => FND_LOG.level_statement,
14601       module  =>  g_module_prefix || l_module_name,
14602       message  => 'Entered procedure with p_auction_status = ' ||
14603                   p_auction_status || ', p_is_paused = ' || p_is_paused
14604                   || ', p_view_by_date = ' || p_view_by_date ||
14605                   ', p_open_bidding_date = ' || p_open_bidding_date ||
14606                   ', p_close_bidding_date = ' || p_close_bidding_date);
14607   END IF; --}
14608 
14609   IF (p_auction_status = 'CANCELLED') THEN -- {
14610     l_return_value := 'CANCELLED';
14611   ELSIF (p_auction_status = 'AMENDED') THEN
14612     l_return_value := 'AMENDED';
14613   ELSIF (p_auction_status = 'DRAFT') THEN
14614     l_return_value := 'DRAFT';
14615   ELSIF (nvl (p_is_paused, 'N') = 'Y') THEN
14616     l_return_value := 'PAUSED';
14617   ELSIF (sign (nvl (p_view_by_date, p_open_bidding_date) - sysdate) = 1) THEN
14618     l_return_value := 'SUBMITTED';
14619   ELSIF (sign (p_open_bidding_date - sysdate) = 1) THEN
14620     l_return_value := 'PREVIEW';
14621   ELSIF (sign (p_close_bidding_date - sysdate) = 1) THEN
14622     l_return_value := 'ACTIVE';
14623   ELSE
14624     l_return_value := 'CLOSED';
14625   END IF; --}
14626 
14627   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14628     FND_LOG.string(log_level => FND_LOG.level_statement,
14629       module  =>  g_module_prefix || l_module_name,
14630       message  => 'Returning value = ' || l_return_value);
14631   END IF; --}
14632 
14633   RETURN l_return_value;
14634 
14635 END; -- }
14636 
14637 --========================================================================
14638 -- PROCEDURE : GET_NEGOTIATION_STATUS
14639 -- PARAMETERS:
14640 --             p_auction_status - The auction_status column
14641 --             p_is_paused - is_paused column
14642 --             p_view_by_date - view_by_date column
14643 --             p_open_bidding_date - open_bidding_date column
14644 --             p_close_bidding_date - close_bidding_date column
14645 --             p_award_status - award_status column
14646 --             p_award_approval_status - award_approval_status column
14647 --             p_outcome_status - outcome_status column
14648 --
14649 -- COMMENT   : This procedure will be used in the pon_auction_headers_all_v
14650 --             view to get the value for the negotiation_status
14651 --             column in the view. Prior to the use of this function the
14652 --             same code existed as decodes in the view itself.
14653 --========================================================================
14654 FUNCTION GET_NEGOTIATION_STATUS (
14655   p_auction_status VARCHAR2,
14656   p_is_paused VARCHAR2,
14657   p_view_by_date DATE,
14658   p_open_bidding_date DATE,
14659   p_close_bidding_date DATE,
14660   p_award_status VARCHAR2,
14661   p_award_approval_status VARCHAR2,
14662   p_outcome_status VARCHAR2
14663 ) RETURN VARCHAR2 IS -- {
14664 
14665 l_module_name VARCHAR2(40) := 'GET_NEGOTIATION_STATUS';
14666 l_return_value VARCHAR2(40);
14667 
14668 BEGIN
14669 
14670   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14671     FND_LOG.string(log_level => FND_LOG.level_statement,
14672       module  =>  g_module_prefix || l_module_name,
14673       message  => 'Entered with p_auction_status = ' || p_auction_status ||
14674                   ', p_is_paused = ' || p_is_paused || ', p_view_by_date = ' ||
14675                   p_view_by_date || ', p_open_bidding_date = ' || p_open_bidding_date
14676                   || ', p_close_bidding_date = ' || p_close_bidding_date ||
14677 		  'p_award_approval_status = ' || p_award_approval_status ||
14678 		  'p_award_status = ' || p_award_status || ', p_outcome_status = '
14679                   || p_outcome_status);
14680   END IF; --}
14681 
14682   IF (p_auction_status = 'CANCELLED') THEN -- {
14683     l_return_value :=  'CANCELLED';
14684   ELSIF (p_auction_status = 'AMENDED') THEN
14685     l_return_value :=  'AMENDED';
14686   ELSIF (p_auction_status = 'DRAFT') THEN
14687     l_return_value :=  'DRAFT';
14688   ELSIF (nvl (p_is_paused, 'N') = 'Y') THEN
14689     l_return_value :=  'PAUSED';
14690   ELSIF (sign (nvl (p_view_by_date, p_open_bidding_date) - sysdate) = 1) THEN
14691     l_return_value :=  'SUBMITTED';
14692   ELSIF (sign (p_open_bidding_date - sysdate) = 1) THEN
14693     l_return_value :=  'PREVIEW';
14694   ELSIF (sign (p_close_bidding_date - sysdate) = 1) THEN
14695     l_return_value :=  'ACTIVE';
14696   ELSIF (p_auction_status = 'ACTIVE') THEN
14697     IF (p_award_status = 'NO') THEN -- {
14698       IF (p_award_approval_status = 'APPROVED') THEN -- {
14699         l_return_value :=  'AWARD_APPROVED';
14700       ELSIF (p_award_approval_status = 'REJECTED') THEN
14701         l_return_value :=  'AWARD_REJECTED';
14702       ELSIF (p_award_approval_status = 'INPROCESS') THEN
14703         l_return_value :=  'AWARD_APPROVAL_INPROCESS';
14704       ELSE
14705         l_return_value :=  'CLOSED';
14706       END IF; -- }
14707     ELSIF (p_award_status = 'PARTIAL') THEN
14708       IF (p_award_approval_status = 'APPROVED') THEN -- {
14709         l_return_value :=  'AWARD_APPROVED';
14710       ELSIF (p_award_approval_status = 'REJECTED') THEN
14711         l_return_value :=  'AWARD_REJECTED';
14712       ELSIF (p_award_approval_status = 'INPROCESS') THEN
14713         l_return_value :=  'AWARD_APPROVAL_INPROCESS';
14714       ELSE
14715         l_return_value :=  'AWARD_IN_PROG';
14716       END IF; -- }
14717     ELSIF (p_award_status = 'AWARDED') THEN
14718       IF (p_award_approval_status = 'APPROVED') THEN -- {
14719         l_return_value :=  'AWARD_APPROVED';
14720       ELSIF (p_award_approval_status = 'REJECTED') THEN
14721         l_return_value :=  'AWARD_REJECTED';
14722       ELSIF (p_award_approval_status = 'INPROCESS') THEN
14723         l_return_value :=  'AWARD_APPROVAL_INPROCESS';
14724       ELSE
14725         l_return_value :=  'AWARD_IN_PROG';
14726       END IF; -- }
14727     END IF; -- }
14728   ELSIF (p_auction_status = 'AUCTION_CLOSED') THEN
14729     IF (p_award_status = 'NO') THEN -- {
14730       l_return_value :=  'ROUND_COMPLETED';
14731     ELSIF (p_award_status = 'QUALIFIED') THEN
14732       l_return_value :=  'RFI_COMPLETED';
14733     ELSIF (p_outcome_status = 'NOT_ALLOCATED') THEN
14734       l_return_value :=  'AWARD_COMPLETED';
14735     ELSIF (p_outcome_status = 'PARTIALLY_ALLOCATED') THEN
14736       l_return_value :=  'ALLOCATION_IN_PROG';
14737     ELSIF (p_outcome_status = 'ALLOCATED') THEN
14738       l_return_value :=  'ALLOCATION_IN_PROG';
14739     ELSIF (p_outcome_status = 'ALLOCATION_NOT_REQUIRED') THEN
14740       l_return_value :=  'AWARD_COMPLETED';
14741     ELSE
14742       l_return_value :=  p_outcome_status;
14743     END IF; -- }
14744   END IF; -- }
14745 
14746   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14747     FND_LOG.string(log_level => FND_LOG.level_statement,
14748       module  =>  g_module_prefix || l_module_name,
14749       message  => 'Returning ' || l_return_value);
14750   END IF; --}
14751 
14752   RETURN l_return_value;
14753 
14754 END; -- }
14755 
14756 /*============================================================================================================*
14757  * PROCEDURE : GET_DEFAULT_TIERS_INDICATOR                                                                    *
14758  * PARAMETERS:                                                                                                *
14759  *             p_contract_type - outcome of the negotiation                                                   *
14760  *             p_price_breaks_enabled - to indicate if price breaks are applicable as per po style            *
14761  *             p_qty_price_tiers_enabled - to indicate if price tiers are applicable as per neg style         *
14762  *             p_doctype_id - document type id of the negotiation                                             *
14763  *             x_price_tiers_indicator - default price tiers indicator value.                                 *
14764  *                                                                                                            *
14765  * COMMENT   : This procedure will be used in getting the default  price tier indicator value.                *
14766  *             It's used in plsql routines where new negotiation created from autocreation and renegotiation. *
14767  *             The logic is same as AuctionHeadersAllEO.getPriceTiersPoplist. Only difference is that we      *
14768  *             don't have to return the poplist here. So few conditions where default values is same can be   *
14769  *             clubbeb together.                                                                              *
14770  * ===========================================================================================================*/
14771 
14772 PROCEDURE GET_DEFAULT_TIERS_INDICATOR (
14773   p_contract_type                   IN VARCHAR2,
14774   p_price_breaks_enabled            IN VARCHAR2,
14775   p_qty_price_tiers_enabled         IN VARCHAR2,
14776   p_doctype_id                      IN NUMBER,
14777   x_price_tiers_indicator           OUT NOCOPY VARCHAR2
14778 ) IS -- {
14779 
14780 l_module_name VARCHAR2(40) := 'GET_DEFAULT_TIERS_INDICATOR';
14781 l_rfi_doctype_id   NUMBER;
14782 
14783 BEGIN
14784 
14785   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14786     FND_LOG.string(log_level => FND_LOG.level_statement,
14787       module  =>  g_module_prefix || l_module_name,
14788       message  => 'Entered with p_contract_type = ' || p_contract_type ||
14789                   ', p_price_breaks_enabled = ' || p_price_breaks_enabled || ', p_qty_price_tiers_enabled = ' ||
14790                   p_qty_price_tiers_enabled || ', p_doctype_id = ' || p_doctype_id);
14791   END IF; --}
14792 
14793   --
14794   -- To check if given doctype_id corresponds to a RFI we need to select doctype id for RFI from PON_AUC_DOCTYPES
14795   --
14796 
14797   SELECT doctype_id
14798   INTO l_rfi_doctype_id
14799   FROM PON_AUC_DOCTYPES
14800   WHERE doctype_group_name = 'REQUEST_FOR_INFORMATION';
14801 
14802   --
14803   -- Default price tiers value is Null if neg is
14804   -- 1. RFI  OR
14805   -- 2. SPO and Sourcing style does not allows quantity based tiers
14806   -- 3. BPA/CPA and Sourcing style doe not allows quantity based tiers and PO Flag disables price breaks
14807   --
14808 
14809   IF ( (p_doctype_id = l_rfi_doctype_id) OR (p_contract_type = 'STANDARD' and p_qty_price_tiers_enabled = 'N')
14810         OR (p_contract_type <> 'STANDARD' and p_qty_price_tiers_enabled = 'N' and p_price_breaks_enabled = 'N') ) THEN --{
14811 
14812         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14813           FND_LOG.string(log_level => FND_LOG.level_statement,
14814             module  =>  g_module_prefix || l_module_name,
14815             message  => '(Neg is RFI) or(SPO and Sourcing style does not allows quantity based tiers.) or ' ||
14816                          '(BPA/CPA and Sourcing style doe not allows quantity based tiers and PO Flag disables price breaks)');
14817           FND_LOG.string(log_level => FND_LOG.level_statement,
14818             module  =>  g_module_prefix || l_module_name,
14819             message  => ' Setting the default price tiers indicator as null.');
14820         END IF; --}
14821 
14822         x_price_tiers_indicator := null;
14823 
14824   -- } End of is rfi or spo ....
14825 
14826   --
14827   -- Default value is PRICE_BREAKS if
14828   -- 1. a BPA/CPA AND
14829   -- 2. PO Flag enables price breaks
14830   --
14831 
14832   ELSIF ( p_contract_type <> 'STANDARD' and p_price_breaks_enabled = 'Y') THEN --{
14833 
14834         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14835           FND_LOG.string(log_level => FND_LOG.level_statement,
14836             module  =>  g_module_prefix || l_module_name,
14837             message  => 'BPA/CPA; price breaks are enabled. Setting default value to price_breaks');
14838         END IF; --}
14839 
14840         x_price_tiers_indicator := 'PRICE_BREAKS';
14841 
14842   --} End of else if
14843 
14844   --
14845   -- Default value is NONE if
14846   -- Sourcing style allows quantity based tiers  and
14847   -- 1. a BPA/CPA AND PO Flag disables price breaks  OR
14848   -- 2. a SPO
14849   --
14850 
14851   ELSE  --{
14852 
14853         IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14854           FND_LOG.string(log_level => FND_LOG.level_statement,
14855             module  =>  g_module_prefix || l_module_name,
14856             message  => 'Price tiers are enabled and ( price breaks are disabled for BPA/CPA OR is an SPO) Setting default value to none');
14857         END IF; --}
14858 
14859         x_price_tiers_indicator := 'NONE';
14860 
14861   END IF;   --} End of else
14862 
14863   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14864     FND_LOG.string(log_level => FND_LOG.level_statement,
14865       module  =>  g_module_prefix || l_module_name,
14866       message  => 'Returning to the caller with  x_price_tiers_indicator as '|| x_price_tiers_indicator);
14867   END IF; --}
14868 
14869 END GET_DEFAULT_TIERS_INDICATOR; -- }
14870 
14871 -- adsahay: bug 6374353
14872 -- populate the two part meanings' cache
14873 procedure init_two_part_cache
14874 as
14875 begin
14876     IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN --{
14877       FND_LOG.string(log_level => FND_LOG.level_procedure,
14878         module  =>  g_module_prefix || 'init_two_part_cache',
14879         message  => 'Entered procedure init_two_part_cache');
14880     END IF; --}
14881 
14882     SELECT flv1.LANGUAGE, flv1.meaning AS technical_meaning, flv2.meaning AS commercial_meaning
14883     BULK COLLECT INTO g_two_part_cache
14884     FROM fnd_lookup_values flv1, fnd_lookup_values flv2
14885     WHERE flv1.lookup_type='PON_TWO_PART_TYPE'
14886     AND flv2.lookup_type=flv1.lookup_type
14887     AND flv1.lookup_code='TECHNICAL'
14888     AND flv2.lookup_code='COMMERCIAL'
14889     AND flv1.LANGUAGE=flv2.LANGUAGE;
14890 
14891     g_tp_cache_rec := g_two_part_cache(1); -- first time initialisation
14892 
14893     IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN --{
14894       FND_LOG.string(log_level => FND_LOG.level_procedure,
14895         module  =>  g_module_prefix || 'init_two_part_cache',
14896         message  => 'Exiting procedure init_two_part_cache');
14897     END IF; --}
14898 
14899 end init_two_part_cache;
14900 
14901 -- adsahay: bug 6374353
14902 -- update record from from cache table when needed
14903 PROCEDURE update_cache_rec
14904 AS
14905 BEGIN
14906   IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN --{
14907     FND_LOG.string(log_level => FND_LOG.level_procedure,
14908       module  =>  g_module_prefix || 'update_cache_rec',
14909       message  => 'Entered procedure update_cache_rec');
14910   END IF; --}
14911 
14912   IF (g_tp_cache_rec.language <> USERENV('LANG')) THEN -- {
14913 
14914     IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN --{
14915       FND_LOG.string(log_level => FND_LOG.level_statement,
14916         module  =>  g_module_prefix || 'update_cache_rec',
14917         message  => 'User session language is now ' || USERENV('LANG'));
14918     END IF; --}
14919 
14920     FOR i in 1..g_two_part_cache.COUNT LOOP
14921       IF (g_two_part_cache(i).language = USERENV('LANG')) THEN
14922         g_tp_cache_rec := g_two_part_cache(i);
14923         exit;        -- if we got our values, then break loop.
14924       END IF;
14925     END LOOP;
14926   END IF; -- }
14927 
14928   IF (FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level) THEN --{
14929     FND_LOG.string(log_level => FND_LOG.level_procedure,
14930       module  =>  g_module_prefix || 'update_cache_rec',
14931       message  => 'Exiting procedure update_cache_rec');
14932   END IF; --}
14933 END update_cache_rec;
14934 
14935 -------------------------------------------------------------------------------
14936 --Start of Comments
14937 -- Bug Number: 8446265
14938 --Procedure:
14939 --  GEN_PON_DSQBID_BODY
14940 --Procedure Usage:
14941 --  Bid Disqualification Message Body is being replaced with FND Message & its tokens
14942 --Parameters:
14943 --  itemtype, itemkey
14944 --IN:
14945 --  itemtype, item key
14946 --OUT:
14947 --  document
14948 --End of Comments
14949 ------------------------------------------------------------------------------
14950 PROCEDURE GEN_PON_DSQBID_BODY(p_document_id    IN VARCHAR2,
14951 			               display_type  IN VARCHAR2,
14952 			               document      IN OUT NOCOPY CLOB,
14953 			               document_type IN OUT NOCOPY VARCHAR2)
14954 IS
14955 
14956 NL              VARCHAR2(1) := fnd_global.newline;
14957 l_document      VARCHAR2(32000) := '';
14958 l_disp_type     VARCHAR2(20) := 'text/plain';
14959 l_item_type wf_items.item_type%TYPE;
14960 l_item_key  wf_items.item_key%TYPE;
14961 x_preview_date   	   DATE;
14962 x_preview_date_notspec VARCHAR2(240);
14963 x_auction_start_date   DATE;
14964 x_auction_end_date     DATE;
14965 x_disqualify_reason    varchar2(2000) := '';
14966 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
14967 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
14968 x_view_quote_url VARCHAR2(2000);
14969 x_disqualify_date    DATE;
14970 x_bid_name           VARCHAR2(10);
14971 x_staggered_close_note VARCHAR2(1000);
14972 x_timezone1_disp VARCHAR2(240);
14973 x_timezone_disp VARCHAR2(240);
14974 x_preview_date_format VARCHAR2(80);
14975 x_auction_start_date_format VARCHAR2(80);
14976 x_auction_end_date_format VARCHAR2(80);
14977 x_disqualify_date_format VARCHAR2(80);
14978 x_notification_id NUMBER;
14979 
14980 BEGIN
14981 
14982   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
14983   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
14984 
14985   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
14986                                               itemkey    => l_item_key,
14987 					                                    aname      => 'PREVIEW_DATE_TZ');
14988 
14989   IF(x_preview_date IS null) then
14990   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
14991                                               itemkey    => l_item_key,
14992 					                                    aname      => 'PREVIEW_DATE');
14993   END IF;
14994 
14995   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
14996 					                                      itemkey  => l_item_key,
14997 					                                      aname    => 'TP_TIME_ZONE1');
14998 
14999   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
15000                                                       itemkey  => l_item_key,
15001       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
15002 
15003   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15004                                                     itemkey    => l_item_key,
15005                                                     aname      => 'AUCTION_START_DATE_BIDDER');
15006 
15007   IF(x_auction_start_date IS null) then
15008   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15009                                                     itemkey    => l_item_key,
15010                                                     aname      => 'AUCTION_START_DATE');
15011   END IF;
15012 
15013 
15014   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15015                                                   itemkey    => l_item_key,
15016                                                   aname      => 'AUCTION_END_DATE_BIDDER');
15017 
15018   IF(x_auction_end_date IS null)  then
15019   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15020                                                   itemkey    => l_item_key,
15021                                                   aname      => 'AUCTION_END_DATE');
15022   END IF;
15023 
15024   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15025     					                                itemkey  => l_item_key,
15026 					                                    aname    => 'TP_TIME_ZONE');
15027 
15028   x_disqualify_reason := wf_engine.GetItemAttrText(itemtype => l_item_type,
15029 	                                                itemkey  => l_item_key,
15030 	                                                aname    => 'DISQUALIFY_REASON');
15031 
15032   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
15033                                                   itemkey  => l_item_key,
15034                                                   aname    => 'BIDDER_TP_NAME');
15035 
15036   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
15037                                                   itemkey  => l_item_key,
15038                                                   aname    => 'BIDDER_TP_ADDRESS_NAME');
15039 
15040 
15041   x_view_quote_url := wf_engine.GetItemAttrText (itemtype => l_item_type,
15042                                                 itemkey  => l_item_key,
15043                                                 aname    => 'VIEW_QUOTE_URL');
15044 
15045 
15046   x_disqualify_date := wf_engine.GetItemAttrDate (itemtype => l_item_type,
15047                                                   itemkey  => l_item_key,
15048                                                   aname    => 'BIDDER_DISQUALIFY_DATE');
15049 
15050 
15051   x_bid_name := wf_engine.GetItemAttrText (itemtype => l_item_type,
15052                                           itemkey  => l_item_key,
15053                                           aname    => 'BID');
15054 
15055   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
15056                                                       itemkey  => l_item_key,
15057                                                      aname    => 'STAGGERED_CLOSE_NOTE');
15058 
15059  x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
15060  x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
15061  x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
15062  x_disqualify_date_format:= to_char(x_disqualify_date,'Month dd, yyyy hh:mi am');
15063 
15064  --Added for Bug 10388725
15065  --Replacing &#NID in the Response Details URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
15066  Begin
15067   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
15068   AND ITEM_KEY=l_item_key
15069   AND ASSIGNED_USER IS NOT NULL
15070   AND ROWNUM<=1;
15071  EXCEPTION
15072     WHEN No_Data_Found THEN
15073       x_notification_id:=NULL;
15074     WHEN OTHERS THEN
15075       NULL;
15076  END;
15077     IF(x_notification_id IS NOT null) THEN
15078 	x_view_quote_url:=REPLACE(x_view_quote_url,'&#NID',x_notification_id);
15079     END IF;
15080 
15081 
15082  IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
15083     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
15084     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
15085     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
15086     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
15087     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
15088     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
15089     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
15090     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
15091     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_disqualify_date = ' ||x_disqualify_date_format );
15092     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'VIEW_QUOTE_URL_SUPPLIER = ' ||x_view_quote_url );
15093     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_bid_name = ' ||x_bid_name );
15094     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
15095     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_DSQBID_BODY',message  => 'x_disqualify_reason = ' ||x_disqualify_reason );
15096   END IF;
15097 
15098  IF display_type = 'text/html' THEN
15099       l_disp_type:= display_type;
15100       fnd_message.set_name('PON','PON_WF_AUC_DSQBID_HB');
15101         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15102         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15103         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15104         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15105         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15106         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15107         fnd_message.set_token('DISQUALIFY_DATE',x_disqualify_date_format);
15108         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15109         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15110         fnd_message.set_token('DISQUALIFY_REASON',x_disqualify_reason);
15111         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15112         fnd_message.set_token('BID',x_bid_name);
15113         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15114         l_document :=   l_document || NL || NL || fnd_message.get;
15115    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15116 
15117   ELSE
15118         l_disp_type:= display_type;
15119         fnd_message.set_name('PON','PON_WF_AUC_DSQBID_TB');
15120         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15121         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15122         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15123         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15124         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15125         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15126         fnd_message.set_token('DISQUALIFY_DATE',x_disqualify_date_format);
15127         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15128         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15129         fnd_message.set_token('DISQUALIFY_REASON',x_disqualify_reason);
15130         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15131         fnd_message.set_token('BID',x_bid_name);
15132         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15133         l_document :=   l_document || NL || NL || fnd_message.get;
15134    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15135   END IF;
15136 EXCEPTION
15137 WHEN OTHERS THEN
15138     RAISE;
15139 END GEN_PON_DSQBID_BODY;
15140 -------------------------------------------------------------------------------
15141 --Start of Comments
15142 -- Bug Number: 8446265
15143 --Procedure:
15144 --  GEN_PON_ARI_UNINVITED_BODY
15145 --Procedure Usage:
15146 -- Additional Round Invitation- Uninvited Participants Message Body is being replaced with FND Message & its tokens
15147 --Parameters:
15148 --  itemtype, itemkey
15149 --IN:
15150 --  itemtype, item key
15151 --OUT:
15152 --  document
15153 --End of Comments
15154 ------------------------------------------------------------------------------
15155 PROCEDURE GEN_PON_ARI_UNINVITED_BODY(p_document_id    IN VARCHAR2,
15156 			               display_type  IN VARCHAR2,
15157 			               document      IN OUT NOCOPY CLOB,
15158 			               document_type IN OUT NOCOPY VARCHAR2)
15159 IS
15160 
15161 NL              VARCHAR2(1) := fnd_global.newline;
15162 l_document      VARCHAR2(32000) := '';
15163 l_disp_type     VARCHAR2(20) := 'text/plain';
15164 l_item_type wf_items.item_type%TYPE;
15165 l_item_key  wf_items.item_key%TYPE;
15166 x_preview_date   	   DATE;
15167 x_preview_date_notspec VARCHAR2(240);
15168 x_auction_start_date   DATE;
15169 x_auction_end_date     DATE;
15170 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
15171 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
15172 x_staggered_close_note VARCHAR2(1000);
15173 x_timezone1_disp VARCHAR2(240);
15174 x_timezone_disp VARCHAR2(240);
15175 x_preview_date_format VARCHAR2(80);
15176 x_auction_start_date_format VARCHAR2(80);
15177 x_auction_end_date_format VARCHAR2(80);
15178 
15179 x_refund_supplier     VARCHAR2(2000); --bug 8613271
15180 
15181 BEGIN
15182 
15183 
15184   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
15185   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
15186 
15187 
15188   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15189                                               itemkey    => l_item_key,
15190 					                                    aname      => 'PREVIEW_DATE_TZ');
15191   IF(x_preview_date IS null) then
15192   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15193                                               itemkey    => l_item_key,
15194 					                                    aname      => 'PREVIEW_DATE');
15195   END IF;
15196 
15197 
15198   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15199 					                                      itemkey  => l_item_key,
15200 					                                      aname    => 'TP_TIME_ZONE1');
15201 
15202 
15203   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
15204                                                       itemkey  => l_item_key,
15205       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
15206 
15207 
15208   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15209                                                       itemkey    => l_item_key,
15210                                                       aname      => 'AUCTION_START_DATE_TZ');
15211 
15212   IF(x_auction_start_date IS null) then
15213   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15214                                                     itemkey    => l_item_key,
15215                                                     aname      => 'AUCTION_START_DATE');
15216   END IF;
15217 
15218   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15219                                                   itemkey    => l_item_key,
15220                                                   aname      => 'AUCTION_END_DATE_TZ');
15221   IF(x_auction_end_date IS null) then
15222   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15223                                                   itemkey    => l_item_key,
15224                                                   aname      => 'AUCTION_END_DATE');
15225   END IF;
15226 
15227 
15228   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15229     					                                 itemkey  => l_item_key,
15230 					                                     aname    => 'TP_TIME_ZONE');
15231 
15232 
15233   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
15234                                                 itemkey  => l_item_key,
15235                                                 aname    => 'BIDDER_TP_NAME');
15236 
15237 
15238   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
15239                                                         itemkey  => l_item_key,
15240                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
15241 
15242 
15243   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
15244                                                       itemkey  => l_item_key,
15245                                                       aname    => 'STAGGERED_CLOSE_NOTE');
15246 
15247   x_refund_supplier := wf_engine.GetItemAttrText (itemtype => l_item_type,
15248                                                         itemkey  => l_item_key,
15249                                                         aname    => 'REFUND_SUPPLIER');
15250 
15251  x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
15252  x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
15253  x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
15254 
15255  IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
15256     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
15257     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
15258     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
15259     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
15260     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
15261     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
15262     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
15263     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
15264     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_PON_ARI_UNINVITED_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
15265   END IF;
15266 
15267  IF display_type = 'text/html' THEN
15268       l_disp_type:= display_type;
15269       fnd_message.set_name('PON','PON_NON_INV_NEW_RND_START_HB');
15270         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15271         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15272         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15273         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15274         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15275         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15276         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15277         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15278 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
15279         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15280         l_document :=   l_document || NL || NL || fnd_message.get;
15281    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15282 
15283   ELSE
15284         l_disp_type:= display_type;
15285         fnd_message.set_name('PON','PON_NON_INV_NEW_RND_START_TB');
15286         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15287         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15288         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15289         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15290         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15291         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15292         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15293         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15294 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
15295         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15296         l_document :=   l_document || NL || NL || fnd_message.get;
15297    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15298   END IF;
15299 EXCEPTION
15300 WHEN OTHERS THEN
15301     RAISE;
15302 END GEN_PON_ARI_UNINVITED_BODY;
15303 -------------------------------------------------------------------------------
15304 --Start of Comments
15305 -- Bug Number: 8446265
15306 --Procedure:
15307 --  GEN_AWARD_LINES_BODY
15308 --Procedure Usage:
15309 --  Awarding-WithLines Message Body is being replaced with FND Message & its tokens
15310 --Parameters:
15311 --  itemtype, itemkey
15312 --IN:
15313 --  itemtype, item key
15314 --OUT:
15315 --  document
15316 --End of Comments
15317 -----------------------------------------------------------------------------
15318 PROCEDURE GEN_AWARD_LINES_BODY(p_document_id    IN VARCHAR2,
15319 			               display_type  IN VARCHAR2,
15320 			               document      IN OUT NOCOPY CLOB,
15321 			               document_type IN OUT NOCOPY VARCHAR2)
15322 IS
15323 
15324 NL              VARCHAR2(1) := fnd_global.newline;
15325 l_document      VARCHAR2(32000) := '';
15326 l_disp_type     VARCHAR2(20) := 'text/plain';
15327 l_item_type wf_items.item_type%TYPE;
15328 l_item_key  wf_items.item_key%TYPE;
15329 x_preview_date   	   DATE;
15330 x_preview_date_notspec VARCHAR2(240);
15331 x_auction_start_date   DATE;
15332 x_auction_end_date     DATE;
15333 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
15334 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
15335 x_view_quote_url VARCHAR2(2000);
15336 x_bid_name           VARCHAR2(10);
15337 x_staggered_close_note VARCHAR2(1000);
15338 x_timezone1_disp VARCHAR2(240);
15339 x_timezone_disp VARCHAR2(240);
15340 x_bid_id           NUMBER;
15341 x_bid_caps      VARCHAR2(10);
15342 x_note_to_supplier PON_BID_HEADERS.NOTE_TO_SUPPLIER%TYPE;
15343 x_award_date PON_AUCTION_HEADERS_ALL.AWARD_DATE%TYPE;
15344 x_number_awarded	NUMBER;
15345 x_number_rejected	NUMBER;
15346 x_preview_date_format VARCHAR2(80);
15347 x_auction_start_date_format VARCHAR2(80);
15348 x_auction_end_date_format VARCHAR2(80);
15349 x_award_date_format VARCHAR2(80);
15350 x_notification_id NUMBER;
15351 
15352 BEGIN
15353 
15354   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
15355   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
15356 
15357 
15358 
15359   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15360                                               itemkey    => l_item_key,
15361                                  				      aname      => 'PREVIEW_DATE_TZ');
15362 
15363   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15364 					                                      itemkey  => l_item_key,
15365 					                                      aname    => 'TP_TIME_ZONE1');
15366 
15367   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
15368                                                       itemkey  => l_item_key,
15369       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
15370 
15371 
15372   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15373                                                     itemkey    => l_item_key,
15374                                                     aname      => 'AUCTION_START_DATE_TZ');
15375 
15376   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15377                                                   itemkey    => l_item_key,
15378                                                   aname      => 'AUCTION_END_DATE_TZ');
15379 
15380   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15381     					                                itemkey  => l_item_key,
15382 					                                    aname    => 'TP_TIME_ZONE_AUCTION');
15383 
15384   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
15385                                                 itemkey  => l_item_key,
15386                                                 aname    => 'BIDDER_TP_NAME');
15387 
15388 
15389   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
15390                                                         itemkey  => l_item_key,
15391                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
15392 
15393 
15394   x_view_quote_url := wf_engine.GetItemAttrText (itemtype => l_item_type,
15395                                                  itemkey  => l_item_key,
15396                                                  aname    => 'VIEW_QUOTE_URL');
15397 
15398 
15399   x_bid_name := wf_engine.GetItemAttrText (itemtype => l_item_type,
15400                                            itemkey  => l_item_key,
15401                                            aname    => 'BID');
15402 
15403   x_award_date:=wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15404                                           itemkey    => l_item_key,
15405                                           aname      => 'AWARD_DATE_TZ');
15406 
15407   x_bid_id:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
15408                                         itemkey    => l_item_key,
15409                                         aname      => 'BID_ID');
15410 
15411   x_bid_caps:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
15412                                          itemkey    => l_item_key,
15413                                          aname      => 'BID_CAPS');
15414 
15415   x_note_to_supplier:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
15416                                                  itemkey    => l_item_key,
15417                                                  aname      => 'NOTE_TO_SUPPLIER');
15418 
15419   x_number_awarded:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
15420                                                  itemkey    => l_item_key,
15421                                                  aname      => 'NUMBER_AWARDED');
15422 
15423   x_number_rejected:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
15424                                                   itemkey    => l_item_key,
15425                                                   aname      => 'NUMBER_REJECTED');
15426 
15427   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
15428                                                        itemkey  => l_item_key,
15429                                                        aname    => 'STAGGERED_CLOSE_NOTE');
15430 
15431  x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
15432  x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
15433  x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
15434  x_award_date_format := to_char(x_award_date,'Month dd, yyyy hh:mi am');
15435   --Added for Bug 10388725
15436   --Replacing &#NID in the Response Details URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
15437  Begin
15438   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
15439   AND ITEM_KEY=l_item_key
15440   AND ASSIGNED_USER IS NOT NULL
15441   AND ROWNUM<=1;
15442  EXCEPTION
15443     WHEN No_Data_Found THEN
15444       x_notification_id:=NULL;
15445     WHEN OTHERS THEN
15446       NULL;
15447  END;
15448     IF(x_notification_id IS NOT null) THEN
15449 	x_view_quote_url:=REPLACE(x_view_quote_url,'&#NID',x_notification_id);
15450     END IF;
15451 
15452  IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
15453     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
15454     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
15455     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
15456     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
15457     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
15458     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
15459     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
15460     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_award_date_format = ' ||x_award_date_format );
15461     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
15462     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_bid_id = ' ||x_bid_id );
15463     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_bid_caps = ' ||x_bid_caps );
15464     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_note_to_supplier = ' ||x_note_to_supplier );
15465     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_number_rejected = ' ||x_number_rejected );
15466     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_number_awarded = ' ||x_number_awarded );
15467     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_view_quote_url = ' ||x_view_quote_url );
15468     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_LINES_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
15469   END IF;
15470 
15471  IF display_type = 'text/html' THEN
15472       l_disp_type:= display_type;
15473       fnd_message.set_name('PON','PON_AUC_WF_AWARD_L_HB');
15474         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15475         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15476         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15477         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15478         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15479         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15480         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15481         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15482         fnd_message.set_token('AWARD_DATE',x_award_date_format);
15483         fnd_message.set_token('BID_CAPS',x_bid_caps);
15484         fnd_message.set_token('BID_ID',x_bid_id);
15485         fnd_message.set_token('BID',x_bid_name);
15486         fnd_message.set_token('NUMBER_AWARDED',x_number_awarded);
15487         fnd_message.set_token('NUMBER_REJECTED',x_number_rejected);
15488         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
15489         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15490         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15491         l_document :=   l_document || NL || NL || fnd_message.get;
15492    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15493 
15494   ELSE
15495         l_disp_type:= display_type;
15496 	fnd_message.set_name('PON','PON_AUC_WF_AWARD_L_TB');
15497         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15498         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15499         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15500         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15501         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15502         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15503         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15504         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15505         fnd_message.set_token('AWARD_DATE',x_award_date_format);
15506         fnd_message.set_token('BID_CAPS',x_bid_caps);
15507         fnd_message.set_token('BID_ID',x_bid_id);
15508         fnd_message.set_token('BID',x_bid_name);
15509         fnd_message.set_token('NUMBER_AWARDED',x_number_awarded);
15510         fnd_message.set_token('NUMBER_REJECTED',x_number_rejected);
15511         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
15512         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15513         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15514         l_document :=   l_document || NL || NL || fnd_message.get;
15515    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15516   END IF;
15517 EXCEPTION
15518 WHEN OTHERS THEN
15519     RAISE;
15520 END GEN_AWARD_LINES_BODY;
15521 -------------------------------------------------------------------------------
15522 --Start of Comments
15523 -- Bug Number: 8446265
15524 --Procedure:
15525 --  GEN_AWARD_NOLINES_BODY
15526 --Procedure Usage:
15527 --  Awarding-WithoutLines Message Body is being replaced with FND Message & its tokens
15528 --Parameters:
15529 --  itemtype, itemkey
15530 --IN:
15531 --  itemtype, item key
15532 --OUT:
15533 --  document
15534 --End of Comments
15535 ------------------------------------------------------------------------------
15536 PROCEDURE GEN_AWARD_NOLINES_BODY(p_document_id    IN VARCHAR2,
15537 			               display_type  IN VARCHAR2,
15538 			               document      IN OUT NOCOPY CLOB,
15539 			               document_type IN OUT NOCOPY VARCHAR2)
15540 IS
15541 
15542 NL              VARCHAR2(1) := fnd_global.newline;
15543 l_document      VARCHAR2(32000) := '';
15544 l_disp_type     VARCHAR2(20) := 'text/plain';
15545 l_item_type wf_items.item_type%TYPE;
15546 l_item_key  wf_items.item_key%TYPE;
15547 x_preview_date   	   DATE;
15548 x_preview_date_notspec VARCHAR2(240);
15549 x_auction_start_date   DATE;
15550 x_auction_end_date     DATE;
15551 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
15552 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
15553 x_view_quote_url VARCHAR2(2000);
15554 x_bid_name           VARCHAR2(10);
15555 x_staggered_close_note VARCHAR2(1000);
15556 x_timezone1_disp VARCHAR2(240);
15557 x_timezone_disp VARCHAR2(240);
15558 x_bid_id           NUMBER;
15559 x_bid_caps      VARCHAR2(10);
15560 x_note_to_supplier PON_BID_HEADERS.NOTE_TO_SUPPLIER%TYPE;
15561 x_award_date PON_AUCTION_HEADERS_ALL.AWARD_DATE%TYPE;
15562 x_preview_date_format VARCHAR2(80);
15563 x_auction_start_date_format VARCHAR2(80);
15564 x_auction_end_date_format VARCHAR2(80);
15565 x_award_date_format VARCHAR2(80);
15566 x_notification_id NUMBER;
15567 
15568 BEGIN
15569 
15570   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
15571   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
15572 
15573 
15574   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15575                                               itemkey    => l_item_key,
15576 					                                    aname      => 'PREVIEW_DATE_TZ');
15577 
15578 
15579   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15580 					                                      itemkey  => l_item_key,
15581 					                                      aname    => 'TP_TIME_ZONE1');
15582 
15583 
15584   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
15585                                                       itemkey  => l_item_key,
15586       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
15587 
15588 
15589 
15590   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15591                                                     itemkey    => l_item_key,
15592                                                     aname      => 'AUCTION_START_DATE_TZ');
15593 
15594 
15595   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15596                                                   itemkey    => l_item_key,
15597                                                   aname      => 'AUCTION_END_DATE_TZ');
15598 
15599 
15600   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15601     					                                itemkey  => l_item_key,
15602 					                                    aname    => 'TP_TIME_ZONE_AUCTION');
15603 
15604 
15605   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
15606                                                 itemkey  => l_item_key,
15607                                                 aname    => 'BIDDER_TP_NAME');
15608 
15609 
15610   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
15611                                                         itemkey  => l_item_key,
15612                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
15613 
15614 
15615   x_view_quote_url := wf_engine.GetItemAttrText (itemtype => l_item_type,
15616                                                 itemkey  => l_item_key,
15617                                                 aname    => 'VIEW_QUOTE_URL');
15618 
15619 
15620   x_bid_name := wf_engine.GetItemAttrText (itemtype => l_item_type,
15621                                           itemkey  => l_item_key,
15622                                           aname    => 'BID');
15623 
15624 
15625   x_award_date:=wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15626                                           itemkey    => l_item_key,
15627                                           aname      => 'AWARD_DATE_TZ');
15628 
15629 
15630   x_bid_id:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
15631                                         itemkey    => l_item_key,
15632                                         aname      => 'BID_ID');
15633 
15634   x_bid_caps:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
15635                                         itemkey    => l_item_key,
15636                                         aname      => 'BID_CAPS');
15637 
15638   x_note_to_supplier:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
15639                                                 itemkey    => l_item_key,
15640                                                 aname      => 'NOTE_TO_SUPPLIER');
15641 
15642   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
15643                                                       itemkey  => l_item_key,
15644                                                      aname    => 'STAGGERED_CLOSE_NOTE');
15645 
15646  x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
15647  x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
15648  x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
15649  x_award_date_format := to_char(x_award_date,'Month dd, yyyy hh:mi am');
15650  --Added for Bug 10388725
15651  --Replacing &#NID in the Response Details URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
15652  Begin
15653   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
15654   AND ITEM_KEY=l_item_key
15655   AND ASSIGNED_USER IS NOT NULL
15656   AND ROWNUM<=1;
15657  EXCEPTION
15658     WHEN No_Data_Found THEN
15659       x_notification_id:=NULL;
15660     WHEN OTHERS THEN
15661       NULL;
15662  END;
15663     IF(x_notification_id IS NOT null) THEN
15664 	x_view_quote_url:=REPLACE(x_view_quote_url,'&#NID',x_notification_id);
15665     END IF;
15666 
15667  IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
15668     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
15669     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
15670     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
15671     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
15672     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
15673     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_award_date_format = ' ||x_award_date_format );
15674     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
15675     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
15676     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
15677     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_bid_id = ' ||x_bid_id );
15678     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_bid_caps = ' ||x_bid_caps );
15679     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_note_to_supplier = ' ||x_note_to_supplier );
15680     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_NOLINES_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
15681   END IF;
15682 
15683  IF display_type = 'text/html' THEN
15684       l_disp_type:= display_type;
15685         fnd_message.set_name('PON','PON_AUC_WF_AWARD_NL_HB');
15686         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15687         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15688         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15689         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15690         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15691         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15692         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15693         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15694         fnd_message.set_token('AWARD_DATE',x_award_date_format);
15695         fnd_message.set_token('BID_CAPS',x_bid_caps);
15696         fnd_message.set_token('BID_ID',x_bid_id);
15697         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
15698         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15699         fnd_message.set_token('BID',x_bid_name);
15700         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15701         l_document :=   l_document || NL || NL || fnd_message.get;
15702    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15703 
15704   ELSE
15705         l_disp_type:= display_type;
15706 	      fnd_message.set_name('PON','PON_AUC_WF_AWARD_NL_TB');
15707         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15708         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15709         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15710         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15711         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15712         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15713         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15714         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15715         fnd_message.set_token('AWARD_DATE',x_award_date_format);
15716         fnd_message.set_token('BID_CAPS',x_bid_caps);
15717         fnd_message.set_token('BID_ID',x_bid_id);
15718         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
15719         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15720         fnd_message.set_token('BID',x_bid_name);
15721         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15722         l_document :=   l_document || NL || NL || fnd_message.get;
15723    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15724   END IF;
15725 EXCEPTION
15726 WHEN OTHERS THEN
15727     RAISE;
15728 END GEN_AWARD_NOLINES_BODY;
15729 -------------------------------------------------------------------------------
15730 --Start of Comments
15731 -- Bug Number: 8446265
15732 --Procedure:
15733 --  GEN_AWARD_EVENT_LINES_BODY
15734 --Procedure Usage:
15735 --  Awarding-Event WithLines Message Body is being replaced with FND Message & its tokens
15736 --Parameters:
15737 --  itemtype, itemkey
15738 --IN:
15739 --  itemtype, item key
15740 --OUT:
15741 --  document
15742 --End of Comments
15743 ------------------------------------------------------------------------------
15744 
15745 PROCEDURE GEN_AWARD_EVENT_LINES_BODY(p_document_id    IN VARCHAR2,
15746 			               display_type  IN VARCHAR2,
15747 			               document      IN OUT NOCOPY CLOB,
15748 			               document_type IN OUT NOCOPY VARCHAR2)
15749 IS
15750 
15751 NL              VARCHAR2(1) := fnd_global.newline;
15752 l_document      VARCHAR2(32000) := '';
15753 l_disp_type     VARCHAR2(20) := 'text/plain';
15754 l_item_type wf_items.item_type%TYPE;
15755 l_item_key  wf_items.item_key%TYPE;
15756 x_preview_date   	   DATE;
15757 x_preview_date_notspec VARCHAR2(240);
15758 x_auction_start_date   DATE;
15759 x_auction_end_date     DATE;
15760 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
15761 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
15762 x_view_quote_url VARCHAR2(2000);
15763 x_bid_name           VARCHAR2(10);
15764 x_staggered_close_note VARCHAR2(1000);
15765 x_timezone1_disp VARCHAR2(240);
15766 x_timezone_disp VARCHAR2(240);
15767 x_bid_id           NUMBER;
15768 x_bid_caps      VARCHAR2(10);
15769 x_note_to_supplier PON_BID_HEADERS.NOTE_TO_SUPPLIER%TYPE;
15770 x_award_date PON_AUCTION_HEADERS_ALL.AWARD_DATE%TYPE;
15771 x_event_title       varchar2(80);
15772 x_number_awarded	NUMBER;
15773 x_number_rejected	NUMBER;
15774 x_preview_date_format VARCHAR2(80);
15775 x_auction_start_date_format VARCHAR2(80);
15776 x_auction_end_date_format VARCHAR2(80);
15777 x_award_date_format VARCHAR2(80);
15778 x_notification_id NUMBER;
15779 
15780 BEGIN
15781 
15782 
15783   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
15784   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
15785 
15786 
15787   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15788                                               itemkey    => l_item_key,
15789 					                                    aname      => 'PREVIEW_DATE_TZ');
15790 
15791   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15792 					                                      itemkey  => l_item_key,
15793 					                                      aname    => 'TP_TIME_ZONE1');
15794 
15795   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
15796                                                       itemkey  => l_item_key,
15797       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
15798 
15799 
15800   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15801                                                       itemkey    => l_item_key,
15802                                                       aname      => 'AUCTION_START_DATE_TZ');
15803 
15804   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15805                                                   itemkey    => l_item_key,
15806                                                   aname      => 'AUCTION_END_DATE_TZ');
15807 
15808 
15809   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
15810     					                                itemkey  => l_item_key,
15811 					                                    aname    => 'TP_TIME_ZONE_AUCTION');
15812 
15813 
15814   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
15815                                                 itemkey  => l_item_key,
15816                                                 aname    => 'BIDDER_TP_NAME');
15817 
15818 
15819   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
15820                                                         itemkey  => l_item_key,
15821                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
15822 
15823 
15824   x_view_quote_url := wf_engine.GetItemAttrText (itemtype => l_item_type,
15825                                                 itemkey  => l_item_key,
15826                                                 aname    => 'VIEW_QUOTE_URL');
15827 
15828 
15829   x_bid_name := wf_engine.GetItemAttrText (itemtype => l_item_type,
15830                                           itemkey  => l_item_key,
15831                                           aname    => 'BID');
15832 
15833   x_award_date:=wf_engine.GetItemAttrDate (itemtype   => l_item_type,
15834                                           itemkey    => l_item_key,
15835                                           aname      => 'AWARD_DATE_TZ');
15836 
15837   x_event_title:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
15838                                             itemkey    => l_item_key,
15839                                             aname      => 'EVENT_TITLE');
15840 
15841   x_bid_id:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
15842                                          itemkey    => l_item_key,
15843                                          aname      => 'BID_ID');
15844 
15845   x_bid_caps:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
15846                                          itemkey    => l_item_key,
15847                                          aname      => 'BID_CAPS');
15848 
15849   x_note_to_supplier:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
15850                                                  itemkey    => l_item_key,
15851                                                  aname      => 'NOTE_TO_SUPPLIER');
15852 
15853   -- Bug 16199497
15854    x_number_awarded:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
15855                                                   itemkey    => l_item_key,
15856                                                   aname      => 'NUMBER_AWARDED');
15857 
15858    x_number_rejected:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
15859                                                    itemkey    => l_item_key,
15860                                                    aname      => 'NUMBER_REJECTED');
15861   -- Bug 16199497 -End
15862 
15863   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
15864                                                        itemkey  => l_item_key,
15865                                                        aname    => 'STAGGERED_CLOSE_NOTE');
15866 
15867  x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
15868  x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
15869  x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
15870  x_award_date_format := to_char(x_award_date,'Month dd, yyyy hh:mi am');
15871    --Added for Bug 10388725
15872    --Replacing &#NID in the Response Details URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
15873  Begin
15874   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
15875   AND ITEM_KEY=l_item_key
15876   AND ASSIGNED_USER IS NOT NULL
15877   AND ROWNUM<=1;
15878  EXCEPTION
15879     WHEN No_Data_Found THEN
15880       x_notification_id:=NULL;
15881     WHEN OTHERS THEN
15882       NULL;
15883  END;
15884     IF(x_notification_id IS NOT null) THEN
15885 	x_view_quote_url:=REPLACE(x_view_quote_url,'&#NID',x_notification_id);
15886     END IF;
15887 
15888 
15889  IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
15890     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
15891     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
15892     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
15893     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
15894     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_award_date_format = ' ||x_award_date_format );
15895     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
15896     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_auction_end_date_format = ' ||x_auction_end_date_format );
15897     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
15898     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
15899     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_bid_id = ' ||x_bid_id );
15900     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_bid_caps = ' ||x_bid_caps );
15901     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_note_to_supplier = ' ||x_note_to_supplier );
15902     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_number_rejected = ' ||x_number_rejected );
15903     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_number_awarded = ' ||x_number_awarded );
15904     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_view_quote_url = ' ||x_view_quote_url );
15905     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_event_title = ' ||x_event_title );
15906     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_LINES_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
15907   END IF;
15908 
15909  IF display_type = 'text/html' THEN
15910       l_disp_type:= display_type;
15911       fnd_message.set_name('PON','PON_AUC_WF_AWARD_EVENT_L_HB');
15912         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15913         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15914         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15915         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15916         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15917         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15918         fnd_message.set_token('EVENT_TITLE',x_event_title);
15919         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15920         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15921         fnd_message.set_token('AWARD_DATE',x_award_date_format);
15922         fnd_message.set_token('BID_CAPS',x_bid_caps);
15923         fnd_message.set_token('BID_ID',x_bid_id);
15924         fnd_message.set_token('BID',x_bid_name);
15925         fnd_message.set_token('NUMBER_AWARDED',x_number_awarded);
15926         fnd_message.set_token('NUMBER_REJECTED',x_number_rejected);
15927         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
15928         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15929         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15930         l_document :=   l_document || NL || NL || fnd_message.get;
15931    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15932 
15933   ELSE
15934         l_disp_type:= display_type;
15935 	fnd_message.set_name('PON','PON_AUC_WF_AWARD_EVENT_L_TB');
15936         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
15937         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
15938         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
15939         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
15940         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
15941         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
15942         fnd_message.set_token('EVENT_TITLE',x_event_title);
15943         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
15944         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
15945         fnd_message.set_token('AWARD_DATE',x_award_date_format);
15946         fnd_message.set_token('BID_CAPS',x_bid_caps);
15947         fnd_message.set_token('BID_ID',x_bid_id);
15948         fnd_message.set_token('BID',x_bid_name);
15949         fnd_message.set_token('NUMBER_AWARDED',x_number_awarded);
15950         fnd_message.set_token('NUMBER_REJECTED',x_number_rejected);
15951         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
15952         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
15953         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
15954         l_document :=   l_document || NL || NL || fnd_message.get;
15955    	    WF_NOTIFICATION.WriteToClob(document, l_document);
15956   END IF;
15957 EXCEPTION
15958 WHEN OTHERS THEN
15959     RAISE;
15960 END GEN_AWARD_EVENT_LINES_BODY;
15961 -------------------------------------------------------------------------------
15962 --Start of Comments
15963 -- Bug Number: 8446265
15964 --Procedure:
15965 --  GEN_AWARD_EVENT_NOLINES_BODY
15966 --Procedure Usage:
15967 --  Awarding-Event WithoutLines Message Body is being replaced with FND Message & its tokens
15968 --Parameters:
15969 --  itemtype, itemkey
15970 --IN:
15971 --  itemtype, item key
15972 --OUT:
15973 --  document
15974 --End of Comments
15975 ------------------------------------------------------------------------------
15976 PROCEDURE GEN_AWARD_EVENT_NOLINES_BODY(p_document_id    IN VARCHAR2,
15977 			               display_type  IN VARCHAR2,
15978 			               document      IN OUT NOCOPY CLOB,
15979 			               document_type IN OUT NOCOPY VARCHAR2)
15980 IS
15981 
15982 NL              VARCHAR2(1) := fnd_global.newline;
15983 l_document      VARCHAR2(32000) := '';
15984 l_disp_type     VARCHAR2(20) := 'text/plain';
15985 l_item_type wf_items.item_type%TYPE;
15986 l_item_key  wf_items.item_key%TYPE;
15987 x_preview_date   	   DATE;
15988 x_preview_date_notspec VARCHAR2(240);
15989 x_auction_start_date   DATE;
15990 x_auction_end_date     DATE;
15991 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
15992 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
15993 x_view_quote_url VARCHAR2(2000);
15994 x_bid_name           VARCHAR2(10);
15995 x_staggered_close_note VARCHAR2(1000);
15996 x_timezone1_disp VARCHAR2(240);
15997 x_timezone_disp VARCHAR2(240);
15998 x_bid_id           NUMBER;
15999 x_bid_caps      VARCHAR2(10);
16000 x_note_to_supplier PON_BID_HEADERS.NOTE_TO_SUPPLIER%TYPE;
16001 x_award_date PON_AUCTION_HEADERS_ALL.AWARD_DATE%TYPE;
16002 x_event_title       varchar2(80);
16003 x_preview_date_format VARCHAR2(80);
16004 x_auction_start_date_format VARCHAR2(80);
16005 x_auction_end_date_format VARCHAR2(80);
16006 x_award_date_format VARCHAR2(80);
16007 x_notification_id NUMBER;
16008 
16009 BEGIN
16010 
16011   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
16012   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
16013 
16014   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16015                                               itemkey    => l_item_key,
16016 					                                    aname      => 'PREVIEW_DATE_TZ');
16017 
16018   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16019 					                                      itemkey  => l_item_key,
16020 					                                      aname    => 'TP_TIME_ZONE1');
16021 
16022   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
16023                                                       itemkey  => l_item_key,
16024       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
16025 
16026 
16027   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16028                                                       itemkey    => l_item_key,
16029                                                       aname      => 'AUCTION_START_DATE_TZ');
16030 
16031   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16032                                                   itemkey    => l_item_key,
16033                                                   aname      => 'AUCTION_END_DATE_TZ');
16034 
16035 
16036   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16037     					                                itemkey  => l_item_key,
16038 					                                    aname    => 'TP_TIME_ZONE');
16039 
16040 
16041   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
16042                                                 itemkey  => l_item_key,
16043                                                 aname    => 'BIDDER_TP_NAME');
16044 
16045 
16046   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
16047                                                         itemkey  => l_item_key,
16048                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
16049 
16050 
16051   x_view_quote_url := wf_engine.GetItemAttrText (itemtype => l_item_type,
16052                                                 itemkey  => l_item_key,
16053                                                 aname    => 'VIEW_QUOTE_URL');
16054 
16055 
16056   x_bid_name := wf_engine.GetItemAttrText (itemtype => l_item_type,
16057                                           itemkey  => l_item_key,
16058                                           aname    => 'BID');
16059 
16060   x_award_date:=wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16061                                           itemkey    => l_item_key,
16062                                           aname      => 'AWARD_DATE_TZ');
16063 
16064   x_bid_id:=wf_engine.GetItemAttrNumber (itemtype   => l_item_type,
16065                                         itemkey    => l_item_key,
16066                                         aname      => 'BID_ID');
16067 
16068   x_bid_caps:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16069                                         itemkey    => l_item_key,
16070                                         aname      => 'BID_CAPS');
16071 
16072   x_event_title:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16073                                             itemkey    => l_item_key,
16074                                             aname      => 'EVENT_TITLE');
16075 
16076   x_note_to_supplier:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16077                                                 itemkey    => l_item_key,
16078                                                 aname      => 'NOTE_TO_SUPPLIER');
16079 
16080   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
16081                                                       itemkey  => l_item_key,
16082                                                      aname    => 'STAGGERED_CLOSE_NOTE');
16083 
16084  x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
16085  x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
16086  x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
16087  x_award_date_format := to_char(x_award_date,'Month dd, yyyy hh:mi am');
16088  --Added for Bug 10388725
16089  --Replacing &#NID in the Response Details URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
16090  Begin
16091   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
16092   AND ITEM_KEY=l_item_key
16093   AND ASSIGNED_USER IS NOT NULL
16094   AND ROWNUM<=1;
16095  EXCEPTION
16096     WHEN No_Data_Found THEN
16097       x_notification_id:=NULL;
16098     WHEN OTHERS THEN
16099       NULL;
16100  END;
16101     IF(x_notification_id IS NOT null) THEN
16102 	x_view_quote_url:=REPLACE(x_view_quote_url,'&#NID',x_notification_id);
16103     END IF;
16104 
16105 
16106   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
16107     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
16108     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
16109     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
16110     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
16111     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
16112     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_auction_end_date = ' ||x_award_date_format );
16113     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
16114     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
16115     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
16116     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_bid_id = ' ||x_bid_id );
16117     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_bid_caps = ' ||x_bid_caps );
16118     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_event_title = ' ||x_event_title );
16119     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_note_to_supplier = ' ||x_note_to_supplier );
16120     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AWARD_EVENT_NOLINES_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
16121   END IF;
16122 
16123 IF display_type = 'text/html' THEN
16124       l_disp_type:= display_type;
16125       fnd_message.set_name('PON','PON_AUC_WF_AWARD_EVENT_NL_HB');
16126         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16127         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16128         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16129         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16130         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16131         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16132         fnd_message.set_token('EVENT_TITLE',x_event_title);
16133         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16134         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16135         fnd_message.set_token('AWARD_DATE',x_award_date_format);
16136         fnd_message.set_token('BID_CAPS',x_bid_caps);
16137         fnd_message.set_token('BID_ID',x_bid_id);
16138         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
16139         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
16140         fnd_message.set_token('BID',x_bid_name);
16141         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16142         l_document :=   l_document || NL || NL || fnd_message.get;
16143    	    WF_NOTIFICATION.WriteToClob(document, l_document);
16144 
16145   ELSE
16146         l_disp_type:= display_type;
16147 	fnd_message.set_name('PON','PON_AUC_WF_AWARD_EVENT_NL_TB');
16148         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16149         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16150         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16151         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16152         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16153         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16154         fnd_message.set_token('EVENT_TITLE',x_event_title);
16155         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16156         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16157         fnd_message.set_token('AWARD_DATE',x_award_date_format);
16158         fnd_message.set_token('BID_CAPS',x_bid_caps);
16159         fnd_message.set_token('BID_ID',x_bid_id);
16160         fnd_message.set_token('NOTE_TO_SUPPLIER',x_note_to_supplier);
16161         fnd_message.set_token('VIEW_QUOTE_URL_SUPPLIER',x_view_quote_url);
16162         fnd_message.set_token('BID',x_bid_name);
16163         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16164         l_document :=   l_document || NL || NL || fnd_message.get;
16165    	WF_NOTIFICATION.WriteToClob(document, l_document);
16166   END IF;
16167 EXCEPTION
16168 WHEN OTHERS THEN
16169     RAISE;
16170 END GEN_AWARD_EVENT_NOLINES_BODY;
16171 -------------------------------------------------------------------------------
16172 --Start of Comments
16173 -- Bug Number: 8446265
16174 --Procedure:
16175 --  GEN_AUC_AMEND_BODY
16176 --Procedure Usage:
16177 --  Amendment Message Body is being replaced with FND Message & its tokens
16178 --Parameters:
16179 --  itemtype, itemkey
16180 --IN:
16181 --  itemtype, item key
16182 --OUT:
16183 --  document
16184 --End of Comments
16185 ------------------------------------------------------------------------------
16186 PROCEDURE GEN_AUC_AMEND_BODY(p_document_id    IN VARCHAR2,
16187 			               display_type  IN VARCHAR2,
16188 			               document      IN OUT NOCOPY CLOB,
16189 			               document_type IN OUT NOCOPY VARCHAR2)
16190 IS
16191 
16192 NL              VARCHAR2(1) := fnd_global.newline;
16193 l_document      VARCHAR2(32000) := '';
16194 l_disp_type     VARCHAR2(20) := 'text/plain';
16195 l_item_type wf_items.item_type%TYPE;
16196 l_item_key  wf_items.item_key%TYPE;
16197 x_auction_start_date   DATE;
16198 x_auction_end_date     DATE;
16199 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
16200 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
16201 x_neg_summary_url VARCHAR2(2000);
16202 x_staggered_close_note VARCHAR2(1000);
16203 x_timezone_disp VARCHAR2(240);
16204 x_auction_start_date_format VARCHAR2(80);
16205 x_auction_end_date_format VARCHAR2(80);
16206 
16207 x_refund_supplier     VARCHAR2(2000); -- bug 8613271
16208 x_notification_id  NUMBER;
16209 BEGIN
16210 
16211   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
16212   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
16213 
16214   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16215 					                                    itemkey  => l_item_key,
16216 					                                    aname    => 'TP_TIME_ZONE');
16217 
16218   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16219                                                       itemkey    => l_item_key,
16220                                                       aname      => 'AUCTION_START_DATE_TZ');
16221   IF(x_auction_start_date IS null) then
16222   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16223                                                     itemkey    => l_item_key,
16224                                                     aname      => 'AUCTION_START_DATE');
16225   END IF;
16226 
16227 
16228   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16229                                                   itemkey    => l_item_key,
16230                                                   aname      => 'AUCTION_END_DATE_TZ');
16231   IF(x_auction_end_date IS null) then
16232   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16233                                                   itemkey    => l_item_key,
16234                                                   aname      => 'AUCTION_END_DATE');
16235   END IF;
16236 
16237   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
16238                                                 itemkey  => l_item_key,
16239                                                 aname    => 'BIDDER_TP_NAME');
16240 
16241 
16242   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
16243                                                         itemkey  => l_item_key,
16244                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
16245 
16246   x_neg_summary_url := wf_engine.GetItemAttrText (itemtype => l_item_type,
16247                                                   itemkey  => l_item_key,
16248                                                   aname    => 'NET_CHANGES_URL');
16249 
16250   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
16251                                                       itemkey  => l_item_key,
16252                                                      aname    => 'STAGGERED_CLOSE_NOTE');
16253 
16254   x_refund_supplier := wf_engine.GetItemAttrText (itemtype => l_item_type,
16255                                                         itemkey  => l_item_key,
16256                                                         aname    => 'REFUND_SUPPLIER');
16257 
16258  x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
16259  x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
16260    --Added for Bug 8664757
16261     --Replacing &#NID in the Negotiation URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
16262        Begin
16263  	   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
16264  	   AND ITEM_KEY=l_item_key
16265  	   AND ASSIGNED_USER IS NOT NULL
16266  	   AND ROWNUM<=1;
16267        EXCEPTION
16268  	     WHEN No_Data_Found THEN
16269  	       x_notification_id:=NULL;
16270  	     WHEN OTHERS THEN
16271  	       NULL;
16272 	END;
16273 
16274 	IF(x_notification_id IS NOT null) THEN
16275  	      x_neg_summary_url:=REPLACE(x_neg_summary_url,'&#NID',x_notification_id);
16276  	 END IF;
16277 
16278    IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
16279     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AUC_AMEND_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
16280     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AUC_AMEND_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
16281     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AUC_AMEND_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
16282     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AUC_AMEND_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
16283     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AUC_AMEND_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
16284     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AUC_AMEND_BODY',message  => 'x_neg_summary_url = ' ||x_neg_summary_url );
16285     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_AUC_AMEND_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
16286   END IF;
16287 
16288  IF display_type = 'text/html' THEN
16289       l_disp_type:= display_type;
16290       fnd_message.set_name('PON','PON_AMENDMENT_START_HB');
16291         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16292         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16293         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16294         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16295         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16296 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
16297         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
16298         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16299         l_document :=   l_document || NL || NL || fnd_message.get;
16300    	WF_NOTIFICATION.WriteToClob(document, l_document);
16301 
16302   ELSE
16303         l_disp_type:= display_type;
16304 	fnd_message.set_name('PON','PON_AMENDMENT_START_TB');
16305         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16306         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16307         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16308         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16309         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16310 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
16311         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
16312         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16313         l_document :=   l_document || NL || NL || fnd_message.get;
16314    	WF_NOTIFICATION.WriteToClob(document, l_document);
16315   END IF;
16316 EXCEPTION
16317 WHEN OTHERS THEN
16318     RAISE;
16319 END GEN_AUC_AMEND_BODY;
16320 -------------------------------------------------------------------------------
16321 --Start of Comments
16322 -- Bug Number: 8446265
16323 --Procedure:
16324 --  GEN_INVITE_REQ_SUPP_RESP_BODY
16325 --Procedure Usage:
16326 --  Invite Requested suppliers response Message Body is being replaced with FND Message & its tokens
16327 --Parameters:
16328 --  itemtype, itemkey
16329 --IN:
16330 --  itemtype, item key
16331 --OUT:
16332 --  document
16333 --End of Comments
16334 ------------------------------------------------------------------------------
16335 PROCEDURE GEN_INVITE_REQ_SUPP_RESP_BODY(p_document_id    IN VARCHAR2,
16336 			               display_type  IN VARCHAR2,
16337 			               document      IN OUT NOCOPY CLOB,
16338 			               document_type IN OUT NOCOPY VARCHAR2)
16339 IS
16340 
16341 NL              VARCHAR2(1) := fnd_global.newline;
16342 l_document      VARCHAR2(32000) := '';
16343 l_disp_type     VARCHAR2(20) := 'text/plain';
16344 l_item_type wf_items.item_type%TYPE;
16345 l_item_key  wf_items.item_key%TYPE;
16346 x_preview_date   	   DATE;
16347 x_preview_date_notspec VARCHAR2(240);
16348 x_auction_start_date   DATE;
16349 x_auction_end_date     DATE;
16350 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
16351 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
16352 x_ack_participation_url VARCHAR2(2000);
16353 x_neg_summary_url VARCHAR2(2000);
16354 x_staggered_close_note VARCHAR2(1000);
16355 x_timezone1_disp VARCHAR2(240);
16356 x_timezone_disp VARCHAR2(240);
16357 x_preview_date_format VARCHAR2(80);
16358 x_auction_start_date_format VARCHAR2(80);
16359 x_auction_end_date_format VARCHAR2(80);
16360 
16361 -- Bug 9309785
16362 x_auction_title            pon_auction_headers_all.auction_title%TYPE;
16363 x_doc_number               pon_auction_headers_all.document_number%TYPE;
16364 x_auction_owner_tp_name    VARCHAR2(640);
16365 x_isp_new_supplier_reg_url VARCHAR2(500);
16366 
16367 x_notification_id  NUMBER;
16368 
16369 BEGIN
16370 
16371 
16372   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
16373   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
16374 
16375   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16376                                               itemkey    => l_item_key,
16377 					                                    aname      => 'PREVIEW_DATE_TZ');
16378   IF(x_preview_date IS null) then
16379   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16380                                               itemkey    => l_item_key,
16381 					                                    aname      => 'PREVIEW_DATE');
16382   END IF;
16383 
16384   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16385 					                                      itemkey  => l_item_key,
16386 					                                      aname    => 'TP_TIME_ZONE1');
16387 
16388   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
16389                                                       itemkey  => l_item_key,
16390       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
16391 
16392 
16393   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16394                                                       itemkey    => l_item_key,
16395                                                       aname      => 'AUCTION_START_DATE_TZ');
16396   IF(x_auction_start_date IS null) then
16397   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16398                                                     itemkey    => l_item_key,
16399                                                     aname      => 'AUCTION_START_DATE');
16400   END IF;
16401 
16402   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16403                                                   itemkey    => l_item_key,
16404                                                   aname      => 'AUCTION_END_DATE_TZ');
16405   IF(x_auction_end_date IS null) then
16406   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16407                                                   itemkey    => l_item_key,
16408                                                   aname      => 'AUCTION_END_DATE');
16409   END IF;
16410 
16411 
16412   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16413     					                                itemkey  => l_item_key,
16414 					                                    aname    => 'TP_TIME_ZONE');
16415 
16416 
16417   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
16418                                                 itemkey  => l_item_key,
16419                                                 aname    => 'BIDDER_TP_NAME');
16420 
16421 
16422   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
16423                                                         itemkey  => l_item_key,
16424                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
16425 
16426 
16427   x_neg_summary_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16428                                                 itemkey    => l_item_key,
16429                                                 aname      => 'NEG_SUMMARY_URL');
16430 
16431   x_ack_participation_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16432                                                       itemkey    => l_item_key,
16433                                                       aname      => 'ACK_PARTICIPATION_URL');
16434 
16435   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
16436                                                       itemkey  => l_item_key,
16437                                                      aname    => 'STAGGERED_CLOSE_NOTE');
16438 
16439   x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
16440   x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
16441   x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
16442 
16443   -- Begin Bug 9309785
16444   x_auction_title := wf_engine.GetItemAttrText (itemtype => l_item_type,
16445                                                 itemkey  => l_item_key,
16446                                                 aname    => 'AUCTION_TITLE');
16447 
16448   x_doc_number := wf_engine.GetItemAttrText (itemtype => l_item_type,
16449                                              itemkey  => l_item_key,
16450                                              aname    => 'DOC_NUMBER');
16451 
16452   x_auction_owner_tp_name := wf_engine.GetItemAttrText (itemtype => l_item_type,
16453                                                         itemkey  => l_item_key,
16454                                                         aname    => 'PREPARER_TP_NAME');
16455 
16456   x_isp_new_supplier_reg_url := wf_engine.GetItemAttrText (itemtype => l_item_type,
16457                                                            itemkey  => l_item_key,
16458                                                            aname    => 'ISP_NEW_SUPPLIER_REG_URL');
16459   -- End Bug 9309785
16460     --Added for Bug 8664757
16461     --Replacing &#NID in the Negotiation URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
16462        Begin
16463  	   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
16464  	   AND ITEM_KEY=l_item_key
16465  	   AND ASSIGNED_USER IS NOT NULL
16466  	   AND ROWNUM<=1;
16467        EXCEPTION
16468  	     WHEN No_Data_Found THEN
16469  	       x_notification_id:=NULL;
16470  	     WHEN OTHERS THEN
16471  	       NULL;
16472 	END;
16473 
16474 	IF(x_notification_id IS NOT null) THEN
16475  	      x_neg_summary_url:=REPLACE(x_neg_summary_url,'&#NID',x_notification_id);
16476  	 END IF;
16477 
16478   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
16479     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
16480     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
16481     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
16482     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
16483     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
16484     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
16485     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
16486     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
16487     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_neg_summary_url = ' ||x_neg_summary_url );
16488     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_ack_participation_url = ' ||x_ack_participation_url );
16489     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_REQ_SUPP_RESP_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
16490   END IF;
16491 
16492 IF display_type = 'text/html' THEN
16493       l_disp_type:= display_type;
16494 
16495       -- Begin Bug 9309785
16496       -- Use a different body for Supplier Hub
16497       IF (fnd_profile.value('POS_SM_ENABLE_SPM_EXTENSION') = 'Y') THEN
16498         fnd_message.set_name('PON','PON_SM_INVITE_REQ_SUPP_RESP_HB');
16499         fnd_message.set_token('AUCTION_TITLE', x_auction_title);
16500         fnd_message.set_token('DOC_NUMBER', x_doc_number);
16501         fnd_message.set_token('PREPARER_TP_NAME',x_auction_owner_tp_name);
16502         fnd_message.set_token('ISP_NEW_SUPPLIER_REG_URL',x_isp_new_supplier_reg_url);
16503         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16504         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16505       ELSE
16506         fnd_message.set_name('PON','PON_INVITE_REQ_SUPP_RESP_HB');
16507         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16508         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16509         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16510         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16511         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16512         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16513         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16514         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16515         fnd_message.set_token('ACK_PARTICIPATION_URL',x_ack_participation_url);
16516         fnd_message.set_token('NEG_SUMMARY_URL',x_neg_summary_url);
16517         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16518       END IF;
16519       -- End Bug 9309785
16520 
16521         l_document :=   l_document || NL || NL || fnd_message.get;
16522    	    WF_NOTIFICATION.WriteToClob(document, l_document);
16523   ELSE
16524         l_disp_type:= display_type;
16525 
16526       -- Begin Bug 9309785
16527       -- Use a different body for Supplier Hub
16528       IF (fnd_profile.value('POS_SM_ENABLE_SPM_EXTENSION') = 'Y') THEN
16529         fnd_message.set_name('PON','PON_SM_INVITE_REQ_SUPP_RESP_TB');
16530         fnd_message.set_token('AUCTION_TITLE', x_auction_title);
16531         fnd_message.set_token('DOC_NUMBER', x_doc_number);
16532         fnd_message.set_token('PREPARER_TP_NAME',x_auction_owner_tp_name);
16533         fnd_message.set_token('ISP_NEW_SUPPLIER_REG_URL',x_isp_new_supplier_reg_url);
16534         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16535         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16536       ELSE
16537 	fnd_message.set_name('PON','PON_INVITE_REQ_SUPP_RESP_TB');
16538         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16539         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16540         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16541         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16542         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16543         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16544         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16545         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16546         fnd_message.set_token('ACK_PARTICIPATION_URL',x_ack_participation_url);
16547         fnd_message.set_token('NEG_SUMMARY_URL',x_neg_summary_url);
16548         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16549       END IF;
16550       -- End Bug 9309785
16551 
16552         l_document :=   l_document || NL || NL || fnd_message.get;
16553    	WF_NOTIFICATION.WriteToClob(document, l_document);
16554   END IF;
16555 EXCEPTION
16556 WHEN OTHERS THEN
16557     RAISE;
16558 END GEN_INVITE_REQ_SUPP_RESP_BODY;
16559 -------------------------------------------------------------------------------
16560 --Start of Comments
16561 -- Bug Number: 8446265
16562 --Procedure:
16563 --  GEN_INVITE_CONT_RESP_BODY
16564 --Procedure Usage:
16565 --  Invite Supplier Contact Response Message Body is being replaced with FND Message & its tokens
16566 --Parameters:
16567 --  itemtype, itemkey
16568 --IN:
16569 --  itemtype, item key
16570 --OUT:
16571 --  document
16572 --End of Comments
16573 ------------------------------------------------------------------------------
16574 PROCEDURE GEN_INVITE_CONT_RESP_BODY(p_document_id    IN VARCHAR2,
16575 			               display_type  IN VARCHAR2,
16576 			               document      IN OUT NOCOPY CLOB,
16577 			               document_type IN OUT NOCOPY VARCHAR2)
16578 IS
16579 
16580 NL              VARCHAR2(1) := fnd_global.newline;
16581 l_document      VARCHAR2(32000) := '';
16582 l_disp_type     VARCHAR2(20) := 'text/plain';
16583 l_item_type wf_items.item_type%TYPE;
16584 l_item_key  wf_items.item_key%TYPE;
16585 x_preview_date   	   DATE;
16586 x_preview_date_notspec VARCHAR2(240);
16587 x_auction_start_date   DATE;
16588 x_auction_end_date     DATE;
16589 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
16590 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
16591 x_neg_summary_url VARCHAR2(2000);
16592 x_staggered_close_note VARCHAR2(1000);
16593 x_timezone1_disp VARCHAR2(240);
16594 x_timezone_disp VARCHAR2(240);
16595 x_preview_date_format VARCHAR2(80);
16596 x_auction_start_date_format VARCHAR2(80);
16597 x_auction_end_date_format VARCHAR2(80);
16598 x_supplier_exempted_info VARCHAR2(1000);
16599 x_notification_id  NUMBER;
16600 BEGIN
16601 
16602 
16603   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
16604   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
16605 
16606   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16607                                               itemkey    => l_item_key,
16608 					                                    aname      => 'PREVIEW_DATE_TZ');
16609   IF(x_preview_date IS null) then
16610   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16611                                               itemkey    => l_item_key,
16612 					                                    aname      => 'PREVIEW_DATE');
16613   END IF;
16614 
16615   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16616 					                                      itemkey  => l_item_key,
16617 					                                      aname    => 'TP_TIME_ZONE1');
16618 
16619   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
16620                                                       itemkey  => l_item_key,
16621       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
16622 
16623 
16624   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16625                                                       itemkey    => l_item_key,
16626                                                       aname      => 'AUCTION_START_DATE_TZ');
16627   IF(x_auction_start_date IS null) then
16628    x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16629                                                     itemkey    => l_item_key,
16630                                                     aname      => 'AUCTION_START_DATE');
16631   END IF;
16632 
16633   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16634                                                   itemkey    => l_item_key,
16635                                                   aname      => 'AUCTION_END_DATE_TZ');
16636   IF(x_auction_end_date IS null) then
16637    x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16638                                                   itemkey    => l_item_key,
16639                                                   aname      => 'AUCTION_END_DATE');
16640   END IF;
16641 
16642 
16643   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16644     					                                itemkey  => l_item_key,
16645 					                                    aname    => 'TP_TIME_ZONE');
16646 
16647 
16648   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
16649                                                   itemkey  => l_item_key,
16650                                                   aname    => 'BIDDER_TP_NAME');
16651 
16652 
16653   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
16654                                                   itemkey  => l_item_key,
16655                                                   aname    => 'BIDDER_TP_ADDRESS_NAME');
16656 
16657 
16658   x_neg_summary_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16659                                                 itemkey    => l_item_key,
16660                                                 aname      => 'NEG_SUMMARY_URL');
16661 
16662   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
16663                                                       itemkey  => l_item_key,
16664                                                      aname    => 'STAGGERED_CLOSE_NOTE');
16665 
16666   x_supplier_exempted_info := wf_engine.GetItemAttrText (itemtype => l_item_type,
16667                                                       itemkey  => l_item_key,
16668                                                      aname    => 'SUPPLIER_EXEMPTED_INFO');
16669 
16670   x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
16671   x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
16672   x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
16673     --Added for Bug 8664757
16674     --Replacing &#NID in the Negotiation URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
16675        Begin
16676  	   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
16677  	   AND ITEM_KEY=l_item_key
16678  	   AND ASSIGNED_USER IS NOT NULL
16679  	   AND ROWNUM<=1;
16680        EXCEPTION
16681  	     WHEN No_Data_Found THEN
16682  	       x_notification_id:=NULL;
16683  	     WHEN OTHERS THEN
16684  	       NULL;
16685 	END;
16686 
16687 	IF(x_notification_id IS NOT null) THEN
16688  	      x_neg_summary_url:=REPLACE(x_neg_summary_url,'&#NID',x_notification_id);
16689  	 END IF;
16690 
16691   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
16692     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
16693     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
16694     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
16695     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
16696     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
16697     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
16698     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
16699     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
16700     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_neg_summary_url = ' ||x_neg_summary_url );
16701     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
16702     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_CONT_RESP_BODY',message  => 'x_supplier_exempted_info = ' ||x_supplier_exempted_info );
16703   END IF;
16704 
16705 IF display_type = 'text/html' THEN
16706       l_disp_type:= display_type;
16707         fnd_message.set_name('PON','PON_INVITE_RESPONSE_HB');
16708         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16709         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16710         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16711         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16712         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16713         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16714         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16715         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16716         fnd_message.set_token('SUPPLIER_EXEMPTED_INFO',x_supplier_exempted_info);
16717         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
16718         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16719         l_document :=   l_document || NL || NL || fnd_message.get;
16720    	    WF_NOTIFICATION.WriteToClob(document, l_document);
16721 
16722   ELSE
16723         l_disp_type:= display_type;
16724 	fnd_message.set_name('PON','PON_INVITE_RESPONSE_TB');
16725         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16726         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16727         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16728         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16729         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16730         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16731         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16732         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16733         fnd_message.set_token('SUPPLIER_EXEMPTED_INFO',x_supplier_exempted_info);
16734         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
16735         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16736         l_document :=   l_document || NL || NL || fnd_message.get;
16737    	    WF_NOTIFICATION.WriteToClob(document, l_document);
16738   END IF;
16739 EXCEPTION
16740 WHEN OTHERS THEN
16741     RAISE;
16742 END GEN_INVITE_CONT_RESP_BODY;
16743 -------------------------------------------------------------------------------
16744 --Start of Comments
16745 -- Bug Number: 8446265
16746 --Procedure:
16747 --  GEN_INVITE_ADD_CONT_RESP_BODY
16748 --Procedure Usage:
16749 --  Invite Supplier Additional Contact Response Message Body is being replaced with FND Message & its tokens
16750 --Parameters:
16751 --  itemtype, itemkey
16752 --IN:
16753 --  itemtype, item key
16754 --OUT:
16755 --  document
16756 --End of Comments
16757 ------------------------------------------------------------------------------
16758 PROCEDURE GEN_INVITE_ADD_CONT_RESP_BODY(p_document_id    IN VARCHAR2,
16759 			               display_type  IN VARCHAR2,
16760 			               document      IN OUT NOCOPY CLOB,
16761 			               document_type IN OUT NOCOPY VARCHAR2)
16762 IS
16763 
16764 NL              VARCHAR2(1) := fnd_global.newline;
16765 l_document      VARCHAR2(32000) := '';
16766 l_disp_type     VARCHAR2(20) := 'text/plain';
16767 l_item_type wf_items.item_type%TYPE;
16768 l_item_key  wf_items.item_key%TYPE;
16769 x_preview_date   	   DATE;
16770 x_preview_date_notspec VARCHAR2(240);
16771 x_auction_start_date   DATE;
16772 x_auction_end_date     DATE;
16773 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
16774 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
16775 x_neg_summary_url VARCHAR2(2000);
16776 x_ack_participation_url VARCHAR2(2000);
16777 x_isupplier_reg_url VARCHAR2(2000);
16778 x_staggered_close_note VARCHAR2(1000);
16779 x_timezone1_disp VARCHAR2(240);
16780 x_timezone_disp VARCHAR2(240);
16781 x_preview_date_format VARCHAR2(80);
16782 x_auction_start_date_format VARCHAR2(80);
16783 x_auction_end_date_format VARCHAR2(80);
16784 x_supplier_exempted_info VARCHAR2(1000);
16785 x_notification_id  NUMBER;
16786 
16787 BEGIN
16788   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
16789   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
16790 
16791   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16792                                               itemkey    => l_item_key,
16793 					                                    aname      => 'PREVIEW_DATE_TZ');
16794   IF(x_preview_date IS null) then
16795   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16796                                               itemkey    => l_item_key,
16797 					                                    aname      => 'PREVIEW_DATE');
16798   END IF;
16799 
16800   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16801 					                                      itemkey  => l_item_key,
16802 					                                      aname    => 'TP_TIME_ZONE1');
16803 
16804   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
16805                                                       itemkey  => l_item_key,
16806       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
16807 
16808 
16809   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16810                                                       itemkey    => l_item_key,
16811                                                       aname      => 'AUCTION_START_DATE_TZ');
16812   IF(x_auction_start_date IS null) then
16813   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16814                                                     itemkey    => l_item_key,
16815                                                     aname      => 'AUCTION_START_DATE');
16816   END IF;
16817 
16818   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16819                                                   itemkey    => l_item_key,
16820                                                   aname      => 'AUCTION_END_DATE_TZ');
16821   IF(x_auction_end_date IS null) then
16822   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16823                                                   itemkey    => l_item_key,
16824                                                   aname      => 'AUCTION_END_DATE');
16825   END IF;
16826 
16827 
16828   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16829     					                                itemkey  => l_item_key,
16830 					                                    aname    => 'TP_TIME_ZONE');
16831 
16832 
16833   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
16834                                                 itemkey  => l_item_key,
16835                                                 aname    => 'BIDDER_TP_NAME');
16836 
16837 
16838   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
16839                                                         itemkey  => l_item_key,
16840                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
16841 
16842 
16843   x_neg_summary_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16844                                                 itemkey    => l_item_key,
16845                                                 aname      => 'NEG_SUMMARY_URL');
16846 
16847   x_ack_participation_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16848                                                       itemkey    => l_item_key,
16849                                                       aname      => 'ACK_PARTICIPATION_URL');
16850 
16851   x_isupplier_reg_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
16852                                                   itemkey    => l_item_key,
16853                                                   aname      => 'ISP_SUPPLIER_REG_URL');
16854 
16855   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
16856                                                       itemkey  => l_item_key,
16857                                                      aname    => 'STAGGERED_CLOSE_NOTE');
16858 
16859   x_supplier_exempted_info := wf_engine.GetItemAttrText (itemtype => l_item_type,
16860                                                       itemkey  => l_item_key,
16861                                                      aname    => 'SUPPLIER_EXEMPTED_INFO');
16862 
16863   x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
16864   x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
16865   x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
16866     --Added for Bug 8664757
16867     --Replacing &#NID in the Negotiation URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
16868        Begin
16869  	   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
16870  	   AND ITEM_KEY=l_item_key
16871  	   AND ASSIGNED_USER IS NOT NULL
16872  	   AND ROWNUM<=1;
16873        EXCEPTION
16874  	     WHEN No_Data_Found THEN
16875  	       x_notification_id:=NULL;
16876  	     WHEN OTHERS THEN
16877  	       NULL;
16878 	END;
16879 
16880 	IF(x_notification_id IS NOT null) THEN
16881  	      x_neg_summary_url:=REPLACE(x_neg_summary_url,'&#NID',x_notification_id);
16882  	 END IF;
16883 
16884   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
16885     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
16886     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
16887     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
16888     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
16889     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
16890     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
16891     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
16892     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
16893     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_neg_summary_url = ' ||x_neg_summary_url );
16894     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_ack_participation_url = ' ||x_ack_participation_url );
16895     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_isupplier_reg_url = ' ||x_isupplier_reg_url );
16896     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
16897     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INVITE_ADD_CONT_RESP_BODY',message  => 'x_supplier_exempted_info = ' ||x_supplier_exempted_info );
16898   END IF;
16899 
16900 IF display_type = 'text/html' THEN
16901       l_disp_type:= display_type;
16902         fnd_message.set_name('PON','PON_INV_RESP_ADD_CONT_HB');
16903         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16904         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16905         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16906         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16907         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16908         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16909         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16910         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16911         fnd_message.set_token('SUPPLIER_EXEMPTED_INFO',x_supplier_exempted_info);
16912         fnd_message.set_token('ACK_PARTICIPATION_URL',x_ack_participation_url);
16913         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
16914         fnd_message.set_token('ISP_SUPPLIER_REG_URL',x_isupplier_reg_url);
16915         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16916         l_document :=   l_document || NL || NL || fnd_message.get;
16917    	    WF_NOTIFICATION.WriteToClob(document, l_document);
16918 
16919   ELSE
16920         l_disp_type:= display_type;
16921 	fnd_message.set_name('PON','PON_INV_RESP_ADD_CONT_TB');
16922         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
16923         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
16924         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
16925         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
16926         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
16927         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
16928         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
16929         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
16930         fnd_message.set_token('SUPPLIER_EXEMPTED_INFO',x_supplier_exempted_info);
16931         fnd_message.set_token('ACK_PARTICIPATION_URL',x_ack_participation_url);
16932         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
16933         fnd_message.set_token('ISP_SUPPLIER_REG_URL',x_isupplier_reg_url);
16934         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
16935         l_document :=   l_document || NL || NL || fnd_message.get;
16936    	    WF_NOTIFICATION.WriteToClob(document, l_document);
16937   END IF;
16938 EXCEPTION
16939 WHEN OTHERS THEN
16940     RAISE;
16941 END GEN_INVITE_ADD_CONT_RESP_BODY;
16942 -------------------------------------------------------------------------------
16943 --Start of Comments
16944 -- Bug Number: 8446265
16945 --Procedure:
16946 --  GEN_INV_NEWRND_START_BODY
16947 --Procedure Usage:
16948 --  Invite Supplier Contact New Round Message Body is being replaced with FND Message & its tokens
16949 --Parameters:
16950 --  itemtype, itemkey
16951 --IN:
16952 --  itemtype, item key
16953 --OUT:
16954 --  document
16955 --End of Comments
16956 ------------------------------------------------------------------------------
16957 PROCEDURE GEN_INV_NEWRND_START_BODY(p_document_id    IN VARCHAR2,
16958 			               display_type  IN VARCHAR2,
16959 			               document      IN OUT NOCOPY CLOB,
16960 			               document_type IN OUT NOCOPY VARCHAR2)
16961 IS
16962 
16963 NL              VARCHAR2(1) := fnd_global.newline;
16964 l_document      VARCHAR2(32000) := '';
16965 l_disp_type     VARCHAR2(20) := 'text/plain';
16966 l_item_type wf_items.item_type%TYPE;
16967 l_item_key  wf_items.item_key%TYPE;
16968 x_preview_date   	   DATE;
16969 x_preview_date_notspec VARCHAR2(240);
16970 x_auction_start_date   DATE;
16971 x_auction_end_date     DATE;
16972 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
16973 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
16974 x_neg_summary_url VARCHAR2(2000);
16975 x_staggered_close_note VARCHAR2(1000);
16976 x_timezone1_disp VARCHAR2(240);
16977 x_timezone_disp VARCHAR2(240);
16978 x_preview_date_format VARCHAR2(80);
16979 x_auction_start_date_format VARCHAR2(80);
16980 x_auction_end_date_format VARCHAR2(80);
16981 
16982 x_refund_supplier     VARCHAR2(2000); -- bug 8613271
16983 x_notification_id  NUMBER;
16984 BEGIN
16985 
16986   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
16987   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
16988 
16989   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16990                                               itemkey    => l_item_key,
16991 					                                    aname      => 'PREVIEW_DATE_TZ');
16992   IF(x_preview_date IS null) then
16993   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
16994                                               itemkey    => l_item_key,
16995 					                                    aname      => 'PREVIEW_DATE');
16996   END IF;
16997 
16998   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
16999 					                                      itemkey  => l_item_key,
17000 					                                      aname    => 'TP_TIME_ZONE1');
17001 
17002   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
17003                                                       itemkey  => l_item_key,
17004       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
17005 
17006 
17007   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17008                                                       itemkey    => l_item_key,
17009                                                       aname      => 'AUCTION_START_DATE');
17010   IF(x_auction_start_date IS null) then
17011   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17012                                                     itemkey    => l_item_key,
17013                                                     aname      => 'AUCTION_START_DATE');
17014   END IF;
17015 
17016   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17017                                                   itemkey    => l_item_key,
17018                                                   aname      => 'AUCTION_END_DATE');
17019   IF(x_auction_end_date IS null) then
17020   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17021                                                   itemkey    => l_item_key,
17022                                                   aname      => 'AUCTION_END_DATE');
17023   END IF;
17024 
17025   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
17026     					                                itemkey  => l_item_key,
17027 					                                    aname    => 'TP_TIME_ZONE');
17028 
17029 
17030   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
17031                                                 itemkey  => l_item_key,
17032                                                 aname    => 'BIDDER_TP_NAME');
17033 
17034 
17035   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
17036                                                         itemkey  => l_item_key,
17037                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
17038 
17039 
17040   x_neg_summary_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
17041                                                 itemkey    => l_item_key,
17042                                                 aname      => 'NEG_SUMMARY_URL');
17043 
17044   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
17045                                                       itemkey  => l_item_key,
17046                                                      aname    => 'STAGGERED_CLOSE_NOTE');
17047 
17048   x_refund_supplier := wf_engine.GetItemAttrText (itemtype => l_item_type,
17049                                                   itemkey  => l_item_key,
17050                                                       aname    => 'REFUND_SUPPLIER');
17051 
17052   x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
17053   x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
17054   x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
17055     --Added for Bug 8664757
17056     --Replacing &#NID in the Negotiation URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
17057        Begin
17058  	   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
17059  	   AND ITEM_KEY=l_item_key
17060  	   AND ASSIGNED_USER IS NOT NULL
17061  	   AND ROWNUM<=1;
17062        EXCEPTION
17063  	     WHEN No_Data_Found THEN
17064  	       x_notification_id:=NULL;
17065  	     WHEN OTHERS THEN
17066  	       NULL;
17067 	END;
17068 
17069 	IF(x_notification_id IS NOT null) THEN
17070  	      x_neg_summary_url:=REPLACE(x_neg_summary_url,'&#NID',x_notification_id);
17071  	 END IF;
17072 
17073   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
17074     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
17075     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
17076     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
17077     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
17078     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
17079     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
17080     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
17081     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
17082     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_neg_summary_url = ' ||x_neg_summary_url );
17083     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
17084   END IF;
17085 
17086 IF display_type = 'text/html' THEN
17087       l_disp_type:= display_type;
17088         fnd_message.set_name('PON','PON_INV_NEW_RND_START_HB');
17089         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
17090         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
17091         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
17092         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
17093         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
17094         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
17095         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
17096         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
17097 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
17098         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
17099         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
17100         l_document :=   l_document || NL || NL || fnd_message.get;
17101    	    WF_NOTIFICATION.WriteToClob(document, l_document);
17102   ELSE
17103         l_disp_type:= display_type;
17104 	fnd_message.set_name('PON','PON_INV_NEW_RND_START_TB');
17105         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
17106         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
17107         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
17108         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
17109         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
17110         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
17111         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
17112         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
17113 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
17114         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
17115         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
17116         l_document :=   l_document || NL || NL || fnd_message.get;
17117    	    WF_NOTIFICATION.WriteToClob(document, l_document);
17118   END IF;
17119 EXCEPTION
17120 WHEN OTHERS THEN
17121     RAISE;
17122 END GEN_INV_NEWRND_START_BODY;
17123 
17124 -------------------------------------------------------------------------------
17125 --Start of Comments
17126 -- Bug Number: 8446265
17127 --Procedure:
17128 --  GEN_INV_NEWRND_START_AD_BODY
17129 --Procedure Usage:
17130 --  Invite Supplier Additional Contact New Round Message Body is being replaced with FND Message & its tokens
17131 --Parameters:
17132 --  itemtype, itemkey
17133 --IN:
17134 --  itemtype, item key
17135 --OUT:
17136 --  document
17137 --End of Comments
17138 ------------------------------------------------------------------------------
17139 PROCEDURE GEN_INV_NEWRND_START_AD_BODY(p_document_id    IN VARCHAR2,
17140 			               display_type  IN VARCHAR2,
17141 			               document      IN OUT NOCOPY CLOB,
17142 			               document_type IN OUT NOCOPY VARCHAR2)
17143 IS
17144 
17145 NL              VARCHAR2(1) := fnd_global.newline;
17146 l_document      VARCHAR2(32000) := '';
17147 l_disp_type     VARCHAR2(20) := 'text/plain';
17148 l_item_type wf_items.item_type%TYPE;
17149 l_item_key  wf_items.item_key%TYPE;
17150 x_preview_date   	   DATE;
17151 x_preview_date_notspec VARCHAR2(240);
17152 x_auction_start_date   DATE;
17153 x_auction_end_date     DATE;
17154 x_bidder_tp_name       PON_BIDDING_PARTIES.TRADING_PARTNER_NAME%TYPE;
17155 x_bidder_tp_addresssname PO_VENDOR_SITES_ALL.VENDOR_SITE_CODE%TYPE;
17156 x_neg_summary_url VARCHAR2(2000);
17157 x_isupplier_reg_url VARCHAR2(2000);
17158 x_ack_participation_url VARCHAR2(2000);
17159 x_staggered_close_note VARCHAR2(1000);
17160 x_timezone1_disp VARCHAR2(240);
17161 x_timezone_disp VARCHAR2(240);
17162 x_preview_date_format VARCHAR2(80);
17163 x_auction_start_date_format VARCHAR2(80);
17164 x_auction_end_date_format VARCHAR2(80);
17165 
17166 x_refund_supplier     VARCHAR2(2000); -- bug 8613271
17167 x_notification_id  NUMBER;
17168 
17169 BEGIN
17170 
17171 
17172   l_item_type := substr(p_document_id, 1, instr(p_document_id, ':') - 1);
17173   l_item_key := substr(p_document_id, instr(p_document_id, ':') + 1, length(p_document_id));
17174 
17175   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17176                                               itemkey    => l_item_key,
17177 					                                    aname      => 'PREVIEW_DATE_TZ');
17178   IF(x_preview_date IS null) then
17179   x_preview_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17180                                               itemkey    => l_item_key,
17181 					                                    aname      => 'PREVIEW_DATE');
17182   END IF;
17183 
17184   x_timezone1_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
17185 					                                      itemkey  => l_item_key,
17186 					                                      aname    => 'TP_TIME_ZONE1');
17187 
17188   x_preview_date_notspec := wf_engine.GetItemAttrText (itemtype => l_item_type,
17189                                                       itemkey  => l_item_key,
17190       	                                              aname    => 'PREVIEW_DATE_NOTSPECIFIED');
17191 
17192 
17193   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17194                                                       itemkey    => l_item_key,
17195                                                       aname      => 'AUCTION_START_DATE_TZ');
17196   IF(x_auction_start_date IS null) then
17197   x_auction_start_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17198                                                     itemkey    => l_item_key,
17199                                                     aname      => 'AUCTION_START_DATE');
17200   END IF;
17201 
17202   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17203                                                   itemkey    => l_item_key,
17204                                                   aname      => 'AUCTION_END_DATE_TZ');
17205   IF(x_auction_end_date IS null) then
17206   x_auction_end_date := wf_engine.GetItemAttrDate (itemtype   => l_item_type,
17207                                                   itemkey    => l_item_key,
17208                                                   aname      => 'AUCTION_END_DATE');
17209   END IF;
17210 
17211   x_timezone_disp:= wf_engine.GetItemAttrText (itemtype => l_item_type,
17212     					                                itemkey  => l_item_key,
17213 					                                    aname    => 'TP_TIME_ZONE');
17214 
17215 
17216   x_bidder_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
17217                                                 itemkey  => l_item_key,
17218                                                 aname    => 'BIDDER_TP_NAME');
17219 
17220 
17221   x_bidder_tp_addresssname := wf_engine.GetItemAttrText(itemtype => l_item_type,
17222                                                         itemkey  => l_item_key,
17223                                                         aname    => 'BIDDER_TP_ADDRESS_NAME');
17224 
17225 
17226   x_neg_summary_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
17227                                                 itemkey    => l_item_key,
17228                                                 aname      => 'NEG_SUMMARY_URL');
17229 
17230   x_ack_participation_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
17231                                                       itemkey    => l_item_key,
17232                                                       aname      => 'ACK_PARTICIPATION_URL');
17233 
17234   x_isupplier_reg_url:=wf_engine.GetItemAttrText (itemtype   => l_item_type,
17235                                                   itemkey    => l_item_key,
17236                                                   aname      => 'ISP_SUPPLIER_REG_URL');
17237 
17238   x_staggered_close_note := wf_engine.GetItemAttrText (itemtype => l_item_type,
17239                                                       itemkey  => l_item_key,
17240                                                      aname    => 'STAGGERED_CLOSE_NOTE');
17241 
17242   x_refund_supplier := wf_engine.GetItemAttrText (itemtype => l_item_type,
17243                                                         itemkey  => l_item_key,
17244                                                         aname    => 'REFUND_SUPPLIER');
17245 
17246   x_preview_date_format := to_char(x_preview_date,'Month dd, yyyy hh:mi am');
17247   x_auction_start_date_format := to_char(x_auction_start_date,'Month dd, yyyy hh:mi am');
17248   x_auction_end_date_format := to_char(x_auction_end_date,'Month dd, yyyy hh:mi am');
17249     --Added for Bug 8664757
17250     --Replacing &#NID in the Negotiation URL with the actual Notification Id from WF_ITEM_ACTIVITY_STATUSES table
17251        Begin
17252  	   SELECT notification_id  INTO x_notification_id from WF_ITEM_ACTIVITY_STATUSES WHERE ITEM_TYPE=l_item_type
17253  	   AND ITEM_KEY=l_item_key
17254  	   AND ASSIGNED_USER IS NOT NULL
17255  	   AND ROWNUM<=1;
17256        EXCEPTION
17257  	     WHEN No_Data_Found THEN
17258  	       x_notification_id:=NULL;
17259  	     WHEN OTHERS THEN
17260  	       NULL;
17261 	END;
17262 
17263 	IF(x_notification_id IS NOT null) THEN
17264  	      x_neg_summary_url:=REPLACE(x_neg_summary_url,'&#NID',x_notification_id);
17265  	 END IF;
17266 
17267 
17268   IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
17269     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_preview_date = ' ||x_preview_date_format );
17270     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_timezone1_disp = ' ||x_timezone1_disp );
17271     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_preview_date_notspec = ' ||x_preview_date_notspec );
17272     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_auction_start_date = ' ||x_auction_start_date_format );
17273     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_auction_end_date = ' ||x_auction_end_date_format );
17274     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_timezone_disp = ' ||x_timezone_disp );
17275     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_bidder_tp_name = ' ||x_bidder_tp_name );
17276     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_bidder_tp_addresssname = ' ||x_bidder_tp_addresssname );
17277     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_neg_summary_url = ' ||x_neg_summary_url );
17278     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_ack_participation_url = ' ||x_ack_participation_url );
17279     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_isupplier_reg_url = ' ||x_isupplier_reg_url );
17280     FND_LOG.string (log_level => FND_LOG.level_statement,module  =>  g_module_prefix || '.GEN_INV_NEWRND_START_AD_BODY',message  => 'x_staggered_close_note = ' ||x_staggered_close_note );
17281   END IF;
17282 IF display_type = 'text/html' THEN
17283       l_disp_type:= display_type;
17284       fnd_message.set_name('PON','PON_INV_NEW_RND_START_AD_HB');
17285         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
17286         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
17287         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
17288         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
17289         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
17290         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
17291         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
17292         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
17293 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
17294         fnd_message.set_token('ACK_PARTICIPATION_URL',x_ack_participation_url);
17295         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
17296         fnd_message.set_token('ISP_SUPPLIER_REG_URL',x_isupplier_reg_url);
17297         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
17298         l_document :=   l_document || NL || NL || fnd_message.get;
17299    	    WF_NOTIFICATION.WriteToClob(document, l_document);
17300 
17301   ELSE
17302         l_disp_type:= display_type;
17303         fnd_message.set_name('PON','PON_INV_NEW_RND_START_AD_TB');
17304         fnd_message.set_token('PREVIEW_DATE',x_preview_date_format);
17305         fnd_message.set_token('TP_TIME_ZONE1',x_timezone1_disp);
17306         fnd_message.set_token('PREVIEW_DATE_NOTSPECIFIED',x_preview_date_notspec);
17307         fnd_message.set_token('AUCTION_START_DATE',x_auction_start_date_format);
17308         fnd_message.set_token('TP_TIME_ZONE',x_timezone_disp);
17309         fnd_message.set_token('AUCTION_END_DATE',x_auction_end_date_format);
17310         fnd_message.set_token('BIDDER_TP_NAME',x_bidder_tp_name);
17311         fnd_message.set_token('BIDDER_TP_ADDRESS_NAME',x_bidder_tp_addresssname);
17312 	fnd_message.set_token('REFUND_SUPPLIER',x_refund_supplier);
17313         fnd_message.set_token('ACK_PARTICIPATION_URL',x_ack_participation_url);
17314         fnd_message.set_token('NEG_SUMMARY_URL_SUPPLIER',x_neg_summary_url);
17315         fnd_message.set_token('ISP_SUPPLIER_REG_URL',x_isupplier_reg_url);
17316         fnd_message.set_token('STAGGERED_CLOSE_NOTE',x_staggered_close_note);
17317         l_document :=   l_document || NL || NL || fnd_message.get;
17318    	    WF_NOTIFICATION.WriteToClob(document, l_document);
17319   END IF;
17320 EXCEPTION
17321 WHEN OTHERS THEN
17322     RAISE;
17323 END GEN_INV_NEWRND_START_AD_BODY;
17324 
17325 
17326 -------------------------------------------------------------------------------
17327 --Start of Comments
17328 -- FBO project
17329 --Procedure:
17330 --  NOTIFY_REQUESTOR_PUBLISH
17331 --Procedure Usage:
17332 --  Call from workflow function to send notification to requestors of document publish
17333 --Parameters:
17334 --  itemtype, itemkey, actid, uncmode
17335 --IN:
17336 --  itemtype, item key, itemtype, itemkey, actid, uncmode
17337 --OUT:
17338 --  resultout
17339 --End of Comments
17340 ------------------------------------------------------------------------------
17341 
17342 PROCEDURE NOTIFY_REQUESTOR_PUBLISH(  itemtype  in varchar2,
17343                                      itemkey    in varchar2,
17344                                      actid           in number,
17345                                      uncmode    in varchar2,
17346                                      resultout       out NOCOPY varchar2) IS
17347 
17348 x_notification_id  NUMBER;
17349 x_progress    VARCHAR2(3);
17350 
17351 BEGIN
17352 
17353     EMAIL_REQUESTORS(p_itemtype    => itemtype,
17354                      p_itemkey    => itemkey,
17355                      p_actid    => actid,
17356                      p_message_name  => 'NOTIFY_REQ_PUBLISH',
17357                      p_notification_id  => x_notification_id);
17358 
17359 END;
17360 
17361 PROCEDURE EMAIL_REQUESTORS(p_itemtype      IN  VARCHAR2,
17362            p_itemkey      IN  VARCHAR2,
17363            p_actid        IN  NUMBER,
17364            p_message_name      IN  VARCHAR2,
17365            p_notification_id    OUT NOCOPY NUMBER) IS
17366 
17367 x_auction_header_id  NUMBER;
17368 x_progress     VARCHAR2(3);
17369 x_doc_number VARCHAR2(500);
17370 x_doc_amendment_number VARCHAR2(500);
17371 x_username          VARCHAR2(100);
17372 x_user_display_name VARCHAR2(240);
17373 x_pr_number VARCHAR2(500);
17374 x_doc_number_wf VARCHAR2(500);
17375 x_msg_suffix varchar2(3) := '';
17376 
17377 
17378 CURSOR preparer_list IS
17379     select prha.preparer_id
17380     from po_requisition_headers_all prha, PON_BACKING_REQUISITIONS pbr
17381     where pbr.auction_header_id = x_auction_header_id
17382     and prha.requisition_header_id = pbr.requisition_header_id;
17383 
17384 
17385 
17386 BEGIN
17387     x_auction_header_id := wf_engine.GetItemAttrNumber (itemtype => p_itemtype,
17388                                                         itemkey  => p_itemkey,
17389                                                        aname    => 'AUCTION_ID');
17390 
17391      x_doc_number := wf_engine.GetItemAttrText (itemtype => p_itemtype,
17392                                                   itemkey  => p_itemkey,
17393                                                   aname    => 'DOC_NUMBER');
17394 
17395     x_doc_amendment_number := wf_engine.GetItemAttrText (itemtype => p_itemtype,
17396                                                            itemkey  => p_itemkey,
17397                                                            aname    => 'DOC_AMENDMENT_NUMBER');
17398 
17399    select DECODE(nvl(revision,0), 0, x_doc_number, x_doc_amendment_number)
17400    into x_doc_number_wf
17401    from PON_AUCTION_HEADERS_ALL
17402    where AUCTION_HEADER_ID = x_auction_header_id;
17403 
17404     FOR preparer IN preparer_list LOOP
17405 
17406        PO_REQAPPROVAL_INIT1.get_user_name(preparer.preparer_id, x_username, x_user_display_name);
17407 
17408        p_notification_id := WF_NOTIFICATION.send(role   => x_username,
17409                  context  => p_itemtype||':'||p_itemkey||':'||to_char(p_actid),
17410                        msg_type   => 'PONAUCT',
17411                        msg_name   => p_message_name);
17412 
17413         wf_Notification.SetAttrText(p_notification_id, 'DOC_PUBLISHED_REQ_SUBJECT',
17414                                                 getMessage('PON_AUC_WF_PUBLISHED_SUB', x_msg_suffix,
17415                                                            'DOCUMENT_NUMBER', x_doc_number_wf,
17416                                                            'AUCTION_TITLE', wf_engine.GetItemAttrText (itemtype  => p_itemtype,
17417                                                                                         itemkey   => p_itemkey,
17418                                                                                         aname     =>'AUCTION_TITLE')));
17419 
17420         wf_Notification.setAttrDate(p_notification_id, 'AUCTION_START_DATE', wf_engine.GetItemAttrdate (itemtype  => p_itemtype,
17421                                                                                         itemkey   => p_itemkey,
17422                                                                                         aname     =>'AUCTION_START_DATE'));
17423 
17424         wf_Notification.setAttrDate(p_notification_id, 'AUCTION_END_DATE', wf_engine.GetItemAttrdate (itemtype  => p_itemtype,
17425                                                                                         itemkey   => p_itemkey,
17426                                                                                         aname     =>'AUCTION_END_DATE'));
17427         wf_Notification.setAttrText (p_notification_id, 'PR_NUMBER', get_all_pr_number(x_auction_header_id));
17428         wf_Notification.setAttrText(p_notification_id, 'NEG_SUMMARY_URL', wf_engine.GetItemAttrText (itemtype  => p_itemtype,
17429                                                                                         itemkey   => p_itemkey,
17430                                                                                         aname     =>'NEG_SUMMARY_URL'));
17431 
17432 
17433 
17434    END LOOP;
17435     exception when others then
17436     null;
17437 END;
17438 
17439 /*======================================================================
17440  FUNCTION:  get_all_pr_number	PUBLIC
17441    PARAMETERS: p_auction_header_id - solicitation header id
17442    COMMENT   : This function return all the requisition_header_id of specific Sourcing Documents,
17443               separate by comma.
17444 ======================================================================*/
17445 FUNCTION get_all_pr_number(p_auction_header_id IN NUMBER)
17446 RETURN VARCHAR2 IS
17447 CURSOR req_list IS
17448     select requisition_header_id
17449     from pon_backing_requisitions
17450     where auction_header_id = p_auction_header_id;
17451 
17452 l_req_all VARCHAR2(500);
17453 
17454 BEGIN
17455 
17456  FOR req IN req_list LOOP
17457       if l_req_all is null then
17458         l_req_all := req.requisition_header_id;
17459       else
17460         l_req_all := l_req_all ||', '||req.requisition_header_id;
17461       end if;
17462  END LOOP;
17463 
17464  return l_req_all;
17465 END;
17466 
17467 -- Begin Bug 8992789
17468 FUNCTION IS_INTERNAL_ONLY(p_auction_header_id NUMBER) RETURN BOOLEAN
17469 IS
17470 
17471 l_internal_only_flag VARCHAR2(1);
17472 
17473 BEGIN
17474 
17475   SELECT internal_only_flag
17476   INTO l_internal_only_flag
17477   FROM pon_auction_headers_all
17478   WHERE auction_header_id = p_auction_header_id;
17479 
17480   RETURN (l_internal_only_flag = 'Y');
17481 
17482 END IS_INTERNAL_ONLY;
17483 -- End Bug 8992789
17484 
17485 -- Begin Bug 9309785
17486 -- Function to get prospective supplier registration URL
17487 FUNCTION GET_SUPPLIER_REG_URL(p_supp_reg_id NUMBER) RETURN VARCHAR2
17488 IS
17489 
17490 l_reg_key    pos_supplier_registrations.reg_key%TYPE;
17491 
17492 CURSOR l_cur IS
17493   SELECT reg_key
17494   FROM pos_supplier_registrations
17495   WHERE supplier_reg_id = p_supp_reg_id;
17496 
17497 BEGIN
17498 
17499   OPEN l_cur;
17500   FETCH l_cur INTO l_reg_key;
17501   CLOSE l_cur;
17502 
17503   RETURN pos_url_pkg.get_external_url ||
17504          'OA_HTML/jsp/pos/suppreg/SupplierRegister.jsp?regkey=' ||
17505          l_reg_key;
17506 
17507 END GET_SUPPLIER_REG_URL;
17508 -- END Bug 9309785
17509 
17510 -- Begin Supplier Management: Bug 9222914
17511 PROCEDURE SYNC_BID_HEADER_ATTACHMENTS(p_auction_header_id IN NUMBER)
17512 AS
17513 
17514   l_intgr_hdr_attach_flag pon_auction_headers_all.intgr_hdr_attach_flag%TYPE;
17515   l_bid_number            pon_bid_headers.bid_number%TYPE;
17516   l_vendor_id             pon_bid_headers.vendor_id%TYPE;
17517 
17518   CURSOR get_intgr_hdr_attach_flag IS
17519     SELECT intgr_hdr_attach_flag
17520     FROM pon_auction_headers_all
17521     WHERE auction_header_id = p_auction_header_id;
17522 
17523   CURSOR bids_cursor IS
17524     SELECT bid_number, vendor_id
17525     FROM pon_bid_headers
17526     WHERE auction_header_id = p_auction_header_id
17527       AND bid_status = 'ACTIVE'
17528       AND vendor_id <> -1;
17529 
17530 BEGIN
17531 
17532   OPEN get_intgr_hdr_attach_flag;
17533   FETCH get_intgr_hdr_attach_flag INTO l_intgr_hdr_attach_flag;
17534   CLOSE get_intgr_hdr_attach_flag;
17535 
17536   IF (l_intgr_hdr_attach_flag = 'Y') THEN
17537 
17538     FOR bid IN bids_cursor LOOP
17539 
17540       fnd_attached_documents2_pkg.copy_attachments(
17541         X_from_entity_name => 'PON_BID_HEADERS',
17542         X_from_pk1_value => p_auction_header_id,
17543         X_from_pk2_value => bid.bid_number,
17544         X_to_entity_name => 'PO_VENDORS',
17545         X_to_pk1_value => bid.vendor_id,
17546         X_created_by => fnd_global.user_id,
17547         X_last_update_login => fnd_global.login_id);
17548 
17549     END LOOP;
17550 
17551   END IF;
17552 
17553 END SYNC_BID_HEADER_ATTACHMENTS;
17554 -- End Supplier Management: Bug 9222914
17555 
17556 -- Begin Supplier Management: Bug 10075648
17557 -- Procedure to update supplier registration status, used when publishing RFI.
17558 PROCEDURE UPDATE_SUPPLIER_REG_STATUS(p_supp_reg_id IN NUMBER)
17559 AS
17560 BEGIN
17561 
17562   UPDATE pos_supplier_registrations
17563   SET registration_status = 'RIF_SUPPLIER'
17564   WHERE supplier_reg_id = p_supp_reg_id
17565     AND registration_status = 'PENDING_APPROVAL';
17566 
17567 END UPDATE_SUPPLIER_REG_STATUS;
17568 -- End Supplier Management: Bug 10075648
17569 
17570 -- Begin Supplier Management: Bug 10378806 / 11071755
17571 PROCEDURE GEN_REQ_SUPP_AUC_AMEND_BODY(p_document_id    IN VARCHAR2,
17572                                       display_type     IN VARCHAR2,
17573                                       document         IN OUT NOCOPY CLOB,
17574                                       document_type    IN OUT NOCOPY VARCHAR2)
17575 IS
17576 
17577   l_document      VARCHAR2(32000) := '';
17578   l_item_type     wf_items.item_type%TYPE;
17579   l_item_key      wf_items.item_key%TYPE;
17580 
17581   l_auction_title               pon_auction_headers_all.auction_title%TYPE;
17582   l_doc_number                  pon_auction_headers_all.document_number%TYPE;
17583   l_auction_owner_tp_name       pon_auction_headers_all.trading_partner_name%TYPE;
17584   l_auction_end_date            DATE;
17585   l_auction_end_date_format     VARCHAR2(80);
17586   l_timezone_disp               VARCHAR2(240);
17587   l_isp_new_supplier_reg_url    VARCHAR2(500);
17588 
17589 BEGIN
17590 
17591   l_item_type := SUBSTR(p_document_id, 1, INSTR(p_document_id, ':') - 1);
17592   l_item_key := SUBSTR(p_document_id, INSTR(p_document_id, ':') + 1, LENGTH(p_document_id));
17593 
17594   l_auction_title := wf_engine.GetItemAttrText(itemtype => l_item_type,
17595                                                itemkey  => l_item_key,
17596                                                aname    => 'AUCTION_TITLE');
17597 
17598   l_doc_number := wf_engine.GetItemAttrText(itemtype => l_item_type,
17599                                             itemkey  => l_item_key,
17600                                             aname    => 'DOC_NUMBER');
17601 
17602   l_auction_owner_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
17603                                                        itemkey  => l_item_key,
17604                                                        aname    => 'PREPARER_TP_NAME');
17605 
17606   l_timezone_disp:= wf_engine.GetItemAttrText(itemtype => l_item_type,
17607                                               itemkey  => l_item_key,
17608                                               aname    => 'TP_TIME_ZONE');
17609 
17610   l_auction_end_date := wf_engine.GetItemAttrDate(itemtype => l_item_type,
17611                                                   itemkey  => l_item_key,
17612                                                   aname    => 'AUCTION_END_DATE_TZ');
17613 
17614   IF (l_auction_end_date IS NULL) THEN
17615     l_auction_end_date := wf_engine.GetItemAttrDate(itemtype => l_item_type,
17616                                                     itemkey  => l_item_key,
17617                                                     aname    => 'AUCTION_END_DATE');
17618   END IF;
17619 
17620   l_auction_end_date_format := TO_CHAR(l_auction_end_date,'Month dd, yyyy hh:mi am');
17621 
17622   l_isp_new_supplier_reg_url := wf_engine.GetItemAttrText(itemtype => l_item_type,
17623                                                           itemkey  => l_item_key,
17624                                                           aname    => 'ISP_NEW_SUPPLIER_REG_URL');
17625 
17626   IF display_type = 'text/html' THEN
17627     fnd_message.set_name('PON','PON_SM_REQ_SUPP_AMEND_HB');
17628     fnd_message.set_token('AUCTION_TITLE', l_auction_title);
17629     fnd_message.set_token('DOC_NUMBER', l_doc_number);
17630     fnd_message.set_token('PREPARER_TP_NAME', l_auction_owner_tp_name);
17631     fnd_message.set_token('ISP_NEW_SUPPLIER_REG_URL', l_isp_new_supplier_reg_url);
17632     fnd_message.set_token('AUCTION_END_DATE', l_auction_end_date_format);
17633     fnd_message.set_token('TP_TIME_ZONE', l_timezone_disp);
17634     l_document := l_document || fnd_global.newline || fnd_global.newline ||
17635                   fnd_message.get;
17636     WF_NOTIFICATION.WriteToClob(document, l_document);
17637   ELSE
17638     fnd_message.set_name('PON','PON_SM_REQ_SUPP_AMEND_TB');
17639     fnd_message.set_token('AUCTION_TITLE', l_auction_title);
17640     fnd_message.set_token('DOC_NUMBER', l_doc_number);
17641     fnd_message.set_token('PREPARER_TP_NAME', l_auction_owner_tp_name);
17642     fnd_message.set_token('ISP_NEW_SUPPLIER_REG_URL', l_isp_new_supplier_reg_url);
17643     fnd_message.set_token('AUCTION_END_DATE', l_auction_end_date_format);
17644     fnd_message.set_token('TP_TIME_ZONE', l_timezone_disp);
17645     l_document := l_document || fnd_global.newline || fnd_global.newline ||
17646                   fnd_message.get;
17647     WF_NOTIFICATION.WriteToClob(document, l_document);
17648   END IF;
17649 
17650 END GEN_REQ_SUPP_AUC_AMEND_BODY;
17651 
17652 PROCEDURE GEN_INV_REQ_SUPP_NEWRND_BODY(p_document_id    IN VARCHAR2,
17653                                        display_type     IN VARCHAR2,
17654                                        document         IN OUT NOCOPY CLOB,
17655                                        document_type    IN OUT NOCOPY VARCHAR2)
17656 IS
17657 
17658   l_document      VARCHAR2(32000) := '';
17659   l_item_type     wf_items.item_type%TYPE;
17660   l_item_key      wf_items.item_key%TYPE;
17661 
17662   l_auction_title               pon_auction_headers_all.auction_title%TYPE;
17663   l_doc_number                  pon_auction_headers_all.document_number%TYPE;
17664   l_auction_owner_tp_name       pon_auction_headers_all.trading_partner_name%TYPE;
17665   l_auction_end_date            DATE;
17666   l_auction_end_date_format     VARCHAR2(80);
17667   l_timezone_disp               VARCHAR2(240);
17668   l_isp_new_supplier_reg_url    VARCHAR2(500);
17669 
17670 BEGIN
17671 
17672   l_item_type := SUBSTR(p_document_id, 1, INSTR(p_document_id, ':') - 1);
17673   l_item_key := SUBSTR(p_document_id, INSTR(p_document_id, ':') + 1, LENGTH(p_document_id));
17674 
17675   l_auction_title := wf_engine.GetItemAttrText(itemtype => l_item_type,
17676                                                itemkey  => l_item_key,
17677                                                aname    => 'AUCTION_TITLE');
17678 
17679   l_doc_number := wf_engine.GetItemAttrText(itemtype => l_item_type,
17680                                             itemkey  => l_item_key,
17681                                             aname    => 'DOC_NUMBER');
17682 
17683   l_auction_owner_tp_name := wf_engine.GetItemAttrText(itemtype => l_item_type,
17684                                                        itemkey  => l_item_key,
17685                                                        aname    => 'PREPARER_TP_NAME');
17686 
17687   l_timezone_disp:= wf_engine.GetItemAttrText(itemtype => l_item_type,
17688                                               itemkey  => l_item_key,
17689                                               aname    => 'TP_TIME_ZONE');
17690 
17691   l_auction_end_date := wf_engine.GetItemAttrDate(itemtype => l_item_type,
17692                                                   itemkey  => l_item_key,
17693                                                   aname    => 'AUCTION_END_DATE_TZ');
17694 
17695   IF (l_auction_end_date IS NULL) THEN
17696     l_auction_end_date := wf_engine.GetItemAttrDate(itemtype => l_item_type,
17697                                                     itemkey  => l_item_key,
17698                                                     aname    => 'AUCTION_END_DATE');
17699   END IF;
17700 
17701   l_auction_end_date_format := TO_CHAR(l_auction_end_date,'Month dd, yyyy hh:mi am');
17702 
17703   l_isp_new_supplier_reg_url := wf_engine.GetItemAttrText(itemtype => l_item_type,
17704                                                           itemkey  => l_item_key,
17705                                                           aname    => 'ISP_NEW_SUPPLIER_REG_URL');
17706 
17707   IF display_type = 'text/html' THEN
17708     fnd_message.set_name('PON','PON_SM_INV_REQ_SUPP_NEWRND_HB');
17709     fnd_message.set_token('AUCTION_TITLE', l_auction_title);
17710     fnd_message.set_token('DOC_NUMBER', l_doc_number);
17711     fnd_message.set_token('PREPARER_TP_NAME', l_auction_owner_tp_name);
17712     fnd_message.set_token('ISP_NEW_SUPPLIER_REG_URL', l_isp_new_supplier_reg_url);
17713     fnd_message.set_token('AUCTION_END_DATE', l_auction_end_date_format);
17714     fnd_message.set_token('TP_TIME_ZONE', l_timezone_disp);
17715     l_document := l_document || fnd_global.newline || fnd_global.newline ||
17716                   fnd_message.get;
17717     WF_NOTIFICATION.WriteToClob(document, l_document);
17718   ELSE
17719     fnd_message.set_name('PON','PON_SM_INV_REQ_SUPP_NEWRND_TB');
17720     fnd_message.set_token('AUCTION_TITLE', l_auction_title);
17721     fnd_message.set_token('DOC_NUMBER', l_doc_number);
17722     fnd_message.set_token('PREPARER_TP_NAME', l_auction_owner_tp_name);
17723     fnd_message.set_token('ISP_NEW_SUPPLIER_REG_URL', l_isp_new_supplier_reg_url);
17724     fnd_message.set_token('AUCTION_END_DATE', l_auction_end_date_format);
17725     fnd_message.set_token('TP_TIME_ZONE', l_timezone_disp);
17726     l_document := l_document || fnd_global.newline || fnd_global.newline ||
17727                   fnd_message.get;
17728     WF_NOTIFICATION.WriteToClob(document, l_document);
17729   END IF;
17730 
17731 END GEN_INV_REQ_SUPP_NEWRND_BODY;
17732 
17733 PROCEDURE IS_SM_ENABLED(itemtype     IN VARCHAR2,
17734                         itemkey      IN VARCHAR2,
17735                         actid        IN NUMBER,
17736                         funcmode     IN VARCHAR2,
17737                         resultout    OUT NOCOPY VARCHAR2)
17738 IS
17739 BEGIN
17740 
17741   IF FND_PROFILE.value('POS_SM_ENABLE_SPM_EXTENSION') = 'Y' THEN
17742     resultout := 'Y';
17743   ELSE
17744     resultout := 'N';
17745   END IF;
17746 
17747 END IS_SM_ENABLED;
17748 -- End Supplier Management: Bug 10378806 / 11071755
17749 
17750 -- Added for the bug#8847938 to remove the space as delimitter in user name
17751 
17752 procedure String_To_UserTable (p_UserList  in VARCHAR2,
17753  	                                p_UserTable out NOCOPY WF_DIRECTORY.UserTable)
17754 is
17755 
17756 c1          pls_integer;
17757 u1          pls_integer := 0;
17758 l_userList  varchar2(32000);
17759 
17760 BEGIN
17761 if (p_UserList is not NULL) THEN
17762 l_userList := ltrim(p_UserList);
17763 p_UserTable(u1) := l_userList;
17764 end if;
17765 END String_To_UserTable;
17766 
17767 --for populating requisition references in pon_backing_requisitions table
17768 PROCEDURE POPULATE_PON_PR_REFS(p_auction_header_id IN NUMBER,
17769 			       p_auction_line_number IN PO_TBL_NUMBER,
17770 			       p_requisition_line_id IN PO_TBL_NUMBER,
17771 			       x_return_status OUT NOCOPY VARCHAR2,
17772 			       x_error_msg OUT NOCOPY VARCHAR2,
17773 			       x_no_of_rows_inserted OUT NOCOPY NUMBER) IS
17774 
17775 l_req_header_id NUMBER;
17776 l_req_number VARCHAR2(20);
17777 l_progress VARCHAR2(10);
17778 l_return_status VARCHAR2(1);
17779 l_error_msg VARCHAR2(200);
17780 l_no_of_rows_inserted NUMBER;
17781 
17782 BEGIN
17783 
17784 	l_progress := '0010';
17785 	IF (fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17786       		FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||'Begin proc:POPULATE_PON_PR_REFS');
17787       		FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||'auction_header_id:' || p_auction_header_id );
17788 	END IF;
17789 
17790 	x_return_status := FND_API.G_RET_STS_SUCCESS;
17791 	x_no_of_rows_inserted := 0;
17792 	l_no_of_rows_inserted := 0;
17793 
17794 	--insert req reference in pon_backing_requisitions table
17795 	l_progress := '0020';
17796 	FOR i in 1..p_auction_line_number.COUNT LOOP
17797 		FOR j in 1..p_requisition_line_id.COUNT LOOP
17798 
17799 			SELECT  h.requisition_header_id, h.segment1
17800 			INTO l_req_header_id, l_req_number
17801 			FROM po_requisition_lines_all l, po_requisition_headers_all h
17802 			WHERE requisition_line_id = p_requisition_line_id(j)
17803 			      and h.requisition_header_id = l.requisition_header_id;
17804 
17805 			BEGIN
17806 				INSERT INTO pon_backing_requisitions(auction_header_id, line_number, requisition_header_id, requisition_line_id, requisition_number,
17807 								     creation_date, created_by, last_update_date, last_updated_by, last_update_login)
17808 				VALUES (p_auction_header_id, p_auction_line_number(i), l_req_header_id, p_requisition_line_id(j), l_req_number,
17809 					SYSDATE, FND_GLOBAL.USER_ID, SYSDATE, FND_GLOBAL.USER_ID, FND_GLOBAL.LOGIN_ID);
17810 
17811 				l_no_of_rows_inserted := l_no_of_rows_inserted + sql%rowcount; --counting the no. of rows inserted
17812 
17813 				IF (fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17814 		      			FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||'inserted row: linenum ='|| p_auction_line_number(i)||' reqlineid ='||p_requisition_line_id(j));
17815 				END IF;
17816 
17817 			EXCEPTION
17818 			WHEN DUP_VAL_ON_INDEX THEN
17819 				IF (fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17820 		      			FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||'duplicate value on index exception occured. auction_line_number ='||p_auction_line_number(i)||' reqlineid ='||p_requisition_line_id(j));
17821 				END IF;
17822 			END;
17823 
17824 		END LOOP;
17825 	END LOOP;
17826 
17827 	x_no_of_rows_inserted := l_no_of_rows_inserted;
17828 
17829 	l_progress := '0030';
17830 	IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17831       		FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' inserted pr references in pon_backing_requisitions table');
17832       		FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' rows inserted in pon_backing_requisitions table: '|| l_no_of_rows_inserted);
17833 	END IF;
17834 
17835 	--to remove the selected requisitions from the requisition pool
17836 	po_negotiations_sv1.REMOVE_FROM_REQ_POOL('SOLICITATION', p_auction_header_id, p_requisition_line_id, l_return_status, l_error_msg);
17837 
17838 	IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
17839 		x_return_status := l_return_status;
17840 		x_error_msg := l_error_msg;
17841 		l_progress := '0040';
17842 		IF (fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17843 	      		FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' Exception occured in the procedure po_negotiations_sv1.REMOVE_FROM_REQ_POOL:' );
17844 	      		FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' return_status: '|| l_return_status || ' error_msg: '|| l_error_msg);
17845 		END IF;
17846 	END IF;
17847 
17848 	l_progress := '0050';
17849 	IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17850 	      	FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' Removed the selected requisitions from the pool');
17851 	END IF;
17852 
17853 	l_progress := '0060';
17854 	IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17855       		FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' End proc: populate_pon_pr_refs');
17856 	END IF;
17857 
17858 
17859 EXCEPTION
17860 WHEN OTHERS THEN
17861     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
17862     x_error_msg := 'Unexpectional error occured. sqlerrm: '||sqlerrm;
17863 
17864     l_progress := '0070';
17865     IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
17866       	FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' Unexpected error occured');
17867       	FND_LOG.string(fnd_log.level_statement, g_log_module_name, 'progress:='||l_progress||' sqlerrm: '||sqlerrm);
17868     END IF;
17869 
17870     raise; --raise exception
17871 
17872 END POPULATE_PON_PR_REFS;
17873 
17874 END PON_AUCTION_PKG;