
------------------------------------------------------------------------------
-- ADVANTAGE 2004.3.2
-- OPTIONS and APPLICATION SINCE ADVANTAGE 2004.3.1
-- 06 NOV 2006
------------------------------------------------------------------------------


--************************************************
--******     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 = 'OptionButton' AND
                  Control_Name = 'optRemoteStock' AND
                  Control_Index = 0
        )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'OptionButton',
                'optRemoteStock',
                0,
                'True'
            )
    END


    IF NOT EXISTS
        (
            SELECT Sys_AW_Options_ID
            FROM Sys_AW_Options
            WHERE Control_Type = 'OptionButton' AND
                  Control_Name = 'optRemoteStock' AND
                  Control_Index = 1
        )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'OptionButton',
                'optRemoteStock',
                1,
                'False'
            )
    END

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

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

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

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

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

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

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

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

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

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

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

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

DECLARE @AppID int 


IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Enterprise Product Reports' AND
              Form_Name = 'frmProductEnterpriseReports'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Enterprise Product Reports',
                2,
                98,
                'frmProductEnterpriseReports',
                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 = 'Customer Discount Filters' AND
              Form_Name = 'frmCustomerDiscountFilters'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Customer Discount Filters',
                3,
                16,
                'frmCustomerDiscountFilters',
                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_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'CheckBox' AND
              Control_Name = 'chkShowRemoteCost' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'CheckBox',
                'chkShowRemoteCost',
                0,
                '0'
            )
    END

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