UPDATE TBDD_MODULES SET PRODUCT_VERSION = '2.4.6.0' where NAME = 'Record-Organizer' 
GO
ALTER TABLE TBPMO_FORM
ADD LOCK_CONTROLS_BG_LOAD BIT NOT NULL DEFAULT 1
GO
ALTER VIEW VWPMO_CONSTRUCTOR_FORMS AS
SELECT TOP 100 PERCENT
	T2.GUID,
	T1.GUID FORM_VIEW_ID,
	T1.SCREEN_ID,
	T2.CONSTRUCT_ID,
	T.PARENT_ID,
	T2.SEQUENCE,
	T2.LEVEL1_SELECT,
	T.GUID			AS FORM_ID, 
	T1.FORM_TITLE, 
	T2.SQL_SELECT_EBENE1,
	T2.SQL_SELECT_EBENE2,
	T2.SQL_QUICK_VIEW,
	T2.COLUMN_NAME1,
	T2.COLUMN_NAME2,
	T.FORM_TYPE_ID,
	T2.LOAD_DIRECT,
	T2.CONTROL_DOCTYPE_MATCH,
	T2.SQL_RIGHT_READ_AND_VIEW_ONLY,
	T2.SQL_RIGHT_WINDREAM_VIEW,
	T1.DOCUMENT_VIEW,
	T.DATE_FORMAT,
	T.LOCK_CONTROLS_BG_LOAD,
	(SELECT COUNT(GUID) FROm TBPMO_CONTROL WHERE FORM_ID = T1.FORM_ID AND TREE_VIEW = 1) AS COUNT_TREEVIEW
FROM 
	tbpmo_form T, 
	TBPMO_FORM_VIEW T1,
	TBPMO_FORM_CONSTRUCTOR_DETAIL T2 
where 
	T2.FORM_ID = T.GUID AND
	T.GUID = T1.FORM_ID 
ORDER BY 
	T2.CONSTRUCT_ID,T.PARENT_ID,T2.SEQUENCE
GO
CREATE FUNCTION [dbo].[FNPMO_DOC_GET_DROPDOWN](@pDOCID INTEGER, @pENTITY INTEGER, @DOC_DD VARCHAR(20), @LANGUAGE VARCHAR(5))
RETURNS VARCHAR(250)
AS
BEGIN
	DECLARE @HEADER_CAPTION VARCHAR(30), 
		@CONFIG_ID INTEGER, @VALUE VARCHAR(250), @RESULT VARCHAR(250)
	SELECT 
		@HEADER_CAPTION = HEADER_CAPTION,
		@CONFIG_ID = GUID FROM TBPMO_DOCSEARCH_RESULTLIST_CONFIG WHERE 
	ENTITY_ID = @pENTITY AND COLUMN_VIEW = @DOC_DD AND LANGUAGE = @LANGUAGE

	IF @HEADER_CAPTION IS NULL
		SET @RESULT = 'NO DROP-DOWN CONFIGURATION'
	ELSE
		BEGIN
			SELECT @VALUE =  VALUE FROM TBPMO_DOC_VALUES WHERE DocID = @pDOCID AND CONFIG_ID = @CONFIG_ID
			IF @VALUE IS NOT NULL
				SET @RESULT = @VALUE
			ELSE
				SET @RESULT = 'NO RESULT'
		END
	RETURN @RESULT
END

GO





