------------------------------------------------------------------------------
-- ADVANTAGE 2004.4.8.1
-- OPTIONS and APPLICATION
-- 08/08/2010
------------------------------------------------------------------------------


----------------------------------------------------------------
-- New System Options
----------------------------------------------------------------

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

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

    IF NOT EXISTS
        (
            SELECT Sys_AW_Options_ID
            FROM Sys_AW_Options
            WHERE Control_Type = 'TextBox' AND
                  Control_Name = 'txtBankStatementsPath' AND
                  Control_Index = 0
        )
        BEGIN
            INSERT Sys_AW_Options
                (
                    Control_Type,
                    Control_Name,
                    Control_Index,
                    Control_Value
                )
            VALUES
                (
                    'TextBox',
                    'txtBankStatementsPath',
                    0,
                    'C:\'
                )
        END

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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


----------------------------------------------------------------------------
-- Retired Applications
----------------------------------------------------------------------------



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

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

DECLARE @AppID int 


IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Internet Cash Book' AND
              Form_Name = 'frmCashbookIBS'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Internet Cash Book',
                5,
                11,
                'frmCashbookIBS',
                getdate(),
                1,
                1
            )

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

    END
ELSE
    BEGIN
        UPDATE Sys_AW_Applications
        SET Slu_AW_Active_ID = 1,
            Application_Seq = 11
        WHERE Description = 'Internet Cash Book' AND
              Form_Name = 'frmCashbookIBS'
    END



----------------------------------------------------------------------------
-- Lookup Editor
----------------------------------------------------------------------------

----------------------------------------------------------------
-- New Lookups
----------------------------------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Lookup_Editor_ID
        FROM Sys_AW_Lookup_Editor
        WHERE TableName = 'Lup_AB_Transaction_Type_Maps' AND
              Caption = 'Bank Transaction Types Mapping'
    )
    BEGIN
        INSERT Sys_AW_Lookup_Editor
            (
                Sys_AW_Lookup_Editor_ID,
                TableName,
                Caption,
                ColumnWidths
            )
            VALUES
            (
                83,
                'Lup_AB_Transaction_Type_Maps',
                'Bank Transaction Types Mapping',
                '0,1590,2400,8940,0,0,0,1005'
            )
    END


----------------------------------------------------------------
-- Modify Lookups
----------------------------------------------------------------


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