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