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

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

DECLARE

  l_VIEW_NAME CONSTANT fnd_views.view_name%TYPE
    := 'XXAS_TCM_PERIOD_ASSIGNMENTS_V';

  l_VIEW_TEXT CONSTANT varchar2(32767)
    := ' SELECT xtp.period_id '
    || ' ,      xtp.period_name '
    || ' ,      xtp.start_date '
    || ' ,      xtp.end_date '
    || ' ,      xtpa.assignment_id '
    || ' ,      xtpa.person_id '
    || ' ,      xtpa.late_start '
    || ' ,      xtpa.early_finish '
    || ' FROM   xxas_tcm_periods            xtp '
    || ' ,      xxas_tcm_period_assignments xtpa '
    || ' WHERE  xtp.period_id = xtpa.period_id ';

BEGIN

  -- 
  -- Register the XXAS_TCM_PERIOD_ASSIGNMENTS_V view
  --
  fnd_dictionary_pkg.UploadView
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_text                   => l_VIEW_TEXT
    ,x_description            => 'Timecard periods by assignment'
    ,x_user_id                => xxas_util_pkg.app);
    
  -- 
  -- Register the view columns
  --
  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'PERIOD_ID'
    ,x_view_column_sequence   => '5'
    ,x_user_id                => xxas_util_pkg.app);

  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'ASSIGNMENT_ID'
    ,x_view_column_sequence   => '10'
    ,x_user_id                => xxas_util_pkg.app);
    
  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'PERSON_ID'
    ,x_view_column_sequence   => '15'
    ,x_user_id                => xxas_util_pkg.app);
    
  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'PERIOD_NAME'
    ,x_view_column_sequence   => '20'
    ,x_user_id                => xxas_util_pkg.app);
    
  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'START_DATE'
    ,x_view_column_sequence   => '25'
    ,x_user_id                => xxas_util_pkg.app);
    
  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'END_DATE'
    ,x_view_column_sequence   => '30'
    ,x_user_id                => xxas_util_pkg.app);
    
  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'LATE_START'
    ,x_view_column_sequence   => '35'
    ,x_user_id                => xxas_util_pkg.app);
    
  fnd_dictionary_pkg.UploadViewColumn
    (x_application_short_name => xxas_util_pkg.app
    ,x_view_name              => l_VIEW_NAME
    ,x_view_column_name       => 'EARLY_FINISH'
    ,x_view_column_sequence   => '40'
    ,x_user_id                => xxas_util_pkg.app);

END;
/
COMMIT;
EXIT;
