/* $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_blocks_all_v
AS
SELECT  lower(xxas_com_sec_pkg.get_parameter_value(cf.parameters, 'pModule')) block_type
        ,cf.function_id
        ,cf.function_name
        ,cf.object_id
        ,cf.obj_name
        ,cf.parameters function_parameters
        ,cf.web_icon function_icon
        ,decode(cf.object_id, null, 'RO', 'RD') security_type
        ,decode(upper(substr(cf.function_name, 1, 4)), 'XXAS', 'Y', 'N') seeded_block_flag
        ,cf.object_values block_values
FROM    (SELECT f.function_id
                ,f.function_name
                ,f.object_id
                ,o.obj_name
                ,f.parameters
                ,f.web_icon
                ,xov.object_values
          FROM   fnd_form_functions_vl f
                ,fnd_objects o
                ,xxas_object_values xov
          WHERE  f.object_id = o.object_id(+)
          AND    f.function_id = xov.object_id(+)
          AND    xov.object_type = 'BLOCK') cf
WHERE    cf.function_id IS NOT NULL
AND      xxas_com_sec_pkg.get_parameter_value(cf.parameters, 'pModule') IS NOT NULL;

BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_BLOCKS_ALL_V'
   ,p_description            => 'Applaud All Blocks');
END;
/

COMMIT;
EXIT;

