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

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

DECLARE

  --
  -- Local constants
  --
  l_MODULE_PKG    CONSTANT varchar2(30) := 'HR_PERSON_ABSENCE_API';
  l_BUSINESS_PROC CONSTANT varchar2(2)  := 'BP';
  l_BEFORE_PROC   CONSTANT varchar2(2)  := 'BP';
  l_AFTER_PROC    CONSTANT varchar2(2)  := 'AP';
  l_CALL_PKG      CONSTANT varchar2(30) := 'XXAS_OUT_ABS_HOOK_PKG';
  l_YES           CONSTANT varchar2(1)  := 'Y';
  l_api_module_id number;

BEGIN

  --
  -- Register the Absence After Create Hook
  --
  XXAS_util_pkg.register_api_hook
    (p_module_package => l_MODULE_PKG
    ,p_module_name    => 'CREATE_PERSON_ABSENCE'
    ,p_module_type    => l_BUSINESS_PROC
    ,p_hook_type      => l_AFTER_PROC
    ,p_call_package   => l_CALL_PKG
    ,p_call_procedure => 'AFTER_CREATE'
    ,p_enabled_flag   => l_YES);

  select api_module_id
  into l_api_module_id from hr_api_modules
  where module_name = 'CREATE_PERSON_ABSENCE';

  hr_api_user_hooks_utility.create_hooks_add_report(l_api_module_id);

  --
  -- Register the Absence After Update Hook
  --
  XXAS_util_pkg.register_api_hook
    (p_module_package => l_MODULE_PKG
    ,p_module_name    => 'UPDATE_PERSON_ABSENCE'
    ,p_module_type    => l_BUSINESS_PROC
    ,p_hook_type      => l_BEFORE_PROC
    ,p_call_package   => l_CALL_PKG
    ,p_call_procedure => 'BEFORE_UPDATE'
    ,p_enabled_flag   => l_YES);

  select api_module_id
  into l_api_module_id from hr_api_modules
  where module_name = 'UPDATE_PERSON_ABSENCE';

  hr_api_user_hooks_utility.create_hooks_add_report(l_api_module_id);

  --
  -- Register the Absence After Delete Hook
  --
  XXAS_util_pkg.register_api_hook
    (p_module_package => l_MODULE_PKG
    ,p_module_name    => 'DELETE_PERSON_ABSENCE'
    ,p_module_type    => l_BUSINESS_PROC
    ,p_hook_type      => l_BEFORE_PROC
    ,p_call_package   => l_CALL_PKG
    ,p_call_procedure => 'BEFORE_DELETE'
    ,p_enabled_flag   => l_YES);

  select api_module_id
  into l_api_module_id from hr_api_modules
  where module_name = 'DELETE_PERSON_ABSENCE';

  hr_api_user_hooks_utility.create_hooks_add_report(l_api_module_id);

END;
/
COMMIT;
EXIT;
