/* $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_chart_v
AS
SELECT b.menu_id
      ,b.function_id
      ,b.function_name
      ,b.entry_sequence
      ,b.prompt
      ,b.object_id
      ,b.obj_name
	  ,decode(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pHideIf'),null,'N','Y') RESTRICT_DEVICE
      ,(xxas_block_pkg.get_restrictions(b.function_parameters)) RESTRICTIONS
      ,upper(b.block_type) block_type
      ,b.description
      ,xxas_util_pkg.boolean_to_flag(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pStamp')) stamp
      ,xxas_util_pkg.boolean_to_flag(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pFullWidth')) full_width
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pBackgroundColor') background_color      
      ,b.function_icon
      ,b.security_type type_of_security
      ,CASE WHEN xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pChartXmlFunction') IS NOT NULL THEN
              'EBS'
            WHEN existsNode(b.block_values, 'v/chartSettings') > 0 THEN
              'AC'
       END data_source
      ,extractValue(b.block_values, 'v/chartSettings') chart_settings_json
      ,extractValue(b.block_values, 'v/exportSettings') chart_export_json
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pChartXmlFunction') data_provider_function
      ,p.context_handler page_object_handler
      ,p.object_id_format page_object_id_format
      ,CASE WHEN p.layout = 'columns2'
            THEN 'Y'
            WHEN p.layout = 'columns3'
            THEN 'Y'
            ELSE 'N'
       END  is_page_column_layout
      ,p.layout page_layout
	  ,CASE WHEN p.layout = 'columns3' 
			THEN decode(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pBlockSize'),'two-third','Two-third','full-width','Full width','One-third') 
			ELSE NULL
		END BLOCK_SIZE
      ,b.seeded_block_flag
FROM   xxas_blocks_v b
      ,xxas_pages_v p
WHERE  b.block_type = 'chart'
AND    b.menu_id    = p.menu_id;

BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_BLOCK_CHART_V'
   ,p_description            => 'Applaud Block Chart');
END;
/

COMMIT;
EXIT;

