UPDATE TBDD_MODULES SET DB_VERSION = '2.2.2.0' where NAME = 'Process-Manager'
GO
--UPDATE TBDD_SQL_COMMANDS SET SQL_COMMAND = 
--  'select T.*  FROm VWPM_PROFILE_ACTIVE T where T.FILE_COUNT > 0 and T.GUID IN (SELECT PROFILE_ID FROm dbo.FNPM_GET_ACTIVE_PROFILES_USER (@USER_ID))
--UNION
--select T.*  FROm VWPM_PROFILE_ACTIVE T where T.DISPLAY_MODE like ''AdHoc BlindFile%'' and T.GUID IN (SELECT PROFILE_ID FROm dbo.FNPM_GET_ACTIVE_PROFILES_USER (@USER_ID))'
--WHERE TITLE = 'PM_PROFILES_USER'
--GO
IF COL_LENGTH('TBPM_PROFILE', 'DISPLAY_MODE') IS NOT NULL
BEGIN
	-- Column Exists
	ALTER TABLE TBPM_PROFILE 
	ALTER COLUMN DISPLAY_MODE VARCHAR(250)	NOT NULL;
END
IF COL_LENGTH('TBPM_PROFILE', 'SHOW_DOCUMENT') IS NOT NULL
BEGIN
	ALTER TABLE TBPM_PROFILE 
	ADD SHOW_DOCUMENT BIT NOT NULL DEFAULT 1;
END
IF COL_LENGTH('TBPM_PROFILE', 'WM_DRIVE_LETTER') IS NOT NULL
BEGIN
	ALTER TABLE TBPM_KONFIGURATION 
	ADD WM_DRIVE_LETTER VARCHAR(1)	NOT NULL DEFAULT 'W';
END

GO
--Changed:	30.11.2022	MS	SHOW_DOC
ALTER VIEW [dbo].[VWPM_PROFILE_ACTIVE] AS 
SELECT 
	T1.[GUID]
      ,T1.[NAME]
      ,T1.[TITLE]
      ,T1.[WD_OBJECTTYPE]
      ,T1.[PRIORITY]
      ,T1.[DESCRIPTION]
      ,T1.[TYPE]
      ,T1.[LOG_INDEX]
      ,T1.[IN_WORK]
      ,T1.[ACTIVE]
      ,T1.[WD_SEARCH]
      ,T1.[PM_VEKTOR_INDEX]
      ,T1.[NO_OF_DOCUMENTS]
      ,T1.[FINAL_PROFILE]
      ,T1.[FINAL_TEXT]
      ,T1.[MOVE2FOLDER]
      ,T1.[SORT_BY_LATEST]
      ,T1.[WORK_HISTORY_ENTRY]
      ,T1.[ANNOTATE_ALL_WORK_HISTORY_ENTRIES]
      ,T1.[ANNOTATE_WORK_HISTORY_ENTRY]
      ,T1.[SQL_VIEW]
      ,T1.[ADDED_WHO]
      ,T1.[ADDED_WHEN]
      ,T1.[CHANGED_WHO]
      ,T1.[CHANGED_WHEN]
     -- ,T1.[SQL_GROUP_COLOR]
     -- ,T1.[SQL_GROUP_TEXT]
      ,T1.[DISPLAY_MODE]
	  ,T1.SHOW_DOCUMENT


	,(SELECT COUNT(GUID) FROM TBPM_PROFILE_FILES WHERE PROFIL_ID = T1.GUID) AS FILE_COUNT,
	[dbo].[FNPM_PROFILE_GROUP_COLOR] (T1.GUID) AS 'GROUP_COLOR',
	dbo.FNPM_PROFILE_GROUP_FONT_COLOR (T1.GUID) AS 'GROUP_FONT_COLOR',
	[dbo].[FNPM_PROFILE_GROUP_TEXT] (T1.GUID) AS 'GROUP_TEXT'
FROM 
	TBPM_PROFILE T1
WHERE 
	T1.ACTIVE = 1
GO
