/* $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_PERF_PLAN_DASHBOARD_SWI_V
AS
SELECT  'flexible' "type"
       ,person_id
       ,title "line1"
       ,start_date
       ,'<font color="'
     || xxas_rslt_cache_pkg.resolve_color_name('grey')
     || '">'
     || to_char(start_date,'Fmdd Mon YYYY')
     || ' to '
     || to_char(end_date,'Fmdd Mon YYYY')
     || '</font>' "line3"
       ,'performance-dashboard' "pageId"
       ,person_id || '_' || perf_plan_id "objectId"
   FROM
  (SELECT distinct xpp.perf_plan_id, xpp.start_date, xpp.end_date,papf.person_id,xpp.title
  FROM  xxas_perf_plans xpp
       ,xxas_perf_plan_enrollments xppe
       ,per_all_people_f papf
  WHERE xpp.perf_plan_id = xppe.perf_plan_id
  AND   xxas_com_hier_pkg.is_per_report_of_person(papf.person_id, xppe.PERSON_ID) = 'Y'
  AND   trunc(SYSDATE) BETWEEN papf.effective_start_date AND papf.effective_end_date);

BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_PERF_PLAN_DASHBOARD_SWI_V'
   ,p_description            => 'Applaud Performance Plan Dashboard Switch List');
END;
/

COMMIT;
EXIT;