
------------------------------------------------------------------------------
-- ADVANTAGE 2004.3.4
-- OPTIONS and APPLICATION SINCE ADVANTAGE 2004.3.3
-- 09 APR 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 = 'chkTotalPriceAdjustment' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'CheckBox',
                'chkTotalPriceAdjustment',
                0,
                '0'
            )
    END



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

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

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

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

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

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

IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'TextBox' AND
              Control_Name = 'txtCSalesExclusions' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'TextBox',
                'txtCSalesExclusions',
                0,
                'giant truck,tractor,agricultural,otr,roadbuilder,earthmover,mining,industrial,lube,lubric,spares'
            )
    END

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

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


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

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

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

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

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

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

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

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

DECLARE @AppID int 


IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Cost Adjustments' AND
              Form_Name = 'frmCostAdjustments'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Cost Adjustments',
                2,
                15,
                'frmCostAdjustments',
                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 = 'Enterprise Sales Reports' AND
              Form_Name = 'frmSalesEnterpriseReports'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Enterprise Sales Reports',
                1,
                96,
                'frmSalesEnterpriseReports',
                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 = 'Enterprise Customer Reports' AND
              Form_Name = 'frmCustomerEnterpriseReports'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Enterprise Customer Reports',
                3,
                97,
                'frmCustomerEnterpriseReports',
                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 Transfers' AND
--               Form_Name = 'frmStockTransfers'
--     )
--     BEGIN
--         INSERT Sys_AW_Applications
--             (
--                 Description,
--                 Sys_AW_Modules_ID,
--                 Application_Seq,
--                 Form_Name,
--                 Date_Captured,
--                 User_ID,
--                 Slu_AW_Active_ID
--             )
--         VALUES
--             (
--                 'Stock Transfers',
--                 2,
--                 16,
--                 'frmStockTransfers',
--                 getdate(),
--                 1,
--                 1
--             )
-- 
--         SELECT @AppID = Scope_Identity()
--         
--         EXEC sp_AW_Insert_Apps_Per_Role 2, @AppID, 1, 1
-- 
--     END

----------------------------------------------------------------------------
-- Sys_AW_Lookup_Editor
----------------------------------------------------------------------------


INSERT Sys_AW_Lookup_Editor ( Sys_AW_Lookup_Editor_ID, TableName, Caption, ColumnWidths )
VALUES (67, 'Lup_AP_Purchase_Categories', 'Product Purchase Categories', '0,7275,0,0,0,1005' )


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