/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2014 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_per_asg_history_v 
AS
SELECT IAS.ASSIGNMENT_ID,
  IAS.ASSIGNMENT_STATUS_ID,
  IAS.STATUS_CHANGE_DATE,
  decode(IAS.STATUS_CHANGE_REASON,null,null,hr_general.decode_lookup('APL_ASSIGN_REASON',STATUS_CHANGE_REASON)) as STATUS_CHANGE_REASON,
  AST.USER_STATUS AS ASSIGNMENT_STATUS,
  AST.ASSIGNMENT_STATUS_TYPE_ID,
  AST.EXTERNAL_STATUS
FROM PER_ASSIGNMENT_STATUS_TYPES_V AST,
  IRC_ASSIGNMENT_STATUSES IAS
WHERE 
IAS.ASSIGNMENT_STATUS_TYPE_ID = AST.ASSIGNMENT_STATUS_TYPE_ID
ORDER BY IAS.STATUS_CHANGE_DATE DESC;
BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'xxas_per_asg_history_v'
   ,p_description            => 'Applaud Person Applicant Assignment History');
END;
/
  
COMMIT;
EXIT;