/* $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_payslip_v
AS
SELECT b.menu_id
      ,b.function_id
      ,b.function_name
	  ,b.seeded_block_flag
      ,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
      ,b.description
      ,b.function_icon
      ,b.security_type type_of_security
      ,upper(b.block_type) block_type
      ,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
      ,f.function_id data_function_id
      ,xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pOrderBy') order_by
      ,CASE WHEN xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pPersonIdColumnName') IS NOT NULL 
              OR xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pAssignmentIdColumnName') IS NOT NULL 
              OR xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pTransactionIdColumnName') IS NOT NULL 
              OR xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pPartyIdColumnName') IS NOT NULL 
            THEN 'Y'
            ELSE 'N'
       END  show_joining_columns
      ,xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pPersonIdColumnName') person_id_column_name
      ,xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pAssignmentIdColumnName') Assignment_Id_Column_Name
      ,xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pTransactionIdColumnName') transaction_id_column_name
      ,xxas_com_sec_pkg.get_parameter_value(f.parameters, 'pPartyIdColumnName') party_Id_Column_Name
      ,o.object_id data_object_id
      ,xxas_com_sec_pkg.get_parameter_value(function_parameters, 'pPayslipsFormulaName') payslips_formula_name
	  ,xxas_com_sec_pkg.get_parameter_value(function_parameters, 'pDataDefinitionApp') data_def_app
	  ,xxas_com_sec_pkg.get_parameter_value(function_parameters, 'pDataDefinitionCode') data_def_code
      ,xxas_com_msg_pkg.get_string(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pNoDataMessage')) no_data_text
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pNoDataMessage') no_data_message
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pBackgroundColor') background_color
      ,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
       FROM xxas_blocks_v b 
          , fnd_objects_vl o 
          , fnd_form_functions f
          , xxas_pages_v p
       WHERE  b.block_type = 'payslip'
          AND o.object_id (+) = f.object_id
          AND f.function_name(+) = xxas_com_sec_pkg.get_parameter_value(function_parameters, 'pPayslipsDataFunction')
          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_PAYSLIP_V'
   ,p_description            => 'Applaud Block Payslip');
END;
/

COMMIT;
EXIT;

