SELECT FSACTIONWIPSTEPS.TARGET_OBJECT_KEY AS PROJECT_CODE, FSACTIONWIPSTEPS.ACTION_CODE, FSACTIONWIPSTEPS.DESCRIPTION,
(SELECT ENUM_LABEL AS STATUS FROM FSVALIDENUMVAL EV, FSVALIDENUMLABEL EL WHERE EV.ENUM_ORDER = EL.ENUM_ORDER AND EV.ENUM_VALUE = FSACTIONWIPSTEPS.QUEUE_STATUS_IND
AND EL.ENUM_CODE = 'QUEUESTATUSIND' AND EV.ENUM_CODE = 'QUEUESTATUSIND' AND EL.LANGUAGE_CODE = 'EN-US') AS 'QUEUE STATUS',
CONVERT(DATETIME, FSACTIONWIPSTEPS.START_DATE) AS START_DATE, CONVERT(DATETIME, FSACTIONWIPSTEPS.DUE_DATE) AS DUE_DATE, FSACTIONWIPSTEPS.TARGET_OBJECT_KEY AS DR_PROJECT_PROJECT_CODE,
CASE FSACTIONWIPSTEPS.DESCRIPTION
WHEN 'IDEATION STAGE' THEN '#CFF5F5'
WHEN 'DOCUMENT IDEA' THEN '#F4B8C4'
WHEN 'SUBMIT' THEN 'PALEGREEN'
WHEN 'APPROVAL STAGE' THEN 'RED'
WHEN 'MARKETING APPROVAL' THEN 'BLUE'
WHEN 'MANUFACTURING APPROVAL' THEN 'GREEN'
WHEN 'EXECUTIVE APPROVAL' THEN '#FF5733'
END AS F_BG_PROJECT_CODE,
CASE FSACTIONWIPSTEPS.ACTION_CODE
WHEN 'APPROVE/REJECT' THEN '#C3228B'
WHEN 'RETURN/APPROVE' THEN '#F4B8C4'
WHEN 'SUBMIT CONCEPT' THEN 'PALEGREEN'
WHEN 'CONCEPT REVIEW' THEN 'RED'
WHEN 'PLANNING' THEN 'BLUE'
WHEN 'DEVELOPMENT' THEN 'GREEN'
WHEN 'VALIDATION' THEN '#FF5733'
WHEN 'PRODUCT LAUNCH' THEN '#C4FF33'
WHEN 'PROJECT CLOSURE' THEN '#33FFF9'
WHEN 'SUBMIT CONCEPT' THEN '#FF33F3'
END AS F_FG_ACTION_CODE,
(SELECT CASE WHEN DATEADD(DAY, 5, GETDATE()) <= CONVERT(DATE,FSACTIONWIPSTEPS.DUE_DATE) THEN 'MAJOR_DELAY' WHEN DATEADD(DAY, 4, GETDATE()) <= CONVERT(DATE,
FSACTIONWIPSTEPS.DUE_DATE) THEN 'MINOR_DELAY' WHEN DATEADD(DAY, 3, GETDATE()) >= CONVERT(DATE, FSACTIONWIPSTEPS.DUE_DATE) THEN 'ON_TIME'
END) AS F_STATUS_ICON_PROJECT_STATUS
FROM FSACTIONWIPSTEPS
INNER JOIN FSACTIONWIP
ON FSACTIONWIP.ACTIONWIP_ID = FSACTIONWIPSTEPS.ACTIONWIP_ID WHERE FSACTIONWIPSTEPS.TARGET_OBJECT_SYMBOL = 'PROJECT' AND FSACTIONWIP.STAGE_GATE_IND = 1