UPDATE TBDD_MODULES SET DB_VERSION = '2.3.0.0' where NAME = 'Process-Manager'
GO

IF NOT EXISTS(SELECT 1 FROM sys.columns 
          WHERE Name = N'SQL_BTN_REJECT'
          AND Object_ID = Object_ID(N'dbo.TBPM_PROFILE'))
BEGIN
    PRINT 'COLUMN [SQL_BTN_REJECT] NOT EXISTING...'
	ALTER TABLE TBPM_PROFILE ADD SQL_BTN_REJECT NVARCHAR(MAX) NOT NULL DEFAULT ''
END
ELSE
	PRINT 'COLUMN [SQL_BTN_REJECT] DOES EXIST'
GO
IF NOT EXISTS(SELECT 1 FROM sys.columns 
          WHERE Name = N'BTN_REJECT_CAPTION'
          AND Object_ID = Object_ID(N'dbo.TBPM_PROFILE'))
BEGIN
    PRINT 'COLUMN [BTN_REJECT_CAPTION] NOT EXISTING...'
	ALTER TABLE TBPM_PROFILE ADD BTN_REJECT_CAPTION NVARCHAR(100) NOT NULL DEFAULT ''
END
ELSE
	PRINT 'COLUMN [BTN_REJECT_CAPTION] DOES EXIST'
GO
ALTER TABLE TBPM_PROFILE ADD REJECT_SQL_REASONS NVARCHAR(3000) NOT NULL DEFAULT ''
GO
ALTER TABLE TBPM_PROFILE ADD REJECT_ACTIONS_ATTRIBUTE VARCHAR(100) NOT NULL DEFAULT ''
GO
ALTER TABLE TBPM_PROFILE ADD REJECT_COMMENT_ATTRIBUTE VARCHAR(100) NOT NULL DEFAULT ''
GO

ALTER PROCEDURE PRTF_PROFILE_LANGUAGE_PHRASES AS 
DECLARe @ID VARCHAR(3),@TITLE VARCHAR(100),@DECR VARCHAR(100),@FINAL_TEXT VARCHAR(100),@REJ_TEXT VARCHAR(100)
DECLARE cur2 CURSOR FOR 
	select GUID, TITLE,DESCRIPTION,FINAL_TEXT,BTN_REJECT_CAPTION from TBPM_PROFILE 
OPEN cur2 
FETCH NEXT FROM cur2 INTO @ID,@TITLE,@DECR,@FINAL_TEXT,@REJ_TEXT
WHILE @@FETCH_STATUS = 0
BEGIN
	Declare @IDTEXT VARCHAR(100)
	SET @IDTEXT = 'PROFILE_TITLE' + @ID
	PRINT @IDTEXT
	EXEC PRDD_GUI_LANGUAGE_PHRASE 'PM',@IDTEXT,'de-DE','Title of Profile',@TITLE,'','System',@ID,0
	IF @DECR IS NOT NULL
		BEGIN
			SET @IDTEXT = 'PROFILE_DESCRIPTION' + @ID
			EXEC PRDD_GUI_LANGUAGE_PHRASE 'PM',@IDTEXT,'de-DE','Description of Profile',@DECR,'','System',@ID,0
		END
		IF @FINAL_TEXT IS NOT NULL
			BEGIN
				SET @IDTEXT = 'PROFILE_FINAL_TEXT' + @ID
				EXEC PRDD_GUI_LANGUAGE_PHRASE 'PM',@IDTEXT,'de-DE','BTN_FINAL_CAPT',@FINAL_TEXT,'','System',@ID,0
			END
		IF LEN(@REJ_TEXT) > 0
			BEGIN
				SET @IDTEXT = 'PROFILE_REJECTION_CAPT' + @ID
				EXEC PRDD_GUI_LANGUAGE_PHRASE 'PM',@IDTEXT,'de-DE', 'PROFILE_REJECTION_CAPT',@REJ_TEXT,'','System',@ID,0
			END
		FETCH NEXT FROM cur2 INTO @ID,@TITLE,@DECR,@FINAL_TEXT,@REJ_TEXT
END
CLOSE cur2
DEALLOCATE cur2



