[Home] [Help]
PACKAGE BODY: APPS.IBE_WORKFLOW_PVT
Source
1 PACKAGE BODY ibe_workflow_pvt AS
2 /* $Header: IBEVWFB.pls 120.36.12020000.3 2012/08/30 13:19:53 avitiwar ship $ */
3
4 /*
5 ==============================================================================
6 | NAME
7 | ibe_workflow_pvt - Procedure for all iStore alerts that will be
8 | executed using Workflow
9 |
10 | MODIFICATION HISTORY
11 | 07/25/00 hjaganat Created for Account Registration
12 | 08/23/00 hjaganat Modifications for Order Status Alerts
13 | completed
14 | 09/06/00 hjaganat Modifications for Contracts completed
15 | 09/07/00 hjaganat Modifications for Sales Assistance
16 | completed
17 | 10/06/00 hjaganat Modifications for shipping and handling
18 | 12/05/00 hjaganat Added additional exception handling
19 | 01/17/01 DKHANNA Modified to add cursors, profile contollable workflow,
20 | avoid adhoc user creation.
21 | 01/18/01 DKHANNA Improved Logic
22 | 01/22/01 DKHANNA Added suggestions by Harish
23 | 02/05/01 DKHANNA Bugfix: 1625486 - Performance
24 | 02/06/01 DKHANNA Bugfix: 1625486 - Order_id - for ibe views
25 | 03/02/01 DKhanna Bugfix: 1667013 - Replace order no. with web conf. no.
26 | 05/02/01 Dkhanna Bugfix: 1751367 - Modified for Contract Workflow.
27 | 05/11/01 Dkhanna Bugfix: 1768043 - Replaced extended_price with lines_total.
28 | 05/15/01 Dkhanna Bugfix: 1783921 - Changing Subtotal defination
29 | 05/17/01 Dkhanna Bugfix: 1786058 - Unable to Re-Send Contract Notification
30 | 06/13/01 Dkhanna Bugfix: 1824177 - Shipment Method Code is Picked
31 | 07/14/01 Dkhanna Bugfix: 1855509 - Major Change to accomodate the Map Frame Work
32 | 08/06/01 Dkhanna Bugfix: 1915315 - TO_BE_SHIPPED(Y/N) IS NOT FILLED OUT
33 | 09/04/01 Dkhanna Bugfix: 1971128 - SAVED CART IS NOT RETRIEVABLE
34 | 09/13/01 Dkhanna Bugfix: 1993433 - Error After Filling 2ND email add. in Save Cart
35 | 09/17/01 Dkhanna Bugfix: 1890460 - Currency Symbol with Amounts
36 | 09/13/01 Dkhanna Bugfix: 1869219 - GLOBAL TAX Display in Order Notif.
37 | 02/10/01 Dkhanna Bugfix: 2002751 - Wrong Alert When PO Opt. And No PO Num.
38 | 10/26/01 Ashukla - Added Method for Quote Publish
39 | 12/03/01 Ashukla Bugfix: 1984683 - Getting Contact Name instead Customer Name
40 | 12/15/01 Ashukla Bugfix: 2144114 - Notification error when word is bigger that 30 character
41 | 12/27/01 Ashukla Bugfix: 2077446 - Add FirstName as token in IBE alerts
42 | 02/18/02 ljanakir Bugfix: 2223507 - Added p_salesrep_user_id parameter
43 | for NotifyForSalesAssistance
44 | 03/13/02 ljanakir Bugfix: 2111316 - Added the procedure NotifyForgetLogin
45 | 04/04/02 ljanakir Bugfix: 2299210 - Modify NotifyForSharedCart to pass
46 | in the first/last name of the sharer.
47 | Modify procedures GetFirstName,
48 | GetLastName, GetTitle (similar to
49 | fix 2280544 done in branch)
50 | 05/15/02 mannamra Enh : 2116080 - Added a new API notify_cancel_order for
51 | order cancellation.
52 | Added new API to display line level details
53 | with tax and without tax for both orders and quotes.
54 | Added new API getfirstname_for_quote to retrieve the
55 | first name of the owner of the quote.
56 |
57 | 05/24/02 mannamra Bugfix: 2111316 - Modified procedure Notify_cancel_order to remove
58 | any references to quote schema.
59 | Added a new procedure get_contact_details_for_order
60 |
61 | 06/03/02 mannamra Bugfix: 2380273 - Replaced HZ_PARTY_RELATIONSHIPS
62 | with HZ_RELATIONSHIPS to improve query
63 | performance.
64 | 06/10/02 mannamra Bugfix: 2387181 - During cancel_order value for sold_to_contact is not
65 | available in oe_order_headers_all table for some orders,
66 | so using the value in last_updated_by column
67 | to identify the appropriate recipient of
68 | the cancel order notification.
69 | 06/18/02 mannamra Bugfix: 2417011 - Obsoleted getfirstname_for_quote API because
70 | getfirstname solves the purpose.
71 | 08/20/02 mannamra Bugfix: 2426274 - Orders with KIT items should not show 'INCLUDED'
72 | items, though their prices should be rolled up to
73 | the KIT level.
74 | 09/06/02 mannamra Bugfix: 2552417 - Notification shows two lines for a single line in
75 | order
76 | 09/27/02 batoleti Added Notify_End_Working notification procedure
77 | 10/01/02 batoleti Added Notify_Finish_Sharing notification procedure
78 | 10/04/02 batoleti Added Notify_Shared_Cart notification procedure
79 | 10/07/02 batoleti Added Notify_Access_Change notification procedure
80 | 12/12/02 SCHAK Bug # 2691704 Modified for NOCOPY Changes.
81 | 01/16/03 mannamra Enh : 2745338 - Added API set_item_attributes and identify_cart_quote
82 | Also included a fix to send access_change notif to B2C
83 | users.
84 | 07/24/03 batoleti Added NotifyReturnOrderStatus notification procedure
85 / 8/26/03 abhandar changed getUserType(),Get_Name_Details()and NotifyRegistration()
86 / Added Generate_Approval_Msg()
87 | 12/11/2003 3192506 IBE_USE_WORKFLOW profile Obsoletion
88 | 12/23/03 batoleti Bug#3313522 Commented the IF (display_type = 'text/plain' ) checking conditions.
89 | 12/23/03 batoleti Bug#3334542 Added billing address for B2C return order notifications.
90 | 12/29/03 batoleti Bug#3325710 Added view Netprice token to order confirmation notification
91 | sent to sharee.
92 | 12/30/03 mannamra Bug#3319902 View shared cart should display 'owner' as a role.
93 | 01/14/04 batoleti Bug#3342929 Added IBE_UTIL.nls_number_format function call for quantity and amount values
94 | in istore workflow notification procedures.
95 | 01/19/04 batoleti Bug#3378966 In Return order notification, the INCLUDED items are not shown.
96 | 01/29/04 batoleti Bug#3348583 In Return order notification, order number should not be shown for the
97 | child items.
98 | 02/05/04 mannamra Bug#3316860 HTML enabled tokens with PL/SQL callbacks.
99 | 30/11/04 Knachiap Bug#4031180 SetOrderId for OrderNotBooked Notification
100 | 06/12/04 Knachiap Bug#4031180 OrderConf Notification to Recipient
101 | 07/12/04 abairy Bug#4049509 Customised Approval Message Keys for Customised UserTypes
102 | 02/27/05 abairy Bug #4184705 removed wrong usage of organization party number as orgId
103 | 01/May/05 Knachiap MACD Notification Change for Cart/Checkout
104 | 06/02/05 abairy Added Generate_Credential_Msg procedure
105 | 07/18/05 banatara Added the m_site_type='I' check for the ibe_msites table cursors
106 | 07/21/05 Knachiap MOAC Fix
107 | 07/29/05 banatara Removed the m_site_type='I' check for the ibe_msites table cursors
108 | 19/08/05 Knachiap MOAC Changes
109 | 24/08/05 Knachiap MOAC Changes - Client Info
110 | 09/06/05 abairy Setting party number as the value for ORGNUM token in NotifyRegistration
111 | Changed Generate_credential_msg to only ignore password. Username shall always be shown.
112 | 14/Nov/05 Knachiap Line Type for Quote
113 | 16/Nov/05 Knachiap MACD Footer fixes
114 | 14/Dec/05 Knachiap 4774306 - SQL Perf Fixes
115 | 06/Jun/06 aannamal 5260544 - Fix to have negative amounts within angular brackets
116 | 19/Sep/06 aannamal 5480501 - Made changes to display correct line amount in Order confirmation Notification
117 | 24/Apr/08 ukalaiah 6877589 - WRONG WORKFLOW NOTIFICATION BEING FIRED FOR CREDIT CARD ORDERS
118 | 26/Jun/09 scnagara 8337371 - For NotifyReturnOrderStatus, passed the return order minisite id to
119 | IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
120 | 1/Jul/09 scnagara 7720550 - For NotifyReturnOrderStatus and Notify_cancel_order,
121 | passed the current org Id to Retrieve_Msg_Mapping
122 | 23-AUG-2010 amaheshw 10016159 Replace IBY_TRXN_EXTENSIONS_V with IBY_EXTN_INSTR_DETAILS_VREM
123 | 23-MAY-2011 ytian 12573026 Modified buildDocument function to increase the VARCHAR2 size to 495.
124 | 07-MAY-2012 scnagara 13767382 procedure get_sales_assist_rsn_meaning - changed to use aso_lookups view
125 | 30-AUG-2012 avitiwar 12851105 - Istore Registration Page Application Error
126 ==============================================================================================
127 */
128 l_true VARCHAR2(1) := FND_API.G_TRUE;
129 g_ItemType Varchar2(10) := 'IBEALERT';
130 g_processName Varchar2(30) := 'PROCESSMAP';
131
132
133 GET_MESSAGE_ERROR EXCEPTION;
134
135 Cursor c_ship_methods(pCode Varchar2) IS
136 Select Meaning
137 from oe_ship_methods_v
138 Where Lookup_code = pCode;
139
140 Cursor c_order_header (c_order_id NUMBER) IS
141 SELECT oh.ordered_date,
142 oh.order_number,
143 sold_to_party.party_name customer_name,
144 oe_totals_grp.Get_Order_Total(oh.header_id,null,'ALL')order_total,
145 oe_totals_grp.Get_Order_Total(oh.header_id,null,'CHARGES')charges_total,
146 oe_totals_grp.Get_Order_Total(oh.header_id,null,'TAXES')taxes_total,
147 oe_totals_grp.Get_Order_Total(oh.header_id,null,'LINES')lines_total,
148 sold_to_party.party_id,
149 oh.payment_type_code,
150 oh.cust_po_number,
151 substr(oh.credit_card_number,(length(oh.credit_card_number)-3),4)credit_card_number,
152 oh.orig_sys_document_ref web_confirm_number,
153 oh.shipping_method_code,
154 oh.minisite_id, -- bug 8337371, scnagara
155 shipaddr.address1 ship_to_address1,
156 shipaddr.address2 ship_to_address2,
157 shipaddr.address3 ship_to_address3,
158 shipaddr.address4 ship_to_address4,
159 shipaddr.city ship_to_city,
160 shipaddr.state ship_to_state,
161 shipaddr.postal_code ship_to_postal_code,
162 shipaddr.country ship_to_country,
163 invaddr.address1 bill_to_address1,
164 invaddr.address2 bill_to_address2,
165 invaddr.address3 bill_to_address3,
166 invaddr.address4 bill_to_address4,
167 invaddr.city bill_to_city,
168 invaddr.state bill_to_state,
169 invaddr.postal_code bill_to_postal_code,
170 invaddr.country bill_to_country,
171 oh.transactional_curr_code
172 from oe_order_headers_all oh,
173 hz_parties sold_to_party,
174 hz_cust_accounts sold_to_account,
175 hz_locations shipaddr,
176 hz_party_sites shp_party_site,
177 hz_cust_acct_sites_all shp_acct_site,
178 hz_cust_site_uses_all shp_site_use,
179 hz_locations invaddr,
180 hz_party_sites inv_party_site,
181 hz_cust_acct_sites_all inv_acct_site,
182 hz_cust_site_uses_all inv_site_use
183 where oh.header_id=c_order_id
184 and sold_to_party.party_id= sold_to_account.party_id
185 and sold_to_account.cust_account_id = oh.sold_to_org_id
186 and oh.ship_to_org_id=shp_site_use.site_use_id(+)
187 and shp_site_use.cust_acct_site_id=shp_acct_site.cust_acct_site_id(+)
188 and shp_acct_site.party_site_id=shp_party_site.party_site_id(+)
189 and shp_party_site.location_id=shipaddr.location_id(+)
190 and oh.invoice_to_org_id=inv_site_use.site_use_id(+)
191 and inv_site_use.cust_acct_site_id=inv_acct_site.cust_acct_site_id(+)
192 and inv_acct_site.party_site_id=inv_party_site.party_site_id(+)
193 and inv_party_site.location_id=invaddr.location_id(+);
194
195 g_header_rec c_order_header%ROWTYPE;
196
197 Cursor c_order_detail(p_order_id NUMBER) IS
198 SELECT ol.line_id,
199 ol.item_type_code,
200 ol.top_model_line_id,
201 ol.link_to_line_id,
202 msi.description item_description,
203 ol.ordered_quantity,
204 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'LINES') lines_total,
205 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'TAXES') taxes_total,
206 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'CHARGES') charges_total,
207 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'ALL') extended_price
208 FROM oe_order_lines_all ol, mtl_system_items_tl msi
209 WHERE ol.header_id = p_order_id
210 and ol.inventory_item_id = msi.inventory_item_id
211 and msi.organization_id = oe_profile.value('OE_ORGANIZATION_ID', ol.org_id)
212 and msi.language = userenv('LANG')
213 ORDER BY line_number, shipment_number,nvl(option_number,-1), nvl(component_number,-1), nvl(service_number,-1);
214
215 Cursor c_contract_rep (p_org_id NUMBER) IS
216 Select ORG_INFORMATION1 Contract_Rep,
217 ORG_INFORMATION2 Sales_Rep,
218 ORG_INFORMATION3 CustCare_Rep
219 From hr_organization_information
220 where org_information_context = 'DEFAULT_NOTIFICATION_USER'
221 And organization_id = p_org_id;
222
223 Cursor c_contract_header(p_id number) IS
224 Select Contract_number,Contract_number_modifier
225 From okc_k_headers_b
226 Where ID = p_id;
227
228 g_detail_rec c_order_detail%ROWTYPE;
229
230 Cursor c_quote_header (p_quote_id NUMBER) IS
231 SELECT org_id,
232 party_id,
233 quote_name,
234 quote_number,
235 quote_version,
236 quote_password,
237 cust_account_id,
238 invoice_to_party_id,
239 invoice_to_party_site_id,
240 quote_header_id,
241 ordered_date,
242 order_id,
243 total_list_price,
244 total_shipping_charge,
245 total_tax,
246 total_quote_price,
247 invoice_to_cust_account_id,
248 total_adjusted_amount,
249 currency_code,
250 resource_id
251 FROM aso_quote_headers_all
252 WHERE quote_header_id = p_quote_id;
253 g_quote_header_rec c_quote_header%ROWTYPE;
254
255 Cursor c_quote_detail (p_quote_id NUMBER) IS
256 SELECT Inventory_item_id,
257 Organization_id,
258 Quantity,
259 Line_quote_price,
260 currency_code
261 FROM Aso_quote_lines_all
262 WHERE quote_header_id = p_quote_id
263 ORDER BY line_number;
264 g_quote_line_rec c_quote_detail%ROWTYPE;
265
266
267 Cursor c_quote_payment (p_quote_id NUMBER) IS
268 SELECT Payment_type_code
269 FROM Aso_Payments
270 WHERE quote_header_id = p_quote_id;
271
272 Cursor c_hz_parties(c_party_id NUMBER) IS
273 SELECT Party_Name,
274 Person_First_Name,
275 Person_Middle_Name,
276 Person_Last_name,
277 party_type,
278 Person_title
279 FROM hz_parties
280 WHERE party_id = c_party_id;
281
282 Cursor c_hz_contact_points(p_party_id NUMBER) IS
283 SELECT Contact_Point_type,
284 Primary_flag,
285 Phone_line_type,
286 Phone_Country_code,
287 Phone_area_code,
288 Phone_number,
289 Email_address
290 FROM hz_contact_points
291 WHERE owner_table_name = 'HZ_PARTIES'
292 AND owner_table_id = p_party_id;
293
294 cursor c_order_curr_code(c_order_id number) is
295 select transactional_curr_code
296 from oe_order_headers_all
297 where header_id = c_order_id;
298 rec_order_curr_code c_order_curr_code%rowtype;
299
300 cursor c_curr_symbol(p_currCode VARCHAR2) IS
301 SELECT fc.symbol
302 FROM FND_CURRENCIES fc
303 WHERE fc.currency_code = p_currCode;
304
305 Cursor c_get_source_code(p_quote_id NUMBER) is
306 select quote_source_code
307 from aso_quote_headers_all
308 where quote_header_id = p_quote_id;
309
310 g_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
311 g_amt_format VARCHAR2(20);
312
313 NEWLINE VARCHAR2(1) := fnd_global.newline;
314 TAB VARCHAR2(1) := fnd_global.tab;
315
316
317 /*Procedure getUserType(pPartyId IN Varchar2,
318 pUserType OUT NOCOPY Varchar2) IS
319 l_PartyType Varchar2(30);
320 l_UserType jtf_um_usertypes_b.usertype_key%type := 'B2B';
321 BEGIN
322 ----DBMS_OUTPUT.PUT('Into getusertype party_id is: '||ppartyid);
323 FOR c_hz_parties_rec IN c_hz_parties(pPartyId) LOOP
324 ----DBMS_OUTPUT.PUT('Opened the cursor loop');
325
326 l_PartyType := rtrim(c_hz_parties_rec.party_type);
327 ----DBMS_OUTPUT.PUT('party_type is: '||l_partytype);
328 END LOOP;
329
330 If l_PartyType = 'PERSON' Then
331 l_userType := 'B2C';
332 End If;
333
334 pUserType := l_userType;
335
336 END getUserType;
337 */
338
339 /*Returns the mail format preference of the mail recipient*/
340
341 /*PROCEDURE get_mail_format_pref(p_user_name IN VARCHAR2,
342 x_mail_pref OUT VARCHAR2) is
343
344 cursor c_get_pref(c_user VARCHAR2) is
345 SELECT name,
346 notification_preference
347 FROM wf_roles
348 WHERE name = c_user;
349 rec_get_pref c_get_pref%rowtype;
350 l_mail_pref VARCHAR2(100);
351
352 BEGIN
353 FOR rec_get_pref in c_get_pref(p_user_name) LOOP
354 x_mail_pref := rec_get_pref.notification_preference;
355
356 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
357 IBE_UTIL.DEBUG('get_mail_format_pref: Mail preference: '|| x_mail_pref);
358 END IF;
359 EXIT when c_get_pref%NOTFOUND;
360 END LOOP;
361 END;*/
362
363 Procedure getUserType(pPartyId IN NUMBER,
364 pUserType OUT NOCOPY Varchar2) IS
365
366 l_api_name CONSTANT VARCHAR2(30) :='getUserType';
367 l_PartyType HZ_PARTIES.PARTY_TYPE%type :='';
368 l_UserType jtf_um_usertypes_b.usertype_key%type :='ALL';
369 l_user_name FND_USER.USER_NAME%type;
370 l_is_pv_partner boolean :=false;
371 l_is_int_primary_user boolean:=false;
372 plsql_block VARCHAR2(500);
373 pv_flag VARCHAR2(1):='N';
374
375 -- check for user id exists in jtf_um_usertype_reg table
376 -- if not then use the permissions logic to retrieve the user type else return ALL
377 -- The new user type supported out of the box are :
378 -- IBE_INDIVIDUAL, IBE_BUSINESS, IBE_PRIMARY, IBE_PARTNER, IBE_PARTNER_PRIMARY.
379 --
380 -- cursor to retrieve user type from jta tables
381 Cursor c_get_user_type(c_party_id NUMBER) IS
382 select b.usertype_key
383 from jtf_um_usertype_reg a,jtf_um_usertypes_b b, fnd_user c , hz_parties d
384 where a.usertype_id=b.usertype_id and c.user_id = a.user_id
385 and d.party_id = c.customer_id and b.application_id=671
386 and d.party_id = c_party_id;
387
388 -- Cursor to get the party type , user name from fnd and hz tables
389 Cursor c_get_party_type_user_name(c_party_id NUMBER) IS
390 select d.party_type,c.user_name
391 from fnd_user c , hz_parties d
392 where d.party_id=c.customer_id
393 and d.party_id=c_party_id;
394
395 BEGIN
396
397 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
398 IBE_UTIL.DEBUG('start: getUserType' ||':partyid='||pPartyId);
399 END IF;
400
401 open c_get_user_type(pPartyId);
402
403 fetch c_get_user_type into l_UserType;
404
405 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
406 IBE_UTIL.DEBUG('getUserType:After fetch' ||'l_UserType='||l_UserType);
407 END IF;
408
409 IF (c_get_user_type%NOTFOUND) THEN
410 -- user not created thru the new JTA UM functionality
411 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
412 IBE_UTIL.DEBUG('getUserType:' ||'l_UserType not found in jta tables');
413 END IF;
414 open c_get_party_type_user_name(pPartyId);
415 fetch c_get_party_type_user_name into l_PartyType,l_user_name;
416 CLOSE c_get_party_type_user_name;
417
418 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
419 IBE_UTIL.DEBUG('getUserType:' ||'l_PartyType='||l_PartyType);
420 END IF;
421
422 if (l_PartyType='PERSON') then
423 l_userType:='IBE_INDIVIDUAL';
424 else
425 l_is_int_primary_user := IBE_UTIL.check_jtf_permission('IBE_INT_PRIMARY_USER',l_user_name);
426 -- l_is_pv_partner := IBE_UTIL.check_jtf_permission('PV_PARTNER',l_user_name);
427
428 -----------------------------------------------------------
429 -- checking the PV_PARTNER permission thru a sql package
430 BEGIN
431
432 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
433 IBE_UTIL.DEBUG('getUserType:Before calling PV_USER_MGMT_PVTS.is_partner_user');
434 END IF;
435
436 plsql_block := 'BEGIN :pvFlag:=PV_USER_MGMT_PVT.is_partner_user(:partyId);END;';
437 EXECUTE IMMEDIATE plsql_block USING OUT pv_flag,pPartyId;
438
439 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
440 IBE_UTIL.DEBUG('getUserType:After calling PV_USER_MGMT_PVTS: value of permission='||pv_flag);
441 END If;
442 EXCEPTION
443 WHEN OTHERS THEN
444 --set partner permission to 'N'
445 pv_flag := 'N';
446 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
447 IBE_UTIL.DEBUG('getUserType: The This is a standalone iStore installation,with no PRM integration, hence the dynamic call to retrieve the PRM usertypes throws following exception,please ignore it');
448 IBE_UTIL.DEBUG('getUserType:sqlcode='||sqlcode||' :sqlerr='|| sqlerrm);
449 IBE_UTIL.DEBUG('getUserType:Reminder:Please ignore the above sql exception,there is no error here.It is an expected behaviour as per the code logic.');
450 END IF;
451 END;
452 if pv_flag='Y' then
453 l_is_pv_partner:=true;
454 else
455 l_is_pv_partner:=false;
456 end if;
457 -------------------------------------------------
458 if (l_is_pv_partner=true) THEN
459 if (l_is_int_primary_user=true) then
460 l_userType:='IBE_PARTNER_PRIMARY';
461 else
462 l_userType:='IBE_PARTNER_BUSINESS';
463 end if;
464 else -- partner is false
465 if (l_is_int_primary_user=true) then
466 l_userType:='IBE_PRIMARY';
467 else
468 l_userType:='IBE_BUSINESS';
469 end if;
470 END IF;
471 END IF;
472 END IF;
473 CLOSE c_get_user_type;
474 pUserType:=l_userType;
475 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
476 IBE_UTIL.DEBUG('getUserType:' ||'pUserType='||pUserType);
477 END IF;
478
479 END getUserType;
480
481 Procedure identify_cart_quote(p_quote_header_id IN NUMBER
482 ,x_is_it_quote OUT NOCOPY VARCHAR2) is
483 cursor c_get_cart_type(c_quote_header_id NUMBER) is
484 select resource_id
485 from aso_quote_headers_all
486 where quote_header_id = c_quote_header_id;
487
488 rec_get_cart_type c_get_cart_type%rowtype;
489 l_is_it_quote VARCHAR2(1) := fnd_api.g_false;
490 BEGIN
491
492 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
493 IBE_UTIL.DEBUG('Identify_cart_quote: Start');
494 IBE_UTIL.DEBUG('Identify_cart_quote:inout quote_header_id: '||p_quote_header_id);
495 END IF;
496 For rec_get_cart_type in c_get_cart_type(p_quote_header_id) LOOP
497 IF (rec_get_cart_type.resource_id is not null) THEN
498 l_is_it_quote := FND_API.G_TRUE;
499 END IF;
500 EXIT when c_get_cart_type%notfound;
501 END LOOP;
502 x_is_it_quote := l_is_it_quote;
503 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
504 IBE_UTIL.DEBUG('Identify_cart_quote:X_is_it_quote: '||x_is_it_quote);
505 END IF;
506
507 END;
508
509 Procedure create_adhoc_entity
510 ( p_quote_recipient_id IN NUMBER := FND_API.G_MISS_NUM
511 ,p_quote_header_id IN NUMBER := FND_API.G_MISS_NUM
512 ,p_email_address IN VARCHAR2:= FND_API.G_MISS_CHAR
513 ,p_Notification_preference IN VARCHAR2:= FND_API.G_MISS_CHAR
514 ,x_adhoc_role OUT NOCOPY VARCHAR2) is
515
516 l_adhoc_user VARCHAR2(2000);
517 l_adhoc_user_display VARCHAR2(2000);
518 l_role_users VARCHAR2(2000);
519 l_adhoc_role VARCHAR2(2000);
520 l_adhoc_role_display VARCHAR2(2000);
521
522 BEGIN
523 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
524 IBE_UTIL.DEBUG('Create_adhoc_entity:Start');
525 IBE_UTIL.DEBUG('Create_adhoc_entity:Input recipient_id: '||p_quote_recipient_id);
526 IBE_UTIL.DEBUG('Create_adhoc_entity:Input QUOTE_HEADER_ID: '||p_quote_header_id);
527 IBE_UTIL.DEBUG('Create_adhoc_entity:Input email address: '||p_email_address);
528 END IF;
529
530 l_adhoc_user := 'SCU'||p_QUOTE_recipient_id
531 ||'Q'||p_quote_header_id||to_char(sysdate,'MMDDYYHH24MISS');
532 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
533 IBE_UTIL.DEBUG('Create_adhoc_entity:l_adhoc_user: '||l_adhoc_user);
534 END IF;
535
536 l_adhoc_user_display := 'SCU'||p_QUOTE_recipient_id
537 ||'Q'||p_quote_header_id||to_char(sysdate,'MMDDYYHH24MISS');
538
539 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
540 IBE_UTIL.DEBUG('Create_adhoc_entity:Creating adhoc user');
541 END IF;
542 wf_directory.CreateAdHocUser(
543 name => l_adhoc_user ,
544 display_name => l_adhoc_user_display ,
545 notification_preference => p_notification_preference ,
546 email_address => p_email_address ,
547 expiration_date => sysdate + 1);
548
549
550 l_role_users := l_adhoc_user;
551
552 l_adhoc_role := 'SCR'||p_QUOTE_recipient_id
553 ||'Q'||p_quote_header_id||to_char(sysdate,'MMDDYYHH24MISS');
554 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
555 IBE_UTIL.DEBUG('Create_adhoc_entity:l_adhoc_role: '||l_adhoc_role);
556 END IF;
557
558 l_adhoc_role_display := 'SCR'||p_QUOTE_recipient_id
559 ||'Q'||p_quote_header_id||to_char(sysdate,'MMDDYYHH24MISS');
560 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
561 IBE_UTIL.DEBUG('Create_adhoc_entity:Creating ad-hoc role');
562 END IF;
563
564 wf_directory.CreateAdHocRole
565 (role_name => l_adhoc_role,
566 role_display_name => l_adhoc_role_display,
567 notification_preference => p_notification_preference,
568 role_users => l_role_users,
569 expiration_date => sysdate + 1);
570 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
571 IBE_UTIL.DEBUG('Create_adhoc_entity:x_adhoc_role: '||x_adhoc_role);
572 END IF;
573 x_adhoc_role := l_adhoc_role;
574 END;
575
576
577
578 procedure set_item_attributes
579 ( p_item_key IN VARCHAR2
580 ,p_message_name IN VARCHAR2
581 ,p_access_level IN VARCHAR2 :=FND_API.G_MISS_CHAR
582 ,p_old_access_level IN VARCHAR2 :=FND_API.G_MISS_CHAR
583 ,p_recipient_number IN VARCHAR2 :=FND_API.G_MISS_CHAR
584 ,p_first_name IN VARCHAR2
585 ,p_last_name IN VARCHAR2
586 ,p_url IN VARCHAR2 :=FND_API.G_MISS_CHAR
587 ,p_minisite_id IN VARCHAR2
588 ,p_cart_name IN VARCHAR2
589 ,p_adhoc_role IN VARCHAR2 :=FND_API.G_MISS_CHAR
590 ,p_context_msg IN VARCHAR2 :=FND_API.G_MISS_CHAR
591 ,p_notes IN VARCHAR2 :=FND_API.G_MISS_CHAR
592 ,p_notif_context IN VARCHAR2 ) is
593
594 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
595 l_temp_retrieve_str Varchar2(2000);
596 L_temp_update_str Varchar2(2000);
597
598
599 BEGIN
600 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
601 IBE_UTIL.DEBUG('Set_item_attributes: Start');
602 IBE_UTIL.DEBUG('Set_item_attributes:Input messsage name: '||p_message_name);
603 IBE_UTIL.DEBUG('Set_item_attributes:retrieval_number: '||p_recipient_number);
604 IBE_UTIL.DEBUG('Set_item_attributes:old_access_level: '||p_old_access_level);
605 IBE_UTIL.DEBUG('Set_item_attributes:URL: '||p_url);
606 IBE_UTIL.DEBUG('Set_item_attributes:context message: '||p_context_msg);
607 IBE_UTIL.DEBUG('Set_item_attributes:msiteid: '||p_minisite_id);
608 IBE_UTIL.DEBUG('Set_item_attributes:cartname: '||p_cart_name);
609 IBE_UTIL.DEBUG('Set_item_attributes:first_name: '||p_first_name);
610 IBE_UTIL.DEBUG('Set_item_attributes:last_name: '||p_last_name);
611 IBE_UTIL.DEBUG('Set_item_attributes:p_item_key: '||p_item_key);
612 IBE_UTIL.DEBUG('Set_item_attributes:p_notes: '||p_notes);
613 IBE_UTIL.DEBUG('Set_item_attributes:Wf_engine.create_process: START');
614 END IF;
615
616 wf_engine.CreateProcess(
617 itemtype => g_ItemType,
618 itemkey => p_item_key,
619 process => g_processName);
620
621 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
622 IBE_UTIL.DEBUG('Set_item_attributes:Done creating process');
623 END IF;
624
625 wf_engine.SetItemUserKey(
626 itemtype => g_ItemType,
627 itemkey => p_item_key,
628 userkey => p_item_key);
629 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
630 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemUserKey');
631 END IF;
632
633 wf_engine.SetItemAttrText(
634 itemtype => g_ItemType,
635 itemkey => p_item_key,
636 aname => 'MESSAGE',
637 avalue => p_Message_Name);
638 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
639 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for MESSAGE');
640 END IF;
641
642 wf_engine.SetItemAttrText(
643 itemtype => g_ItemType,
644 itemkey => p_item_key,
645 aname => 'MSITEID',
646 avalue => p_minisite_id);
647 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
648 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for MSITEID');
649 END IF;
650
651 wf_engine.SetItemAttrText(
652 itemtype => g_ItemType,
653 itemkey => p_item_key,
654 aname => 'CARTNAME',
655 avalue => p_cart_name);
656 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
657 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for CARTNAME');
658 END IF;
659
660 IF((p_first_name is not null) and
661 (p_first_name <> FND_API.G_MISS_CHAR)) THEN
662 wf_engine.SetItemAttrText(
663 itemtype => g_ItemType,
664 itemkey => p_item_key,
665 aname => 'FIRSTNAME',
666 avalue => p_first_name);
667 END IF;
668 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
669 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for FIRSTNAME');
670 END IF;
671
672 IF((p_last_name is not null) and
673 (p_first_name <> FND_API.G_MISS_CHAR)) THEN
674 wf_engine.SetItemAttrText(
675 itemtype => g_ItemType,
676 itemkey => p_item_key,
677 aname => 'LASTNAME',
678 avalue => p_last_name);
679 END IF;
680
681 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
682 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for LASTNAME');
683 END IF;
684 IF((p_notes is not null) and
685 (p_notes <> FND_API.G_MISS_CHAR)) THEN
686 wf_engine.SetItemAttrText(
687 itemtype => g_ItemType,
688 itemkey => p_item_key,
689 aname => 'SHARECOMMENTS',
690 avalue => p_notes);
691 END IF;
692
693 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
694 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for COMMENTS');
695 END IF;
696
697 IF((p_notif_context = 'SHARECARTNOTIF') OR
698 (p_notif_context = 'SHARECARTNOTIF_B2B')OR
699 (p_notif_context = 'SHAREQUOTENOTIF') OR
700 (p_notif_context = 'SHAREQUOTENOTIF_B2B') OR
701 (p_notif_context = 'CHANGEACCESSLEVEL') OR
702 (p_notif_context = 'CHANGEACCESSLEVEL_QUOTE')) THEN
703
704 wf_engine.SetItemAttrText(
705 itemtype => g_ItemType,
706 itemkey => p_item_key,
707 aname => 'ACCESSCODE',
708 avalue => p_access_level);
709 END IF;
710 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
711 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for ACCESSLEVEL');
712 END IF;
713
714
715 IF((p_notif_context <> 'STOPWORKING' ) AND
716 (p_notif_context <> 'STOPWORKING_QUOTE' )) THEN
717
718 wf_engine.SetItemAttrText(
719 itemtype => g_ItemType,
720 itemkey => p_item_key,
721 aname => 'ISTOREURL',
722 avalue => p_url);
723 END IF;
724 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
725 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for URL');
726 END IF;
727
728
729 IF ((p_notif_context = 'STOPWORKING' ) OR
730 (p_notif_context = 'STOPWORKING_QUOTE' ))THEN
731 wf_engine.SetItemAttrText(
732 itemtype => g_ItemType,
733 itemkey => p_item_key,
734 aname => 'CONTEXT_CODE',
735 avalue => p_context_msg);
736 END IF;
737 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
738 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for CONTEXT_MESSAGE');
739 END IF;
740
741 IF ((p_notif_context = 'CHANGEACCESSLEVEL') OR
742 (p_notif_context = 'CHANGEACCESSLEVEL_QUOTE')) THEN
743 wf_engine.SetItemAttrText(
744 itemtype => g_ItemType,
745 itemkey => p_item_key,
746 aname => 'ACCESSCODE_OLD',
747 avalue => p_old_access_level);
748 END IF;
749 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
750 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for OLDACCESSLEVEL');
751 END IF;
752
753 IF((p_notif_context = 'SHARECARTNOTIF') OR
754 (p_notif_context = 'SHARECARTNOTIF_B2B')OR
755 (p_notif_context = 'CHANGEACCESSLEVEL')) THEN
756
757 l_temp_update_str := 'IBE_PRMT_UPDATE_CART';
758
759 wf_engine.SetItemAttrText(
760 itemtype => g_ItemType,
761 itemkey => p_item_key,
762 aname => 'UPDATEMSG_CODE',
763 avalue => l_temp_update_str);
764 END IF;
765 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
766 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for UPDATEMSG');
767 END IF;
768
769 IF ((p_notif_context = 'SHARECARTNOTIF') OR
770 (p_notif_context = 'SHAREQUOTENOTIF'))THEN
771
772 -- Retrieve the message text for retrieve message from fnd_messages
773 --fnd_message.set_name('IBE','IBE_PRMT_SC_RETRIEVE');
774 l_temp_retrieve_str := 'IBE_PRMT_SC_RETRIEVE';
775 --l_temp_retrieve_str := fnd_message.get;
776
777 wf_engine.SetItemAttrText(
778 itemtype => g_ItemType,
779 itemkey => p_item_key,
780 aname => 'RETRIEVEMSG_CODE',
781 avalue => l_temp_retrieve_str);
782 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
783 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for RETRIEVEMSG');
784 END IF;
785
786 wf_engine.SetItemAttrText(
787 itemtype => g_ItemType,
788 itemkey => p_item_key,
789 aname => 'SHNUM',
790 avalue => p_recipient_number);
791 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
792 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for SHNUM');
793 END IF;
794
795 END IF;
796
797
798 wf_engine.SetItemAttrText(
799 itemtype => g_ItemType,
800 itemkey => p_item_key,
801 aname => 'SENDTO',
802 avalue => p_adhoc_role);
803 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
804 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemAttribute for SENDTO');
805 END IF;
806
807 wf_engine.SetItemOwner(
808 itemtype => g_ItemType,
809 itemkey => p_item_key,
810 owner => l_item_owner);
811 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
812 IBE_UTIL.DEBUG('Set_item_attributes:Done setItemOwner');
813 END IF;
814
815 wf_engine.StartProcess(
816 itemtype => g_ItemType,
817 itemkey => p_item_key);
818 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
819 IBE_UTIL.DEBUG('Set_item_attributes:Done StartProcess');
820 END IF;
821 EXCEPTION
822 When OTHERS THEN
823 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
824 IBE_UTIL.DEBUG('Set_item_attributes:Exception block: '||SQLCODE||': '||SQLERRM);
825 END IF;
826 RAISE;
827 END ;
828
829
830
831 /*PROCEDURE Get_Name_details(p_party_id IN HZ_PARTIES.PARTY_ID%TYPE,
832 p_user_type IN VARCHAR2,
833 p_sharee_number IN NUMBER := FND_API.G_MISS_NUM,
834 x_contact_first_name OUT NOCOPY HZ_PARTIES.PERSON_FIRST_NAME%TYPE,
835 x_contact_last_name OUT NOCOPY HZ_PARTIES.PERSON_LAST_NAME%TYPE,
836 x_party_id OUT NOCOPY HZ_PARTIES.PARTY_ID%TYPE) IS
837
838 l_usertype jtf_um_usertypes_b.usertype_key%type;
839 l_contact_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
840 l_contact_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
841 l_partyid HZ_PARTIES.PARTY_ID%TYPE;
842
843 CURSOR c_get_recepient_name(p_party_id number) IS
844 SELECT person_first_name, person_last_name
845 FROM hz_parties
846 WHERE party_id = p_party_id;
847
848 rec_get_recepient_name c_get_recepient_name%rowtype;
849
850 CURSOR b2b_contact_info(p_party_id number) IS
851 SELECT p.person_first_name,
852 p.person_last_name,
853 p.party_id
854 FROM hz_relationships l,
855 hz_parties p
856 WHERE l.party_id = p_party_id
857 AND l.subject_id = p.party_id
858 AND l.subject_type = 'PERSON'
859 AND l.object_type = 'ORGANIZATION';
860 rec_party_info b2b_contact_info%rowtype;
861
862 BEGIN
863 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
864
865 ibe_util.debug('get_name_details:input user_type: '||p_user_type);
866 ibe_util.debug('get_name_details:input party_id: '||p_party_id);
867 ibe_util.debug('get_name_details:input sharee number: '||p_sharee_number);
868 END IF;
869
870
871 IF ((p_user_type = FND_API.G_MISS_CHAR)
872 OR (p_user_type = null)) THEN
873 -- User Type of the owner
874 getUserType(p_party_Id,l_UserType);
875 ELSE
876 l_userType := p_user_type;
877 END IF;
878 IF (l_userType = 'B2B') THEN
879
880 FOR rec_party_info IN b2b_contact_info(p_party_id)
881 LOOP
882 x_Contact_First_Name := rec_party_info.person_first_name;
883 x_Contact_last_name := rec_party_info.person_last_name;
884 x_party_id := rec_party_info.party_id;
885 END LOOP;
886 ELSE
887 x_party_id := p_party_id;
888 IF ((p_party_id is not null) or (p_party_id <> fnd_api.g_miss_num)) THEN
889 FOR rec_get_recepient_name IN c_get_recepient_name(p_party_id )
890 LOOP
891 x_contact_first_name := rec_get_recepient_name.person_first_name;
892 x_contact_last_name := rec_get_recepient_name.person_last_name;
893 END LOOP;
894 END IF;
895 END IF;
896 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
897
898 ibe_util.debug('get_name_details:output first_name: '||x_contact_first_name);
899 ibe_util.debug('get_name_details:input last_name: '||x_contact_first_name);
900 END IF;
901
902 END Get_Name_details;
903 */
904 /********************************************************
905 Get_Name_Details: Here the input parameters are:
906 party_id, User type.
907
908 This procedure is responsible to retrive the
909 First name, last name of the person.
910 ********************************************************/
911 --modified by abhandar for 11.5.10
912 --Modification : If party_type= person then
913 --retrieve name from the HZ_PARTY, else retrieve from the HZ_Relationship and HZ_Part tables .
914
915 PROCEDURE Get_Name_details(p_party_id IN HZ_PARTIES.PARTY_ID%TYPE,
916 p_user_type IN VARCHAR2,
917 p_sharee_number IN NUMBER := NULL,
918 x_contact_first_name OUT NOCOPY HZ_PARTIES.PERSON_FIRST_NAME%TYPE,
919 x_contact_last_name OUT NOCOPY HZ_PARTIES.PERSON_LAST_NAME%TYPE,
920 x_party_id OUT NOCOPY HZ_PARTIES.PARTY_ID%TYPE) IS
921
922 l_usertype jtf_um_usertypes_b.usertype_key%type;
923 l_contact_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
924 l_contact_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
925 l_partyid HZ_PARTIES.PARTY_ID%TYPE;
926 l_PartyType Varchar2(30);
927
928
929 CURSOR c_get_party_type_and_name (p_party_id number) IS
930 SELECT party_type, person_first_name, person_last_name,party_id
931 FROM hz_parties
932 WHERE party_id = p_party_id;
933
934 rec_get_recipient_name c_get_party_type_and_name%rowtype;
935
936 CURSOR c_b2b_contact_info(p_party_id number) IS
937 SELECT p.person_first_name,
938 p.person_last_name,
939 p.party_id
940 FROM hz_relationships l,
941 hz_parties p
942 WHERE l.party_id = p_party_id
943 AND l.subject_id = p.party_id
944 AND l.subject_type = 'PERSON'
945 AND l.object_type = 'ORGANIZATION';
946
947 rec_party_info c_b2b_contact_info%rowtype;
948
949 BEGIN
950 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
951 ibe_util.debug('get_name_details:input user_type: '||p_user_type);
952 ibe_util.debug('get_name_details:input party_id: '||p_party_id);
953 END IF;
954 open c_get_party_type_and_name(p_party_id);
955 Fetch c_get_party_type_and_name into l_partyType, x_contact_first_name ,x_contact_last_name,x_party_id ;
956
957 IF (l_PartyType<>'PERSON') THEN
958 FOR rec_party_info IN c_b2b_contact_info(p_party_id) LOOP
959 x_Contact_First_Name := rec_party_info.person_first_name;
960 x_Contact_last_name := rec_party_info.person_last_name;
961 x_party_id := rec_party_info.party_id;
962 END LOOP;
963 ELSE
964 x_party_id := p_party_id;
965
966 END IF;
967 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
968
969 ibe_util.debug('get_name_details:output first_name: '||x_contact_first_name);
970 ibe_util.debug('get_name_details:input last_name: '||x_contact_first_name);
971 END IF;
972
973 END Get_Name_details;
974
975
976
977 PROCEDURE NotifyForQuotePublish(
978 p_api_version IN NUMBER,
979 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
980 p_Msite_Id IN NUMBER,
981 p_quote_id IN VARCHAR2,
982 p_Req_Name IN Varchar2,
983 p_Send_Name IN Varchar2,
984 p_Email_Address IN Varchar2,
985 p_url IN Varchar2,
986 x_return_status OUT NOCOPY VARCHAR2,
987 x_msg_count OUT NOCOPY NUMBER,
988 x_msg_data OUT NOCOPY VARCHAR2
989 ) IS
990
991
992 g_ItemType Varchar2(10) := 'IBEALERT';
993 g_processName Varchar2(30) := 'PROCESSMAP';
994
995
996 l_adhoc_user WF_USERS.NAME%TYPE;
997 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
998 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
999
1000 l_partyId Number;
1001
1002 l_notifEnabled Varchar2(3) := 'Y';
1003 l_notifName Varchar2(30) := 'QUOTEPUB';
1004 l_OrgId Number := null;
1005 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
1006
1007 l_messageName WF_MESSAGES.NAME%TYPE;
1008 l_msgEnabled VARCHAR2(3) :='Y';
1009
1010 l_resource_id number;
1011 l_first_name JTF_RS_RESOURCE_EXTNS.SOURCE_FIRST_NAME%TYPE;
1012 l_last_name JTF_RS_RESOURCE_EXTNS.SOURCE_LAST_NAME%TYPE;
1013 l_full_name Varchar2(360);
1014
1015
1016
1017 Cursor C_login_User(c_login_name VARCHAR2) IS
1018 Select USR.CUSTOMER_ID Name
1019 From FND_USER USR
1020 Where USR.EMPLOYEE_ID is null
1021 and user_name = c_login_name;
1022
1023 Cursor C_Name_form_ResourceId(c_resource_id number)IS
1024 Select SOURCE_FIRST_NAME, SOURCE_LAST_NAME
1025 From JTF_RS_RESOURCE_EXTNS
1026 Where RESOURCE_ID = c_resource_id;
1027
1028 BEGIN
1029
1030 x_return_status := FND_API.g_ret_sts_success;
1031
1032
1033 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1034 ibe_util.debug('Check if this notification is enabled.');
1035 END IF;
1036 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
1037 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1038 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
1039 END IF;
1040
1041 If l_notifEnabled = 'Y' Then
1042
1043 l_adhoc_user := upper(p_send_name);
1044
1045 FOR c_rec IN c_login_user(l_adhoc_user) LOOP
1046 l_adhoc_user := 'HZ_PARTY:'||c_rec.Name;
1047 l_partyId := c_rec.Name;
1048 END LOOP;
1049
1050 l_orgId := MO_GLOBAL.get_current_org_id();
1051 getUserType(l_partyId,l_UserType);
1052
1053 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1054 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||' Org_id: '||to_char(l_orgId) ||' User Type: '||l_userType);
1055 END IF;
1056
1057 FOR c_quote_rec In c_quote_header(p_quote_id) LOOP
1058 l_resource_id := c_quote_rec.resource_id;
1059 END LOOP;
1060
1061 FOR c_jtf_rs_rec In C_Name_form_ResourceId(l_resource_id) LOOP
1062 l_first_name := c_jtf_rs_rec.source_first_name;
1063 l_last_name := c_jtf_rs_rec.source_last_name;
1064 END LOOP;
1065 l_full_name := l_last_name || ', ' || l_first_name;
1066
1067 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
1068 (
1069 p_org_id => l_OrgId,
1070 p_msite_id => p_msite_id,
1071 p_user_type => l_userType,
1072 p_notif_name => l_notifName,
1073 x_enabled_flag => l_msgEnabled,
1074 x_wf_message_name => l_MessageName,
1075 x_return_status => x_return_status,
1076 x_msg_data => x_msg_data,
1077 x_msg_count => x_msg_count);
1078
1079
1080 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1081 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
1082 END IF;
1083
1084
1085 If x_msg_count > 0 Then
1086 Raise GET_MESSAGE_ERROR;
1087 End if;
1088
1089 If l_msgEnabled = 'Y' Then
1090
1091 l_item_key := l_notifName||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_send_name;
1092
1093 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1094 ibe_util.debug('Create and Start Process with Item Key: '||l_item_key);
1095 END IF;
1096
1097 wf_engine.CreateProcess(
1098 itemtype => g_ItemType,
1099 itemkey => l_item_key,
1100 process => g_processName);
1101
1102 wf_engine.SetItemUserKey(
1103 itemtype => g_ItemType,
1104 itemkey => l_item_key,
1105 userkey => l_item_key);
1106
1107 wf_engine.SetItemAttrText(
1108 itemtype => g_ItemType,
1109 itemkey => l_item_key,
1110 aname => 'MESSAGE',
1111 avalue => l_MessageName);
1112
1113 wf_engine.SetItemAttrText(
1114 itemtype => g_ItemType,
1115 itemkey => l_item_key,
1116 aname => 'SENDTO',
1117 avalue => l_adhoc_user);
1118
1119 wf_engine.SetItemAttrText(
1120 itemtype => g_ItemType,
1121 itemkey => l_item_key,
1122 aname => 'EVENTTYPE',
1123 avalue => l_notifName);
1124
1125 wf_engine.SetItemAttrText(
1126 itemtype => g_ItemType,
1127 itemkey => l_item_key,
1128 aname => 'REQ_F_NAME',
1129 avalue => l_first_name);
1130
1131 wf_engine.SetItemAttrText(
1132 itemtype => g_ItemType,
1133 itemkey => l_item_key,
1134 aname => 'REQ_L_NAME',
1135 avalue => l_last_name);
1136
1137 wf_engine.SetItemAttrText(
1138 itemtype => g_ItemType,
1139 itemkey => l_item_key,
1140 aname => 'REQ_NAME',
1141 avalue => l_full_name);
1142
1143 wf_engine.SetItemAttrText(
1144 itemtype => g_ItemType,
1145 itemkey => l_item_key,
1146 aname => 'LOGINNAME',
1147 avalue => p_send_name);
1148
1149 wf_engine.SetItemAttrText(
1150 itemtype => g_ItemType,
1151 itemkey => l_item_key,
1152 aname => 'QUOTEID',
1153 avalue => p_quote_id);
1154
1155 wf_engine.SetItemAttrText(
1156 itemtype => g_ItemType,
1157 itemkey => l_item_key,
1158 aname => 'URL',
1159 avalue => p_url);
1160
1161 wf_engine.SetItemOwner(
1162 itemtype => g_ItemType,
1163 itemkey => l_item_key,
1164 owner => l_item_owner);
1165
1166 wf_engine.StartProcess(
1167 itemtype => g_ItemType,
1168 itemkey => l_item_key);
1169
1170 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1171 ibe_util.debug('Process Started');
1172 END IF;
1173
1174 End If;
1175 End If;
1176 Exception
1177
1178 When OTHERS Then
1179 x_return_status := FND_API.g_ret_sts_error;
1180 x_msg_count := 0;
1181
1182 wf_core.context('ibe_workflow_pvt',
1183 'NotifyRegistration',
1184 p_send_name
1185 );
1186 raise;
1187 END NotifyForQuotePublish;
1188
1189 -----------added by abhandar :08/26/03 - new procedure---------------
1190 PROCEDURE Generate_Approval_Msg(
1191 document_id IN VARCHAR2,
1192 display_type IN VARCHAR2,
1193 document IN OUT NOCOPY VARCHAR2,
1194 document_type IN OUT NOCOPY VARCHAR2
1195 ) is
1196 L_api_name CONSTANT VARCHAR2(30) := 'Generate_Approval_Msg';
1197 L_api_version CONSTANT NUMBER := 1.0;
1198
1199 L_quote_flag VARCHAR2(1) := fnd_api.g_true;
1200 L_tax_flag VARCHAR2(1) := fnd_api.g_true;
1201 BEGIN
1202 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1203 IBE_UTIL.DEBUG(L_api_name||':START: value of document id ='||document_id);
1204 END IF;
1205 FND_MESSAGE.set_name('IBE',document_id);
1206 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1207 IBE_UTIL.DEBUG(L_api_name||':After call to FND_MESSAGE.set_name()');
1208 END IF;
1209 document:=FND_MESSAGE.get();
1210 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1211 IBE_UTIL.DEBUG(L_api_name||'After Fnd_message.get(): document='||document);
1212 END IF;
1213 document_type := 'text/plain';
1214 EXCEPTION
1215 WHEN OTHERS THEN
1216 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1217 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_Approval_Msg');
1218 END IF;
1219
1220 END;
1221 ----------------------added by abhandar :end -----------------------
1222
1223 PROCEDURE Generate_Credential_Msg(
1224 document_id IN VARCHAR2,
1225 display_type IN VARCHAR2,
1226 document IN OUT NOCOPY VARCHAR2,
1227 document_type IN OUT NOCOPY VARCHAR2
1228 ) is
1229 L_api_name CONSTANT VARCHAR2(30) := 'Generate_Credential_Msg';
1230 L_api_version CONSTANT NUMBER := 1.0;
1231 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
1232 -- l_uname VARCHAR2(30);
1233 l_passwd VARCHAR2(30);
1234 l_credential_line VARCHAR2(255);
1235 BEGIN
1236 l_item_key:= document_id ;
1237 -- l_uname := wf_engine.GetItemAttrText (
1238 -- itemtype => g_itemType,
1239 -- itemkey => l_item_key,
1240 -- aname => 'LOGINNAME'
1241 -- );
1242 l_passwd := wf_engine.GetItemAttrText (
1243 itemtype => g_itemType,
1244 itemkey => l_item_key,
1245 aname => 'PASSWORD'
1246 );
1247
1248 document := ' ';
1249
1250 IF l_passwd is not null THEN
1251
1252 --FND_MESSAGE.set_name('IBE','IBE_UM_WF_USER_CREDENTIALS');
1253 -- FND_MESSAGE.Set_Token('LOGINNAME', l_uname);
1254 FND_MESSAGE.set_name('IBE','IBE_UM_WF_USER_CREDENTIAL_PWD');
1255 FND_MESSAGE.Set_Token('PASSWORD', l_passwd);
1256 l_credential_line := ' ' || FND_MESSAGE.get();
1257 ELSE
1258 l_credential_line := ' ';
1259
1260 END IF;
1261
1262 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1263 IBE_UTIL.DEBUG('ibe_workflow_pvt.Generater_Credential l_credential_line =' || l_credential_line);
1264 END IF;
1265 document := l_credential_line;
1266
1267 document_type := 'text/plain';
1268 EXCEPTION
1269 WHEN OTHERS THEN
1270 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1271 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_User_Credential_Msg');
1272 END IF;
1273 END Generate_Credential_Msg;
1274
1275
1276 /* PROCEDURE: To send out email alert for user registration.
1277 CALL IN FILE(s): RegisterationHandler.java
1278 */
1279
1280 PROCEDURE NotifyRegistration (
1281 p_api_version IN NUMBER,
1282 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1283 p_first_name IN VARCHAR2,
1284 p_last_name IN VARCHAR2,
1285 p_login_name IN VARCHAR2,
1286 p_password IN VARCHAR2,
1287 p_usertype IN VARCHAR2,
1288 p_email_address IN VARCHAR2,
1289 p_event_type IN VARCHAR2,
1290 p_language IN VARCHAR2,
1291 x_return_status OUT NOCOPY VARCHAR2,
1292 x_msg_count OUT NOCOPY NUMBER,
1293 x_msg_data OUT NOCOPY VARCHAR2
1294 ) IS
1295 Begin
1296
1297 NotifyRegistration (
1298 p_api_version,
1299 p_init_msg_list,
1300 null,
1301 p_first_name,
1302 p_last_name,
1303 p_login_name,
1304 p_password,
1305 p_usertype,
1306 p_email_address,
1307 p_event_type ,
1308 p_language,
1309 x_return_status,
1310 x_msg_count,
1311 x_msg_data
1312 );
1313
1314
1315 End NotifyRegistration;
1316
1317 PROCEDURE NotifyRegistration (
1318
1319 p_api_version IN NUMBER,
1320 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1321 p_Msite_Id IN NUMBER,
1322 p_first_name IN VARCHAR2,
1323 p_last_name IN VARCHAR2,
1324 p_login_name IN VARCHAR2,
1325 p_password IN VARCHAR2,
1326 p_usertype IN VARCHAR2,
1327 p_email_address IN VARCHAR2,
1328 p_event_type IN VARCHAR2,
1329 p_language IN VARCHAR2,
1330 x_return_status OUT NOCOPY VARCHAR2,
1331 x_msg_count OUT NOCOPY NUMBER,
1332 x_msg_data OUT NOCOPY VARCHAR2
1333 ) IS
1334 l_adhoc_user WF_USERS.NAME%TYPE;
1335 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
1336 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
1337 l_partyId Number;
1338 l_notifEnabled Varchar2(3) := 'Y';
1339 l_notifName Varchar2(30) := 'ACCTREGNOTIFICATION';
1340 l_OrgId Number := null;
1341 l_partyNum Varchar2(30);
1342 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
1343 l_messageName WF_MESSAGES.NAME%TYPE;
1344 l_msgEnabled VARCHAR2(3) :='Y';
1345
1346 --ab
1347
1348 l_url VARCHAR2(240) ; -- based on the JTA profile value
1349 l_merchant_name VARCHAR(240); -- based on the JTA profile value
1350 l_approval_id NUMBER;
1351 l_approval_msg_name VARCHAR2(1000);
1352 l_partner_pos NUMBER;
1353 --end ab
1354 Cursor C_login_User(c_login_name VARCHAR2) IS
1355 Select USR.CUSTOMER_ID Name
1356 From FND_USER USR
1357 Where USR.EMPLOYEE_ID is null
1358 and user_name = c_login_name;
1359 -- ab
1360 Cursor C_get_approval_id(c_usertype VARCHAR2) IS
1361 select approval_id from jtf_um_usertypes_b
1362 where usertype_key=c_usertype and (effective_end_date > sysdate or effective_end_date is null)
1363 and rownum= 1 and application_id=671;
1364
1365 Cursor C_get_org_num(c_party_id NUMBER) IS
1366 select b.party_number
1367 from hz_parties a,hz_parties b,hz_relationships c
1368 where a.party_id= c.party_id
1369 and b.party_id= c.object_id
1370 and c.subject_table_name = 'HZ_PARTIES'
1371 and c.object_table_name = 'HZ_PARTIES'
1372 and c.directional_flag = 'F'
1373 and a.party_id=c_party_id;
1374
1375 -- end-ab
1376 BEGIN
1377
1378 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1379 ibe_util.debug('NotifyRegistration :start notification for p_login_name='||p_login_name);
1380 END If;
1381 -- get the URL from the profile
1382 l_url:=FND_PROFILE.value ('JTA_UM_APPL_URL');
1383
1384 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1385 ibe_util.debug('NotifyRegistration:l_url='||l_url);
1386 END If;
1387 -- get the merchant name from the profile
1388 l_merchant_name:= FND_PROFILE.value('JTF_UM_MERCHANT_NAME');
1389 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1390 ibe_util.debug('NotifyRegistration:l_merchant_name='||l_merchant_name);
1391 END If;
1392 -- end-ab
1393 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1394 ibe_util.debug('Check if this notification is enabled.');
1395 END IF;
1396 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
1397
1398 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1399 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
1400 END IF;
1401
1402 If l_notifEnabled = 'Y' Then
1403 l_adhoc_user := upper(p_login_name);
1404 FOR c_rec IN c_login_user(l_adhoc_user) LOOP
1405 l_adhoc_user := 'HZ_PARTY:'||c_rec.Name;
1406 l_partyId := c_rec.Name;
1407 END LOOP;
1408 l_orgId := MO_GLOBAL.get_current_org_id();
1409
1410 OPEN C_get_org_num(l_partyId);
1411 FETCH C_get_org_num into l_partyNum;
1412 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1413 ibe_util.debug('NotifyRegistration '||':l_partyId='||l_partyId ||':p_UserType='||p_UserType||'l_orgId='||l_orgId||':l_partyNum='||l_partyNum);
1414 END IF;
1415 CLOSE C_get_org_num;
1416
1417 -- getUserType(l_partyId,l_UserType);
1418 l_UserType:=p_usertype;
1419
1420 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1421 ibe_util.debug('NotifyRegistration:Before Get Message - MsiteId: '||to_Char(p_msite_id)||' Org_id: '||to_char(l_orgId)
1422 ||' User Type: '||l_userType);
1423
1424 END IF;
1425 --ab-start
1426 -- get the approval id associated with the user type
1427
1428 OPEN C_get_approval_id(l_UserType);
1429 FETCH C_get_approval_id into l_approval_id;
1430 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1431 ibe_util.debug('NotifyRegistration:l_approval_id='||l_approval_id);
1432 END IF;
1433 IF C_get_approval_id%FOUND AND l_approval_id >0 THEN
1434 ibe_util.debug('NotifyRegistration:Approval id associated with the user type');
1435 ------ approval associated with the user type -----------
1436 IF (l_UserType='IBE_INDIVIDUAL') THEN
1437 l_approval_msg_name:='IBE_APPRVL_REQD_B2C';
1438 ELSIF (l_UserType='IBE_PRIMARY') OR (l_UserType='IBE_BUSINESS') THEN
1439 l_approval_msg_name:='IBE_APPRVL_REQD_B2B';
1440 ELSIF (l_UserType='IBE_PARTNER_PRIMARY') OR (l_UserType='IBE_PARTNER_BUSINESS') THEN
1441 l_approval_msg_name:='IBE_APPRVL_REQD_PRM';
1442 ELSE
1443 l_approval_msg_name:= l_UserType||'_APPR';
1444 ibe_util.debug('NotifyRegistration:l_approval_msg =: '||fnd_message.get(l_approval_msg_name));
1445 If fnd_message.get(l_approval_msg_name)= l_approval_msg_name Then
1446 l_approval_msg_name:='IBE_APPRVL_REQD_CUST';
1447 End if;
1448 END IF;
1449 ELSE --approval not associated with the user type
1450 ibe_util.debug('NotifyRegistration:Approval not associated with the user type');
1451 IF (l_UserType='IBE_INDIVIDUAL') THEN
1452 l_approval_msg_name:='IBE_APPRVL_NOT_REQD_B2C';
1453 ELSIF (l_UserType='IBE_PRIMARY')OR (l_UserType='IBE_BUSINESS') THEN
1454 l_approval_msg_name:='IBE_APPRVL_NOT_REQD_B2B';
1455 ELSIF (l_UserType='IBE_PARTNER_PRIMARY') OR (l_UserType='IBE_PARTNER_BUSINESS') THEN
1456 l_approval_msg_name:='IBE_APPRVL_NOT_REQD_PRM';
1457 ELSE
1458 l_approval_msg_name:= l_UserType||'_NOAPPR';
1459 ibe_util.debug('NotifyRegistration:l_approval_msg =: '||fnd_message.get(l_approval_msg_name));
1460 If fnd_message.get(l_approval_msg_name)= l_approval_msg_name Then
1461 l_approval_msg_name:='IBE_APPRVL_NOT_REQD_CUST';
1462 End if;
1463 END IF;
1464 END IF;
1465 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1466 ibe_util.debug('NotifyRegistration:l_approval_msg_name='||l_approval_msg_name);
1467 END IF;
1468 CLOSE C_get_approval_id;
1469 --end ab
1470 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
1471 ( p_org_id => l_OrgId,
1472 p_msite_id => p_msite_id,
1473 p_user_type => l_userType,
1474 p_notif_name => l_notifName,
1475 x_enabled_flag => l_msgEnabled,
1476 x_wf_message_name => l_MessageName,
1477 x_return_status => x_return_status,
1478 x_msg_data => x_msg_data,
1479 x_msg_count => x_msg_count);
1480
1481 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1482 ibe_util.debug('NotifyRegistration:Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
1483 ibe_util.debug('NotifyRegistration:x_msg_count=:'||x_msg_count);
1484 END IF;
1485 -- If x_msg_count > 0 Then
1486 -- Raise GET_MESSAGE_ERROR;
1487 -- End if;
1488 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1489 ibe_util.debug('NotifyRegistration:l_msg_enabled='||l_msgEnabled);
1490 END IF;
1491 If l_msgEnabled = 'Y' Then
1492 l_item_key := p_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_login_name;
1493 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1494 ibe_util.debug('NotifyRegistration:Create and Start Process with Item Key: '||l_item_key);
1495 ibe_util.debug('The attributes to be set are: Message='||l_MessageName ||
1496 ':ApprovalMsgId='||l_approval_msg_name||
1497 ':FirstName='||p_first_name|| ':LastName='||p_last_name || ':LoginName=' ||p_login_name ||
1498 ':emailAddress='|| p_email_address || ':eventType='||p_event_type ||
1499 ':sendTo='||l_adhoc_user ||':URL=''||l_url'||':orgnum='||l_partyNum ||
1500 ':merchantName='||l_merchant_name);
1501 END IF;
1502 wf_engine.CreateProcess(
1503 itemtype => g_ItemType,
1504 itemkey => l_item_key,
1505 process => g_processName);
1506
1507 wf_engine.SetItemUserKey(
1508 itemtype => g_ItemType,
1509 itemkey => l_item_key,
1510 userkey => l_item_key);
1511
1512 wf_engine.SetItemAttrText(
1513 itemtype => g_ItemType,
1514 itemkey => l_item_key,
1515 aname => 'MESSAGE',
1516 avalue => l_MessageName);
1517
1518 wf_engine.SetItemAttrText(
1519 itemtype => g_ItemType,
1520 itemkey => l_item_key,
1521 aname => 'FIRSTNAME',
1522 avalue => p_first_name);
1523
1524 wf_engine.SetItemAttrText(
1525 itemtype => g_ItemType,
1526 itemkey => l_item_key,
1527 aname => 'LASTNAME',
1528 avalue => p_last_name);
1529
1530 wf_engine.SetItemAttrText(
1531 itemtype => g_ItemType,
1532 itemkey => l_item_key,
1533 aname => 'LOGINNAME',
1534 avalue => p_login_name);
1535
1536 wf_engine.SetItemAttrText(
1537 itemtype => g_ItemType,
1538 itemkey => l_item_key,
1539 aname => 'PASSWORD',
1540 avalue => p_password);
1541
1542 wf_engine.SetItemAttrText(
1543 itemtype => g_ItemType,
1544 itemkey => l_item_key,
1545 aname => 'EMAILADDRESS',
1546 avalue => p_email_address);
1547
1548 wf_engine.SetItemAttrText(
1549 itemtype => g_ItemType,
1550 itemkey => l_item_key,
1551 aname => 'EVENTTYPE',
1552 avalue => p_event_type);
1553
1554 wf_engine.SetItemAttrText(
1555 itemtype => g_ItemType,
1556 itemkey => l_item_key,
1557 aname => 'SENDTO',
1558 avalue => l_adhoc_user);
1559 -- start ab
1560 wf_engine.SetItemAttrText(
1561 itemtype => g_ItemType,
1562 itemkey => l_item_key,
1563 aname => 'ISTOREURL',
1564 avalue => l_url);
1565
1566 wf_engine.SetItemAttrText(
1567 itemtype => g_ItemType,
1568 itemkey => l_item_key,
1569 aname => 'APPROVALMSGID',
1570 avalue => l_approval_msg_name);
1571
1572 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1573 ibe_util.debug('NotifyRegistration :set attribute APPROVALMSGID='|| l_approval_msg_name);
1574 END IF;
1575
1576 wf_engine.SetItemAttrText(
1577 itemtype => g_ItemType,
1578 itemkey => l_item_key,
1579 aname => 'ORGNUM',
1580 avalue => l_partyNum);
1581
1582 wf_engine.SetItemAttrText(
1583 itemtype => g_ItemType,
1584 itemkey => l_item_key,
1585 aname => 'MERCHANTNAME',
1586 avalue => l_merchant_name);
1587 -- end ab
1588
1589 wf_engine.SetItemAttrText(
1590 itemtype => g_ItemType,
1591 itemkey => l_item_key,
1592 aname => 'ITEMKEY',
1593 avalue => l_item_key);
1594
1595 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1596 ibe_util.debug('NotifyRegistration : Item key set as'|| l_item_key);
1597 END IF;
1598
1599 wf_engine.SetItemOwner(
1600 itemtype => g_ItemType,
1601 itemkey => l_item_key,
1602 owner => l_item_owner);
1603
1604 wf_engine.StartProcess(
1605 itemtype => g_ItemType,
1606 itemkey => l_item_key);
1607
1608 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1609 ibe_util.debug('NotifyRegistration :workflow Process Started');
1610 END IF;
1611 End If;
1612 End If;
1613 Exception
1614 When OTHERS Then
1615 x_return_status := FND_API.g_ret_sts_error;
1616 x_msg_count := 0;
1617 wf_core.context('ibe_workflow_pvt',
1618 'NotifyRegistration',
1619 p_login_name
1620 );
1621 raise;
1622 END NotifyRegistration;
1623
1624 --Bug 2111316
1625 PROCEDURE NotifyForgetLogin(
1626 p_api_version IN NUMBER,
1627 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1628 p_Msite_Id IN NUMBER,
1629 p_first_name IN VARCHAR2,
1630 p_last_name IN VARCHAR2,
1631 p_login_name IN VARCHAR2,
1632 p_password IN VARCHAR2,
1633 p_email_address IN VARCHAR2,
1634 x_return_status OUT NOCOPY VARCHAR2,
1635 x_msg_count OUT NOCOPY NUMBER,
1636 x_msg_data OUT NOCOPY VARCHAR2
1637 ) IS
1638
1639 l_adhoc_user WF_USERS.NAME%TYPE;
1640 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
1641 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
1642
1643 l_partyId Number;
1644
1645 l_event_type Varchar2(30) := 'FORGETLOGIN';
1646 l_notifEnabled Varchar2(3) := 'Y';
1647 l_notifName Varchar2(30) := 'FORGETLOGINNOTIFICATION';
1648 l_OrgId Number := null;
1649 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
1650
1651 l_messageName WF_MESSAGES.NAME%TYPE;
1652 l_msgEnabled VARCHAR2(3) :='Y';
1653
1654 CURSOR c_login_User(c_login_name VARCHAR2) IS
1655 SELECT USR.CUSTOMER_ID Name
1656 FROM FND_USER USR
1657 WHERE USR.EMPLOYEE_ID IS NULL
1658 AND user_name = c_login_name;
1659
1660 BEGIN
1661
1662 x_return_status := FND_API.g_ret_sts_success;
1663
1664
1665 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1666 ibe_util.debug('Check if this notification is enabled.');
1667 END IF;
1668
1669 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
1670
1671 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1672 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||
1673 l_notifEnabled);
1674 END IF;
1675
1676 IF l_notifEnabled = 'Y' THEN
1677 l_adhoc_user := upper(p_login_name);
1678
1679 FOR c_rec IN c_login_user(l_adhoc_user) LOOP
1680 l_adhoc_user := 'HZ_PARTY:'||c_rec.Name;
1681 l_partyId := c_rec.Name;
1682 END LOOP;
1683
1684 l_orgId := MO_GLOBAL.get_current_org_id();
1685 getUserType(l_partyId,l_UserType);
1686
1687 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1688 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||
1689 ' Org_id: '||to_char(l_orgId) ||' User Type: '||
1690 l_userType);
1691 END IF;
1692
1693 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
1694 (
1695 p_org_id => l_OrgId,
1696 p_msite_id => p_msite_id,
1697 p_user_type => l_userType,
1698 p_notif_name => l_notifName,
1699 x_enabled_flag => l_msgEnabled,
1700 x_wf_message_name => l_MessageName,
1701 x_return_status => x_return_status,
1702 x_msg_data => x_msg_data,
1703 x_msg_count => x_msg_count);
1704
1705
1706 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1707 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||
1708 l_msgEnabled);
1709 END IF;
1710 IF x_msg_count > 0 THEN
1711 Raise GET_MESSAGE_ERROR;
1712 END IF;
1713
1714 IF l_msgEnabled = 'Y' THEN
1715
1716 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||
1717 '-'||p_login_name;
1718 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1719 ibe_util.debug('Create and Start Process with Item Key: '||l_item_key);
1720 END IF;
1721
1722 wf_engine.CreateProcess(
1723 itemtype => g_ItemType,
1724 itemkey => l_item_key,
1725 process => g_processName);
1726
1727 wf_engine.SetItemUserKey(
1728 itemtype => g_ItemType,
1729 itemkey => l_item_key,
1730 userkey => l_item_key);
1731
1732 wf_engine.SetItemAttrText(
1733 itemtype => g_ItemType,
1734 itemkey => l_item_key,
1735 aname => 'MESSAGE',
1736 avalue => l_MessageName);
1737
1738 wf_engine.SetItemAttrText(
1739 itemtype => g_ItemType,
1740 itemkey => l_item_key,
1741 aname => 'FIRSTNAME',
1742 avalue => p_first_name);
1743
1744 wf_engine.SetItemAttrText(
1745 itemtype => g_ItemType,
1746 itemkey => l_item_key,
1747 aname => 'LASTNAME',
1748 avalue => p_last_name);
1749
1750 wf_engine.SetItemAttrText(
1751 itemtype => g_ItemType,
1752 itemkey => l_item_key,
1753 aname => 'LOGINNAME',
1754 avalue => p_login_name);
1755
1756 wf_engine.SetItemAttrText(
1757 itemtype => g_ItemType,
1758 itemkey => l_item_key,
1759 aname => 'PASSWORD',
1760 avalue => p_password);
1761
1762 wf_engine.SetItemAttrText(
1763 itemtype => g_ItemType,
1764 itemkey => l_item_key,
1765 aname => 'EMAILADDRESS',
1766 avalue => p_email_address);
1767
1768 wf_engine.SetItemAttrText(
1769 itemtype => g_ItemType,
1770 itemkey => l_item_key,
1771 aname => 'EVENTTYPE',
1772 avalue => l_event_type);
1773
1774 wf_engine.SetItemAttrText(
1775 itemtype => g_ItemType,
1776 itemkey => l_item_key,
1777 aname => 'SENDTO',
1778 avalue => l_adhoc_user);
1779
1780 wf_engine.SetItemOwner(
1781 itemtype => g_ItemType,
1782 itemkey => l_item_key,
1783 owner => l_item_owner);
1784
1785 wf_engine.StartProcess(
1786 itemtype => g_ItemType,
1787 itemkey => l_item_key);
1788
1789 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1790 ibe_util.debug('Process Started');
1791 END IF;
1792
1793 END IF;
1794 END IF;
1795
1796 EXCEPTION
1797
1798 WHEN OTHERS THEN
1799 x_return_status := FND_API.g_ret_sts_error;
1800 x_msg_count := 0;
1801 wf_core.context('ibe_workflow_pvt', 'NotifyForgetLogin', p_login_name);
1802 raise;
1803
1804 END NotifyForgetLogin;
1805
1806
1807 /* PROCEDURE: To send out email alert for various order status information.
1808 CALL IN FILE(s): Quote.java -> IBEVQASB.pls
1809 */
1810
1811 PROCEDURE NotifyOrderStatus(
1812 p_api_version IN NUMBER,
1813 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1814 p_quote_id IN NUMBER,
1815 p_status IN VARCHAR2,
1816 p_errmsg_count IN NUMBER,
1817 p_errmsg_data IN VARCHAR2,
1818 p_sharee_partyId IN NUMBER := NULL,
1819 x_return_status OUT NOCOPY VARCHAR2,
1820 x_msg_count OUT NOCOPY NUMBER,
1821 x_msg_data OUT NOCOPY VARCHAR2
1822 ) IS
1823
1824 Begin
1825
1826 NotifyOrderStatus(
1827 p_api_version,
1828 p_init_msg_list,
1829 null,
1830 p_quote_id,
1831 p_status,
1832 p_errmsg_count,
1833 p_errmsg_data,
1834 p_sharee_partyId,
1835 x_return_status,
1836 x_msg_count,
1837 x_msg_data);
1838
1839 END NotifyOrderStatus;
1840
1841 PROCEDURE NotifyOrderStatus(
1842 p_api_version IN NUMBER,
1843 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
1844 p_msite_id IN NUMBER,
1845 p_quote_id IN NUMBER,
1846 p_status IN VARCHAR2,
1847 p_errmsg_count IN NUMBER,
1848 p_errmsg_data IN VARCHAR2,
1849 p_sharee_partyId IN NUMBER,
1850 x_return_status OUT NOCOPY VARCHAR2,
1851 x_msg_count OUT NOCOPY NUMBER,
1852 x_msg_data OUT NOCOPY VARCHAR2
1853 ) IS
1854
1855 l_adhoc_user WF_USERS.NAME%TYPE;
1856 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
1857 l_event_type VARCHAR2(20);
1858 l_email_addr WF_USERS.Email_Address%TYPE;
1859 l_this NUMBER;
1860 l_temp_str VARCHAR2(2000);
1861 l_next NUMBER;
1862 l_errmsg_count NUMBER;
1863 l_errmsg_data VARCHAR2(32000);
1864 l_party_id NUMBER;
1865 lx_party_id NUMBER;
1866 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
1867 l_order_id NUMBER;
1868 l_partyId Number;
1869 l_first_name VARCHAR2(2000);
1870 l_last_name VARCHAR2(2000);
1871
1872 l_notifEnabled Varchar2(3) := 'Y';
1873 l_notifName Varchar2(30) := 'ORDCONFNOTIFICATION';
1874 l_Orgid Number := null;
1875 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
1876
1877 l_messageName WF_MESSAGES.NAME%TYPE;
1878 l_msgEnabled VARCHAR2(3) :='Y';
1879
1880 l_payment_code Varchar2(30) := 'NOPO';
1881 l_msite_name VARCHAR2(2000);
1882 l_permission_to_view_price BOOLEAN;
1883 l_view_net_price_flag VARCHAR2(1);
1884 l_paynow_flag VARCHAR2(1);
1885 l_reccharge_flag VARCHAR2(1);
1886 l_adhoc_role WF_ROLES.NAME%TYPE;
1887 l_adhoc_role_display WF_ROLES.DISPLAY_NAME%TYPE;
1888 l_admin_email_addr WF_USERS.email_address%TYPE;
1889 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
1890 l_admin_adhoc_user WF_USERS.NAME%TYPE;
1891 l_admin_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
1892 l_role_users Varchar2(200);
1893 l_card_number Varchar2(50);--bug 6877589 ukalaiah
1894
1895
1896 /* Cursor c_minisite_name(p_msite number) is
1897 SELECT msite_name
1898 FROM ibe_msites_vl
1899 WHERE msite_id = p_msite;
1900 rec_minisite_name c_minisite_name%rowtype;*/
1901
1902 --bug 6877589 ukalaiah
1903 Cursor c_card_number (l_order_id NUMBER) IS
1904 --bug 10016159 SELECT itev.card_number FROM IBY_TRXN_EXTENSIONS_V itev
1905 SELECT itev.card_number FROM IBY_EXTN_INSTR_DETAILS_V itev
1906 WHERE itev.order_id = trim(to_char(l_order_id)) and instrument_type = 'CREDITCARD';
1907
1908 BEGIN
1909 x_return_status := FND_API.g_ret_sts_success;
1910 -- Check for WorkFlow Feature Availablity.
1911 /*for rec_minisite_name in c_minisite_name(p_msite_id) loop
1912 l_msite_name := 'Msite_name'||rec_minisite_name.msite_name;
1913 exit when c_minisite_name%notfound;
1914 end loop;*/
1915
1916 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1917 ibe_util.debug('Minisite_id in NotifyOrderStatus is: '||p_msite_id);
1918 END IF;
1919 /* Success 'S' indicates order confirmation for Credit Card or Fax Orders */
1920 l_adhoc_user := NULL;
1921 IF ( p_status = 'S' ) THEN
1922 FOR c_quote_rec In c_quote_header(p_quote_id) LOOP
1923 l_adhoc_user :='HZ_PARTY:'||c_quote_rec.party_id;
1924 l_order_id := c_quote_rec.order_id;
1925 l_partyId := c_quote_rec.party_id;
1926 l_orgId := c_quote_rec.org_id;
1927 END LOOP;
1928 FOR g_header_rec In c_order_header(l_order_id) LOOP
1929 l_event_type := 'ORDCONF';
1930 l_notifName := 'ORDCONFNOTIFICATION';
1931
1932 IF trim(g_header_rec.payment_type_code) is NULL Then
1933 FOR c_quote_pay In c_quote_payment(p_quote_id) LOOP
1934 l_payment_code := c_quote_pay.payment_type_code;
1935 End Loop;
1936 If l_payment_code = 'PO' Then
1937 l_event_type := 'ORDFAX';
1938 l_notifName := 'ORDFAXNOTIFICATION';
1939 End If;
1940 --bug 6877589 ukalaiah
1941 --ElsIf ( g_header_rec.payment_type_code = 'CREDIT_CARD' And trim(g_header_rec.credit_card_number) is NULL) THEN
1942 ElsIf ( g_header_rec.payment_type_code = 'CREDIT_CARD') THEN
1943
1944 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1945 ibe_util.debug('trying for credit card '||to_char(l_order_id));
1946 END IF;
1947 OPEN c_card_number(l_order_id);
1948 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1949 ibe_util.debug('opened the cursor successfully');
1950 END IF;
1951
1952 IF (c_card_number%NOTFOUND) THEN
1953 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1954 ibe_util.debug('query returned zero rows, event type: fax');
1955 END IF;
1956 l_event_type := 'ORDFAX';
1957 l_notifName := 'ORDFAXNOTIFICATION';
1958 ELSE
1959 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1960 ibe_util.debug('query returned some rows, looking for credit card');
1961 END IF;
1962 FETCH c_card_number into l_card_number;
1963 IF (trim(l_card_number) is NULL) THEN
1964 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1965 ibe_util.debug('query returned some rows, credit card number not exist');
1966 END IF;
1967 l_event_type := 'ORDFAX';
1968 l_notifName := 'ORDFAXNOTIFICATION';
1969 END IF;
1970 END IF;
1971 CLOSE c_card_number;
1972 END IF;
1973 END LOOP;
1974 ElsIF ( p_status = 'E' )THEN
1975 l_event_type := 'ORDERROR';
1976 l_notifName := 'ORDNOTBOOKNOTIFICATION';
1977 l_errmsg_count := p_errmsg_count;
1978 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1979 ibe_util.debug('Notify Order Status - Error Message Count - '||to_char(l_errmsg_count));
1980 END IF;
1981 IF ( l_errmsg_count = 1 ) THEN
1982 l_errmsg_data := p_errmsg_data;
1983 ELSE
1984 l_this := 1;
1985 l_errmsg_data := '';
1986 WHILE ( l_this <= l_errmsg_count ) LOOP
1987 l_temp_str := null;
1988 fnd_msg_pub.Get(l_this,FND_API.G_FALSE,l_temp_str,l_next);
1989 l_errmsg_data := l_errmsg_data || TAB || TAB ||l_temp_str || NEWLINE;
1990 l_this := l_this + 1;
1991 END LOOP;
1992 END IF;
1993 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1994 ibe_util.debug('NotifyOrderStatus - Error Message Data After LOOP - '||l_errmsg_data);
1995 END IF;
1996 END IF;
1997
1998 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1999 ibe_util.debug('Check if this notification is enabled.');
2000 END IF;
2001 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
2002 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2003 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
2004 END IF;
2005 If l_notifEnabled = 'Y' Then
2006 IF ( p_status = 'S' ) THEN
2007 getUserType(l_partyId,l_UserType);
2008 if(l_userType = 'IBE_PARTNER' or l_userType = 'IBE_PARTNER_PRIMARY') THEN
2009 l_admin_email_addr := FND_PROFILE.VALUE_SPECIFIC('IBE_ORDER_ADMIN',null,null,671);
2010 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
2011 l_admin_adhoc_user := 'IBEU'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id ;
2012 l_admin_adhoc_user_display := 'IBEU'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
2013 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2014 IBE_UTIL.DEBUG('Partner Order-AdminEmail '||l_admin_email_addr||'Name'||l_admin_adhoc_user||'preference'||l_notification_preference);
2015 END IF;
2016 wf_directory.CreateAdHocUser(
2017 name => l_admin_adhoc_user,
2018 display_name => l_admin_adhoc_user_display,
2019 notification_preference => l_notification_preference,
2020 email_address => l_admin_email_addr,
2021 expiration_date => sysdate + 1,
2022 language => 'AMERICAN');
2023 l_role_users := l_adhoc_user||','||l_admin_adhoc_user;
2024 l_adhoc_role := 'IBEC'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
2025 l_adhoc_role_display := 'IBEC'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
2026
2027 wf_directory.CreateAdHocRole
2028 (role_name => l_adhoc_role,
2029 role_display_name => l_adhoc_role_display,
2030 language => 'AMERICAN',
2031 notification_preference => l_notification_preference,
2032 role_users => l_role_users,
2033 expiration_date => sysdate + 1);
2034 l_adhoc_user := l_adhoc_role;
2035 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2036 IBE_UTIL.DEBUG('Partner Order-Adhoc Role: '||l_adhoc_user);
2037 END IF;
2038 END IF; --Partner UserType End If
2039 Else
2040 L_adhoc_user := FND_PROFILE.VALUE_SPECIFIC('IBE_DEF_ORDER_ADMIN_EMAIL',null,null,671);
2041 l_orgId := null;
2042 l_userType := 'ALL';
2043 FOR c_quote_rec In c_quote_header(p_quote_id) LOOP
2044 l_order_id := c_quote_rec.order_id;
2045 END LOOP;
2046 End if;
2047 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2048 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||' Org_id: '||to_char(l_orgId)||' User Type: '||l_userType);
2049 END IF;
2050
2051 /*The following function call determines whether the user has permission
2052 to view Price or not. This ibe_util.check_user_permission return TRUE if the permission
2053 to view net price is enabled for this user otherwise this function return false */
2054
2055 l_permission_to_view_price := ibe_util.check_user_permission( p_permission => 'IBE_VIEW_NET_PRICE' );
2056 l_paynow_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_PAY_NOW',null,null,671), 'N');
2057 l_reccharge_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_RECURRING_CHARGES',null,null,671), 'N');
2058
2059 IF (l_permission_to_view_price) THEN
2060 l_view_net_price_flag := 'Y';
2061 ELSE
2062 l_view_net_price_flag := 'N';
2063 END IF;
2064
2065 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping(
2066 p_org_id => l_OrgId ,
2067 p_msite_id => p_msite_id ,
2068 p_user_type => l_userType ,
2069 p_notif_name => l_notifName ,
2070 x_enabled_flag => l_msgEnabled ,
2071 x_wf_message_name => l_MessageName ,
2072 x_return_status => x_return_status,
2073 x_msg_data => x_msg_data ,
2074 x_msg_count => x_msg_data);
2075 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2076 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
2077 END IF;
2078 If x_msg_count > 0 Then
2079 Raise GET_MESSAGE_ERROR;
2080 End if;
2081 If l_msgEnabled = 'Y' Then
2082 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2083 ibe_util.debug('NotifyOrderStatus - p_quote_id - '||to_char(p_quote_id)||','||p_status);
2084 END IF;
2085
2086 get_name_details(
2087 p_party_id => l_partyId,
2088 p_user_type => FND_API.G_MISS_CHAR,
2089 x_contact_first_name => l_first_name,
2090 x_contact_last_name => l_last_name,
2091 x_party_id => lx_party_id);
2092
2093 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2094 ibe_util.debug('first_name of the owner: '||l_first_name);
2095 END IF;
2096 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_id;
2097 /* Item Key should be Unique as it represent a process instance with ITEM TYPE*/
2098 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2099 ibe_util.debug('Create and Start Process with Item Key: '||l_item_key);
2100 END IF;
2101 wf_engine.CreateProcess(
2102 itemtype => g_ItemType,
2103 itemkey => l_item_key,
2104 process => g_processName);
2105 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2106 ibe_util.debug('DONE:Create and Start Process with Item Key: '||l_item_key);
2107 END IF;
2108
2109
2110 wf_engine.SetItemUserKey(
2111 itemtype => g_ItemType,
2112 itemkey => l_item_key,
2113 userkey => l_item_key);
2114 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2115 ibe_util.debug('NotifyOrderStatus: Done setItemUserKey');
2116 END IF;
2117
2118 wf_engine.SetItemAttrText(
2119 itemtype => g_ItemType,
2120 itemkey => l_item_key,
2121 aname => 'MESSAGE',
2122 avalue => l_MessageName);
2123 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2124 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for MESSAGE');
2125 END IF;
2126
2127 wf_engine.SetItemAttrText(
2128 itemtype => g_ItemType,
2129 itemkey => l_item_key,
2130 aname => 'ITEMKEY',
2131 avalue => l_item_key);
2132 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2133 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for ITEMKEY');
2134 END IF;
2135
2136 wf_engine.SetItemAttrText(
2137 itemtype => g_ItemType,
2138 itemkey => l_item_key,
2139 aname => 'EVENTTYPE',
2140 avalue => l_event_type);
2141 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2142 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for EVENTTYPE');
2143 END IF;
2144
2145 wf_engine.SetItemAttrText(
2146 itemtype => g_ItemType,
2147 itemkey => l_item_key,
2148 aname => 'QUOTEID',
2149 avalue => p_quote_id);
2150 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2151 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for QUOTEID');
2152 END IF;
2153
2154 wf_engine.SetItemAttrText(
2155 itemtype => g_ItemType,
2156 itemkey => l_item_key,
2157 aname => 'MSITEID',
2158 avalue => p_msite_id);
2159 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2160 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for MSITENAME');
2161 END IF;
2162
2163 wf_engine.SetItemAttrText(
2164 itemtype => g_ItemType,
2165 itemkey => l_item_key,
2166 aname => 'FIRSTNAME',
2167 avalue => l_first_name);
2168
2169 wf_engine.SetItemAttrText(
2170 itemtype => g_ItemType,
2171 itemkey => l_item_key,
2172 aname => 'LASTNAME',
2173 avalue => l_last_name);
2174
2175
2176 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2177 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for FIRSTNAME');
2178 END IF;
2179
2180 wf_engine.SetItemAttrText(
2181 itemtype => g_ItemType,
2182 itemkey => l_item_key,
2183 aname => 'ORDERID',
2184 avalue => l_order_id);
2185 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2186 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for ORDERID');
2187 END IF;
2188
2189 wf_engine.SetItemAttrText(
2190 itemtype => g_ItemType,
2191 itemkey => l_item_key,
2192 aname => 'VIEWNETPRICE',
2193 avalue => l_view_net_price_flag);
2194
2195 wf_engine.SetItemAttrText(
2196 itemtype => g_ItemType,
2197 itemkey => l_item_key,
2198 aname => 'RECCHARGEENABLED',
2199 avalue => l_reccharge_flag);
2200
2201 wf_engine.SetItemAttrText(
2202 itemtype => g_ItemType,
2203 itemkey => l_item_key,
2204 aname => 'PAYNOWENABLED',
2205 avalue => l_paynow_flag);
2206
2207
2208 wf_engine.SetItemAttrText(
2209 itemtype => g_ItemType,
2210 itemkey => l_item_key,
2211 aname => 'SENDTO',
2212 avalue => l_adhoc_user);
2213 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2214 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for SENDTO');
2215 END IF;
2216
2217 wf_engine.SetItemAttrText(
2218 itemtype => g_ItemType,
2219 itemkey => l_item_key,
2220 aname => 'ERRMSG',
2221 avalue => l_errmsg_data);
2222 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2223 ibe_util.debug('NotifyOrderStatus: Done setItemAttrText for ERRMSG');
2224 END IF;
2225
2226 wf_engine.SetItemOwner(
2227 itemtype => g_ItemType,
2228 itemkey => l_item_key,
2229 owner => l_item_owner);
2230 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2231 ibe_util.debug('NotifyOrderStatus: Done setItemOwner');
2232 END IF;
2233
2234 wf_engine.StartProcess(
2235 itemtype => g_ItemType,
2236 itemkey => l_item_key);
2237
2238 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2239 ibe_util.debug('Process Started');
2240 END IF;
2241
2242 End If;
2243 END IF;
2244
2245 IF(p_status = 'E' and l_order_id IS NOT NULL) then
2246 FOR g_header_rec In c_order_header(l_order_id) LOOP
2247 l_event_type := 'ORDCONF';
2248 l_notifName := 'ORDCONFNOTIFICATION';
2249
2250 IF trim(g_header_rec.payment_type_code) is NULL Then
2251 FOR c_quote_pay In c_quote_payment(p_quote_id) LOOP
2252 l_payment_code := c_quote_pay.payment_type_code;
2253 End Loop;
2254 If l_payment_code = 'PO' Then
2255 l_event_type := 'ORDFAX';
2256 l_notifName := 'ORDFAXNOTIFICATION';
2257 End If;
2258 --bug 6877589 ukalaiah
2259 --ElsIf ( g_header_rec.payment_type_code = 'CREDIT_CARD' And trim(g_header_rec.credit_card_number) is NULL)
2260 ElsIf ( g_header_rec.payment_type_code = 'CREDIT_CARD' )
2261 THEN
2262 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2263 ibe_util.debug('2:trying for credit card '||to_char(l_order_id));
2264 END IF;
2265 OPEN c_card_number(l_order_id);
2266 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2267 ibe_util.debug('2:opened the cursor successfully');
2268 END IF;
2269
2270 IF (c_card_number%NOTFOUND) THEN
2271 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2272 ibe_util.debug('2:query returned zero rows, event type: fax');
2273 END IF;
2274 l_event_type := 'ORDFAX';
2275 l_notifName := 'ORDFAXNOTIFICATION';
2276 ELSE
2277 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2278 ibe_util.debug('2:query returned some rows, looking for credit card');
2279 END IF;
2280 FETCH c_card_number into l_card_number;
2281 IF (trim(l_card_number) is NULL) THEN
2282 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2283 ibe_util.debug('2:query returned some rows, credit card number not exist');
2284 END IF;
2285 l_event_type := 'ORDFAX';
2286 l_notifName := 'ORDFAXNOTIFICATION';
2287 END IF;
2288 END IF;
2289
2290 CLOSE c_card_number;
2291 END IF;
2292 END LOOP;
2293 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
2294 END IF;
2295 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2296 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
2297 END IF;
2298
2299
2300 /*2369138
2301 If (l_msgEnabled = 'Y') AND (l_event_type = 'ORDCONF')
2302 AND (p_status = 'S')
2303 AND (p_sharee_partyId IS NOT NULL) Then*/
2304 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2305 ibe_util.debug('NotifyOrderStatus:p_sharee_party_id: '||p_sharee_partyId);
2306 END IF;
2307
2308 IF (l_notifEnabled = 'Y') AND (p_sharee_partyId IS NOT NULL) THEN
2309 l_partyid := p_sharee_partyid;
2310 l_adhoc_user := 'HZ_PARTY:'||p_sharee_partyId;
2311 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_id||'-'||l_partyId;
2312 getUserType(l_partyId, l_UserType);
2313
2314
2315 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping(
2316 p_org_id => l_OrgId,
2317 p_msite_id => p_msite_id,
2318 p_user_type => l_userType,
2319 p_notif_name => l_notifName,
2320 x_enabled_flag => l_msgEnabled,
2321 x_wf_message_name => l_MessageName,
2322 x_return_status => x_return_status,
2323 x_msg_data => x_msg_data,
2324 x_msg_count => x_msg_data);
2325 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2326 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
2327 END IF;
2328 If x_msg_count > 0 Then
2329 Raise GET_MESSAGE_ERROR;
2330 End if;
2331
2332 If l_msgEnabled = 'Y' Then
2333 get_name_details(
2334 p_party_id => p_sharee_partyid,
2335 p_user_type => FND_API.G_MISS_CHAR,
2336 x_contact_first_name => l_first_name,
2337 x_contact_last_name => l_last_name,
2338 x_party_id => l_partyid);
2339
2340
2341 /*The following function call determines whether the user has permission
2342 to view Price or not. This ibe_util.check_user_permission return TRUE if the permission
2343 to view net price is enabled for this user otherwise this function return false */
2344
2345 l_permission_to_view_price := ibe_util.check_user_permission( p_permission => 'IBE_VIEW_NET_PRICE' );
2346 l_paynow_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_PAY_NOW',null,null,671), 'N');
2347 l_reccharge_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_RECURRING_CHARGES',null,null,671), 'N');
2348
2349 IF (l_permission_to_view_price) THEN
2350 l_view_net_price_flag := 'Y';
2351 ELSE
2352 l_view_net_price_flag := 'N';
2353 END IF;
2354
2355
2356 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2357 ibe_util.debug('first_name of the recipient: '||l_first_name);
2358 END IF;
2359
2360 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2361 ibe_util.debug('NotifyOrderStatus - p_quote_id - '||to_char(p_quote_id)||','||p_status);
2362 ibe_util.debug('Create and Start Process with Item Key: '||l_item_key);
2363 END IF;
2364 wf_engine.CreateProcess(
2365 itemtype => g_ItemType,
2366 itemkey => l_item_key,
2367 process => g_processName);
2368
2369 wf_engine.SetItemUserKey(
2370 itemtype => g_ItemType,
2371 itemkey => l_item_key,
2372 userkey => l_item_key);
2373
2374 wf_engine.SetItemAttrText(
2375 itemtype => g_ItemType,
2376 itemkey => l_item_key,
2377 aname => 'MESSAGE',
2378 avalue => l_MessageName);
2379
2380
2381 wf_engine.SetItemAttrText(
2382 itemtype => g_ItemType,
2383 itemkey => l_item_key,
2384 aname => 'ITEMKEY',
2385 avalue => l_item_key);
2386
2387
2388 wf_engine.SetItemAttrText(
2389 itemtype => g_ItemType,
2390 itemkey => l_item_key,
2391 aname => 'EVENTTYPE',
2392 avalue => l_event_type);
2393
2394 wf_engine.SetItemAttrText(
2395 itemtype => g_ItemType,
2396 itemkey => l_item_key,
2397 aname => 'QUOTEID',
2398 avalue => p_quote_id);
2399
2400 wf_engine.SetItemAttrText(
2401 itemtype => g_ItemType,
2402 itemkey => l_item_key,
2403 aname => 'ORDERID',
2404 avalue => l_order_id);
2405
2406 wf_engine.SetItemAttrText(
2407 itemtype => g_ItemType,
2408 itemkey => l_item_key,
2409 aname => 'VIEWNETPRICE',
2410 avalue => l_view_net_price_flag);
2411
2412 wf_engine.SetItemAttrText(
2413 itemtype => g_ItemType,
2414 itemkey => l_item_key,
2415 aname => 'RECCHARGEENABLED',
2416 avalue => l_reccharge_flag);
2417
2418 wf_engine.SetItemAttrText(
2419 itemtype => g_ItemType,
2420 itemkey => l_item_key,
2421 aname => 'PAYNOWENABLED',
2422 avalue => l_paynow_flag);
2423
2424 wf_engine.SetItemAttrText(
2425 itemtype => g_ItemType,
2426 itemkey => l_item_key,
2427 aname => 'MSITENAME',
2428 avalue => l_msite_name);
2429
2430 wf_engine.SetItemAttrText(
2431 itemtype => g_ItemType,
2432 itemkey => l_item_key,
2433 aname => 'FIRSTNAME',
2434 avalue => l_first_name);
2435
2436 wf_engine.SetItemAttrText(
2437 itemtype => g_ItemType,
2438 itemkey => l_item_key,
2439 aname => 'LASTNAME',
2440 avalue => l_last_name);
2441
2442
2443 wf_engine.SetItemAttrText(
2444 itemtype => g_ItemType,
2445 itemkey => l_item_key,
2446 aname => 'SENDTO',
2447 avalue => l_adhoc_user);
2448
2449 wf_engine.SetItemAttrText(
2450 itemtype => g_ItemType,
2451 itemkey => l_item_key,
2452 aname => 'ERRMSG',
2453 avalue => l_errmsg_data);
2454
2455 wf_engine.SetItemOwner(
2456 itemtype => g_ItemType,
2457 itemkey => l_item_key,
2458 owner => l_item_owner);
2459
2460 wf_engine.StartProcess(
2461 itemtype => g_ItemType,
2462 itemkey => l_item_key);
2463
2464 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2465 ibe_util.debug('Process Started');
2466 END IF;
2467 End if;
2468 End If;
2469 Exception
2470 When OTHERS Then
2471 x_return_status := FND_API.g_ret_sts_error;
2472 x_msg_count := 0;
2473
2474 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2475 IBE_UTIL.DEBUG('NotifyOrderStatus:Exception block: '||SQLCODE||': '||SQLERRM);
2476 END IF;
2477
2478 wf_core.context('ibe_workflow_pvt',
2479 'NotifyOrderStatus',
2480 l_event_type,
2481 to_char(p_quote_id)
2482 );
2483 raise;
2484
2485 END NotifyOrderStatus;
2486
2487 /********************************************************
2488 NotifyReturnOrderStatus: Here the input parameters are
2489 party_id of the user and
2490 order_header_id of the return order.
2491
2492 This procedure is responsible to send a retun order confirmation
2493 email to the end user. This notification has 2 differnt messages
2494 for B2B and B2C users.
2495 Here permission based pricing logic is incorporated.
2496 *********************************************************/
2497
2498 PROCEDURE NotifyReturnOrderStatus(
2499 p_api_version IN NUMBER,
2500 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2501 p_party_id IN NUMBER,
2502 p_order_header_id IN NUMBER,
2503 p_errmsg_count IN NUMBER,
2504 p_errmsg_data IN VARCHAR2,
2505 x_return_status OUT NOCOPY VARCHAR2,
2506 x_msg_count OUT NOCOPY NUMBER,
2507 x_msg_data OUT NOCOPY VARCHAR2
2508 ) IS
2509
2510
2511 l_user_name WF_USERS.NAME%TYPE;
2512 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
2513 l_event_type VARCHAR2(20);
2514 l_party_id NUMBER;
2515 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
2516 l_order_header_id NUMBER;
2517 l_permission_to_view_price BOOLEAN;
2518 l_view_net_price_flag VARCHAR2(1);
2519 x_recepient_party_id NUMBER;
2520 l_first_name VARCHAR2(2000);
2521 l_last_name VARCHAR2(2000);
2522 l_notifEnabled VARCHAR2(3) := 'Y';
2523 l_notifName VARCHAR2(30) ;
2524 l_Orgid NUMBER := null;
2525 l_UserType jtf_um_usertypes_b.usertype_key%type;
2526 l_messageName WF_MESSAGES.NAME%TYPE;
2527 l_msgEnabled VARCHAR2(3) :='Y';
2528 l_minisite_id NUMBER := null; -- bug 8337371, scnagara
2529
2530
2531
2532 BEGIN
2533 x_return_status := FND_API.g_ret_sts_success;
2534
2535
2536 l_event_type := 'RETURNORDER';
2537
2538 l_party_id := p_party_id;
2539
2540 -- identify whether the user type is B2B (IBE_BUSINESS, IBE_PRIMARY, IBE_PARTNER_PRIMARY
2541 -- and IBE_PARTNER_BUSINESS )or B2C (IBE_INDIVIDUAL).
2542 -- Based on the use type, set the notifications.
2543
2544
2545 l_notifName := 'IBE_RETURNORDERCONF';
2546 -- initialize the user type variable.
2547 l_usertype := FND_API.G_MISS_CHAR;
2548 GetUserType(l_party_id,l_usertype);
2549 l_user_name := 'HZ_PARTY:'||l_party_id;
2550
2551 -- Call the Get_Name_details to get the party_id of the email recepient.
2552
2553 x_recepient_party_id := 0;
2554
2555 Get_Name_details(p_party_id => l_party_id,
2556 p_user_type => l_UserType,
2557 x_contact_first_name => l_first_name,
2558 x_contact_last_name => l_last_name,
2559 x_party_id => x_recepient_party_id);
2560
2561 -- l_user_name := 'HZ_PARTY:'||x_recepient_party_id;
2562
2563 l_order_header_id := p_order_header_id;
2564
2565 l_OrgId := MO_GLOBAL.get_current_org_id(); -- bug 7720550, scnagara
2566 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2567 IBE_UTIL.DEBUG('NotifyReturnOrderStatus org id : '|| l_OrgId);
2568 END IF;
2569
2570 FOR g_header_rec In c_order_header(l_order_header_id) LOOP -- bug 8337371, scnagara
2571 l_minisite_id := g_header_rec.minisite_id;
2572 END LOOP;
2573
2574 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2575 IBE_UTIL.DEBUG('NotifyReturnOrderStatus: l_order_header_id = ' || l_order_header_id);
2576 IBE_UTIL.DEBUG('NotifyReturnOrderStatus: l_usertype = ' || l_usertype);
2577 IBE_UTIL.DEBUG('NotifyReturnOrderStatus: l_Orgid = ' || l_Orgid);
2578 IBE_UTIL.DEBUG('NotifyReturnOrderStatus: l_minisite_id = ' || l_minisite_id);
2579 IBE_UTIL.DEBUG('NotifyReturnOrderStatus: l_party_id = ' || l_party_id);
2580 END IF;
2581
2582
2583 /* Check whether the notification is enabled or not */
2584 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
2585
2586
2587
2588 IF l_notifEnabled = 'Y' Then
2589
2590
2591 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping(
2592 p_org_id => l_OrgId ,
2593 -- p_msite_id => NULL , -- bug 8337371, scnagara
2594 p_msite_id => l_minisite_id , -- bug 8337371, scnagara
2595 p_user_type => l_userType ,
2596 p_notif_name => l_notifName ,
2597 x_enabled_flag => l_msgEnabled ,
2598 x_wf_message_name => l_MessageName ,
2599 x_return_status => x_return_status,
2600 x_msg_data => x_msg_data ,
2601 x_msg_count => x_msg_data);
2602
2603 -- Get permission based pricing value from api function
2604
2605 l_permission_to_view_price := ibe_util.check_user_permission( p_permission => 'IBE_VIEW_NET_PRICE' );
2606 IF (l_permission_to_view_price) THEN
2607 l_view_net_price_flag := 'Y';
2608 ELSE
2609 l_view_net_price_flag := 'N';
2610 END IF;
2611
2612
2613 If l_msgEnabled = 'Y' Then
2614
2615 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||l_order_header_id;
2616
2617 wf_engine.CreateProcess(
2618 itemtype => g_ItemType,
2619 itemkey => l_item_key,
2620 process => g_processName);
2621
2622 wf_engine.SetItemUserKey(
2623 itemtype => g_ItemType,
2624 itemkey => l_item_key,
2625 userkey => l_item_key);
2626
2627 wf_engine.SetItemAttrText(
2628 itemtype => g_ItemType,
2629 itemkey => l_item_key,
2630 aname => 'MESSAGE',
2631 avalue => l_MessageName);
2632
2633 wf_engine.SetItemAttrText(
2634 itemtype => g_ItemType,
2635 itemkey => l_item_key,
2636 aname => 'ITEMKEY',
2637 avalue => l_item_key);
2638
2639 wf_engine.SetItemAttrText(
2640 itemtype => g_ItemType,
2641 itemkey => l_item_key,
2642 aname => 'EVENTTYPE',
2643 avalue => l_event_type);
2644
2645
2646 wf_engine.SetItemAttrText(
2647 itemtype => g_ItemType,
2648 itemkey => l_item_key,
2649 aname => 'FIRSTNAME',
2650 avalue => l_first_name);
2651
2652 wf_engine.SetItemAttrText(
2653 itemtype => g_ItemType,
2654 itemkey => l_item_key,
2655 aname => 'LASTNAME',
2656 avalue => l_last_name);
2657
2658 wf_engine.SetItemAttrText(
2659 itemtype => g_ItemType,
2660 itemkey => l_item_key,
2661 aname => 'VIEWNETPRICE',
2662 avalue => l_view_net_price_flag);
2663
2664
2665
2666 wf_engine.SetItemAttrText(
2667 itemtype => g_ItemType,
2668 itemkey => l_item_key,
2669 aname => 'STOREUSERTYPE',
2670 avalue => l_usertype);
2671
2672 wf_engine.SetItemAttrText(
2673 itemtype => g_ItemType,
2674 itemkey => l_item_key,
2675 aname => 'ORDERID',
2676 avalue => l_order_header_id);
2677
2678 wf_engine.SetItemAttrText(
2679 itemtype => g_ItemType,
2680 itemkey => l_item_key,
2681 aname => 'SENDTO',
2682 avalue => l_user_name);
2683
2684 wf_engine.SetItemOwner(
2685 itemtype => g_ItemType,
2686 itemkey => l_item_key,
2687 owner => l_item_owner);
2688
2689
2690
2691 wf_engine.StartProcess(
2692 itemtype => g_ItemType,
2693 itemkey => l_item_key);
2694
2695
2696 End If;
2697
2698 END IF;
2699
2700
2701 Exception
2702 When OTHERS Then
2703 x_return_status := FND_API.g_ret_sts_error;
2704 x_msg_count := 0;
2705
2706 wf_core.context('ibe_workflow_pvt',
2707 'NotifyReturnOrderStatus',
2708 l_event_type,
2709 to_char(l_order_header_id)
2710 );
2711 raise;
2712
2713 END NotifyReturnOrderStatus;
2714
2715
2716 /*This procedure is used to get the contact details of the owner of the order.
2717 Dependinng on the user type two seperate cursors are used to retrieve contact details of B2C or B2B users*/
2718
2719 Procedure get_contact_details_for_order(
2720 p_api_version IN NUMBER,
2721 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2722 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
2723 p_order_id IN NUMBER,
2724 x_contact_party_id OUT NOCOPY NUMBER,
2725 x_contact_first_name OUT NOCOPY VARCHAR2,
2726 x_contact_mid_name OUT NOCOPY VARCHAR2,
2727 x_contact_last_name OUT NOCOPY VARCHAR2,
2728 x_return_status OUT NOCOPY VARCHAR2,
2729 x_msg_count OUT NOCOPY NUMBER,
2730 x_msg_data OUT NOCOPY VARCHAR2
2731 ) is
2732 Cursor c_b2b_contact(c_order_id Number) IS
2733 Select p.party_id Person_Party_id,
2734 l.party_id contact_party_id,
2735 p.person_first_name,
2736 p.person_last_name,
2737 p.party_type,
2738 o.sold_to_contact_id
2739 from oe_order_headers_all o,
2740 hz_cust_Account_roles r,
2741 hz_relationships l,
2742 hz_parties p
2743 where o.header_id = c_order_id
2744 and o.sold_to_contact_id = r.cust_account_role_id
2745 and r.party_id = l.party_id
2746 and l.subject_id = p.party_id
2747 and l.subject_type = 'PERSON'
2748 and l.object_type = 'ORGANIZATION';
2749
2750 cursor c_b2c_contact(c_order_id number) is
2751 select p.party_id,
2752 p.party_type,
2753 p.person_first_name,
2754 p.person_last_name,
2755 p.person_middle_name
2756
2757 from hz_cust_accounts a,
2758 oe_order_headers_all o,
2759 hz_parties p
2760 where o.sold_to_org_id = a.cust_account_id
2761 and a.party_id = p.party_id
2762 and o.header_id = c_order_id;
2763
2764 cursor c_last_updated_by(c_order_id number) is
2765 select f.customer_id ,
2766 o.sold_to_contact_id,
2767 o.last_updated_by ,
2768 p.person_first_name ,
2769 p.person_middle_name,
2770 p.person_last_name
2771 from hz_parties p,
2772 oe_order_headers_all o,
2773 fnd_user f,
2774 hz_relationships r
2775 where o.last_updated_by = f.user_id
2776 and f.customer_id = r.party_id
2777 and r.subject_id = p.party_id
2778 and r.subject_type = 'PERSON'
2779 and r.object_type = 'ORGANIZATION'
2780 and o.header_id = c_order_id;
2781
2782 rec_b2c_contact c_b2c_contact%rowtype;
2783 rec_b2b_contact c_b2b_contact%rowtype;
2784 rec_last_updated_by c_last_updated_by%rowtype;
2785 l_sold_to_contact NUMBER;
2786 l_contact_party_id NUMBER;
2787 l_contact_first_name VARCHAR2(2000);
2788 l_contact_mid_name VARCHAR2(2000);
2789 l_contact_last_name VARCHAR2(2000);
2790
2791 l_party_type VARCHAR2(2000);
2792 G_PKG_NAME CONSTANT VARCHAR2(30) := 'ibe_workflow_pvt';
2793 l_api_name CONSTANT VARCHAR2(50) := 'Get_contact_details';
2794 l_api_version NUMBER := 1.0;
2795
2796 BEGIN
2797
2798 -- Standard Start of API savepoint
2799 SAVEPOINT get_contact_details_for_order;
2800 ----DBMS_OUTPUT.PUT('Standard Start of API savepoint');
2801 -- Standard call to check for call compatibility.
2802 IF NOT FND_API.Compatible_API_Call(L_API_VERSION,
2803 p_api_version,
2804 L_API_NAME ,
2805 G_PKG_NAME )
2806 THEN
2807 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2808 END IF;
2809
2810 -- Initialize message list if p_init_msg_list is set to TRUE.
2811 IF FND_API.To_Boolean(p_init_msg_list) THEN
2812 FND_Msg_Pub.initialize;
2813 END IF;
2814
2815 -- Initialize API return status to success
2816 x_return_status := FND_API.G_RET_STS_SUCCESS;
2817 --Start of API Body
2818 ----DBMS_OUTPUT.PUT('Start of API Body');
2819 ----DBMS_OUTPUT.PUT('Order id is: '||p_order_id);
2820 FOR rec_b2c_contact in c_b2c_contact(p_order_id) LOOP
2821 l_party_type := rec_b2c_contact.party_type;
2822 ----DBMS_OUTPUT.PUT('Party type is: '||l_party_type);
2823 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2824 IBE_UTIL.debug('L_party_type in get_contact_details_for_order: '||l_party_type);
2825 END IF;
2826 IF (l_party_type = 'PERSON') then --B2C user, get the details directly from hz_parties
2827 x_contact_party_id := rec_b2c_contact.party_id;
2828 x_contact_first_name := rec_b2c_contact.person_first_name;
2829 x_contact_mid_name := rec_b2c_contact.person_middle_name;
2830 x_contact_last_name := rec_b2c_contact.person_last_name;
2831 END IF;
2832 exit when c_b2c_contact%notfound;
2833 END LOOP;
2834
2835 IF (l_party_type = 'ORGANIZATION') then --B2B user, determine party_id of type 'RELATIONSHIP'
2836 --sold_to_contact_id in oe_order_headers_all is the account_id
2837 --of the organization owning the order
2838 FOR rec_b2b_contact IN c_b2b_contact(p_order_id) LOOP
2839 ----DBMS_OUTPUT.PUT('Order id is: '||p_order_id);
2840 l_sold_to_contact := rec_b2b_contact.sold_to_contact_id;
2841 l_contact_party_id := rec_b2b_contact.contact_party_id;
2842 l_contact_first_name := rec_b2b_contact.person_first_name; --details of the 'PERSON' tied to the
2843 l_contact_mid_name := rec_b2c_contact.person_middle_name;--'RELATIONSHIP'
2844 l_contact_last_name := rec_b2c_contact.person_last_name;
2845 EXIT when c_b2b_contact%notfound;
2846 END LOOP;
2847 IF(l_sold_to_contact is null) THEN
2848 --last_updated_by column saves the fnd user_id. Customer_id column in fnd_user table saves the
2849 --party_id of the person who last_updated the order. Hence l_contact_party_id is assigned the value of
2850 --customer_id from fnd_user table.
2851 FOR rec_last_updated_by in c_last_updated_by(p_order_id) LOOP
2852 l_contact_party_id := rec_last_updated_by.customer_id;
2853 l_contact_first_name := rec_last_updated_by.person_first_name;
2854 l_contact_mid_name := rec_last_updated_by.person_middle_name;
2855 l_contact_last_name := rec_last_updated_by.person_last_name;
2856 EXIT when c_last_updated_by%NOTFOUND;
2857 END LOOP;
2858 END IF;
2859 x_contact_party_id := l_contact_party_id;
2860 x_contact_first_name := l_contact_first_name;
2861 x_contact_mid_name := l_contact_mid_name;
2862 x_contact_last_name := l_contact_last_name;
2863 END IF;
2864
2865 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2866 IBE_UTIL.Debug('x_contact_party_id: '||x_contact_party_id);
2867 IBE_UTIL.Debug('x_contact_first_name: '||x_contact_first_name);
2868 IBE_UTIL.Debug('x_contact_last_name: '||x_contact_last_name);
2869 END IF;
2870
2871 -- Standard check of p_commit.
2872 IF FND_API.To_Boolean(p_commit) THEN
2873 COMMIT WORK;
2874 END IF;
2875
2876 -- Standard call to get message count and if count is 1, get message info.
2877 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2878 p_count => x_msg_count ,
2879 p_data => x_msg_data);
2880 EXCEPTION
2881 WHEN FND_API.G_EXC_ERROR THEN
2882 ROLLBACK TO get_contact_details_for_order;
2883 x_return_status := FND_API.G_RET_STS_ERROR;
2884 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2885 p_count => x_msg_count ,
2886 p_data => x_msg_data);
2887 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2888 ROLLBACK TO get_contact_details_for_order;
2889 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2890 FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2891 p_count => x_msg_count ,
2892 p_data => x_msg_data);
2893 WHEN OTHERS THEN
2894 ROLLBACK TO get_contact_details_for_order;
2895 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2896 IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2897 FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
2898 L_API_NAME);
2899 END IF;
2900
2901 END;
2902
2903 PROCEDURE Notify_cancel_order(
2904 p_api_version IN NUMBER,
2905 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
2906 p_order_id IN NUMBER,
2907 x_return_status OUT NOCOPY VARCHAR2,
2908 x_msg_count OUT NOCOPY NUMBER,
2909 x_msg_data OUT NOCOPY VARCHAR2
2910 ) is
2911
2912 l_cust_adhoc_user WF_USERS.NAME%TYPE;
2913 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
2914 l_event_type VARCHAR2(20) := 'CNCLORDR';
2915 l_errmsg_count NUMBER;
2916 l_errmsg_data VARCHAR2(32000);
2917 l_party_id NUMBER;
2918 l_contact_party_id NUMBER;
2919 l_msite_name VARCHAR2(2000);
2920 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
2921 l_order_id NUMBER;
2922 l_quote_id NUMBER;
2923 l_order_num NUMBER;
2924 l_contact_first_name VARCHAR2(2000);
2925 l_contact_mid_name VARCHAR2(2000);
2926 l_contact_last_name VARCHAR2(2000);
2927
2928
2929 l_notifEnabled Varchar2(3) := 'Y';
2930 l_notifName Varchar2(30) := 'CANCELORDER';
2931 l_Orgid Number := null;
2932 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
2933 l_messageName WF_MESSAGES.NAME%TYPE := 'CANCELORDER';
2934 l_msgEnabled VARCHAR2(3) :='Y';
2935
2936
2937 BEGIN
2938 --ibe_util.enable_debug;
2939 ----DBMS_OUTPUT.PUT('reday to call Notify_cancel_order');
2940 x_return_status := FND_API.g_ret_sts_success;
2941 -- Check for WorkFlow Feature Availablity.
2942 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2943 ibe_util.debug('Check if this notification is enabled.');
2944 END IF;
2945 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
2946 ----DBMS_OUTPUT.PUT('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
2947 --l_notifEnabled := 'Y';
2948 If l_notifEnabled = 'Y' Then
2949 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2950 IBE_UTIL.debug('Getting the contact party id');
2951 END IF;
2952 ----DBMS_OUTPUT.PUT('Getting the contact party id');
2953 ibe_workflow_pvt.get_contact_details_for_order
2954 (p_api_version => 1.0 ,
2955 p_init_msg_list => FND_API.G_TRUE ,
2956 p_commit => FND_API.G_FALSE ,
2957 p_order_id => p_order_id ,
2958 x_contact_party_id => l_contact_party_id,
2959 x_contact_first_name => l_contact_first_name,
2960 x_contact_mid_name => l_contact_mid_name,
2961 x_contact_last_name => l_contact_last_name,
2962 x_return_status => x_return_status,
2963 x_msg_count => x_msg_count,
2964 x_msg_data => x_msg_data ) ;
2965 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2966 RAISE FND_API.G_EXC_ERROR;
2967 END IF;
2968
2969 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2970 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2971 END IF;
2972 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2973 IBE_UTIL.DEBUG('Contact party_id in Notify_Cancel_Order obtained from get_contact_from_order: '||l_contact_party_id);
2974 END IF;
2975 ----DBMS_OUTPUT.PUT('Contact party_id in Notify_Cancel_Order obtained from get_contact_from_order: '||l_contact_party_id);
2976 getUserType(l_contact_party_Id,
2977 l_UserType);
2978 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2979 IBE_UTIL.debug('Getting the contact party id');
2980 END IF;
2981 l_cust_adhoc_user := 'HZ_PARTY:'||l_contact_party_id;--'HZ_PARTY:4230';
2982
2983
2984 --select the order number here
2985 select order_number into l_order_num
2986 from oe_order_headers_all i
2987 where header_id = p_order_id;
2988
2989
2990 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2991 ibe_util.debug('Get Message - Org_id: '||to_char(l_orgId)||' User Type: '||l_userType);
2992 END IF;
2993 ----DBMS_OUTPUT.PUT('Get Message - Org_id: '||to_char(l_orgId)||' User Type: '||l_userType);
2994
2995 l_OrgId := MO_GLOBAL.get_current_org_id(); -- bug 7720550, scnagara
2996 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2997 ibe_util.debug('Get Message - After setting, l_OrgId: '||to_char(l_OrgId));
2998 END IF;
2999
3000 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping(
3001 p_org_id => l_OrgId,
3002 p_msite_id => NULL,
3003 p_user_type => l_userType,
3004 p_notif_name => l_notifName,
3005 x_enabled_flag => l_msgEnabled,
3006 x_wf_message_name => l_MessageName,
3007 x_return_status => x_return_status,
3008 x_msg_data => x_msg_data,
3009 x_msg_count => x_msg_data);
3010 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3011 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
3012 END IF;
3013 ----DBMS_OUTPUT.PUT('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
3014 If x_msg_count > 0 Then
3015 Raise GET_MESSAGE_ERROR;
3016 End if;
3017 If l_msgEnabled = 'Y' Then
3018 --ibe_util.debug('NotifyOrderStatus - p_quote_id - '||to_char(p_quote_id)||','||p_status);
3019 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_order_id;
3020 /* Item Key should be Unique as it represent a process instance with ITEM TYPE*/
3021 ----DBMS_OUTPUT.PUT('Create and Start Process with Item Key: '||l_item_key);
3022
3023 wf_engine.CreateProcess(
3024 itemtype => g_ItemType,
3025 itemkey => l_item_key,
3026 process => g_processName);
3027
3028 wf_engine.SetItemUserKey(
3029 itemtype => g_ItemType,
3030 itemkey => l_item_key,
3031 userkey => l_item_key);
3032
3033 wf_engine.SetItemAttrText(
3034 itemtype => g_ItemType,
3035 itemkey => l_item_key,
3036 aname => 'MESSAGE',
3037 avalue => l_MessageName);
3038
3039 wf_engine.SetItemAttrText(
3040 itemtype => g_ItemType,
3041 itemkey => l_item_key,
3042 aname => 'ITEMKEY',
3043 avalue => l_item_key);
3044
3045 wf_engine.SetItemAttrText(
3046 itemtype => g_ItemType,
3047 itemkey => l_item_key,
3048 aname => 'EVENTTYPE',
3049 avalue => l_event_type);
3050
3051 wf_engine.SetItemAttrText(
3052 itemtype => g_ItemType,
3053 itemkey => l_item_key,
3054 aname => 'QUOTEID',
3055 avalue => l_quote_id);
3056
3057 wf_engine.SetItemAttrText(
3058 itemtype => g_ItemType,
3059 itemkey => l_item_key,
3060 aname => 'ORDERID',
3061 avalue => P_order_id);
3062
3063 wf_engine.SetItemAttrText(
3064 itemtype => g_ItemType,
3065 itemkey => l_item_key,
3066 aname => 'ORDERNUMBER',
3067 avalue => l_order_num);
3068
3069 wf_engine.SetItemAttrText(
3070 itemtype => g_ItemType,
3071 itemkey => l_item_key,
3072 aname => 'FIRSTNAME',
3073 avalue => l_contact_first_name);
3074
3075 wf_engine.SetItemAttrText(
3076 itemtype => g_ItemType,
3077 itemkey => l_item_key,
3078 aname => 'LASTNAME',
3079 avalue => l_contact_last_name);
3080
3081 wf_engine.SetItemAttrText(
3082 itemtype => g_ItemType,
3083 itemkey => l_item_key,
3084 aname => 'SENDTO',
3085 avalue => l_cust_adhoc_user);
3086
3087 wf_engine.SetItemAttrText(
3088 itemtype => g_ItemType,
3089 itemkey => l_item_key,
3090 aname => 'ERRMSG',
3091 avalue => l_errmsg_data);
3092
3093 wf_engine.SetItemOwner(
3094 itemtype => g_ItemType,
3095 itemkey => l_item_key,
3096 owner => l_item_owner);
3097
3098 wf_engine.StartProcess(
3099 itemtype => g_ItemType,
3100 itemkey => l_item_key);
3101
3102 ----DBMS_OUTPUT.PUT('Process Started');
3103
3104
3105 End If;
3106 End If;
3107 Exception
3108 When OTHERS Then
3109 x_return_status := FND_API.g_ret_sts_error;
3110 x_msg_count := 0;
3111 wf_core.context('ibe_workflow_pvt',
3112 'NotifyOrderStatus',
3113 l_event_type,
3114 to_char(p_order_id)
3115 );
3116 raise;
3117
3118 END Notify_cancel_order;
3119
3120
3121 /* PROCEDURE: To send out email alert for change in contract status.
3122
3123 */
3124
3125 PROCEDURE NotifyForContractsStatus(
3126 p_api_version IN NUMBER,
3127 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3128 p_quote_id IN NUMBER,
3129 p_contract_id IN NUMBER,
3130 p_contract_status IN NUMBER,
3131 x_return_status OUT NOCOPY VARCHAR2,
3132 x_msg_count OUT NOCOPY NUMBER,
3133 x_msg_data OUT NOCOPY VARCHAR2
3134 ) IS
3135
3136 l_event_type VARCHAR(20);
3137 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
3138 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
3139
3140 l_quote_org_id NUMBER;
3141
3142 l_org_contract_rep WF_USERS.NAME%TYPE;
3143 l_customer_user WF_USERS.NAME%TYPE;
3144
3145 l_quote_number Number;
3146
3147 l_msite_id Number := null;
3148
3149 l_partyId Number;
3150
3151 l_notifEnabled Varchar2(3) := 'Y';
3152 l_notifName Varchar2(30) := 'TERMAPPROVEDNOTIF';
3153 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
3154 l_messageName WF_MESSAGES.NAME%TYPE;
3155 l_msgEnabled VARCHAR2(3) :='Y';
3156 l_permission_to_view_price BOOLEAN;
3157 l_view_net_price_flag VARCHAR2(1);
3158 l_paynow_flag VARCHAR2(1);
3159 l_reccharge_flag VARCHAR2(1);
3160
3161
3162 BEGIN
3163
3164 x_return_status := FND_API.g_ret_sts_success;
3165
3166
3167 If p_contract_status = 0 then -- Approved
3168
3169 l_event_type := 'TERMAPPROVED';
3170 l_notifName := 'TERMAPPROVEDNOTIF';
3171
3172 ElsIf p_contract_status = 1 then
3173
3174 l_event_type := 'TERMREJECTED';
3175 l_notifName := 'TERMREJECTEDNOTIF';
3176
3177 Elsif p_contract_status = 2 then
3178
3179 l_event_type := 'TERMCANCELLED';
3180 l_notifName := 'TERMCANCELLEDNOTIF';
3181
3182 End if;
3183
3184
3185 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3186 ibe_util.debug('Check if this notification is enabled.');
3187 END IF;
3188
3189 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
3190
3191 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3192 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
3193 END IF;
3194
3195 If l_notifEnabled = 'Y' Then
3196
3197 FOR c_quote_rec In c_quote_header(p_quote_id) LOOP
3198 l_customer_user :='HZ_PARTY:'||c_quote_rec.party_id;
3199 l_quote_org_id := c_quote_rec.org_id;
3200 l_quote_number := c_quote_rec.quote_number;
3201 l_partyId := c_quote_rec.party_id;
3202 END LOOP;
3203
3204 l_msite_id := null;
3205
3206 getUserType(l_partyId,l_UserType);
3207
3208 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3209 ibe_util.debug('Get Message - MsiteId: '||to_Char(l_msite_id)||' Org_id: '||to_char(l_quote_org_id)||' User Type: '||l_userType);
3210 END IF;
3211
3212 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
3213 (
3214 p_org_id => l_quote_org_id,
3215 p_msite_id => l_msite_id,
3216 p_user_type => l_userType,
3217 p_notif_name => l_notifName,
3218 x_enabled_flag => l_msgEnabled,
3219 x_wf_message_name => l_MessageName,
3220 x_return_status => x_return_status,
3221 x_msg_data => x_msg_data,
3222 x_msg_count => x_msg_data);
3223
3224
3225 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3226 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
3227 END IF;
3228
3229 /*The following function call determines whether the user has permission
3230 to view Price or not. */
3231
3232 l_permission_to_view_price := ibe_util.check_user_permission( p_permission => 'IBE_VIEW_NET_PRICE' );
3233 l_paynow_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_PAY_NOW',null,null,671), 'N');
3234 l_reccharge_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_RECURRING_CHARGES',null,null,671), 'N');
3235
3236 IF (l_permission_to_view_price) THEN
3237 l_view_net_price_flag := 'Y';
3238 ELSE
3239 l_view_net_price_flag := 'N';
3240 END IF;
3241
3242 If x_msg_count > 0 Then
3243 Raise GET_MESSAGE_ERROR;
3244 End if;
3245
3246 If l_msgEnabled = 'Y' Then
3247
3248 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3249 ibe_util.debug('NotifyForContractsStatus - eventtype - '||l_event_type);
3250 END IF;
3251
3252 If Not (l_notifName = 'TERMREJECTEDNOTIF') Then
3253
3254 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-C'||p_quote_id;
3255
3256 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3257 ibe_util.debug('Create and Start Process with Item Key: '||l_item_key);
3258 END IF;
3259
3260 wf_engine.CreateProcess(
3261 itemtype => g_ItemType,
3262 itemkey => l_item_key,
3263 process => g_processName);
3264
3265 wf_engine.SetItemUserKey(
3266 itemtype => g_ItemType,
3267 itemkey => l_item_key,
3268 userkey => l_item_key);
3269
3270 wf_engine.SetItemAttrText(
3271 itemtype => g_ItemType,
3272 itemkey => l_item_key,
3273 aname => 'MESSAGE',
3274 avalue => l_MessageName);
3275 wf_engine.SetItemAttrText(
3276 itemtype => g_ItemType,
3277 itemkey => l_item_key,
3278 aname => 'ITEMKEY',
3279 avalue => l_item_key);
3280
3281 wf_engine.SetItemAttrText(
3282 itemtype => g_ItemType,
3283 itemkey => l_item_key,
3284 aname => 'EVENTTYPE',
3285 avalue => l_event_type);
3286
3287 wf_engine.SetItemAttrText(
3288 itemtype => g_ItemType,
3289 itemkey => l_item_key,
3290 aname => 'QUOTEID',
3291 avalue => p_quote_id);
3292
3293 wf_engine.SetItemAttrText(
3294 itemtype => g_ItemType,
3295 itemkey => l_item_key,
3296 aname => 'QUOTENUM',
3297 avalue => l_quote_number);
3298
3299 wf_engine.SetItemAttrText(
3300 itemtype => g_ItemType,
3301 itemkey => l_item_key,
3302 aname => 'CONTRACTNO',
3303 avalue => p_contract_id);
3304
3305
3306 wf_engine.SetItemAttrText(
3307 itemtype => g_ItemType,
3308 itemkey => l_item_key,
3309 aname => 'SENDTO',
3310 avalue => l_customer_user);
3311
3312
3313 wf_engine.SetItemAttrText(
3314 itemtype => g_ItemType,
3315 itemkey => l_item_key,
3316 aname => 'VIEWNETPRICE',
3317 avalue => l_view_net_price_flag);
3318
3319 wf_engine.SetItemAttrText(
3320 itemtype => g_ItemType,
3321 itemkey => l_item_key,
3322 aname => 'RECCHARGEENABLED',
3323 avalue => l_reccharge_flag);
3324
3325 wf_engine.SetItemAttrText(
3326 itemtype => g_ItemType,
3327 itemkey => l_item_key,
3328 aname => 'PAYNOWENABLED',
3329 avalue => l_paynow_flag);
3330
3331 wf_engine.SetItemOwner(
3332 itemtype => g_ItemType,
3333 itemkey => l_item_key,
3334 owner => l_item_owner);
3335
3336 wf_engine.StartProcess(
3337 itemtype => g_ItemType,
3338 itemkey => l_item_key);
3339
3340
3341 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3342 ibe_util.debug('Process Started');
3343 END IF;
3344 End If;
3345
3346 l_org_contract_rep := null;
3347
3348 FOR c_rep_rec In c_contract_rep(l_quote_org_id) LOOP
3349 l_org_contract_rep := c_rep_rec.contract_rep;
3350 END LOOP;
3351
3352 If Not (l_org_contract_rep is null) Then
3353
3354 l_org_contract_rep := upper(l_org_contract_rep);
3355
3356 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3357 ibe_util.debug('Sending Mail to Contract Org Rep.: '||l_org_contract_rep);
3358 END IF;
3359
3360 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-S'||p_quote_id;
3361
3362 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3363 ibe_util.debug('Create and Start Process with Item Key: '||l_item_key);
3364 END IF;
3365
3366 wf_engine.CreateProcess(
3367 itemtype => g_ItemType,
3368 itemkey => l_item_key,
3369 process => g_processName);
3370
3371 wf_engine.SetItemUserKey(
3372 itemtype => g_ItemType,
3373 itemkey => l_item_key,
3374 userkey => l_item_key);
3375
3376 wf_engine.SetItemAttrText(
3377 itemtype => g_ItemType,
3378 itemkey => l_item_key,
3379 aname => 'MESSAGE',
3380 avalue => l_MessageName);
3381 wf_engine.SetItemAttrText(
3382 itemtype => g_ItemType,
3383 itemkey => l_item_key,
3384 aname => 'ITEMKEY',
3385 avalue => l_item_key);
3386
3387 wf_engine.SetItemAttrText(
3388 itemtype => g_ItemType,
3389 itemkey => l_item_key,
3390 aname => 'EVENTTYPE',
3391 avalue => l_event_type);
3392
3393 wf_engine.SetItemAttrText(
3394 itemtype => g_ItemType,
3395 itemkey => l_item_key,
3396 aname => 'QUOTEID',
3397 avalue => p_quote_id);
3398
3399 wf_engine.SetItemAttrText(
3400 itemtype => g_ItemType,
3401 itemkey => l_item_key,
3402 aname => 'QUOTENUM',
3403 avalue => l_quote_number);
3404
3405 wf_engine.SetItemAttrText(
3406 itemtype => g_ItemType,
3407 itemkey => l_item_key,
3408 aname => 'CONTRACTNO',
3409 avalue => p_contract_id);
3410
3411
3412 wf_engine.SetItemAttrText(
3413 itemtype => g_ItemType,
3414 itemkey => l_item_key,
3415 aname => 'SENDTO',
3416 avalue => l_org_contract_rep);
3417
3418 wf_engine.SetItemOwner(
3419 itemtype => g_ItemType,
3420 itemkey => l_item_key,
3421 owner => l_item_owner);
3422
3423 wf_engine.StartProcess(
3424 itemtype => g_ItemType,
3425 itemkey => l_item_key);
3426 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3427 ibe_util.debug('Process Started');
3428 END IF;
3429
3430 End If;
3431 End If;
3432 End If;
3433 Exception
3434 When OTHERS Then
3435 x_return_status := FND_API.g_ret_sts_error;
3436 x_msg_count := 0;
3437
3438 wf_core.context('ibe_workflow_pvt',
3439 'NotifyForContractsStatus',
3440 l_event_type,
3441 to_char(p_quote_id)
3442 );
3443 raise GET_MESSAGE_ERROR;
3444 END NotifyForContractsStatus;
3445
3446
3447
3448 /* PROCEDURE: To send out email alert for Contract Term Change Request.
3449 CALL IN FILE(s): Contract.java
3450 */
3451
3452
3453 PROCEDURE NotifyForContractsChange(
3454 p_api_version IN NUMBER,
3455 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3456 p_quote_id IN NUMBER,
3457 p_contract_id IN NUMBER,
3458 p_customer_comments IN VARCHAR2 := FND_API.G_MISS_CHAR,
3459 p_salesrep_email_id IN VARCHAR2 := FND_API.G_MISS_CHAR,
3460 x_return_status OUT NOCOPY VARCHAR2,
3461 x_msg_count OUT NOCOPY NUMBER,
3462 x_msg_data OUT NOCOPY VARCHAR2
3463 ) IS
3464
3465 Begin
3466
3467 /*For bug 2875949*/
3468 IF (p_salesrep_email_id = fnd_api.g_miss_char) then
3469 IBE_UTIL.DEBUG('salesemail id is g miss char');
3470 return;
3471 ELSE
3472 IBE_UTIL.DEBUG('salesemail id is not g miss char, ideally call from iStore');
3473 END IF;
3474 /*For bug 2875949*/
3475
3476 NotifyForContractsChange(
3477 p_api_version,
3478 p_init_msg_list,
3479 null,
3480 p_quote_id,
3481 p_contract_id,
3482 p_customer_comments,
3483 p_salesrep_email_id,
3484 x_return_status,
3485 x_msg_count,
3486 x_msg_data);
3487
3488 End NotifyForContractsChange;
3489
3490 PROCEDURE NotifyForContractsChange(
3491 p_api_version IN NUMBER,
3492 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3493 p_msite_id IN NUMBER,
3494 p_quote_id IN NUMBER,
3495 p_contract_id IN NUMBER,
3496 p_customer_comments IN VARCHAR2 := FND_API.G_MISS_CHAR,
3497 p_salesrep_email_id IN VARCHAR2 := FND_API.G_MISS_CHAR,
3498 x_return_status OUT NOCOPY VARCHAR2,
3499 x_msg_count OUT NOCOPY NUMBER,
3500 x_msg_data OUT NOCOPY VARCHAR2
3501 ) IS
3502
3503 l_cust_email_addr WF_USERS.Email_Address%TYPE;
3504 l_cust_event_type VARCHAR(20);
3505 l_cust_adhoc_user WF_USERS.NAME%TYPE;
3506 l_cust_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
3507 l_cust_item_key WF_ITEMS.ITEM_KEY%TYPE;
3508 l_sales_email_addr WF_USERS.email_address%TYPE;
3509 l_sales_event_type VARCHAR(20);
3510 l_sales_adhoc_user WF_USERS.NAME%TYPE;
3511 l_sales_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
3512 l_sales_item_key WF_ITEMS.ITEM_KEY%TYPE;
3513 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
3514 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
3515
3516 l_quote_org_id NUMBER;
3517 l_org_contract_rep WF_USERS.NAME%TYPE;
3518
3519 l_role_users Varchar2(200);
3520 l_sales_adhoc_role WF_ROLES.NAME%TYPE;
3521 l_sales_adhoc_role_display WF_ROLES.DISPLAY_NAME%TYPE;
3522
3523 l_quote_name Varchar2(50);
3524 l_quote_number Number;
3525
3526 l_partyid Number;
3527 l_notifEnabled Varchar2(3) := 'Y';
3528 l_notifName Varchar2(30) := 'CUSTQUOTENOTIFICATION';
3529 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
3530 l_MessageName WF_MESSAGES.NAME%TYPE;
3531 l_msgEnabled VARCHAR2(3) :='Y';
3532
3533 BEGIN
3534
3535 x_return_status := FND_API.g_ret_sts_success;
3536
3537
3538 FOR c_quote_rec In c_quote_header(p_quote_id) LOOP
3539 l_cust_adhoc_user :='HZ_PARTY:'||c_quote_rec.party_id;
3540 l_quote_org_id := c_quote_rec.org_id;
3541 l_quote_name := c_quote_rec.quote_name;
3542 l_quote_number := c_quote_rec.quote_number;
3543 l_partyId := c_quote_rec.party_id;
3544 END LOOP;
3545
3546 l_notifName := 'CUSTQUOTENOTIFICATION';
3547 l_cust_event_type := 'ORDCUSTQUOTE';
3548
3549 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3550 ibe_util.debug('Check if this notification is enabled.');
3551 END IF;
3552
3553 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
3554
3555 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3556 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
3557 END IF;
3558
3559 If l_notifEnabled = 'Y' Then
3560
3561 getUserType(l_partyId,l_UserType);
3562
3563 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3564 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||' Org_id: '||to_char(l_quote_org_id)||' User Type: '||l_userType);
3565 END IF;
3566
3567 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
3568 (
3569 p_org_id => l_quote_org_id,
3570 p_msite_id => p_msite_id,
3571 p_user_type => l_userType,
3572 p_notif_name => l_notifName,
3573 x_enabled_flag => l_msgEnabled,
3574 x_wf_message_name => l_MessageName,
3575 x_return_status => x_return_status,
3576 x_msg_data => x_msg_data,
3577 x_msg_count => x_msg_data);
3578
3579 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3580 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
3581 END IF;
3582
3583 If x_msg_count > 0 Then
3584 Raise GET_MESSAGE_ERROR;
3585 End if;
3586
3587 If l_msgEnabled = 'Y' Then
3588
3589 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3590 ibe_util.debug('NotifyForContractsChange - p_quote_id '||to_char(p_quote_id));
3591 END IF;
3592
3593 l_cust_item_key := l_cust_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_id;
3594
3595 /* Item Key should be Unique as it represent a process instance with ITEM TYPE*/
3596 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3597 ibe_util.debug('Create and Start Process with Item Key: '||l_cust_item_key);
3598 END IF;
3599
3600
3601 wf_engine.CreateProcess(
3602 itemtype => g_ItemType,
3603 itemkey => l_cust_item_key,
3604 process => g_processName);
3605
3606 wf_engine.SetItemUserKey(
3607 itemtype => g_ItemType,
3608 itemkey => l_cust_item_key,
3609 userkey => l_cust_item_key);
3610
3611 wf_engine.SetItemAttrText(
3612 itemtype => g_ItemType,
3613 itemkey => l_cust_item_key,
3614 aname => 'MESSAGE',
3615 avalue => l_MessageName);
3616
3617 wf_engine.SetItemAttrText(
3618 itemtype => g_ItemType,
3619 itemkey => l_cust_item_key,
3620 aname => 'ITEMKEY',
3621 avalue => l_cust_item_key);
3622
3623 wf_engine.SetItemAttrText(
3624 itemtype => g_ItemType,
3625 itemkey => l_cust_item_key,
3626 aname => 'EVENTTYPE',
3627 avalue => l_cust_event_type);
3628
3629 wf_engine.SetItemAttrText(
3630 itemtype => g_ItemType,
3631 itemkey => l_cust_item_key,
3632 aname => 'QUOTEID',
3633 avalue => p_quote_id);
3634
3635 wf_engine.SetItemAttrText(
3636 itemtype => g_ItemType,
3637 itemkey => l_cust_item_key,
3638 aname => 'QUOTENUM',
3639 avalue => l_quote_number);
3640
3641
3642 wf_engine.SetItemAttrText(
3643 itemtype => g_ItemType,
3644 itemkey => l_cust_item_key,
3645 aname => 'CONTRACTNO',
3646 avalue => p_contract_id);
3647
3648 wf_engine.SetItemAttrText(
3649 itemtype => g_ItemType,
3650 itemkey => l_cust_item_key,
3651 aname => 'QUOTENAME',
3652 avalue => l_quote_name);
3653
3654 wf_engine.SetItemAttrText(
3655 itemtype => g_ItemType,
3656 itemkey => l_cust_item_key,
3657 aname => 'COMMENTS',
3658 avalue => p_customer_comments);
3659
3660 wf_engine.SetItemAttrText(
3661 itemtype => g_ItemType,
3662 itemkey => l_cust_item_key,
3663 aname => 'SENDTO',
3664 avalue => l_cust_adhoc_user);
3665
3666 wf_engine.SetItemOwner(
3667 itemtype => g_ItemType,
3668 itemkey => l_cust_item_key,
3669 owner => l_item_owner);
3670
3671 wf_engine.StartProcess(
3672 itemtype => g_ItemType,
3673 itemkey => l_cust_item_key);
3674
3675 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3676 ibe_util.debug('Process Started');
3677 END IF;
3678 End If; --If msg enabled
3679 End If; --If notif enabled
3680
3681 --Create and set process values for the salesrep quote notification
3682
3683 l_notifName := 'SALESQUOTENOTIFICATION';
3684 l_sales_event_type := 'ORDSALESQUOTE';
3685
3686 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3687 ibe_util.debug('Check if this notification is enabled.');
3688 END IF;
3689
3690 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
3691
3692 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3693 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
3694 END IF;
3695
3696 If l_notifEnabled = 'Y' Then
3697
3698 l_UserType := 'ALL';
3699 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3700 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||' Org_id: '||to_char(l_quote_org_id)||' User Type: '||l_userType);
3701 END IF;
3702
3703 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
3704 (
3705 p_org_id => l_quote_org_id,
3706 p_msite_id => p_msite_id,
3707 p_user_type => l_userType,
3708 p_notif_name => l_notifName,
3709 x_enabled_flag => l_msgEnabled,
3710 x_wf_message_name => l_MessageName,
3711 x_return_status => x_return_status,
3712 x_msg_data => x_msg_data,
3713 x_msg_count => x_msg_data);
3714
3715
3716 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3717 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
3718 END IF;
3719
3720 If x_msg_count > 0 Then
3721 Raise GET_MESSAGE_ERROR;
3722 End if;
3723
3724 If l_msgEnabled = 'Y' Then
3725 l_sales_adhoc_role := null;
3726 l_role_users := null;
3727
3728 FOR c_rep_rec In c_contract_rep(l_quote_org_id) LOOP
3729 l_org_contract_rep := c_rep_rec.contract_rep;
3730 END LOOP;
3731
3732 IF(IBE_UTIL.g_debugon = l_true) THEN
3733 IBE_UTIL.DEBUG('Contracts rep from database l_org_contract_rep: '||l_org_contract_rep);
3734 END IF;
3735
3736 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
3737
3738 IF ( p_salesrep_email_id is NOT NULL) THEN
3739 IF(IBE_UTIL.g_debugon = l_true) THEN
3740 IBE_UTIL.DEBUG(' p_salesrep_email_id is NOT NULL: '||p_salesrep_email_id );
3741 END IF;
3742 l_sales_adhoc_user := 'IBEU'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id ;
3743 l_sales_adhoc_user_display := 'IBEU'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
3744 l_sales_email_addr := p_salesrep_email_id;
3745
3746 wf_directory.CreateAdHocUser(
3747 name => l_sales_adhoc_user,
3748 display_name => l_sales_adhoc_user_display,
3749 notification_preference => l_notification_preference,
3750 email_address => l_sales_email_addr,
3751 expiration_date => sysdate + 1,
3752 language => 'AMERICAN');
3753
3754 If Not (l_org_contract_rep is null) Then
3755 l_role_users := upper(l_org_contract_rep)||','||l_sales_adhoc_user;
3756 Else
3757 l_role_users := l_sales_adhoc_user;
3758 End If;
3759
3760 l_sales_adhoc_role := 'IBEC'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
3761 l_sales_adhoc_role_display := 'IBEC'||to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
3762
3763 wf_directory.CreateAdHocRole
3764 (role_name => l_sales_adhoc_role,
3765 role_display_name => l_sales_adhoc_role_display,
3766 language => 'AMERICAN',
3767 notification_preference => l_notification_preference,
3768 role_users => l_role_users,
3769 expiration_date => sysdate + 1);
3770 ELSE
3771 l_sales_adhoc_role := l_org_contract_rep;
3772
3773 END IF;
3774
3775 If Not( l_sales_adhoc_role is null) Then
3776
3777 l_sales_adhoc_role := upper(l_sales_adhoc_role);
3778 l_sales_item_key := l_sales_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_id;
3779
3780 /* Item Key should be Unique as it represent a process instance with ITEM TYPE*/
3781
3782 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3783 ibe_util.debug('Create and Start Process with Item Key: '||l_sales_item_key);
3784 END IF;
3785
3786 wf_engine.CreateProcess(
3787 itemtype => g_ItemType,
3788 itemkey => l_sales_item_key,
3789 process => g_processName);
3790
3791 wf_engine.SetItemUserKey(
3792 itemtype => g_ItemType,
3793 itemkey => l_sales_item_key,
3794 userkey => l_sales_item_key);
3795
3796 wf_engine.SetItemAttrText(
3797 itemtype => g_ItemType,
3798 itemkey => l_sales_item_key,
3799 aname => 'MESSAGE',
3800 avalue => l_MessageName);
3801
3802 wf_engine.SetItemAttrText(
3803 itemtype => g_ItemType,
3804 itemkey => l_sales_item_key,
3805 aname => 'ITEMKEY',
3806 avalue => l_sales_item_key);
3807
3808 wf_engine.SetItemAttrText(
3809 itemtype => g_ItemType,
3810 itemkey => l_sales_item_key,
3811 aname => 'EVENTTYPE',
3812 avalue => l_sales_event_type);
3813
3814 wf_engine.SetItemAttrText(
3815 itemtype => g_ItemType,
3816 itemkey => l_sales_item_key,
3817 aname => 'QUOTEID',
3818 avalue => p_quote_id);
3819
3820 wf_engine.SetItemAttrText(
3821 itemtype => g_ItemType,
3822 itemkey => l_sales_item_key,
3823 aname => 'QUOTENUM',
3824 avalue => l_quote_number);
3825
3826 wf_engine.SetItemAttrText(
3827 itemtype => g_ItemType,
3828 itemkey => l_sales_item_key,
3829 aname => 'CONTRACTNO',
3830 avalue => p_contract_id);
3831
3832 wf_engine.SetItemAttrText(
3833 itemtype => g_ItemType,
3834 itemkey => l_sales_item_key,
3835 aname => 'COMMENTS',
3836 avalue => p_customer_comments);
3837
3838 wf_engine.SetItemAttrText(
3839 itemtype => g_ItemType,
3840 itemkey => l_sales_item_key,
3841 aname => 'SENDTO',
3842 avalue => l_sales_adhoc_role);
3843
3844 wf_engine.SetItemOwner(
3845 itemtype => g_ItemType,
3846 itemkey => l_sales_item_key,
3847 owner => l_item_owner);
3848
3849 wf_engine.StartProcess(
3850 itemtype => g_ItemType,
3851 itemkey => l_sales_item_key);
3852
3853 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3854 ibe_util.debug('Process Started');
3855 END IF;
3856 End If; -- if l_sales_adhoc_role
3857 End If; -- if salesquote message is enabled
3858 End If; -- if salesqute is enabled
3859 Exception
3860 When OTHERS Then
3861 x_return_status := FND_API.g_ret_sts_error;
3862 x_msg_count := 0;
3863 IF(IBE_UTIL.g_debugon = l_true) THEN
3864 IBE_UTIL.DEBUG('NotifyForContractsChange:Exception: '||SQLCODE||SQLERRM);
3865 END IF;
3866 wf_core.context('ibe_workflow_pvt','NotifyQuote',l_sales_event_type,to_char(p_quote_id));
3867 raise;
3868 END NotifyForContractsChange;
3869
3870
3871
3872
3873 /* PROCEDURE: To send out email alert for Sales Assistance Request.
3874 CALL IN FILE(s): Quote.java
3875 */
3876
3877
3878
3879 PROCEDURE NotifyForSalesAssistance (
3880 p_api_version IN NUMBER,
3881 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3882 p_quote_id IN NUMBER,
3883 p_customer_comments IN VARCHAR2 := FND_API.G_MISS_CHAR,
3884 p_salesrep_email_id IN VARCHAR2 := FND_API.G_MISS_CHAR,
3885 p_reason_code IN VARCHAR2 := FND_API.G_MISS_CHAR,
3886 p_salesrep_user_id IN NUMBER := NULL,
3887 x_return_status OUT NOCOPY VARCHAR2,
3888 x_msg_count OUT NOCOPY NUMBER,
3889 x_msg_data OUT NOCOPY VARCHAR2
3890 ) IS
3891 Begin
3892
3893
3894 NotifyForSalesAssistance (
3895 p_api_version,
3896 p_init_msg_list,
3897 null,
3898 p_quote_id,
3899 p_customer_comments,
3900 p_salesrep_email_id,
3901 p_reason_code,
3902 p_salesrep_user_id,
3903 x_return_status,
3904 x_msg_count,
3905 x_msg_data);
3906
3907
3908 End NotifyForSalesAssistance;
3909
3910 PROCEDURE NotifyForSalesAssistance (
3911 p_api_version IN NUMBER,
3912 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3913 p_msite_id IN NUMBER,
3914 p_quote_id IN NUMBER,
3915 p_customer_comments IN VARCHAR2 := FND_API.G_MISS_CHAR,
3916 p_salesrep_email_id IN VARCHAR2 := FND_API.G_MISS_CHAR,
3917 p_reason_code IN VARCHAR2 := FND_API.G_MISS_CHAR,
3918 p_salesrep_user_id IN NUMBER := NULL,
3919 x_return_status OUT NOCOPY VARCHAR2,
3920 x_msg_count OUT NOCOPY NUMBER,
3921 x_msg_data OUT NOCOPY VARCHAR2
3922 ) IS
3923
3924 l_cust_email_addr hz_contact_points.email_address%TYPE;
3925 l_cust_event_type VARCHAR(20);
3926 l_cust_adhoc_user WF_USERS.NAME%TYPE;
3927 l_cust_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
3928 l_cust_item_key WF_ITEMS.ITEM_KEY%TYPE;
3929 l_sales_email_addr WF_USERS.email_address%TYPE;
3930 l_sales_event_type VARCHAR(20);
3931
3932 l_role_users Varchar2(200);
3933 l_sales_adhoc_role WF_ROLES.NAME%TYPE;
3934 l_sales_adhoc_role_display WF_ROLES.DISPLAY_NAME%TYPE;
3935
3936 l_sales_adhoc_user WF_USERS.NAME%TYPE;
3937 l_sales_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
3938
3939 l_sales_item_key WF_ITEMS.ITEM_KEY%TYPE;
3940 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
3941
3942 l_Notification WF_USERS.Notification_Preference%TYPE;
3943 l_Lang WF_USERS.Language%TYPE;
3944 l_Territory WF_USERS.Territory%TYPE;
3945 l_email_addr WF_USERS.email_address%TYPE;
3946 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
3947
3948 l_order_id NUMBER;
3949 l_sales_rep WF_USERS.NAME%TYPE;
3950
3951 l_partyId Number;
3952 l_orgid Number := null;
3953 l_notifEnabled Varchar2(3) := 'Y';
3954 l_notifName Varchar2(30) := 'CUSTASSISTNOTIFICATON';
3955 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
3956 l_MessageName WF_MESSAGES.NAME%TYPE;
3957 l_msgEnabled VARCHAR2(3) :='Y';
3958
3959 --Bug 2223507
3960 l_quote_num VARCHAR2(1000) := null;
3961 l_first_name VARCHAR2(1000);
3962 l_last_name VARCHAR2(1000);
3963 l_contact_phone hz_contact_points.phone_number%TYPE;
3964 l_cart_name ibe_quote_headers_v.quote_name%TYPE;
3965 l_cart_date ibe_quote_headers_v.last_update_date%TYPE;
3966 l_ship_to_name aso_shipments_v.ship_to_cust_name%TYPE;
3967 l_address VARCHAR2(4000);
3968 l_address1 VARCHAR2(240);
3969 l_address2 VARCHAR2(240);
3970 l_address3 VARCHAR2(240);
3971 l_address4 VARCHAR2(240);
3972 l_country VARCHAR2(60);
3973 l_city VARCHAR2(60);
3974 l_postal_code VARCHAR2(60);
3975 l_ship_to_state VARCHAR2(60);
3976 l_ship_to_province VARCHAR2(60);
3977 l_ship_to_county VARCHAR2(60);
3978 l_minisite_name ibe_msites_vl.msite_name%TYPE;
3979 l_shipping_method wsh_carrier_ship_methods_v.ship_method_code_meaning%TYPE;
3980 l_contact_name ibe_quote_headers_v.party_name%TYPE;
3981
3982 l_ship_and_hand ibe_quote_headers_v.TOTAL_SHIPPING_CHARGE%TYPE;
3983 l_tax ibe_quote_headers_v.TOTAL_TAX%TYPE;
3984 l_total ibe_quote_headers_v.TOTAL_QUOTE_PRICE%TYPE;
3985
3986 l_return_status VARCHAR2(20);
3987 l_msg_count NUMBER;
3988 l_msg_data VARCHAR2(4000);
3989
3990 l_employee_id NUMBER;
3991 l_user_name VARCHAR2(2000);
3992 l_permission_to_view_price BOOLEAN;
3993 l_view_net_price_flag VARCHAR2(1);
3994 l_paynow_flag VARCHAR2(1);
3995 l_reccharge_flag VARCHAR2(1);
3996
3997 cursor c_userenv_partyid is
3998 select customer_id
3999 from FND_USER
4000 where user_id = FND_GLOBAL.USER_ID;
4001 rec_userenv_partyid c_userenv_partyid%rowtype;
4002
4003 BEGIN
4004 x_return_status := FND_API.g_ret_sts_success;
4005
4006 -- Check for WorkFlow Enable Profile
4007
4008
4009 FOR c_quote_rec In c_quote_header(p_quote_id)
4010 LOOP
4011 l_orgid := c_quote_rec.org_id;
4012 l_order_id := c_quote_rec.order_id;
4013 l_quote_num := c_quote_rec.quote_number;
4014 END LOOP;
4015 FOR rec_userenv_partyid in c_userenv_partyid LOOP
4016
4017 l_cust_adhoc_user :='HZ_PARTY:'||rec_userenv_partyid.customer_id;
4018 l_partyId := rec_userenv_partyid.customer_id;
4019 EXIT when c_userenv_partyid%notfound;
4020 END LOOP;
4021
4022 --Bug 2223507 start
4023 --Call the procedure to retrieve the token values for header/footer
4024 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4025 ibe_util.debug('NotifyForSalesAssistance - '||
4026 'calling Get_sales_assist_hdr_tokens');
4027 END IF;
4028 IBE_CART_NOTIFY_UTIL.Get_sales_assist_hdr_tokens (
4029 p_api_version => 1.0,
4030 p_init_msg_list => FND_API.G_TRUE,
4031 p_commit => FND_API.G_FALSE,
4032 x_return_status => l_return_status,
4033 x_msg_count => l_msg_count,
4034 x_msg_data => l_msg_data,
4035 p_quote_header_id => p_quote_id,
4036 p_minisite_id => p_msite_id,
4037 x_Contact_Name => l_contact_name,
4038 x_Contact_phone => l_contact_phone,
4039 x_email => l_email_addr,
4040 x_first_name => l_first_name,
4041 x_last_name => l_last_name,
4042 x_Cart_name => l_cart_name,
4043 x_cart_date => l_cart_date,
4044 x_Ship_to_name => l_ship_to_name,
4045 x_ship_to_address1 => l_address1,
4046 x_ship_to_address2 => l_address2,
4047 x_ship_to_address3 => l_address3,
4048 x_ship_to_address4 => l_address4,
4049 x_country => l_country,
4050 x_CITY => l_city,
4051 x_POSTAL_CODE => l_postal_code,
4052 x_SHIP_TO_STATE => l_ship_to_state,
4053 x_SHIP_TO_PROVINCE => l_ship_to_province,
4054 x_SHIP_TO_COUNTY => l_ship_to_county,
4055 x_shipping_method => l_shipping_method,
4056 x_minisite_name => l_minisite_name,
4057 x_ship_and_hand => l_ship_and_hand,
4058 x_tax => l_tax,
4059 x_total => l_total
4060 );
4061
4062 IF (l_return_status <> 'S') THEN
4063 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4064 ibe_util.debug('NotifyForSalesAssistance - Get_sales_assist_hdr_tokens,'||
4065 'error occured;' ||l_msg_data);
4066 END IF;
4067 END IF;
4068
4069 l_address := l_address1||NEWLINE;
4070 IF (l_address2 IS NOT NULL) THEN
4071 l_address := l_address ||TAB||TAB||' '||l_address2||NEWLINE;
4072 END IF;
4073 IF (l_address3 IS NOT NULL) THEN
4074 l_address := l_address || TAB||TAB||' '||l_address3||NEWLINE;
4075 END IF;
4076 IF (l_address4 IS NOT NULL) THEN
4077 l_address := l_address || TAB||TAB||' '||l_address4||NEWLINE;
4078 END IF;
4079 l_address := l_address|| TAB||TAB||' '||l_city||',';
4080 l_address := l_address|| l_ship_to_state||' ';
4081 l_address := l_address|| l_postal_code||NEWLINE;
4082 l_address := l_address|| TAB||TAB||' '||l_country;
4083
4084 --Bug 2223507 end
4085
4086 /* Permission based pricing function call
4087 This function returns TRUE if the user has permission to view net price
4088 Otherwise this function will return FALSE */
4089 l_permission_to_view_price := ibe_util.check_user_permission( p_permission => 'IBE_VIEW_NET_PRICE' );
4090 l_paynow_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_PAY_NOW',null,null,671), 'N');
4091 l_reccharge_flag := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_ENABLE_RECURRING_CHARGES',null,null,671), 'N');
4092
4093
4094 IF (l_permission_to_view_price) THEN
4095 l_view_net_price_flag := 'Y';
4096 ELSE
4097 l_view_net_price_flag := 'N';
4098 END IF;
4099
4100
4101 l_cust_event_type := 'CUSTASSIST';
4102 l_notifName := 'CUSTASSISTNOTIFICATON';
4103
4104 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4105 ibe_util.debug('Check if this notification is enabled.');
4106 END IF;
4107
4108 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
4109
4110 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4111 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||
4112 l_notifEnabled);
4113 END IF;
4114 IF l_notifEnabled = 'Y' THEN
4115 getUserType(l_partyId,l_UserType);
4116 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4117 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||
4118 ' Org_id: '||to_char(l_orgid)||' User Type: '||l_userType);
4119 END IF;
4120
4121 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
4122 (
4123 p_org_id => l_orgId,
4124 p_msite_id => p_msite_id,
4125 p_user_type => l_userType,
4126 p_notif_name => l_notifName,
4127 x_enabled_flag => l_msgEnabled,
4128 x_wf_message_name => l_MessageName,
4129 x_return_status => x_return_status,
4130 x_msg_data => x_msg_data,
4131 x_msg_count => x_msg_data);
4132
4133 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4134 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||
4135 l_msgEnabled);
4136 END IF;
4137
4138 IF x_msg_count > 0 THEN
4139 Raise GET_MESSAGE_ERROR;
4140 END IF;
4141
4142 IF l_msgEnabled = 'Y' THEN
4143 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4144 ibe_util.debug('NotifyForSalesAssistance - p_quote_id '||to_char(p_quote_id));
4145 END IF;
4146 l_cust_item_key := l_cust_event_type||'-'||
4147 to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_id;
4148
4149 /* Item Key should be Unique as it represent a process instance with
4150 ITEM TYPE*/
4151
4152
4153 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4154 ibe_util.debug('Create and Start Process with Item Key: '||
4155 l_cust_item_key);
4156 END IF;
4157
4158 wf_engine.CreateProcess(
4159 itemtype => g_ItemType,
4160 itemkey => l_cust_item_key,
4161 process => g_processName);
4162
4163 wf_engine.SetItemUserKey(
4164 itemtype => g_ItemType,
4165 itemkey => l_cust_item_key,
4166 userkey => l_cust_item_key);
4167
4168 wf_engine.SetItemAttrText(
4169 itemtype => g_ItemType,
4170 itemkey => l_cust_item_key,
4171 aname => 'MESSAGE',
4172 avalue => l_MessageName);
4173
4174 wf_engine.SetItemAttrText(
4175 itemtype => g_ItemType,
4176 itemkey => l_cust_item_key,
4177 aname => 'ITEMKEY',
4178 avalue => l_cust_item_key);
4179
4180 wf_engine.SetItemAttrText(
4181 itemtype => g_ItemType,
4182 itemkey => l_cust_item_key,
4183 aname => 'EVENTTYPE',
4184 avalue => l_cust_event_type);
4185
4186 wf_engine.SetItemAttrText(
4187 itemtype => g_ItemType,
4188 itemkey => l_cust_item_key,
4189 aname => 'QUOTEID',
4190 avalue => p_quote_id);
4191
4192 wf_engine.SetItemAttrText(
4193 itemtype => g_ItemType,
4194 itemkey => l_cust_item_key,
4195 aname => 'ORDERID',
4196 avalue => l_order_id);
4197
4198 wf_engine.SetItemAttrText(
4199 itemtype => g_ItemType,
4200 itemkey => l_cust_item_key,
4201 aname => 'COMMENTS',
4202 avalue => p_customer_comments);
4203
4204 wf_engine.SetItemAttrText(
4205 itemtype => g_ItemType,
4206 itemkey => l_cust_item_key,
4207 aname => 'SENDTO',
4208 avalue => l_cust_adhoc_user);
4209
4210 --Bug 2223507 start
4211 wf_engine.SetItemAttrText(
4212 itemtype => g_ItemType,
4213 itemkey => l_cust_item_key,
4214 aname => 'REASON',
4215 avalue => p_reason_code);
4216
4217 wf_engine.SetItemAttrText(
4218 itemtype => g_ItemType,
4219 itemkey => l_cust_item_key,
4220 aname => 'FIRSTNAME',
4221 avalue => l_first_name);
4222
4223 wf_engine.SetItemAttrText(
4224 itemtype => g_ItemType,
4225 itemkey => l_cust_item_key,
4226 aname => 'CONTACTNAME',
4227 avalue => l_contact_name);
4228
4229 wf_engine.SetItemAttrText(
4230 itemtype => g_ItemType,
4231 itemkey => l_cust_item_key,
4232 aname => 'EMAILADDRESS',
4233 avalue => l_email_addr);
4234
4235 wf_engine.SetItemAttrText(
4236 itemtype => g_ItemType,
4237 itemkey => l_cust_item_key,
4238 aname => 'CONTACTPHONE',
4239 avalue => l_contact_phone);
4240
4241 wf_engine.SetItemAttrText(
4242 itemtype => g_ItemType,
4243 itemkey => l_cust_item_key,
4244 aname => 'VIEWNETPRICE',
4245 avalue => l_view_net_price_flag);
4246
4247 wf_engine.SetItemAttrText(
4248 itemtype => g_ItemType,
4249 itemkey => l_cust_item_key,
4250 aname => 'RECCHARGEENABLED',
4251 avalue => l_reccharge_flag);
4252
4253 wf_engine.SetItemAttrText(
4254 itemtype => g_ItemType,
4255 itemkey => l_cust_item_key,
4256 aname => 'PAYNOWENABLED',
4257 avalue => l_paynow_flag);
4258
4259 wf_engine.SetItemAttrText(
4260 itemtype => g_ItemType,
4261 itemkey => l_cust_item_key,
4262 aname => 'MSITEID',
4263 avalue => p_msite_id);
4264
4265 wf_engine.SetItemAttrText(
4266 itemtype => g_ItemType,
4267 itemkey => l_cust_item_key,
4268 aname => 'CARTNAME',
4269 avalue => l_cart_name);
4270
4271 wf_engine.SetItemAttrText(
4272 itemtype => g_ItemType,
4273 itemkey => l_cust_item_key,
4274 aname => 'DATE_ITEMKEY',
4275 avalue => l_cust_item_key);
4276
4277 wf_engine.SetItemAttrText(
4278 itemtype => g_ItemType,
4279 itemkey => l_cust_item_key,
4280 aname => 'SHIPMETHOD',
4281 avalue => l_shipping_method);
4282
4283 wf_engine.SetItemAttrText(
4284 itemtype => g_ItemType,
4285 itemkey => l_cust_item_key,
4286 aname => 'SHIPTONAME',
4287 avalue => l_ship_to_name);
4288
4289 wf_engine.SetItemAttrText(
4290 itemtype => g_ItemType,
4291 itemkey => l_cust_item_key,
4292 aname => 'SHIPTOADDRESS',
4293 avalue => l_address);
4294
4295 --end bug 2223507
4296
4297 wf_engine.SetItemOwner(
4298 itemtype => g_ItemType,
4299 itemkey => l_cust_item_key,
4300 owner => l_item_owner);
4301
4302 wf_engine.StartProcess(
4303 itemtype => g_ItemType,
4304 itemkey => l_cust_item_key);
4305
4306 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4307 ibe_util.debug('Process Started');
4308 END IF;
4309 END IF; --l_msgEnabled = 'Y'
4310 END IF; --l_notifEnabled = 'Y'
4311
4312 --Create and set process values for the salesrep assist. notification
4313
4314 l_sales_event_type := 'SALESASSIST';
4315 l_notifName := 'SALESASSISTNOTIFICATION';
4316
4317 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4318 ibe_util.debug('Check if this notification is enabled.');
4319 END IF;
4320
4321 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
4322
4323 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4324 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||
4325 l_notifEnabled);
4326 END IF;
4327
4328 IF l_notifEnabled = 'Y' THEN
4329
4330 l_UserType := 'ALL';
4331 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4332 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||
4333 ' Org_id: '||to_char(l_orgid)||' User Type: '||l_userType);
4334 END IF;
4335 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
4336 (
4337 p_org_id => l_orgId,
4338 p_msite_id => p_msite_id,
4339 p_user_type => l_userType,
4340 p_notif_name => l_notifName,
4341 x_enabled_flag => l_msgEnabled,
4342 x_wf_message_name => l_MessageName,
4343 x_return_status => x_return_status,
4344 x_msg_data => x_msg_data,
4345 x_msg_count => x_msg_data);
4346
4347 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4348 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||
4349 l_msgEnabled);
4350 END IF;
4351 IF x_msg_count > 0 THEN
4352 Raise GET_MESSAGE_ERROR;
4353 END IF;
4354
4355 IF l_msgEnabled = 'Y' THEN
4356 l_sales_adhoc_role := null;
4357 l_role_users := null;
4358
4359 FOR c_rep_rec In c_contract_rep(l_orgid)
4360 LOOP
4361 l_sales_rep := c_rep_rec.sales_rep;
4362 END LOOP;
4363
4364 l_notification_preference :=
4365 NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
4366
4367 --Bug 2223507 start
4368 IF ( (p_salesrep_email_id is NOT NULL AND p_salesrep_email_id <> FND_API.G_MISS_CHAR) OR
4369 (p_salesrep_user_id is NOT NULL AND p_salesrep_user_id <> FND_API.G_MISS_NUM) ) THEN
4370 --Bug 2223507 end
4371
4372 IF (( p_salesrep_email_id is NOT NULL)
4373 AND (p_salesrep_email_id <> FND_API.G_MISS_CHAR)) THEN
4374
4375 l_sales_adhoc_user := 'IBEA'||to_char(sysdate,'MMDDYYHH24MISS')||
4376 'Q'||p_quote_id ;
4377 l_sales_adhoc_user_display := 'IBEA'||
4378 to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
4379 l_sales_email_addr := p_salesrep_email_id;
4380
4381 wf_directory.CreateAdHocUser(
4382 name => l_sales_adhoc_user,
4383 display_name => l_sales_adhoc_user_display,
4384 notification_preference => l_notification_preference,
4385 email_address => l_sales_email_addr,
4386 expiration_date => sysdate + 1,
4387 language => 'AMERICAN');
4388 l_role_users := l_sales_adhoc_user;
4389 --Bug2223507 END IF;
4390
4391 --Bug 2223507 start
4392 END IF; -- p_salesrep_email_id is NOT NULL
4393
4394 IF (p_salesrep_user_id is NOT NULL) THEN
4395 BEGIN
4396 SELECT Employee_ID,user_name
4397 INTO l_employee_id,l_user_name
4398 FROM FND_USER
4399 WHERE USER_ID = p_salesrep_user_id;
4400 EXCEPTION
4401 WHEN OTHERS THEN
4402 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4403 ibe_util.debug('NotifyforSalesAssistance: error while'||
4404 'getting the employee id');
4405 END IF;
4406 END;
4407 /*Create a role with the salesrep e-mail address (if any passed in)
4408 and the sales rep in the profile) */
4409 IF (l_user_name IS NOT NULL ) THEN
4410 IF (l_role_users is not null) THEN
4411 l_role_users := l_role_users||','||l_user_name;
4412 ELSE
4413 l_role_users := l_user_name;
4414 END IF;
4415 END IF; --l_user_name IS NOT NULL
4416
4417 END IF; --p_salesrep_user_id is NOT NULL
4418
4419
4420 /*Attach the admin salesrep here*/
4421 IF ((l_Sales_Rep is not null) and (l_Sales_Rep <> l_user_name)) Then
4422 l_role_users := l_role_users||','||upper(l_Sales_Rep);
4423 END IF;
4424
4425 --Bug 2223507 end
4426 /*Finally create the WF ad hoc role*/
4427 l_sales_adhoc_role := 'IBEB'||
4428 to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
4429 l_sales_adhoc_role_display := 'IBEB'||
4430 to_char(sysdate,'MMDDYYHH24MISS')||'Q'||p_quote_id;
4431
4432 wf_directory.CreateAdHocRole
4433 (role_name => l_sales_adhoc_role,
4434 role_display_name => l_sales_adhoc_role_display,
4435 language => 'AMERICAN',
4436 notification_preference => l_notification_preference,
4437 role_users => l_role_users,
4438 expiration_date => sysdate + 1);
4439
4440 ELSE -- p_salesrep_email_id is NULL AND p_salesrep_user_id is null
4441
4442 l_sales_adhoc_role := l_sales_rep;
4443
4444 END IF;
4445
4446 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4447 ibe_util.debug('NotifySalesAssistance: l_sales_adhoc_role '||
4448 l_sales_adhoc_role);
4449 END IF;
4450
4451
4452 IF l_sales_adhoc_role is not null THEN
4453 l_sales_adhoc_role := upper(l_sales_adhoc_role);
4454 l_sales_item_key := l_sales_event_type||'-'||
4455 to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_id;
4456 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4457 ibe_util.debug('Create and Start Process with Item Key: '||
4458 l_sales_item_key);
4459 END IF;
4460
4461 wf_engine.CreateProcess(
4462 itemtype => g_ItemType,
4463 itemkey => l_sales_item_key,
4464 process => g_processName);
4465
4466 wf_engine.SetItemUserKey(
4467 itemtype => g_ItemType,
4468 itemkey => l_sales_item_key,
4469 userkey => l_sales_item_key);
4470
4471 wf_engine.SetItemAttrText(
4472 itemtype => g_ItemType,
4473 itemkey => l_sales_item_key,
4474 aname => 'MESSAGE',
4475 avalue => l_MessageName);
4476
4477 wf_engine.SetItemAttrText(
4478 itemtype => g_ItemType,
4479 itemkey => l_sales_item_key,
4480 aname => 'ITEMKEY',
4481 avalue => l_sales_item_key);
4482
4483 wf_engine.SetItemAttrText(
4484 itemtype => g_ItemType,
4485 itemkey => l_sales_item_key,
4486 aname => 'EVENTTYPE',
4487 avalue => l_sales_event_type);
4488
4489 wf_engine.SetItemAttrText(
4490 itemtype => g_ItemType,
4491 itemkey => l_sales_item_key,
4492 aname => 'QUOTEID',
4493 avalue => p_quote_id);
4494
4495 wf_engine.SetItemAttrText(
4496 itemtype => g_ItemType,
4497 itemkey => l_sales_item_key,
4498 aname => 'ORDERID',
4499 avalue => l_order_id);
4500
4501 wf_engine.SetItemAttrText(
4502 itemtype => g_ItemType,
4503 itemkey => l_sales_item_key,
4504 aname => 'COMMENTS',
4505 avalue => p_customer_comments);
4506
4507 --Bug 2223507 start
4508 wf_engine.SetItemAttrText(
4509 itemtype => g_ItemType,
4510 itemkey => l_sales_item_key,
4511 aname => 'QUOTENUM',
4512 avalue => l_quote_num);
4513
4514 wf_engine.SetItemAttrText(
4515 itemtype => g_ItemType,
4516 itemkey => l_sales_item_key,
4517 aname => 'FIRSTNAME',
4518 avalue => l_first_name);
4519
4520 wf_engine.SetItemAttrText(
4521 itemtype => g_ItemType,
4522 itemkey => l_sales_item_key,
4523 aname => 'CONTACTNAME',
4524 avalue => l_contact_name);
4525
4526 -- For bug# 3268959
4527
4528 wf_engine.SetItemAttrText(
4529 itemtype => g_ItemType,
4530 itemkey => l_sales_item_key,
4531 aname => 'VIEWNETPRICE',
4532 avalue => l_view_net_price_flag);
4533
4534 wf_engine.SetItemAttrText(
4535 itemtype => g_ItemType,
4536 itemkey => l_sales_item_key,
4537 aname => 'RECCHARGEENABLED',
4538 avalue => l_reccharge_flag);
4539
4540 wf_engine.SetItemAttrText(
4541 itemtype => g_ItemType,
4542 itemkey => l_sales_item_key,
4543 aname => 'PAYNOWENABLED',
4544 avalue => l_paynow_flag);
4545
4546 wf_engine.SetItemAttrText(
4547 itemtype => g_ItemType,
4548 itemkey => l_sales_item_key,
4549 aname => 'MSITEID',
4550 avalue => p_msite_id);
4551
4552 wf_engine.SetItemAttrText(
4553 itemtype => g_ItemType,
4554 itemkey => l_sales_item_key,
4555 aname => 'REASON',
4556 avalue => p_reason_code);
4557
4558 wf_engine.SetItemAttrText(
4559 itemtype => g_ItemType,
4560 itemkey => l_sales_item_key,
4561 aname => 'CONTACTPHONE',
4562 avalue => l_contact_phone);
4563
4564 wf_engine.SetItemAttrText(
4565 itemtype => g_ItemType,
4566 itemkey => l_sales_item_key,
4567 aname => 'EMAILADDRESS',
4568 avalue => l_email_addr);
4569
4570 wf_engine.SetItemAttrText(
4571 itemtype => g_ItemType,
4572 itemkey => l_sales_item_key,
4573 aname => 'CARTNAME',
4574 avalue => l_cart_name);
4575
4576 wf_engine.SetItemAttrText(
4577 itemtype => g_ItemType,
4578 itemkey => l_sales_item_key,
4579 aname => 'DATE_ITEMKEY',
4580 avalue => l_sales_item_key);
4581
4582 wf_engine.SetItemAttrText(
4583 itemtype => g_ItemType,
4584 itemkey => l_sales_item_key,
4585 aname => 'SHIPMETHOD',
4586 avalue => l_shipping_method);
4587
4588 wf_engine.SetItemAttrText(
4589 itemtype => g_ItemType,
4590 itemkey => l_sales_item_key,
4591 aname => 'SHIPTONAME',
4592 avalue => l_ship_to_name);
4593
4594 wf_engine.SetItemAttrText(
4595 itemtype => g_ItemType,
4596 itemkey => l_sales_item_key,
4597 aname => 'SHIPTOADDRESS',
4598 avalue => l_address);
4599
4600 --Bug 2223507 end
4601
4602 wf_engine.SetItemAttrText(
4603 itemtype => g_ItemType,
4604 itemkey => l_sales_item_key,
4605 aname => 'SENDTO',
4606 avalue => l_sales_adhoc_role);
4607
4608 wf_engine.SetItemOwner(
4609 itemtype => g_ItemType,
4610 itemkey => l_sales_item_key,
4611 owner => l_item_owner);
4612 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4613 ibe_util.debug('Finally here');
4614 END IF;
4615
4616
4617 wf_engine.StartProcess(
4618 itemtype => g_ItemType,
4619 itemkey => l_sales_item_key);
4620 ELSE
4621 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4622 IBE_UTIL.DEBUG('NotifySalesAssist:Not sending sales assistance e-mail because l_sales_adhoc_role is null');
4623 END IF;
4624
4625 END IF; --l_sales_adhoc_role is not null
4626
4627 END IF; --l_msgEnabled = 'Y
4628 END IF; --l_notifEnabled = 'Y'
4629
4630 EXCEPTION
4631
4632 WHEN OTHERS THEN
4633 x_return_status := FND_API.g_ret_sts_error;
4634 x_msg_count := 0;
4635 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4636 IBE_UTIL.DEBUG('NotifySalesAssist:Exception block: '||SQLCODE||': '||SQLERRM);
4637 END IF;
4638
4639 wf_core.context('ibe_workflow_pvt',
4640 'NotifySalesAssistance',
4641 l_sales_event_type,
4642 to_char(p_quote_id)
4643 );
4644 raise;
4645
4646 END NotifyForSalesAssistance;
4647 ------------------------------------
4648
4649 /********************************************************
4650 Get_Speciality_Store_name: Here the input parameter is: msite id.
4651
4652 This procedure is responsible to retrive the
4653 speciality store name related to the input parameter msite id.
4654 ********************************************************/
4655 /*This procedure is commented, as minisite name will be obtained from a callback
4656 /*PROCEDURE Get_Speciality_Store_name(p_msite IN IBE_MSITES_VL.MSITE_ID%TYPE,
4657 x_Speciality_Store_Name OUT NOCOPY IBE_MSITES_VL.MSITE_NAME%TYPE) is
4658 CURSOR c_msite_name(p_msite number) IS
4659 SELECT msite_name
4660 FROM ibe_msites_vl
4661 WHERE msite_id = p_msite;
4662 rec_msite_name c_msite_name%rowtype;
4663 BEGIN
4664
4665 FOR rec_msite_name IN c_msite_name(p_Msite)
4666 LOOP
4667 x_Speciality_Store_Name := rec_msite_name.msite_name;
4668 END LOOP;
4669
4670 END Get_Speciality_Store_name;*/
4671
4672 /********************************************************
4673 This API is tyo determine if the contact point is saved against IBE_SH_QUOTE_ACCESS or HZ_PARTIES
4674 If the contact point is saved against IBE_SH_QUOTE_ACCESS then notifications will only be
4675 sent to ad-hoc users, otherwise they will be sent to users who will be identified by their party_id
4676 in the HZ_PARTIES table
4677 *********************************************************/
4678 procedure locate_contact_point
4679 ( p_contact_point_id IN NUMBER ,
4680 x_create_adhoc_flag OUT NOCOPY VARCHAR2 ) is
4681 cursor c_contact_point is
4682 select owner_table_name
4683 from hz_contact_points
4684 where contact_point_id = p_contact_point_id;
4685 rec_contact_point c_contact_point%rowtype;
4686
4687 begin
4688
4689 for rec_contact_point in c_contact_point loop
4690 if rec_contact_point.owner_table_name = 'IBE_SH_QUOTE_ACCESS' then
4691 x_create_adhoc_flag := FND_API.G_TRUE;
4692 end if;
4693 exit when c_contact_point%notfound;
4694 end loop;
4695
4696 end;
4697
4698
4699 /********************************************************
4700 Notify_End_Working: Here the input parameters are
4701 quote_header_id of the shared cart.
4702 party_id of the recepient,
4703 cust_account_id of the recepient,
4704 Retrieval number for b2c users,
4705 speciality store id,
4706 URL of the shared cart.
4707
4708 This procedure is responsible to send an email to the owner of the cart
4709 to inform that the recepinet has completed the modifications on the
4710 shared cart.
4711 *********************************************************/
4712 PROCEDURE Notify_End_Working(
4713 p_api_version IN NUMBER,
4714 p_init_msg_list IN VARCHAR2,
4715 p_quote_header_id IN NUMBER,
4716 p_party_id IN NUMBER,
4717 p_Cust_Account_Id IN NUMBER,
4718 p_retrieval_number IN NUMBER,
4719 p_minisite_id IN NUMBER,
4720 p_url IN VARCHAR2,
4721 p_notes IN VARCHAR2,
4722 x_return_status OUT NOCOPY VARCHAR2,
4723 x_msg_count OUT NOCOPY NUMBER,
4724 x_msg_data OUT NOCOPY VARCHAR2
4725 ) IS
4726
4727 l_event_type VARCHAR2(20) := 'ENDWORK';
4728 l_notifEnabled Varchar2(3);
4729 l_notifName Varchar2(30) := 'ENDWORK';
4730 l_notif_context VARCHAR2(2000);
4731 l_Orgid Number := null;
4732 l_messageName WF_MESSAGES.NAME%TYPE;
4733 l_msgEnabled VARCHAR2(3);
4734 l_partyid HZ_PARTIES.PARTY_ID%TYPE;
4735 x_partyid HZ_PARTIES.PARTY_ID%TYPE;
4736 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
4737 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
4738 l_user_name WF_USERS.NAME%TYPE;
4739 l_usertype jtf_um_usertypes_b.usertype_key%type := FND_API.G_MISS_CHAR;
4740 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
4741 l_quote_name ASO_QUOTE_HEADERS_ALL.QUOTE_NAME%TYPE;
4742 l_quote_Num ASO_QUOTE_HEADERS_ALL.QUOTE_NUMBER%TYPE;
4743 l_quote_ver ASO_QUOTE_HEADERS_ALL.QUOTE_VERSION%TYPE;
4744 l_msite_name IBE_MSITES_VL.MSITE_NAME%TYPE;
4745 l_cart_name ASO_QUOTE_HEADERS_ALL.QUOTE_NAME%TYPE;
4746 l_is_it_quote VARCHAR2(1) := FND_API.G_FALSE;
4747 x_contact_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
4748 x_contact_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
4749 l_recip_name Varchar2(2000);
4750
4751 CURSOR c_msite_name(p_msite number) IS
4752 SELECT msite_name
4753 FROM ibe_msites_vl
4754 WHERE msite_id = p_msite;
4755
4756 CURSOR c_b2c_sharing(c_retrieval_number number) is
4757 select quote_name
4758 from aso_quote_headers_all
4759 where quote_header_id = (select quote_header_id
4760 from ibe_sh_quote_access
4761 where quote_sharee_number = c_retrieval_number);
4762 CURSOR c_get_recip_name(c_retrieval_number number) is
4763 select recipient_name
4764 from ibe_sh_quote_access
4765 where quote_sharee_number = c_retrieval_number;
4766
4767 rec_msite_name C_MSITE_NAME%ROWTYPE;
4768 rec_b2c_sharing c_b2c_sharing%ROWTYPE;
4769 rec_get_recip_name c_get_recip_name%rowtype;
4770
4771
4772 BEGIN
4773 x_return_status := FND_API.g_ret_sts_success;
4774
4775
4776 identify_cart_quote(p_quote_header_id => p_Quote_Header_id,
4777 x_is_it_quote => l_is_it_quote);
4778
4779 IF(l_is_it_quote = l_true) THEN
4780 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4781 IBE_UTIL.DEBUG('Notify_end_working:l_is_it_quote: '||l_is_it_quote);
4782 END IF;
4783 l_notifName := 'ENDWORK_QUOTE';
4784 l_notif_context := 'ENDWORK_QUOTE';
4785 ELSE
4786 l_notif_context := 'ENDWORK';
4787 END IF;
4788
4789 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
4790 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4791 ibe_util.debug('Notify_end_working: Notification enabled: '||l_notifEnabled);
4792 END IF;
4793
4794 IF l_notifEnabled = 'Y' THEN
4795 -- IF (p_quote_header_id is not null) or (p_quote_header_id <> fnd_api.g_miss_num) THEN
4796 FOR c_quote_rec In c_quote_header(p_Quote_Header_id) LOOP
4797 l_user_name :='HZ_PARTY:'||c_quote_rec.party_id;
4798 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4799 ibe_util.debug('Notify_end_working: I_user_name: '||l_user_name);
4800 END IF;
4801 l_orgid := c_quote_rec.org_id;
4802 l_cart_name := c_quote_rec.quote_name;
4803 l_partyId := c_quote_rec.party_id;
4804 l_quote_num := c_quote_rec.quote_number;
4805 l_quote_ver := c_quote_rec.quote_version;
4806 END LOOP;
4807 /*ELSE
4808 FOR rec_b2c_sharing in c_b2c_sharing(p_retrieval_number) LOOP
4809 l_cart_name := rec_b2c_sharing.cart_name;
4810 EXIT when c_b2c_sharing%notfound;
4811 END LOOP;
4812 END IF;*/
4813
4814 -- Retrive Actual Message
4815 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
4816 (
4817 p_org_id => l_OrgId,
4818 p_msite_id => p_minisite_id,
4819 p_user_type => l_userType,
4820 p_notif_name => l_notifName,
4821 x_enabled_flag => l_msgEnabled,
4822 x_wf_message_name => l_MessageName,
4823 x_return_status => x_return_status,
4824 x_msg_data => x_msg_data,
4825 x_msg_count => x_msg_data);
4826 IF x_msg_count > 0 THEN
4827 Raise GET_MESSAGE_ERROR;
4828 END IF;
4829 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4830 ibe_util.debug('Notify_end_working:l_MessageName: '||l_MessageName);
4831 ibe_util.debug('Notify_end_working:l_msgenabled: '||l_msgEnabled);
4832 END IF;
4833
4834 IF l_msgEnabled = 'Y' THEN
4835 l_usertype := FND_API.G_MISS_CHAR;
4836 x_contact_first_name := NULL;
4837 x_contact_last_name := NULL;
4838 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4839 ibe_util.debug('Notify_end_working:querying recipient_name');
4840 END IF;
4841 FOR rec_get_recip_name in c_get_recip_name(p_retrieval_number) LOOP
4842 l_recip_name := rec_get_recip_name.recipient_name;
4843 IF(l_recip_name is not null) THEN
4844 x_contact_first_name := l_recip_name;
4845 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4846 ibe_util.debug('Notify_end_working:recipient_name from sh_quote_access tbl: '||x_contact_first_name);
4847 END IF;
4848
4849 ELSE
4850 Get_Name_details(
4851 p_party_id => p_party_id,
4852 p_user_type => l_UserType,
4853 x_contact_first_name => x_contact_first_name,
4854 x_contact_last_name => x_contact_last_name,
4855 x_party_id => x_partyid);
4856 END IF;
4857 EXIT when c_get_recip_name%NOTFOUND;
4858 END LOOP;
4859
4860 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4861 ibe_util.debug('Notify_end_working:p_retrieval_number: '||p_retrieval_number);
4862 ibe_util.debug('Notify_end_working:x_contact_first_name: '||x_contact_first_name);
4863 ibe_util.debug('Notify_end_working:x_contact_last_name: '||x_contact_last_name);
4864 END IF;
4865 -- Create Item Type and notification Preference
4866 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_Quote_Header_id;
4867 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4868 ibe_util.debug('Notify_end_working:l_item_key: '||l_item_key);
4869 END IF;
4870 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
4871
4872 set_item_attributes
4873 ( p_item_key => l_item_key
4874 ,p_message_name => l_MessageName
4875 ,p_recipient_number => p_retrieval_number
4876 ,p_first_name => x_contact_first_name
4877 ,p_last_name => x_contact_last_name
4878 ,p_url => p_url
4879 ,p_minisite_id => p_minisite_id
4880 ,p_cart_name => l_cart_name
4881 ,p_adhoc_role => l_user_name
4882 ,p_notes => p_notes
4883 ,p_notif_context => l_notif_context);
4884
4885 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4886 ibe_util.debug('Notify_end_working:Create_process start');
4887 END IF;
4888 END IF; --l_msgEnabled
4889 END IF; --l_notifenabled
4890 EXCEPTION
4891
4892 WHEN OTHERS THEN
4893 x_return_status := FND_API.g_ret_sts_error;
4894 x_msg_count := 0;
4895 wf_core.context('IBE_WORKFLOW_PVT',l_notifname,l_messagename,p_quote_header_id);
4896 RAISE;
4897
4898 END Notify_End_Working;
4899
4900 /********************************************************
4901 Notify_Finish_Sharing: Here the input parameters are
4902 quote_access_record of the shared cart.
4903 speciality store id,
4904 URL of the shared cart.
4905 Context code : The context in which the mail has triggered.
4906
4907 This procedure is responsible to send an email to the recepient of the cart
4908 to inform that the owner has finished sharing the shared cart.
4909 The email can be generated in any of the following scenarios:
4910 Owner has deleted the Cart
4911 Owner has placed the order
4912 Owner has revoked the sharing of the cart
4913 Owner has transferred the access of this shared cart.
4914 *********************************************************/
4915
4916 PROCEDURE Notify_Finish_Sharing(
4917 p_api_version IN NUMBER,
4918 p_init_msg_list IN VARCHAR2,
4919 p_quote_access_rec IN IBE_QUOTE_SAVESHARE_pvt.QUOTE_ACCESS_REC_TYPE, --of the recepient
4920 p_minisite_id IN NUMBER,
4921 p_url IN VARCHAR2,
4922 p_context_code IN VARCHAR2,
4923 p_shared_by_partyid IN NUMBER := FND_API.G_MISS_NUM,
4924 p_notes IN VARCHAR2,
4925 x_return_status OUT NOCOPY VARCHAR2,
4926 x_msg_count OUT NOCOPY NUMBER,
4927 x_msg_data OUT NOCOPY VARCHAR2
4928 ) IS
4929 l_event_type VARCHAR2(20) := 'STOPWORK';
4930 l_notifEnabled Varchar2(3);
4931 l_notifName Varchar2(30) := 'STOPWORKING';
4932 l_notif_context VARCHAR2(2000);
4933 l_Orgid Number := null;
4934 l_messageName WF_MESSAGES.NAME%TYPE;
4935 l_msgEnabled VARCHAR2(3);
4936 l_usertype jtf_um_usertypes_b.usertype_key%type := 'ALL' ;
4937 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
4938 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
4939 l_user_name WF_USERS.NAME%TYPE;
4940 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE ;
4941 l_msite_name IBE_MSITES_VL.MSITE_NAME%TYPE;
4942 l_cart_name ASO_QUOTE_HEADERS_ALL.QUOTE_NAME%TYPE;
4943 l_is_it_quote VARCHAR2(1) := FND_API.G_FALSE;
4944
4945 l_sharedby_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
4946 l_sharedby_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
4947 l_owner_partyid HZ_PARTIES.PARTY_ID%TYPE;
4948 x_owner_new_party_id HZ_PARTIES.PARTY_ID%TYPE;
4949
4950 l_recepient_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
4951 l_recepient_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
4952 x_recepient_party_id HZ_PARTIES.PARTY_ID%TYPE;
4953
4954 l_stop_working_msg_context FND_NEW_MESSAGES.MESSAGE_TEXT%TYPE;
4955
4956 l_role_users Varchar2(200);
4957 l_adhoc_role WF_ROLES.NAME%TYPE;
4958 l_adhoc_role_display WF_ROLES.DISPLAY_NAME%TYPE;
4959 l_adhoc_user WF_USERS.NAME%TYPE;
4960 l_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
4961 l_create_adhoc_flag VARCHAR2(1);
4962 l_context_code VARCHAR2(2000);
4963
4964
4965 /*CURSOR c_context_code(c_context_code VARCHAR2) IS
4966 SELECT message_text
4967 FROM fnd_new_messages
4968 WHERE message_name = c_context_code
4969 AND application_id = 671
4970 AND language_code = userenv('LANG');
4971 rec_get_context_msg C_CONTEXT_CODE%ROWTYPE;*/
4972
4973
4974 BEGIN
4975 x_return_status := FND_API.g_ret_sts_success ;
4976
4977 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
4978
4979
4980 l_context_code := p_context_code;
4981
4982 identify_cart_quote(p_quote_header_id => p_quote_access_rec.Quote_Header_id,
4983 x_is_it_quote => l_is_it_quote);
4984
4985 IF(l_is_it_quote = l_true) THEN
4986 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4987 IBE_UTIL.DEBUG('Notify_finish_sharing:l_is_it_quote: '||l_is_it_quote);
4988 END IF;
4989 l_notifName := 'STOPWORKING_QUOTE';
4990 l_notif_context := 'STOPWORKING_QUOTE';
4991 IF (p_context_code = 'IBE_SC_CART_ORDERED') THEN
4992 l_context_code := 'IBE_SC_QUOTE_ORDERED';
4993 ELSIF(p_context_code = 'IBE_SC_CART_STOPSHARING') THEN
4994 l_context_code := 'IBE_SC_QUOTE_STOPSHARING';
4995 END IF;
4996
4997 ELSE
4998 l_notifName := 'STOPWORKING';
4999 l_notif_context := 'STOPWORKING';
5000 END IF;
5001
5002
5003 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
5004 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5005 IBE_UTIL.DEBUG('Notify_finish_sharing: '||l_notifEnabled);
5006 END IF;
5007 IF l_notifEnabled = 'Y' THEN
5008
5009
5010 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5011 IBE_UTIL.DEBUG('Notify_finish_sharing: Notification enabled');
5012 IBE_UTIL.DEBUG('Notify_finish_sharing:Querying owner party_id');
5013 END IF;
5014 FOR c_quote_rec In c_quote_header(p_quote_access_rec.Quote_Header_id)
5015 LOOP
5016 l_owner_partyid := c_quote_rec.party_id;
5017 l_orgid := c_quote_rec.org_id;
5018 l_cart_name := c_quote_rec.quote_name; -- cart name
5019 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5020 IBE_UTIL.DEBUG('Notify_finish_sharing:Quote_header_id for stop_sharing: '||p_quote_access_rec.Quote_Header_id);
5021 IBE_UTIL.DEBUG('Notify_finish_sharing:Owner_party_id: '||l_owner_partyid);
5022 IBE_UTIL.DEBUG('Notify_finish_sharing:Owner cart name: '||l_cart_name);
5023 END IF;
5024 END LOOP;
5025
5026 l_usertype := FND_API.G_MISS_CHAR;
5027 l_sharedby_first_name := NULL;
5028 l_sharedby_last_name := NULL;
5029 Get_Name_details(p_party_id => p_shared_by_partyid,
5030 p_user_type => l_UserType,
5031 x_contact_first_name => l_sharedby_first_name,
5032 x_contact_last_name => l_sharedby_last_name,
5033 x_party_id => x_owner_new_party_id);
5034
5035
5036 -- Dealing with context..........
5037
5038 /*FOR rec_get_context_msg IN c_context_code(l_context_code)
5039 LOOP
5040 l_stop_working_msg_context := rec_get_context_msg.message_text;
5041 END LOOP;*/
5042
5043 --whether to create adhoc users or not
5044 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5045 IBE_UTIL.DEBUG('Notify_finish_sharing:locate_contact_point:whether to create adhoc users or not');
5046 END IF;
5047 locate_contact_point(
5048 p_contact_point_id => p_quote_access_rec.contact_point_id,
5049 x_create_adhoc_flag => l_create_adhoc_flag);
5050
5051
5052 IF (l_create_adhoc_flag = FND_API.G_TRUE) THEN
5053 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5054 IBE_UTIL.DEBUG('Notify_finish_sharing:l_create_adhoc_flag: '||l_create_adhoc_flag);
5055 END IF;
5056
5057 /*If an e-mail address is passed then the recipient party
5058 does not have a contact point, hence we create an adhoc user*/
5059 create_adhoc_entity
5060 ( p_quote_recipient_id => p_quote_access_rec.QUOTE_SHAREE_ID
5061 ,p_quote_header_id => p_quote_access_rec.quote_header_id
5062 ,p_email_address => p_quote_access_rec.email_contact_address
5063 ,p_Notification_preference => l_notification_preference
5064 ,x_adhoc_role => l_adhoc_role);
5065 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5066 IBE_UTIL.DEBUG('Notify_finish_sharing:Create_adhoc_entity: done');
5067 END IF;
5068
5069 Else
5070
5071 l_user_name := 'HZ_PARTY:'||p_quote_access_rec.party_id;
5072 l_adhoc_role := l_user_name;
5073
5074 End If;
5075
5076 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5077 IBE_UTIL.DEBUG('Notify_finish_sharing:l_adhoc_role: '||l_adhoc_role);
5078 END IF;
5079
5080
5081 -- Retrive Actual Message
5082 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5083 IBE_UTIL.DEBUG('Notify_finish_sharing:Retrievng message mapping');
5084 END IF;
5085 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
5086 (
5087 p_org_id => l_OrgId,
5088 p_msite_id => p_minisite_id,
5089 p_user_type => l_userType,
5090 p_notif_name => l_notifName,
5091 x_enabled_flag => l_msgEnabled,
5092 x_wf_message_name => l_MessageName,
5093 x_return_status => x_return_status,
5094 x_msg_data => x_msg_data,
5095 x_msg_count => x_msg_data);
5096 IF x_msg_count > 0 THEN
5097 Raise GET_MESSAGE_ERROR;
5098 END IF;
5099 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5100 IBE_UTIL.DEBUG('Notify_finish_sharing:After message mapping:l_messagename: '||l_MessageName);
5101 IBE_UTIL.DEBUG('Notify_finish_sharing:After message mapping:l_msg_enabled: '||l_msgEnabled);
5102 END IF;
5103
5104 IF l_msgEnabled = 'Y' THEN
5105
5106 -- Create Item Type and notification Preference
5107 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_access_rec.Quote_Header_id
5108 ||p_quote_access_rec.Quote_sharee_number;
5109 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5110 IBE_UTIL.DEBUG('Notify_finish_sharing:Item_key : '||l_item_key);
5111 END IF;
5112 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
5113
5114
5115 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5116 IBE_UTIL.DEBUG('Notify_finish_sharing:Create_process start');
5117 END IF;
5118
5119 set_item_attributes
5120 ( p_item_key => l_item_key
5121 ,p_message_name => l_MessageName
5122 ,p_first_name => l_sharedby_first_name
5123 ,p_last_name => l_sharedby_last_name
5124 ,p_minisite_id => p_minisite_id
5125 ,p_cart_name => l_cart_name
5126 ,p_adhoc_role => l_adhoc_role
5127 ,p_context_msg => l_context_code
5128 ,p_notes => p_notes
5129 ,p_notif_context=> l_notif_context);
5130
5131 END IF; --l_msgEnabled
5132 END IF; --l_notif enabled
5133 EXCEPTION
5134
5135 WHEN OTHERS THEN
5136 x_return_status := FND_API.g_ret_sts_error;
5137 x_msg_count := 0;
5138 wf_core.context('IBE_WORKFLOW_PVT',l_notifName,l_notifName);
5139 RAISE;
5140
5141 END Notify_Finish_Sharing;
5142
5143 /********************************************************
5144 NotifyForSharedCart : Here the input parameters are
5145 quote_access_record of the shared cart.
5146 speciality store id,
5147 URL of the shared cart.
5148 Here owner will send email to the recepient.
5149 Depending on the recepient user type (B2B/B2C) the email body
5150 will be changed.
5151 ********************************************************/
5152 PROCEDURE Notify_shared_cart (
5153 p_api_version IN NUMBER,
5154 p_init_msg_list IN VARCHAR2,
5155 p_quote_access_rec IN IBE_QUOTE_SAVESHARE_pvt.QUOTE_ACCESS_REC_TYPE, --of the recepient
5156 p_minisite_id IN NUMBER,
5157 p_url IN VARCHAR2,
5158 p_shared_by_party_id IN NUMBER := FND_API.G_MISS_NUM,
5159 p_notes IN VARCHAR2,
5160 x_return_status OUT NOCOPY VARCHAR2,
5161 x_msg_count OUT NOCOPY NUMBER,
5162 x_msg_data OUT NOCOPY VARCHAR2
5163 ) IS
5164 l_event_type VARCHAR2(20) := 'SHARECARTNOTIF';
5165 l_notifEnabled Varchar2(3) ;
5166 l_notifName Varchar2(30):= 'SHARECARTNOTIF';
5167 l_notif_context VARCHAR2(2000);
5168 l_Orgid Number := null;
5169 l_messageName WF_MESSAGES.NAME%TYPE;
5170 l_msgEnabled VARCHAR2(3);
5171 l_usertype jtf_um_usertypes_b.usertype_key%type := 'ALL' ;
5172 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
5173 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
5174 l_user_name WF_USERS.NAME%TYPE;
5175 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE ;
5176 l_msite_name IBE_MSITES_VL.MSITE_NAME%TYPE;
5177 l_cart_name ASO_QUOTE_HEADERS_ALL.QUOTE_NAME%TYPE;
5178 l_is_it_quote VARCHAR2(1) := FND_API.G_FALSE;
5179
5180 l_sharedby_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
5181 l_sharedby_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
5182 l_owner_partyid HZ_PARTIES.PARTY_ID%TYPE;
5183 x_owner_new_party_id HZ_PARTIES.PARTY_ID%TYPE;
5184
5185 l_recepient_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
5186 l_recepient_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
5187 x_recepient_party_id HZ_PARTIES.PARTY_ID%TYPE;
5188 l_accesslevel VARCHAR2(60);
5189
5190 l_role_users Varchar2(400);
5191 l_adhoc_role WF_ROLES.NAME%TYPE;
5192 l_adhoc_role_display WF_ROLES.DISPLAY_NAME%TYPE;
5193 l_adhoc_user WF_USERS.NAME%TYPE;
5194 l_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
5195 l_create_adhoc_flag VARCHAR2(1);
5196
5197 l_temp_retrieve_str VARCHAR2(1000);
5198 l_temp_update_str VARCHAR2(1000);
5199
5200
5201 BEGIN
5202 x_return_status := FND_API.g_ret_sts_success ;
5203
5204 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
5205
5206 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5207 IBE_UTIL.DEBUG('Notify_shared_cart:calling identify_cart_quote');
5208 END IF;
5209
5210
5211 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5212 IBE_UTIL.DEBUG('Notify_shared_cart:Determining party_type');
5213 END IF;
5214 IF ((p_quote_access_rec.party_id is null )
5215 OR (p_quote_access_rec.party_id = FND_API.G_MISS_NUM)) THEN
5216
5217 l_usertype := 'IBE_INDIVIDUAL';
5218
5219 ELSE
5220 getUserType(p_quote_access_rec.party_id,l_UserType);
5221 END IF;
5222
5223 identify_cart_quote(p_quote_header_id => p_quote_access_rec.Quote_Header_id,
5224 x_is_it_quote => l_is_it_quote);
5225
5226 IF(l_is_it_quote = l_true) THEN
5227 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5228 IBE_UTIL.DEBUG('Notify_shared_cart:l_is_it_quote: '||l_is_it_quote);
5229 END IF;
5230 l_notifname := 'SHAREQUOTENOTIF';
5231 IF (l_usertype = 'IBE_INDIVIDUAL') THEN
5232 l_notif_context := 'SHAREQUOTENOTIF';
5233 ELSE
5234 l_notif_context := 'SHAREQUOTENOTIF_B2B';
5235 END IF;
5236 ELSE
5237 l_notifname := 'SHARECARTNOTIF';
5238 IF (l_usertype = 'IBE_INDIVIDUAL') THEN
5239 l_notif_context := 'SHARECARTNOTIF';
5240 ELSE
5241 l_notif_context := 'SHARECARTNOTIF_B2B';
5242 END IF;
5243 END IF;
5244
5245 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5246 IBE_UTIL.DEBUG('Notify_shared_cart:l_notifname: '||l_notifName);
5247 IBE_UTIL.DEBUG('Notify_shared_cart:l_usertype: '||l_usertype);
5248 END IF;
5249 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
5250 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5251 IBE_UTIL.DEBUG('Notify_shared_cart:Shared cart notification enabled: '||l_notifEnabled);
5252 END IF;
5253
5254 IF l_notifEnabled = 'Y' THEN
5255 --get owner party_id, cart_name here from input quote_header_id
5256 FOR c_quote_rec IN c_quote_header(p_quote_access_rec.Quote_Header_id)
5257 LOOP
5258 l_owner_partyid := c_quote_rec.party_id;
5259 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5260 IBE_UTIL.DEBUG('Notify_shared_cart:Owner party_id: '||l_owner_partyid);
5261 END IF;
5262 l_orgid := c_quote_rec.org_id;
5263 l_cart_name := c_quote_rec.quote_name; -- cart name
5264 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5265 IBE_UTIL.DEBUG('Notify_shared_cart:cart name: '||l_cart_name);
5266 END IF;
5267 END LOOP;
5268
5269 --get owner name from owner party_id obtained above
5270 l_sharedby_first_name := NULL;
5271 l_sharedby_last_name := NULL;
5272 Get_Name_details(p_party_id => p_shared_by_party_id,
5273 p_user_type => l_UserType,
5274 x_contact_first_name => l_sharedby_first_name,
5275 x_contact_last_name => l_sharedby_last_name,
5276 x_party_id => x_owner_new_party_id);
5277
5278 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5279 IBE_UTIL.DEBUG('Notify_shared_cart:Owner first name: '||l_sharedby_first_name);
5280 IBE_UTIL.DEBUG('Notify_shared_cart:owner last name: '||l_sharedby_last_name);
5281 END IF;
5282 --whether to create adhoc user or not
5283
5284 locate_contact_point(
5285 p_contact_point_id => p_quote_access_rec.contact_point_id,
5286 x_create_adhoc_flag => l_create_adhoc_flag);
5287
5288 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5289 IBE_UTIL.DEBUG('Notify_shared_cart:l_create_adhoc_flag: '||l_create_adhoc_flag);
5290 END IF;
5291
5292 --if create adhoc user flag is "true" then call wf_directory API
5293 IF (l_create_adhoc_flag = FND_API.G_TRUE) THEN
5294 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5295 IBE_UTIL.DEBUG('Notify_shared_cart:l_create_adhoc_flag is true');
5296 IBE_UTIL.DEBUG('Notify_shared_cart:p_quote_access_rec.QUOTE_SHAREE_ID: '||p_quote_access_rec.QUOTE_SHAREE_ID);
5297 IBE_UTIL.DEBUG('Notify_shared_cart:p_quote_access_rec.quote_header_id: '||p_quote_access_rec.quote_header_id);
5298 END IF;
5299
5300 create_adhoc_entity
5301 ( p_quote_recipient_id => p_quote_access_rec.QUOTE_SHAREE_ID
5302 ,p_quote_header_id => p_quote_access_rec.quote_header_id
5303 ,p_email_address => p_quote_access_rec.email_contact_address
5304 ,p_Notification_preference => l_notification_preference
5305 ,x_adhoc_role => l_adhoc_role);
5306 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5307 IBE_UTIL.DEBUG('Notify_shared_cart:Create_adhoc_entity: done');
5308 END IF;
5309 Else
5310
5311 l_user_name := 'HZ_PARTY:'||p_quote_access_rec.party_id;
5312 l_adhoc_role := l_user_name;
5313
5314 End If; --create adhoc user or not
5315
5316 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5317 IBE_UTIL.DEBUG('Notify_shared_cart:l_adhoc role: '||l_adhoc_role);
5318 END IF;
5319
5320 --Get Access Level Info.
5321 /* IF (p_quote_access_rec.UPDATE_PRIVILEGE_TYPE_CODE = 'A') THEN
5322 l_accesslevel := 'Administrator';
5323 ELSIF (p_quote_access_rec.UPDATE_PRIVILEGE_TYPE_CODE = 'F' OR
5324 p_quote_access_rec.UPDATE_PRIVILEGE_TYPE_CODE = 'U' ) THEN
5325 l_accesslevel := 'Participant';
5326 ELSE
5327 l_accesslevel := 'Viewer';
5328 END IF;*/
5329
5330 -- Retrive Actual Message
5331 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5332 IBE_UTIL.DEBUG('Notify_shared_cart:retrieving message mapping');
5333 END IF;
5334
5335 -- Retrieve the message text for update message from fnd_messages
5336
5337 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
5338 (
5339 p_org_id => l_OrgId,
5340 p_msite_id => p_minisite_id,
5341 p_user_type => l_userType,
5342 p_notif_name => l_notifName,
5343 x_enabled_flag => l_msgEnabled,
5344 x_wf_message_name => l_MessageName,
5345 x_return_status => x_return_status,
5346 x_msg_data => x_msg_data,
5347 x_msg_count => x_msg_data);
5348
5349 IF x_msg_count > 0 THEN
5350 Raise GET_MESSAGE_ERROR;
5351 END IF;
5352 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5353 IBE_UTIL.DEBUG('Notify_shared_cart:Message_name: '||l_messageName);
5354 IBE_UTIL.DEBUG('Notify_shared_cart:l_msgenabled: '||l_msgenabled);
5355 END IF;
5356
5357 IF l_msgEnabled = 'Y' THEN
5358
5359 -- Create Item Type and notification Preference
5360 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_access_rec.Quote_Header_id
5361 ||p_quote_access_rec.Quote_sharee_number;
5362 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5363 IBE_UTIL.DEBUG('Notify_shared_cart:Item_key: '||l_item_key);
5364 END IF;
5365 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
5366
5367 set_item_attributes
5368 ( p_item_key => l_item_key
5369 ,p_message_name => l_MessageName
5370 ,p_access_level => p_quote_access_rec.UPDATE_PRIVILEGE_TYPE_CODE
5371 ,p_recipient_number => p_quote_access_rec.quote_sharee_number
5372 ,p_first_name => l_sharedby_first_name
5373 ,p_last_name => l_sharedby_last_name
5374 ,p_url => p_url
5375 ,p_minisite_id => p_minisite_id
5376 ,p_cart_name => l_cart_name
5377 ,p_adhoc_role => l_adhoc_role
5378 ,p_notes => p_notes
5379 ,p_notif_context => l_notif_context);
5380 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5381 IBE_UTIL.DEBUG('Notify_shared_cart:Set_item_attributes: Done');
5382 END IF;
5383 END IF; ----l_msgEnabled
5384 END IF; -- l_notifenabled
5385 EXCEPTION
5386
5387 WHEN OTHERS THEN
5388 x_return_status := FND_API.g_ret_sts_error;
5389 x_msg_count := 0;
5390 wf_core.context('IBE_WORKFLOW_PVT',l_notifName,l_notifName);
5391 RAISE;
5392
5393 END Notify_Shared_Cart ;
5394
5395 /********************************************************
5396 Notify_Access_Change: Here the input parameters are
5397 quote_access_record of the shared cart.
5398 speciality store id,
5399 old_access_level of the recepient
5400 URL of the shared cart.
5401 Here owner will send email to the recepient.
5402 This email states that the recepient access level is changed from old access level
5403 to the new access level.
5404 ********************************************************/
5405 PROCEDURE Notify_Access_Change(
5406 p_api_version IN NUMBER,
5407 p_init_msg_list IN VARCHAR2,
5408 p_quote_access_rec IN IBE_QUOTE_SAVESHARE_pvt.QUOTE_ACCESS_REC_TYPE, --of the recepient
5409 p_minisite_id IN NUMBER,
5410 p_url IN VARCHAR2,
5411 p_old_accesslevel IN VARCHAR2,
5412 p_shared_by_party_id IN NUMBER := FND_API.G_MISS_NUM,
5413 p_notes IN VARCHAR2,
5414 x_return_status OUT NOCOPY VARCHAR2,
5415 x_msg_count OUT NOCOPY NUMBER,
5416 x_msg_data OUT NOCOPY VARCHAR2
5417 ) IS
5418 l_event_type VARCHAR2(20) := 'ACCESSCHANGE';
5419 l_notifEnabled Varchar2(3);
5420 l_notifName Varchar2(30) := 'CHANGEACCESSLEVEL';
5421 l_notif_context VARCHAR2(2000);
5422 l_Orgid Number := null;
5423 l_messageName WF_MESSAGES.NAME%TYPE;
5424 l_msgEnabled VARCHAR2(3);
5425 l_usertype jtf_um_usertypes_b.usertype_key%type := 'ALL' ;
5426 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
5427 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
5428 l_user_name WF_USERS.NAME%TYPE;
5429 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE ;
5430 l_msite_name IBE_MSITES_VL.MSITE_NAME%TYPE;
5431 l_cart_name ASO_QUOTE_HEADERS_ALL.QUOTE_NAME%TYPE;
5432 l_is_it_quote varchar2(1) := FND_API.G_FALSE;
5433
5434 l_sharedby_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
5435 l_sharedby_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
5436 l_owner_partyid HZ_PARTIES.PARTY_ID%TYPE;
5437 x_owner_new_party_id HZ_PARTIES.PARTY_ID%TYPE;
5438
5439 l_recepient_first_name HZ_PARTIES.PERSON_FIRST_NAME%TYPE;
5440 l_recepient_last_name HZ_PARTIES.PERSON_LAST_NAME%TYPE;
5441 x_recepient_party_id HZ_PARTIES.PARTY_ID%TYPE;
5442
5443 l_new_access_level VARCHAR2(60);
5444 l_old_access_level VARCHAR2(60);
5445
5446 l_role_users Varchar2(400);
5447 l_adhoc_role WF_ROLES.NAME%TYPE;
5448 l_adhoc_role_display WF_ROLES.DISPLAY_NAME%TYPE;
5449 l_adhoc_user WF_USERS.NAME%TYPE;
5450 l_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
5451 l_create_adhoc_flag VARCHAR2(1);
5452 l_quote_access_rec IBE_QUOTE_SAVESHARE_pvt.QUOTE_ACCESS_REC_TYPE;
5453 l_temp_update_str VARCHAR2(1000);
5454 l_url VARCHAR2(2000);
5455
5456 cursor c_get_email(c_contact_point_id NUMBER) is
5457 select email_address
5458 from HZ_CONTACT_POINTS
5459 where contact_point_id = c_contact_point_id;
5460
5461 rec_get_email c_get_email%rowtype;
5462
5463 BEGIN
5464 x_return_status := FND_API.g_ret_sts_success ;
5465
5466 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
5467 l_quote_access_rec := p_quote_access_rec;
5468
5469 identify_cart_quote(p_quote_header_id => l_quote_access_rec.Quote_Header_id,
5470 x_is_it_quote => l_is_it_quote);
5471
5472 IF(l_is_it_quote = l_true) THEN
5473 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5474 IBE_UTIL.DEBUG('Notify_shared_cart:l_is_it_quote: '||l_is_it_quote);
5475 END IF;
5476 l_notifName := 'CHANGEACCESSLEVEL_QUOTE';
5477 l_notif_context := 'CHANGEACCESSLEVEL_QUOTE';
5478 ELSE
5479 l_notif_context := 'CHANGEACCESSLEVEL';
5480 END IF;
5481
5482
5483 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
5484 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5485 IBE_UTIL.DEBUG('Notify_access_change:l_notifEnabled: '||l_notifEnabled);
5486 END IF;
5487 --l_notifEnabled := 'Y';
5488 If l_notifEnabled = 'Y' Then
5489 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5490 IBE_UTIL.DEBUG('Notify_access_change:Notification enabled');
5491 IBE_UTIL.DEBUG('Notify_access_change:Quote_header_id of shared cart: '||l_quote_access_rec.Quote_Header_id);
5492 END IF;
5493 FOR c_quote_rec In c_quote_header(l_quote_access_rec.Quote_Header_id) LOOP
5494 l_owner_partyid := c_quote_rec.party_id;
5495 l_orgid := c_quote_rec.org_id;
5496 l_cart_name := c_quote_rec.quote_name; -- cart name
5497 END LOOP;
5498
5499 l_usertype := FND_API.G_MISS_CHAR;
5500 l_sharedby_first_name := NULL;
5501 l_sharedby_last_name := NULL;
5502 Get_Name_details(p_party_id => p_shared_by_party_id,
5503 p_user_type => l_UserType,
5504 x_contact_first_name => l_sharedby_first_name,
5505 x_contact_last_name => l_sharedby_last_name,
5506 x_party_id => x_owner_new_party_id);
5507
5508 -- Now identify whether the recepient is B2B or B2C ****
5509 -- Call the Get_Name_details to get the party_id of the recepient.
5510 -- And pipe it with HZ_PARTIES to get email id of the recepient.
5511
5512 l_usertype := FND_API.G_MISS_CHAR;
5513 x_recepient_party_id := 0;
5514 Get_Name_details(p_party_id => l_quote_access_rec.party_id,
5515 p_user_type => l_UserType,
5516 x_contact_first_name => l_recepient_first_name,
5517 x_contact_last_name => l_recepient_last_name,
5518 x_party_id => x_recepient_party_id);
5519
5520 l_user_name := 'HZ_PARTY:'||x_recepient_party_id;
5521 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5522 IBE_UTIL.DEBUG('Notify_access_change:recipient first name: '||l_recepient_first_name);
5523 IBE_UTIL.DEBUG('Notify_access_change:recipient last name: '||l_recepient_last_name);
5524 IBE_UTIL.DEBUG('Notify_access_change:recipient party_id: '||x_recepient_party_id);
5525 END IF;
5526
5527
5528 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5529 IBE_UTIL.DEBUG('Notify_access_change:Calling locate_contact_point');
5530 END IF;
5531
5532 locate_contact_point(
5533 p_contact_point_id => l_quote_access_rec.contact_point_id,
5534 x_create_adhoc_flag => l_create_adhoc_flag);
5535
5536 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5537 IBE_UTIL.DEBUG('Notify_access_change:l_create_adhoc_flag: '||l_create_adhoc_flag);
5538 END IF;
5539 IF (l_create_adhoc_flag = FND_API.G_TRUE) THEN
5540
5541 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5542 IBE_UTIL.DEBUG('Notify_access_change:Opening c_get_email');
5543 END IF;
5544
5545 FOR rec_get_email in c_get_email(l_quote_access_rec.contact_point_id) LOOP
5546 l_quote_access_rec.email_contact_address := rec_get_email.email_address;
5547 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5548 IBE_UTIL.DEBUG('Notify_access_change:email address in c_get_email: '||l_quote_access_rec.email_contact_address);
5549 END IF;
5550 EXIT WHEN c_get_email%notfound;
5551 END LOOP;
5552
5553 /*If an e-mail address is passed then the recipient party
5554 does not have a contact point, hence we create an adhoc user*/
5555
5556 create_adhoc_entity
5557 ( p_quote_recipient_id => l_quote_access_rec.QUOTE_SHAREE_ID
5558 ,p_quote_header_id => l_quote_access_rec.quote_header_id
5559 ,p_email_address => l_quote_access_rec.email_contact_address
5560 ,p_Notification_preference => l_notification_preference
5561 ,x_adhoc_role => l_adhoc_role);
5562 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5563 IBE_UTIL.DEBUG('Notify_access_change:Create_adhoc_entity: done');
5564 END IF;
5565
5566 Else --for create_adhoc_flag
5567
5568 l_user_name := 'HZ_PARTY:'||l_quote_access_rec.party_id;
5569 l_adhoc_role := l_user_name;
5570
5571 End If; --for create_adhoc_flag
5572
5573 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5574 IBE_UTIL.DEBUG('Notify_access_change:l_adhoc_role: '||l_adhoc_role);
5575 END IF;
5576
5577 -- Retrive Actual Message
5578 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
5579 (
5580 p_org_id => l_OrgId,
5581 p_msite_id => p_minisite_id,
5582 p_user_type => l_userType,
5583 p_notif_name => l_notifName,
5584 x_enabled_flag => l_msgEnabled,
5585 x_wf_message_name => l_MessageName,
5586 x_return_status => x_return_status,
5587 x_msg_data => x_msg_data,
5588 x_msg_count => x_msg_data);
5589
5590 IF x_msg_count > 0 THEN
5591 Raise GET_MESSAGE_ERROR;
5592 END IF;
5593
5594 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5595 IBE_UTIL.DEBUG('Notify_access_change:After message mapping call:l_MessageName: '||l_MessageName);
5596 IBE_UTIL.DEBUG('Notify_access_change:l_msgEnabled: '||l_msgEnabled);
5597 END IF;
5598
5599 -- Retrieve the message text for update message from fnd_messages
5600 fnd_message.set_name('IBE','IBE_PRMT_UPDATE_CART');
5601 l_temp_update_str := FND_API.G_MISS_CHAR;
5602 l_temp_update_str := fnd_message.get;
5603 --l_msgEnabled := 'Y';
5604 IF l_msgEnabled = 'Y' THEN
5605 l_url := p_url;
5606 l_url := l_url||p_quote_access_rec.quote_sharee_number;
5607 -- Create Item Type and notification Preference
5608 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||l_quote_access_rec.Quote_Header_id||
5609 l_quote_access_rec.quote_sharee_number ;
5610 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5611 IBE_UTIL.DEBUG('Notify_access_change:Calling set_item_attributes');
5612 END IF;
5613 set_item_attributes
5614 ( p_item_key => l_item_key
5615 ,p_message_name => l_messagename
5616 ,p_access_level => l_quote_access_rec.UPDATE_PRIVILEGE_TYPE_CODE
5617 ,p_old_access_level => P_old_accesslevel
5618 ,p_first_name => l_sharedby_first_name
5619 ,p_last_name => l_sharedby_last_name
5620 ,p_url => l_url
5621 ,p_minisite_id => p_minisite_id
5622 ,p_cart_name => l_cart_name
5623 ,p_adhoc_role => l_adhoc_role
5624 ,p_notes => p_notes
5625 ,p_notif_context => l_notif_context);
5626 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5627 IBE_UTIL.DEBUG('Notify_access_change:Done calling set_item_attributes');
5628 END IF;
5629 END IF; --l_msgEnabled
5630 END IF; --l_notifenabled
5631 EXCEPTION
5632
5633 WHEN OTHERS THEN
5634 x_return_status := FND_API.g_ret_sts_error;
5635 x_msg_count := 0;
5636 wf_core.context('IBE_WORKFLOW_PVT',l_notifName,l_notifName);
5637 RAISE;
5638
5639 END Notify_access_change;
5640
5641 PROCEDURE Notify_view_shared_cart(
5642 p_api_version IN NUMBER,
5643 p_init_msg_list IN VARCHAR2,
5644 p_quote_access_rec IN IBE_QUOTE_SAVESHARE_PVT.QUOTE_ACCESS_REC_TYPE, --of the recepient
5645 p_minisite_id IN NUMBER,
5646 p_url IN VARCHAR2,
5647 p_sent_by_party_id IN NUMBER ,
5648 p_notes IN VARCHAR2,
5649 p_owner_party_id IN NUMBER := FND_API.G_MISS_NUM,
5650 x_return_status OUT NOCOPY VARCHAR2,
5651 x_msg_count OUT NOCOPY NUMBER,
5652 x_msg_data OUT NOCOPY VARCHAR2
5653 ) is
5654
5655 cursor c_quote_name(c_qte_header_id number) is
5656 select quote_name
5657 from aso_quote_headers_all
5658 where quote_header_id = c_qte_header_id;
5659
5660 cursor c_get_email(c_contact_point_id NUMBER) is
5661 select email_address
5662 from HZ_CONTACT_POINTS
5663 where contact_point_id = c_contact_point_id;
5664
5665 rec_get_email c_get_email%rowtype;
5666 rec_quote_name c_quote_name%rowtype;
5667
5668 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
5669 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
5670 l_event_type VARCHAR2(100) := 'VIEWSHAREDCART';
5671
5672 l_sent_by_first_name VARCHAR2(1000);
5673 l_sent_by_last_name VARCHAR2(1000);
5674 l_sent_by_party_id NUMBER;
5675 l_owner_first_name VARCHAR2(1000);
5676 l_owner_last_name VARCHAR2(1000);
5677 l_owner_party_id NUMBER;
5678 l_quote_name VARCHAR2(1000);
5679 l_user_Type jtf_um_usertypes_b.usertype_key%type;
5680 l_msg_Enabled VARCHAR2(1);
5681 l_msg_name VARCHAR2(1000);
5682 l_org_id NUMBER;
5683 l_create_adhoc_flag VARCHAR2(10);
5684 l_adhoc_role VARCHAR2(2000);
5685 l_url VARCHAR2(4000);
5686 l_access_code VARCHAR2(2000);
5687 l_email_address VARCHAR2(2000);
5688 l_notif_Enabled VARCHAR2(1);
5689
5690 l_notif_name VARCHAR2(1000) := 'IBE_VIEWSHAREDCART';
5691 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
5692 BEGIN
5693 x_return_status := FND_API.g_ret_sts_success ;
5694 IBE_UTIL.DEBUG('Notify_view_shared_cart: START');
5695
5696 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5697 ibe_util.debug('Check if this notification is enabled.');
5698 END IF;
5699
5700 l_notif_Enabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notif_Name);
5701 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5702 ibe_util.debug('Notification Name: '||l_notif_Name||' Enabled: '||l_notif_Enabled);
5703 END IF;
5704
5705 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
5706 locate_contact_point(
5707 p_contact_point_id => p_quote_access_rec.contact_point_id,
5708 x_create_adhoc_flag => l_create_adhoc_flag);
5709
5710
5711 IF (l_create_adhoc_flag = FND_API.G_TRUE) THEN
5712 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5713 IBE_UTIL.DEBUG('Notify_view_shared_cart:l_create_adhoc_flag: '||l_create_adhoc_flag);
5714 END IF;
5715
5716
5717 FOR rec_get_email in c_get_email(p_quote_access_rec.contact_point_id) LOOP
5718 l_email_address := rec_get_email.email_address;
5719 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5720 IBE_UTIL.DEBUG('Notify_access_change:email address in c_get_email: '||l_email_address);
5721 END IF;
5722 EXIT WHEN c_get_email%notfound;
5723 END LOOP;
5724
5725 /*If an e-mail address is passed then the recipient party
5726 does not have a contact point, hence we create an adhoc user*/
5727 create_adhoc_entity
5728 ( p_quote_recipient_id => p_quote_access_rec.QUOTE_SHAREE_ID
5729 ,p_quote_header_id => p_quote_access_rec.quote_header_id
5730 ,p_email_address => l_email_address
5731 ,p_Notification_preference => l_notification_preference
5732 ,x_adhoc_role => l_adhoc_role);
5733
5734 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5735 IBE_UTIL.DEBUG('Notify_view_shared_cart:Create_adhoc_entity: done');
5736 END IF;
5737
5738 ELSE
5739 l_adhoc_role := 'HZ_PARTY:'||p_quote_access_rec.party_id;
5740 END IF;
5741
5742
5743 IF l_notif_Enabled = 'Y' THEN
5744 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5745 IBE_UTIL.DEBUG('Notify_view_shared_cart:sent_by_party_id: '||p_sent_by_party_id);
5746 IBE_UTIL.DEBUG('Notify_view_shared_cart:Calling get_name_details for the owner');
5747 IBE_UTIL.DEBUG('Notify_view_shared_cart:p_quote_access_rec.party_id '||p_quote_access_rec.party_id);
5748 END IF;
5749
5750 Get_Name_details(p_party_id => p_sent_by_party_id,
5751 p_user_type => FND_API.G_MISS_CHAR,
5752 x_contact_first_name => l_sent_by_first_name,
5753 x_contact_last_name => l_sent_by_last_name,
5754 x_party_id => l_sent_by_party_id);
5755
5756 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5757 IBE_UTIL.DEBUG('Notify_view_shared_cart:sent_by first name: '||l_sent_by_first_name);
5758 IBE_UTIL.DEBUG('Notify_view_shared_cart:sent_by last name: '||l_sent_by_last_name);
5759 END IF;
5760
5761 FOR rec_quote_name in c_quote_name(p_quote_access_rec.quote_header_id) LOOP
5762 l_quote_name := rec_quote_name.quote_name;
5763 EXIT when c_quote_name%NOTFOUND;
5764 END LOOP;
5765
5766 getusertype(p_quote_access_rec.party_id, l_user_type);
5767
5768 IF ((p_owner_party_id is not null ) AND
5769 (p_owner_party_id <> FND_API.G_MISS_NUM)) THEN
5770 l_url := p_url;
5771 l_access_code :='O';
5772 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5773 IBE_UTIL.DEBUG('Notify_view_shared_cart:l_access_code '||l_access_code);
5774 END IF;
5775 ELSE
5776 l_access_code := p_quote_access_rec.UPDATE_PRIVILEGE_TYPE_CODE;
5777 l_url := p_url;
5778 l_url := l_url|| p_quote_access_rec.quote_sharee_number;
5779 END IF;
5780
5781 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5782 IBE_UTIL.DEBUG('Notify_view_shared_cart:quote name: '||l_quote_name);
5783 IBE_UTIL.DEBUG('Notify_view_shared_cart:retrieving message mapping');
5784 END IF;
5785
5786 l_org_Id := MO_GLOBAL.get_current_org_id();
5787 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
5788 (
5789 p_org_id => l_Org_Id,
5790 p_msite_id => p_minisite_id,
5791 p_user_type => l_user_Type,
5792 p_notif_name => l_notif_Name,
5793 x_enabled_flag => l_msg_Enabled,
5794 x_wf_message_name => l_msg_name,
5795 x_return_status => x_return_status,
5796 x_msg_data => x_msg_data,
5797 x_msg_count => x_msg_data);
5798
5799 IF x_msg_count > 0 Then
5800 Raise GET_MESSAGE_ERROR;
5801 END IF;
5802 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5803 ibe_util.debug('Message Name: '||l_msg_name||' Enabled: '||l_msg_Enabled);
5804 END IF;
5805
5806 IF l_msg_Enabled = 'Y' THEN
5807 IF (p_quote_access_rec.Quote_sharee_number is not null AND
5808 p_quote_access_rec.Quote_sharee_number <> FND_API.G_MISS_NUM) THEN
5809 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_access_rec.Quote_Header_id
5810 ||p_quote_access_rec.Quote_sharee_number;
5811 ELSE
5812 l_item_key := l_event_type||'-'||to_char(sysdate,'MMDDYYHH24MISS')||'-'||p_quote_access_rec.Quote_Header_id;
5813 END IF;
5814
5815 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
5816
5817 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5818 ibe_util.debug('view_shared_cart:item_key: '||l_item_key);
5819 ibe_util.debug('ready to create process');
5820 END IF;
5821
5822 wf_engine.CreateProcess(
5823 itemtype => g_ItemType,
5824 itemkey => l_item_key,
5825 process => g_processName);
5826
5827 wf_engine.SetItemUserKey(
5828 itemtype => g_ItemType,
5829 itemkey => l_item_key,
5830 userkey => l_item_key);
5831
5832 wf_engine.SetItemAttrText(
5833 itemtype => g_ItemType,
5834 itemkey => l_item_key,
5835 aname => 'MESSAGE',
5836 avalue => l_msg_name);
5837
5838 wf_engine.SetItemAttrText(
5839 itemtype => g_ItemType,
5840 itemkey => l_item_key,
5841 aname => 'SENTBYFIRSTNAME',
5842 avalue => l_sent_by_first_name);
5843
5844 wf_engine.SetItemAttrText(
5845 itemtype => g_ItemType,
5846 itemkey => l_item_key,
5847 aname => 'SENTBYLASTNAME',
5848 avalue => l_sent_by_last_name);
5849
5850 wf_engine.SetItemAttrText(
5851 itemtype => g_ItemType,
5852 itemkey => l_item_key,
5853 aname => 'FIRSTNAME',
5854 avalue => l_owner_first_name);
5855
5856 wf_engine.SetItemAttrText(
5857 itemtype => g_ItemType,
5858 itemkey => l_item_key,
5859 aname => 'LASTNAME',
5860 avalue => l_owner_last_name);
5861
5862
5863 wf_engine.SetItemAttrText(
5864 itemtype => g_ItemType,
5865 itemkey => l_item_key,
5866 aname => 'CARTNAME',
5867 avalue => l_quote_name);
5868
5869 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5870 IBE_UTIL.DEBUG('Notify_view_shared_cart:ACCESSCODE: '||p_quote_access_rec.UPDATE_PRIVILEGE_TYPE_CODE);
5871 END IF;
5872 wf_engine.SetItemAttrText(
5873 itemtype => g_ItemType,
5874 itemkey => l_item_key,
5875 aname => 'ACCESSCODE',
5876 avalue => l_access_code);
5877
5878 wf_engine.SetItemAttrText(
5879 itemtype => g_ItemType,
5880 itemkey => l_item_key,
5881 aname => 'ISTOREURL',
5882 avalue => L_url);
5883
5884 wf_engine.SetItemAttrText(
5885 itemtype => g_ItemType,
5886 itemkey => l_item_key,
5887 aname => 'DATE_ITEMKEY',
5888 avalue => l_item_key);
5889
5890 wf_engine.SetItemAttrText(
5891 itemtype => g_ItemType,
5892 itemkey => l_item_key,
5893 aname => 'SHARECOMMENTS',
5894 avalue => p_notes);
5895
5896 wf_engine.SetItemAttrText(
5897 itemtype => g_ItemType,
5898 itemkey => l_item_key,
5899 aname => 'MSITEID',
5900 avalue => p_minisite_id);
5901
5902 wf_engine.SetItemAttrText(
5903 itemtype => g_ItemType,
5904 itemkey => l_item_key,
5905 aname => 'UPDATEMSG_CODE',
5906 avalue => 'IBE_PRMT_UPDATE_CART');
5907
5908 wf_engine.SetItemAttrText(
5909 itemtype => g_ItemType,
5910 itemkey => l_item_key,
5911 aname => 'SENDTO',
5912 avalue => l_adhoc_role);
5913
5914 wf_engine.SetItemOwner(
5915 itemtype => g_ItemType,
5916 itemkey => l_item_key,
5917 owner => l_item_owner);
5918
5919 wf_engine.StartProcess(
5920 itemtype => g_ItemType,
5921 itemkey => l_item_key);
5922
5923 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
5924 IBE_UTIL.DEBUG('Process Started');
5925 END IF;
5926
5927 END IF;
5928 END IF;
5929 EXCEPTION
5930
5931 WHEN OTHERS THEN
5932 x_return_status := FND_API.g_ret_sts_error;
5933 x_msg_count := 0;
5934 --wf_core.context('IBE_WORKFLOW_PVT',l_notifName,l_notifName);
5935 RAISE;
5936
5937 END;
5938
5939
5940 ------------------------------------------------------------------------
5941
5942 PROCEDURE NotifyForSharedCart (
5943 p_api_version IN NUMBER,
5944 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
5945 p_Quote_Header_id IN NUMBER,
5946 p_emailAddress IN VARCHAR2,
5947 p_quoteShareeNum IN NUMBER,
5948 p_privilegeType IN VARCHAR2,
5949 p_url IN VARCHAR2,
5950 p_comments IN VARCHAR2 := FND_API.G_MISS_CHAR,
5951 x_return_status OUT NOCOPY VARCHAR2,
5952 x_msg_count OUT NOCOPY NUMBER,
5953 x_msg_data OUT NOCOPY VARCHAR2
5954 ) IS
5955
5956
5957 BEGIN
5958
5959 NotifyForSharedCart (
5960 p_api_version,
5961 p_init_msg_list,
5962 null,
5963 p_Quote_Header_id,
5964 p_emailAddress,
5965 p_quoteShareeNum,
5966 p_privilegeType,
5967 p_url,
5968 p_comments,
5969 x_return_status,
5970 x_msg_count,
5971 x_msg_data);
5972
5973
5974 End NotifyForSharedCart;
5975
5976
5977 PROCEDURE NotifyForSharedCart (
5978 p_api_version IN NUMBER,
5979 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
5980 p_Msite_id IN NUMBER,
5981 p_Quote_Header_id IN NUMBER,
5982 p_emailAddress IN VARCHAR2,
5983 p_quoteShareeNum IN NUMBER,
5984 p_privilegeType IN VARCHAR2,
5985 p_url IN VARCHAR2,
5986 p_comments IN VARCHAR2 := FND_API.G_MISS_CHAR,
5987 x_return_status OUT NOCOPY VARCHAR2,
5988 x_msg_count OUT NOCOPY NUMBER,
5989 x_msg_data OUT NOCOPY VARCHAR2
5990 ) IS
5991
5992 l_event_type Varchar2(30) := 'SHAREDCART';
5993 l_notifEnabled Varchar2(3) := 'Y';
5994 l_notifName Varchar2(30) := 'SHAREDCART';
5995 l_OrgId Number := null;
5996 l_UserType jtf_um_usertypes_b.usertype_key%type := 'ALL';
5997 l_messageName WF_MESSAGES.NAME%TYPE;
5998 l_msgEnabled VARCHAR2(3) :='Y';
5999 l_partyid Number;
6000 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
6001 l_item_owner WF_USERS.NAME%TYPE := 'SYSADMIN';
6002 l_user_name WF_USERS.NAME%TYPE;
6003 l_role_users Varchar2(200);
6004 l_adhoc_role WF_ROLES.NAME%TYPE;
6005 l_adhoc_role_display WF_ROLES.DISPLAY_NAME%TYPE;
6006 l_adhoc_user WF_USERS.NAME%TYPE;
6007 l_adhoc_user_display WF_USERS.DISPLAY_NAME%TYPE;
6008 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
6009 l_quote_name Varchar2(50);
6010 l_quote_Num Number;
6011 l_quote_ver Number;
6012 l_quote_password Varchar2(240);
6013
6014 --2299210
6015 l_first_name_sc VARCHAR2(360) := 'Firstname';
6016 l_last_name_sc VARCHAR2(360);
6017 l_dummy_document_type VARCHAR2(200);
6018
6019 BEGIN
6020 x_return_status := FND_API.g_ret_sts_success;
6021
6022 -- Check for WorkFlow Feature Availablity.
6023 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6024 ibe_util.debug('Check if this notification is enabled.');
6025 END IF;
6026 l_notifEnabled := IBE_WF_NOTIF_SETUP_PVT.Check_Notif_Enabled(l_notifName);
6027 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6028 ibe_util.debug('Notification Name: '||l_notifName||' Enabled: '||l_notifEnabled);
6029 END IF;
6030 If l_notifEnabled = 'Y' Then
6031 FOR c_quote_rec In c_quote_header(p_Quote_Header_id) LOOP
6032 l_user_name :='HZ_PARTY:'||c_quote_rec.party_id;
6033 l_orgid := c_quote_rec.org_id;
6034 l_quote_name := c_quote_rec.quote_name;
6035 l_partyId := c_quote_rec.party_id;
6036 l_quote_password := c_quote_rec.quote_password;
6037 l_quote_num := c_quote_rec.quote_number;
6038 l_quote_ver := c_quote_rec.quote_version;
6039 END LOOP;
6040 --2299210
6041 GetFirstName (p_Quote_Header_id,
6042 null,
6043 l_first_name_sc,
6044 l_dummy_document_type);
6045
6046 GetLastName (p_Quote_Header_id, null,
6047 l_last_name_sc,
6048 l_dummy_document_type);
6049 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6050 ibe_util.debug('Sharee First Name: '||nvl(l_first_name_sc,'noname'));
6051 ibe_util.debug('Sharee Last Name: '||l_last_name_sc);
6052 END IF;
6053
6054 getUserType(l_partyId,l_UserType);
6055 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6056 ibe_util.debug('Get Message - MsiteId: '||to_Char(p_msite_id)||' Org_id: '||to_char(l_orgId)
6057 ||' User Type: '||l_userType);
6058 END IF;
6059 IBE_WF_MSG_MAPPING_PVT.Retrieve_Msg_Mapping
6060 (
6061 p_org_id => l_OrgId,
6062 p_msite_id => p_msite_id,
6063 p_user_type => l_userType,
6064 p_notif_name => l_notifName,
6065 x_enabled_flag => l_msgEnabled,
6066 x_wf_message_name => l_MessageName,
6067 x_return_status => x_return_status,
6068 x_msg_data => x_msg_data,
6069 x_msg_count => x_msg_data);
6070
6071 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6072 ibe_util.debug('Message Name: '||l_MessageName||' Enabled: '||l_msgEnabled);
6073 END IF;
6074 If x_msg_count > 0 Then
6075 Raise GET_MESSAGE_ERROR;
6076 End if;
6077
6078 if l_msgEnabled = 'Y' Then
6079 l_item_key := l_event_type||'-'||p_quoteShareeNum||'-'||p_Quote_Header_id;
6080 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
6081 If p_emailaddress is not null Then
6082 l_adhoc_user := 'SCU'||p_quoteShareeNum||'Q'||p_Quote_Header_id ;
6083 l_adhoc_user_display := 'SCU'||p_quoteShareeNum||'Q'||p_Quote_Header_id;
6084 wf_directory.CreateAdHocUser(
6085 name => l_adhoc_user,
6086 display_name => l_adhoc_user_display,
6087 notification_preference => l_notification_preference,
6088 email_address => p_emailAddress,
6089 expiration_date => sysdate + 1);
6090
6091 --l_user_name :='HZ_PARTY:'||c_quote_rec.party_id;
6092 --l_adhoc_user := 'SCU'||p_quoteShareeNum||'Q'||p_Quote_Header_id ;
6093 l_role_users := l_user_name||','||l_adhoc_user;
6094 l_adhoc_role := 'SCR'||p_quoteShareeNum||'Q'||p_Quote_Header_id;
6095 l_adhoc_role_display := 'SCR'||p_quoteShareeNum||'Q'||p_Quote_Header_id;
6096 wf_directory.CreateAdHocRole
6097 (role_name => l_adhoc_role,
6098 role_display_name => l_adhoc_role_display,
6099 notification_preference => l_notification_preference,
6100 role_users => l_role_users,
6101 expiration_date => sysdate + 1);
6102 Else
6103 l_adhoc_role := l_user_name;
6104 End If;
6105
6106
6107 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6108 ibe_util.debug('Create and Start Process with Item Key: '||l_item_key);
6109 END IF;
6110
6111 wf_engine.CreateProcess(
6112 itemtype => g_ItemType,
6113 itemkey => l_item_key,
6114 process => g_processName);
6115
6116 wf_engine.SetItemUserKey(
6117 itemtype => g_ItemType,
6118 itemkey => l_item_key,
6119 userkey => l_item_key);
6120
6121 wf_engine.SetItemAttrText(
6122 itemtype => g_ItemType,
6123 itemkey => l_item_key,
6124 aname => 'MESSAGE',
6125 avalue => l_MessageName);
6126
6127 wf_engine.SetItemAttrText(
6128 itemtype => g_ItemType,
6129 itemkey => l_item_key,
6130 aname => 'PASSWORD',
6131 avalue => l_quote_password);
6132
6133
6134 wf_engine.SetItemAttrNumber(
6135 itemtype => g_ItemType,
6136 itemkey => l_item_key,
6137 aname => 'QUOTEID',
6138 avalue => p_Quote_Header_id);
6139
6140
6141 wf_engine.SetItemAttrNumber(
6142 itemtype => g_ItemType,
6143 itemkey => l_item_key,
6144 aname => 'QUOTENUM',
6145 avalue => l_quote_num);
6146
6147 wf_engine.SetItemAttrNumber(
6148 itemtype => g_ItemType,
6149 itemkey => l_item_key,
6150 aname => 'QUOTEVER',
6151 avalue => l_quote_ver);
6152
6153 wf_engine.SetItemAttrNumber(
6154 itemtype => g_ItemType,
6155 itemkey => l_item_key,
6156 aname => 'SHNUM',
6157 avalue => p_quoteShareeNum);
6158
6159
6160 wf_engine.SetItemAttrText(
6161 itemtype => g_ItemType,
6162 itemkey => l_item_key,
6163 aname => 'QUOTENAME',
6164 avalue => l_quote_name);
6165
6166 wf_engine.SetItemAttrText(
6167 itemtype => g_ItemType,
6168 itemkey => l_item_key,
6169 aname => 'ISTOREURL',
6170 avalue => p_url);
6171
6172 wf_engine.SetItemAttrText(
6173 itemtype => g_ItemType,
6174 itemkey => l_item_key,
6175 aname => 'COMMENTS',
6176 avalue => p_Comments);
6177
6178 --2299210
6179 wf_engine.SetItemAttrText(
6180 itemtype => g_ItemType,
6181 itemkey => l_item_key,
6182 aname => 'FIRSTNAME',
6183 avalue => l_first_name_sc);
6184
6185 wf_engine.SetItemAttrText(
6186 itemtype => g_ItemType,
6187 itemkey => l_item_key,
6188 aname => 'LASTNAME',
6189 avalue => l_last_name_sc);
6190
6191 wf_engine.SetItemAttrText(
6192 itemtype => g_ItemType,
6193 itemkey => l_item_key,
6194 aname => 'MSITEID',
6195 avalue => p_msite_id);
6196
6197 wf_engine.SetItemAttrText(
6198 itemtype => g_ItemType,
6199 itemkey => l_item_key,
6200 aname => 'SENDTO',
6201 avalue => l_adhoc_role);
6202
6203
6204 wf_engine.SetItemOwner(
6205 itemtype => g_ItemType,
6206 itemkey => l_item_key,
6207 owner => l_item_owner);
6208
6209 wf_engine.StartProcess(
6210 itemtype => g_ItemType,
6211 itemkey => l_item_key);
6212
6213 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6214 ibe_util.debug('Process Started');
6215 END IF;
6216
6217 End If;
6218 End If;
6219 Exception
6220
6221 When OTHERS Then
6222 x_return_status := FND_API.g_ret_sts_error;
6223 x_msg_count := 0;
6224 wf_core.context('ibe_workflow_pvt','SHAREDCART','SHAREDCART');
6225 raise;
6226 End NotifyForSharedCart;
6227
6228
6229
6230 PROCEDURE ParseThisString (
6231 p_string_in IN VARCHAR2,
6232 p_string_out OUT NOCOPY VARCHAR2,
6233 p_string_left OUT NOCOPY VARCHAR2
6234 ) IS
6235
6236 l_lengthy_word BOOLEAN;
6237 l_line_length NUMBER;
6238 l_length NUMBER;
6239 l_lim NUMBER;
6240 i NUMBER;
6241 j NUMBER;
6242 l_pos NUMBER;
6243
6244 BEGIN
6245 l_line_length := 20;
6246 l_length := length(p_string_in);
6247 IF ( l_length < l_line_length ) THEN
6248 p_string_out := rpad(p_string_in,20,' ');
6249 p_string_left := '';
6250 ELSE
6251 l_lim := l_line_length;
6252 p_string_out := '';
6253 i := 1;
6254 j := 1;
6255 l_pos := 0;
6256
6257 WHILE i <= l_lim LOOP
6258 j := instr(p_string_in,' ',i);
6259 IF( (j=0) AND (i=1) ) THEN
6260 l_pos := 18;
6261 l_lengthy_word := true;
6262 END IF;
6263 IF ( j <> 0 ) THEN
6264 i := j+1;
6265 l_pos := j;
6266 END IF;
6267 EXIT WHEN j = 0;
6268 END LOOP;
6269 p_string_out := substr(p_string_in,1,l_pos);
6270 IF ( l_lengthy_word = true ) THEN
6271 l_lengthy_word := false;
6272 p_string_out := p_string_out || '-';
6273 END IF;
6274 IF (length(p_string_out) < 20 ) THEN
6275 p_string_out := rpad(p_string_out,20,' ');
6276 END IF;
6277 p_string_left := substr(p_string_in,l_pos+1,length(p_string_in)-l_pos);
6278 END IF;
6279 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6280 ibe_util.debug('ParseThisString - p_string_out - '||p_string_out);
6281 ibe_util.debug('ParseThisString - p_string_left - '||p_string_left);
6282 END IF;
6283 END ParseThisString;
6284
6285 PROCEDURE ParseThisString1 (
6286 p_string_in IN VARCHAR2,
6287 p_string_out OUT NOCOPY VARCHAR2,
6288 p_string_left OUT NOCOPY VARCHAR2
6289 ) IS
6290
6291 l_lengthy_word BOOLEAN;
6292 l_line_length NUMBER;
6293 l_length NUMBER;
6294 l_lim NUMBER;
6295 i NUMBER;
6296 j NUMBER;
6297 l_pos NUMBER;
6298
6299 BEGIN
6300 l_line_length := 10;
6301 l_length := length(p_string_in);
6302 IF ( l_length < l_line_length ) THEN
6303 p_string_out := rpad(p_string_in,12,' ');
6304 p_string_left := '';
6305 ELSE
6306 l_lim := l_line_length;
6307 p_string_out := '';
6308 i := 1;
6309 j := 1;
6310 l_pos := 0;
6311
6312 WHILE i <= l_lim LOOP
6313 j := instr(p_string_in,' ',i);
6314 IF( (j=0) AND (i=1) ) THEN
6315 l_pos := 8;
6316 l_lengthy_word := true;
6317 END IF;
6318 IF ( j <> 0 ) THEN
6319 i := j+1;
6320 l_pos := j;
6321 END IF;
6322 EXIT WHEN j = 0;
6323 END LOOP;
6324 p_string_out := substr(p_string_in,1,l_pos);
6325 IF ( l_lengthy_word = true ) THEN
6326 l_lengthy_word := false;
6327 p_string_out := p_string_out || '-';
6328 END IF;
6329 IF (length(p_string_out) < 12 ) THEN
6330 p_string_out := rpad(p_string_out,12,' ');
6331 END IF;
6332 p_string_left := substr(p_string_in,l_pos+1,length(p_string_in)-l_pos);
6333 END IF;
6334
6335 END ParseThisString1;
6336
6337
6338
6339 FUNCTION AddSpaces (
6340 p_num_in IN NUMBER
6341 ) RETURN VARCHAR2
6342 IS
6343 l_str_out varchar2(200);
6344 BEGIN
6345 l_str_out := rpad(' ',p_num_in,' ');
6346 return l_str_out;
6347 END AddSpaces;
6348
6349 PROCEDURE GenerateHeader(
6350 document_id IN VARCHAR2,
6351 display_type IN VARCHAR2,
6352 document IN OUT NOCOPY VARCHAR2,
6353 document_type IN OUT NOCOPY VARCHAR2
6354 )IS
6355
6356 l_item_type wf_items.item_type%TYPE;
6357 l_item_key wf_items.item_key%TYPE;
6358 l_quote_id NUMBER;
6359 l_event_type VARCHAR2(20);
6360 l_document VARCHAR2(32000) := '';
6361 l_party_first_name hz_parties.person_first_name%TYPE;
6362 l_party_last_name hz_parties.person_last_name%TYPE;
6363 l_temp_str VARCHAR2(2000):='';
6364 l_errmsg_data VARCHAR2(2000):='';
6365 l_order_id NUMBER;
6366 l_Ship_Method Varchar2(80);
6367 l_view_net_price_flag VARCHAR2(1);
6368 l_user_type jtf_um_usertypes_b.usertype_key%type;
6369 l_notif_name VARCHAR2(20);
6370
6371
6372
6373 BEGIN
6374 l_item_key := document_id;
6375 ----DBMS_OUTPUT.PUT('Item key in generateHeader is: '||l_item_key);
6376
6377 l_event_type := wf_engine.GetItemAttrText (
6378 itemtype => g_itemType,
6379 itemkey => l_item_key,
6380 aname => 'EVENTTYPE'
6381 );
6382
6383
6384 IF l_event_type <> 'RETURNORDER' THEN
6385
6386 l_quote_id := wf_engine.GetItemAttrText (
6387 itemtype => g_itemType,
6388 itemkey => l_item_key,
6389 aname => 'QUOTEID'
6390 );
6391
6392 l_errmsg_data := wf_engine.GetItemAttrText (
6393 itemtype => g_itemType,
6394 itemkey => l_item_key,
6395 aname => 'ERRMSG'
6396 );
6397
6398 END IF;
6399
6400
6401 l_order_id := wf_engine.GetItemAttrText (
6402 itemtype => g_itemType,
6403 itemkey => l_item_key,
6404 aname => 'ORDERID'
6405 );
6406
6407
6408 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6409 ibe_util.debug('GenerateHeader - l_event_type -'|| l_event_type);
6410 END IF;
6411
6412 OPEN c_order_header(l_order_id);
6413 LOOP
6414 FETCH c_order_header INTO g_header_rec;
6415 EXIT WHEN c_order_header%NOTFOUND;
6416
6417 l_party_first_name := null;
6418 l_party_last_name := null;
6419
6420 l_party_first_name:= wf_engine.GetItemAttrText (
6421 itemtype => g_itemType,
6422 itemkey => l_item_key,
6423 aname => 'FIRSTNAME'
6424 );
6425
6426 l_party_last_name:= wf_engine.GetItemAttrText (
6427 itemtype => g_itemType,
6428 itemkey => l_item_key,
6429 aname => 'LASTNAME'
6430 );
6431
6432 IF l_event_type <> 'RETURNORDER' THEN
6433 For c_ship_method_rec in c_ship_methods(g_header_rec.shipping_method_code)
6434 LOOP
6435 l_Ship_Method := c_ship_method_rec.Meaning;
6436 END LOOP;
6437 END IF;
6438
6439 IF ( l_event_type = 'ORDFAX' OR l_event_type = 'ORDCONF' OR l_event_type = 'CNCLORDR' OR l_event_type = 'RETURNORDER') THEN
6440 -- IF (display_type = 'text/plain' ) THEN
6441 fnd_message.set_name('IBE','IBE_PRMT_ORDER_NO_COLON');
6442 l_temp_str := null;
6443 l_temp_str := fnd_message.get;
6444 l_document := l_document || l_temp_str ||TAB||TAB||TAB||g_header_rec.order_number||NEWLINE;
6445 fnd_message.set_name('IBE','IBE_PRMT_ORDER_DATE_COLON');
6446 l_temp_str := null;
6447 l_temp_str := fnd_message.get;
6448 l_document := l_document || l_temp_str ||TAB||TAB||TAB||g_header_rec.ordered_date||NEWLINE;
6449 IF l_event_type <> 'RETURNORDER' THEN
6450 fnd_message.set_name('IBE','IBE_PRMT_SHIP_METH_COLON');
6451 l_temp_str := null;
6452 l_temp_str := fnd_message.get;
6453 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_Ship_Method||NEWLINE;
6454 END IF;
6455 -- Need to get the user type. For individual users, show address, for others skip.
6456 l_user_type := wf_engine.GetItemAttrText (
6457 itemtype => g_itemType,
6458 itemkey => l_item_key,
6459 aname => 'STOREUSERTYPE'
6460 );
6461 IF ((l_user_type = 'IBE_INDIVIDUAL'and l_event_type = 'RETURNORDER') or (l_event_type <> 'RETURNORDER')) THEN
6462 IF (l_event_type <> 'RETURNORDER') THEN
6463 fnd_message.set_name('IBE','IBE_PRMT_SHIP_INFO_COLON');
6464 l_temp_str := null;
6465 l_temp_str := fnd_message.get;
6466
6467 l_document := l_document || l_temp_str ||TAB||TAB||l_party_first_name||' '||l_party_last_name||NEWLINE;
6468 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_address1||NEWLINE;
6469 IF ( rtrim(g_header_rec.ship_to_address2) IS NOT NULL ) THEN
6470 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_address2||NEWLINE;
6471 END IF;
6472 IF ( rtrim(g_header_rec.ship_to_address3) IS NOT NULL ) THEN
6473 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_address3||NEWLINE;
6474 END IF;
6475 IF ( rtrim(g_header_rec.ship_to_address4) IS NOT NULL ) THEN
6476 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_address4||NEWLINE;
6477 END IF;
6478 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_city||',';
6479 l_document := l_document || g_header_rec.ship_to_state||' ';
6480 l_document := l_document || g_header_rec.ship_to_postal_code||NEWLINE;
6481 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_country;
6482
6483 ELSE ---3334542
6484 fnd_message.set_name('IBE','IBE_EOS_BILLING_ADDRESS_COLON');
6485 l_temp_str := null;
6486 l_temp_str := fnd_message.get;
6487
6488 l_document := l_document || l_temp_str ||TAB||TAB||l_party_first_name||' '||l_party_last_name||NEWLINE;
6489 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.bill_to_address1||NEWLINE;
6490 IF ( rtrim(g_header_rec.bill_to_address2) IS NOT NULL ) THEN
6491 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.bill_to_address2||NEWLINE;
6492 END IF;
6493 IF ( rtrim(g_header_rec.bill_to_address3) IS NOT NULL ) THEN
6494 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.bill_to_address3||NEWLINE;
6495 END IF;
6496 IF ( rtrim(g_header_rec.bill_to_address4) IS NOT NULL ) THEN
6497 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.bill_to_address4||NEWLINE;
6498 END IF;
6499 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.bill_to_city||',';
6500 l_document := l_document || g_header_rec.bill_to_state||' ';
6501 l_document := l_document || g_header_rec.bill_to_postal_code||NEWLINE;
6502 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.bill_to_country;
6503
6504 END IF;
6505
6506 END IF;
6507 --ELSE
6508 --null;
6509 --END IF;
6510 ELSIF ( l_event_type = 'ORDERROR') THEN
6511 -- IF (display_type = 'text/plain' ) THEN
6512 fnd_message.set_name('IBE','IBE_PRMT_ORDER_NO_COLON');
6513 l_temp_str := null;
6514 l_temp_str := fnd_message.get;
6515 l_document := l_document || l_temp_str||TAB||TAB||TAB||g_header_rec.order_number||NEWLINE;
6516 fnd_message.set_name('IBE','IBE_PRMT_OOE_NO_COLON');
6517 l_temp_str := null;
6518 l_temp_str := fnd_message.get;
6519 l_document := l_document|| l_temp_str ||TAB||TAB||TAB ||g_header_rec.order_number||NEWLINE;
6520 fnd_message.set_name('IBE','IBE_PRMT_COMPANY_NAME_COLON');
6521 l_temp_str := null;
6522 l_temp_str := fnd_message.get;
6523 l_document := l_document|| l_temp_str ||TAB||TAB ||g_header_rec.customer_name||NEWLINE;
6524 fnd_message.set_name('IBE','IBE_PRMT_NAME_COLON');
6525 l_temp_str := null;
6526 l_temp_str := fnd_message.get;
6527 l_document := l_document || l_temp_str||TAB||TAB||TAB ||l_party_first_name||' '||l_party_last_name||NEWLINE;
6528 fnd_message.set_name('IBE','IBE_PRMT_DATE_SUBMIT_COLON');
6529 l_temp_str := null;
6530 l_temp_str := fnd_message.get;
6531 l_document := l_document || l_temp_str||TAB||TAB ||g_header_rec.ordered_date||NEWLINE;
6532 -- Need to restrict the end user to view the net price.
6533
6534 l_view_net_price_flag := wf_engine.GetItemAttrText (
6535 itemtype => g_itemType,
6536 itemkey => l_item_key,
6537 aname => 'VIEWNETPRICE'
6538 );
6539
6540 IF l_view_net_price_flag = 'Y' THEN
6541 fnd_message.set_name('IBE','IBE_PRMT_ORDER_TOTAL_COLON');
6542 l_temp_str := null;
6543 l_temp_str := fnd_message.get;
6544 l_document := l_document|| l_temp_str ||TAB||TAB||to_char(g_header_rec.order_total)||NEWLINE;
6545 fnd_message.set_name('IBE','IBE_PRMT_PAY_METH_COLON');
6546 l_temp_str := null;
6547 l_temp_str := fnd_message.get;
6548 l_document := l_document|| l_temp_str ||TAB||TAB ||g_header_rec.payment_type_code||NEWLINE;
6549 END IF;
6550 fnd_message.set_name('IBE','IBE_PRMT_REASON_CODE_COLON');
6551 l_temp_str := null;
6552 l_temp_str := fnd_message.get;
6553 l_document := l_document || l_temp_str ||TAB||TAB || NEWLINE ;
6554 l_document := l_document ||TAB||TAB||TAB|| l_errmsg_data ||NEWLINE;
6555 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6556 ibe_util.debug('Error Message '|| l_errmsg_data);
6557 END IF;
6558 -- ELSE
6559 -- null;
6560 --END IF;
6561 END IF;
6562 END LOOP;
6563 CLOSE c_order_header;
6564
6565
6566
6567 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6568 ibe_util.debug('GenerateHeader - l_document - '||NEWLINE|| l_document);
6569 END IF;
6570 l_document := l_document||NEWLINE;
6571 document := l_document;
6572
6573
6574 IF(display_type = 'text/html') THEN
6575 document_type := 'text/html';
6576 ELSE
6577 document_type := 'text/plain';
6578 END IF;
6579
6580 EXCEPTION
6581 When Others Then
6582 IF c_order_header%ISOPEN THEN
6583 CLOSE c_order_header;
6584 END IF;
6585 Raise;
6586 END GenerateHeader;
6587
6588 PROCEDURE GenerateAssistHeader(
6589 document_id IN VARCHAR2,
6590 display_type IN VARCHAR2,
6591 document IN OUT NOCOPY VARCHAR2,
6592 document_type IN OUT NOCOPY VARCHAR2
6593 )
6594 IS
6595 l_item_type wf_items.item_type%TYPE;
6596 l_item_key wf_items.item_key%TYPE;
6597 l_quote_id NUMBER;
6598 l_event_type VARCHAR2(20);
6599 l_comments VARCHAR2(2000);
6600 l_party_first_name hz_parties.person_first_name%TYPE;
6601 l_party_last_name hz_parties.person_last_name%TYPE;
6602 l_contact_party_id hz_parties.party_id%TYPE;
6603 l_contact_name VARCHAR2(400);
6604 l_contact_number VARCHAR2(70);
6605 l_contact_email hz_contact_points.email_address%TYPE;
6606 l_contact_fax VARCHAR2(70);
6607 l_ship_address hz_locations.address1%TYPE;
6608 l_bill_address hz_locations.address1%TYPE;
6609 l_document VARCHAR2(32000) := '';
6610 l_temp_str VARCHAR2(2000):='';
6611 l_order_id NUMBER;
6612
6613 l_ship_method Varchar2(80);
6614
6615 Cursor c_b2b_contact(pOrder Number) IS
6616 Select p.party_id Person_Party_id,
6617 l.party_id contact_party_id,
6618 p.person_first_name,
6619 p.person_last_name,
6620 p.party_type
6621 from oe_order_headers_all o,
6622 hz_cust_Account_roles r,
6623 hz_relationships l,
6624 hz_parties p
6625 where o.header_id = pOrder
6626 and o.sold_to_contact_id = r.cust_account_role_id
6627 and r.party_id = l.party_id
6628 and l.subject_id = p.party_id
6629 and l.subject_type = 'PERSON'
6630 and l.object_type = 'ORGANIZATION';
6631
6632
6633 BEGIN
6634
6635 l_item_key := document_id;
6636
6637 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6638 ibe_util.debug('GenerateAssistHeader - l_item_key - '||l_item_key);
6639 END IF;
6640
6641 l_quote_id := wf_engine.GetItemAttrText (
6642 itemtype => g_itemType,
6643 itemkey => l_item_key,
6644 aname => 'QUOTEID');
6645
6646 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6647 ibe_util.debug('GenerateAssistHeader - l_quote_id - '||l_quote_id);
6648 END IF;
6649
6650 l_order_id := wf_engine.GetItemAttrText (
6651 itemtype => g_itemType,
6652 itemkey => l_item_key,
6653 aname => 'ORDERID');
6654
6655 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6656 ibe_util.debug('GenerateHeader - l_order_id - '||l_order_id);
6657 END IF;
6658
6659 l_event_type := wf_engine.GetItemAttrText (
6660 itemtype => g_itemType,
6661 itemkey => l_item_key,
6662 aname => 'EVENTTYPE');
6663
6664 l_comments := wf_engine.GetItemAttrText (
6665 itemtype => g_itemType,
6666 itemkey => l_item_key,
6667 aname => 'COMMENTS');
6668
6669 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6670 ibe_util.debug('GenerateAssistHeader - l_event_type - '|| l_event_type);
6671 ibe_util.debug('GenerateAssistHeader - l_event_type -'|| l_event_type);
6672 END IF;
6673
6674 OPEN c_order_header(l_order_id);
6675 LOOP
6676 FETCH c_order_header INTO g_header_rec;
6677 EXIT WHEN c_order_header%NOTFOUND;
6678
6679 l_party_first_name := null;
6680 l_party_last_name := null;
6681 l_contact_name := null;
6682
6683 FOR c_hz_parties_rec IN c_hz_parties(g_header_rec.party_id) LOOP
6684 If c_hz_parties_rec.Party_type = 'ORGANIZATION' Then
6685 For c_b2b_contact_rec in c_b2b_contact(l_order_id) Loop
6686 l_party_first_name := upper(rtrim(c_b2b_contact_rec.person_first_name));
6687 l_party_last_name := upper(rtrim(c_b2b_contact_rec.person_last_name));
6688 l_contact_name := l_party_first_name||' '||l_party_last_name;
6689 l_contact_party_id := c_b2b_contact_rec.contact_party_id;
6690 End Loop;
6691 Else
6692 l_party_first_name := upper(rtrim(c_hz_parties_rec.person_first_name));
6693 l_party_last_name := upper(rtrim(c_hz_parties_rec.person_last_name));
6694 l_contact_name := l_party_first_name||' '||l_party_last_name;
6695 l_contact_party_id := g_header_rec.party_id;
6696 End If;
6697 END LOOP;
6698
6699 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6700 ibe_util.debug('GenerateAssistHeader - l_contact_name '|| l_contact_name);
6701 END IF;
6702
6703 l_contact_number := NULL;
6704 l_contact_email := NULL;
6705 l_contact_fax := NULL;
6706
6707 FOR c_hz_contact_rec IN c_hz_contact_points(l_contact_party_id) LOOP
6708
6709 If (c_hz_contact_rec.contact_point_type = 'PHONE' AND c_hz_contact_rec.phone_line_type = 'GEN')
6710 AND (l_contact_number IS NULL OR c_hz_contact_rec.primary_flag ='Y')
6711 Then
6712
6713 l_contact_number := trim(c_hz_contact_rec.Phone_Country_code||' '||c_hz_contact_rec.Phone_area_code||' '||c_hz_contact_rec.Phone_number);
6714
6715 Elsif c_hz_contact_rec.contact_point_type = 'EMAIL' AND (l_contact_email IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
6716
6717 l_contact_email := c_hz_contact_rec.email_address;
6718
6719 Elsif (c_hz_contact_rec.contact_point_type = 'PHONE' AND c_hz_contact_rec.phone_line_type = 'FAX') AND (l_contact_fax IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
6720
6721 l_contact_fax := trim(c_hz_contact_rec.Phone_Country_code||' '||c_hz_contact_rec.Phone_area_code||' '||c_hz_contact_rec.Phone_number);
6722
6723 End If;
6724
6725 END LOOP;
6726
6727 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6728 ibe_util.debug('GenerateAssistHeader - l_contact_number - '|| l_contact_number);
6729 END IF;
6730
6731 l_ship_address := rtrim(g_header_rec.ship_to_address1) ||' '||rtrim(g_header_rec.ship_to_address2) ||' '||
6732 rtrim(g_header_rec.ship_to_address3) ||' '||rtrim(g_header_rec.ship_to_address4) ;
6733
6734 l_bill_address := rtrim(g_header_rec.bill_to_address1) ||' '||rtrim(g_header_rec.bill_to_address2) ||' '||
6735 rtrim(g_header_rec.bill_to_address3) ||' '||rtrim(g_header_rec.bill_to_address4) ;
6736
6737 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6738 ibe_util.debug('GenerateAssistHeader - l_bill_address - '|| l_bill_address);
6739 ibe_util.debug('GenerateAssistHeader - l_ship_address - '|| l_ship_address);
6740 END IF;
6741
6742 For c_ship_method_rec in c_ship_methods(g_header_rec.shipping_method_code) LOOP
6743 l_Ship_Method := c_ship_method_rec.Meaning;
6744 End Loop;
6745
6746 IF ( l_event_type = 'CUSTASSIST' ) THEN
6747 --IF ( display_type = 'text/plain' ) THEN
6748 fnd_message.set_name('IBE','IBE_PRMT_CUST_CNTCT_INFO');
6749 l_temp_str := null;
6750 l_temp_str := fnd_message.get;
6751 l_document := l_document || NEWLINE ||l_temp_str ||NEWLINE||NEWLINE;
6752
6753 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NAME_COL');
6754 l_temp_str := null;
6755 l_temp_str := fnd_message.get;
6756 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_contact_name||NEWLINE;
6757
6758 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NUM_COL');
6759 l_temp_str := null;
6760 l_temp_str := fnd_message.get;
6761 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_contact_number||NEWLINE;
6762
6763 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_EMAIL_COL');
6764 l_temp_str := null;
6765 l_temp_str := fnd_message.get;
6766 l_document := l_document || l_temp_str ||TAB||TAB||l_contact_email||NEWLINE;
6767
6768 fnd_message.set_name('IBE','IBE_PRMT_COMMENTS_COL');
6769 l_temp_str := null;
6770 l_temp_str := fnd_message.get;
6771 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_comments ||NEWLINE||NEWLINE;
6772
6773 fnd_message.set_name('IBE','IBE_PRMT_ORDER_NO_COLON');
6774 l_temp_str := null;
6775 l_temp_str := fnd_message.get;
6776 l_document := l_document || l_temp_str ||TAB||TAB||TAB||g_header_rec.order_number||NEWLINE;
6777
6778 fnd_message.set_name('IBE','IBE_PRMT_ORDER_DATE_COLON');
6779 l_temp_str := null;
6780 l_temp_str := fnd_message.get;
6781 l_document := l_document || l_temp_str ||TAB||TAB||TAB||g_header_rec.ordered_date||NEWLINE||NEWLINE;
6782
6783 fnd_message.set_name('IBE','IBE_PRMT_SHIP_METH_COLON');
6784 l_temp_str := null;
6785 l_temp_str := fnd_message.get;
6786 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_ship_method||NEWLINE;
6787
6788 fnd_message.set_name('IBE','IBE_PRMT_CUST_NAME_COLON');
6789 l_temp_str := null;
6790 l_temp_str := fnd_message.get;
6791 l_document := l_document || l_temp_str ||TAB||TAB||TAB||g_header_rec.customer_name||NEWLINE;
6792 l_document := l_document || TAB||TAB||TAB||TAB||l_ship_address||NEWLINE;
6793 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_city||NEWLINE;
6794 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_state||' ';
6795 l_document := l_document || g_header_rec.ship_to_postal_code||NEWLINE;
6796 l_document := l_document || TAB||TAB||TAB||TAB||g_header_rec.ship_to_country||NEWLINE;
6797 --ELSE
6798 --null;
6799 --END IF;
6800 ELSIF ( l_event_type = 'SALESASSIST' ) THEN
6801 --IF (display_type = 'text/plain' ) THEN
6802 fnd_message.set_name('IBE','IBE_PRMT_ORDER_NO_COLON');
6803 l_temp_str := null;
6804 l_temp_str := fnd_message.get;
6805 l_document := l_document || l_temp_str ||TAB||TAB||g_header_rec.order_number||NEWLINE;
6806
6807 fnd_message.set_name('IBE','IBE_PRMT_OOE_NO_COLON');
6808 l_temp_str := null;
6809 l_temp_str := fnd_message.get;
6810 l_document := l_document|| l_temp_str ||TAB||TAB||TAB ||g_header_rec.order_number||NEWLINE;
6811
6812 fnd_message.set_name('IBE','IBE_PRMT_ORDER_DATE_COLON');
6813 l_temp_str := null;
6814 l_temp_str := fnd_message.get;
6815 l_document := l_document || l_temp_str ||TAB||TAB||g_header_rec.ordered_date||NEWLINE;
6816
6817 fnd_message.set_name('IBE','IBE_PRMT_SHIP_METH_COLON');
6818 l_temp_str := null;
6819 l_temp_str := fnd_message.get;
6820 l_document := l_document || l_temp_str||TAB||TAB||l_ship_method||NEWLINE;
6821
6822 fnd_message.set_name('IBE','IBE_PRMT_CUST_CNTCT_INFO');
6823 l_temp_str := null;
6824 l_temp_str := fnd_message.get;
6825 l_document := l_document || NEWLINE ||l_temp_str ||NEWLINE||NEWLINE;
6826
6827 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NAME_COL');
6828 l_temp_str := null;
6829 l_temp_str := fnd_message.get;
6830 l_document := l_document || l_temp_str ||TAB||TAB||l_contact_name||NEWLINE;
6831
6832 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NUM_COL');
6833 l_temp_str := null;
6834 l_temp_str := fnd_message.get;
6835 l_document := l_document || l_temp_str ||TAB||TAB||l_contact_number||NEWLINE;
6836
6837 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_EMAIL_COL');
6838 l_temp_str := null;
6839 l_temp_str := fnd_message.get;
6840 l_document := l_document || l_temp_str ||TAB||l_contact_email||NEWLINE;
6841
6842 fnd_message.set_name('IBE','IBE_PRMT_COMMENTS_COL');
6843 l_temp_str := null;
6844 l_temp_str := fnd_message.get;
6845 l_document := l_document || l_temp_str ||TAB||TAB||l_comments ||NEWLINE;
6846
6847 fnd_message.set_name('IBE','IBE_PRMT_ORD_BILL_INFO');
6848 l_temp_str := null;
6849 l_temp_str := fnd_message.get;
6850 l_document := l_document || NEWLINE ||l_temp_str ||NEWLINE||NEWLINE;
6851
6852 fnd_message.set_name('IBE','IBE_PRMT_CUST_NAME_COLON');
6853 l_temp_str := null;
6854 l_temp_str := fnd_message.get;
6855 l_document := l_document || l_temp_str ||TAB||TAB||g_header_rec.customer_name||NEWLINE;
6856
6857 fnd_message.set_name('IBE','IBE_PRMT_ADDRESS_COLON');
6858 l_temp_str := null;
6859 l_temp_str := fnd_message.get;
6860 l_document := l_document || l_temp_str ||TAB||TAB||l_bill_address||NEWLINE;
6861
6862 fnd_message.set_name('IBE','IBE_PRMT_CITY_COLON');
6863 l_temp_str := null;
6864 l_temp_str := fnd_message.get;
6865 l_document := l_document || l_temp_str ||TAB||TAB||TAB||g_header_rec.bill_to_city||NEWLINE;
6866
6867 fnd_message.set_name('IBE','IBE_PRMT_STATE_PRO_COLON');
6868 l_temp_str := null;
6869 l_temp_str := fnd_message.get;
6870 l_document := l_document || l_temp_str ||TAB||TAB||g_header_rec.bill_to_state||NEWLINE;
6871
6872 fnd_message.set_name('IBE','IBE_PRMT_ZIP_POSTAL_COLON');
6873 l_temp_str := null;
6874 l_temp_str := fnd_message.get;
6875 l_document := l_document || l_temp_str ||TAB||g_header_rec.bill_to_postal_code||NEWLINE;
6876
6877 fnd_message.set_name('IBE','IBE_PRMT_COUNTRY_COLON');
6878 l_temp_str := null;
6879 l_temp_str := fnd_message.get;
6880 l_document := l_document || l_temp_str ||TAB||TAB||g_header_rec.bill_to_country||NEWLINE;
6881
6882 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NAME_COL');
6883 l_temp_str := null;
6884 l_temp_str := fnd_message.get;
6885 l_document := l_document || l_temp_str ||TAB||TAB||l_contact_name||NEWLINE;
6886
6887 fnd_message.set_name('IBE','IBE_PRMT_TEL_NO_COLON');
6888 l_temp_str := null;
6889 l_temp_str := fnd_message.get;
6890 l_document := l_document || l_temp_str ||TAB||l_contact_number||NEWLINE;
6891
6892 fnd_message.set_name('IBE','IBE_PRMT_FAX_NO_COLON');
6893 l_temp_str := null;
6894 l_temp_str := fnd_message.get;
6895 l_document := l_document || l_temp_str ||TAB||TAB||l_contact_fax||NEWLINE;
6896
6897 fnd_message.set_name('IBE','IBE_PRMT_ORD_SHIP_INFOR');
6898 l_temp_str := null;
6899 l_temp_str := fnd_message.get;
6900 l_document := l_document || NEWLINE ||l_temp_str ||NEWLINE||NEWLINE;
6901
6902 fnd_message.set_name('IBE','IBE_PRMT_CUST_NAME_COLON');
6903 l_temp_str := null;
6904 l_temp_str := fnd_message.get;
6905 l_document := l_document || l_temp_str ||TAB||TAB||g_header_rec.customer_name||NEWLINE;
6906
6907 fnd_message.set_name('IBE','IBE_PRMT_ADDRESS_COLON');
6908 l_temp_str := null;
6909 l_temp_str := fnd_message.get;
6910 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_address||NEWLINE;
6911
6912 fnd_message.set_name('IBE','IBE_PRMT_CITY_COLON');
6913 l_temp_str := null;
6914 l_temp_str := fnd_message.get;
6915 l_document := l_document || l_temp_str||TAB||TAB||TAB||g_header_rec.ship_to_city||NEWLINE;
6916
6917 fnd_message.set_name('IBE','IBE_PRMT_STATE_PRO_COLON');
6918 l_temp_str := null;
6919 l_temp_str := fnd_message.get;
6920 l_document := l_document || l_temp_str||TAB||TAB||g_header_rec.ship_to_state||NEWLINE;
6921
6922 fnd_message.set_name('IBE','IBE_PRMT_ZIP_POSTAL_COLON');
6923 l_temp_str := null;
6924 l_temp_str := fnd_message.get;
6925 l_document := l_document || l_temp_str||TAB||g_header_rec.ship_to_postal_code||NEWLINE;
6926
6927 fnd_message.set_name('IBE','IBE_PRMT_COUNTRY_COLON');
6928 l_temp_str := null;
6929 l_temp_str := fnd_message.get;
6930 l_document := l_document || l_temp_str||TAB||TAB||g_header_rec.ship_to_country||NEWLINE;
6931
6932 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NAME_COL');
6933 l_temp_str := null;
6934 l_temp_str := fnd_message.get;
6935 l_document := l_document || l_temp_str||TAB||TAB||l_contact_name||NEWLINE;
6936
6937 fnd_message.set_name('IBE','IBE_PRMT_TEL_NO_COLON');
6938 l_temp_str := null;
6939 l_temp_str := fnd_message.get;
6940 l_document := l_document || l_temp_str||TAB||l_contact_number||NEWLINE;
6941
6942 fnd_message.set_name('IBE','IBE_PRMT_FAX_NO_COLON');
6943 l_temp_str := null;
6944 l_temp_str := fnd_message.get;
6945 l_document := l_document || l_temp_str||TAB||TAB||l_contact_fax||NEWLINE;
6946 --ELSE
6947 --null;
6948 --END IF;
6949 END IF;
6950 END LOOP;
6951 CLOSE c_order_header;
6952
6953 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
6954 ibe_util.debug('GenerateAssistHeader - l_document - '||NEWLINE|| l_document);
6955 END IF;
6956
6957 document := l_document;
6958
6959 IF(display_type = 'text/html') THEN
6960 document_type := 'text/html';
6961 ELSE
6962 document_type := 'text/plain';
6963 END IF;
6964
6965 EXCEPTION
6966 When Others Then
6967 IF c_order_header%ISOPEN THEN
6968 CLOSE c_order_header;
6969 END IF;
6970 Raise;
6971 END GenerateAssistHeader;
6972
6973 /********************************************************
6974 GenerateOrderDetailHeader: Here the input parameters are
6975 document_id and display_type.
6976 document_id is nothingbut item key.
6977 display_type is text or html type message.
6978 The in and out parameters are document and document_type.
6979 Docuemnt contains order detail header info.
6980 (EX: Product number, amount ..)
6981 And document type is again text/html.
6982
6983 This procedure is responsible to send order detail header lables to workflow process.
6984 This procedure is getting called from workflow process.
6985 If the permission based procing is enabled then added amount label to the document
6986 otherwise, except amount label all other required lables are added.
6987
6988 *********************************************************/
6989 PROCEDURE GenerateOrderDetailHeader(
6990 document_id IN VARCHAR2,
6991 display_type IN VARCHAR2,
6992 document IN OUT NOCOPY VARCHAR2,
6993 document_type IN OUT NOCOPY VARCHAR2
6994 ) IS
6995 l_document VARCHAR2(32000) := ' '||NEWLINE;
6996 l_view_net_price_flag VARCHAR2(1);
6997 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
6998 l_order_id NUMBER;
6999 l_temp_str VARCHAR2(2000):='';
7000 l_event_type VARCHAR2(20);
7001 l_quote_id NUMBER;
7002 l_quote_source_code VARCHAR2(100);
7003
7004
7005 BEGIN
7006
7007
7008 l_item_key:= document_id ;
7009
7010 l_view_net_price_flag := wf_engine.GetItemAttrText (
7011 itemtype => g_itemType,
7012 itemkey => l_item_key,
7013 aname => 'VIEWNETPRICE'
7014 );
7015
7016
7017 l_event_type := wf_engine.GetItemAttrText (
7018 itemtype => g_itemType,
7019 itemkey => l_item_key,
7020 aname => 'EVENTTYPE'
7021 );
7022
7023 l_quote_id := wf_engine.GetItemAttrText (
7024 itemtype => g_itemType,
7025 itemkey => l_item_key,
7026 aname => 'QUOTEID');
7027
7028 IF (l_event_type = 'RETURNORDER') THEN -- For Return Order WF Notification
7029 fnd_message.set_name('IBE','IBE_PRMT_PRODUCT_G');
7030 l_temp_str := null;
7031 l_temp_str := fnd_message.get;
7032 l_document := rpad(l_temp_str,7)||' ';
7033 fnd_message.set_name('IBE','IBE_PRMT_DESCRIPTION_G');
7034 l_temp_str := null;
7035 l_temp_str := fnd_message.get;
7036 l_document := l_document||rpad(l_temp_str,20)||' ';
7037 fnd_message.set_name('IBE','IBE_PRMT_ORDER_NO_DOT_G');
7038 l_temp_str := null;
7039 l_temp_str := fnd_message.get;
7040 l_document := l_document||rpad(l_temp_str,9)||' ';
7041 fnd_message.set_name('IBE','IBE_PRMT_QUANTITY_G');
7042 l_temp_str := null;
7043 l_temp_str := fnd_message.get;
7044 l_document := l_document||rpad(l_temp_str,4)||' ';
7045 IF l_view_net_price_flag = 'Y' THEN
7046 fnd_message.set_name('IBE','IBE_PRMT_RETURN_AMOUNT_G');
7047 l_temp_str := null;
7048 l_temp_str := fnd_message.get;
7049 l_document := l_document||rpad(l_temp_str,15)||' ';
7050 END IF;
7051 fnd_message.set_name('IBE','IBE_PRMT_RETURN_REASON_G');
7052 l_temp_str := null;
7053 l_temp_str := fnd_message.get;
7054 l_document := l_document||rpad(l_temp_str,13);
7055 ELSIF (l_event_type = 'CUSTASSIST' OR l_event_type = 'SALESASSIST') THEN -- For Sales Assistance WF Notification
7056 Open c_get_source_code(l_quote_id);
7057 FETCH c_get_source_code into l_quote_source_code;
7058 Close c_get_source_code;
7059 if (l_quote_source_code = 'IStore InstallBase') then
7060 fnd_message.set_name('IBE','IBE_M_ACTION_PRMT');
7061 l_temp_str := null;
7062 l_temp_str := fnd_message.get;
7063 l_document := l_document ||rpad(l_temp_str,9)||' ';
7064
7065 end if;
7066 fnd_message.set_name('IBE','IBE_PRMT_PRODUCT_G');
7067 l_temp_str := null;
7068 l_temp_str := fnd_message.get;
7069 l_document := l_document ||rpad(l_temp_str,28)||' ';
7070 fnd_message.set_name('IBE','IBE_PRMT_UOM_SHORT_G');
7071 l_temp_str := null;
7072 l_temp_str := fnd_message.get;
7073 l_document := l_document||lpad(l_temp_str,8)||' ';
7074 fnd_message.set_name('IBE','IBE_PRMT_QUANTITY_G');
7075 l_temp_str := null;
7076 l_temp_str := fnd_message.get;
7077 l_document := l_document||lpad(l_temp_str,7)||' ';
7078 if (l_quote_source_code <> 'IStore InstallBase') then
7079 fnd_message.set_name('IBE','Shippable');
7080 l_temp_str := null;
7081 l_temp_str := fnd_message.get;
7082 l_document := l_document||lpad(l_temp_str,9)||' ';
7083 end if;
7084 IF l_view_net_price_flag = 'Y' THEN
7085 fnd_message.set_name('IBE','IBE_PRMT_AMOUNT_G');
7086 l_temp_str := null;
7087 l_temp_str := fnd_message.get;
7088 l_document := l_document||lpad(l_temp_str,15)||' ';
7089 END IF;
7090 ELSE -- For all other WF notifications (Order conf and Contracts negeotiations)
7091 Open c_get_source_code(l_quote_id);
7092 FETCH c_get_source_code into l_quote_source_code;
7093 Close c_get_source_code;
7094
7095 if (l_quote_source_code = 'IStore InstallBase') then
7096 fnd_message.set_name('IBE','IBE_M_ACTION_PRMT');
7097 l_temp_str := null;
7098 l_temp_str := fnd_message.get;
7099 l_document := l_document ||rpad(l_temp_str,9)||' ';
7100
7101 end if;
7102 fnd_message.set_name('IBE','IBE_PRMT_PRODUCT_G');
7103 l_temp_str := null;
7104 l_temp_str := fnd_message.get;
7105 l_document := l_document ||rpad(l_temp_str,28)||' ';
7106 fnd_message.set_name('IBE','IBE_PRMT_UOM_SHORT_G');
7107 l_temp_str := null;
7108 l_temp_str := fnd_message.get;
7109 l_document := l_document||lpad(l_temp_str,8)||' ';
7110 fnd_message.set_name('IBE','IBE_PRMT_QUANTITY_G');
7111 l_temp_str := null;
7112 l_temp_str := fnd_message.get;
7113 l_document := l_document||lpad(l_temp_str,7)||' ';
7114 if (l_quote_source_code <> 'IStore InstallBase') then
7115 fnd_message.set_name('IBE','Shippable');
7116 l_temp_str := null;
7117 l_temp_str := fnd_message.get;
7118 l_document := l_document||lpad(l_temp_str,9)||' ';
7119 end if;
7120 IF l_view_net_price_flag = 'Y' THEN
7121 fnd_message.set_name('IBE','IBE_PRMT_AMOUNT_G');
7122 l_temp_str := null;
7123 l_temp_str := fnd_message.get;
7124 l_document := l_document||lpad(l_temp_str,15)||' ';
7125 END IF;
7126 END IF;
7127
7128 document := l_document||NEWLINE;
7129
7130 IF(display_type = 'text/html') THEN
7131 document_type := 'text/html';
7132 ELSE
7133 document_type := 'text/plain';
7134 END IF;
7135
7136 END GenerateOrderDetailHeader;
7137
7138
7139
7140
7141 --This API added by mannamra
7142 PROCEDURE Generate_Detail(
7143 P_item_key IN VARCHAR2,
7144 p_quote_flag IN VARCHAR2,
7145 p_tax_flag IN VARCHAR2,
7146 x_document OUT NOCOPY VARCHAR2
7147 ) is
7148 l_item_type wf_items.item_type%TYPE;
7149 l_item_key wf_items.item_key%TYPE;
7150 l_quote_id NUMBER;
7151 l_event_type VARCHAR2(20);
7152 l_document VARCHAR2(32000) := '';
7153 l_ship_flag VARCHAR2(1);
7154 l_string_in VARCHAR2(250);
7155 l_string_out VARCHAR2(250);
7156 l_string_left VARCHAR2(250);
7157 l_order_id NUMBER;
7158 l_can_qty VARCHAR2(50);
7159 l_can_amt VARCHAR2(50);
7160
7161 l_amt_format Varchar2(50);
7162 l_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
7163 l_temp_str VARCHAR2(2000):='';
7164 l_view_net_price_flag VARCHAR2(1);
7165 l_view_line_type_flag VARCHAR2(1) := FND_API.G_FALSE;
7166 Cursor c_ship_flag(p_line_id NUMBER) IS
7167 SELECT msi.shippable_item_flag
7168 FROM oe_order_lines_all line,
7169 OE_SYSTEM_PARAMETERS_ALL osp,
7170 mtl_system_items_kfv msi
7171 WHERE line.line_id = p_line_id
7172 AND line.org_id = osp.org_id
7173 AND osp.master_organization_id = msi.organization_id
7174 AND line.inventory_item_id = msi.inventory_item_id;
7175
7176
7177 notif_line_tbl Notif_Line_Tbl_Type;
7178 Cursor c_get_top_quote_lines(p_quote_header_id number) is
7179 SELECT m.description,
7180 u.unit_of_measure,
7181 q.quote_line_id,
7182 q.Quantity,
7183 q.item_type_code,
7184 q.Line_quote_price,
7185 q.currency_code,
7186 uom.unit_of_measure_tl charge_periodicity_desc,
7187 m.shippable_item_flag,
7188 sum(t.tax_amount) tax_amount,
7189 qld.config_instance_name,
7190 tran.name action,
7191 qld.config_delta
7192 FROM Aso_quote_lines_all q,
7193 mtl_system_items_vl m,
7194 aso_tax_details t,
7195 mtl_units_of_measure u,
7196 Aso_quote_line_details qld,
7197 oe_transaction_types_tl tran,
7198 mtl_units_of_measure_tl uom
7199 WHERE q.inventory_item_id = m.inventory_item_id
7200 and q.organization_id = m.organization_id
7201 and t.quote_line_id(+) = q.quote_line_id
7202 and u.uom_code = q.uom_code
7203 and q.quote_header_id = p_quote_header_id --2548--6399
7204 and q.item_type_code <> 'CFG'
7205 and qld.quote_line_id(+) = q.quote_line_id
7206 and tran.TRANSACTION_TYPE_ID(+) = q.order_line_type_id
7207 and tran.language(+) = userenv('lang')
7208 and uom.uom_code(+) = q.charge_periodicity_code
7209 and uom.language(+) = userenv('lang')
7210 and qld.ref_line_id is null
7211 GROUP BY q.quote_line_id,
7212 q.line_number,
7213 m.description,
7214 u.unit_of_measure,
7215 q.Quantity,
7216 q.item_type_code,
7217 q.Line_quote_price,
7218 q.charge_periodicity_code,
7219 q.currency_code,
7220 m.shippable_item_flag,
7221 qld.config_instance_name,
7222 tran.name,
7223 uom.unit_of_measure_tl,
7224 qld.config_delta
7225 ORDER BY q.line_number;
7226 g_notif_quote_line_rec c_get_top_quote_lines%ROWTYPE;
7227
7228 Cursor c_get_config_tree (p_quote_header_id number,p_parent_line_id number) is
7229 SELECT m.description description,
7230 u.unit_of_measure,
7231 q.Quantity,
7232 q.item_type_code,
7233 q.Line_quote_price,
7234 uom.unit_of_measure_tl charge_periodicity_desc,
7235 m.shippable_item_flag,
7236 m.bom_item_type,
7237 m.config_model_type,
7238 sum(t.tax_amount) tax_amount,
7239 qld.config_instance_name,
7240 tran.name action,
7241 qld.config_delta
7242 FROM ( SELECT related_quote_line_id,LEVEL depth
7243 FROM aso_line_relationships
7244 START WITH quote_line_id = p_parent_line_id
7245 CONNECT BY quote_line_id =
7246 PRIOR related_quote_line_id ) ALR,
7247 Aso_quote_lines_all q,
7248 mtl_system_items_vl m,
7249 aso_tax_details t,
7250 mtl_units_of_measure u,
7251 Aso_quote_line_details qld,
7252 oe_transaction_types_tl tran,
7253 mtl_units_of_measure_tl uom
7254 WHERE q.quote_line_id = ALR.related_quote_line_id and
7255 q.inventory_item_id = m.inventory_item_id
7256 and q.organization_id = m.organization_id
7257 and t.quote_line_id(+) = q.quote_line_id
7258 and u.uom_code = q.uom_code
7259 and q.quote_header_id = p_quote_header_id -- 2548--6399
7260 and qld.quote_line_id(+) = q.quote_line_id
7261 and tran.TRANSACTION_TYPE_ID(+) = q.order_line_type_id
7262 and tran.language(+) = userenv('lang')
7263 and uom.uom_code(+) = q.charge_periodicity_code
7264 and uom.language(+) = userenv('lang')
7265 GROUP BY q.quote_line_id,
7266 q.line_number,
7267 m.description,
7268 u.unit_of_measure,
7269 q.Quantity,
7270 q.item_type_code,
7271 q.Line_quote_price,
7272 q.charge_periodicity_code,
7273 m.shippable_item_flag,
7274 m.bom_item_type,
7275 m.config_model_type,
7276 qld.config_instance_name,
7277 tran.name,
7278 uom.unit_of_measure_tl,
7279 qld.config_delta
7280 ORDER BY q.line_number;
7281 g_notif_config_line_rec c_get_config_tree%ROWTYPE;
7282
7283 Cursor c_get_top_order_lines(p_order_id NUMBER) IS
7284 SELECT ol.item_type_code,
7285 ol.top_model_line_id,
7286 ol.link_to_line_id,
7287 msi.description description,
7288 cfgdtl.name config_instance_name,
7289 linetyp.name action,
7290 ol.order_quantity_uom unit_of_measure,
7291 ol.ordered_quantity quantity,
7292 msit1.UNIT_OF_MEASURE charge_periodicity_desc,
7293 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'LINES') lines_total,
7294 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'TAXES') taxes_total,
7295 ol.shippable_flag,
7296 decode(msi.config_model_type,'N','Y','N') model_container_flag,
7297 cfgdtl.config_delta config_delta_flag
7298 FROM oe_order_lines_all ol,
7299 mtl_system_items_vl msi,
7300 CZ_CONFIG_ITEMS cfgdtl,
7301 mtl_units_of_measure_tl msit1,
7302 oe_transaction_types_tl linetyp
7303 WHERE ol.header_id = p_order_id
7304 AND decode(ol.top_model_line_id,null,'1',decode(ol.top_model_line_id,ol.line_id,decode(ol.link_to_line_id,null,'1','2'),'2'))= '1'
7305 and ol.inventory_item_id = msi.inventory_item_Id
7306 and msit1.language(+) = userenv('LANG')
7307 and ol.charge_periodicity_code = msit1.uom_code(+)
7308 and msi.organization_id = oe_profile.value('OE_ORGANIZATION_ID', ol.org_id)
7309 and ol.config_header_id = cfgdtl.config_hdr_id(+)
7310 and ol.config_rev_nbr = cfgdtl.config_rev_nbr (+)
7311 and ol.configuration_id = cfgdtl.config_item_id(+)
7312 AND ol.line_type_id = linetyp.transaction_type_id
7313 AND linetyp.language = userenv('LANG')
7314 ORDER BY ol.line_number,
7315 shipment_number,
7316 nvl( option_number,-1),
7317 nvl( component_number,-1),
7318 nvl( service_number,-1);
7319 g_notif_order_line_rec c_get_top_order_lines%ROWTYPE;
7320
7321 Cursor c_get_order_config_tree(p_order_id NUMBER, p_mdl_top_line_id VARCHAR2) IS
7322 SELECT ol.item_type_code,
7323 ol.top_model_line_id,
7324 ol.link_to_line_id,
7325 msi.description description,
7326 cfgdtl.name config_instance_name,
7327 linetyp.name action,
7328 ol.order_quantity_uom unit_of_measure,
7329 ol.ordered_quantity quantity,
7330 msit1.UNIT_OF_MEASURE charge_periodicity_desc,
7331 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'LINES') lines_total,
7332 oe_totals_grp.Get_Order_Total(ol.header_id,ol.line_id,'TAXES') taxes_total,
7333 ol.shippable_flag,
7334 decode(msi.config_model_type,'N','Y','N') model_container_flag,
7335 cfgdtl.config_delta config_delta_flag
7336 FROM oe_order_lines_all ol,
7337 mtl_system_items_vl msi,
7338 CZ_CONFIG_ITEMS cfgdtl,
7339 mtl_units_of_measure_tl msit1,
7340 oe_transaction_types_tl linetyp
7341 WHERE ol.header_id = p_order_id
7342 and link_to_line_id is not null
7343 and ( top_model_line_id = p_mdl_top_line_id)
7344 and ol.inventory_item_id = msi.inventory_item_Id
7345 and msit1.language(+) = userenv('LANG')
7346 and ol.charge_periodicity_code = msit1.uom_code(+)
7347 and msi.organization_id = oe_profile.value('OE_ORGANIZATION_ID', ol.org_id)
7348 and ol.config_header_id = cfgdtl.config_hdr_id(+)
7349 and ol.config_rev_nbr = cfgdtl.config_rev_nbr (+)
7350 and ol.configuration_id = cfgdtl.config_item_id(+)
7351 AND ol.line_type_id = linetyp.transaction_type_id
7352 AND linetyp.language = userenv('LANG')
7353 ORDER BY ol.line_number,
7354 shipment_number,
7355 nvl( option_number,-1),
7356 nvl( component_number,-1),
7357 nvl( service_number,-1);
7358 g_notif_config_orderline_rec c_get_order_config_tree%ROWTYPE;
7359
7360 l_index number := 1;
7361
7362 ord_detail_rec c_order_detail%rowtype;
7363
7364 type order_details_tbl_type is table of ibe_order_detail_v%rowtype
7365 INDEX BY BINARY_INTEGER;
7366 ord_detail_tbl order_details_tbl_type;
7367 i number :=1;
7368 j number :=1;
7369 counter number;
7370 l_kit_line_id number;
7371 l_kit_index number :=0 ;
7372 l_kit_line_price number := 0;
7373 l_kit_line_tax number := 0;
7374 l_kit_found_here number := 0;
7375 l_displayOptionClass VARCHAR2(1);
7376 l_displayUnchangedItem VARCHAR2(1);
7377 l_quote_source_code VARCHAR2(100);
7378
7379 TYPE Kit_log_rec IS RECORD (
7380 Kit_line_index NUMBER,
7381 item_type_code VARCHAR2(2000),
7382 lines_total NUMBER,
7383 taxes_total NUMBER,
7384 total_line_price NUMBER,
7385 total_tax_price NUMBER);
7386
7387 TYPE kit_log_tbl_type IS table OF kit_log_rec INDEX BY BINARY_INTEGER;
7388 kit_log_tbl kit_log_tbl_type; --PL/SQl table to save 'KIT' and 'INCLUDED' items
7389
7390
7391 -- ord_detail_rec order_details_rec_type;
7392 BEGIN
7393
7394 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7395 IBE_UTIL.DEBUG('Generate_detail:START');
7396 END IF;
7397 ----DBMS_OUTPUT.PUT('Quote flag is: '||p_quote_flag);
7398 ----DBMS_OUTPUT.PUT('Tax flag is: '||p_tax_flag);
7399 l_item_key := p_item_key;
7400 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7401 ibe_util.debug('Generate_Detail - l_item_key - '||l_item_key);
7402 END IF;
7403
7404 l_quote_id := wf_engine.GetItemAttrText (
7405 itemtype => g_itemType,
7406 itemkey => l_item_key,
7407 aname => 'QUOTEID'
7408 );
7409 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7410 ibe_util.debug('Generate_Detail - l_quote_id - '||l_quote_id);
7411 END IF;
7412 l_order_id := wf_engine.GetItemAttrText (
7413 itemtype => g_itemType,
7414 itemkey => l_item_key,
7415 aname => 'ORDERID'
7416 );
7417 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7418 ibe_util.debug('Generate_Detail - l_order_id - '||l_order_id);
7419 END IF;
7420 l_event_type := wf_engine.GetItemAttrText (
7421 itemtype => g_itemType,
7422 itemkey => l_item_key,
7423 aname => 'EVENTTYPE'
7424 );
7425 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7426 ibe_util.debug('Generate_Detail - l_event_type - '|| l_event_type);
7427 END IF;
7428
7429
7430 l_view_net_price_flag := wf_engine.GetItemAttrText (
7431 itemtype => g_itemType,
7432 itemkey => l_item_key,
7433 aname => 'VIEWNETPRICE'
7434 );
7435
7436 Open c_get_source_code(l_quote_id);
7437 FETCH c_get_source_code into l_quote_source_code;
7438 Close c_get_source_code;
7439 if (l_quote_source_code = 'IStore InstallBase') then
7440 l_view_line_type_flag := FND_API.G_TRUE;
7441 end if;
7442
7443 For g_quote_header_rec In c_quote_header(l_quote_id) Loop
7444 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK(g_quote_header_rec.currency_code,18);
7445 g_amt_format := l_amt_format;
7446 IF l_view_net_price_flag = 'Y' THEN
7447 For curr_sym_rec In c_curr_symbol(g_quote_header_rec.currency_code)
7448 Loop
7449 l_curr_sym := trim(nvl(curr_sym_rec.symbol,' '));
7450 g_curr_sym := l_curr_sym;
7451 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7452 IBE_UTIL.DEBUG('currency symbol is: '||nvl(l_curr_sym,'nothing'));
7453 END IF;
7454 End Loop;
7455 END IF;
7456 End Loop;
7457 ----DBMS_OUTPUT.PUT('Quote flag is: '||p_quote_flag);
7458 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7459 ibe_util.debug('p_quote_flag '||p_quote_flag);
7460 END IF;
7461 --Get Display Option class profile value
7462 l_displayOptionClass := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DISPLAY_OPTION_CLASSES',null,null,671), 'Y');
7463 l_displayUnchangedItem := NVL( FND_PROFILE.VALUE_SPECIFIC('CZ_OUTPUT_IB_UNCHD_CHILD_ITEMS',null,null,671), 'Y');
7464
7465 IF(p_quote_flag = fnd_api.g_true) then
7466 FOR g_notif_quote_line_rec IN c_get_top_quote_lines(l_quote_id) LOOP
7467 if(g_notif_quote_line_rec.config_instance_name is not null) then
7468 notif_line_tbl(l_index).Product := g_notif_quote_line_rec.description||':'||g_notif_quote_line_rec.config_instance_name;
7469 else
7470 notif_line_tbl(l_index).Product := g_notif_quote_line_rec.description;
7471 end if;
7472 --DBMS_OUTPUT.PUT_LINE(Notif_Line_Tbl(l_index).Product);
7473 notif_line_tbl(l_index).UOM :=g_notif_quote_line_rec.unit_of_measure;
7474 notif_line_tbl(l_index).Quantity :=g_notif_quote_line_rec.Quantity;
7475 notif_line_tbl(l_index).Shippable :=g_notif_quote_line_rec.shippable_item_flag;
7476 notif_line_tbl(l_index).NetAmount :=g_notif_quote_line_rec.Line_quote_price;
7477 notif_line_tbl(l_index).Periodicity :=g_notif_quote_line_rec.charge_periodicity_desc;
7478 notif_line_tbl(l_index).TaxAmount :=g_notif_quote_line_rec.tax_amount;
7479 if(g_notif_quote_line_rec.config_delta <> 0) then
7480 notif_line_tbl(l_index).Action :=g_notif_quote_line_rec.action;
7481 end if;
7482 l_index := l_index+1;
7483 if(g_notif_quote_line_rec.item_type_code = 'MDL') then
7484 For g_notif_config_line_rec In c_get_config_tree(l_quote_id,g_notif_quote_line_rec.quote_line_id) Loop
7485 if((l_displayOptionClass = 'Y' OR (l_displayOptionClass = 'N' and g_notif_config_line_rec.bom_item_type <> '2'))
7486 and (l_displayUnchangedItem = 'Y' OR (l_displayUnchangedItem = 'N' and g_notif_config_line_rec.config_delta <> '0')))then
7487 if(g_notif_config_line_rec.config_instance_name is not null) then
7488 notif_line_tbl(l_index).Product := g_notif_config_line_rec.description||':'||g_notif_quote_line_rec.config_instance_name;
7489 else
7490 notif_line_tbl(l_index).Product := g_notif_config_line_rec.description;
7491 end if;
7492 notif_line_tbl(l_index).UOM :=g_notif_config_line_rec.unit_of_measure;
7493 notif_line_tbl(l_index).Quantity :=g_notif_config_line_rec.Quantity;
7494 notif_line_tbl(l_index).Shippable :=g_notif_config_line_rec.shippable_item_flag;
7495 notif_line_tbl(l_index).NetAmount :=g_notif_config_line_rec.Line_quote_price;
7496 notif_line_tbl(l_index).Periodicity :=g_notif_config_line_rec.charge_periodicity_desc;
7497 notif_line_tbl(l_index).TaxAmount :=g_notif_config_line_rec.tax_amount;
7498 if(g_notif_config_line_rec.config_delta <> 0) then
7499 notif_line_tbl(l_index).Action :=g_notif_config_line_rec.action;
7500 end if;
7501 l_index := l_index+1;
7502 END IF;--Hide Option class and Unchanged Lines
7503 end loop;
7504 end if;
7505 notif_line_tbl(l_index-1).LastItem := FND_API.G_TRUE;
7506 EXIT WHEN c_get_top_quote_lines%NOTFOUND;
7507 END LOOP;
7508 l_document := buildDocument(notif_line_tbl,l_view_net_price_flag,l_view_line_type_flag,p_tax_flag);
7509 --Order details content generation
7510 Elsif(p_quote_flag = fnd_api.g_false) then
7511 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7512 IBE_UTIL.debug('p_quote_flag is false, entering the order area');
7513 END IF;
7514 --Begin New Order Generate Detail
7515 FOR g_notif_order_line_rec IN c_get_top_order_lines(l_order_id) LOOP
7516 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7517 IBE_UTIL.debug('Notif Order Line not null');
7518 END IF;
7519 if(g_notif_order_line_rec.config_instance_name is not null) then
7520 notif_line_tbl(l_index).Product := g_notif_order_line_rec.description||':'||g_notif_order_line_rec.config_instance_name;
7521 else
7522 notif_line_tbl(l_index).Product := g_notif_order_line_rec.description;
7523 end if;
7524 --DBMS_OUTPUT.PUT_LINE(Notif_Line_Tbl(l_index).Product);
7525 notif_line_tbl(l_index).UOM :=g_notif_order_line_rec.unit_of_measure;
7526 notif_line_tbl(l_index).Quantity :=g_notif_order_line_rec.Quantity;
7527 notif_line_tbl(l_index).Shippable :=g_notif_order_line_rec.shippable_flag;
7528 notif_line_tbl(l_index).NetAmount :=g_notif_order_line_rec.lines_total;
7529 notif_line_tbl(l_index).Periodicity :=g_notif_order_line_rec.charge_periodicity_desc;
7530 notif_line_tbl(l_index).TaxAmount :=g_notif_order_line_rec.taxes_total;
7531 if (g_notif_order_line_rec.config_delta_flag <> 0) then
7532 notif_line_tbl(l_index).Action :=g_notif_order_line_rec.action;
7533 end if;
7534 l_index := l_index+1;
7535 if(g_notif_order_line_rec.item_type_code = 'MODEL') then
7536 For g_notif_config_orderline_rec In c_get_order_config_tree(l_order_id,g_notif_order_line_rec.top_model_line_id) Loop
7537 if((l_displayOptionClass = 'Y' OR (l_displayOptionClass = 'N' and g_notif_config_orderline_rec.item_type_code <> 'CLASS'))
7538 and (l_displayUnchangedItem = 'Y' OR (l_displayUnchangedItem = 'N' and g_notif_config_orderline_rec.config_delta_flag <> '0'))) then
7539 if(g_notif_config_orderline_rec.config_instance_name is not null) then
7540 notif_line_tbl(l_index).Product := g_notif_config_orderline_rec.description||':'||g_notif_config_orderline_rec.config_instance_name;
7541 else
7542 notif_line_tbl(l_index).Product := g_notif_config_orderline_rec.description;
7543 end if;
7544 notif_line_tbl(l_index).UOM :=g_notif_config_orderline_rec.unit_of_measure;
7545 notif_line_tbl(l_index).Quantity :=g_notif_config_orderline_rec.Quantity;
7546 notif_line_tbl(l_index).Shippable :=g_notif_config_orderline_rec.shippable_flag;
7547 notif_line_tbl(l_index).NetAmount :=g_notif_config_orderline_rec.lines_total;
7548 notif_line_tbl(l_index).Periodicity :=g_notif_config_orderline_rec.charge_periodicity_desc;
7549 notif_line_tbl(l_index).TaxAmount :=g_notif_config_orderline_rec.taxes_total;
7550 if (g_notif_config_orderline_rec.config_delta_flag <> 0) then
7551 notif_line_tbl(l_index).Action :=g_notif_config_orderline_rec.action;
7552 end if;
7553 l_index := l_index+1;
7554 END IF;--Hide Option class and Unchanged Lines
7555 END LOOP;
7556 END IF;
7557 if(g_notif_order_line_rec.item_type_code = 'KIT') then
7558 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7559 IBE_UTIL.Debug('Kit found here: Need to do changes');
7560 END IF;
7561 For g_notif_config_orderline_rec In c_get_order_config_tree(l_quote_id,g_notif_order_line_rec.top_model_line_id) Loop
7562 notif_line_tbl(l_index).NetAmount := notif_line_tbl(l_index).NetAmount + g_notif_config_orderline_rec.lines_total;
7563 notif_line_tbl(l_index).TaxAmount := notif_line_tbl(l_index).NetAmount + g_notif_config_orderline_rec.lines_total;
7564 END LOOP;
7565 end if;
7566 notif_line_tbl(l_index-1).LastItem := FND_API.G_TRUE;
7567 END LOOP;
7568 --End New Order Generate Detail
7569 l_document := buildDocument(notif_line_tbl,l_view_net_price_flag,l_view_line_type_flag,p_tax_flag);
7570 END IF; --for l_quote_flag
7571 x_document := l_document;
7572 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7573 ibe_util.debug('Generate_Detail - l_document - ' ||NEWLINE||l_document);
7574 END IF;
7575 END;
7576
7577 /********************************************************
7578 GenerateReturnDetail: Here the input parameters are
7579 item_key and tax_flag of the user and
7580 x_document is the output parameter.
7581
7582 This procedure is responsible to retrive the return order details.
7583 This procedure is being called from Generate_Rtn_ord_Detail_notax
7584 and Generate_Rtn_ord_Detail_wtax procedures.
7585 *********************************************************/
7586 PROCEDURE GenerateReturnDetail(
7587 P_item_key IN VARCHAR2,
7588 p_tax_flag IN VARCHAR2,
7589 x_document IN OUT NOCOPY VARCHAR2
7590 )IS
7591
7592 l_item_key WF_ITEMS.ITEM_KEY%TYPE;
7593 l_event_type VARCHAR2(20);
7594 l_document VARCHAR2(32000) := '';
7595 l_string_in VARCHAR2(250);
7596 l_string_out VARCHAR2(250);
7597 l_string_left VARCHAR2(250);
7598 lr_string_in VARCHAR2(250);
7599 lr_string_out VARCHAR2(250);
7600 lr_string_left VARCHAR2(250);
7601 lr_length NUMBER;
7602 l_order_id NUMBER;
7603 l_amt_format VARCHAR2(50);
7604 l_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
7605 l_temp_str VARCHAR2(2000) :='';
7606 l_view_net_price_flag VARCHAR2(2);
7607 l_tax_flag VARCHAR2(1);
7608 l_parent_line_id NUMBER;
7609 p_index NUMBER;
7610 l_return_reason_code AR_LOOKUPS.LOOKUP_CODE%TYPE;
7611 l_return_reason AR_LOOKUPS.MEANING%TYPE;
7612 p_mdl_source_line_id VARCHAR2(240);
7613 l_print_len NUMBER;
7614 l_can_qty VARCHAR2(50);
7615 l_can_amt VARCHAR2(50);
7616
7617
7618 Cursor cursor_for_std_mdl_items(p_order_id NUMBER) IS
7619 SELECT source_line_id,
7620 item_type_code,
7621 orig_top_model_line_id,
7622 orig_link_to_line_id,
7623 item_description,
7624 item_number,
7625 source_order_number,
7626 return_reason_code,
7627 returned_quantity,
7628 lines_total,
7629 taxes_total,
7630 charges_total
7631 FROM ibe_return_detail_v
7632 WHERE header_id = p_order_id
7633 AND (orig_top_model_line_id is null or (orig_top_model_line_id = source_line_id and orig_link_to_line_id is null))
7634 ORDER BY line_number,
7635 shipment_number,
7636 nvl( option_number,-1),
7637 nvl( component_number,-1),
7638 nvl( service_number,-1);
7639 c_detail_rec1 cursor_for_std_mdl_items%rowtype;
7640
7641 Cursor cursor_for_mdl_components(p_order_id NUMBER, p_mdl_source_line_id VARCHAR2) IS
7642 SELECT source_line_id,
7643 item_type_code,
7644 orig_top_model_line_id,
7645 orig_link_to_line_id,
7646 orig_item_type_code,
7647 item_description,
7648 item_number,
7649 source_order_number,
7650 return_reason_code,
7651 returned_quantity,
7652 lines_total,
7653 taxes_total,
7654 charges_total
7655 FROM ibe_return_detail_v
7656 WHERE header_id = p_order_id
7657 and orig_link_to_line_id is not null and ( orig_top_model_line_id = to_number(p_mdl_source_line_id))
7658 ORDER BY line_number,
7659 shipment_number,
7660 nvl( option_number,-1),
7661 nvl( component_number,-1),
7662 nvl( service_number,-1);
7663 c_detail_rec2 cursor_for_mdl_components%rowtype;
7664
7665 CURSOR c_return_reason(l_return_reason_code VARCHAR2) IS
7666 SELECT meaning
7667 FROM ar_lookups
7668 WHERE lookup_type = 'CREDIT_MEMO_REASON'
7669 AND lookup_code = l_return_reason_code;
7670
7671 type order_details_tbl_type is table of ibe_return_detail_v%rowtype
7672 INDEX BY BINARY_INTEGER;
7673 ord_detail_tbl order_details_tbl_type;
7674 i number :=1;
7675 j number :=1;
7676 counter number;
7677 l_kit_line_id number;
7678 l_kit_index number :=0 ;
7679 l_kit_line_price number := 0;
7680 l_kit_line_tax number := 0;
7681 l_kit_found_here number := 0;
7682 TYPE Kit_log_rec IS RECORD (
7683 Kit_line_index NUMBER,
7684 item_type_code VARCHAR2(2000),
7685 lines_total NUMBER,
7686 taxes_total NUMBER,
7687 total_line_price NUMBER,
7688 total_tax_price NUMBER);
7689
7690 TYPE kit_log_tbl_type IS table OF kit_log_rec INDEX BY BINARY_INTEGER;
7691 kit_log_tbl kit_log_tbl_type; --PL/SQl table to save 'KIT' and 'INCLUDED' items
7692
7693 BEGIN
7694
7695
7696 l_item_key := P_item_key;
7697
7698 l_order_id := wf_engine.GetItemAttrText (
7699 itemtype => g_itemType,
7700 itemkey => l_item_key,
7701 aname => 'ORDERID'
7702 );
7703
7704
7705 l_event_type := wf_engine.GetItemAttrText (
7706 itemtype => g_itemType,
7707 itemkey => l_item_key,
7708 aname => 'EVENTTYPE'
7709 );
7710
7711
7712
7713 For ord_hd_rec In c_order_header(l_order_id) Loop
7714 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK(ord_hd_rec.transactional_curr_code,18);
7715
7716 For curr_sym_rec In c_curr_symbol(ord_hd_rec.transactional_curr_code) Loop
7717 l_curr_sym := trim(nvl(curr_sym_rec.symbol,' '));
7718 End Loop;
7719
7720 End Loop;
7721
7722
7723
7724 OPEN cursor_for_std_mdl_items(l_order_id);
7725 LOOP
7726
7727 -------------------------------------------
7728 FETCH cursor_for_std_mdl_items INTO c_detail_rec1;
7729 EXIT WHEN cursor_for_std_mdl_items%NOTFOUND;
7730
7731 IF(c_detail_rec1.orig_top_model_line_id is NULL) THEN -- STD item
7732
7733 ord_detail_tbl(i).line_id := c_detail_rec1.source_line_id;
7734 ord_detail_tbl(i).item_number := c_detail_rec1.item_number;
7735 ord_detail_tbl(i).item_description := c_detail_rec1.item_description;
7736 ord_detail_tbl(i).source_order_number := c_detail_rec1.source_order_number;
7737 ord_detail_tbl(i).item_type_code := c_detail_rec1.item_type_code;
7738 ord_detail_tbl(i).returned_quantity := c_detail_rec1.returned_quantity;
7739 ord_detail_tbl(i).return_reason_code := c_detail_rec1.return_reason_code;
7740 ord_detail_tbl(i).lines_total := c_detail_rec1.lines_total;
7741 ord_detail_tbl(i).taxes_total := c_detail_rec1.taxes_total;
7742 i:=i+1;
7743 ELSE -- MDL item case
7744 -- First take the model item and save it in ord_detail_tbl.
7745 ord_detail_tbl(i).line_id := c_detail_rec1.source_line_id;
7746 p_mdl_source_line_id := c_detail_rec1.source_line_id;
7747 ord_detail_tbl(i).item_number := c_detail_rec1.item_number;
7748 ord_detail_tbl(i).item_description := c_detail_rec1.item_description;
7749 ord_detail_tbl(i).source_order_number := c_detail_rec1.source_order_number;
7750 ord_detail_tbl(i).item_type_code := c_detail_rec1.item_type_code;
7751 ord_detail_tbl(i).returned_quantity := c_detail_rec1.returned_quantity;
7752 ord_detail_tbl(i).return_reason_code := c_detail_rec1.return_reason_code;
7753 ord_detail_tbl(i).lines_total := c_detail_rec1.lines_total;
7754 ord_detail_tbl(i).taxes_total := c_detail_rec1.taxes_total;
7755 j:= i; -- to note that this is a model item and we need to roll up the total and taxes
7756 i:=i+1;
7757 -- now get the components of this model item.
7758 OPEN cursor_for_mdl_components(l_order_id, p_mdl_source_line_id);
7759 LOOP
7760 FETCH cursor_for_mdl_components INTO c_detail_rec2;
7761 EXIT WHEN cursor_for_mdl_components%NOTFOUND;
7762 IF (c_detail_rec2.orig_item_type_code <> 'INCLUDED') THEN
7763 ord_detail_tbl(i).line_id := c_detail_rec2.source_line_id;
7764 ord_detail_tbl(i).item_number := c_detail_rec2.item_number;
7765 ord_detail_tbl(i).item_description := c_detail_rec2.item_description;
7766 ord_detail_tbl(i).source_order_number := NULL;--c_detail_rec2.source_order_number;
7767 ord_detail_tbl(i).item_type_code := c_detail_rec2.item_type_code;
7768 ord_detail_tbl(i).returned_quantity := c_detail_rec2.returned_quantity;
7769 ord_detail_tbl(i).return_reason_code :='';
7770 i := i+1;
7771 END IF;
7772 -- below roll up the totals to its parent (model) item.
7773 ord_detail_tbl(j).lines_total := ord_detail_tbl(j).lines_total + c_detail_rec2.lines_total;
7774 ord_detail_tbl(j).taxes_total := ord_detail_tbl(j).taxes_total + c_detail_rec2.taxes_total;
7775 END LOOP;
7776 CLOSE cursor_for_mdl_components;
7777 END IF;
7778
7779 END LOOP;
7780 CLOSE cursor_for_std_mdl_items;
7781 -------------------------------------
7782
7783 i := 0;
7784 /*Construct the display string from the ord_detail_tbl here*/
7785 -------------------------------
7786 FOR i IN 1..ORD_DETAIL_TBL.COUNT loop
7787 l_document := l_document || rpad(ltrim(rtrim(ord_detail_tbl(i).item_number)),7)||' ';
7788 l_string_in := rtrim(ord_detail_tbl(i).item_description);
7789 l_string_out := '';
7790 l_string_left := '';
7791 ibe_workflow_pvt.ParseThisString1(l_string_in,l_string_out,l_string_left);
7792 l_document := l_document ||rpad(l_string_out,20)||' ' ;
7793 IF (ord_detail_tbl(i).source_order_number IS NOT NULL) THEN
7794 l_document := l_document || rpad(to_char(ord_detail_tbl(i).source_order_number),9)||' ';
7795 ELSE
7796 l_document := l_document || rpad(' ',10);
7797 END IF;
7798 l_can_qty := ibe_util.nls_number_format(p_number_in => to_char(ord_detail_tbl(i).returned_quantity));
7799 l_document := l_document || rpad(to_char(to_number(l_can_qty)),5)||' ';
7800
7801 l_view_net_price_flag:= wf_engine.GetItemAttrText (
7802 itemtype => g_itemType,
7803 itemkey => l_item_key,
7804 aname => 'VIEWNETPRICE'
7805 );
7806 IF l_view_net_price_flag = 'Y' THEN
7807 IF (to_char(ord_detail_tbl(i).lines_total) is null) THEN
7808 l_document := l_document || lpad(' ' || to_char(to_number(ord_detail_tbl(i).lines_total),l_amt_format), 14, ' ');
7809 ELSE
7810 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(ord_detail_tbl(i).lines_total));
7811 l_document := l_document || lpad(l_curr_sym || to_char(to_number(l_can_amt),l_amt_format), 14, ' ')||' ';
7812 END IF;
7813 END IF;
7814 IF (ord_detail_tbl(i).return_reason_code is not NULL) THEN
7815 l_return_reason_code := ord_detail_tbl(i).return_reason_code;
7816 l_return_reason := ' ';
7817 OPEN c_return_reason(l_return_reason_code);
7818 LOOP
7819 FETCH c_return_reason INTO l_return_reason;
7820 EXIT WHEN c_return_reason%NOTFOUND;
7821 ord_detail_tbl(i).return_reason_code := l_return_reason;
7822 END LOOP;
7823 CLOSE c_return_reason ;
7824 ELSE
7825 l_document := l_document||NEWLINE;
7826 END IF;
7827 lr_length := length(ord_detail_tbl(i).return_reason_code);
7828 IF (lr_length > 12) THEN
7829 lr_string_in := rtrim(ord_detail_tbl(i).return_reason_code);
7830 lr_string_out := '';
7831 lr_string_left := '';
7832 ibe_workflow_pvt.ParseThisString1(lr_string_in,lr_string_out,lr_string_left);
7833 l_document := l_document||rpad(lr_string_out,11)|| NEWLINE;
7834 lr_length := length(lr_string_left);
7835 IF (lr_length > 0) THEN
7836 lr_string_in := lr_string_left;
7837 ELSE
7838 lr_string_in := '';
7839 END IF;
7840 ELSE
7841 --l_document := l_document || ord_detail_tbl(i).return_reason_code||NEWLINE;
7842 IF lr_length <> 0 THEN
7843 l_print_len := length(ord_detail_tbl(i).return_reason_code);
7844 IF l_view_net_price_flag = 'Y' THEN
7845 l_print_len := 12;
7846 ELSE
7847 --l_document := l_document||rpad(' ',15); -----29-dec-2003
7848 l_print_len := 12;
7849 END IF;
7850 l_document := l_document ||rpad(ord_detail_tbl(i).return_reason_code,l_print_len)||NEWLINE;
7851 END IF;
7852 END IF;
7853 l_string_in := l_string_left;
7854 WHILE length(l_string_in) > 0 or length(lr_string_in) > 0 LOOP
7855 IF (length(l_string_in) > 0) THEN
7856 l_string_out := '';
7857 l_string_left := '';
7858 ibe_workflow_pvt.ParseThisString1(l_string_in,l_string_out,l_string_left);
7859 IF l_view_net_price_flag = 'Y' THEN
7860 l_document := l_document ||rpad(' ',8)||rpad(l_string_out,20)||rpad(' ',32) ;
7861 ELSE
7862 l_document := l_document ||rpad(' ',8)||rpad(l_string_out,20)||rpad(' ',17) ;
7863 END IF;
7864
7865 l_string_in := l_string_left ;
7866 IF length(lr_string_in) > 0 THEN
7867 lr_string_out := '';
7868 lr_string_left := '';
7869 ibe_workflow_pvt.ParseThisString1(lr_string_in,lr_string_out,lr_string_left);
7870 IF l_view_net_price_flag = 'Y' THEN
7871 l_print_len := 11;
7872 ELSE
7873 l_print_len := 11;
7874 END IF;
7875 l_document := l_document ||rpad(lr_string_out,l_print_len)||NEWLINE;
7876 --l_document := l_document ||TAB||TAB||TAB||TAB||TAB||TAB||lr_string_out||NEWLINE ;
7877 lr_string_in := lr_string_left ;
7878 ELSE
7879 l_document := l_document||NEWLINE;
7880 END IF;
7881 ELSE
7882 IF (length(lr_string_in) > 0 ) THEN
7883 lr_string_out := '';
7884 lr_string_left := '';
7885 ibe_workflow_pvt.ParseThisString1(lr_string_in,lr_string_out,lr_string_left);
7886 --l_document := l_document ||TAB||TAB||TAB||TAB||lr_string_out||NEWLINE ;
7887 IF l_view_net_price_flag = 'Y' THEN
7888 l_print_len := 11;
7889 l_document := l_document ||rpad(' ',60)||rpad(lr_string_out,l_print_len)||NEWLINE;
7890 ELSE
7891 l_print_len := 11;
7892 l_document := l_document ||rpad(' ',46)||rpad(lr_string_out,l_print_len)||NEWLINE;
7893 END IF;
7894 --l_document := l_document ||rpad(' ',58)||rpad(lr_string_out,l_print_len)||NEWLINE;
7895 lr_string_in := lr_string_left ;
7896 ELSE
7897 l_document := l_document ||NEWLINE;
7898 END IF;
7899 END IF;
7900 END LOOP;
7901 IF (l_view_net_price_flag = 'Y' and p_tax_flag = fnd_api.g_true) THEN
7902 fnd_message.set_name('IBE','IBE_PRMT_ORD_TAX');
7903 l_temp_str := null;
7904 l_temp_str := fnd_message.get;
7905 IF (to_char(ord_detail_tbl(i).taxes_total) is not null) THEN
7906 --l_document := l_document ||
7907 --lpad(l_temp_str||': '||' '|| to_char(to_number(ord_detail_tbl(i).taxes_total),l_amt_format),72,' ')||NEWLINE;
7908 --ELSE
7909 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(ord_detail_tbl(i).taxes_total));
7910 l_document := l_document ||
7911 lpad(l_temp_str||': '||l_curr_sym|| to_char(to_number(l_can_amt),l_amt_format),59,' ')||NEWLINE;
7912 END IF;
7913 END IF;
7914 l_document := l_document || NEWLINE;
7915 END LOOP;
7916
7917
7918 ----------------------------
7919 x_document := l_document;
7920
7921
7922 EXCEPTION
7923 When Others Then
7924 NULL;
7925 Raise;
7926 END GenerateReturnDetail;
7927
7928
7929 PROCEDURE Generate_order_Detail_wtax(
7930 document_id IN VARCHAR2,
7931 display_type IN VARCHAR2,
7932 document IN OUT NOCOPY VARCHAR2,
7933 document_type IN OUT NOCOPY VARCHAR2
7934 ) is
7935 L_api_name CONSTANT VARCHAR2(30) := 'Generate_order_Detail_wtax';
7936 L_api_version CONSTANT NUMBER := 1.0;
7937
7938 L_quote_flag VARCHAR2(1) := fnd_api.g_false;
7939 L_tax_flag VARCHAR2(1) := fnd_api.g_true;
7940 BEGIN
7941 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7942 IBE_UTIL.DEBUG('Generate_order_Detail_wtax:START');
7943 END IF;
7944 ibe_workflow_pvt.Generate_Detail(
7945 P_item_key => document_id,
7946 p_quote_flag => l_quote_flag,
7947 p_tax_flag => l_tax_flag,
7948 x_document => document
7949 );
7950
7951 IF(display_type = 'text/html') THEN
7952 document_type := 'text/html';
7953 ELSE
7954 document_type := 'text/plain';
7955 END IF;
7956
7957 EXCEPTION
7958 WHEN OTHERS THEN
7959 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
7960 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_order_Detail_wtax');
7961 END IF;
7962
7963 END;
7964 /********************************************************
7965 Generate_Rtn_ord_Detail_wtax: Here the input parameters are
7966 document_id and display_type.
7967 document_id is nothingbut item key.
7968 display_type is text or html type message.
7969 The in and out parameters are document and document_type.
7970 Docuemnt contains order details.
7971 And document type is again text/html.
7972
7973 This procedure is responsible to get order details (with tax) and sent to workflow process.
7974 This procedure is getting called from workflow process.
7975 This procedure calls GenerateReturnDetail procedure. And this procedure sends the
7976 order details in document parameter. This parameter value will be sent back to workflow process
7977 *********************************************************/
7978 PROCEDURE Generate_Rtn_ord_Detail_wtax (
7979 document_id IN VARCHAR2,
7980 display_type IN VARCHAR2,
7981 document IN OUT NOCOPY VARCHAR2,
7982 document_type IN OUT NOCOPY VARCHAR2
7983 ) is
7984 l_api_name CONSTANT VARCHAR2(30) := 'Generate_rtn_ord_Detail_wtax';
7985 l_api_version CONSTANT NUMBER := 1.0;
7986 l_tax_flag VARCHAR2(1) := fnd_api.g_true;
7987
7988 BEGIN
7989
7990 ibe_workflow_pvt.GenerateReturnDetail(
7991 p_item_key => document_id,
7992 p_tax_flag => l_tax_flag,
7993 x_document => document
7994 );
7995
7996 IF(display_type = 'text/html') THEN
7997 document_type := 'text/html';
7998 ELSE
7999 document_type := 'text/plain';
8000 END IF;
8001
8002 EXCEPTION
8003 WHEN OTHERS THEN
8004 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8005 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_rtn_ord_Detail_wtax');
8006 END IF;
8007
8008 END Generate_Rtn_ord_Detail_wtax ;
8009
8010
8011
8012 --Added by mannamra
8013 PROCEDURE Generate_quote_Detail_wtax(
8014 document_id IN VARCHAR2,
8015 display_type IN VARCHAR2,
8016 document IN OUT NOCOPY VARCHAR2,
8017 document_type IN OUT NOCOPY VARCHAR2
8018 ) is
8019 L_api_name CONSTANT VARCHAR2(30) := 'Generate_quote_Detail_wtax';
8020 L_api_version CONSTANT NUMBER := 1.0;
8021
8022 L_quote_flag VARCHAR2(1) := fnd_api.g_true;
8023 L_tax_flag VARCHAR2(1) := fnd_api.g_true;
8024 BEGIN
8025 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8026 IBE_UTIL.DEBUG('Generate_quote_Detail_wtax:START');
8027 END IF;
8028 ibe_workflow_pvt.Generate_Detail(
8029 P_item_key => document_id,
8030 p_quote_flag => l_quote_flag,
8031 p_tax_flag => l_tax_flag,
8032 x_document => document
8033 );
8034
8035 IF(display_type = 'text/html') THEN
8036 document_type := 'text/html';
8037 ELSE
8038 document_type := 'text/plain';
8039 END IF;
8040
8041 EXCEPTION
8042 WHEN OTHERS THEN
8043 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8044 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_quote_Detail_wtax');
8045 END IF;
8046
8047 END;
8048 --Added by mannamra
8049 PROCEDURE Generate_order_Detail_notax(
8050 document_id IN VARCHAR2,
8051 display_type IN VARCHAR2,
8052 document IN OUT NOCOPY VARCHAR2,
8053 document_type IN OUT NOCOPY VARCHAR2
8054 ) is
8055 L_api_name CONSTANT VARCHAR2(30) := 'Generate_order_Detail_notax';
8056 L_api_version CONSTANT NUMBER := 1.0;
8057
8058 L_quote_flag VARCHAR2(1) := fnd_api.g_false;
8059 L_tax_flag VARCHAR2(1) := fnd_api.g_false;
8060 BEGIN
8061 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8062 IBE_UTIL.DEBUG('Generate_order_Detail_notax:START');
8063 END IF;
8064 ----DBMS_OUTPUT.PUT('Generate_order_Detail_notax:START');
8065 ibe_workflow_pvt.Generate_Detail(
8066 P_item_key => document_id,
8067 p_quote_flag => l_quote_flag,
8068 p_tax_flag => l_tax_flag,
8069 x_document => document
8070 );
8071
8072 IF(display_type = 'text/html') THEN
8073 document_type := 'text/html';
8074 ELSE
8075 document_type := 'text/plain';
8076 END IF;
8077 EXCEPTION
8078 WHEN OTHERS THEN
8079 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8080 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_order_Detail_notax');
8081 END IF;
8082
8083 END;
8084
8085 /********************************************************
8086 Generate_Rtn_ord_Detail_notax: Here the input parameters are
8087 document_id and display_type.
8088 document_id is nothingbut item key.
8089 display_type is text or html type message.
8090 The in and out parameters are document and document_type.
8091 Docuemnt contains order details.
8092 And document type is again text/html.
8093
8094 This procedure is responsible to get order details (without tax) and sent to workflow process.
8095 This procedure is getting called from workflow process.
8096 This procedure calls GenerateReturnDetail procedure. And this procedure sends the
8097 order details in document parameter. This parameter value will be sent back to workflow process
8098 *********************************************************/
8099 PROCEDURE Generate_Rtn_ord_Detail_notax (
8100 document_id IN VARCHAR2,
8101 display_type IN VARCHAR2,
8102 document IN OUT NOCOPY VARCHAR2,
8103 document_type IN OUT NOCOPY VARCHAR2
8104 ) is
8105 l_api_name CONSTANT VARCHAR2(30) := 'Generate_rtn_ord_Detail_notax';
8106 l_api_version CONSTANT NUMBER := 1.0;
8107 l_tax_flag VARCHAR2(1) := fnd_api.g_false;
8108
8109 BEGIN
8110
8111 ibe_workflow_pvt.GenerateReturnDetail(
8112 p_item_key => document_id,
8113 p_tax_flag => l_tax_flag,
8114 x_document => document
8115 );
8116
8117 IF(display_type = 'text/html') THEN
8118 document_type := 'text/html';
8119 ELSE
8120 document_type := 'text/plain';
8121 END IF;
8122
8123 EXCEPTION
8124 WHEN OTHERS THEN
8125 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8126 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_rtn_ord_Detail_notax');
8127 END IF;
8128
8129 END Generate_Rtn_ord_Detail_notax;
8130
8131
8132
8133 --Added by mannamra
8134 PROCEDURE Generate_quote_Detail_notax(
8135 document_id IN VARCHAR2,
8136 display_type IN VARCHAR2,
8137 document IN OUT NOCOPY VARCHAR2,
8138 document_type IN OUT NOCOPY VARCHAR2
8139 ) is
8140 L_api_name CONSTANT VARCHAR2(30) := 'Generate_quote_Detail_notax';
8141 L_api_version CONSTANT NUMBER := 1.0;
8142
8143 L_quote_flag VARCHAR2(1) := fnd_api.g_true;
8144 L_tax_flag VARCHAR2(1) := fnd_api.g_false;
8145 BEGIN
8146 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8147 IBE_UTIL.DEBUG('Generate_order_Detail_notax:START');
8148 END IF;
8149 ibe_workflow_pvt.Generate_Detail(
8150 P_item_key => document_id,
8151 p_quote_flag => l_quote_flag,
8152 p_tax_flag => l_tax_flag,
8153 x_document => document
8154 );
8155
8156 IF(display_type = 'text/html') THEN
8157 document_type := 'text/html';
8158 ELSE
8159 document_type := 'text/plain';
8160 END IF;
8161
8162 EXCEPTION
8163 WHEN OTHERS THEN
8164 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8165 IBE_UTIL.DEBUG('Unidentified error in ibe_workflow_pvt.Generate_quote_Detail_notax');
8166 END IF;
8167
8168 END;
8169 --existing API
8170 PROCEDURE GenerateDetail(
8171 document_id IN VARCHAR2,
8172 display_type IN VARCHAR2,
8173 document IN OUT NOCOPY VARCHAR2,
8174 document_type IN OUT NOCOPY VARCHAR2
8175 )IS
8176
8177 l_item_type wf_items.item_type%TYPE;
8178 l_item_key wf_items.item_key%TYPE;
8179 l_quote_id NUMBER;
8180 l_event_type VARCHAR2(20);
8181 l_document VARCHAR2(32000) := '';
8182 l_ship_flag VARCHAR2(1);
8183 l_string_in VARCHAR2(250);
8184 l_string_out VARCHAR2(250);
8185 l_string_left VARCHAR2(250);
8186 l_order_id NUMBER;
8187
8188 l_amt_format Varchar2(50);
8189 l_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
8190
8191 l_temp_str VARCHAR2(2000):='';
8192 l_view_net_price_flag VARCHAR2(1);
8193
8194 Cursor c_ship_flag(p_line_id NUMBER) IS
8195 SELECT msi.shippable_item_flag
8196 FROM oe_order_lines_all line, OE_SYSTEM_PARAMETERS_ALL osp,
8197 mtl_system_items_kfv msi
8198 WHERE line.line_id = p_line_id
8199 AND line.org_id = osp.org_id
8200 AND osp.master_organization_id = msi.organization_id
8201 AND line.inventory_item_id = msi.inventory_item_id;
8202
8203 BEGIN
8204
8205 l_item_key := document_id;
8206 ----DBMS_OUTPUT.PUT('Calling GenerateDetail - l_item_key - '||l_item_key);
8207 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8208 ibe_util.debug('GenerateDetail - l_item_key - '||l_item_key);
8209 END IF;
8210
8211 l_quote_id := wf_engine.GetItemAttrText (
8212 itemtype => g_itemType,
8213 itemkey => l_item_key,
8214 aname => 'QUOTEID'
8215 );
8216 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8217 ibe_util.debug('GenerateDetail - l_quote_id - '||l_quote_id);
8218 END IF;
8219
8220 l_order_id := wf_engine.GetItemAttrText (
8221 itemtype => g_itemType,
8222 itemkey => l_item_key,
8223 aname => 'ORDERID'
8224 );
8225
8226 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8227 ibe_util.debug('GenerateDetail - l_order_id - '||l_order_id);
8228 END IF;
8229
8230
8231 l_event_type := wf_engine.GetItemAttrText (
8232 itemtype => g_itemType,
8233 itemkey => l_item_key,
8234 aname => 'EVENTTYPE'
8235 );
8236
8237
8238 l_view_net_price_flag:= wf_engine.GetItemAttrText (
8239 itemtype => g_itemType,
8240 itemkey => l_item_key,
8241 aname => 'VIEWNETPRICE'
8242 );
8243
8244
8245 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8246 ibe_util.debug('GenerateDetail - l_event_type - '|| l_event_type);
8247 END IF;
8248
8249 IF l_view_net_price_flag = 'Y' THEN
8250 For ord_hd_rec In c_order_header(l_order_id) Loop
8251 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK(ord_hd_rec.transactional_curr_code,18);
8252
8253 For curr_sym_rec In c_curr_symbol(ord_hd_rec.transactional_curr_code)
8254 Loop
8255 l_curr_sym := trim(nvl(curr_sym_rec.symbol,' '));
8256 End Loop;
8257
8258 End Loop;
8259 END IF;
8260
8261 OPEN c_order_detail(l_order_id);
8262 LOOP
8263 FETCH c_order_detail INTO g_detail_rec;
8264 EXIT WHEN c_order_detail%NOTFOUND;
8265
8266
8267 l_ship_flag := null;
8268
8269 FOR c_ship_rec IN c_ship_flag(g_detail_rec.line_id) LOOP
8270 l_ship_flag := c_ship_rec.shippable_item_flag;
8271 END LOOP;
8272
8273 l_string_in := rtrim(g_detail_rec.item_description);
8274 l_string_out := '';
8275 l_string_left := '';
8276 ibe_workflow_pvt.ParseThisString(l_string_in,l_string_out,l_string_left);
8277
8278 l_document := l_document || l_string_out ||TAB;
8279 l_document := l_document || to_char(g_detail_rec.ordered_quantity)||TAB;
8280 l_document := l_document || l_ship_flag;
8281 IF l_view_net_price_flag = 'Y' THEN
8282 l_document := l_document || lpad(l_curr_sym || to_char(g_detail_rec.lines_total,l_amt_format), 23, ' ');
8283 END IF;
8284
8285 l_string_in := l_string_left;
8286 WHILE length(l_string_in) > 0 LOOP
8287 l_string_out := '';
8288 l_string_left := '';
8289 ibe_workflow_pvt.ParseThisString(l_string_in,l_string_out,l_string_left);
8290 l_document := l_document || l_string_out ||NEWLINE;
8291 l_string_in := l_string_left;
8292 END LOOP;
8293
8294 IF l_view_net_price_flag = 'Y' THEN
8295 fnd_message.set_name('IBE','IBE_PRMT_ORD_TAX');
8296 l_temp_str := null;
8297 l_temp_str := fnd_message.get;
8298
8299 l_document := l_document ||
8300 lpad(l_temp_str||': '||l_curr_sym|| to_char(g_detail_rec.taxes_total,l_amt_format),72,' ')||
8301 NEWLINE;
8302 END IF;
8303
8304 l_document := l_document || NEWLINE;
8305
8306 END LOOP;
8307 CLOSE c_order_detail;
8308
8309 document := l_document;
8310
8311 IF(display_type = 'text/html') THEN
8312 document_type := 'text/html';
8313 ELSE
8314 document_type := 'text/plain';
8315 END IF;
8316
8317 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8318 ibe_util.debug('GenerateDetail - l_document - ' ||NEWLINE||l_document);
8319 END IF;
8320
8321 EXCEPTION
8322 When Others Then
8323 IF c_order_detail%ISOPEN THEN
8324 CLOSE c_order_detail;
8325 END IF;
8326 Raise;
8327 END GenerateDetail;
8328
8329 PROCEDURE GenerateFooter(
8330 document_id IN VARCHAR2,
8331 display_type IN VARCHAR2,
8332 document IN OUT NOCOPY VARCHAR2,
8333 document_type IN OUT NOCOPY VARCHAR2
8334 )IS
8335
8336 l_item_type wf_items.item_type%TYPE;
8337 l_item_key wf_items.item_key%TYPE;
8338 l_quote_id NUMBER;
8339 l_event_type VARCHAR2(20);
8340 l_document VARCHAR2(32000) := '';
8341 l_temp_str VARCHAR2(2000):='';
8342 l_sub_total NUMBER;
8343 l_order_id NUMBER;
8344 l_view_net_price_flag VARCHAR2(1);
8345
8346
8347 l_amt_format Varchar2(50);
8348 l_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
8349
8350 l_can_amt VARCHAR2(50);
8351 l_paynow varchar2(1);
8352 l_reccharge varchar2(1);
8353
8354 Cursor c_macd_order_header (c_order_id NUMBER) IS
8355 Select oe_totals_grp.Get_PayNow_Total(oh.header_id,null,'LINES') PayNow_lines_total,
8356 oe_totals_grp.Get_PayNow_Total(oh.header_id,null,'CHARGES') PayNow_charges_total,
8357 oe_totals_grp.Get_PayNow_Total(oh.header_id,null,'TAXES') PayNow_taxes_total,
8358 oe_totals_grp.Get_PayNow_Total(oh.header_id,null,'ALL') PayNow_order_total,
8359 oh.transactional_curr_code,
8360 oe_totals_grp.Get_Order_Total(oh.header_id,null,'ALL') order_total,
8361 oh.order_number
8362 from oe_order_headers_all oh
8363 where oh.header_id = c_order_id;
8364 g_macd_ord_rec c_macd_order_header%ROWTYPE;
8365 l_rec_charge_tbl OE_OE_TOTALS_SUMMARY.Rec_Charges_Tbl_Type;
8366
8367 i number;
8368
8369 BEGIN
8370
8371 l_item_key := document_id;
8372 ----DBMS_OUTPUT.PUT('Calling GenerateFooter - l_item_key - '||l_item_key);
8373 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8374 ibe_util.debug('GenerateFooter - l_item_key - '||l_item_key);
8375 END IF;
8376
8377 l_quote_id := wf_engine.GetItemAttrText (
8378 itemtype => g_itemType,
8379 itemkey => l_item_key,
8380 aname => 'QUOTEID'
8381 );
8382 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8383 ibe_util.debug('GenerateFooter - l_quote_id - '||l_quote_id);
8384 END IF;
8385
8386 l_order_id := wf_engine.GetItemAttrText (
8387 itemtype => g_itemType,
8388 itemkey => l_item_key,
8389 aname => 'ORDERID'
8390 );
8391
8392 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8393 ibe_util.debug('GenerateFooter - l_order_id - '||l_order_id);
8394 END IF;
8395
8396 l_event_type := wf_engine.GetItemAttrText (
8397 itemtype => g_itemType,
8398 itemkey => l_item_key,
8399 aname => 'EVENTTYPE'
8400 );
8401
8402
8403 l_view_net_price_flag:= wf_engine.GetItemAttrText (
8404 itemtype => g_itemType,
8405 itemkey => l_item_key,
8406 aname => 'VIEWNETPRICE'
8407 );
8408
8409 l_paynow := wf_engine.GetItemAttrText (
8410 itemtype => g_itemType,
8411 itemkey => l_item_key,
8412 aname => 'PAYNOWENABLED'
8413 );
8414 l_reccharge := wf_engine.GetItemAttrText (
8415 itemtype => g_itemType,
8416 itemkey => l_item_key,
8417 aname => 'RECCHARGEENABLED'
8418 );
8419
8420 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8421 ibe_util.debug('l_reccharge and l_paynow'||l_reccharge||'paynow'||l_paynow);
8422 ibe_util.debug('Event Type ' || l_event_type);
8423 ibe_util.debug('l_view_net_price_flag'||l_view_net_price_flag);
8424 END IF;
8425
8426 if(l_reccharge = 'Y' and l_event_type <> 'RETURNORDER') THEN
8427 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8428 ibe_util.debug('GenerateFooter - MACD Order Footer '|| l_event_type);
8429 END IF;
8430 OPEN c_macd_order_header(l_order_id);
8431 LOOP
8432 FETCH c_macd_order_header INTO g_macd_ord_rec;
8433 EXIT WHEN c_macd_order_header%NOTFOUND;
8434
8435 IF l_view_net_price_flag = 'Y' THEN
8436 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK(g_macd_ord_rec.transactional_curr_code,22);
8437 For curr_sym_rec In c_curr_symbol(g_macd_ord_rec.transactional_curr_code) Loop
8438 l_curr_sym := trim(nvl(curr_sym_rec.symbol,' '));
8439 End Loop;
8440 END IF;
8441 IF l_view_net_price_flag = 'Y' THEN
8442 fnd_message.set_name('IBE','IBE_PRMT_OT_ONE_TIME_PRICE');
8443 l_temp_str := null;
8444 l_temp_str := fnd_message.get;
8445 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_ord_rec.order_total));
8446 l_document := l_document|| lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt), l_amt_format), 20, ' ')||NEWLINE;
8447
8448 --Call OM to find the recurring totals
8449 OE_Totals_GRP.GET_RECURRING_TOTALS
8450 (
8451 p_header_id => l_order_id,
8452 x_rec_charges_tbl => l_rec_charge_tbl
8453 );
8454 IF(l_rec_charge_tbl is not null) THEN
8455 i := l_rec_charge_tbl.FIRST;
8456 WHILE i is not null
8457 LOOP
8458 l_document := l_document || lpad(l_rec_charge_tbl(i).charge_periodicity_meaning,51,' ');
8459 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(l_rec_charge_tbl(i).rec_subtotal));
8460 l_document := l_document || lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
8461 i := l_rec_charge_tbl.NEXT(i);
8462 END LOOP;
8463 END IF;
8464 END IF;
8465 END LOOP;
8466 CLOSE c_macd_order_header;
8467 ELSE
8468 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8469 ibe_util.debug('GenerateFooter - NON-MACD Order Footer l_event_type - '|| l_event_type);
8470 END IF;
8471
8472 OPEN c_order_header(l_order_id);
8473 LOOP
8474 FETCH c_order_header INTO g_header_rec;
8475 EXIT WHEN c_order_header%NOTFOUND;
8476
8477
8478 IF l_view_net_price_flag = 'Y' THEN
8479 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK(g_header_rec.transactional_curr_code,22);
8480
8481 For curr_sym_rec In c_curr_symbol(g_header_rec.transactional_curr_code) Loop
8482 l_curr_sym := trim(nvl(curr_sym_rec.symbol,' '));
8483 End Loop;
8484 END IF;
8485
8486
8487 --IF (display_type = 'text/plain' ) THEN
8488 IF l_view_net_price_flag = 'Y' THEN
8489
8490 fnd_message.set_name('IBE','IBE_PRMT_SUBTOTAL_COLON');
8491 l_temp_str := null;
8492 l_temp_str := fnd_message.get;
8493
8494 l_sub_total := g_header_rec.lines_total;
8495 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(l_sub_total));
8496 IF l_event_type = 'RETURNORDER' THEN
8497 l_document := l_document ||lpad(l_temp_str,44,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),14,' ')||NEWLINE;
8498 ELSE
8499 l_document := l_document ||lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
8500 END IF;
8501 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_header_rec.charges_total));
8502 IF l_event_type = 'RETURNORDER' THEN
8503 fnd_message.set_name('IBE','IBE_OT_RET_CHARGES');
8504 l_temp_str := null;
8505 l_temp_str := fnd_message.get;
8506
8507 l_document := l_document || lpad(l_temp_str,44,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),14,' ')||NEWLINE;
8508 ELSE
8509 fnd_message.set_name('IBE','IBE_PRMT_SHIP_HAND_COLON');
8510 l_temp_str := null;
8511 l_temp_str := fnd_message.get;
8512
8513 l_document := l_document || lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
8514 END IF;
8515 fnd_message.set_name('IBE','IBE_PRMT_TAX_EST_COLON');
8516 l_temp_str := null;
8517 l_temp_str := fnd_message.get;
8518 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_header_rec.taxes_total));
8519 IF l_event_type = 'RETURNORDER' THEN
8520 l_document := l_document || lpad(l_temp_str,44,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),14,' ')||NEWLINE;
8521 ELSE
8522 l_document := l_document || lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
8523 END IF;
8524
8525
8526 fnd_message.set_name('IBE','IBE_PRMT_SC_TOTAL2');
8527 l_temp_str := null;
8528 l_temp_str := fnd_message.get;
8529 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_header_rec.order_total));
8530 IF l_event_type = 'RETURNORDER' THEN
8531 l_document := l_document|| lpad(l_temp_str,44,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt), l_amt_format), 14, ' ')||NEWLINE;
8532 ELSE
8533 l_document := l_document|| lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt), l_amt_format), 20, ' ')||NEWLINE;
8534 END IF;
8535 END IF;
8536 --ELSE
8537 --null;
8538 --END IF;
8539 END LOOP;
8540 CLOSE c_order_header;
8541 END IF; --Non MACD Footer
8542
8543 --Amount due with order display
8544 if (l_reccharge = 'Y' OR l_paynow = 'Y') then
8545 OPEN c_macd_order_header(l_order_id);
8546 LOOP
8547 FETCH c_macd_order_header INTO g_macd_ord_rec;
8548 EXIT WHEN c_macd_order_header%NOTFOUND;
8549
8550 IF l_view_net_price_flag = 'Y' THEN
8551 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK(g_macd_ord_rec.transactional_curr_code,22);
8552 For curr_sym_rec In c_curr_symbol(g_macd_ord_rec.transactional_curr_code) Loop
8553 l_curr_sym := trim(nvl(curr_sym_rec.symbol,' '));
8554 End Loop;
8555 END IF;
8556 IF l_view_net_price_flag = 'Y' THEN
8557 fnd_message.set_name('IBE','IBE_PRMT_SC_PAY_NOW_CHARGES');
8558 l_temp_str := null;
8559 l_temp_str := fnd_message.get;
8560 l_document := l_document || lpad(l_temp_str,51,' ')||NEWLINE;
8561 l_document := l_document || lpad('-',(51-length(l_temp_str)))||rpad('-',(71-(51-(length(l_temp_str)))),'-')||NEWLINE;
8562
8563 fnd_message.set_name('IBE','IBE_PRMT_SUBTOTAL_COLON');
8564 l_temp_str := null;
8565 l_temp_str := fnd_message.get;
8566 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_ord_rec.paynow_lines_total));
8567 l_document := l_document ||lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
8568
8569 fnd_message.set_name('IBE','IBE_PRMT_TAX_COL');
8570 l_temp_str := null;
8571 l_temp_str := fnd_message.get;
8572 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_ord_rec.paynow_taxes_total));
8573 l_document := l_document || lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
8574
8575 fnd_message.set_name('IBE','IBE_PRMT_SHIP_HAND_COLON');
8576 l_temp_str := null;
8577 l_temp_str := fnd_message.get;
8578 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_ord_rec.paynow_charges_total));
8579 l_document := l_document || lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
8580
8581 fnd_message.set_name('IBE','IBE_PRMT_SC_PN_TOTAL_COL');
8582 l_temp_str := null;
8583 l_temp_str := fnd_message.get;
8584 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_ord_rec.paynow_order_total));
8585 l_document := l_document|| lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt), l_amt_format), 20, ' ');
8586 END IF;
8587 END LOOP;
8588 CLOSE c_macd_order_header;
8589 end if;
8590
8591 document := l_document;
8592
8593 IF(display_type = 'text/html') THEN
8594 document_type := 'text/html';
8595 ELSE
8596 document_type := 'text/plain';
8597 END IF;
8598 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8599 ibe_util.debug('GenerateFooter - l_document - '||NEWLINE|| l_document);
8600 END IF;
8601
8602 EXCEPTION
8603 When Others Then
8604 IF c_order_header%ISOPEN THEN
8605 CLOSE c_order_header;
8606 END IF;
8607 Raise;
8608 END GenerateFooter;
8609
8610 PROCEDURE GenerateQuoteHeader(
8611 document_id IN VARCHAR2,
8612 display_type IN VARCHAR2,
8613 document IN OUT NOCOPY VARCHAR2,
8614 document_type IN OUT NOCOPY VARCHAR2
8615 ) IS
8616
8617 l_item_type wf_items.item_type%TYPE := 'IBEALERT';
8618 l_item_key wf_items.item_key%TYPE;
8619 l_quote_id NUMBER;
8620 l_event_type VARCHAR2(20);
8621 l_contract_id NUMBER;
8622 l_contract_Number VARCHAR2(120);
8623 l_contract_Modifier VARCHAR2(120);
8624 l_comments VARCHAR2(2000);
8625 l_contact_name VARCHAR2(400);
8626 l_contact_number VARCHAR2(70);
8627 l_contact_email hz_contact_points.email_address%TYPE;
8628 l_bill_to_party_name hz_parties.party_name%TYPE;
8629 l_bill_to_name VARCHAR2(400);
8630 l_bill_to_number VARCHAR2(70);
8631 l_bill_to_fax VARCHAR2(70);
8632 l_bill_to_address hz_locations.address1%TYPE;
8633 l_bill_to_city hz_locations.city%TYPE;
8634 l_bill_to_state hz_locations.state%TYPE;
8635 l_bill_to_zip hz_locations.postal_code%TYPE;
8636 l_bill_to_country hz_locations.country%TYPE;
8637 l_ship_to_site_id aso_shipments.ship_to_party_site_id%TYPE;
8638 l_ship_to_party_id aso_shipments.ship_to_party_id%TYPE;
8639 l_ship_to_cust_account_id aso_shipments.ship_to_cust_account_id%TYPE;
8640 l_ship_method_code aso_shipments.ship_method_code%TYPE;
8641
8642 l_ship_method varchar2(80);
8643
8644 l_ship_to_party_name hz_parties.party_name%TYPE;
8645 l_ship_to_name VARCHAR2(400);
8646 l_ship_to_number VARCHAR2(70);
8647 l_ship_to_fax VARCHAR2(70);
8648 l_ship_to_address hz_locations.address1%TYPE;
8649 l_ship_to_city hz_locations.city%TYPE;
8650 l_ship_to_state hz_locations.state%TYPE;
8651 l_ship_to_zip hz_locations.postal_code%TYPE;
8652 l_ship_to_country hz_locations.country%TYPE;
8653 l_document VARCHAR2(32000) := '';
8654 l_temp_str VARCHAR2(2000):='';
8655
8656 Cursor c_hz_locations(p_loc_site_id NUMBER) IS
8657 SELECT rtrim(address1) || ' ' || rtrim(address2) || ' ' || rtrim(address3) || ' ' || rtrim(address4) loc_address,
8658 rtrim(city) loc_city,
8659 rtrim(state)||'/' || rtrim(province) loc_state,
8660 rtrim(postal_code) loc_zip,
8661 rtrim(country) loc_country
8662 FROM hz_locations
8663 WHERE location_id = ( SELECT location_id
8664 FROM hz_party_sites
8665 WHERE party_site_id = p_loc_site_id);
8666 Cursor c_aso_shipments(p_quote_id NUMBER) IS
8667 SELECT ship_to_cust_account_id, ship_to_party_site_id, ship_to_party_id, ship_method_code
8668 FROM aso_shipments
8669 WHERE quote_header_id = p_quote_id
8670 AND quote_line_id IS NULL
8671 AND rownum = 1;
8672
8673
8674 Cursor c_hz_cust_accounts(p_cust_account_id NUMBER) IS
8675 SELECT hc.party_id,hp.Party_Name,hp.Person_First_Name,hp.Person_Middle_Name,hp.Person_Last_name,hp.party_type
8676 FROM hz_cust_accounts hc, hz_parties hp
8677 WHERE cust_account_id = p_cust_account_id
8678 AND hc.party_id = hp.party_id;
8679
8680 l_sold_contact_party_id Number;
8681 l_bill_contact_party_id Number;
8682 l_ship_contact_party_id Number;
8683
8684
8685 BEGIN
8686
8687 l_item_key := document_id;
8688
8689 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8690 ibe_util.debug('GenerateQuoteHeader - l_item_key - '||l_item_key);
8691 END IF;
8692
8693 l_quote_id := wf_engine.GetItemAttrText (
8694 itemtype => g_ItemType,
8695 itemkey => l_item_key,
8696 aname => 'QUOTEID'
8697 );
8698 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8699 ibe_util.debug('GenerateQuoteHeader - l_quote_id - '||l_quote_id);
8700 END IF;
8701
8702 l_event_type := wf_engine.GetItemAttrText (
8703 itemtype => g_ItemType,
8704 itemkey => l_item_key,
8705 aname => 'EVENTTYPE'
8706 );
8707
8708 l_contract_id := wf_engine.GetItemAttrText (
8709 itemtype => g_ItemType,
8710 itemkey => l_item_key,
8711 aname => 'CONTRACTNO'
8712 );
8713
8714
8715 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8716 ibe_util.debug('GenerateQuoteHeader - l_event_type - '|| l_event_type);
8717 END IF;
8718
8719 FOR c_contract_rec In c_contract_header(l_contract_id) LOOP
8720 l_contract_number := c_contract_rec.contract_number;
8721 l_contract_modifier := c_contract_rec.contract_number_modifier;
8722 END LOOP;
8723
8724
8725 OPEN c_quote_header(l_quote_id);
8726 LOOP
8727 FETCH c_quote_header INTO g_quote_header_rec;
8728 EXIT WHEN c_quote_header%NOTFOUND;
8729
8730 /* Get all contact information */
8731
8732 l_contact_name := null;
8733 l_sold_contact_party_id := null;
8734
8735 FOR c_hz_parties_rec IN c_hz_parties(g_quote_header_rec.party_id) LOOP
8736 If c_hz_parties_rec.party_type = 'PARTY_RELATIONSHIP' Then
8737 l_contact_name := upper(rtrim(c_hz_parties_rec.person_first_name))||' '||upper(rtrim(c_hz_parties_rec.person_last_name));
8738
8739 l_sold_contact_party_id := g_quote_header_rec.party_id;
8740 End If;
8741 END LOOP;
8742
8743
8744 If l_sold_contact_party_id is null Then
8745 FOR c_hz_cust_acct_rec IN c_hz_cust_accounts(g_quote_header_rec.cust_account_id) LOOP
8746 l_contact_name := upper(rtrim(c_hz_cust_acct_rec.person_first_name))||' '||upper(rtrim(c_hz_cust_acct_rec.person_last_name));
8747 l_sold_contact_party_id := c_hz_cust_acct_rec.party_id;
8748 End Loop;
8749 End If;
8750
8751 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8752 ibe_util.debug('GenerateQuoteHeader - l_contact_name '|| l_contact_name);
8753 END IF;
8754
8755 l_contact_number := null;
8756 l_contact_email := null;
8757
8758
8759 FOR c_hz_contact_rec IN c_hz_contact_points(l_sold_contact_party_id) LOOP
8760
8761 If (c_hz_contact_rec.contact_point_type = 'PHONE' AND c_hz_contact_rec.phone_line_type = 'GEN') AND (l_contact_number IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
8762
8763 l_contact_number := trim(c_hz_contact_rec.Phone_Country_code||' '||c_hz_contact_rec.Phone_area_code||' '||c_hz_contact_rec.Phone_number);
8764
8765 Elsif c_hz_contact_rec.contact_point_type = 'EMAIL' AND (l_contact_email IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
8766
8767 l_contact_email := c_hz_contact_rec.email_address;
8768
8769 End If;
8770 END LOOP;
8771
8772 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8773 ibe_util.debug('GenerateQuoteHeader - l_contact_number - '|| l_contact_number);
8774 ibe_util.debug('GenerateQuoteHeader - l_contact_email - '|| l_contact_email);
8775 END IF;
8776
8777 /* Get all billing information */
8778
8779 l_bill_to_party_name := null;
8780 l_bill_to_name := null;
8781
8782
8783 /* Bill Customer Info. From Invoice_To_Cust_Account_ID */
8784
8785 FOR c_hz_cust_acct_rec IN c_hz_cust_accounts(nvl(g_quote_header_rec.invoice_to_cust_account_id,g_quote_header_rec.cust_account_id)) LOOP
8786 l_bill_to_party_name := rtrim(c_hz_cust_acct_rec.party_name);
8787 l_bill_to_name := upper(rtrim(c_hz_cust_acct_rec.person_first_name))||' '||upper(rtrim(c_hz_cust_acct_rec.person_last_name));
8788 l_bill_contact_party_id := c_hz_cust_acct_rec.party_id;
8789 End Loop;
8790
8791 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8792 ibe_util.debug('GenerateQuoteHeader - bill_party_name - '||l_bill_to_party_name);
8793 ibe_util.debug('GenerateQuoteHeader - bill_name - '||l_bill_to_name);
8794 END IF;
8795
8796
8797 l_bill_to_number := null;
8798 l_bill_to_fax := null;
8799
8800 /* Bill Contact Info. From Invoice_To_Party_ID (PARTY_RELATIONSHIP) OR Bill Customer Party Id. */
8801
8802 If g_quote_header_rec.invoice_to_party_id is not null Then
8803 FOR c_hz_parties_rec IN c_hz_parties(g_quote_header_rec.invoice_to_party_id) LOOP
8804 If c_hz_parties_rec.party_type = 'PARTY_RELATIONSHIP' Then
8805 l_bill_contact_party_id := g_quote_header_rec.party_id;
8806 End If;
8807 END LOOP;
8808 End if;
8809
8810 FOR c_hz_contact_rec IN c_hz_contact_points(l_bill_contact_party_id) LOOP
8811
8812 If (c_hz_contact_rec.contact_point_type = 'PHONE' AND c_hz_contact_rec.phone_line_type = 'GEN') AND (l_bill_to_number IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
8813
8814 l_bill_to_number := trim(c_hz_contact_rec.Phone_Country_code||' '||c_hz_contact_rec.Phone_area_code||' '||c_hz_contact_rec.Phone_number);
8815
8816 Elsif (c_hz_contact_rec.contact_point_type = 'PHONE' AND c_hz_contact_rec.phone_line_type = 'FAX') AND (l_bill_to_fax IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
8817
8818 l_bill_to_fax := trim(c_hz_contact_rec.Phone_Country_code||' '||c_hz_contact_rec.Phone_area_code||' '||c_hz_contact_rec.Phone_number);
8819
8820 End If;
8821 END LOOP;
8822
8823 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8824 ibe_util.debug('GenerateQuoteHeader - bill_party_number - '||l_bill_to_number);
8825 ibe_util.debug('GenerateQuoteHeader - bill_fax - '||l_bill_to_fax);
8826 END IF;
8827
8828 l_bill_to_address := null;
8829 l_bill_to_city := null;
8830 l_bill_to_state := null;
8831 l_bill_to_zip := null;
8832 l_bill_to_country := null;
8833
8834 /* Bill to Location id using invoice_to_party_site_id */
8835
8836 FOR c_hz_locations_rec IN c_hz_locations(g_quote_header_rec.invoice_to_party_site_id) LOOP
8837 l_bill_to_address := c_hz_locations_rec.loc_address;
8838 l_bill_to_city := c_hz_locations_rec.loc_city;
8839 l_bill_to_state := c_hz_locations_rec.loc_state;
8840 l_bill_to_zip := c_hz_locations_rec.loc_zip;
8841 l_bill_to_country := c_hz_locations_rec.loc_country;
8842
8843 END LOOP;
8844
8845 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8846 ibe_util.debug('GenerateQuoteHeader - bill_address - '||l_bill_to_address);
8847 ibe_util.debug('GenerateQuoteHeader - bill_city - '||l_bill_to_city);
8848 ibe_util.debug('GenerateQuoteHeader - bill_state - '||l_bill_to_state);
8849 ibe_util.debug('GenerateQuoteHeader - bill_zip - '||l_bill_to_zip);
8850 ibe_util.debug('GenerateQuoteHeader - bill_country - '||l_bill_to_country);
8851 END IF;
8852
8853 /* Get all shipping information */
8854
8855 l_ship_to_site_id := null;
8856 l_ship_to_party_id := null;
8857 l_ship_method_code := null;
8858
8859 FOR c_aso_shipments_rec IN c_aso_shipments(l_quote_id) LOOP
8860 l_ship_to_site_id := c_aso_shipments_rec.ship_to_party_site_id;
8861 l_ship_to_cust_account_id := c_aso_shipments_rec.ship_to_cust_account_id;
8862 l_ship_to_party_id := c_aso_shipments_rec.ship_to_party_id;
8863 l_ship_method_code := c_aso_shipments_rec.ship_method_code;
8864 END LOOP;
8865
8866 For c_ship_method_rec in c_ship_methods(l_ship_method_code) LOOP
8867 l_Ship_Method := c_ship_method_rec.Meaning;
8868 End Loop;
8869
8870 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8871 ibe_util.debug('GenerateQuoteHeader - ship_to_site_id - '||l_ship_to_site_id);
8872 ibe_util.debug('GenerateQuoteHeader - ship_to_party_id - '||l_ship_to_party_id);
8873 ibe_util.debug('GenerateQuoteHeader - ship_to_method - '||l_ship_method_code);
8874 END IF;
8875
8876 /* Shipping Customer Information - ship_to_cust_account_id */
8877
8878
8879
8880
8881 FOR c_hz_cust_acct_rec IN c_hz_cust_accounts(nvl(l_ship_to_cust_account_id,g_quote_header_rec.cust_account_id)) LOOP
8882 l_ship_to_party_name := rtrim(c_hz_cust_acct_rec.party_name);
8883 l_ship_to_name := upper(rtrim(c_hz_cust_acct_rec.person_first_name))||' '||upper(rtrim(c_hz_cust_acct_rec.person_last_name));
8884 l_ship_contact_party_id := c_hz_cust_acct_rec.party_id;
8885 End Loop;
8886
8887
8888 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8889 ibe_util.debug('GenerateQuoteHeader - ship_to_party_name - '||l_ship_to_party_name);
8890 ibe_util.debug('GenerateQuoteHeader - ship_to_name - '||l_ship_to_name);
8891 END IF;
8892
8893 /* Shipping Contact ship_to_party_id(PARTY_REALTIONSHIP) OR Ship Customer's Party Id */
8894 If l_ship_to_party_id is not null Then
8895 FOR c_hz_parties_rec IN c_hz_parties(l_ship_to_party_id) LOOP
8896 If c_hz_parties_rec.party_type = 'PARTY_RELATIONSHIP' Then
8897 l_ship_contact_party_id := g_quote_header_rec.party_id;
8898 End If;
8899 END LOOP;
8900 End If;
8901
8902 FOR c_hz_contact_rec IN c_hz_contact_points(l_ship_contact_party_id) LOOP
8903
8904 If (c_hz_contact_rec.contact_point_type = 'PHONE' AND c_hz_contact_rec.phone_line_type = 'GEN') AND (l_ship_to_number IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
8905
8906 l_ship_to_number := trim(c_hz_contact_rec.Phone_Country_code||' '||c_hz_contact_rec.Phone_area_code||' '||c_hz_contact_rec.Phone_number);
8907
8908 Elsif (c_hz_contact_rec.contact_point_type = 'PHONE' AND c_hz_contact_rec.phone_line_type = 'FAX') AND (l_ship_to_fax IS NULL OR c_hz_contact_rec.primary_flag ='Y') Then
8909
8910 l_ship_to_fax := trim(c_hz_contact_rec.Phone_Country_code||' '||c_hz_contact_rec.Phone_area_code||' '||c_hz_contact_rec.Phone_number);
8911
8912 End If;
8913 END LOOP;
8914
8915 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8916 ibe_util.debug('GenerateQuoteHeader - ship_to_number - '||l_ship_to_number);
8917 ibe_util.debug('GenerateQuoteHeader - ship_to_fax - '||l_ship_to_fax);
8918 END IF;
8919
8920 l_ship_to_address := null;
8921 l_ship_to_city := null;
8922 l_ship_to_state := null;
8923 l_ship_to_zip := null;
8924 l_ship_to_country := null;
8925
8926 FOR c_hz_locations_rec IN c_hz_locations(l_ship_to_site_id) LOOP
8927
8928 l_ship_to_address := c_hz_locations_rec.loc_address;
8929 l_ship_to_city := c_hz_locations_rec.loc_city;
8930 l_ship_to_state := c_hz_locations_rec.loc_state;
8931 l_ship_to_zip := c_hz_locations_rec.loc_zip;
8932 l_ship_to_country := c_hz_locations_rec.loc_country;
8933
8934 END LOOP;
8935
8936
8937 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
8938 ibe_util.debug('GenerateQuoteHeader - ship_address - '||l_ship_to_address);
8939 ibe_util.debug('GenerateQuoteHeader - ship_city - '||l_ship_to_city);
8940 ibe_util.debug('GenerateQuoteHeader - ship_state - '||l_ship_to_state);
8941 ibe_util.debug('GenerateQuoteHeader - ship_zip - '||l_ship_to_zip);
8942 ibe_util.debug('GenerateQuoteHeader - ship_country - '||l_ship_to_country);
8943 ibe_util.debug('GenerateQuoteHeader - quote_header_id - '||g_quote_header_rec.quote_header_id);
8944 END IF;
8945
8946 --IF (display_type = 'text/plain' ) THEN
8947 fnd_message.set_name('IBE','IBE_PRMT_QUOTE_ID_COLON');
8948 l_temp_str := null;
8949 l_temp_str := fnd_message.get;
8950 l_document := l_document || l_temp_str ||TAB||TAB||g_quote_header_rec.quote_number||NEWLINE;
8951
8952 fnd_message.set_name('IBE','IBE_PRMT_CONTRACT_NO_COLON');
8953 l_temp_str := null;
8954 l_temp_str := fnd_message.get;
8955 l_document := l_document || l_temp_str ||TAB||l_contract_number||' '||l_contract_modifier||NEWLINE;
8956
8957 fnd_message.set_name('IBE','IBE_PRMT_QUOTE_NAME_COLON');
8958 l_temp_str := null;
8959 l_temp_str := fnd_message.get;
8960 l_document := l_document || l_temp_str ||TAB||g_quote_header_rec.quote_name||NEWLINE;
8961 /*
8962 fnd_message.set_name('IBE','IBE_PRMT_ORDER_DATE_COLON');
8963 l_temp_str := null;
8964 l_temp_str := fnd_message.get;
8965 l_document := l_document || l_temp_str ||TAB||TAB||g_quote_header_rec.ordered_date||NEWLINE;
8966 */
8967 fnd_message.set_name('IBE','IBE_PRMT_SHIP_METH_COLON');
8968 l_temp_str := null;
8969 l_temp_str := fnd_message.get;
8970 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_method||NEWLINE;
8971
8972 fnd_message.set_name('IBE','IBE_PRMT_CUST_CNTCT_INFO');
8973 l_temp_str := null;
8974 l_temp_str := fnd_message.get;
8975 l_document := l_document || NEWLINE ||l_temp_str ||NEWLINE||NEWLINE;
8976
8977 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NAME_COL');
8978 l_temp_str := null;
8979 l_temp_str := fnd_message.get;
8980 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_contact_name||NEWLINE;
8981
8982 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NUM_COL');
8983 l_temp_str := null;
8984 l_temp_str := fnd_message.get;
8985 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_contact_number||NEWLINE;
8986
8987 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_EMAIL_COL');
8988 l_temp_str := null;
8989 l_temp_str := fnd_message.get;
8990 l_document := l_document || l_temp_str ||TAB||TAB||l_contact_email||NEWLINE;
8991
8992
8993 If not(l_event_type = 'TERMREJECTED') Then
8994 l_comments := wf_engine.GetItemAttrText (
8995 itemtype => l_item_type,
8996 itemkey => l_item_key,
8997 aname => 'COMMENTS'
8998 );
8999 fnd_message.set_name('IBE','IBE_PRMT_ADDL_TERMS_COLON');
9000 l_temp_str := null;
9001 l_temp_str := fnd_message.get;
9002 l_document := l_document || l_temp_str ||TAB||l_comments ||NEWLINE;
9003 End If;
9004
9005 fnd_message.set_name('IBE','IBE_PRMT_ORD_BILL_INFO');
9006 l_temp_str := null;
9007 l_temp_str := fnd_message.get;
9008 l_document := l_document || NEWLINE ||l_temp_str ||NEWLINE||NEWLINE;
9009
9010 fnd_message.set_name('IBE','IBE_PRMT_CUST_NAME_COLON');
9011 l_temp_str := null;
9012 l_temp_str := fnd_message.get;
9013 l_document := l_document || l_temp_str ||TAB||TAB||l_bill_to_party_name||NEWLINE;
9014
9015 fnd_message.set_name('IBE','IBE_PRMT_ADDRESS_COLON');
9016 l_temp_str := null;
9017 l_temp_str := fnd_message.get;
9018 l_document := l_document || l_temp_str ||TAB||TAB||l_bill_to_address||NEWLINE;
9019
9020 fnd_message.set_name('IBE','IBE_PRMT_CITY_COLON');
9021 l_temp_str := null;
9022 l_temp_str := fnd_message.get;
9023 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_bill_to_city||NEWLINE;
9024
9025 fnd_message.set_name('IBE','IBE_PRMT_STATE_PRO_COLON');
9026 l_temp_str := null;
9027 l_temp_str := fnd_message.get;
9028 l_document := l_document || l_temp_str ||TAB||TAB||l_bill_to_state||NEWLINE;
9029
9030 fnd_message.set_name('IBE','IBE_PRMT_ZIP_POSTAL_COLON');
9031 l_temp_str := null;
9032 l_temp_str := fnd_message.get;
9033 l_document := l_document || l_temp_str ||TAB||l_bill_to_zip||NEWLINE;
9034
9035 fnd_message.set_name('IBE','IBE_PRMT_COUNTRY_COLON');
9036 l_temp_str := null;
9037 l_temp_str := fnd_message.get;
9038 l_document := l_document || l_temp_str ||TAB||TAB||l_bill_to_country||NEWLINE;
9039
9040 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NAME_COL');
9041 l_temp_str := null;
9042 l_temp_str := fnd_message.get;
9043 l_document := l_document || l_temp_str ||TAB||TAB||l_bill_to_name||NEWLINE;
9044
9045 fnd_message.set_name('IBE','IBE_PRMT_TEL_NO_COLON');
9046 l_temp_str := null;
9047 l_temp_str := fnd_message.get;
9048 l_document := l_document || l_temp_str ||TAB||l_bill_to_number||NEWLINE;
9049
9050 fnd_message.set_name('IBE','IBE_PRMT_FAX_NO_COLON');
9051 l_temp_str := null;
9052 l_temp_str := fnd_message.get;
9053 l_document := l_document || l_temp_str ||TAB||TAB||l_bill_to_fax||NEWLINE;
9054
9055 fnd_message.set_name('IBE','IBE_PRMT_ORD_SHIP_INFOR');
9056 l_temp_str := null;
9057 l_temp_str := fnd_message.get;
9058 l_document := l_document || NEWLINE ||l_temp_str ||NEWLINE||NEWLINE;
9059
9060 fnd_message.set_name('IBE','IBE_PRMT_CUST_NAME_COLON');
9061 l_temp_str := null;
9062 l_temp_str := fnd_message.get;
9063 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_to_party_name||NEWLINE;
9064
9065 fnd_message.set_name('IBE','IBE_PRMT_ADDRESS_COLON');
9066 l_temp_str := null;
9067 l_temp_str := fnd_message.get;
9068 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_to_address||NEWLINE;
9069
9070 fnd_message.set_name('IBE','IBE_PRMT_CITY_COLON');
9071 l_temp_str := null;
9072 l_temp_str := fnd_message.get;
9073 l_document := l_document || l_temp_str ||TAB||TAB||TAB||l_ship_to_city||NEWLINE;
9074
9075 fnd_message.set_name('IBE','IBE_PRMT_STATE_PRO_COLON');
9076 l_temp_str := null;
9077 l_temp_str := fnd_message.get;
9078 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_to_state||NEWLINE;
9079
9080 fnd_message.set_name('IBE','IBE_PRMT_COUNTRY_COLON');
9081 l_temp_str := null;
9082 l_temp_str := fnd_message.get;
9083 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_to_country||NEWLINE;
9084
9085 fnd_message.set_name('IBE','IBE_PRMT_CNTCT_NAME_COL');
9086 l_temp_str := null;
9087 l_temp_str := fnd_message.get;
9088 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_to_name||NEWLINE;
9089
9090 fnd_message.set_name('IBE','IBE_PRMT_TEL_NO_COLON');
9091 l_temp_str := null;
9092 l_temp_str := fnd_message.get;
9093 l_document := l_document || l_temp_str ||TAB||l_ship_to_number||NEWLINE;
9094
9095 fnd_message.set_name('IBE','IBE_PRMT_FAX_NO_COLON');
9096 l_temp_str := null;
9097 l_temp_str := fnd_message.get;
9098 l_document := l_document || l_temp_str ||TAB||TAB||l_ship_to_fax||NEWLINE;
9099
9100 --ELSE
9101 --null;
9102 --END IF;
9103
9104 END LOOP;
9105 CLOSE c_quote_header;
9106
9107 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9108 ibe_util.debug('GenerateQuoteHeader - l_document'||NEWLINE|| l_document);
9109 END IF;
9110
9111 document := l_document;
9112
9113 IF(display_type = 'text/html') THEN
9114 document_type := 'text/html';
9115 ELSE
9116 document_type := 'text/plain';
9117 END IF;
9118
9119 EXCEPTION
9120 When Others Then
9121 IF c_quote_header%ISOPEN THEN
9122 CLOSE c_quote_header;
9123 END IF;
9124 Raise;
9125 END GenerateQuoteHeader;
9126
9127
9128
9129 PROCEDURE GenerateQuoteDetail(
9130 document_id IN VARCHAR2,
9131 display_type IN VARCHAR2,
9132 document IN OUT NOCOPY VARCHAR2,
9133 document_type IN OUT NOCOPY VARCHAR2
9134 ) IS
9135
9136 l_item_type wf_items.item_type%TYPE := 'IBEALERT';
9137 l_item_key wf_items.item_key%TYPE;
9138 l_quote_id NUMBER;
9139 l_event_type VARCHAR2(20);
9140 l_document VARCHAR2(32000) := '';
9141 l_description mtl_system_items_kfv.description%TYPE;
9142 l_ship_flag VARCHAR2(1);
9143 l_string_in VARCHAR2(250);
9144 l_string_out VARCHAR2(250);
9145 l_string_left VARCHAR2(250);
9146 l_view_net_price_flag VARCHAR2(1);
9147
9148 l_amt_format Varchar2(50);
9149 l_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
9150
9151 Cursor c_ship_flag(p_inv_item_id NUMBER,p_org_id NUMBER) IS
9152 SELECT shippable_item_flag, rtrim(description) Description
9153 FROM mtl_system_items_kfv
9154 WHERE inventory_item_id = p_inv_item_id
9155 AND organization_id = p_org_id;
9156
9157 BEGIN
9158
9159
9160 l_item_key := document_id;
9161
9162 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9163 ibe_util.debug('GenerateQuoteDetail_new - l_item_key - '||l_item_key);
9164 END IF;
9165
9166 l_quote_id := wf_engine.GetItemAttrText (
9167 itemtype => g_ItemType,
9168 itemkey => l_item_key,
9169 aname => 'QUOTEID'
9170 );
9171 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9172 ibe_util.debug('GenerateQuoteDetail_new - l_quote_id - '||l_quote_id);
9173 END IF;
9174
9175 l_event_type := wf_engine.GetItemAttrText (
9176 itemtype => g_ItemType,
9177 itemkey => l_item_key,
9178 aname => 'EVENTTYPE'
9179 );
9180 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9181 ibe_util.debug('GenerateQuoteDetail - l_event_type - '|| l_event_type);
9182 END IF;
9183
9184 l_view_net_price_flag := wf_engine.GetItemAttrText (
9185 itemtype => g_itemType,
9186 itemkey => l_item_key,
9187 aname => 'VIEWNETPRICE'
9188 );
9189
9190
9191 For qte_hd_rec In c_quote_header(l_quote_id) Loop
9192
9193 IF l_view_net_price_flag = 'Y' THEN
9194 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK(qte_hd_rec.Currency_code,18);
9195
9196 For curr_sym_rec In c_curr_symbol(qte_hd_rec.Currency_code)
9197 Loop
9198 l_curr_sym := trim(nvl(curr_sym_rec.symbol,' '));
9199 End Loop;
9200 END IF;
9201
9202 End Loop;
9203
9204
9205 OPEN c_quote_detail(l_quote_id);
9206 LOOP
9207 FETCH c_quote_detail INTO g_quote_line_rec;
9208 EXIT WHEN c_quote_detail%NOTFOUND;
9209
9210 l_ship_flag := null;
9211 l_description := null;
9212
9213 FOR c_ship_rec IN c_ship_flag(g_quote_line_rec.inventory_item_id,g_quote_line_rec.organization_id) LOOP
9214
9215 l_ship_flag := c_ship_rec.shippable_item_flag;
9216 l_description := c_ship_rec.description;
9217
9218 END LOOP;
9219
9220 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9221 ibe_util.debug('GenerateQuoteDetail - l_ship_flag - '|| l_ship_flag);
9222 ibe_util.debug('GenerateQuoteDetail - l_description - '|| l_description);
9223 ibe_util.debug('GenerateQuoteDetail - quantity - '||g_quote_line_rec.quantity);
9224 ibe_util.debug('GenerateQuoteDetail - price '||g_quote_line_rec.line_quote_price);
9225 END IF;
9226
9227 l_string_in := l_description;
9228 l_string_out := '';
9229 l_string_left := '';
9230 ibe_workflow_pvt.ParseThisString(l_string_in,l_string_out,l_string_left);
9231
9232 l_document := l_document || l_string_out ||TAB;
9233 l_document := l_document || to_char(g_quote_line_rec.quantity)||TAB;
9234 l_document := l_document || l_ship_flag;
9235 IF l_view_net_price_flag = 'Y' THEN
9236 l_document := l_document || lpad(l_curr_sym||to_char( (g_quote_line_rec.quantity*g_quote_line_rec.line_quote_price), l_amt_format),23,' ');
9237 END IF;
9238
9239 l_string_in := l_string_left;
9240 WHILE length(l_string_in) > 0 LOOP
9241 l_string_out := '';
9242 l_string_left := '';
9243 ibe_workflow_pvt.ParseThisString(l_string_in,l_string_out,l_string_left);
9244 l_document := l_document || l_string_out ||NEWLINE;
9245 l_string_in := l_string_left;
9246 END LOOP;
9247 l_document := l_document || NEWLINE;
9248
9249 END LOOP;
9250 CLOSE c_quote_detail;
9251
9252 document := l_document;
9253
9254 IF(display_type = 'text/html') THEN
9255 document_type := 'text/html';
9256 ELSE
9257 document_type := 'text/plain';
9258 END IF;
9259
9260 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9261 ibe_util.debug('GenerateQuoteDetail - l_document - '||NEWLINE|| l_document);
9262 END IF;
9263
9264 EXCEPTION
9265 When Others Then
9266 IF c_quote_detail%ISOPEN THEN
9267 CLOSE c_quote_detail;
9268 END IF;
9269 Raise;
9270 END GenerateQuoteDetail;
9271
9272 PROCEDURE GenerateQuoteFooter(
9273 document_id IN VARCHAR2,
9274 display_type IN VARCHAR2,
9275 document IN OUT NOCOPY VARCHAR2,
9276 document_type IN OUT NOCOPY VARCHAR2
9277 )IS
9278
9279 l_item_type wf_items.item_type%TYPE := 'IBEALERT';
9280 l_item_key wf_items.item_key%TYPE;
9281 l_quote_id NUMBER;
9282 l_event_type VARCHAR2(20);
9283 l_document VARCHAR2(32000) := '';
9284 l_temp_str VARCHAR2(2000):='';
9285 l_sub_total NUMBER;
9286
9287 l_view_net_price_flag VARCHAR2(1);
9288 l_amt_format Varchar2(50);
9289 l_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
9290
9291 l_can_amt VARCHAR2(50);
9292 l_paynow VARCHAR2(1);
9293 l_reccharge VARCHAR2(1);
9294
9295 Cursor c_reccur_quote_footer(c_quote_id NUMBER) IS
9296 select uom.unit_of_measure_tl charge_periodicity_desc,nvl(sum(ql.line_quote_price*ql.quantity),'0.00') rec_subtotal
9297 from aso_quote_lines_all ql,mtl_units_of_measure_tl uom
9298 where ql.quote_header_id = c_quote_id
9299 and ql.charge_periodicity_code is not null
9300 and uom.uom_code(+) = ql.charge_periodicity_code
9301 and uom.language(+) = userenv('lang')
9302 group by uom.unit_of_measure_tl;
9303 g_recur_quote_rec c_reccur_quote_footer%ROWTYPE;
9304
9305 Cursor c_macd_quote_footer(c_quote_id NUMBER) IS
9306 select nvl(sum(ql.line_paynow_subtotal),'0.00')paynow_lines_total,nvl(sum(ql.line_paynow_charges),'0.00')paynow_charges_total,nvl(sum(ql.line_paynow_tax),'0.00')paynow_taxes_total,
9307 nvl(sum(ql.line_paynow_subtotal + ql.line_paynow_charges + ql.line_paynow_tax),'0.00')paynow_order_total,
9308 qh.total_quote_price quote_total,qh.currency_code
9309 from aso_quote_lines_all ql,aso_quote_headers_all qh
9310 where qh.quote_header_id = c_quote_id
9311 and ql.quote_header_id = qh.quote_header_id
9312 group by ql.quote_header_id,qh.total_quote_price,qh.currency_code;
9313 g_macd_quote_rec c_macd_quote_footer%ROWTYPE;
9314
9315
9316 BEGIN
9317
9318 l_item_key := document_id;
9319
9320 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9321 ibe_util.debug('GenerateQuoteFooter - l_item_key - '||l_item_key);
9322 END IF;
9323
9324 l_quote_id := wf_engine.GetItemAttrText (
9325 itemtype => g_ItemType,
9326 itemkey => l_item_key,
9327 aname => 'QUOTEID'
9328 );
9329 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9330 ibe_util.debug('GenerateQuoteFooter - l_quote_id - '||l_quote_id);
9331 END IF;
9332
9333 l_event_type := wf_engine.GetItemAttrText (
9334 itemtype => g_ItemType,
9335 itemkey => l_item_key,
9336 aname => 'EVENTTYPE'
9337 );
9338 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9339 ibe_util.debug('GenerateQuoteFooter - l_event_type - '|| l_event_type);
9340 END IF;
9341
9342
9343 l_view_net_price_flag := wf_engine.GetItemAttrText (
9344 itemtype => g_itemType,
9345 itemkey => l_item_key,
9346 aname => 'VIEWNETPRICE'
9347 );
9348
9349 l_paynow := wf_engine.GetItemAttrText (
9350 itemtype => g_itemType,
9351 itemkey => l_item_key,
9352 aname => 'PAYNOWENABLED'
9353 );
9354
9355 l_reccharge := wf_engine.GetItemAttrText (
9356 itemtype => g_itemType,
9357 itemkey => l_item_key,
9358 aname => 'RECCHARGEENABLED'
9359 );
9360
9361 if(l_reccharge = 'Y') THEN
9362 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9363 ibe_util.debug('GenerateQuoteFooter - Recurring loop');
9364 end if;
9365 OPEN c_quote_header(l_quote_id);
9366 LOOP
9367 FETCH c_quote_header INTO g_quote_header_rec;
9368 EXIT WHEN c_quote_header%NOTFOUND;
9369 IF l_view_net_price_flag = 'Y' THEN
9370 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK( g_quote_header_rec.Currency_code,22);
9371 For curr_sym_rec In c_curr_symbol(g_quote_header_rec.Currency_code) Loop
9372 l_curr_sym := trim(curr_sym_rec.symbol);
9373 End Loop;
9374
9375 fnd_message.set_name('IBE','IBE_PRMT_OT_ONE_TIME_PRICE');
9376 l_temp_str := null;
9377 l_temp_str := fnd_message.get;
9378 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_quote_header_rec.total_quote_price));
9379 l_document := l_document|| lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt), l_amt_format), 20, ' ')||NEWLINE;
9380
9381 OPEN c_reccur_quote_footer(l_quote_id);
9382 LOOP
9383 FETCH c_reccur_quote_footer INTO g_recur_quote_rec;
9384 EXIT WHEN c_reccur_quote_footer%NOTFOUND;
9385 l_document := l_document || lpad(g_recur_quote_rec.charge_periodicity_desc,51,' ');
9386 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_recur_quote_rec.rec_subtotal));
9387 l_document := l_document || lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
9388 END LOOP;
9389 CLOSE c_reccur_quote_footer;
9390
9391 END IF;
9392 END LOOP;
9393 CLOSE c_quote_header;
9394 else
9395 OPEN c_quote_header(l_quote_id);
9396 LOOP
9397 FETCH c_quote_header INTO g_quote_header_rec;
9398 EXIT WHEN c_quote_header%NOTFOUND;
9399
9400 IF l_view_net_price_flag = 'Y' THEN
9401 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK( g_quote_header_rec.Currency_code,22);
9402
9403 For curr_sym_rec In c_curr_symbol(g_quote_header_rec.Currency_code) Loop
9404 l_curr_sym := trim(curr_sym_rec.symbol);
9405 End Loop;
9406 END IF;
9407
9408
9409
9410 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9411 ibe_util.debug('GenerateQuoteFooter - shipping - '||to_char(g_quote_header_rec.total_shipping_charge));
9412 ibe_util.debug('GenerateQuoteFooter - tax - '||to_char(g_quote_header_rec.total_tax));
9413 ibe_util.debug('GenerateQuoteFooter - total quote price - '||to_char(g_quote_header_rec.total_quote_price));
9414 END IF;
9415
9416 --IF (display_type = 'text/plain' ) THEN
9417 IF l_view_net_price_flag = 'Y' THEN
9418
9419 fnd_message.set_name('IBE','IBE_PRMT_SUBTOTAL_COLON');
9420 l_temp_str := null;
9421 l_temp_str := fnd_message.get;
9422
9423 l_sub_total := g_quote_header_rec.total_list_price - abs(g_quote_header_rec.total_adjusted_amount);
9424 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(l_sub_total));
9425 l_document := l_document || lpad(l_temp_str,51,' ')|| ' '|| lpad( l_curr_sym||to_char(to_number(l_can_amt),l_amt_format), 20, ' ')|| NEWLINE;
9426
9427
9428 fnd_message.set_name('IBE','IBE_PRMT_SHIP_HAND_COLON');
9429 l_temp_str := null;
9430 l_temp_str := fnd_message.get;
9431 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_quote_header_rec.total_shipping_charge));
9432 l_document := l_document || lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt), l_amt_format), 20, ' ')|| NEWLINE;
9433
9434
9435 fnd_message.set_name('IBE','IBE_PRMT_TAX_EST_COLON');
9436 l_temp_str := null;
9437 l_temp_str := fnd_message.get;
9438 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_quote_header_rec.total_tax));
9439 l_document := l_document || lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')|| NEWLINE;
9440
9441 fnd_message.set_name('IBE','IBE_PRMT_SC_TOTAL2');
9442 l_temp_str := null;
9443 l_temp_str := fnd_message.get;
9444 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_quote_header_rec.total_quote_price));
9445 l_document := l_document || lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym|| to_char(to_number(l_can_amt),l_amt_format),20,' ');
9446 END IF;
9447 --ELSE
9448 --null;
9449 --END IF;
9450 END LOOP;
9451 CLOSE c_quote_header;
9452 end if; -- Recurring charge else loop
9453
9454 if (l_reccharge = 'Y' OR l_paynow = 'Y') then
9455 OPEN c_macd_quote_footer(l_quote_id);
9456 LOOP
9457 FETCH c_macd_quote_footer INTO g_macd_quote_rec;
9458 EXIT WHEN c_macd_quote_footer%NOTFOUND;
9459
9460 IF l_view_net_price_flag = 'Y' THEN
9461 l_amt_format := FND_CURRENCY.GET_FORMAT_MASK( g_macd_quote_rec.Currency_code,22);
9462 For curr_sym_rec In c_curr_symbol(g_macd_quote_rec.Currency_code) Loop
9463 l_curr_sym := trim(curr_sym_rec.symbol);
9464 End Loop;
9465 END IF;
9466 IF l_view_net_price_flag = 'Y' THEN
9467 fnd_message.set_name('IBE','IBE_PRMT_SC_PAY_NOW_CHARGES');
9468 l_temp_str := null;
9469 l_temp_str := fnd_message.get;
9470 l_document := l_document || lpad(l_temp_str,51,' ')||NEWLINE;
9471 l_document := l_document || lpad('-',(51-length(l_temp_str)))||rpad('-',(71-(51-(length(l_temp_str)))),'-')||NEWLINE;
9472
9473 fnd_message.set_name('IBE','IBE_PRMT_SUBTOTAL_COLON');
9474 l_temp_str := null;
9475 l_temp_str := fnd_message.get;
9476 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_quote_rec.paynow_lines_total));
9477 l_document := l_document ||lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
9478
9479 fnd_message.set_name('IBE','IBE_PRMT_TAX_COL');
9480 l_temp_str := null;
9481 l_temp_str := fnd_message.get;
9482 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_quote_rec.paynow_taxes_total));
9483 l_document := l_document || lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
9484
9485 fnd_message.set_name('IBE','IBE_PRMT_SHIP_HAND_COLON');
9486 l_temp_str := null;
9487 l_temp_str := fnd_message.get;
9488 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_quote_rec.paynow_charges_total));
9489 l_document := l_document || lpad(l_temp_str,51,' ')||' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),20,' ')||NEWLINE;
9490
9491 fnd_message.set_name('IBE','IBE_PRMT_SC_PN_TOTAL_COL');
9492 l_temp_str := null;
9493 l_temp_str := fnd_message.get;
9494 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(g_macd_quote_rec.paynow_order_total));
9495 l_document := l_document|| lpad(l_temp_str,51,' ')|| ' '|| lpad(l_curr_sym||to_char(to_number(l_can_amt), l_amt_format), 20, ' ');
9496 END IF;
9497 END LOOP;
9498 CLOSE c_macd_quote_footer;
9499 end if;
9500
9501 document := l_document;
9502
9503 IF(display_type = 'text/html') THEN
9504 document_type := 'text/html';
9505 ELSE
9506 document_type := 'text/plain';
9507 END IF;
9508
9509
9510 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9511 ibe_util.debug('GenerateQuoteFooter - l_document - '||NEWLINE|| l_document);
9512 END IF;
9513
9514 EXCEPTION
9515 When Others Then
9516 IF c_quote_header%ISOPEN THEN
9517 CLOSE c_quote_header;
9518 END IF;
9519 Raise;
9520 END GenerateQuoteFooter;
9521
9522 PROCEDURE Selector(
9523 itemtype IN VARCHAR2,
9524 itemkey IN VARCHAR2,
9525 actid IN NUMBER,
9526 funcmode IN VARCHAR2,
9527 result OUT NOCOPY VARCHAR2
9528 ) IS
9529
9530 l_event_type VARCHAR2(50);
9531
9532 BEGIN
9533 IF ( funcmode = 'RUN' ) THEN
9534 l_event_type := wf_engine.GetItemAttrText(
9535 itemtype => itemtype,
9536 itemkey => itemkey,
9537 aname => 'EVENTTYPE'
9538 );
9539
9540 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9541 ibe_util.debug('Selector - Inside RUN- '||l_event_type);
9542 END IF;
9543
9544 IF l_event_type = 'ACCOUNT_REGISTRATION' THEN
9545 result := 'COMPLETE:ACCTREG';
9546 ELSIF l_event_type = 'ORDCONF' THEN
9547 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9548 ibe_util.debug('Selector - Inside order confirmation selection ');
9549 END IF;
9550 result := 'COMPLETE:ORDCONF';
9551 ELSIF l_event_type = 'ORDFAX' THEN
9552 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9553 ibe_util.debug('Selector - Inside order fax selection ');
9554 END IF;
9555 result := 'COMPLETE:ORDFAX';
9556 ELSIF l_event_type = 'ORDERROR' THEN
9557 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9558 ibe_util.debug('Selector - Inside order error selection ');
9559 END IF;
9560 result := 'COMPLETE:ORDERROR';
9561 ELSIF l_event_type = 'ORDCUSTQUOTE' THEN
9562 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9563 ibe_util.debug('Selector - Inside order cust quote selection ');
9564 END IF;
9565 result := 'COMPLETE:ORDCUSTQUOTE';
9566 ELSIF l_event_type = 'ORDSALESQUOTE' THEN
9567 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9568 ibe_util.debug('Selector - Inside order sales quote selection ');
9569 END IF;
9570 result := 'COMPLETE:ORDSALESQUOTE';
9571 ELSIF l_event_type = 'CUSTASSIST' THEN
9572 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9573 ibe_util.debug('Selector - Inside cust assist selection ');
9574 END IF;
9575 result := 'COMPLETE:CUSTASSIST';
9576 ELSIF l_event_type = 'SALESASSIST' THEN
9577 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9578 ibe_util.debug('Selector - Inside sales assist selection ');
9579 END IF;
9580 result := 'COMPLETE:SALESASSIST';
9581 ELSIF l_event_type = 'TERMAPPROVED' THEN
9582 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9583 ibe_util.debug('Selector - Inside Term Apporved selection ');
9584 END IF;
9585 result := 'COMPLETE:TERMAPPROVED';
9586 ELSIF l_event_type = 'TERMREJECTED' THEN
9587 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9588 ibe_util.debug('Selector - Inside Term Rejected selection ');
9589 END IF;
9590 result := 'COMPLETE:TERMREJECTED';
9591 ELSIF l_event_type = 'TERMCANCELLED' THEN
9592 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9593 ibe_util.debug('Selector - Inside Term Cancelled selection ');
9594 END IF;
9595 result := 'COMPLETE:TERMCANCELLED';
9596 END IF;
9597 END IF;
9598 IF ( funcmode = 'CANCEL' ) THEN
9599 result := 'COMPLETE';
9600 END IF;
9601 END Selector;
9602
9603 PROCEDURE GetFirstName(
9604 document_id IN VARCHAR2,
9605 display_type IN VARCHAR2,
9606 document IN OUT NOCOPY VARCHAR2,
9607 document_type IN OUT NOCOPY VARCHAR2
9608 ) IS
9609
9610 l_party_id number;
9611 l_first_name varchar2(150);
9612 l_order_id number;
9613
9614 Cursor c_b2b_contact(c_order_id Number) IS
9615 Select p.party_id Person_Party_id,
9616 l.party_id contact_party_id,
9617 p.person_first_name,
9618 p.person_last_name,
9619 p.party_type
9620 from oe_order_headers_all o,
9621 hz_cust_Account_roles r,
9622 hz_relationships l,
9623 hz_parties p
9624 where o.header_id = c_order_id
9625 and o.sold_to_contact_id = r.cust_account_role_id
9626 and r.party_id = l.party_id
9627 and l.subject_id = p.party_id
9628 and l.subject_type = 'PERSON'
9629 and l.object_type = 'ORGANIZATION';
9630
9631 --bug 2299210
9632 Cursor c_b2b_contact_new(pPartyId Number) IS
9633 Select p.person_first_name,
9634 p.person_last_name,
9635 p.person_title,
9636 p.party_type
9637 from hz_relationships l,
9638 hz_parties p
9639 where l.party_id = pPartyId
9640 and l.subject_id = p.party_id
9641 and l.subject_type = 'PERSON'
9642 and l.object_type = 'ORGANIZATION';
9643 --bug 2299210
9644
9645 Begin
9646
9647 FOR c_quote_rec In c_quote_header(to_number(document_id)) LOOP
9648 l_party_id := c_quote_rec.party_id;
9649 l_order_id := c_quote_rec.order_id;
9650 END LOOP;
9651
9652 FOR c_hz_parties_rec IN c_hz_parties(l_party_id) LOOP
9653 If c_hz_parties_rec.Party_type = 'PARTY_RELATIONSHIP' Then
9654 For c_b2b_contact_rec in c_b2b_contact(l_order_id) Loop
9655 l_first_name := upper(rtrim(c_b2b_contact_rec.person_first_name));
9656 End Loop;
9657 Else
9658 l_first_name := upper(rtrim(c_hz_parties_rec.person_first_name));
9659 End If;
9660 END LOOP;
9661
9662 --bug 2299210
9663 IF l_first_name IS NULL THEN
9664 FOR c_hz_parties_rec IN c_hz_parties(l_party_id) LOOP
9665 IF c_hz_parties_rec.Party_type = 'PARTY_RELATIONSHIP' THEN
9666 FOR c_b2b_contact_rec in c_b2b_contact_new(l_party_id) LOOP
9667 l_first_name := upper(rtrim(c_b2b_contact_rec.person_first_name));
9668 END LOOP;
9669 END IF;
9670 END LOOP;
9671 END IF;
9672
9673 document := l_first_name;
9674
9675 IF(display_type = 'text/html') THEN
9676 document_type := 'text/html';
9677 ELSE
9678 document_type := 'text/plain';
9679 END IF;
9680
9681 End GetFirstName;
9682
9683 PROCEDURE GetLastName(
9684 document_id IN VARCHAR2,
9685 display_type IN VARCHAR2,
9686 document IN OUT NOCOPY VARCHAR2,
9687 document_type IN OUT NOCOPY VARCHAR2
9688 ) IS
9689
9690 l_party_id number;
9691 l_last_name varchar2(150);
9692 l_order_id number;
9693
9694 Cursor c_b2b_contact(c_Order_id Number) IS
9695 Select p.party_id Person_Party_id,
9696 l.party_id contact_party_id,
9697 p.person_first_name,
9698 p.person_last_name,
9699 p.party_type
9700 from oe_order_headers_all o,
9701 hz_cust_Account_roles r,
9702 hz_relationships l,
9703 hz_parties p
9704 where o.header_id = c_Order_id
9705 and o.sold_to_contact_id = r.cust_account_role_id
9706 and r.party_id = l.party_id
9707 and l.subject_id = p.party_id
9708 and l.subject_type = 'PERSON'
9709 and l.object_type = 'ORGANIZATION';
9710
9711 --bug 2299210
9712 Cursor c_b2b_contact_new(pPartyId Number) IS
9713 Select p.person_first_name,
9714 p.person_last_name,
9715 p.person_title,
9716 p.party_type
9717 from hz_relationships l,
9718 hz_parties p
9719 where l.party_id = pPartyId
9720 and l.subject_id = p.party_id
9721 and l.subject_type = 'PERSON'
9722 and l.object_type = 'ORGANIZATION';
9723 --bug 2299210
9724
9725 Begin
9726
9727 FOR c_quote_rec In c_quote_header(to_number(document_id)) LOOP
9728 l_party_id := c_quote_rec.party_id;
9729 l_order_id := c_quote_rec.order_id;
9730 END LOOP;
9731
9732 FOR c_hz_parties_rec IN c_hz_parties(l_party_id) LOOP
9733 If c_hz_parties_rec.Party_type = 'PARTY_RELATIONSHIP' Then
9734 For c_b2b_contact_rec in c_b2b_contact(l_order_id) Loop
9735 l_last_name := upper(rtrim(c_b2b_contact_rec.person_last_name));
9736 End Loop;
9737 Else
9738 l_last_name := upper(rtrim(c_hz_parties_rec.person_last_name));
9739 End If;
9740 END LOOP;
9741
9742 --bug 2299210
9743 IF l_last_name IS NULL THEN
9744 FOR c_hz_parties_rec IN c_hz_parties(l_party_id) LOOP
9745 IF c_hz_parties_rec.Party_type = 'PARTY_RELATIONSHIP' THEN
9746 FOR c_b2b_contact_rec in c_b2b_contact_new(l_party_id) LOOP
9747 l_last_name := upper(rtrim(c_b2b_contact_rec.person_last_name));
9748 END LOOP;
9749 END IF;
9750 END LOOP;
9751 END IF;
9752
9753 document := l_last_name;
9754
9755 IF(display_type = 'text/html') THEN
9756 document_type := 'text/html';
9757 ELSE
9758 document_type := 'text/plain';
9759 END IF;
9760
9761 End GetLastName;
9762
9763
9764 PROCEDURE GetTitle(
9765 document_id IN VARCHAR2,
9766 display_type IN VARCHAR2,
9767 document IN OUT NOCOPY VARCHAR2,
9768 document_type IN OUT NOCOPY VARCHAR2
9769 ) IS
9770
9771 l_party_id number;
9772 l_order_id number;
9773 l_person_title HZ_PARTIES.PERSON_TITLE%TYPE;
9774
9775 Cursor c_b2b_contact(c_Order_id Number) IS
9776 Select p.party_id Person_Party_id,
9777 l.party_id contact_party_id,
9778 p.person_first_name,
9779 p.person_last_name,
9780 p.party_type,
9781 p.person_title
9782 from oe_order_headers_all o,
9783 hz_cust_Account_roles r,
9784 hz_relationships l,
9785 hz_parties p
9786 where o.header_id = c_order_id
9787 and o.sold_to_contact_id = r.cust_account_role_id
9788 and r.party_id = l.party_id
9789 and l.subject_id = p.party_id
9790 and l.subject_type = 'PERSON'
9791 and l.object_type = 'ORGANIZATION';
9792
9793 --bug 2299210
9794 Cursor c_b2b_contact_new(pPartyId Number) IS
9795 Select p.person_first_name,
9796 p.person_last_name,
9797 p.person_title,
9798 p.party_type
9799 from hz_relationships l,
9800 hz_parties p
9801 where l.party_id = pPartyId
9802 and l.subject_id = p.party_id
9803 and l.subject_type = 'PERSON'
9804 and l.object_type = 'ORGANIZATION';
9805 --bug 2299210
9806
9807 Begin
9808
9809 FOR c_quote_rec In c_quote_header(to_number(document_id)) LOOP
9810 l_party_id := c_quote_rec.party_id;
9811 l_order_id := c_quote_rec.order_id;
9812 END LOOP;
9813
9814 FOR c_hz_parties_rec IN c_hz_parties(l_party_id) LOOP
9815 If c_hz_parties_rec.Party_type = 'PARTY_RELATIONSHIP' Then
9816 For c_b2b_contact_rec in c_b2b_contact(l_order_id) Loop
9817 l_person_title := upper(rtrim(c_b2b_contact_rec.person_title));
9818 End Loop;
9819 Else
9820 l_person_title := upper(rtrim(c_hz_parties_rec.person_title));
9821 End If;
9822 END LOOP;
9823
9824 --bug 2299210
9825 IF l_person_title IS NULL THEN
9826 FOR c_hz_parties_rec IN c_hz_parties(l_party_id) LOOP
9827 IF c_hz_parties_rec.Party_type = 'PARTY_RELATIONSHIP' THEN
9828 FOR c_b2b_contact_rec in c_b2b_contact_new(l_party_id) LOOP
9829 l_person_title := upper(rtrim(c_b2b_contact_rec.person_title));
9830 END LOOP;
9831 END IF;
9832 END LOOP;
9833 END IF;
9834
9835 document := l_person_title;
9836
9837 IF(display_type = 'text/html') THEN
9838 document_type := 'text/html';
9839 ELSE
9840 document_type := 'text/plain';
9841 END IF;
9842
9843 End GetTitle;
9844
9845
9846 PROCEDURE GetContractRef(
9847 document_id IN VARCHAR2,
9848 display_type IN VARCHAR2,
9849 document IN OUT NOCOPY VARCHAR2,
9850 document_type IN OUT NOCOPY VARCHAR2
9851 ) IS
9852
9853 l_contract_number varchar2(120);
9854 l_contract_modifier varchar2(120);
9855 l_contract_ref varchar2(245);
9856 Begin
9857
9858 FOR c_contract_rec In c_contract_header(to_number(document_id)) LOOP
9859 l_contract_number := c_contract_rec.contract_number;
9860 l_contract_modifier := c_contract_rec.contract_number_modifier;
9861 l_contract_ref := l_contract_number||' '||l_contract_modifier;
9862 END LOOP;
9863
9864 document := l_contract_ref;
9865
9866 IF(display_type = 'text/html') THEN
9867 document_type := 'text/html';
9868 ELSE
9869 document_type := 'text/plain';
9870 END IF;
9871
9872 End GetContractRef;
9873
9874 PROCEDURE GetCartName(
9875 document_id IN VARCHAR2,
9876 display_type IN VARCHAR2,
9877 document IN OUT NOCOPY VARCHAR2,
9878 document_type IN OUT NOCOPY VARCHAR2
9879 ) IS
9880
9881 l_cart_name varchar2(50);
9882
9883 Begin
9884
9885 FOR c_quote_rec In c_quote_header(to_number(document_id)) LOOP
9886 l_cart_name := c_quote_rec.quote_name;
9887 END LOOP;
9888
9889 document := l_cart_name;
9890
9891 IF(display_type = 'text/html') THEN
9892 document_type := 'text/html';
9893 ELSE
9894 document_type := 'text/plain';
9895 END IF;
9896
9897 End GetCartName;
9898
9899 PROCEDURE get_wf_user (
9900 p_user_id IN NUMBER,
9901 p_user_source IN VARCHAR2 DEFAULT 'HZ_PARTY',
9902 p_email_address IN VARCHAR2,
9903 p_quote_header_id IN NUMBER DEFAULT 1,
9904 x_adhoc_user OUT NOCOPY VARCHAR2
9905 ) IS
9906
9907 --define local variables here
9908 l_wf_user VARCHAR2(320);
9909 l_wf_email VARCHAR2(2000);
9910 l_lang_pref VARCHAR2(4000);
9911 l_terr_pref VARCHAR2(4000);
9912 l_sess_lang VARCHAR2(40);
9913 l_sess_terr VARCHAR2(40);
9914 l_adhoc_user VARCHAR2(4000);
9915 l_adhoc_user_display VARCHAR2(4000);
9916 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
9917 l_notif_pref WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
9918 l_email_addr VARCHAR2(2000);
9919
9920 BEGIN
9921 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
9922 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:Start');
9923 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:Input user_id: '||p_user_id);
9924 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:Input user_source: '||p_user_source);
9925 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:Input email_address: '||p_email_address);
9926 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:Input quote_header_id: '||p_quote_header_id);
9927 END IF;
9928
9929 IF (p_user_id > 0) THEN
9930 IF (p_user_source IS NOT NULL AND p_user_source = 'HZ_PARTY') THEN
9931 l_wf_user := 'HZ_PARTY:'||p_user_id;
9932 ELSIF (p_user_source IS NOT NULL AND p_user_source = 'PER') THEN
9933 l_wf_user := 'PER:'||p_user_id;
9934 ELSE
9935 l_wf_user := 'HZ_PARTY:'||p_user_id;
9936 END IF;
9937 --first get the preferred language for this workflow user
9938 BEGIN
9939 SELECT DISTINCT language, territory, notification_preference, email_address
9940 INTO l_lang_pref, l_terr_pref, l_notif_pref, l_email_addr
9941 FROM wf_users
9942 WHERE name = l_wf_user;
9943 EXCEPTION
9944 WHEN OTHERS THEN
9945 --exception while retrieving the language/territory prefs
9946 --could be because the row does not exist
9947 --in this case just return the input parameter as the output
9948 x_adhoc_user := l_wf_user;
9949 END;
9950
9951 --first check the profile to determine whether notification messages should be
9952 --sent in user's preferred language or based on the session language
9953 IF (1=1) THEN
9954 --notificiation messages should be sent in the session language
9955 --check whether the session language/territory is the same as the
9956 --user's preference
9957 SELECT DISTINCT value
9958 INTO l_sess_lang
9959 FROM nls_session_parameters
9960 WHERE parameter = 'NLS_LANGUAGE';
9961
9962 SELECT DISTINCT value
9963 INTO l_sess_terr
9964 FROM nls_session_parameters
9965 WHERE parameter = 'NLS_TERRITORY';
9966
9967 IF (l_sess_lang <> l_lang_pref) THEN
9968 --need to create an adhoc user
9969 l_adhoc_user := substrb(('IBEUE'||FND_GLOBAL.User_ID||to_char(sysdate,'MMDDYYHH24MISS')||p_quote_header_id),1,320);
9970 l_adhoc_user_display := substrb(('IBEUE'||FND_GLOBAL.User_ID||to_char(sysdate,'MMDDYYHH24MISS')||p_quote_header_id),1,320);
9971
9972 wf_directory.CreateAdHocUser(
9973 name => l_adhoc_user ,
9974 display_name => l_adhoc_user_display ,
9975 language => l_sess_lang ,
9976 territory => l_sess_terr ,
9977 notification_preference => l_notif_pref ,
9978 email_address => l_email_addr ,
9979 expiration_date => sysdate + 1);
9980
9981 x_adhoc_user := l_adhoc_user;
9982
9983 ELSE
9984 --no need to create an adhoc user
9985 x_adhoc_user := l_wf_user;
9986
9987 END IF;
9988
9989 ELSE
9990 --notification messages should be sent in user's preferred language
9991 --no need to check anything else
9992 x_adhoc_user := l_wf_user;
9993
9994 END IF;
9995
9996 ELSE
9997 --only e-mail address passed in
9998 --create an adhoc user with session lang and territory as preference
9999 l_adhoc_user := substrb(('IBEUE'||FND_GLOBAL.User_ID||to_char(sysdate,'MMDDYYHH24MISS')||p_quote_header_id),1,320);
10000 l_adhoc_user_display := substrb(('IBEUE'||FND_GLOBAL.User_ID||to_char(sysdate,'MMDDYYHH24MISS')||p_quote_header_id),1,320);
10001
10002 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
10003
10004 wf_directory.CreateAdHocUser(
10005 name => l_adhoc_user ,
10006 display_name => l_adhoc_user_display ,
10007 language => l_sess_lang ,
10008 territory => l_sess_terr ,
10009 notification_preference => l_notification_preference ,
10010 email_address => p_email_address ,
10011 expiration_date => sysdate + 1);
10012
10013 x_adhoc_user := l_adhoc_user;
10014
10015 END IF;
10016
10017 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10018 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:x_adhoc_user = '||x_adhoc_user);
10019 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:x_adhoc_user:End') ;
10020 END IF;
10021
10022 EXCEPTION
10023 WHEN OTHERS THEN
10024 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10025 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_user:Exception occured');
10026 END IF;
10027 RAISE;
10028 END get_wf_user;
10029
10030
10031 PROCEDURE get_wf_role (
10032 p_wf_users_tbl IN JTF_VARCHAR2_TABLE_100,
10033 p_quote_header_id IN NUMBER,
10034 x_wf_role OUT NOCOPY VARCHAR2
10035 ) IS
10036 --any local variables go here
10037 i binary_integer := 0;
10038 l_wf_role_usrs VARCHAR2(4000);
10039 l_adhoc_role VARCHAR2(4000);
10040 l_adhoc_role_display VARCHAR2(4000);
10041 l_sess_lang varchar2(40);
10042 l_sess_terr varchar2(40);
10043 l_notification_preference WF_USERS.NOTIFICATION_PREFERENCE%TYPE;
10044
10045 BEGIN
10046
10047 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10048 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_role:Start');
10049 END IF;
10050 IF (p_wf_users_tbl IS NULL OR p_wf_users_tbl.COUNT <= 0) THEN
10051 return;
10052 END IF;
10053
10054 l_adhoc_role := substrb(('IBER'||FND_GLOBAL.User_ID||to_char(sysdate,'MMDDYYHH24MISS')||p_wf_users_tbl(1)||p_quote_header_id),1,320);
10055 l_adhoc_role_display := substrb(('IBE'||FND_GLOBAL.User_ID||to_char(sysdate,'MMDDYYHH24MISS')||p_wf_users_tbl(1)||p_quote_header_id),1,320);
10056
10057 SELECT DISTINCT value
10058 INTO l_sess_lang
10059 FROM nls_session_parameters
10060 WHERE parameter = 'NLS_LANGUAGE';
10061
10062 SELECT DISTINCT value
10063 INTO l_sess_terr
10064 FROM nls_session_parameters
10065 WHERE parameter = 'NLS_TERRITORY';
10066
10067 FOR i IN 1..p_wf_users_tbl.COUNT LOOP
10068 l_wf_role_usrs := l_wf_role_usrs ||','|| p_wf_users_tbl(i);
10069 END LOOP;
10070 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10071 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_role:l_wf_role_usrs='||l_wf_role_usrs);
10072 END IF;
10073
10074 l_notification_preference := NVL( FND_PROFILE.VALUE_SPECIFIC('IBE_DEFAULT_USER_EMAIL_FORMAT',null,null,671), 'MAILTEXT');
10075
10076 wf_directory.CreateAdHocRole
10077 (role_name => l_adhoc_role,
10078 role_display_name => l_adhoc_role_display,
10079 language => l_sess_lang,
10080 territory => l_sess_terr,
10081 notification_preference => l_notification_preference,
10082 role_users => l_wf_role_usrs,
10083 expiration_date => sysdate + 1);
10084
10085 x_wf_role := l_adhoc_role;
10086 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10087 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_role:End');
10088 END IF;
10089
10090 EXCEPTION
10091 WHEN OTHERS THEN
10092 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10093 IBE_UTIL.DEBUG('ibe_workflow_pvt.get_wf_role:Exception occured');
10094 END IF;
10095 RAISE;
10096 END get_wf_role;
10097
10098 /* PL/SQL callbacks for translatable tokens */
10099
10100 PROCEDURE get_speciality_store_name(
10101 document_id IN VARCHAR2,
10102 display_type IN VARCHAR2,
10103 document IN OUT NOCOPY VARCHAR2,
10104 document_type IN OUT NOCOPY VARCHAR2 ) is
10105
10106 l_msite_id NUMBER;
10107 CURSOR c_msite_name(c_msite_id number) IS
10108 SELECT msite_name
10109 FROM ibe_msites_vl
10110 WHERE msite_id = c_msite_id;
10111 rec_msite_name c_msite_name%rowtype;
10112
10113 BEGIN
10114 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10115 IBE_UTIL.DEBUG('get_speciality_store_name:Document_id: '||document_id);
10116 END IF;
10117 FOR rec_msite_name IN c_msite_name(document_id) LOOP
10118 document := rec_msite_name.msite_name;
10119 EXIT when c_msite_name%NOTFOUND;
10120 END LOOP;
10121
10122 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10123 IBE_UTIL.DEBUG('get_speciality_store_name:Document: '||document);
10124 END IF;
10125
10126 IF(display_type = 'text/html') THEN
10127 document_type := 'text/html';
10128 ELSE
10129 document_type := 'text/plain';
10130 END IF;
10131
10132 END get_speciality_store_name;
10133
10134 PROCEDURE get_fnd_lkpup_value(
10135 document_id IN VARCHAR2,
10136 display_type IN VARCHAR2,
10137 document IN OUT NOCOPY VARCHAR2,
10138 document_type IN OUT NOCOPY VARCHAR2 ) is
10139 cursor c_fnd_lkpup_value(c_fnd_code VARCHAR2) is
10140 select meaning
10141 from fnd_lookups
10142 where lookup_type = 'IBE_QUOTE_UPDATE_PRIVILEGE_WF'
10143 and lookup_code = c_fnd_code;
10144
10145 rec_fnd_lkpup_value c_fnd_lkpup_value%rowtype;
10146 BEGIN
10147
10148 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10149 IBE_UTIL.DEBUG('get_fnd_lkpup_value:Document_id: '||document_id);
10150 END IF;
10151 FOR rec_fnd_lkpup_value in c_fnd_lkpup_value(document_id) LOOP
10152 document := rec_fnd_lkpup_value.meaning;
10153 EXIT when c_fnd_lkpup_value%NOTFOUND;
10154 END LOOP;
10155
10156 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10157 IBE_UTIL.DEBUG('get_fnd_lkpup_value:Document: '||document);
10158 END IF;
10159
10160 IF(display_type = 'text/html') THEN
10161 document_type := 'text/html';
10162 ELSE
10163 document_type := 'text/plain';
10164 END IF;
10165 END ;
10166
10167 PROCEDURE get_FND_message(
10168 document_id IN VARCHAR2,
10169 display_type IN VARCHAR2,
10170 document IN OUT NOCOPY VARCHAR2,
10171 document_type IN OUT NOCOPY VARCHAR2
10172 ) is
10173
10174 BEGIN
10175 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10176 IBE_UTIL.DEBUG('get_FND_message:START: value of document id ='||document_id);
10177 END IF;
10178 FND_MESSAGE.set_name('IBE',document_id);
10179 document:=FND_MESSAGE.get();
10180
10181 IF(display_type = 'text/html') THEN
10182 document_type := 'text/html';
10183 ELSE
10184 document_type := 'text/plain';
10185 END IF;
10186
10187 END get_FND_message;
10188
10189 PROCEDURE get_date(
10190 document_id IN VARCHAR2,
10191 display_type IN VARCHAR2,
10192 document IN OUT NOCOPY VARCHAR2,
10193 document_type IN OUT NOCOPY VARCHAR2
10194 ) is
10195 BEGIN
10196
10197 document := to_char(sysdate);
10198
10199 IF(display_type = 'text/html') THEN
10200 document_type := 'text/html';
10201 ELSE
10202 document_type := 'text/plain';
10203 END IF;
10204
10205 END;
10206
10207 PROCEDURE get_sales_assist_rsn_meaning(
10208 document_id IN VARCHAR2,
10209 display_type IN VARCHAR2,
10210 document IN OUT NOCOPY VARCHAR2,
10211 document_type IN OUT NOCOPY VARCHAR2 ) is
10212 cursor c_fnd_lookup_value(c_fnd_code VARCHAR2) is
10213 select meaning
10214 from aso_lookups /* Bug 13767382, scnagara - changed from fnd_lookups to aso_lookups*/
10215 where lookup_type = 'ASO_SALESREP_ASSISTANCE_REASON'
10216 and lookup_code = c_fnd_code;
10217
10218 rec_fnd_lkpup_value c_fnd_lookup_value%rowtype;
10219 BEGIN
10220
10221 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10222 IBE_UTIL.DEBUG('get_sales_assist_rsn_meaning:Document_id: '||document_id);
10223 END IF;
10224 FOR rec_fnd_lookup_value in c_fnd_lookup_value(document_id) LOOP
10225 document := rec_fnd_lookup_value.meaning;
10226 EXIT when c_fnd_lookup_value%NOTFOUND;
10227 END LOOP;
10228
10229 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10230 IBE_UTIL.DEBUG('get_sales_assist_rsn_meaning:Document: '||document);
10231 END IF;
10232
10233 IF(display_type = 'text/html') THEN
10234 document_type := 'text/html';
10235 ELSE
10236 document_type := 'text/plain';
10237 END IF;
10238 END get_sales_assist_rsn_meaning;
10239
10240 FUNCTION buildDocument
10241 (
10242 notif_line_tbl IN Notif_Line_Tbl_Type,
10243 view_net_price_flag VARCHAR2,
10244 view_line_type_flag VARCHAR2,
10245 tax_flag VARCHAR2
10246 ) return VARCHAR2
10247 is
10248 counter Number;
10249 ldocument VARCHAR2(32000) := '';
10250 l_string_in VARCHAR2(495);
10251 l_string_left VARCHAR2(495);
10252 l_string_out VARCHAR2(495);
10253 l_line_num NUMBER := 1;
10254 l_can_amt NUMBER;
10255 l_amt_format VARCHAR2(20);
10256 l_curr_sym FND_CURRENCIES.SYMBOL%TYPE;
10257 l_space_len NUMBER := 56;
10258 l_temp_str VARCHAR2(100);
10259 BEGIN
10260
10261 l_curr_sym := g_curr_sym;
10262 l_amt_format := g_amt_format;
10263 for counter in 1..notif_line_tbl.count loop
10264 l_space_len := 56;
10265 if(view_line_type_flag = fnd_api.g_true) then
10266 if(Notif_Line_Tbl(counter).Action is not null AND Notif_Line_Tbl(counter).Action <> FND_API.G_MISS_CHAR) then
10267 ldocument := ldocument || rpad(Notif_Line_Tbl(counter).Action,9,' ')||' ';
10268 else
10269 ldocument := ldocument || lpad(' ',9)||' ';
10270 end if;
10271 end if;
10272 l_string_in := Notif_Line_Tbl(counter).Product;
10273 parseString
10274 (p_string_in => l_string_in,
10275 p_string_len => 28,
10276 p_string_out => l_string_out,
10277 p_string_left => l_string_left);
10278 ldocument := ldocument || rpad(l_string_out,28)||' ';
10279 ldocument := ldocument || lpad(trim(Notif_Line_Tbl(counter).UOM),8)||' ';
10280 ldocument := ldocument || lpad(trim(Notif_Line_Tbl(counter).Quantity),7)||' ';
10281 if(view_line_type_flag <> fnd_api.g_true) then
10282 ldocument := ldocument || lpad(trim(Notif_Line_Tbl(counter).Shippable),9)||' ';
10283 end if;
10284 if(view_net_price_flag = 'Y') then
10285 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(Notif_Line_Tbl(counter).NetAmount));
10286 ldocument := ldocument || lpad(trim(l_curr_sym)||trim(to_char(to_number(l_can_amt),l_amt_format)),16);
10287 end if;
10288 ldocument := ldocument ||NEWLINE;
10289 l_string_in := l_string_left;
10290 if(length(l_string_in) > 0) THEN
10291 if(view_line_type_flag = fnd_api.g_true) then
10292 ldocument := ldocument || rpad(' ',9)||' ';
10293 end if;
10294 parseString
10295 (p_string_in => l_string_in,
10296 p_string_len => 28,
10297 p_string_out => l_string_out,
10298 p_string_left => l_string_left);
10299 ldocument := ldocument || rpad(trim(l_string_out),28)||' ';
10300 if(view_line_type_flag = fnd_api.g_true) then
10301 l_space_len := l_space_len - 39;
10302 else
10303 l_space_len := l_space_len - 29;
10304 end if;
10305 if (Notif_Line_Tbl(counter).Periodicity is not null) then
10306 ldocument := ldocument || lpad(' ',l_space_len) || lpad(trim(Notif_Line_Tbl(counter).Periodicity),16)||NEWLINE;
10307 else
10308 ldocument := ldocument ||lpad(' ',l_space_len)||lpad(' ',16)||NEWLINE;
10309 end if;
10310 else
10311 if (Notif_Line_Tbl(counter).Periodicity is not null) then
10312 ldocument := ldocument || lpad(' ',l_space_len) || lpad(trim(Notif_Line_Tbl(counter).Periodicity),16)||NEWLINE;
10313 end if;
10314 END IF;
10315 l_string_in := l_string_left;
10316 WHILE length(l_string_in) > 0 LOOP
10317 l_string_out := '';
10318 l_string_left := '';
10319 parseString(l_string_in,28,l_string_out,l_string_left);
10320 ldocument := ldocument || rpad(trim(l_string_out),28) ||NEWLINE;
10321 l_string_in := l_string_left;
10322 END LOOP;
10323 IF(tax_flag = fnd_api.g_true) then
10324 IF view_net_price_flag = 'Y' THEN
10325 fnd_message.set_name('IBE','IBE_PRMT_ORD_TAX');
10326 l_temp_str := null;
10327 l_temp_str := fnd_message.get;
10328 l_can_amt := ibe_util.nls_number_format(p_number_in => to_char(Notif_Line_Tbl(counter).TaxAmount));
10329 ldocument := ldocument ||lpad(l_temp_str||': '||l_curr_sym||to_char(to_number(l_can_amt),l_amt_format),72,' ')||NEWLINE;
10330 END IF;
10331 END IF;
10332
10333 IF (FND_API.To_Boolean(Notif_Line_Tbl(counter).LastItem) and counter <> Notif_Line_Tbl.count) THEN
10334 ldocument := ldocument || '------------------------------------------------------------------------'||NEWLINE;
10335 END IF;
10336 IF (IBE_UTIL.G_DEBUGON = l_true) THEN
10337 IBE_UTIL.DEBUG('Going to print ldocument in buildDocument'||ldocument);
10338 END IF;
10339 end loop;
10340 return ldocument;
10341 END buildDocument;
10342
10343 PROCEDURE ParseThisString (
10344 p_string_in IN VARCHAR2,
10345 p_string_len IN NUMBER := 12,
10346 p_string_out OUT NOCOPY VARCHAR2,
10347 p_string_left OUT NOCOPY VARCHAR2
10348 ) IS
10349
10350 l_lengthy_word BOOLEAN;
10351 l_line_length NUMBER;
10352 l_length NUMBER;
10353 l_lim NUMBER;
10354 i NUMBER;
10355 j NUMBER;
10356 l_pos NUMBER;
10357
10358 BEGIN
10359 l_length := length(p_string_in);
10360 IF ( l_length < l_line_length ) THEN
10361 p_string_out := rpad(p_string_in,p_string_len,' ');
10362 p_string_left := '';
10363 ELSE
10364 p_string_out := substr(p_string_in,1,p_string_len);
10365 p_string_out := rpad(p_string_out,p_string_len,' ');
10366 p_string_left := substr(p_string_in,p_string_len+1,length(p_string_in)-p_string_len);
10367 END IF;
10368 END ParseThisString;
10369
10370 PROCEDURE parseString (
10371 p_string_in IN VARCHAR2,
10372 p_string_len IN NUMBER := 12,
10373 p_string_out OUT NOCOPY VARCHAR2,
10374 p_string_left OUT NOCOPY VARCHAR2
10375 ) IS
10376
10377 l_lengthy_word BOOLEAN;
10378 l_length NUMBER;
10379 l_lim NUMBER;
10380 i NUMBER;
10381 j NUMBER;
10382 l_pos NUMBER;
10383
10384 BEGIN
10385 l_length := length(p_string_in);
10386 IF ( l_length <= p_string_len ) THEN
10387 p_string_out := rpad(p_string_in,p_string_len,' ');
10388 p_string_left := '';
10389 ELSE
10390 p_string_out := substr(p_string_in,1,p_string_len);
10391 p_string_out := rpad(p_string_out,p_string_len,' ');
10392 p_string_left := substr(p_string_in,p_string_len+1,length(p_string_in)-p_string_len);
10393 END IF;
10394 END parseString;
10395
10396 END ibe_workflow_pvt;