/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2016 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

create or replace view xxas_block_actions_v as
select function_id,
       (SELECT m.message_text 
        FROM   fnd_new_messages m 
        WHERE  m.message_name =xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pTitle')
        AND    m.language_code = USERENV('LANG'))                   Ba_Title,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pTitle') TITLE_NAME,
       object_id,
	   (select obj_name from fnd_objects_vl
       where object_id = b.object_id) obj_name,
       decode(object_id,null,'N','Y') OBJ_EXISTS_FLAG,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pOperation') operation,
       web_icon ba_icon,
       CASE
       WHEN xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pPageId') is not NULL THEN
       'EmployeeCenter Page'
       WHEN xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pHref') is not NULL and xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pOperation') = 'LINK' THEN
       'External URL'
       END TYPE,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pPageId') Page,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pObjectId') ObjectId,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pHref') Url,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pHref') Restend,
       decode(xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pTarget'),'modal','Y','N') Modal,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pWeight') Weight,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pColor') Color,
       decode(xxas_com_sec_pkg.get_parameter_value(b.parameters, 'confirmation'),'true','Y',null) Confirmation,
       xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pConfirmationMessage') Message,
       (select menu_id from xxas_pages_v where actions like '%'||b.function_name||'%'
       and rownum = 1) menu_id
from fnd_form_functions b;
BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'xxas_block_actions_v'
   ,p_description            => 'Applaud Block Actions');
END;
/
COMMIT;
EXIT;
