------------------------------------------------------------------------------
-- ADVANTAGE 2004.5.0.0
-- NEW OPTIONS, LOOKUPS and APPLICATIONS
-- 21/04/2011
------------------------------------------------------------------------------


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

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

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

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

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

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

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

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

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

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


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




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


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


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

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

DECLARE @AppID int 


IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Periodic Billing' AND
              Form_Name = 'frmPeriodicBilling'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Periodic Billing',
                3,
                20,
                'frmPeriodicBilling',
                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 = 20
        WHERE Description = 'Periodic Billing' AND
              Form_Name = 'frmPeriodicBilling'
    END


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

IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Cash Flow Forecasting' AND
              Form_Name = 'frmCashFlow'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Cash Flow Forecasting',
                5,
                12,
                'frmCashFlow',
                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 = 20
        WHERE Description = 'Cash Flow Forecasting' AND
              Form_Name = 'frmCashFlow'
    END


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

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



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


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