
------------------------------------------------------------------------------
-- ADVANTAGE 2004.3.5
-- OPTIONS and APPLICATION SINCE ADVANTAGE 2004.3.4
-- 24 JUN 2007
------------------------------------------------------------------------------


--************************************************
--******     NB. NB. NB. RUN ONLY ONCE     *******
--************************************************


-- USE ADV2004
-- GO



----------------------------------------------------------------
-- New Options
----------------------------------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'CheckBox' AND
              Control_Name = 'chkShowJobRefNo' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'CheckBox',
                'chkShowJobRefNo',
                0,
                '0'
            )
    END

----------------------------------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'CheckBox' AND
              Control_Name = 'chkSellNegativeQty' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'CheckBox',
                'chkSellNegativeQty',
                0,
                '0'
            )
    END

----------------------------------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'CheckBox' AND
              Control_Name = 'chkStockOnHandJob' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'CheckBox',
                'chkStockOnHandJob',
                0,
                '0'
            )
    END

----------------------------------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'CheckBox' AND
              Control_Name = 'chkPOSAccountOverdueJOB' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'CheckBox',
                'chkPOSAccountOverdueJOB',
                0,
                '0'
            )
    END

----------------------------------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'CheckBox' AND
              Control_Name = 'chkStockReservedJob' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'CheckBox',
                'chkStockReservedJob',
                0,
                '0'
            )
    END

----------------------------------------------------------------------------


----------------------------------------------------------------
-- New Applications
----------------------------------------------------------------

DECLARE @AppID int 


IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Enterprise Reports' AND
              Form_Name = 'frmReportsEnterprise'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Enterprise Reports',
                8,
                97,
                'frmReportsEnterprise',
                getdate(),
                1,
                1
            )

        SELECT @AppID = Scope_Identity()
        
        EXEC sp_AW_Insert_Apps_Per_Role 2, @AppID, 1, 1

    END

------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Stock Level Settings' AND
              Form_Name = 'frmStockLevelSettings'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Stock Level Settings',
                2,
                17,
                'frmStockLevelSettings',
                getdate(),
                1,
                1
            )

        SELECT @AppID = Scope_Identity()
        
        EXEC sp_AW_Insert_Apps_Per_Role 2, @AppID, 1, 1

    END


----------------------------------------------------------------
-- END
----------------------------------------------------------------