SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL Serializable
GO
BEGIN TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[tUser]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[tUser]', N'EnableAPIMCPUse') IS NULL
ALTER TABLE [dbo].[tUser] ADD[EnableAPIMCPUse] [tinyint] NULL CONSTRAINT [DF_tUser_EnableAPIMCP] DEFAULT ((0))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[tTask]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[tTask]', N'RecurringSetPos') IS NULL
ALTER TABLE [dbo].[tTask] ADD[RecurringSetPos] [smallint] NULL
IF COL_LENGTH(N'[dbo].[tTask]', N'RecurringWeekday') IS NULL
ALTER TABLE [dbo].[tTask] ADD[RecurringWeekday] [smallint] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[tCompany]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[tCompany]', N'UseAltAddress') IS NULL
ALTER TABLE [dbo].[tCompany] ADD[UseAltAddress] [tinyint] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[tRequestDef]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[tRequestDef]', N'SendIndividualApprovedEmails') IS NULL
ALTER TABLE [dbo].[tRequestDef] ADD[SendIndividualApprovedEmails] [tinyint] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptReportCopyGraph]'
GO
IF OBJECT_ID(N'[dbo].[sptReportCopyGraph]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptReportCopyGraph]
	@UserKey INT,
	@ReportKey INT = 0,
	@ReportID VARCHAR(255),
	@SecurityGroupKey INT = 0,
	@oIdentity INT OUTPUT
AS --Encrypt

/*
|| When       Who Rel		What
|| 07/11/19   GAR 19.0.8.0	(455341) - Added ability to copy graphs from one report dashboard to another
|| 08/30/19   RLB 19.0.9.0  (476468) - Added copy to same board
|| 09/22/21   RLB 21.10.17  (564169) Adding Calculated field options to graphs
|| 02/01/22   RJE 22.02.0   (564169) Adding ability to copy all default graphs to a Security group
|| 06/17/26   RLB 26.07.19  (730877) adding security groups when copying single graphs
*/

IF(@ReportKey = 0)
BEGIN
	--Copying all overrides within the same ReportID but to a different SecurityGroupKey. 
	--Always copies from default (null) to another SGK. Can never copy default to 0
	/*Delete any existing overrides*/
	DELETE tReport WHERE ReportID = @ReportID AND SecurityGroupKey = @SecurityGroupKey;
	
	--only add overrides if there were no overrides deleted in this SGK before ie it''s really a toggle	
	IF @@ROWCOUNT = 0 AND @SecurityGroupKey != 0
	BEGIN	
		/*Copy company defaults*/
		INSERT INTO tReport
			(
			ViewKey, 
			Name, 
			ReportType, 
			ReportFilter, 
			Definition, 
			FieldDefinition, 
			ConditionDefinition, 
			Private, 
			UserKey, 
			CompanyKey, 
			ReportGroupKey, 
			ReportHeading1, 
			ReportHeading1Align, 
			ReportHeading2, 
	        ReportHeading2Align, 
			Orientation, 
			GroupBy, 
			ShowConditions, 
			ReportID, 
			GroupByDefinition, 
			LockedColumns, 
			DefaultReportKey, 
			AutoExpandGroups, 
			Deleted, 
			LastModified, 
			ApplicationVersion, 
			AutoRun, 
			Description, 
			DateAdded, 
	        AddedBy, 
			DateModified, 
			ModifiedBy, 
			DateLastRun, 
			RunCnt, 
			XPos, 
			YPos, 
			Width, 
			Height, 
			DisplayType, 
			TabName, 
			XAxisLabel, 
			YAxisLabel, 
			MaxItemCount, 
			DataTargetUpper, 
			DataTargetLower, 
			RunCntAPI, 
			DateLastRunAPI,
			XAxisHasCField,
			YAxisHasCField,
			SeriesHasCField,
			SecurityGroupKey
			)
	
		SELECT        
			ViewKey, 
			Name, 
			ReportType, 
			ReportFilter, 
			Definition, 
			FieldDefinition, 
			ConditionDefinition, 
			Private, 
			@UserKey, 
			CompanyKey, 
			ReportGroupKey, 
			ReportHeading1, 
			ReportHeading1Align, 
			ReportHeading2, 
	        ReportHeading2Align, 
			Orientation, 
			GroupBy, 
			ShowConditions, 
			@ReportID, 
			GroupByDefinition, 
			LockedColumns, 
			DefaultReportKey, 
			AutoExpandGroups, 
			Deleted, 
			GETUTCDATE(), 
			ApplicationVersion, 
			AutoRun, 
			Description, 
			GETUTCDATE(), 
	        @UserKey, 
			GETUTCDATE(), 
			@UserKey, 
			NULL, 
			0, 
			XPos, 
			YPos, 
			Width, 
			Height, 
			DisplayType, 
			TabName, 
			XAxisLabel, 
			YAxisLabel, 
			MaxItemCount, 
			DataTargetUpper, 
			DataTargetLower, 
			NULL, 
			NULL,
			XAxisHasCField,
			YAxisHasCField,
			SeriesHasCField,
			@SecurityGroupKey
		FROM
			tReport
		WHERE        
			ReportID = @ReportID AND SecurityGroupKey IS NULL
	
		/*delete any rptSecurityGroup rows for this SecurityKey as we now directly use the SecurityGroupKey field in tReport*/
		DELETE rsg FROM tRptSecurityGroup rsg
		LEFT JOIN tReport r
		ON rsg.ReportKey = r.ReportKey
		AND r.ReportID = @ReportID
		AND rsg.SecurityGroupKey IS NULL
		WHERE rsg.SecurityGroupKey = @SecurityGroupKey

		SELECT @oIdentity = 0
		
		RETURN @oIdentity

	END	
	ELSE
	BEGIN
		/*We were removing existing overrides*/
		SELECT @oIdentity = @@ROWCOUNT
		
		RETURN @oIdentity
	END	
END
ELSE
BEGIN
	--Standard copy a single existing graph from one ReportID and SecurityGroupKey to another (can be within the same group or same report)
	DECLARE @NewReportName varchar(255), @CopiedReportID varchar(55), @CopiedSecurityGroupKey INT
	
	--if 0 or not specified we are copying into the default security group
	IF @SecurityGroupKey = 0 SELECT @SecurityGroupKey = NULL 
	
	SELECT @CopiedReportID = ReportID, @NewReportName = Name, @CopiedSecurityGroupKey = SecurityGroupKey FROM tReport (NOLOCK) WHERE ReportKey = @ReportKey

	IF @ReportID = @CopiedReportID AND @SecurityGroupKey = @CopiedSecurityGroupKey
		SELECT @NewReportName = ''Copy Of '' + @NewReportName	

	INSERT INTO tReport
		(
		ViewKey, 
		Name, 
		ReportType, 
		ReportFilter, 
		Definition, 
		FieldDefinition, 
		ConditionDefinition, 
		Private, 
		UserKey, 
		CompanyKey, 
		ReportGroupKey, 
		ReportHeading1, 
		ReportHeading1Align, 
		ReportHeading2, 
        ReportHeading2Align, 
		Orientation, 
		GroupBy, 
		ShowConditions, 
		ReportID, 
		GroupByDefinition, 
		LockedColumns, 
		DefaultReportKey, 
		AutoExpandGroups, 
		Deleted, 
		LastModified, 
		ApplicationVersion, 
		AutoRun, 
		Description, 
		DateAdded, 
        AddedBy, 
		DateModified, 
		ModifiedBy, 
		DateLastRun, 
		RunCnt, 
		XPos, 
		YPos, 
		Width, 
		Height, 
		DisplayType, 
		TabName, 
		XAxisLabel, 
		YAxisLabel, 
		MaxItemCount, 
		DataTargetUpper, 
		DataTargetLower, 
		RunCntAPI, 
		DateLastRunAPI,
		XAxisHasCField,
		YAxisHasCField,
		SeriesHasCField,
		SecurityGroupKey
		)

	SELECT        
		ViewKey, 
		@NewReportName, 
		ReportType, 
		ReportFilter, 
		Definition, 
		FieldDefinition, 
		ConditionDefinition, 
		Private, 
		@UserKey, 
		CompanyKey, 
		ReportGroupKey, 
		ReportHeading1, 
		ReportHeading1Align, 
		ReportHeading2, 
        ReportHeading2Align, 
		Orientation, 
		GroupBy, 
		ShowConditions, 
		@ReportID, 
		GroupByDefinition, 
		LockedColumns, 
		DefaultReportKey, 
		AutoExpandGroups, 
		Deleted, 
		GETUTCDATE(), 
		ApplicationVersion, 
		AutoRun, 
		Description, 
		GETUTCDATE(), 
        @UserKey, 
		GETUTCDATE(), 
		@UserKey, 
		NULL, 
		0, 
		NULL, 
		NULL, 
		Width, 
		Height, 
		DisplayType, 
		TabName, 
		XAxisLabel, 
		YAxisLabel, 
		MaxItemCount, 
		DataTargetUpper, 
		DataTargetLower, 
		NULL, 
		NULL,
		XAxisHasCField,
		YAxisHasCField,
		SeriesHasCField,
		@SecurityGroupKey

	FROM
		tReport
	WHERE        
		ReportKey = @ReportKey
	
	SELECT @oIdentity = @@IDENTITY
	
	Insert Into tRptSecurityGroup (ReportKey, SecurityGroupKey)
	Select @oIdentity, SecurityGroupKey from tRptSecurityGroup (NOLOCK) Where ReportKey = @ReportKey

	RETURN @oIdentity
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spConvertDashboardSeed]'
GO
IF OBJECT_ID(N'[dbo].[spConvertDashboardSeed]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[spConvertDashboardSeed]
(
	@LoadForCompanyKey int = 0,
	@LoadForEntireServer int = 0
)
AS

/*
|| 4/8/19   KMC 19.0.4.0 Created stored procedure to load initial dashboard reports.  If a @LoadForCompanyKey is passed in it will load for just that company.
||						 If no @LoadForCompanyKey is passed in it will load for all companies on the server, but the @LoadForEntireServer must be explicitly specified
||						 to try and avoid reloading for a server/company that has already been loaded.
|| 10/15/19 GWG 19.1.1.0 Adding two new graphs
*/

DECLARE @CompanyKey INT, @UserKey INT 

IF @LoadForCompanyKey > 0
	--Load for just one company
	BEGIN
		SELECT @CompanyKey = @LoadForCompanyKey

		IF NOT EXISTS(SELECT 1 FROM tReport (NOLOCK) WHERE CompanyKey = @CompanyKey AND ReportType = 3)
		BEGIN
			SELECT @UserKey = MIN(UserKey) FROM tUser (NOLOCK) WHERE CompanyKey = @CompanyKey AND Administrator = 1 AND Active = 1 AND UserID IS NOT NULL
	
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''Time by Person'',''Time by Person'',2,''AdminDash'',''Show hours for people on active projects'',0,5,6,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="User Name" Key="PK48910" groupBy="3" columnHeading="User Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48911" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" values="1" calcAfter="0" name="Client Name" promptText="Client Name Equal To" Key="-1"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="1" values="1" calcAfter="0" name="Project Number" promptText="Project Number Equal To" Key="-2"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="2" values="1" calcAfter="0" name="Account Manager" promptText="Account Manager Equal To" Key="-3"></condition><condition calculated="0" dataType="String" andOr="and" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="YES" dataTypeLabel="Text" prompt="0" batch="3" values="1" calcAfter="0" name="Active Project" Key="-4"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Between" condition="3" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="4" values="2" calcAfter="0" name="Date Worked" promptText="Date Worked Between" Key="-5"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  13,''Opportunities by Stage'',''Opportunities by Stage'',0,''AdminDash'',NULL,0,0,6,5,''Bar'',''Stages'',''Sales'',12,20000,10000,''<fields><field dataType="string" name="Lead Stage" Key="PK49868" groupBy="3" columnHeading="Lead Stage"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Forecasted Sale Amount" Key="PK49869" groupBy="6" columnHeading="Forecasted Sale Amount"></field><field dataType="string" groupBy="3" name="Opportunity Owner Name" columnHeading="Opportunity Owner Name"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="YES" dataTypeLabel="Text" prompt="0" batch="0" values="1" calcAfter="0" name="Lead Status Active" Key="-6"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  36,''Amount Adv Billed'',''Amount Adv Billed'',1,''AdminDash'',NULL,6,0,6,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK49623" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Advance Billed" Key="PK49624" groupBy="6" columnHeading="Amount Advance Billed"></field></fields>'',''<conditions><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="-1" inputType="text" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Amount Advance Billed] Greater Than" leftParenthesis="" values="1" name="[Amount Advance Billed]" rightParenthesis=""></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''My Non-Billable Time'',''My Non-Billable Time'',0,''CreativeDash'',NULL,4,0,4,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK52600" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Non Billable Hours" Key="PK52601" groupBy="6" columnHeading="Actual Non Billable Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''My Hours By Service - YTD'',''My Hours By Service - YTD'',1,''CreativeDash'',NULL,0,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK49812" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49834" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="2"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''Invoice Aging'',''Invoice Aging'',2,''BillingDash'',NULL,0,0,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Due Date Aging" Key="PK49746" groupBy="3" columnHeading="Due Date Aging"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK49747" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Open" promptText="Amount Open Not Equal To" Key="-1"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="1" values="1" calcAfter="0" name="Account Manager" promptText="Account Manager Equal To" Key="-2"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''Amount Open'',''Amount Open'',2,''BillingDash'',NULL,4,0,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK50647" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Open" Key="PK50648" groupBy="6" columnHeading="Amount Open"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Open" promptText="Amount Open Not Equal To" Key="-3"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''Revenue YTD'',''Revenue YTD'',2,''BillingDash'',NULL,0,10,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK51547" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK51548" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-4"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''Revenue MTD'',''Revenue MTD'',2,''BillingDash'',NULL,0,5,4,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK52628" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK52629" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Month To Date" andOr="and" condition="19" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Invoice Date" promptText="Invoice Date Month To Date" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''AM Revenue MTD'',''AM Revenue MTD'',2,''BillingDash'',NULL,4,5,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK48662" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK48663" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Month To Date" andOr="or" condition="19" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="1" andOrLabel="OR" calcAfter="0" name="Invoice Date" promptText="Invoice Date Month To Date" values="0" Key="1"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Between" condition="3" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" values="2" calcAfter="0" name="Invoice Date" promptText="Invoice Date Between" Key="-1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''AM Revenue YTD'',''AM Revenue YTD'',2,''BillingDash'',NULL,4,10,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK54554" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK54555" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-7"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''Billing By Month'',''Billing By Month'',1,''BillingDash'',NULL,0,15,8,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Invoice Month" Key="PK1759" groupBy="3" columnHeading="Invoice Month"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK1760" groupBy="6" columnHeading="Amount Total"></field><field dataType="string" groupBy="3" name="Account Manager" columnHeading="Account Manager"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Total" promptText="Amount Total Not Equal To" Key="-1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Service'',''YTD Hours By Service'',1,''PMnDash'',NULL,0,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK51546" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK51547" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Client'',''YTD Hours By Client'',1,''PMnDash'',NULL,0,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK52509" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK52531" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Account Manager'',''YTD Hours By Account Manager'',1,''PMnDash'',NULL,5,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK48845" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48846" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  23,''Tasks Due Today By Person'',''Tasks Due Today By Person'',1,''PMnDash'',NULL,5,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Plan Completion Date" Key="PK1567292" groupBy="3" columnHeading="Plan Completion Date"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Total Allocated Hours" Key="PK1567293" groupBy="6" columnHeading="Total Allocated Hours"></field><field dataType="string" groupBy="3" name="Assigned People" columnHeading="Assigned People"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Blank" condition="24" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Actual Completion Date" promptText="Actual Completion Date Blank" Key="-1"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Today" condition="21" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="3" values="0" calcAfter="0" name="Plan Completion Date" promptText="Plan Completion Date Today" Key="-2"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''My Billable Time'',''My Billable Time'',0,''CreativeDash'',NULL,0,0,4,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK53436" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Billable Hours" Key="PK53437" groupBy="6" columnHeading="Actual Billable Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Is Me" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''My Billable Status - YTD'',''My Billable Status - YTD'',4,''CreativeDash'',''This report shows total hours worked this year by person. It breaks out their billable and non billable time.'',5,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK49620" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49621" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Billing Status" columnHeading="Billing Status"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="text" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="2"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''Time Detail Data'',''Time Detail Data'',1,''PMnDash'',NULL,0,8,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="User Name" Key="PK50644" groupBy="3" columnHeading="User Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Billable Hours" Key="PK50645" groupBy="6" columnHeading="Actual Billable Hours"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  37,''Project Completion Percentage'',''Project Completion Percentage'',1,''RMDash'',NULL,0,3,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Project Name" Key="PK1507516" groupBy="3" columnHeading="Project Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Percentage Complete" Key="PK1507517" groupBy="4" columnHeading="Percentage Complete"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="2018-06-26T00:00:00" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="2018-05-01T00:00:00" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Last Task Due Date" promptText="Last Task Due Date Between" values="2" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  62,''Allocated Hours by Assigned User'',''Allocated Hours by Assigned User'',1,''RMDash'',NULL,0,0,5,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Assigned User" Key="PK54646" groupBy="3" columnHeading="Assigned User"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Allocated Hours" Key="PK54647" groupBy="6" columnHeading="Allocated Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="Int32" parameter2="" conditionName="Less Than" andOr="and" condition="6" inputType="number" parameter1="100" dataTypeLabel="Number" prompt="0" batch="0" step="1" andOrLabel="AND" calcAfter="0" name="Percentage Complete" promptText="Percentage Complete Less Than" values="1" Key="1"></condition><condition calculated="1" dataType="string" parameter2="" conditionName="Does Not Contain" andOr="and" condition="14" Key="2" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Assigned User] Does Not Contain" leftParenthesis="" values="1" name="[Assigned User]" rightParenthesis=""></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''Actual Hours Worked'',''Actual Hours Worked'',1,''RMDash'',NULL,5,0,4,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK1509353" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK1509354" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".0001" andOrLabel="AND" calcAfter="0" name="Actual Hours Worked" promptText="Actual Hours Worked Greater Than" values="1" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''Time Per Week YTD'',''Time Per Week YTD'',1,''CreativeDash'',NULL,0,8,12,3,''Line'','''','''',12,0,0,''<fields><field dataType="string" name="Date Worked Week Formatted" Key="PK1787" groupBy="3" columnHeading="Date Worked Week Formatted"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK1788" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Billing Status" columnHeading="Billing Status"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="or" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="1" step="1" andOrLabel="OR" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" leftParenthesis="(" values="0" Key="2"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="" dataTypeLabel="Date" prompt="1" batch="2" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Between" values="2" Key="3" rightParenthesis=")"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  8,''Open Invoices By Vendor'',''Open Invoices By Vendor'',1,''PurchasingDash'',NULL,6,0,6,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Vendor Name" Key="PK55385" groupBy="3" columnHeading="Vendor Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Invoice Amount Open" Key="PK55386" groupBy="6" columnHeading="Invoice Amount Open"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".0001" andOrLabel="AND" calcAfter="0" name="Invoice Amount Open" promptText="Invoice Amount Open Greater Than" values="1" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  7,''Open Orders by Client'',''Open Orders by Client'',1,''PurchasingDash'',NULL,0,0,6,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK1508571" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Line Total Amount Billable" Key="PK1508572" groupBy="6" columnHeading="Line Total Amount Billable"></field></fields>'',''<conditions><condition calculated="0" dataType="String" conditionName="Equal To" andOr="and" condition="1" inputType="lookup.General" parameter1="Open Approved" dataTypeLabel="Text" datasource="_vl886" batch="0" andOrLabel="AND" calcAfter="0" prompt="0" name="Status" values="1" Key="1"></condition><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="1" step=".0001" andOrLabel="AND" calcAfter="0" name="Remaining PO Amount" promptText="Remaining PO Amount Greater Than" values="1" Key="2"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  61,''Open Quotes By Vendor'',''Open Quotes By Vendor'',1,''PurchasingDash'',NULL,0,4,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Vendor Name" Key="PK1509536" groupBy="3" columnHeading="Vendor Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Quote Number" Key="PK1509537" groupBy="6" columnHeading="Quote Number"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Not Equal To" andOr="and" condition="2" inputType="lookup.General" parameter1="Closed" dataTypeLabel="Text" datasource="_vl886" batch="0" andOrLabel="AND" calcAfter="0" prompt="0" name="Status" promptText="Status Not Equal To" values="1" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''Client Invoice Level Data'',''Client Invoice Level Data'',4,''AccountingDash'',NULL,0,0,5,6,''Bar'',''Account Manager'',''Invoiced Amount'',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK1575662" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Billed" Key="PK1575663" groupBy="6" columnHeading="Amount Billed"></field><field dataType="string" groupBy="3" name="Client Name" columnHeading="Client Name"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="06/27/2018" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="01/01/2017" dataTypeLabel="Date" prompt="0" batch="2" andOrLabel="AND" calcAfter="0" name="Invoice Date" promptText="Invoice Date Between" values="2" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1004,''Client Invoice Level Data'',''Client Invoice Level Data'',1,''AccountingDash'',NULL,5,0,6,6,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Project Number" Key="PK1573989" groupBy="3" columnHeading="Project Number"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK1574011" groupBy="6" columnHeading="Amount Total"></field><field dataType="string" groupBy="3" name="Account Manager" columnHeading="Account Manager"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-7"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  24,''Tasks Due Date With Allocated Hours'',''Tasks Due Date With Allocated Hours'',1,''RMDash'',NULL,0,6,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Plan Completion Date" Key="PK1569924" groupBy="3" columnHeading="Plan Completion Date"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Allocated Hours" Key="PK1569925" groupBy="6" columnHeading="Allocated Hours"></field><field dataType="string" groupBy="3" name="Client Name" columnHeading="Client Name"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Blank" condition="24" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="2" values="0" calcAfter="0" name="Actual Completion Date" promptText="Actual Completion Date Blank" Key="-2"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  13,''Forcasted Closed Amount By Account Manager - YTD'',''Forcasted Closed Amount By Account Manager - YTD'',1,''SalesDash'',NULL,0,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK50832" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Forecasted Sale Amount" Key="PK50833" groupBy="6" columnHeading="Forecasted Sale Amount"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="text" parameter1="" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Forecasted Close Date" promptText="Forecasted Close Date Year To Date" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  16,''GL Transaction Detail Data'',''GL Transaction Detail Data'',1,''OwnerDash'',NULL,0,0,7,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Type" Key="PK48633" groupBy="3" columnHeading="Account Type"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Transaction Amount" Key="PK48634" groupBy="6" columnHeading="Transaction Amount"></field></fields>'',''<conditions><condition calculated="1" dataType="number" parameter2="" conditionName="Not Equal To" andOr="and" condition="2" Key="-1" inputType="text" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Transaction Amount] Not Equal To" leftParenthesis="" values="1" name="[Transaction Amount]" rightParenthesis=""></condition></conditions>'')

			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  41,''Order Detail Accrual Data'',''Order Detail Accrual Data'',1,''MediaDash'',NULL,0,0,6,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK49716" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Accrued" Key="PK49717" groupBy="6" columnHeading="Amount Accrued"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Accrued" promptText="Amount Accrued Not Equal To" Key="-1"></condition></conditions>'')

			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  36,''Hours Items/Services'',''Hours Items/Services'',1,''CreativeDash'',''Sherry'',0,11,12,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Item Name" Key="PK1513197" groupBy="3" columnHeading="Item Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours" Key="PK1513198" groupBy="6" columnHeading="Actual Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Is On Or After" andOr="and" condition="17" inputType="date" parameter1="" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Project Start Date" promptText="Project Start Date Is On Or After" values="1" Key="1"></condition></conditions>'')

			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  30,''Time Entered On Time by User'',''Time Entered On Time by User'',1,''AdminDash'',''Test'',0,9,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="User Full Name" Key="PK48658" groupBy="3" columnHeading="User Full Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48659" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Time Entered On Time" columnHeading="Time Entered On Time"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Any Of" andOr="and" condition="26" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Any Of" values="1" Key="1"></condition><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="2" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".01" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Actual Hours Worked] Greater Than" leftParenthesis="" values="1" name="[Actual Hours Worked]" rightParenthesis=""></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  30,''Time Enterted on Time Global View'',''Time Enterted on Time Global View'',1,''AdminDash'',''NULL'',0,0,5,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Entered On Time" Key="PK52475" groupBy="3" columnHeading="Time Entered On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK52476" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  30,''Time Sheet Submitted on Time by User'',''Time Sheet Submitted on Time by User'',1,''AdminDash'',''NULL'',0,12,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="User Full Name" Key="PK48843" groupBy="3" columnHeading="User Full Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48844" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Time Sheet Submitted On Time" columnHeading="Time Sheet Submitted On Time"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Any Of" andOr="and" condition="26" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Any Of" values="1" Key="1"></condition><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="2" inputType="number" parameter1="40" dataTypeLabel="Number" prompt="0" batch="0" step=".01" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Actual Hours Worked] Greater Than" leftParenthesis="" values="1" name="[Actual Hours Worked]" rightParenthesis=""></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''Time Entered On Time'',''Time Entered On Time'',1,''CreativeDash'',''NULL'',0,14,4,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Entered On Time" Key="PK49592" groupBy="3" columnHeading="Time Entered On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49593" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Is Me" condition="29" andOrLabel="AND" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="User Name" promptText="User Name Is Me" Key="-1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1014,''Timesheet Submitted on Time'',''Timesheet Submitted on Time'',1,''CreativeDash'',''NULL'',4,14,5,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Sheet Submitted On Time" Key="PK50677" groupBy="3" columnHeading="Time Sheet Submitted On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Total Hours" Key="PK50678" groupBy="6" columnHeading="Total Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Name" promptText="Name Is Me" values="0" Key="1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''Service Profitability'',''Service Profitability'',1,''BillingDash'',''NULL'',0,19,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" sortOrder="1" sortDirection="1" name="Service Description" Key="PK1163705637" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" name="Actual Net Profit" Key="PK1146928018" groupBy="6" columnHeading="Actual Net Profit"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="date" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Date Worked" promptText="" Key="-1"></condition></conditions>'')
			INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
			VALUES (@CompanyKey, @UserKey, 3,  1,''Service Income'',''Service Income'',1,''BillingDash'',''NULL'',0,22,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" sortOrder="1" sortDirection="1" name="Service Description" Key="PK490174889" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" name="Billed Total Amount" Key="PK439842032" groupBy="6" columnHeading="Billed Total Amount"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="date" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Date Worked" promptText="" Key="-2"></condition></conditions>'')

			INSERT tRptSecurityGroup(ReportKey, SecurityGroupKey) 
				SELECT ReportKey, sg.SecurityGroupKey
					FROM tReport r (NOLOCK)
					INNER JOIN tSecurityGroup sg (NOLOCK) ON r.CompanyKey = sg.CompanyKey
					WHERE r.CompanyKey = @CompanyKey 
					AND r.ReportType = 3

			UPDATE tReport
				SET Private = 1, Orientation = 0, GroupBy = 1, ShowConditions = 0, LockedColumns = 0, Deleted = 0, AutoRun = 1, ApplicationVersion = 2, RunCnt = 0,  LastModified = GETUTCDATE(),  DateAdded = GETUTCDATE(),  DateModified = GETUTCDATE(), AddedBy = @UserKey, ModifiedBy = @UserKey
				WHERE CompanyKey = @CompanyKey 
					AND ReportType = 3
		END
	END
ELSE
	--Load for entire server
	BEGIN
		IF @LoadForEntireServer = 1
		BEGIN
			SELECT @CompanyKey = -1
			WHILE 1=1
			BEGIN
				SELECT @CompanyKey = MIN(CompanyKey) from tCompany (NOLOCK) WHERE OwnerCompanyKey IS NULL AND Locked = 0 AND CompanyKey > @CompanyKey
					IF @CompanyKey IS NULL
						BREAK

				IF NOT EXISTS(SELECT 1 FROM tReport (NOLOCK) WHERE CompanyKey = @CompanyKey AND ReportType = 3)
				BEGIN
					SELECT @UserKey = MIN(UserKey) FROM tUser (NOLOCK) WHERE CompanyKey = @CompanyKey AND Administrator = 1 AND Active = 1 AND UserID IS NOT NULL
	
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''Time by Person'',''Time by Person'',2,''AdminDash'',''Show hours for people on active projects'',0,5,6,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="User Name" Key="PK48910" groupBy="3" columnHeading="User Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48911" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" values="1" calcAfter="0" name="Client Name" promptText="Client Name Equal To" Key="-1"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="1" values="1" calcAfter="0" name="Project Number" promptText="Project Number Equal To" Key="-2"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="2" values="1" calcAfter="0" name="Account Manager" promptText="Account Manager Equal To" Key="-3"></condition><condition calculated="0" dataType="String" andOr="and" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="YES" dataTypeLabel="Text" prompt="0" batch="3" values="1" calcAfter="0" name="Active Project" Key="-4"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Between" condition="3" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="4" values="2" calcAfter="0" name="Date Worked" promptText="Date Worked Between" Key="-5"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  13,''Opportunities by Stage'',''Opportunities by Stage'',0,''AdminDash'',NULL,0,0,6,5,''Bar'',''Stages'',''Sales'',12,20000,10000,''<fields><field dataType="string" name="Lead Stage" Key="PK49868" groupBy="3" columnHeading="Lead Stage"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Forecasted Sale Amount" Key="PK49869" groupBy="6" columnHeading="Forecasted Sale Amount"></field><field dataType="string" groupBy="3" name="Opportunity Owner Name" columnHeading="Opportunity Owner Name"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="YES" dataTypeLabel="Text" prompt="0" batch="0" values="1" calcAfter="0" name="Lead Status Active" Key="-6"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  36,''Amount Adv Billed'',''Amount Adv Billed'',1,''AdminDash'',NULL,6,0,6,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK49623" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Advance Billed" Key="PK49624" groupBy="6" columnHeading="Amount Advance Billed"></field></fields>'',''<conditions><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="-1" inputType="text" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Amount Advance Billed] Greater Than" leftParenthesis="" values="1" name="[Amount Advance Billed]" rightParenthesis=""></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''My Non-Billable Time'',''My Non-Billable Time'',0,''CreativeDash'',NULL,4,0,4,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK52600" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Non Billable Hours" Key="PK52601" groupBy="6" columnHeading="Actual Non Billable Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''My Hours By Service - YTD'',''My Hours By Service - YTD'',1,''CreativeDash'',NULL,0,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK49812" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49834" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="2"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''Invoice Aging'',''Invoice Aging'',2,''BillingDash'',NULL,0,0,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Due Date Aging" Key="PK49746" groupBy="3" columnHeading="Due Date Aging"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK49747" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Open" promptText="Amount Open Not Equal To" Key="-1"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="1" values="1" calcAfter="0" name="Account Manager" promptText="Account Manager Equal To" Key="-2"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''Amount Open'',''Amount Open'',2,''BillingDash'',NULL,4,0,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK50647" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Open" Key="PK50648" groupBy="6" columnHeading="Amount Open"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Open" promptText="Amount Open Not Equal To" Key="-3"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''Revenue YTD'',''Revenue YTD'',2,''BillingDash'',NULL,0,10,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK51547" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK51548" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-4"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''Revenue MTD'',''Revenue MTD'',2,''BillingDash'',NULL,0,5,4,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK52628" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK52629" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Month To Date" andOr="and" condition="19" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Invoice Date" promptText="Invoice Date Month To Date" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''AM Revenue MTD'',''AM Revenue MTD'',2,''BillingDash'',NULL,4,5,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK48662" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK48663" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Month To Date" andOr="or" condition="19" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="1" andOrLabel="OR" calcAfter="0" name="Invoice Date" promptText="Invoice Date Month To Date" values="0" Key="1"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Between" condition="3" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" values="2" calcAfter="0" name="Invoice Date" promptText="Invoice Date Between" Key="-1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''AM Revenue YTD'',''AM Revenue YTD'',2,''BillingDash'',NULL,4,10,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK54554" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK54555" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-7"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''Billing By Month'',''Billing By Month'',1,''BillingDash'',NULL,0,15,8,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Invoice Month" Key="PK1759" groupBy="3" columnHeading="Invoice Month"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK1760" groupBy="6" columnHeading="Amount Total"></field><field dataType="string" groupBy="3" name="Account Manager" columnHeading="Account Manager"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Total" promptText="Amount Total Not Equal To" Key="-1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Service'',''YTD Hours By Service'',1,''PMnDash'',NULL,0,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK51546" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK51547" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Client'',''YTD Hours By Client'',1,''PMnDash'',NULL,0,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK52509" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK52531" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Account Manager'',''YTD Hours By Account Manager'',1,''PMnDash'',NULL,5,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK48845" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48846" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  23,''Tasks Due Today By Person'',''Tasks Due Today By Person'',1,''PMnDash'',NULL,5,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Plan Completion Date" Key="PK1567292" groupBy="3" columnHeading="Plan Completion Date"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Total Allocated Hours" Key="PK1567293" groupBy="6" columnHeading="Total Allocated Hours"></field><field dataType="string" groupBy="3" name="Assigned People" columnHeading="Assigned People"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Blank" condition="24" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Actual Completion Date" promptText="Actual Completion Date Blank" Key="-1"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Today" condition="21" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="3" values="0" calcAfter="0" name="Plan Completion Date" promptText="Plan Completion Date Today" Key="-2"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''My Billable Time'',''My Billable Time'',0,''CreativeDash'',NULL,0,0,4,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK53436" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Billable Hours" Key="PK53437" groupBy="6" columnHeading="Actual Billable Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Is Me" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''My Billable Status - YTD'',''My Billable Status - YTD'',4,''CreativeDash'',''This report shows total hours worked this year by person. It breaks out their billable and non billable time.'',5,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK49620" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49621" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Billing Status" columnHeading="Billing Status"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="text" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="2"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''Time Detail Data'',''Time Detail Data'',1,''PMnDash'',NULL,0,8,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="User Name" Key="PK50644" groupBy="3" columnHeading="User Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Billable Hours" Key="PK50645" groupBy="6" columnHeading="Actual Billable Hours"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  37,''Project Completion Percentage'',''Project Completion Percentage'',1,''RMDash'',NULL,0,3,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Project Name" Key="PK1507516" groupBy="3" columnHeading="Project Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Percentage Complete" Key="PK1507517" groupBy="4" columnHeading="Percentage Complete"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="2018-06-26T00:00:00" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="2018-05-01T00:00:00" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Last Task Due Date" promptText="Last Task Due Date Between" values="2" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  62,''Allocated Hours by Assigned User'',''Allocated Hours by Assigned User'',1,''RMDash'',NULL,0,0,5,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Assigned User" Key="PK54646" groupBy="3" columnHeading="Assigned User"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Allocated Hours" Key="PK54647" groupBy="6" columnHeading="Allocated Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="Int32" parameter2="" conditionName="Less Than" andOr="and" condition="6" inputType="number" parameter1="100" dataTypeLabel="Number" prompt="0" batch="0" step="1" andOrLabel="AND" calcAfter="0" name="Percentage Complete" promptText="Percentage Complete Less Than" values="1" Key="1"></condition><condition calculated="1" dataType="string" parameter2="" conditionName="Does Not Contain" andOr="and" condition="14" Key="2" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Assigned User] Does Not Contain" leftParenthesis="" values="1" name="[Assigned User]" rightParenthesis=""></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''Actual Hours Worked'',''Actual Hours Worked'',1,''RMDash'',NULL,5,0,4,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK1509353" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK1509354" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".0001" andOrLabel="AND" calcAfter="0" name="Actual Hours Worked" promptText="Actual Hours Worked Greater Than" values="1" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''Time Per Week YTD'',''Time Per Week YTD'',1,''CreativeDash'',NULL,0,8,12,3,''Line'','''','''',12,0,0,''<fields><field dataType="string" name="Date Worked Week Formatted" Key="PK1787" groupBy="3" columnHeading="Date Worked Week Formatted"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK1788" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Billing Status" columnHeading="Billing Status"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="or" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="1" step="1" andOrLabel="OR" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" leftParenthesis="(" values="0" Key="2"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="" dataTypeLabel="Date" prompt="1" batch="2" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Between" values="2" Key="3" rightParenthesis=")"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  8,''Open Invoices By Vendor'',''Open Invoices By Vendor'',1,''PurchasingDash'',NULL,6,0,6,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Vendor Name" Key="PK55385" groupBy="3" columnHeading="Vendor Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Invoice Amount Open" Key="PK55386" groupBy="6" columnHeading="Invoice Amount Open"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".0001" andOrLabel="AND" calcAfter="0" name="Invoice Amount Open" promptText="Invoice Amount Open Greater Than" values="1" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  7,''Open Orders by Client'',''Open Orders by Client'',1,''PurchasingDash'',NULL,0,0,6,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK1508571" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Line Total Amount Billable" Key="PK1508572" groupBy="6" columnHeading="Line Total Amount Billable"></field></fields>'',''<conditions><condition calculated="0" dataType="String" conditionName="Equal To" andOr="and" condition="1" inputType="lookup.General" parameter1="Open Approved" dataTypeLabel="Text" datasource="_vl886" batch="0" andOrLabel="AND" calcAfter="0" prompt="0" name="Status" values="1" Key="1"></condition><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="1" step=".0001" andOrLabel="AND" calcAfter="0" name="Remaining PO Amount" promptText="Remaining PO Amount Greater Than" values="1" Key="2"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  61,''Open Quotes By Vendor'',''Open Quotes By Vendor'',1,''PurchasingDash'',NULL,0,4,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Vendor Name" Key="PK1509536" groupBy="3" columnHeading="Vendor Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Quote Number" Key="PK1509537" groupBy="6" columnHeading="Quote Number"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Not Equal To" andOr="and" condition="2" inputType="lookup.General" parameter1="Closed" dataTypeLabel="Text" datasource="_vl886" batch="0" andOrLabel="AND" calcAfter="0" prompt="0" name="Status" promptText="Status Not Equal To" values="1" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''Client Invoice Level Data'',''Client Invoice Level Data'',4,''AccountingDash'',NULL,0,0,5,6,''Bar'',''Account Manager'',''Invoiced Amount'',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK1575662" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Billed" Key="PK1575663" groupBy="6" columnHeading="Amount Billed"></field><field dataType="string" groupBy="3" name="Client Name" columnHeading="Client Name"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="06/27/2018" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="01/01/2017" dataTypeLabel="Date" prompt="0" batch="2" andOrLabel="AND" calcAfter="0" name="Invoice Date" promptText="Invoice Date Between" values="2" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1004,''Client Invoice Level Data'',''Client Invoice Level Data'',1,''AccountingDash'',NULL,5,0,6,6,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Project Number" Key="PK1573989" groupBy="3" columnHeading="Project Number"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK1574011" groupBy="6" columnHeading="Amount Total"></field><field dataType="string" groupBy="3" name="Account Manager" columnHeading="Account Manager"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-7"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  24,''Tasks Due Date With Allocated Hours'',''Tasks Due Date With Allocated Hours'',1,''RMDash'',NULL,0,6,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Plan Completion Date" Key="PK1569924" groupBy="3" columnHeading="Plan Completion Date"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Allocated Hours" Key="PK1569925" groupBy="6" columnHeading="Allocated Hours"></field><field dataType="string" groupBy="3" name="Client Name" columnHeading="Client Name"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Blank" condition="24" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="2" values="0" calcAfter="0" name="Actual Completion Date" promptText="Actual Completion Date Blank" Key="-2"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  13,''Forcasted Closed Amount By Account Manager - YTD'',''Forcasted Closed Amount By Account Manager - YTD'',1,''SalesDash'',NULL,0,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK50832" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Forecasted Sale Amount" Key="PK50833" groupBy="6" columnHeading="Forecasted Sale Amount"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="text" parameter1="" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Forecasted Close Date" promptText="Forecasted Close Date Year To Date" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  16,''GL Transaction Detail Data'',''GL Transaction Detail Data'',1,''OwnerDash'',NULL,0,0,7,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Type" Key="PK48633" groupBy="3" columnHeading="Account Type"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Transaction Amount" Key="PK48634" groupBy="6" columnHeading="Transaction Amount"></field></fields>'',''<conditions><condition calculated="1" dataType="number" parameter2="" conditionName="Not Equal To" andOr="and" condition="2" Key="-1" inputType="text" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Transaction Amount] Not Equal To" leftParenthesis="" values="1" name="[Transaction Amount]" rightParenthesis=""></condition></conditions>'')

					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  41,''Order Detail Accrual Data'',''Order Detail Accrual Data'',1,''MediaDash'',NULL,0,0,6,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK49716" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Accrued" Key="PK49717" groupBy="6" columnHeading="Amount Accrued"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Accrued" promptText="Amount Accrued Not Equal To" Key="-1"></condition></conditions>'')

					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  36,''Hours Items/Services'',''Hours Items/Services'',1,''CreativeDash'',''Sherry'',0,11,12,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Item Name" Key="PK1513197" groupBy="3" columnHeading="Item Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours" Key="PK1513198" groupBy="6" columnHeading="Actual Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Is On Or After" andOr="and" condition="17" inputType="date" parameter1="" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Project Start Date" promptText="Project Start Date Is On Or After" values="1" Key="1"></condition></conditions>'')

					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  30,''Time Entered On Time by User'',''Time Entered On Time by User'',1,''AdminDash'',''Test'',0,9,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="User Full Name" Key="PK48658" groupBy="3" columnHeading="User Full Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48659" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Time Entered On Time" columnHeading="Time Entered On Time"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Any Of" andOr="and" condition="26" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Any Of" values="1" Key="1"></condition><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="2" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".01" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Actual Hours Worked] Greater Than" leftParenthesis="" values="1" name="[Actual Hours Worked]" rightParenthesis=""></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  30,''Time Enterted on Time Global View'',''Time Enterted on Time Global View'',1,''AdminDash'',''NULL'',0,0,5,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Entered On Time" Key="PK52475" groupBy="3" columnHeading="Time Entered On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK52476" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  30,''Time Sheet Submitted on Time by User'',''Time Sheet Submitted on Time by User'',1,''AdminDash'',''NULL'',0,12,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="User Full Name" Key="PK48843" groupBy="3" columnHeading="User Full Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48844" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Time Sheet Submitted On Time" columnHeading="Time Sheet Submitted On Time"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Any Of" andOr="and" condition="26" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Any Of" values="1" Key="1"></condition><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="2" inputType="number" parameter1="40" dataTypeLabel="Number" prompt="0" batch="0" step=".01" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Actual Hours Worked] Greater Than" leftParenthesis="" values="1" name="[Actual Hours Worked]" rightParenthesis=""></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''Time Entered On Time'',''Time Entered On Time'',1,''CreativeDash'',''NULL'',0,14,4,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Entered On Time" Key="PK49592" groupBy="3" columnHeading="Time Entered On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49593" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Is Me" condition="29" andOrLabel="AND" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="User Name" promptText="User Name Is Me" Key="-1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1014,''Timesheet Submitted on Time'',''Timesheet Submitted on Time'',1,''CreativeDash'',''NULL'',4,14,5,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Sheet Submitted On Time" Key="PK50677" groupBy="3" columnHeading="Time Sheet Submitted On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Total Hours" Key="PK50678" groupBy="6" columnHeading="Total Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Name" promptText="Name Is Me" values="0" Key="1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''Service Profitability'',''Service Profitability'',1,''BillingDash'',''NULL'',0,19,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" sortOrder="1" sortDirection="1" name="Service Description" Key="PK1163705637" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" name="Actual Net Profit" Key="PK1146928018" groupBy="6" columnHeading="Actual Net Profit"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="date" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Date Worked" promptText="" Key="-1"></condition></conditions>'')
					INSERT tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
					VALUES (@CompanyKey, @UserKey, 3,  1,''Service Income'',''Service Income'',1,''BillingDash'',''NULL'',0,22,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" sortOrder="1" sortDirection="1" name="Service Description" Key="PK490174889" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" name="Billed Total Amount" Key="PK439842032" groupBy="6" columnHeading="Billed Total Amount"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="date" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Date Worked" promptText="" Key="-2"></condition></conditions>'')


					INSERT tRptSecurityGroup(ReportKey, SecurityGroupKey) 
						SELECT ReportKey, sg.SecurityGroupKey
						  FROM tReport r (NOLOCK)
							INNER JOIN tSecurityGroup sg (NOLOCK) ON r.CompanyKey = sg.CompanyKey
						 WHERE r.CompanyKey = @CompanyKey 
						   AND r.ReportType = 3

					UPDATE tReport
						SET Private = 1, Orientation = 0, GroupBy = 1, ShowConditions = 0, LockedColumns = 0, Deleted = 0, AutoRun = 1, ApplicationVersion = 2, RunCnt = 0,  LastModified = GETUTCDATE(),  DateAdded = GETUTCDATE(),  DateModified = GETUTCDATE(), AddedBy = @UserKey, ModifiedBy = @UserKey
						WHERE CompanyKey = @CompanyKey 
						  AND ReportType = 3
				END
			END
		END
	END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spConvertAppSeedSetting]'
GO
IF OBJECT_ID(N'[dbo].[spConvertAppSeedSetting]', 'P') IS NOT NULL
EXEC sp_executesql N'



ALTER PROCEDURE [dbo].[spConvertAppSeedSetting]
(
	@LoadBeta int = 0
)
AS

/*
|| When      Who Rel      What
||  exec spConvertAppSeedSetting 1
|| Previous Comments moved to the end of this SP
|| 01/04/24  CRG 24.01.21 (644751)  Added submittedMeetingApprovals
|| 01/05/24  AMP 24.02.18 (661148)  Added Grid Options/Calendar Options headers to the Traffic Calendar
|| 02/07/24  RLB 24.03.17 (663123)  Added hint to myTasks Date range 
|| 02/09/24  CRG 24.03.17 (664035)  Added Meeting Approver to adminEmployees
|| 02/28/24  GAR 24.03.17 (665372)  Added Billing Method to the planningProjects grid
|| 03/04/24  GAR 24.04.14 (665346)  Added Billing Option to the planningProjects grid
|| 03/05/24  RLS 24.04.14 (662926)  Removed campBudgetProjectFullName field from the campBudget section
|| 04/10/24  CRG 24.05.19 (665914)  Added Constraint Name column to Staff Schedule Detail screens
|| 04/11/24  RLB 24.05.19 (668621)  Added Date Task Assigned to staffScheduleWeekDetail and staffScheduleDayDetail (669161) Task Description as well
|| 04/22/24  RLB 24.05.19 (670398)  Removed time section in trafficRM because it is not used on the page
|| 05/16/24  MFT 24.06.00 (672517)  Make Billing Today ProjectStatus and ProjectBillingStatus SelectList to match other screens and fix bug on TM dash
|| 06/03/24  CRG 24.07.14 (667422)  Added Scheduled Transactions to billingToday and purchasingToday
|| 06/06/24  RLS 24.07.14 (671824)  Added AllocatedRemaining to the productionDash section
|| 06/07/24  MCM 24.07.14 (650217)  Added Use Markup to the Broadcast and Print Orders
|| 06/19/24  RLB 24.07.14 (674309)  Added option to use month worked on gl fin drill down
|| 06/26/24  RLS 24.07.14 (675529)  Remove the Your Comments field from the Project Request Approval section
|| 06/27/24  RLB 24.07.14 (675370)  Added Filter for I am BM to productionDash
|| 06/28/24  AMP 24.08.18 (672267)  Added Client Project Number and Client Campaign Number to the Forecast Detail Grid
|| 07/11/24  GAR 24.08.18 (676173)  Added ProjectManager to all 4 system settings for billingToday_
|| 07/20/24  RLB 24.08.18 (679274)  Added Task Plan Complete Date to toDoBoard grouping optionsprjbudgetSettings
|| 08/01/24  RLB 24.09.15 (679468) add Pub/Station to billingTransactions
|| 08/14/24  RLB 24.09.15 (679831) added Project Allocated Hours Remaining to campaignBudget
|| 08/21/24  MCM 24.09.15 (681078) add GLC Exchange Rate to the jeDetail
|| 08/26/24  AMP 24.09.15 (663557) Added the Unapplied Amount to the Project Budget -> Advanced Billed Column drill-down
|| 08/29/24  AMP 24.10.20 (681440) Added Last Transaction Date to the Scheduled Transactions
|| 09/05/24  AMP 24.10.20 (681249) Added Sales Account to Client Billing - Labor Line Settings & Expense Line Settings
|| 09/19/24  RLB 24.10.20 (682495) Added Last Logged Out to adminEmployees
|| 09/19/24  RLS 24.10.20 (682428) Added OpenOrdersGross to the ProjectDash
|| 09/19/24  RLS 24.10.20 (682529) Added CreatedBy to the EmployeeDash
|| 09/27/24  RLB 24.10.20 (682076) Added assigned user col and grouping options on productionAssignment
|| 10/02/24  MCM 24.10.20 (680536) Added authorize.net column widths
|| 10/14/24  GAR 24.11.17 (684046) Added project color to the staff schedule grid
|| 10/15/24  GAR 24.11.17 (683966) Added ProjectColor to today.creatives
|| 10/16/24  GAR 24.11.17 (683246) Added billable and non-billable hours in timesheet approvals
|| 10/21/24  RLB 24.11.17 (685887) productionCampDash changed am an pm to select list to match page
|| 10/24/24  GAR 24.11.17 (683767) Removed Current Total Budget w/o Tax field from the Project Budget screen
|| 10/29/24  GAR 24.11.17 (665347) Added Revenue Forecasts to the notifications approvals window
|| 11/13/24  GAR 24.12.15 (683889) Adding system setting in My Settings to Allow Edit of Backup Approver
|| 11/14/24  RLB 24.12.15 (684868) added Shpw set baseline to projectSchedule
|| 11/14/24  RLB 24.12.15 (688036) fixed label on subject to changeRequestApprovals
|| 11/19/24  RLB 24.12.15 (688036) add column FutureLaborGrossRemaining to prjbudgetSettings
|| 11/20/24  RLB 24.12.15 (688466) added project name to the changeRequestApprovals
|| 11/27/24  RLB 24.12.15 (674309) removed month worked from financialGLDrillDown because the field is not pulled and does not exists on screen
|| 11/27/24  RLS 25.01.19 (685516) Added field prjScheduleBudgetLaborGross and prjScheduleAllocatedHoursGross
|| 12/06/24  RLB 25.01.19 (689358) billingWorksheetsApprovals added worksheet comment
|| 12/11/24  RLB 25.01.19 (687329) Added Default GL Company to grouping of adminEmployees
|| 12/26/24  RLS 25.01.19 (688836) Added new CONNECTIONS - Retainers section
|| 12/26/24  CRG 25.01.19 (685528) Added AssignedTemplatesOnly to projectAdd
|| 11/27/24  RLB 24.12.15 (691987) removed month worked from financialGLDrillDown because the field is not pulled and does not exists on screen. There was an if and month worked was not removed from that when the above fix was done
|| 01/13/25  AMP 25.03.16 (687792) Added ''Entered By'' to Unapproved Transactions and Unposted Transactions (Journal Entries)
|| 01/22/25  MCM 25.02.x  (686981) Added ''Unapplied Amount'' to the Unposted Transactions
|| 01/29/25  RLB 25.02.16 (688067) adding new fields CurrentBudgetExpenseQuantity and ActualQuantity to prjbudgetSettings
|| 02/04/25  CRG 25.02.16 (685937) Added Campaign Snapshot to the Dashboard
|| 02/12/25  RLB 25.03.16 (692356) added hide zero option to both staffScheduleDayDetail and staffScheduleWeekDetail
|| 02/13/25  RLB 25.03.16 (688067) adding new fields CurrentBudgetExpenseQuantity and ActualQuantity to prjbudgetSettings item and type grids
|| 03/03/25  AMP 25.04.20 (695658) Added review Due Date for Billing Worksheet Approvals
|| 04/01/25  AMP 25.04.20 (697413) Added Posting Date to Client Billing->Billing Transaction Settings
|| 04/07/25  AMP 25.05.18 (697727) Added Media Plan Full Name to Accrued Order Detail
|| 04/16/25  RLB 25.05.18 (699375) Added Office to group by to productionDash and productionDashPlanning
|| 04/17/25  CRG 25.05.18 (695993) Added campaignBudgetAnalysis settings
|| 04/17/25  MCM 25.06.x  (681626) Added ApprovalStatus to connectionsInvoices
|| 04/24/25  MCM 25.06.x  (696669) added campaignID to the forecastdetail
|| 04/25/25  CRG 25.05.18 (695993) Modified the title of the campaignBudgetAnalysis group
|| 05/14/25  CRG 25.06.15 (701167) Changed the default setting for AllowCompletionPercentages on myTasks
|| 06/11/25  AMP 25.07.20 (699885) Added settings for Apply Advance Bill 
|| 06/13/25  GAR 25.07.20 (703925) Added Office Name to My Projects Settings
|| 06/18/25  RLB 25.07.20 (704114) Added Display Time Entry Comments to all today pages
|| 07/17/25  AMP 25.05.18 (692056) Added a new column called ''Master'' to the Worksheets to Review, and the Worksheets to Approve pages
|| 08/07/25  RLB 25.09.14 (707450) Added Office Name to productionCampDash
|| 08/11/25  RLB 25.09.14 (708552) Added removed Order number option since it is not a column and is defaulted on for boTraffic and ioTraffic
|| 08/13/25  RLB 25.10.19 (708111) Added Campaign Budget Labor Remaining and Campaign Budget Expense Remaining to campaignBudgetAnalysis
|| 08/19/25  RLB 25.10.19 (707695) Added Percentage of Allocated to the prjbudgetSettings
|| 08/19/25  RLS 25.09.14 (708120) Added Conversation Count to the mytask section
|| 08/25/25  AMP 25.08.17 (709683) Added UpdateStatusNotes, UpdateClientNotes, UpdateDetailNotes to Production Dash
|| 09/03/25  GAR 25.09.21 (709974) Changed the default on edit column sets on campaign schedules to be true
|| 09/16/25  RLS 25.11.16 (711029) Added activecolumn to Admin Screens - Opportunity Outcomes
|| 10/02/25  GAR 25.11.16 (710278) Adding Transaction Grid Settings to the Campaign Billing screen like we have in projects billing
|| 10/31/25  RLB 25.12.14 (714339) Added copy Specs to project Add
|| 11/5/25   GAR 25.11.16 (714330) Change PO Item Name to Item Description
|| 12/11/25  RLB 26.01.18 (717026) added HoursBilled from the rollup to productionDash
|| 12/12/25  MCM 26.01.18 (698136) added IncrementDespositID to the receiptAdd
|| 12/18/25  RLS 26.01.18 (715665) Added Hours After Writeoff to productionDash
|| 12/29/25  GAR 26.02.15 (718310) Added Actual Hours and Time Comments to MyTasks grid settings
|| 01/13/26  RLS 26.02.15 (718167) Added AutoExpandTaskGrid to the trafficRM settings
|| 01/19/26  AMP 26.03.15 (719364) Added Station/Publication to CONNECTIONS - Vendor Invoices
|| 01/27/26  RLB 26.02.15 (718216) Added Media Plans to Global Search
|| 02/02/26  RLS 26.03.15 (718905) Added Originated By and Created By to the coltodoBoard section
|| 02/11/26  GAR 26.03.15 (721898) Added Actual Hours and Time Comments to MyTasks grid settings default load
|| 03/02/26  RLB 26.04.19 (722093) added Variance to clientInvoiceExpense
|| 03/03/26  GAR 26.04.19 (723387) Changed the default columns for the MyTasks grid settings default load
|| 03/17/26  RLS 26.04.19 (722453) Added taskFullName to the deliverable Approval section
|| 04/02/26  GAR 26.05.17 (722819) Added TotalGrossUnbilled to Campaign Billing Detail Settings
|| 04/10/26  GAR 26.05.17 (723471) Added settings in my tasks for ShowAccountManager and ShowProjectManager
|| 04/15/26  GAR 26.05.17 (726555) Added DeliverableCount to the project schedule grid
|| 04/27/26  GAR 26.05.17 (727081) Added BudgetRemainingHours to the project schedule grid
|| 05/12/26  GAR 26.06.14 (728245) Added Description to the Pay Credit Card Charges screen
|| 05/15/26  AMP 26.06.14 (724706) Added Billable to the Insertion Orders and Broadcast Orders
|| 05/26/26  RLS 26.06.14 (729061) Added Billed Variance to the clientInvoiceExpense section
|| 06/02/26  GAR 26.07.19 (728472) Added Posting Date to project billing grid settings - unbilled only
|| 06/15/26  RLB 26.07.19 (729936) Adding option Use Task Count instead of Hours to MyTasks

 */

-- 3 grids are different if the GL companies have foreign currencies
declare @GLCompaniesWithForeignCurrencies int
select @GLCompaniesWithForeignCurrencies = 1

Delete tAppSettingGroup
Delete tAppSetting


/*************************************************************************************************************************
My Settings
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''mySettings'', ''System Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mySettings'', ''H1'', 0, ''My Settings Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''mySettings'', ''EditContactInfo'', 1, ''Allow Editing of Contact Info'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mySettings'', ''EditLoginInfo'', 2, ''Allow Editing of Login Info'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mySettings'', ''EditDefaultSettings'', 3, ''Allow Editing of Default Settings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mySettings'', ''EditBackupApprover'', 4, ''Allow Editing of Backup Approver'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
My Tasks
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''myTasks'', ''System Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''H1'', 0, ''My Task Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, Required)
Values (''myTasks'', ''DateOption'', 1, ''Date Range'', ''1'', ''Due on or before a week from Today'', ''lookup'', ''Due on or before Today:0|Due on or before a week from Today:1|Due on or before 2 weeks from Today:2|Start on or before Today:3|Start on or before a week from Today:4|Start on or before 2 weeks from Today:5|All:6'', NULL, ''When using "All" as the Date Range and when "Completed Predecessors Only" is not checked the tasks shown will be limited to 6 weeks out from today. Any tasks with a start date greater than 6 weeks from today will not show.'', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''OpenToDo'', 2, ''Open To Do Items Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''PredCompOnly'', 3, ''Completed Predecessors Only'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''OpenDeliverablesOnly'', 4, ''Open Deliverables Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''MoreTasks'', 5, ''Assign New Tasks'', ''1'', NULL, ''checkbox'', NULL, NULL, ''Allow users to assign tasks to themselves'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''myTasks'', ''AssignOtherPeoplesTasks'', 6, ''Assign myself to other people''''s tasks'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Allow users to assign others peoples tasks to themselves'', ''MoreTasks'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''ProjectType'', 7, ''Project Type'', ''-1'', ''All'', ''selectlist'', NULL, ''selectlist.ProjectType'', NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''ShowAccountManager'', 8, ''Show Account Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''ShowProjectManager'', 9, ''Show Project Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''H2'', 10, ''Display Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''GroupBy'', 11, ''Group By'', ''PlanComplete'', ''Due Date'', ''lookup'', ''No Grouping:NoGrouping|Priority:PriorityName|Project:ProjectFullName|Campaign:CampaignFullName|Campaign Segment:SegmentName|Client:ClientFullName|Task Name:TaskName|Task Type:TaskTypeDesc|Project Status:ProjectStatus|Project Type:ProjectTypeName|Account Manager:AccountManagerName|Summary Task:SummaryTaskName|Due Date:PlanComplete|Start Date:PlanStart|Project Manager:ProjectManagerName|Assignment Status:TaskUserStatusName|Timeline Segment:TimelineSegmentName|Product Name:ProductName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''GroupByDir'', 12, ''Group Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''SortBy'', 13, ''Sort By'', ''Priority'', ''Priority'', ''lookup'', ''Project Number:ProjectNumber|Campaign ID:CampaignID|Campaign Segment:SegmentName|Client:ClientID|Status:TaskStatus|Priority:Priority|Task:TaskName|Task Type:TaskTypeDesc|Start Date:PlanStart|Due Date:PlanComplete|Due Time:DueBy|Percent Complete:PercComp|Account Manager:AccountManagerName|Summary Task:SummaryTaskName|Open ToDo Items:OpenToDos|Project Manager:ProjectManagerName| Timeline Segment:TimelineSegmentName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''SortByDir'', 14, ''Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''ShowCardView'', 15, ''Show Card View'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''ShowGridView'', 16, ''Show Grid View'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''ShowTileView'', 17, ''Show Tile View'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Date range, grouping and sorting options do not apply to Tile View.'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''myTasks'', ''ShowAssignmentZeroAllocated'', 18, ''Show Assignments With Zero Allocated'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will show task assignments regardless of how many hours are assigned. Use this option if you do not allocate hours to people.'', ''ShowTileView'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''DisableDragging'', 19, ''Disable Dragging Tiles'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''AllowCompletionPercentages'', 20, ''Allow Completion Percentages'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''HandOffTasks'', 21, ''Hand Off Tasks'', ''1'', NULL, ''checkbox'', NULL, NULL, ''Allow users to hand off tasks'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''UseTaskCountNotHours'', 22, ''Use Task Count Instead of Hours'', ''0'', NULL, ''checkbox'', NULL, null, ''This will show user totals based on task count instead of hours on tile view'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''myTasks'', ''grdMyTasksCols'', 23, ''Grid View Columns'', ''mytaskProjectFullName,mytaskTaskIDName,mytaskTaskStatus,mytaskActualHours,mytaskTimeComments,mytaskPercComp,mytaskRemainingHours,mytaskPlanStart,mytaskPlanComplete,mytaskDueBy'', NULL, ''grid'', 

''[{id:"mytaskProjectFullName", label:"Project"},
	{id:"mytaskTaskIDName", label:"Task"},
	{id:"mytaskTaskStatus", label:"Status"},
	{id:"mytaskOpenToDos", label:"Open ToDos"},
	{id:"mytaskOpenDeliverables", label:"Open Deliverables"},
	{id:"mytaskPlanStart", label:"Start"},
	{id:"mytaskPlanComplete", label:"Due"},
	{id:"mytaskPercComp", label:"% Complete"},
	{id:"mytaskDueBy", label:"Due By"},
	{id:"mytaskComments", label:"Task Status Comments"},
	{id:"mytaskRemainingHours", label:"Remaining"},
	{id:"mytaskAssignedHours", label:"Assigned Hours"},
	{id:"mytaskProjectNumber", label:"Project Number"},
	{id:"mytaskCampaignFullName", label:"Campaign"},
	{id:"mytaskCampaignSegmentName", label:"Campaign Segment"},
	{id:"mytaskAccountManagerName", label:"Account Manager"},
	{id:"mytaskProjectManagerName", label:"Project Manager"},
	{id:"mytaskProjectTypeName", label:"Project Type"},
	{id:"mytaskProjectName", label:"Project Name"},
	{id:"mytaskProjectStatus", label:"Project Status"},
	{id:"mytaskOnHold", label:"On Hold"},
	{id:"mytaskClientID", label:"Client ID"},
	{id:"mytaskClientName", label:"Client Name"},
	{id:"mytaskTaskDescription", label:"Description"},
	{id:"mytaskTaskTypeDesc", label:"Task Type"},
	{id:"mytaskTaskID", label:"Task ID"},
	{id:"mytaskPrimaryContact", label:"Primary Contact"},
	{id:"mytaskPhone1", label:"Phone"},
	{id:"mytaskEmail", label:"Email"},
	{id:"mytaskPhone", label:"Company Phone"},
	{id:"mytaskActStart", label:"Actual Start"},
	{id:"mytaskPriorityName", label:"Priority"},
	{id:"mytaskSummaryTaskID", label:"Summary Task ID"},
	{id:"mytaskSummaryTaskName", label:"Summary Task name"},
	{id:"mytaskServiceCode", label:"Service Code"},
	{id:"mytaskServiceDescription", label:"Service Description"},
	{id:"mytaskServiceFullName", label:"Service Full Name"},
	{id:"mytaskPredecessorsComplete", label:"Predecessor Complete"},
	{id:"mytaskBaseStart", label:"Orig Start"},
	{id:"mytaskBaseComplete", label:"Orig Complete"},
	{id:"mytaskProjectStartDate", label:"Project Start Date"},
	{id:"mytaskTaskUserStatusName", label:"Assignment Status"},
	{id:"mytaskProjectCompleteDate", label:"Project Complete Date"},
	{id:"mytaskKeyPeople1", label:"Key Person 1"},
	{id:"mytaskKeyPeople2", label:"Key Person 2"},
	{id:"mytaskKeyPeople3", label:"Key Person 3"},
	{id:"mytaskKeyPeople4", label:"Key Person 4"},
	{id:"mytaskKeyPeople5", label:"Key Person 5"},
	{id:"mytaskKeyPeople6", label:"Key Person 6"},
	{id:"mytaskNextSteps", label:"Next Steps"},
	{id:"mytaskConversationCount", label:"Conversation Count"},
	{id:"mytaskProjectColor", label:"Project Color"},
	{id:"mytaskActualHours", label:"Actual Hours"},
	{id:"mytaskTimeComments", label:"Time Comments"}]''

	 , NULL, NULL, ''Project'', ''Project'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''AutoExpandTaskGrid'', 24, ''Auto Expand Tasks'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''H3'', 25, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''myTasks'', ''DailyFeed'', 26, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''H6'', 27, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''myTasks'', ''SortConversations'', 28, ''Sort Conversations'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''FilterProjectTab'', 29, ''Only show Project Conversations sent to me'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''H4'', 30, ''Timeline Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''hideSchedule'', 31, ''Hide the schedule on the side'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''HideEnterTime'', 32, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''DisplayTimeEntries'', 33, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''myTasks'', ''DisplayTimeEntriesComments'', 34, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''DisplayTimeEntries'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''IncludePublicMeetings'', 35, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''H5'', 36, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myTasks'', ''ShowInOutBoard'', 37, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Time Entry
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''timeEntry'', ''Time Entry Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''DefaultProjects'', 1, ''Default Projects From Assignments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''DefaultSystemLog'', 2, ''Default Projects Touched Today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''ShowRateLevel'', 3, ''Show Rate Level'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''OpenExpanded'', 4, ''Expand Time Sheet When Opened'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''ShowZeroHourTimesheets'', 5, ''Show 0 Hour Time Sheets'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''CopyTimeSheets'', 6, ''Allow Copy Time Sheet'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''H2'', 7, ''Display Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''GroupBy'', 8, ''Group By'', ''NoGrouping'', ''No Grouping'', ''lookup'', ''No Grouping:NoGrouping|Project:ProjectFullName|Client:ClientName|Campaign:CampaignFullName|Task Name:TaskName|Project Status:ProjectStatus|Project Type:ProjectTypeName|Account Manager:AccountManagerName|Project Manager:ProjectManagerName'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''hideWeekend'', 9, ''Hide Weekend Days'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timeEntry'', ''showStartEnd'', 10, ''Show Start Time, End Time, and Paused Hours in Day View grid'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
Marketing Groups
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''marketinggroups'', ''Marketing Group Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''marketinggroups'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''marketinggroups'', ''grdListCols'', 1, ''Columns'', ''UserFullName,UserPhone1,UserEmail,CompanyName,ContactAddress1,ContactCity,ContactState,ContactPostalCode'', NULL, ''grid'', 
''[	{id:"UserFullName", label:"Contact Full Name"},
	{id:"UserPhone1", label:"Contact Phone 1"},
	{id:"UserEmail", label:"Contact Email"},
	{id:"CompanyName", label:"Company Name"},
	{id:"ContactAddress1", label:"Contact Address1"},
	{id:"ContactAddress2", label:"Contact Address2"},
	{id:"ContactAddress3", label:"Contact Address3"},
	{id:"ContactCity", label:"Contact City"},
	{id:"ContactState", label:"Contact State"},
	{id:"ContactPostalCode", label:"Contact PostalCode"},
	{id:"ContactCountry", label:"Contact Country"},
	{id:"CompanyMailingAddress1", label:"Company Mailing Address 1"},
	{id:"CompanyMailingAddress2", label:"Company Mailing Address 2"},
	{id:"CompanyMailingAddress3", label:"Company Mailing Address 3"},
	{id:"CompanyMailingCity", label:"Company Mailing City"},
	{id:"CompanyMailingState", label:"Company Mailing State"},
	{id:"CompanyMailingPostalCode", label:"Company Mailing Postal Code"},
	{id:"CompanyMailingCountry", label:"Company Mailing Country"},
	{id:"CompanyType", label:"Company Type"},
	{id:"CompanyWebSite", label:"Company WebSite"},
	{id:"CompanyMainPhone", label:"Company Main Phone"},
	{id:"CompanyMainFax", label:"Company Main Fax"},
	{id:"CompanySource", label:"Company Source"},
	{id:"UserFirstName", label:"Contact First Name"},
	{id:"UserLastName", label:"Contact Last Name"},
	{id:"UserSalutation", label:"Contact Salutation"},
	{id:"UserPhone2", label:"Contact Phone 2"},
	{id:"UserCell", label:"Contact Cell"},
	{id:"UserFax", label:"Contact Fax"},
	{id:"UserTitle", label:"Contact Title"},
	{id:"UserRole", label:"Contact Role"},
	{id:"Active", label:"Active"},
	{id:"ContactOwner", label:"Contact Owner"},
	{id:"AccountManager", label:"Account Manager"},
	{id:"IsPrimaryContact", label:"Is Primary Contact"},
	{id:"LastSyncMessage", label:"Last Sync Message"}
 ]''
 , NULL, NULL, NULL, NULL)


/*************************************************************************************************************************
Misc Cost
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''misccosts'', ''Misc Cost Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''misccosts'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''misccosts'', ''grdMiscCostCols'', 1, ''Columns'', ''expenseDate,task,item,shortDescription,gridMiscCostTotalCost,gridMiscCostTotalGross'', NULL, ''grid'', 
''[	{id:"expenseDate", label:"Date"},
	{id:"task", label:"Task"},
	{id:"item", label:"Item"},
	{id:"shortDescription", label:"Description"},
	{id:"miscCostClass", label:"Class"},
	{id:"miscCostDepartment", label:"Department"},
	{id:"miscCostExchangeRate", label:"Exchange Rate"},
	{id:"miscCostQuantity", label:"Quantity"},
	{id:"miscCostUnitCost", label:"Unit Cost"},
	{id:"gridMiscCostTotalCost", label:"Net"},
	{id:"miscCostBillable", label:"Billable"},
	{id:"miscCostMarkup", label:"Markup"},
	{id:"misCostUnitRate", label:"Unit Rate"},
	{id:"gridMiscCostTotalGross", label:"Gross"},
	{id:"miscCostComments", label:"Comments"},
	{id:"miscCostStatus", label:"Status"},
	{id:"miscCostAddedBy", label:"Added By"},
	{id:"miscCostUnitDesc", label:"Unit Description"},
	{id:"miscCostScheduled", label:"Scheduled"}
 ]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Expense Report
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''expenses'', ''Expense Receipt Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''expenses'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''expenses'', ''grdExpenseReceiptsCols'', 1, ''Columns'', ''expenseDate,project,task,item,description,actualUnitCost,actualCost,comments'', NULL, ''grid'', 

''[	{id:"expenseDate", label:"Date"},
	{id:"project", label:"Project"},
	{id:"task", label:"Task"},
	{id:"item", label:"Item"},
	{id:"description", label:"Description"},
	{id:"quantity", label:"Quantity"},
	{id:"actualUnitCost", label:"Unit Cost"},
	{id:"actualCost", label:"Net"},
	{id:"comments", label:"Comments"},
	{id:"billable", label:"Billable"},
	{id:"gross", label:"Total Gross"},
	{id:"markup", label:"Mark Up"},
	{id:"paperReceipt", label:"Paper Receipt"},
	{id:"taxable", label:"Tax 1"},
	{id:"taxable2", label:"Tax 2"},
	{id:"actualCostWithTaxes", label:"Total Net With taxes"},
	{id:"unitRate", label:"Unit Rate"},
	{id:"attachmentCount", label:"Attachment Count"},
	{id:"office", label:"Office"},
	{id:"class", label:"Class"},
	{id:"er_ExpenseGLAccountKey", label:"Expense GL Account"}
 ]''
	 , NULL, NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''expenses'', ''GroupByDate'', 1, ''Group By Date'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)




/*************************************************************************************************************************
Project Estimate List
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''estimateList'', ''Estimate List Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateList'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''estimateList'', ''gridCols'', 1, ''Columns'', ''EstimateFullName,EstimateNumber,ChangeOrder,DateAdded,EnteredByName,ExternalApprovalStatus,ExternalApproverName,InternalApprovalStatus,EstimateTotal'', NULL, ''grid'', 
''[	{id:"ChangeOrder", label:"Change Order"},
	{id:"DateAdded", label:"Date Added"},
	{id:"EnteredByName", label:"Entered By"},
	{id:"EstimatedDeliveryDate", label:"Estimated Delivery Date"},
	{id:"EstTypeDesc", label:"Est Type"},
	{id:"EstimateFullName", label:"Estimate Name"},
	{id:"EstimateDescription", label:"Estimate Description"},
	{id:"EstimateNumber", label:"Estimate Number"},
	{id:"ExternalApprovalStatus", label:"External Approval Status"},
	{id:"ExternalApproverName", label:"External Approver Name"},
	{id:"ExternalComments", label:"External Comments"},
    {id:"IncludeInForecast", label:"Include In Forecast"},
	{id:"InternalApprovalStatus", label:"Internal Approval Status"},
	{id:"InternalApproverName", label:"Internal Approver Name"},
	{id:"InternalComments", label:"Internal Comments"},
	{id:"Revision", label:"Revision"},
	{id:"EstimateTotal", label:"Estimate Total"},
	{id:"ExpenseGross", label:"Expense Gross"},
	{id:"ExpenseNet", label:"Expense Net"},
	{id:"Hours", label:"Hours"},
	{id:"LaborGross", label:"Labor Gross"},
	{id:"LaborNet", label:"Labor Net"},
	{id:"SalesTax2Amount", label:"Sales Tax2 Amount"},
	{id:"SalesTaxAmount", label:"Sales Tax Amount"},
	{id:"TaxableTotal", label:"Taxable Total"},
	{id:"Total", label:"Total"},
	{id:"LaborTaxableDesc", label:"Labor Taxable"},
	{id:"SelectedOption", label:"Selected Option"},
	{id:"OptionName", label:"Option Name"},
	{id:"InternalApprovalDate", label:"Internal Approval Date"},
	{id:"ApprovedTotal", label:"Approved Total"}
 ]''
	 , NULL, NULL, null, NULL)


INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''estimateExpense'', ''Estimate Expense Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateExpense'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''estimateExpense'', ''grdExpenseEstimateCols'', 1, ''Columns'', ''task_e,item_e,vendor_e,quantity_e,unitCost_e,totalCost_e,markup_e,gross_e'', NULL, ''grid'', 

''[	{id:"task_e", label:"Task"},
	{id:"line", label:"Line"},
	{id:"segment_e", label:"Segment"},
	{id:"item_e", label:"Item"},
	{id:"vendor_e", label:"Vendor"},
	{id:"vendorcurrency_e", label:"Vendor Currency"},
	{id:"description_e", label:"Description"},
	{id:"quantity_e", label:"Quantity"},
	{id:"unitCost_e", label:"Unit Cost"},
	{id:"totalCost_e", label:"Net"},
	{id:"billable_e", label:"Billable"},
	{id:"gross_e", label:"Gross"},
	{id:"markup_e", label:"Markup"},
	{id:"uom_e", label:"UOM"},
	{id:"uom2_e", label:"UOM 2"},
	{id:"uom3_e", label:"UOM 3"},
	{id:"uom4_e", label:"UOM 4"},
	{id:"uom5_e", label:"UOM 5"},
	{id:"uom6_e", label:"UOM 6"},
	{id:"taxable_e", label:"Tax 1"},
	{id:"taxable2_e", label:"Tax 2"},
	{id:"unitRate_e", label:"Unit Rate"},
	{id:"longdescription_e", label:"Long Description"},
	{id:"quantity2_e", label:"Quantity 2"},
	{id:"quantity3_e", label:"Quantity 3"},
	{id:"quantity4_e", label:"Quantity 4"},
	{id:"quantity5_e", label:"Quantity 5"},
	{id:"quantity6_e", label:"Quantity 6"},
	{id:"unitCost2_e", label:"Unit Cost 2"},
	{id:"unitCost3_e", label:"Unit Cost 3"},
	{id:"unitCost4_e", label:"Unit Cost 4"},
	{id:"unitCost5_e", label:"Unit Cost 5"},
	{id:"unitCost6_e", label:"Unit Cost 6"},
	{id:"totalCost2_e", label:"Net 2"},
	{id:"totalCost3_e", label:"Net 3"},
	{id:"totalCost4_e", label:"Net 4"},
	{id:"totalCost5_e", label:"Net 5"},
	{id:"totalCost6_e", label:"Net 6"},
	{id:"gross_e2", label:"Gross 2"},
	{id:"gross_e3", label:"Gross 3"},
	{id:"gross_e4", label:"Gross 4"},
	{id:"gross_e5", label:"Gross 5"},
	{id:"gross_e6", label:"Gross 6"},
	{id:"markup2_e", label:"Markup 2"},
	{id:"markup3_e", label:"Markup 3"},
	{id:"markup4_e", label:"Markup 4"},
	{id:"markup5_e", label:"Markup 5"},
	{id:"markup6_e", label:"Markup 6"},
	{id:"unitRate2_e", label:"Unit Rate 2"},
	{id:"unitRate3_e", label:"Unit Rate 3"},
	{id:"unitRate4_e", label:"Unit Rate 4"},
	{id:"unitRate5_e", label:"Unit Rate 5"},
	{id:"unitRate6_e", label:"Unit Rate 6"},
	{id:"comments_e", label:"Comments"}
 ]''
	 , NULL, NULL, null, NULL)



/*************************************************************************************************************************
Forecast Detail Grid
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''forecastDetails'', ''Forecast Details Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''forecastDetails'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''forecastDetails'', ''grdForecastDetail'', 1, ''Columns'', ''fdetail_status,fdetail_date,fdetail_months,fdetail_currencyid,fdetail_billingmethod,fdetail_percent,fdetail_total,fdetail_prior,fdetail_bill,fdetail_monthcols,fdetail_next,fdetail_reviewcomp,fdetail_client,fdetail_manager,fdetail_office,fdetail_type,fdetail_est,fdetail_regen,fdetail_clientprojnum,fdetail_clientcampnum'', NULL, ''grid'', 

''[	{id:"fdetail_status", label:"Status"},
	{id:"fdetail_date", label:"Start Date"},
	{id:"fdetail_projectduedate", label:"Project Due Date"},
	{id:"fdetail_months", label:"Number of Months"},
	{id:"fdetail_currencyid", label:"Currency"},
	{id:"fdetail_billingmethod", label:"Billing Method"},
	{id:"fdetail_percent", label:"Probability"},
	{id:"fdetail_totalbefore", label:"Total Before %"},
	{id:"fdetail_total", label:"Total"},
	{id:"fdetail_prior", label:"Prior Months"},
	{id:"fdetail_bill", label:"Act Billing"},
	{id:"fdetail_monthcols", label:"Monthly Cols"},
	{id:"fdetail_next", label:"Next 12 months"},
	{id:"fdetail_reviewcomp", label:"Reviewed"},
	{id:"fdetail_client", label:"Client"},
	{id:"fdetail_manager", label:"Account Manager"},
	{id:"fdetail_office", label:"Office"},
	{id:"fdetail_type", label:"Detail Type"},
	{id:"fdetail_projtype", label:"Project Type"},
	{id:"fdetail_est", label:"From Estimate"},
	{id:"fdetail_regen", label:"Regenerate Needed?"},
	{id:"fdetail_project_manager", label:"Project Manager"},
	{id:"fdetail_total_budget", label:"Total Budget"},
	{id:"fdetail_projstatus", label:"Project Status"},
	{id:"fdetail_clientprojnum", label:"Client Project Number"},
	{id:"fdetail_clientcampnum", label:"Client Campaign Number"},
	{id:"fdetail_campaignid", label:"Campaign ID"}
 ]''
	 , NULL, NULL, null, NULL)

	 
/*************************************************************************************************************************
Purchase Orders
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''poEdit'', ''Purchase Order Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''poEdit'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''poEdit'', ''SpecSheets'', 1, ''Show Spec Sheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''poEdit'', ''Attachments'', 2, ''Show Attachments'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''poEdit'', ''grdPurchaseOrderDetail'', 1, ''Columns'', ''pod_ProjectKey,pod_ItemKey,pod_Quantity,pod_UnitCost,pod_TotalCost,pod_Markup,pod_GrossAmount'', NULL, ''grid'', 

''[	{id:"pod_LineNumber", label:"Line Number"},
	{id:"pod_LinkID", label:"Link ID"},
	{id:"pod_ProjectKey", label:"Project"},
	{id:"pod_TaskKey", label:"Task"},
	{id:"pod_ClassKey", label:"Class"},
	{id:"pod_ItemKey", label:"Item ID"},
	{id:"pod_OfficeKey", label:"Office"},
	{id:"pod_DepartmentKey", label:"Department"},
	{id:"pod_ShortDescription", label:"Item Description"},
	{id:"pod_LongDescription", label:"Standard Description"},
	{id:"pod_Quantity", label:"Quantity"},
	{id:"pod_UnitCost", label:"Unit Cost"},
	{id:"pod_TotalCost", label:"Net"},
	{id:"pod_UnitDescription", label:"Unit Description"},
	{id:"pod_Markup", label:"Markup"},
	{id:"pod_Billable", label:"Billable"},
	{id:"pod_GrossAmount", label:"Gross"},
	{id:"pod_AppliedCost", label:"Applied Cost"},
	{id:"pod_AmountBilled", label:"Amount Billed"},
	{id:"pod_AccruedCost", label:"Accrued Cost"},
	{id:"pod_DateBilled", label:"Date Billed"},
	{id:"pod_Closed", label:"Closed"},
	{id:"pod_Taxable", label:"Taxable"},
	{id:"pod_Taxable2", label:"Taxable2"},
	{id:"pod_BilledComment", label:"Billed Comment"},
	{id:"pod_TransferComment", label:"Transfer Comment"},
	{id:"pod_UnitRate", label:"Unit Rate"},
	{id:"pod_SalesTaxAmount", label:"Sales Tax Amount"},
	{id:"pod_SalesTax1Amount", label:"Sales Tax1 Amount"},
	{id:"pod_SalesTax2Amount", label:"Sales Tax2 Amount"},
	{id:"pod_OtherSalesTaxAmount", label:"Other Sales Tax Amount"}
 ]''
	 , NULL, NULL, null, NULL)

 
/*************************************************************************************************************************
Insertion Orders
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''ioEdit'', ''Insertion Order Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''ioEdit'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''ioEdit'', ''SpecSheets'', 1, ''Show Spec Sheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''ioEdit'', ''Attachments'', 2, ''Show Attachments'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''ioEdit'', ''grdPurchaseOrderDetail'', 1, ''Columns'', ''pod_Actions,pod_DetailOrderDate,pod_ItemKey,pod_ShortDescription,pod_GrossAmount,pod_Markup,pod_TotalCost,pod_LineNumber,pod_AdjustmentNumber'', NULL, ''grid'', 

''[	{id:"pod_LineNumber", label:"Line #"},
    {id:"pod_AdjustmentNumber", label:"Adj #"},
	{id:"pod_LinkID", label:"Link ID"},
	{id:"pod_ReasonID", label:"Revision Reason"},
	{id:"pod_Actions", label:"Actions"},
	{id:"pod_ProjectKey", label:"Project"},
	{id:"pod_TaskKey", label:"Task"},
	{id:"pod_ClassKey", label:"Class"},
	{id:"pod_ItemKey", label:"Item ID"},
	{id:"pod_OfficeKey", label:"Office"},
	{id:"pod_DepartmentKey", label:"Department"},
	{id:"pod_ShortDescription", label:"Item Name (Ad Number/Caption)"},
	{id:"pod_LongDescription", label:"Standard Description"},
	{id:"pod_Quantity", label:"Quantity"},
	{id:"pod_TotalCost", label:"Net"},
	{id:"pod_MaterialsSent", label:"Materials Sent"},
	{id:"pod_MaterialsSentDate", label:"Materials Sent Date"},
	{id:"pod_Billable", label:"Billable"},
	{id:"pod_UnitDescription", label:"Unit Description"},
	{id:"pod_Markup", label:"Commission"},
	{id:"pod_GrossAmount", label:"Gross"},
	{id:"pod_AppliedCost", label:"Applied Cost"},
	{id:"pod_AmountBilled", label:"Amount Billed"},
	{id:"pod_AccruedCost", label:"Accrued Cost"},
	{id:"pod_DateBilled", label:"Date Billed"},
	{id:"pod_Closed", label:"Closed"},
	{id:"pod_Taxable", label:"Taxable"},
	{id:"pod_Taxable2", label:"Taxable2"},
	{id:"pod_BilledComment", label:"Billed Comment"},
	{id:"pod_TransferComment", label:"Transfer Comment"},
	{id:"pod_SalesTaxAmount", label:"Sales Tax Amount"},
	{id:"pod_SalesTax1Amount", label:"Sales Tax1 Amount"},
	{id:"pod_SalesTax2Amount", label:"Sales Tax2 Amount"},
	{id:"pod_OtherSalesTaxAmount", label:"Other Sales Tax Amount"},
	{id:"pod_DetailOrderDate", label:"Insertion Date"},
	{id:"pod_UserDate1", label:"Space Close"},
	{id:"pod_UserDate2", label:"Materials Due"},
	{id:"pod_InvoiceNumber", label:"Client Invoice #"},
	{id:"pod_VendorInvoiceNumber", label:"Vendor Invoice #"},
	{id:"pod_UnaccruedCost", label:"Unaccrued Cost"}
 ]''
	 , NULL, NULL, null, NULL)

 
/*************************************************************************************************************************
Broadcast Orders
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''bcEdit'', ''Broadcast Order Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''bcEdit'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''bcEdit'', ''SpecSheets'', 1, ''Show Spec Sheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''bcEdit'', ''Attachments'', 2, ''Show Attachments'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''bcEdit'', ''grdPurchaseOrderDetail'', 1, ''Columns'', ''pod_Actions,pod_DetailOrderDate,pod_DetailOrderEndDate,pod_ItemKey,pod_ShortDescription,pod_Quantity,pod_GrossAmount,pod_Markup,pod_TotalCost,pod_LineNumber,pod_AdjustmentNumber'', NULL, ''grid'', 

''[	{id:"pod_LineNumber", label:"Line #"},
    {id:"pod_AdjustmentNumber", label:"Adj #"},
	{id:"pod_LinkID", label:"Link ID"},
	{id:"pod_ReasonID", label:"Revision Reason"},
	{id:"pod_Actions", label:"Actions"},
	{id:"pod_ProjectKey", label:"Project"},
	{id:"pod_TaskKey", label:"Task"},
	{id:"pod_ClassKey", label:"Class"},
	{id:"pod_ItemKey", label:"Item ID"},
	{id:"pod_OfficeKey", label:"Office"},
	{id:"pod_DepartmentKey", label:"Department"},
	{id:"pod_ShortDescription", label:"Item Name (Program)"},
	{id:"pod_LongDescription", label:"Standard Description"},
	{id:"pod_Quantity", label:"Spots"},
	{id:"pod_AppliedSpots", label:"Applied Spots"},
	{id:"pod_TotalCost", label:"Net"},
	{id:"pod_MaterialsSent", label:"Materials Sent"},
	{id:"pod_Billable", label:"Billable"},
	{id:"pod_MaterialsSentDate", label:"Materials Sent Date"},
	{id:"pod_UnitDescription", label:"Unit Description"},
	{id:"pod_Markup", label:"Commission"},
	{id:"pod_GrossAmount", label:"Gross"},
	{id:"pod_AppliedCost", label:"Applied Cost"},
	{id:"pod_AmountBilled", label:"Amount Billed"},
	{id:"pod_AppliedAmountBilled", label:"Amount Billed on VI"},
	{id:"pod_AccruedCost", label:"Accrued Cost"},
	{id:"pod_DateBilled", label:"Date Billed"},
	{id:"pod_Closed", label:"Closed"},
	{id:"pod_Taxable", label:"Taxable"},
	{id:"pod_Taxable2", label:"Taxable2"},
	{id:"pod_BilledComment", label:"Billed Comment"},
	{id:"pod_TransferComment", label:"Transfer Comment"},
	{id:"pod_SalesTaxAmount", label:"Sales Tax Amount"},
	{id:"pod_SalesTax1Amount", label:"Sales Tax1 Amount"},
	{id:"pod_SalesTax2Amount", label:"Sales Tax2 Amount"},
	{id:"pod_OtherSalesTaxAmount", label:"Other Sales Tax Amount"},
	{id:"pod_DetailOrderDate", label:"Start Date"},
	{id:"pod_DetailOrderEndDate", label:"End Date"},
	{id:"pod_UserDate1", label:"Space Close"},
	{id:"pod_UserDate2", label:"Materials Due"},
	{id:"pod_InvoiceNumber", label:"Client Invoice #"},
	{id:"pod_VendorInvoiceNumber", label:"Vendor Invoice #"},
	{id:"pod_UnitRate", label:"Unit Rate"},

	{id:"pod_UnaccruedCost", label:"Unaccrued Cost"},
	{id:"pod_OrderDays", label:"Days"},
	{id:"pod_OrderTime", label:"Time"},
	{id:"pod_OrderLength", label:"Length"}
 ]''
	 , NULL, NULL, null, NULL)

	  
/*************************************************************************************************************************
Media Plan Details
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''mediaPlanDetails'', ''Media Vendor Details Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaPlanDetails'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''mediaPlanDetails'', ''grdDetails'', 1, ''Columns'', ''mediaDescription,mediaID,mediaStartDate,mediaEndDate,mediaDate1,mediaDate2,mediaHistory,mediaQuantity,mediaUnitCost,mediaGross,mediaMU,mediaNet,mediaAmountToBill,mediaAppliedCost,mediaPO,mediaLine,mediaBilled,mediaDeleted'', NULL, ''grid'', 

''[	{id:"mediaDescription", label:"Description"},
	{id:"mediaID", label:"Link ID"},
	{id:"mediaOrderID", label:"Order Link ID"},
	{id:"mediaStartDate", label:"Start Date"},
	{id:"mediaEndDate", label:"End Date"},
	{id:"mediaDate1", label:"Space Close"},
	{id:"mediaDate2", label:"Materials Due"},
	{id:"mediaHistory", label:"Changes"},
	{id:"mediaQuantity", label:"Qty/Spots"},
	{id:"mediaUnitCost", label:"Unit Rate"},
	{id:"mediaNet", label:"Net"},
	{id:"mediaMU", label:"Commission"},
	{id:"mediaGross", label:"Gross"},
	{id:"mediaAmountToBill", label:"Amount To Bill"},
	{id:"mediaDeleted", label:"Deleted"},
	{id:"mediaAppliedCost", label:"Applied Costs"},
	{id:"mediaPO", label:"Order"},
	{id:"mediaLine", label:"Line"},
	{id:"mediaBilled", label:"Billed"},
	{id:"mediaOrderDays", label:"Days"},
	{id:"mediaOrderTime", label:"Time"},
	{id:"mediaOrderLength", label:"Length"},
	{id:"mediaErrMsgOrder", label:"Err Message"}
 ]''
	 , NULL, NULL, null, NULL)

/*************************************************************************************************************************
Vendor Invoices
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''voucherEdit'', ''Vendor Invoice Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''voucherEdit'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''voucherEdit'', ''grdVoucherDetail'', 1, ''Columns'', ''vd_ProjectKey,vd_ItemKey,vd_Quantity,vd_UnitCost,vd_TotalCost,vd_Markup,vd_Commission,vd_GrossAmount'', NULL, ''grid'', 

''[	{id:"vd_LinkID", label:"Link ID"},
	{id:"vd_ProjectKey", label:"Project"},
	{id:"vd_TaskKey", label:"Task"},
	{id:"vd_ClassKey", label:"Class"},
	{id:"vd_ItemKey", label:"Item"},
	{id:"vd_OfficeKey", label:"Office"},
	{id:"vd_DepartmentKey", label:"Department"},
	{id:"vd_ExpenseGLAccountKey", label:"Expense GL Account"},
	{id:"vd_ShortDescription", label:"Description"},
	{id:"vd_Quantity", label:"Quantity"},
	{id:"vd_UnitCost", label:"Unit Cost"},
	{id:"vd_TotalCost", label:"Net Cost"},
	{id:"vd_Markup", label:"Markup"},
	{id:"vd_Commission", label:"Media Comm %"},
	{id:"vd_Billable", label:"Billable"},
	{id:"vd_GrossAmount", label:"Gross"},
	{id:"vd_BillableCost", label:"Amount to Bill"},
	{id:"vd_POLineAdjustment", label:"Order Info"},
	{id:"vd_PrebilledInvoice", label:"Prebilled Invoice"},
	{id:"vd_AmountBilled", label:"Amount Billed"},
	{id:"vd_DateBilled", label:"Date Billed"},
	{id:"vd_Taxable", label:"Taxable"},
	{id:"vd_Taxable2", label:"Taxable2"},
	{id:"vd_BilledComment", label:"Billed Comment"},
	{id:"vd_TransferComment", label:"Transfer Comment"},
	{id:"vd_UnitRate", label:"Unit Rate"},
	{id:"vd_SalesTaxAmount", label:"Sales Tax Amount"},
	{id:"vd_SalesTax1Amount", label:"Sales Tax1 Amount"},
	{id:"vd_SalesTax2Amount", label:"Sales Tax2 Amount"},
	{id:"vd_OtherSalesTaxAmount", label:"Other Sales Tax Amount"},
	{id:"vd_TotalWithTax", label:"Total With Tax"},
	{id:"vd_Dates", label:"Dates"},
	{id:"vd_TargetGLCompanyKey", label: "Target Company"},
	{id:"vd_ClientName", label: "Client Name"},
	{id:"vd_AccruedAmount", label: "Accrued Amount"},	
	{id:"vd_StationName", label: "Station / Pub"}
 ]''
	 , NULL, NULL, null, NULL)



/*************************************************************************************************************************
Journal Entries
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''jeEdit'', ''Journal Entry Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''jeEdit'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''jeEdit'', ''grdJEDetail'', 1, ''Columns'', ''jed_account,jed_debit,jed_credit,jed_project,jed_targetglcompany,jed_client,jed_office,jed_department,jed_class,jed_memo,jed_currency'', NULL, ''grid'', 

''[	{id:"jed_account", label:"Account"},
	{id:"jed_debit", label:"Debit"},
	{id:"jed_credit", label:"Credit"},
	{id:"jed_project", label:"Project"},
	{id:"jed_targetglcompany", label:"Target GL Company"},
	{id:"jed_client", label:"Client"},
	{id:"jed_office", label:"Office"},
	{id:"jed_department", label:"Department"},
	{id:"jed_class", label:"Class"},
	{id:"jed_memo", label:"Memo"},
	{id:"jed_currency", label:"Currency"},
	{id:"jed_glcexchangerate", label:"GLC ExchangeRate"}
 ]''
	 , NULL, NULL, null, NULL)



/*************************************************************************************************************************
Unposted Transactions
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''postTransactions'', ''Unposted Transactions Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''postTransactions'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''postTransactions'', ''grdTransaction'', 1, ''Columns'', ''upt_amount,upt_amounthc,upt_PostingDate,upt_company,upt_office,upt_class,upt_glcompany,upt_project,upt_description'', NULL, ''grid'', 

''[	{id:"upt_amount", label:"Amount"},
	{id:"upt_amounthc", label:"Amount HC"},
	{id:"upt_PostingDate", label:"Posting Date"},
	{id:"upt_TransactionDate", label:"Date"},
	{id:"upt_project", label:"Project"},
	{id:"upt_glcompany", label:"GL Company"},
	{id:"upt_company", label:"Company ID"},
	{id:"upt_office", label:"Office"},
	{id:"upt_class", label:"Class"},
	{id:"upt_currency", label:"Currency"},
	{id:"upt_exchangerate", label:"Exch Rate"},
	{id:"upt_voucherid", label:"Voucher ID"},
	{id:"upt_description", label:"Description"},
	{id:"upt_createdby", label:"Entered By"},
	{id:"upt_unappliedamt", label:"Unapplied Amount"}
 ]''
	 , NULL, NULL, null, NULL)

	 

/*************************************************************************************************************************
Unapproved Transactions (Missing Transactions in Flex)
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''missingTransactions'', ''Unapproved Transactions Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''missingTransactions'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''missingTransactions'', ''grdTransaction'', 1, ''Columns'', ''miss_company,miss_project,miss_postingDate,miss_amount,miss_amounthc,miss_status,miss_currency,miss_exchangerate,miss_enteredBy'', NULL, ''grid'', 

''[	{id:"miss_amount", label:"Amount"},
	{id:"miss_amounthc", label:"Amount HC"},
	{id:"miss_postingDate", label:"Posting Date"},
	{id:"miss_company", label:"Company"},
	{id:"miss_currency", label:"Currency"},
	{id:"miss_exchangerate", label:"Exch Rate"},
	{id:"miss_status", label:"Status"},
	{id:"miss_voucherid", label:"Voucher ID"},
	{id:"miss_project", label:"Project"},
	{id:"miss_description", label:"Description"},
	{id:"miss_enteredBy", label:"Entered By"}
 ]''
	 , NULL, NULL, null, NULL)

/*************************************************************************************************************************
Post WIP
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''postWIP'', ''Post WIP Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''postWIP'', ''H1'', 0, ''WIP Detail Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''postWIP'', ''grdWIPDetail'', 1, ''Columns'', ''d_AccountFullName,d_Debit,d_Credit,d_ClientCompanyName,d_ClassFullName,d_ProjectFullName,d_OfficeName,d_DepartmentName'', NULL, ''grid'', 

''[	{id:"d_AccountFullName", label:"Account"},
	{id:"d_Debit", label:"Debit"},
	{id:"d_Credit", label:"Credit"},
	{id:"d_ClientCompanyName", label:"Client"},
	{id:"d_ClassFullName", label:"Class"},
	{id:"d_ProjectFullName", label:"Project"},
	{id:"d_OfficeName", label:"Office"},
	{id:"d_DepartmentName", label:"Department"}
 ]''
	 , NULL, NULL, null, NULL)


/*************************************************************************************************************************
Recurring Transactions
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''scheduledTransactions'', ''Scheduled Transactions Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''scheduledTransactions'', ''H1'', 0, ''Scheduled Transactions Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''scheduledTransactions'', ''grdTransactions'', 1, ''Columns'', ''schedTranRef,schedTranFreq,schedTranNext,schedTranAmount,schedTranNumber,schedTranDaysAdv,schedTranRemind,schedTranDesc,schedTranVendor,schedTranClient,schedCurApprover,schedTranActive,schedTranDaysRemaining,schedLastTranDate'', NULL, ''grid'', 

''[	{id:"schedTranRef", label:"Reference"},
	{id:"schedTranFreq", label:"Timing"},
	{id:"schedTranNext", label:"Next"},
	{id:"schedTranAmount", label:"Amount"},
	{id:"schedTranNumber", label:"# Generated"},
	{id:"schedTranDaysAdv", label:"Days In Advance"},
	{id:"schedTranRemind", label:"Reminder Option"},
	{id:"schedTranDesc", label:"Description"},
	{id:"schedTranVendor", label:"Vendor"},
	{id:"schedTranClient", label:"Client"},
	{id:"schedCurApprover", label:"Current Approver"},
	{id:"schedTranActive", label:"Active"},
	{id:"schedTranDaysRemaining", label:"# Remaining"},
	{id:"schedLastTranDate", label:"Last Transaction Date"}
 ]''
	 , NULL, NULL, null, NULL)


/*************************************************************************************************************************
Credit Card Charges
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''CCCEdit'', ''Credit Card Charge Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''CCCEdit'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''CCCEdit'', ''grdVoucherDetail'', 1, ''Columns'', ''vd_ProjectKey,vd_ItemKey,vd_Quantity,vd_UnitCost,vd_TotalCost,vd_Markup,vd_GrossAmount,vd_Exclude1099'', NULL, ''grid'', 

''[	{id:"vd_LinkID", label:"Link ID"},
	{id:"vd_ProjectKey", label:"Project"},
	{id:"vd_TaskKey", label:"Task"},
	{id:"vd_ClassKey", label:"Class"},
	{id:"vd_ItemKey", label:"Item"},
	{id:"vd_OfficeKey", label:"Office"},
	{id:"vd_DepartmentKey", label:"Department"},
	{id:"vd_ExpenseGLAccountKey", label:"Expense GL Account"},
	{id:"vd_ShortDescription", label:"Description"},
	{id:"vd_Quantity", label:"Quantity"},
	{id:"vd_UnitCost", label:"Unit Cost"},
	{id:"vd_TotalCost", label:"Net Cost"},
	{id:"vd_Markup", label:"Markup"},
	{id:"vd_Commission", label:"Media Comm %"},
	{id:"vd_Billable", label:"Billable"},
	{id:"vd_GrossAmount", label:"Gross"},
	{id:"vd_BillableCost", label:"Amount to Bill"},
	{id:"vd_POLineAdjustment", label:"Order Info"},
	{id:"vd_PrebilledInvoice", label:"PrebilledInvoice"},
	{id:"vd_AmountBilled", label:"Amount Billed"},
	{id:"vd_DateBilled", label:"Date Billed"},
	{id:"vd_Taxable", label:"Taxable"},
	{id:"vd_Taxable2", label:"Taxable2"},
	{id:"vd_BilledComment", label:"Billed Comment"},
	{id:"vd_TransferComment", label:"Transfer Comment"},
	{id:"vd_UnitRate", label:"Unit Rate"},
	{id:"vd_SalesTaxAmount", label:"Sales Tax Amount"},
	{id:"vd_SalesTax1Amount", label:"Sales Tax1 Amount"},
	{id:"vd_SalesTax2Amount", label:"Sales Tax2 Amount"},
	{id:"vd_OtherSalesTaxAmount", label:"Other Sales Tax Amount"},
	{id:"vd_Exclude1099", label:"Exclude From 1099"},
 ]''
	 , NULL, NULL, null, NULL)


/*************************************************************************************************************************
Production Dash
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''productionDash'', ''My Projects Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''H1'', 0, ''My Projects Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''OpenAssignments'', 1, ''Projects With Open Assignments Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''productionDash'', ''OnlyYourOpenAssignments'', 2, ''My Open Assignments Only'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''OnlyProjectsOnTeam'', 3, ''Only Projects I am On The Team'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''productionDash'', ''IncludePlanningProjects'', 4, ''Include Planning Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''IAmAM'', 5, ''Only Projects where I am the AM'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''IAmPM'', 6, ''Only Projects where I am the PM'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''IAmBM'', 7, ''Only Projects where I am the BM'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''ProjectStatus'', 8, ''Project Status'', ''-3'', ''All Active'', ''selectlist'', NULL, ''selectlist.ProjectStatus'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''ProjectBillingStatus'', 9, ''Billing Status'', ''-1'', ''All'', ''selectlist'', NULL, ''selectlist.ProjectBillingStatus'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''GLCompanyID'', 10, ''GL Company'', ''-1'', ''All'', ''lookup'', NULL, ''lookup.GLCompany'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''BudgetWarning'', 11, ''Budget Warning'', ''80'', NULL, ''number'', NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''H2'', 12, ''Display Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''GroupBy'', 13, ''Group By'', ''CustomerFullName'', ''Client'', ''lookup'', ''No Grouping:NoGrouping|Campaign:CampaignName|Campaign Segment:SegmentName|Client:CustomerFullName|Project Status:ProjectStatus|Project Type:ProjectTypeName|Account Manager:AccountManagerName|Project Manager:ProjectManagerName|Parent Client:ParentClientName|Product Name:Product Name|Office:OfficeName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''GroupByDir'', 14, ''Group Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''SortBy'', 15, ''Sort By'', ''ProjectNumber'', ''Project Number'', ''lookup'', ''No Sorting:NoSorting|Project Number:ProjectNumber|Project Status:ProjectStatus|My Open Assignments:OpenAssignments|Project Manager:ProjectManagerName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDash'', ''SortByDir'', 16, ''Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''productionDash'', ''grdProductionDashCols'', 16, ''Columns'', ''productionDashProjectFullName,productionDashFinancialStatusImage,productionDashProjectTaskStatus,productionDashProjectStatus,productionDashProjectPercComp,productionDashOpenAssignments,productionDashStatusNotesUpdated,productionDashClientNotesUpdated,productionDashDetailNotesUpdated'', NULL, ''grid'', 
''[{id:"productionDashProjectFullName", label:"Project Full Name"},
	{id:"productionDashProjectQuickEdit", label:"Quick Edit"},
	{id:"productionDashFolderImage", label:"Project Info"},
	{id:"productionDashFinancialStatusImage", label:"Financial Status"},
	{id:"productionDashProjectTaskStatus", label:"Project Task Status"},	
	{id:"productionDashProjectTaskStatusColor", label:"Project Task Status Color"},	
	{id:"productionDashProjectStatus", label:"Project Status"},
	{id:"productionDashProjectPercComp", label:"% Complete"}, 
	{id:"productionDashAmtAdvBill", label:"Amount Advance Billed"},
	{id:"productionDashAmtAdvBillOpen", label:"Amount Advance Billed Open"},
	{id:"productionDashOpenAssignments", label:"Open Assignments"},
	{id:"productionDashOpenToDo", label:"Open To Dos"},
	{id:"productionDashDeliverables", label:"Deliverables"},
	{id:"productionDashProjectName", label:"Project Name"},
	{id:"productionDashAccountManagerName", label:"Account Manager"},
	{id:"productionDashProjectManagerName", label:"Project Manager"},
	{id:"productionDashBillingManagerName", label:"Billing Manager"},
	{id:"productionDashCustomerFullName", label:"Client Name"},
	{id:"productionDashProjectTypeName", label:"Project Type Name"},
	{id:"productionDashProjectTypeColor", label:"Project Type Color"},
	{id:"productionDashCampaignName", label:"Campaign Name"},
	{id:"productionDashCampaignSegName", label:"Campaign Segment Name"},
	{id:"productionDashPrimaryContact", label:"Primary Contact"},
	{id:"productionDashPhone1", label:"Contact Phone"},
	{id:"productionDashEmail", label:"Contact Email"},
	{id:"productionDashCompanyName", label:"Company Name"},
	{id:"productionDashDivisionName", label:"Division Name"},
	{id:"productionDashPhone", label:"Company Phone"},
	{id:"productionDashTotalGross", label:"Total Gross"},
	{id:"productionDashOriginalBudgetHours", label:"Original Budget Hours"},
	{id:"productionDashOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
	{id:"productionDashOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
	{id:"productionDashOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
	{id:"productionDashCOBudgetHours", label:"CO Budget Hours"},
	{id:"productionDashCOBudgetLaborGross", label:"CO Budget Labor Gross"},
	{id:"productionDashCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
	{id:"productionDashCurrentBudgetHours", label:"Current Budget Hours"},
	{id:"productionDashCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
	{id:"productionDashCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
	{id:"productionDashTotalBudget", label:"Total Budget w/o Tax"},
	{id:"productionDashTotalBudgetwTaxes", label:"Total Budget with Tax"},
	{id:"productionDashBilledAmountNoTax", label:"Total Billed w/o Tax"},
	{id:"productionDashBilledAmount", label:"Total Billed with Tax"},
	{id:"productionDashProjectDescription", label:"Project Description"},
	{id:"productionDashProjectStartDate", label:"Project Start Date"},
	{id:"productionDashProjectDueDate", label:"Project Due Date"},
	{id:"productionDashCreatedDate", label:"Created Date"},
	{id:"productionDashGetLaborRateFrom", label:"Get Labor Rate From"},
	{id:"productionDashGetMarkupFrom", label:"Get Markup From"},
	{id:"productionDashNonBillableProject", label:"Non Billable Project"},
	{id:"productionDashClosedProject", label:"Closed Project"},
	{id:"productionDashProjectNumber", label:"Project Number"},
	{id:"productionDashProjectBillingStatus", label:"Project Billing Status"},
	{id:"productionDashActualHours", label:"Actual Hours"},
	{id:"productionDashBilledHours", label:"Hours Billed"},
	{id:"productionDashProductName", label:"Product Name"},
	{id:"productionDashClientProjectNumber", label:"Client Project Number"},
	{id:"productionHasEstimate", label:"Has Estimate(s)"},
	{id:"productionFlightStartDate", label:"Flight Start Date"},
	{id:"productionFlightEndDate", label:"Flight End Date"},
	{id:"productionProjectColor", label:"Project Color"},
	{id:"productionStatusNotes", label:"Status Notes"},
	{id:"productionClientNotes", label:"Client Notes"},
	{id:"productionDashStatusNotesUpdated", label:"Status Notes Updated On"},
	{id:"productionDashClientNotesUpdated", label:"Client Notes Updated On"},
	{id:"productionDashDetailNotesUpdated", label:"Next Steps Updated On"},
	{id:"productionDashTotalLaborGross", label:"Total Labor Gross"},
	{id:"productionDashTotalCostsGross", label:"Total Costs Gross"},
	{id:"productionDashProjectToBillRemaining", label:"Project To Bill Remaining"},
	{id:"productionDashProjectRemainingHours", label:"Project Remaining Hours"},
	{id:"productionDashProjectRemainingBudget", label:"Project Remaining Budget"},
	{id:"productionDashRemainingLaborBudget", label:"Remaining Labor Budget"},
	{id:"productionDashRemainingExpenseBudget", label:"Remaining Expense Budget"},
	{id:"productionDashProjectCurrency", label:"Currency"},
	{id:"productionDashLastTaskDueDate", label:"Last Task Due Date"},
	{id:"productionNextSteps", label:"Next Steps"},
	{id:"productionDashGLCompanySource", label:"Revenue Source"},
	{id:"productionDashLastTimeEntry", label:"Date of Last Time Entry"},
	{id:"productionDashEstimateProfit", label:"Estimate Profit"},
	{id:"productionDashAllocatedHours", label:"Allocated Hours"},
	{id:"productionDashKeyPeople1", label:"Key Person 1"},
	{id:"productionDashKeyPeople2", label:"Key Person 2"},
	{id:"productionDashKeyPeople3", label:"Key Person 3"},
	{id:"productionDashKeyPeople4", label:"Key Person 4"},
	{id:"productionDashKeyPeople5", label:"Key Person 5"},
	{id:"productionDashKeyPeople6", label:"Key Person 6"},

	{id:"productionDashProjectScheduleAdherance", label:"Schedule Adherance"},
	{id:"productionDashProjectEffortVariance", label:"Effort Variance"},
	{id:"productionDashProjectProjectPerformance", label:"Project Performance"},
	{id:"productionDashTotalUnbilled", label:"Total Gross Unbilled"},
    {id:"productionDashBillingMethod", label:"Billing Method"},	
	{id:"productionDashGLCompany", label:"GL Company Name"},
	{id:"productionDashPlanningProjectName", label:"Planning Project Name"},
	{id:"productionDashAllocatedRemaining", label:"Allocated Remaining"},
	{id:"productionDashOpenOrdersGross", label:"Open Orders Gross"},
	{id:"productionDashRetainerName", label:"Retainer Name"},
	{id:"productionDashHoursAfterWriteoff", label:"Hours After Writeoff"},
	{id:"productionDashOfficeName", label:"Office Name"}]''
	 , NULL, NULL, ''Project'', ''Project'')

/*************************************************************************************************************************
Production Dash (Planning Project)
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''productionDashPlanning'', ''My Planning Projects Settings'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''H1'', 0, ''My Planning Projects Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''OpenAssignments'', 1, ''Projects With Open Assignments Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''productionDashPlanning'', ''OnlyYourOpenAssignments'', 2, ''My Open Assignments Only'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''OnlyProjectsOnTeam'', 3, ''Only Projects I am On The Team'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''IAmAM'', 5, ''Only Projects where I am the AM'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''IAmPM'', 6, ''Only Projects where I am the PM'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''ProjectStatus'', 7, ''Project Status'', ''-1'', ''All Active'', ''lookup'', NULL, ''lookup.ProjectStatus'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''ProjectBillingStatus'', 8, ''Billing Status'', ''-1'', ''All'', ''lookup'', NULL, ''lookup.ProjectBillingStatus'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''GLCompanyID'', 9, ''GL Company'', ''-1'', ''All'', ''lookup'', NULL, ''lookup.GLCompany'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''BudgetWarning'', 10, ''Budget Warning'', ''80'', NULL, ''number'', NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''H2'', 11, ''Display Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''GroupBy'', 12, ''Group By'', ''CustomerFullName'', ''Client'', ''lookup'', ''No Grouping:NoGrouping|Campaign:CampaignName|Campaign Segment:SegmentName|Client:CustomerFullName|Project Status:ProjectStatus|Project Type:ProjectTypeName|Account Manager:AccountManagerName|Project Manager:ProjectManagerName|Parent Client:ParentClientName|Product Name:Product Name|Office:OfficeName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''GroupByDir'', 13, ''Group Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''SortBy'', 14, ''Sort By'', ''ProjectNumber'', ''Project Number'', ''lookup'', ''No Sorting:NoSorting|Project Number:ProjectNumber|Project Status:ProjectStatus|My Open Assignments:OpenAssignments|Project Manager:ProjectManagerName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionDashPlanning'', ''SortByDir'', 15, ''Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''productionDashPlanning'', ''grdProductionDashCols'', 16, ''Columns''
, ''productionDashProjectFullName,productionDashFinancialStatusImage,productionDashProjectStatus,productionDashProjectDueDate,productionDashOpenAssignments'', NULL, ''grid'', 
''[{id:"productionDashProjectFullName", label:"Project Full Name"},
	{id:"productionDashProjectQuickEdit", label:"Quick Edit"},
	{id:"productionDashFolderImage", label:"Project Info"},
	{id:"productionDashFinancialStatusImage", label:"Financial Status"},
	{id:"productionDashProjectTaskStatus", label:"Project Task Status"},	
	{id:"productionDashProjectTaskStatusColor", label:"Project Task Status Color"},	
	{id:"productionDashProjectStatus", label:"Project Status"},
	{id:"productionDashAmtAdvBill", label:"Amount Advance Billed"},
	{id:"productionDashAmtAdvBillOpen", label:"Amount Advance Billed Open"},
	{id:"productionDashOpenAssignments", label:"Open Assignments"},
	{id:"productionDashOpenToDo", label:"Open To Dos"},
	{id:"productionDashDeliverables", label:"Deliverables"},
	{id:"productionDashProjectName", label:"Project Name"},
	{id:"productionDashAccountManagerName", label:"Account Manager"},
	{id:"productionDashProjectManagerName", label:"Project Manager"},
	{id:"productionDashBillingManagerName", label:"Billing Manager"},
	{id:"productionDashCustomerFullName", label:"Client Name"},
	{id:"productionDashProjectTypeName", label:"Project Type Name"},
	{id:"productionDashProjectTypeColor", label:"Project Type Color"},
	{id:"productionDashPrimaryContact", label:"Primary Contact"},
	{id:"productionDashPhone1", label:"Contact Phone"},
	{id:"productionDashEmail", label:"Contact Email"},
	{id:"productionDashCompanyName", label:"Company Name"},
	{id:"productionDashDivisionName", label:"Division Name"},
	{id:"productionDashPhone", label:"Company Phone"},
	{id:"productionDashTotalGross", label:"Total Gross"},
	{id:"productionDashOriginalBudgetHours", label:"Original Budget Hours"},
	{id:"productionDashOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
	{id:"productionDashOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
	{id:"productionDashOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
	{id:"productionDashCOBudgetHours", label:"CO Budget Hours"},
	{id:"productionDashCOBudgetLaborGross", label:"CO Budget Labor Gross"},
	{id:"productionDashCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
	{id:"productionDashCurrentBudgetHours", label:"Current Budget Hours"},
	{id:"productionDashCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
	{id:"productionDashCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
	{id:"productionDashTotalBudget", label:"Total Budget w/o Tax"},
	{id:"productionDashTotalBudgetwTaxes", label:"Total Budget with Tax"},
	{id:"productionDashBilledAmountNoTax", label:"Total Billed w/o Tax"},
	{id:"productionDashBilledAmount", label:"Total Billed with Tax"},
	{id:"productionDashProjectDescription", label:"Project Description"},
	{id:"productionDashProjectStartDate", label:"Project Start Date"},
	{id:"productionDashProjectDueDate", label:"Project Due Date"},
	{id:"productionDashCreatedDate", label:"Created Date"},
	{id:"productionDashGetLaborRateFrom", label:"Get Labor Rate From"},
	{id:"productionDashGetMarkupFrom", label:"Get Markup From"},
	{id:"productionDashNonBillableProject", label:"Non Billable Project"},
	{id:"productionDashClosedProject", label:"Closed Project"},
	{id:"productionDashProjectNumber", label:"Project Number"},
	{id:"productionDashProjectBillingStatus", label:"Project Billing Status"},
	{id:"productionDashActualHours", label:"Actual Hours"},
	{id:"productionDashProductName", label:"Product Name"},
	{id:"productionDashClientProjectNumber", label:"Client Project Number"},
	{id:"productionHasEstimate", label:"Has Estimate(s)"},
	{id:"productionProjectColor", label:"Project Color"},
	{id:"productionStatusNotes", label:"Status Notes"},
	{id:"productionClientNotes", label:"Client Notes"},
	{id:"productionDashTotalLaborGross", label:"Total Labor Gross"},
	{id:"productionDashTotalCostsGross", label:"Total Costs Gross"},
	{id:"productionDashProjectToBillRemaining", label:"Project To Bill Remaining"},
	{id:"productionDashProjectRemainingHours", label:"Project Remaining Hours"},
	{id:"productionDashProjectRemainingBudget", label:"Project Remaining Budget"},
	{id:"productionDashProjectCurrency", label:"Currency"},
	{id:"productionDashLastTaskDueDate", label:"Last Task Due Date"},
	{id:"productionNextSteps", label:"Next Steps"},
	{id:"productionDashGLCompanySource", label:"Revenue Source"},
	{id:"productionDashLastTimeEntry", label:"Date of Last Time Entry"},
	{id:"productionDashEstimateProfit", label:"Estimate Profit"},
	{id:"productionDashAllocatedHours", label:"Allocated Hours"},
	{id:"productionDashPlanningProjectFull", label:"Planning Project Full Name"},
	{id:"productionDashPlanningProjectName", label:"Planning Project Name"},
	{id:"productionDashplanningPrpojectNumber", label:"Plannning Project Number"},
	{id:"productionDashKeyPeople1", label:"Key Person 1"},
	{id:"productionDashKeyPeople2", label:"Key Person 2"},
	{id:"productionDashKeyPeople3", label:"Key Person 3"},
	{id:"productionDashKeyPeople4", label:"Key Person 4"},
	{id:"productionDashKeyPeople5", label:"Key Person 5"},
	{id:"productionDashKeyPeople6", label:"Key Person 6"},	
	{id:"productionDashTotalUnbilled", label:"Total Gross Unbilled"},
	{id:"productionDashBillingMethod", label:"Billing Method"},
	{id:"productionDashPlanningBillingOption", label:"Planning Project Billing Option"}]''
	 , NULL, NULL, ''Project'', ''Project'')

/*************************************************************************************************************************
Production Assignment
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''productionAssignment'', ''Assignment To Do Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''showNotes'', 1, ''Show notes under the subject'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''EditInGrid'', 2, ''Edit To Dos directly in grid'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''productionAssignment'', ''groupBy'', 3, ''Group To Dos By'', ''StatusName'', ''Status Name'', ''lookup'', ''Status Name:StatusName|Assigned:UserFullName|Type:TypeName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''productionAssignment'', ''grdToDosCols'', 4, ''Columns'', ''toDoSubject,toDoCompleted,todoType,todoStatus,todoDueDate'', NULL, ''grid'', 

''[	{id:"toDoSubject", label:"Subject"},
	{id:"toDoCompleted", label:"Completed"},
	{id:"todoType", label:"Type"},
	{id:"todoStatus", label:"Status"},
	{id:"todoUserFullName", label:"Assigned To"},
	{id:"todoDueDate", label:"Due Date"}
 ]''
	 , NULL, NULL, ''Activity'', ''Activity'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''DashboardSettings'', 5, ''Assignment Sections'', NULL, NULL, ''sectionheader'', NULL, NULL, ''Enabling the checkbox will show the item in the project details jump menu. These settings only apply to the assignment page.'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentProjectOverview'', 6, ''Project Overview'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentProjectSetup'', 7, ''Project Setup'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentSchedule'', 8, ''Schedule'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentTeam'', 9, ''Team'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentDailyFeed'', 10, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentSpecsheets'', 11, ''Specs'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentMiscCost'', 12, ''Misc Cost'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentDeliverables'', 13, ''Deliverables'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionAssignment'', ''AssignmentFiles'', 14, ''Files'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)



/*************************************************************************************************************************
Account Manager Today 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''salesToday'', ''System Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''hideSchedule'', 1, ''Hide the schedule on the side'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''HideEnterTime'', 2, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''DisplayTimeEntriesComments'', 3, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''IncludePublicMeetings'', 4, ''Include Public Meetings'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''H3'', 5, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''salesToday'', ''SortConversations'', 6, ''Sort Conversations'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''H2'', 7, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesToday'', ''ShowInOutBoard'', 8, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Manager Today 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminToday'', ''System Settings'', '''', 1)

--INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
--Values (''adminToday'', ''H1'', 0, ''Open Items'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''H3'', 17, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''adminToday'', ''DailyFeed'', 18, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''adminToday'', ''FeedProjectOptions'', 19, ''Project Options'', ''0'', ''All Projects'', ''lookup'', ''All Projects:0|All Project I Am Assigned To:1|Projects Where I Am The Account Manager:2|Only Projects In My Office:3'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''adminToday'', ''ShowTimeEntries'', 20, ''Show Time Entries'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''H4'', 21, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''adminToday'', ''SortConversations'', 22, ''Sort Conversations'', ''DESC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''FilterProjectTab'', 23, ''Only show Project Conversations sent to me'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''H5'', 24, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''ShowInOutBoard'', 25, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''H6'', 26, ''Timeline Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''hideSchedule'', 27, ''Hide the schedule on the side'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''HideEnterTime'', 28, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''DisplayTimeEntries'', 29, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''adminToday'', ''DisplayTimeEntriesComments'', 30, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''DisplayTimeEntries'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminToday'', ''IncludePublicMeetings'', 31, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
Project Manager Today 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''pmToday'', ''System Settings'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''H1'', 0, ''Open Items'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''IncludeOthers'', 1, ''Include/Show Others'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Open items list will include other account managers and be grouped by account manager'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''UnapprovedPurchaseOrders'', 1, ''Unapproved Purchase Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''OpenOrders'', 2, ''Open Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''EstimatesWaitingOnInternalApproval'', 3, ''Estimates waiting on internal approval'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''EstimatesWaitingOnClientApproval'', 4, ''Estimates waiting on client approval'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''OpenRequestsForQuote'', 5, ''Open Requests for Quote'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''UnapprovedVendorInvoices'', 6, ''Unapproved Vendor Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''UnapprovedRequests'', 7, ''Unapproved Project Requests'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''UnapprovedRequestsOthers'', 8, ''Unapproved Project Requests for Others'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''RequestsNoProject'', 9, ''Approved Project Requests with no Project'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
if @LoadBeta = 1
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''UnapprovedChangeRequests'', 10, ''Unapproved Change Requests'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''H2'', 11, ''Items Needing Attention'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''ProjectsGoingOverBudget'', 12, ''Projects with budget warnings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''TasksDueButNotDone'', 13, ''Assignments due but not done'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''ProjectsWithScheduleWarnings'', 14, ''Project with schedule warnings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''ActiveTasks'', 15, ''My Tasks'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''OpenActivities'', 16, ''Open Activities'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''DailyDeliverableStatus'', 17, ''Daily Deliverable Status'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''OverdueBillingWorksheets'', 18, ''Overdue Billing Worksheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''OverworkedAssignments'', 19, ''Overworked Assignments'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''H3'', 20, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''DailyFeed'', 21, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''FeedProjectOptions'', 22, ''Project Options'', ''0'', ''All Projects'', ''lookup'', ''All Projects:0|All Project I Am Assigned To:1|Projects Where I Am The Account Manager Or Project Manager:2|Only Projects In My Office:3'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''pmToday'', ''ShowTimeEntries'', 23, ''Show Time Entries'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''H6'', 24, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''pmToday'', ''SortConversations'', 25, ''Sort Conversations'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''FilterProjectTab'', 26, ''Only show Project Conversations sent to me'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''H4'', 27, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''ShowInOutBoard'', 28, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''H5'', 29, ''Timeline Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''hideSchedule'', 30, ''Hide the schedule on the side'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''HideEnterTime'', 31, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''DisplayTimeEntries'', 32, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''pmToday'', ''DisplayTimeEntriesComments'', 33, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''DisplayTimeEntries'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''pmToday'', ''IncludePublicMeetings'', 34, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)


INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''pmToday_18'', ''Project Manager Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''pmToday_18'', ''grdOpenItemsList_18'', 1, ''Columns'', ''colRequestID,colCompanyName,colSubject,colRequestedBy,colDateAdded,colDueDate,colDateSentForApproval,colProjectDescription'', NULL, ''grid'', 
''[	{id:"colRequestID", label:"Request ID"},
		{id:"colCompanyName", label:"Client"},
		{id:"colSubject", label:"Subject"},
		{id:"colRequestedBy", label:"Requested By"},
		{id:"colDateAdded", label:"Date Added"},
		{id:"colDueDate", label:"Project Due Date"},
		{id:"colDateSentForApproval", label:"Date Sent For Approval"},
		{id:"colProjectDescription", label:"Project Description"}
 ]''
 , NULL, NULL, NULL, NULL)

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''pmToday_20'', ''Project Manager Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''pmToday_20'', ''grdOpenItemsList_20'', 1, ''Columns'', ''colRequestID,colCompanyName,colSubject,colRequestedBy,colDateAdded,colDueDate,colDateSentForApproval,colProjectDescription'', NULL, ''grid'', 
''[	{id:"colRequestID", label:"Request ID"},
		{id:"colCompanyName", label:"Client"},
		{id:"colSubject", label:"Subject"},
		{id:"colRequestedBy", label:"Requested By"},
		{id:"colDateAdded", label:"Date Added"},
		{id:"colDueDate", label:"Project Due Date"},
		{id:"colDateSentForApproval", label:"Date Sent For Approval"},
		{id:"colProjectDescription", label:"Project Description"}
 ]''
 , NULL, NULL, NULL, NULL)

 if @LoadBeta = 1
 BEGIN
	INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''pmToday_21'', ''Project Manager Settings'', '''', 0)
	INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
	Values (''pmToday_21'', ''grdOpenItemsList_21'', 1, ''Columns'', ''colVersionNumber,colCompanyName,colSubject,colRequestedBy,colDateAdded,colProjectDescription'', NULL, ''grid'', 
	''[	{id:"colVersionNumber", label:"Version"},
			{id:"colCompanyName", label:"Client"},
			{id:"colSubject", label:"Subject"},
			{id:"colRequestedBy", label:"Requested By"},
			{id:"colDateAdded", label:"Date Added"},
			{id:"colProjectDescription", label:"Description"}
	 ]''
	 , NULL, NULL, NULL, NULL)

 END
 
 
/*************************************************************************************************************************
Accounting Today 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''glToday'', ''System Settings'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''H1'', 1, ''Items Needing Attention'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''UnpostedTransactions'', 2, ''Unposted Transactions'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''UnapprovedTransactions'', 3, ''Unapproved Transactions'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''AROutOfBalance'', 4, ''AR Out of Balance'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''APOutOfBalance'', 5, ''AP Out of Balance'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''ScheduledTransactions'', 6, ''Scheduled Transactions'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''PostWorkInProgress'', 7, ''Post Work In Progress'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''OpenBankRecs'', 8, ''Open Bank Recs'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''H2'', 9, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''DailyFeed'', 10, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''FeedProjectOptions'', 11, ''Project Options'', ''0'', ''All Projects'', ''lookup'', ''All Projects:0|All Project I Am Assigned To:1|Projects Where I Am The Account Manager:2|Only Projects In My Office:3'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''glToday'', ''ShowTimeEntries'', 12, ''Show Time Entries'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''H3'', 13, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''glToday'', ''SortConversations'', 14, ''Sort Conversations'', ''DESC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''FilterProjectTab'', 15, ''Only show Project Conversations sent to me'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''H4'', 16, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''ShowInOutBoard'', 17, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''H5'', 18, ''Timeline Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''hideSchedule'', 19, ''Hide the schedule on the side'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''HideEnterTime'', 20, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''DisplayTimeEntries'', 21, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''glToday'', ''DisplayTimeEntriesComments'', 22, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''DisplayTimeEntries'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''IncludePublicMeetings'', 23, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''H6'', 24, ''Account Balances'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''Bank'', 25, ''Bank Accounts'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''AR'', 26, ''AR Accounts'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''CurrentAsset'', 27, ''Current Asset Accounts'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''FixedAsset'', 28, ''Fixed Asset Accounts'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''OtherAsset'', 29, ''Other Asset Accounts'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''AP'', 30, ''AP Accounts'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''CurrentLiability'', 31, ''Current Liability'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''LongTermLiability'', 32, ''Long Term Liability'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''CreditCard'', 33, ''Credit Cards'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''EquityNoClose'', 34, ''Equity - Does not Close'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glToday'', ''EquityClose'', 35, ''Equity - Closes'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Media Today 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''mediaToday'', ''System Settings'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
VALUES (''mediaToday'', ''H1'', 0, ''Open Items'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''UnapprovedBroadcastOrders'', 1, ''Unapproved Broadcast Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''OpenBroadcastOrders'', 2, ''Open Broadcast Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''BOUnapprovedVouchers'', 3, ''Unapproved Broadcast Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''UnapprovedInsertionOrders'', 4, ''Unapproved Insertion Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''OpenInsertionOrders'', 5, ''Open Insertion Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''IOUnapprovedVouchers'', 6, ''Unapproved Insertion Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
VALUES (''mediaToday'', ''H2'', 7, ''Orders Needing Attention'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''ActiveTasks'', 8, ''My Tasks'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''BOSpaceClose'', 8, ''Broadcast Orders Space Close'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''BOMaterialsDue'', 9, ''Broadcast Orders Materials Due'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''IOSpaceClose'', 10, ''Insertion Orders Space Close'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''IOMaterialsDue'', 11, ''Insertion Orders Materials Due'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''DaysFromToday'', 12, ''Days Out from Today'', ''14'', NULL, ''number:n0'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''H3'', 17, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''DailyFeed'', 18, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''FeedProjectOptions'', 19, ''Project Options'', ''0'', ''All Projects'', ''lookup'', ''All Projects:0|All Project I Am Assigned To:1|Projects Where I Am The Account Manager:2|Only Projects In My Office:3'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''mediaToday'', ''ShowTimeEntries'', 20, ''Show Time Entries'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''H4'', 21, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''mediaToday'', ''SortConversations'', 22, ''Sort Conversations'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''H5'', 23, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''ShowInOutBoard'', 24, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''H6'', 25, ''Timeline Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''HideEnterTime'', 26, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''DisplayTimeEntries'', 27, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''mediaToday'', ''DisplayTimeEntriesComments'', 28, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''DisplayTimeEntries'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaToday'', ''IncludePublicMeetings'', 29, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)


INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) VALUES(''boTraffic'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
VALUES (''boTraffic'', ''grdMediaTrafficCols'', 1, ''Columns'', ''colVendorID,colVendorName,colStationName,colStatus,colDetailOrderDate,colDetailOrderEndDate,colDescription,colSpecialInstructions,colDeliveryInstructions,colLineNo,colSpaceClose,colMaterialsDue,colShortDescription,colLongDescription'', NULL, ''grid'', 
''[
	{id:"colVendorID", label:"Vendor ID"},
	{id:"colVendorName", label:"Vendor Name"},
	{id:"colStationName", label:"Station"},
	{id:"colStatus", label:"Status"},
	{id:"colDetailOrderDate", label:"Start Date"},
	{id:"colDetailOrderEndDate", label:"End Date"},
	{id:"colDescription", label:"Description"},
	{id:"colSpecialInstructions", label:"Special Instructions"},
	{id:"colDeliveryInstructions", label:"Traffic Instructions"},
	{id:"colLineNo", label:"Line #"},
	{id:"colSpaceClose", label:"Space Close"},
	{id:"colMaterialsDue", label:"Materials Due"},
	{id:"colShortDescription", label:"Program"},
	{id:"colLongDescription", label:"Comments"},
	{id:"colCustomerID", label:"Client ID"},
	{id:"colCompanyName", label:"Client Name"},
	{id:"colCampaignID", label:"Campaign ID"},
	{id:"colCampaignName", label:"Campaign Name"},
	{id:"colMaterialsSent", label:"Materials Sent"},
	{id:"colMaterialsSentDate", label:"Materials Sent Date"}
 ]''
 , NULL, NULL, ''PO_Detail'', ''PO_Detail'')

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) VALUES(''ioTraffic'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
VALUES (''ioTraffic'', ''grdMediaTrafficCols'', 1, ''Columns'', ''colVendorID,colVendorName,colStationName,colStatus,colDetailOrderDate,colDescription,colSpecialInstructions,colDeliveryInstructions,colLineNo,colSpaceClose,colMaterialsDue,colShortDescription,colLongDescription'', NULL, ''grid'', 
''[
	{id:"colVendorID", label:"Vendor ID"},
	{id:"colVendorName", label:"Vendor Name"},
	{id:"colStationName", label:"Publication"},
	{id:"colStatus", label:"Status"},
	{id:"colDetailOrderDate", label:"Insertion Date"},
	{id:"colDescription", label:"Description"},
	{id:"colSpecialInstructions", label:"Special Instructions"},
	{id:"colDeliveryInstructions", label:"Traffic Instructions"},
	{id:"colLineNo", label:"Line #"},
	{id:"colSpaceClose", label:"Space Close"},
	{id:"colMaterialsDue", label:"Materials Due"},
	{id:"colShortDescription", label:"Ad Number/Caption"},
	{id:"colLongDescription", label:"Comments"},
	{id:"colCustomerID", label:"Client ID"},
	{id:"colCompanyName", label:"Client Name"},
	{id:"colCampaignID", label:"Campaign ID"},
	{id:"colCampaignName", label:"Campaign Name"},
	{id:"colMaterialsSent", label:"Materials Sent"},
	{id:"colMaterialsSentDate", label:"Materials Sent Date"}
 ]''
 , NULL, NULL, ''PO_Detail'', ''PO_Detail'')

/*************************************************************************************************************************
Billing Dashboard 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingDashboard'', ''Dashboard Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingDashboard'', ''H2'', 1, ''Aging Periods'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, Required)
VALUES (''billingDashboard'', ''Period1'', 2, ''Period 1'', ''30'', NULL, ''number:n0'', NULL, NULL, NULL, 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, Required)
VALUES (''billingDashboard'', ''Period2'', 3, ''Period 2'', ''60'', NULL, ''number:n0'', NULL, NULL, NULL, 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, Required)
VALUES (''billingDashboard'', ''Period3'', 4, ''Period 3'', ''90'', NULL, ''number:n0'', NULL, NULL, NULL, 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingDashboard'', ''LimitToAM'', 5, ''Limit results to the account manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingDashboard'', ''SummarizeResults'', 6, ''Summarize excessive chart widget results'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)


--exec spConvertAppSeed  


/*************************************************************************************************************************
Billing Today 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingToday'', ''System Settings'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''H1'', 0, ''Billing Worksheets'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''BillingWorksheetsInReview'', 1, ''Billing Worksheets in Review'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''BillingWorksheetsToApprove'', 2, ''Billing Worksheets to Approve'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''ReadyToCreateInvoices'', 3, ''Ready to Create Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''H2'', 4, ''To Bill As Of'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''TimeAndMaterial'', 5, ''Time And Material'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''billingToday'', ''TMProjectStatus'', 6, ''Project Status'', ''-3'', ''All'', ''selectlist'', NULL, ''selectlist.ProjectStatus'', ''This is for Time and Material billing only'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''TMProjectBillingStatus'', 7, ''Billing Status'', ''-1'', ''All'', ''selectlist'', NULL, ''selectlist.ProjectBillingStatus'', ''This is for Time and Material billing only'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''FixedFee'', 8, ''Fixed Fee'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''Retainer'', 9, ''Retainer'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''Media'', 10, ''Media'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''FixedFeeCampaign'', 11, ''Fixed Fee Campaigns'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''H3'', 12, ''Invoices'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''WaitingToSend'', 13, ''Waiting to be Submitted'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''WaitingForApproval'', 14, ''Waiting for Approval'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField)
VALUES (''billingToday'', ''IncludeAllApprovers'', 15, ''Include all Approvers'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Include invoices waiting for approval for all approvers'', ''WaitingForApproval'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''InvoicesToPrintOrEmail'', 16, ''Invoices to Print or Email'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''ScheduledInvoices'', 17, ''Scheduled Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''ScheduledTransactions'', 18, ''Scheduled Transactions'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''PayByCC'', 19, ''Pay by Credit Card'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''billingToday'', ''H5'', 20, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''DailyFeed'', 21, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingToday'', ''FeedProjectOptions'', 22, ''Project Options'', ''0'', ''All Projects'', ''lookup'', ''All Projects:0|All Project I Am Assigned To:1|Projects Where I Am The Account Manager:2|Only Projects In My Office:3'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''H8'', 23, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''billingToday'', ''SortConversations'', 24, ''Sort Conversations'', ''DESC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''FilterProjectTab'', 25, ''Only show Project Conversations sent to me'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''H6'', 26, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''ShowInOutBoard'', 26, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''H7'', 28, ''Timeline Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''hideSchedule'', 29, ''Hide the schedule on the side'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''HideEnterTime'', 30, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingToday'', ''DisplayTimeEntries'', 31, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''billingToday'', ''DisplayTimeEntriesComments'', 32, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''DisplayTimeEntries'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''billingToday'', ''IncludePublicMeetings'', 33, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingToday_18'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''billingToday_18'', ''grdOpenItemsList_18'', 1, ''Columns'', ''colBillingMethodName,colMasterWS,colProjectName,colProjectNumber,colDueDate,colFFTotal,colLaborTotal,colExpenseTotal,colOriginalToBill,colToBill,colWOTotal,colTransferTotal,colHoldTotal,colDoNotBillTotal,colPriorBilled,colCampaignName,colBudgetAmount'', NULL, ''grid'', 
''[	{id:"colBillingMethodName", label:"Billing Method"},
		{id:"colProjectName", label:"Project Name"},
		{id:"colBillingID", label:"ID"},
		{id:"colMasterWS", label:"Master"},
		{id:"colProjectNumber", label:"Project Number"},
		{id:"colDueDate", label:"Due Date"},
		{id:"colFFTotal", label:"Fixed Fee Total"},
		{id:"colLaborTotal", label:"Labor Total"},
		{id:"colExpenseTotal", label:"Expense Total"},
		{id:"colOriginalToBill", label:"Original To Bill"},
		{id:"colToBill", label:"To Bill"},
		{id:"colWOTotal", label:"To Write Off"},
		{id:"colTransferTotal", label:"Transfer"},
		{id:"colHoldTotal", label:"Hold"},
		{id:"colDoNotBillTotal", label:"Do Not Bill"},
		{id:"colPriorBilled", label:"Prior Billed"},
		{id:"colCurrencyID", label:"Currency"},
		{id:"colRetainerAmount", label:"Retainer Amount"},
		{id:"colWorkSheetComment", label:"Worksheet Comments"},
		{id:"colApprovalComments", label:"Approval Comments"},
		{id:"colCampaignName", label:"Campaign Name"},
		{id:"colBudgetAmount", label:"Budget"},
		{id:"colAddable", label:"Addable Transactions"},
	    {id:"colMarkedAsBilledExpenses", label:"Marked as Billed Expenses"},
	    {id:"colMarkedAsBilledLabor", label:"Marked as Billed Labor"},
		{id:"colProjectManager", label:"Project Manager"}
 ]''
 , NULL, NULL, NULL, NULL)

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingToday_7'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''billingToday_7'', ''grdOpenItemsList_7'', 1, ''Columns'', ''colMasterWS,colBillingMethodName,colProjectName,colProjectNumber,colDueDate,colFFTotal,colLaborTotal,colExpenseTotal,colOriginalToBill,colToBill,colWOTotal,colTransferTotal,colHoldTotal,colDoNotBillTotal,colPriorBilled'', NULL, ''grid'', 
''[	{id:"colBillingMethodName", label:"Billing Method"},
		{id:"colProjectName", label:"Project Name"},
		{id:"colProjectNumber", label:"Project Number"},
		{id:"colBillingID", label:"ID"},
		{id:"colMasterWS", label:"Master"},
		{id:"colDueDate", label:"Due Date"},
		{id:"colFFTotal", label:"Fixed Fee Total"},
		{id:"colLaborTotal", label:"Labor Total"},
		{id:"colExpenseTotal", label:"Expense Total"},
		{id:"colOriginalToBill", label:"Original To Bill"},
		{id:"colToBill", label:"To Bill"},
		{id:"colWOTotal", label:"To Write Off"},
		{id:"colTransferTotal", label:"Transfer"},
		{id:"colHoldTotal", label:"Hold"},
		{id:"colDoNotBillTotal", label:"Do Not Bill"},
		{id:"colPriorBilled", label:"Prior Billed"},
		{id:"colCurrencyID", label:"Currency"},
		{id:"colRetainerAmount", label:"Retainer Amount"},
		{id:"colWorkSheetComment", label:"Worksheet Comments"},
		{id:"colApprovalComments", label:"Approval Comments"},
		{id:"colCampaignName", label:"Campaign Name"},
		{id:"colBudgetAmount", label:"Budget"},
		{id:"colProjectManager", label:"Project Manager"}
 ]''
 , NULL, NULL, NULL, NULL)

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingToday_19'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''billingToday_19'', ''grdOpenItemsList_19'', 1, ''Columns'', ''colBillingMethodName,colProjectName,colProjectNumber,colDueDate,colFFTotal,colLaborTotal,colExpenseTotal,colOriginalToBill,colToBill,colWOTotal,colTransferTotal,colHoldTotal,colDoNotBillTotal,colPriorBilled,colErrorMsg,colRetainerAmount'', NULL, ''grid'', 
''[	{id:"colBillingMethodName", label:"Billing Method"},
		{id:"colProjectName", label:"Project Name"},
		{id:"colProjectNumber", label:"Project Number"},
		{id:"colBillingID", label:"ID"},		
		{id:"colDueDate", label:"Due Date"},
		{id:"colFFTotal", label:"Fixed Fee Total"},
		{id:"colLaborTotal", label:"Labor Total"},
		{id:"colExpenseTotal", label:"Expense Total"},
		{id:"colOriginalToBill", label:"Original To Bill"},
		{id:"colToBill", label:"To Bill"},
		{id:"colWOTotal", label:"To Write Off"},
		{id:"colTransferTotal", label:"Transfer"},
		{id:"colHoldTotal", label:"Hold"},
		{id:"colDoNotBillTotal", label:"Do Not Bill"},
		{id:"colPriorBilled", label:"Prior Billed"},
		{id:"colCurrencyID", label:"Currency"},
		{id:"colErrorMsg", label:"Error Message"},
		{id:"colRetainerAmount", label:"Retainer Amount"},
		{id:"colWorkSheetComment", label:"Worksheet Comments"},
		{id:"colApprovalComments", label:"Approval Comments"},
		{id:"colCampaignName", label:"Campaign Name"},
		{id:"colProjectManager", label:"Project Manager"}
 ]''
 , NULL, NULL, NULL, NULL)

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingToday_23'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''billingToday_23'', ''grdOpenItemsList_23'', 1, ''Columns'', ''colBillingMethodName,colProjectName,colProjectNumber,colDueDate,colFFTotal,colLaborTotal,colExpenseTotal,colOriginalToBill,colToBill,colWOTotal,colTransferTotal,colHoldTotal,colDoNotBillTotal,colPriorBilled'', NULL, ''grid'', 
''[	{id:"colBillingMethodName", label:"Billing Method"},
		{id:"colProjectName", label:"Project Name"},
		{id:"colProjectNumber", label:"Project Number"},
		{id:"colDueDate", label:"Due Date"},
		{id:"colFFTotal", label:"Fixed Fee Total"},
		{id:"colLaborTotal", label:"Labor Total"},
		{id:"colExpenseTotal", label:"Expense Total"},
		{id:"colOriginalToBill", label:"Original To Bill"},
		{id:"colToBill", label:"To Bill"},
		{id:"colWOTotal", label:"To Write Off"},
		{id:"colTransferTotal", label:"Transfer"},
		{id:"colHoldTotal", label:"Hold"},
		{id:"colDoNotBillTotal", label:"Do Not Bill"},
		{id:"colPriorBilled", label:"Prior Billed"},
		{id:"colCurrencyID", label:"Currency"},
		{id:"colRetainerAmount", label:"Retainer Amount"},
		{id:"colWorkSheetComment", label:"Worksheet Comments"},
		{id:"colApprovalComments", label:"Approval Comments"},
		{id:"colCampaignName", label:"Campaign Name"},
		{id:"colProjectManager", label:"Project Manager"}		
 ]''
 , NULL, NULL, NULL, NULL)

 
 
/*************************************************************************************************************************
Purchasing Today 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''purchasingToday'', ''System Settings'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H1'', 0, ''Open Items'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''OpenRequestsForQuotes'', 1, ''Requests for Quotes'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''OpenItemsOrders'', 2, ''Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''UnapprovedOrders'', 3, ''Unapproved Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''UnsubmittedOrders'', 4, ''Unsubmitted Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''MyOpenItemsOnly'', 5, ''My Open Items Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H2'', 6, ''Incoming Charges'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''IncomingCharges'', 7, ''Incoming Charges'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H3'', 8, ''To Pay As Of'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''ToPayExpenseReports'', 9, ''Expense Reports'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''ToPayVendorInvoices'', 10, ''Vendor Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''ToPayCreditCards'', 11, ''Credit Cards'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H4'', 12, ''Invoices'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''WaitingToCreateInvoices'', 13, ''Expense Reports Waiting to Create Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''WaitingToSend'', 14, ''Waiting to be Submitted'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''WaitingForApproval'', 15, ''Waiting for Approval'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''RejectedInvoices'', 16, ''Rejected Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''ScheduledInvoices'', 17, ''Scheduled Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''ScheduledTransactions'', 18, ''Scheduled Transactions'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H5'', 19, ''Payments'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''PrintChecks'', 20, ''Checks to Print'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''CCNotSent'', 21, ''Charges not Sent'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''CCNotViewed'', 22, ''Charges Sent but not Viewed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H6'', 23, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''DailyFeed'', 24, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''purchasingToday'', ''FeedProjectOptions'', 25, ''Project Options'', ''0'', ''All Projects'', ''lookup'', ''All Projects:0|All Project I Am Assigned To:1|Projects Where I Am The Account Manager:2|Only Projects In My Office:3'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H7'', 26, ''Conversations'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''purchasingToday'', ''SortConversations'', 27, ''Sort Conversations'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''FilterProjectTab'', 28, ''Only show Project Conversations sent to me'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H8'', 29, ''In/Out Board Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''ShowInOutBoard'', 30, ''Show In/Out Board'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''H9'', 31, ''Timeline Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''hideSchedule'', 32, ''Hide the schedule on the side'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''HideEnterTime'', 33, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''DisplayTimeEntries'', 34, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''purchasingToday'', ''DisplayTimeEntriesComments'', 35, ''Display Time Entry Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''DisplayTimeEntries'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchasingToday'', ''IncludePublicMeetings'', 36, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Project Manager Scoreboard
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectSummaryScoreboard'', ''Scoreboard Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''ShowZeroes'', 1, ''Show Zeroes'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''ShowLaborNet'', 2, ''Show Labor Net'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''ShowLaborGross'', 3, ''Show Labor Gross'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''UseClientDivision'', 4, ''Display Client Division'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''LimitToAM'', 5, ''Limit results to the account manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''SummarizeResults'', 6, ''Summarize excessive chart widget results'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''H2'', 7, ''Choose Sections to View'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeRequests'', 8, ''Project Requests'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeProjectSummary'', 9, ''Project Summary'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeCompletedProjects'', 10, ''Completed Projects by Project Type'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeHoursByProjectType'', 11, ''Hours by Project Type'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeHoursByClient'', 12, ''Hours by Client'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeHoursByDivision'', 13, ''Hours by Division'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeBillingByClient'', 14, ''Billings by Client'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''WithAdvBills'', 15, ''Billings with Advanced Bills'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''IncludeProjectDetails'', 16, ''Completed Project Details'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
/*
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField)
VALUES (''projectSummaryScoreboard'', ''ProjectDetailsGroupBy'', 14, ''Group Project Details by'', ''1'', ''Project Type'', ''lookup'', ''Project Type:1|Client:2|Division:3'', NULL, NULL, ''IncludeProjectDetails'')
*/
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSummaryScoreboard'', ''ProjectDetailsGroupBy'', 17, ''Group Project Details by'', ''1'', ''Project Type'', ''lookup'', ''Project Type:1|Client:2|Division:3'', NULL, NULL)

/*************************************************************************************************************************
Project Setup 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectSetup'', ''Project Setup Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSetup'', ''H2'', 1, ''Printing Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSetup'', ''ShowSummaryTasksOnly'', 2, ''Print Summary Tasks Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSetup'', ''LargePrint'', 3, ''Print With Larger Font'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
Project Files 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectFiles'', ''Project Files Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFiles'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectFiles'', ''SortBy'', 1, ''Sort By'', ''2'', ''Last Modified'', ''lookup'', ''Name:0|Size:1|Last Modified:2|Modified By:3|Uploaded:4|Uploaded By:5'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectFiles'', ''Direction'', 2, ''Direction'', ''1'', ''Descending'', ''lookup'', ''Ascending:0|Descending:1'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectFiles'', ''ShowThumbnails'', 3, ''Show Thumbnails'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)




/*************************************************************************************************************************
Project Add 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectAdd'', ''Add Project Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''AddPrimaryContact'', 1, ''Add Primary Contact and Project Requester to the project team'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''DefaultOfficeFromUser'', 2, ''Default Office From User'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''ShowProjectNumber'', 3, ''Show Project Number'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''ShowClientProjectNumber'', 4, ''Show Client Project Number'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''ShowAccountManager'', 5, ''Show Account Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''AccountManagerRequired'', 6, ''Require Account Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''ClientRequired'', 7, ''Require Client'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''AccountTeamRequired'', 8, ''Require Account Team'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''TemplateProjectRequired'', 9, ''Require Template/Project to Copy'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''StartDateDueDateRequired'', 10, ''Require Start Date / Due Date'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref) 
Values (''projectAdd'', ''ShowProjectManager'', 11, ''Show Project Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''ShowProjectManager'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref) 
Values (''projectAdd'', ''ProjectManagerRequired'', 12, ''Require Project Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''ShowProjectManager'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''CopyEstimates'', 13, ''Copy Estimates'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''CopyFiles'', 14, ''Copy Files'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''CopySpecSheets'', 15, ''Copy Specs'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''ShowPlanningProject'', 16, ''Show Planning Project'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectAdd'', ''AssignedTemplatesOnly'', 17, ''Copy from Assigned Templates Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
Project Edit 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectEdit'', ''Edit Project Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectEdit'', ''DisableEditingProjectNumber'', 1, ''Disable the editing of the Project Number'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Project Dashboard 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectDashBoard'', ''Project Dashboard Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardSettings'', 1, ''Dashboard Sections'', NULL, NULL, ''sectionheader'', NULL, NULL, ''Enabling a checkbox below will show the option in the Project Details section on the project dashboard.  The show on right option will remove the section from the Project Details and only show it on the right side within the body.'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardProjecNextStepsSR'', 2, ''Show Next Steps on right'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardProjecStatusNotesSR'', 3, ''Show Status Notes on right'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardProjectDescriptionSR'', 3, ''Show Project Description on right'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardDailyFeed'', 5, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''projectDashBoard'', ''DashboardDailyFeedSR'', 6, ''Show Daily Feed on right'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL, ''DashboardDailyFeed'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardBurnChart'', 7, ''Burn Chart'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardDiary'', 8, ''Recent Conversations'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''projectDashBoard'', ''DashboardIncludeActivities'', 9, ''Include sales conversations'', ''0'', NULL, ''checkbox'', NULL, NULL, ''This will include conversations entered in the sales area linked to this project.'', ''DashboardDiary'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''projectDashBoard'', ''DashboardDiarySR'', 10, ''Show Conversations on right'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL, ''DashboardDiary'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardCustomFieldsSR'', 11, ''Show Custom Fields on right'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardSnapshotSR'', 12, ''Show Project Snapshot'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardProfitabilitySR'', 13, ''Show Project Profitability'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardTeamSR'', 14, ''Show Team on right'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardSpecsheets'', 15, ''SpecSheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''projectDashBoard'', ''DashboardSpecsheetsSR'', 16, ''Show Specsheets on right'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL, ''DashboardSpecsheets'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardDeliverables'', 17, ''Deliverables'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''projectDashBoard'', ''DashboardDeliverablesSR'', 18, ''Show Deliverables on right'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL, ''DashboardDeliverables'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardCustomFiledsForTempate'', 19, ''Show Custom Fields for Template'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardChangeRequest'', 20, ''Show Project Change Requests'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''DashboardShowClosedBilling'', 21, ''Show Billing for Closed Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectDashBoard'', ''showProjectTrackingForms'', 22, ''Show Tracking Forms'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectDashBoard'', ''H3'', 23, ''Feed'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectDashBoard'', ''ShowTimeEntries'', 24, ''Show Time Entries'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Project Schedule
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectSchedule'', ''Project Schedule Grid'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
delete tAppSetting Where GroupID = ''projectSchedule'' and SessionID = ''AutoSave''
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''projectSchedule'', ''AutoSave'', 1, ''Auto Save Schedule'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''projectSchedule'', ''ScheduleLockedColumns'', 2, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectSchedule'', ''grdProjectScheduleCols'', 3, ''Columns'', ''prjScheduleTaskStatus,prjScheduleAssigned,prjScheduleAssignedFullName,prjSchedulePlanDuration,prjSchedulePlanStart,prjSchedulePlanComp,prjScheduleActualHours,prjScheduleActualStart,prjScheduleActualComplete,prjSchedulePercComp,prjSchedulePredecessors,prjScheduleLine'', NULL, ''grid'', 

''[	{id:"prjSchedulePlanDuration", label:"Days"},
	{id:"prjSchedulePlanStart", label:"Plan Start"},
	{id:"prjSchedulePlanComp", label:"Plan Complete"},
	{id:"prjScheduleTrackSeparately", label:"Track Separately"},
	{id:"prjSchedulePercComp", label:"%"},
	{id:"prjScheduleAssigned", label:"Assigned"},
	{id:"prjScheduleAssignedFullName", label:"Assigned Full Name"},
	{id:"prjScheduleActualHours", label:"Actual Hours"},
	{id:"prjSchedulePredecessors", label:"Predecessors"},
	{id:"prjScheduleActualStart", label:"Actual Start"},
	{id:"prjScheduleActualComplete", label:"Actual Complete"},
	{id:"prjScheduleAllTimesheets", label:"All Time Sheets"},
	{id:"prjScheduleBillingItem", label:"Billing Item"},
	{id:"prjScheduleBOCommision", label:"BO Commission"},
	{id:"prjScheduleConstraint", label:"Constraint"},
	{id:"prjScheduleConstraintDate", label:"Constraint Date"},
	{id:"prjScheduleConstraintDayOfWeek", label:"Constraint Day Of The Week"},
	{id:"prjScheduleDescription", label:"Description"},
	{id:"prjScheduleDueComment", label:"Due Comment"},
	{id:"prjScheduleAllocHours", label:"Allocated Hours"},
	{id:"prjScheduleRemainingHours", label:"Remaining Hours"},
	{id:"prjScheduleEstHours", label:"Est Hours"},
	{id:"prjScheduleHideFromClient", label:"Hide From Client"},
	{id:"prjScheduleMustFinishOnPredComplete", label:"Must Finish On when Pred Complete"},
	{id:"prjScheduleHourlyRate", label:"Hourly Rate"},
	{id:"prjScheduleIOCommision", label:"IO Commission"},

	{id:"prjScheduleLine", label:"Line"},
	{id:"prjScheduleMarkup", label:"Markup"},
	{id:"prjScheduleOrigStart", label:"Baseline Start"},
	{id:"prjScheduleOrigComp", label:"Baseline Complete"},
	{id:"prjSchedulePriority", label:"Priority"},
	{id:"prjScheduleReviewed", label:"Reviewed"},
	{id:"prjScheduleTaskScheduled", label:"Show On Schedule"},
	{id:"prjScheduleShowOnEstimate", label:"Show On Estimate"},
	{id:"prjScheduleTaskStatus", label:"Status"},
	{id:"prjScheduleStatusDescription", label:"Status Comment"},
	{id:"prjScheduleTaskID", label:"Task ID"},
	{id:"prjScheduleTax1", label:"Tax 1"},
	{id:"prjScheduleTax2", label:"Tax 2"},
	{id:"prjScheduleDateAssigned", label:"Date Assigned"},
	{id:"prjScheduleTimeAssigned", label:"Time Assigned"},
	{id:"prjScheduleTrackBudgets", label:"Track Budgets"},
	{id:"prjScheduleExcludeFromStatus", label:"Exclude From Status"},
	{id:"prjScheduleWorkAnyDay", label:"Work Any Day"},
	{id:"prjScheduleTimelineSection", label:"Timeline Section"},
	{id:"prjScheduleTimelineSegmentDisplayName", label:"Override Display Name"},
	{id:"prjScheduleTCProjectStatus", label:"Task Complete Project Status"},
	{id:"prjScheduleOpenToDos", label:"Open ToDos"},
	{id:"prjSchedulePredLegacy", label:"Predecessor Lookup"},
	{id:"prjScheduleConversationCount", label:"Conversation Count"},
	{id:"prjScheduleAllocatedHoursGross", label:"Allocated Hours Gross"},
	{id:"prjScheduleBudgetLaborGross", label:"Curr Budget Labor Gross"},
	{id:"prjScheduleNoTimeEntry", label:"Time Entry Excluded", customization:"deborahWoodTaskNoTime"},
	{id:"prjScheduleDeliverableCount", label:"Deliverable Count"},
	{id:"prjScheduleBudgetRemainingHours", label:"Budget Remaining Hours"}
 ]''
	 , NULL, NULL, null, null)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''OpenExpanded'', 4, ''Expand Schedule When Opened'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''editColumnSets'', 5, ''Edit Column Sets'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''IncludeProjects'', 6, ''Include Projects in Template List'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''IncludeAssignedEmailTo'', 7, ''Include Assigned Users on Task Conversation Email List '', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''PrevTaskPred'', 8, ''Set Previous Task as Predecessor of New Task'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''DefaultTrackBudget'', 9, ''Default Track Budget on New Task'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''PrjSchedBurnChart'', 10, ''Burn Chart'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSchedule'', ''ShowSetBaseline'', 10, ''Show Set Baseline'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
Project Template
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectTemplate'', ''Project Template Grid'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectTemplate'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''projectTemplate'', ''TemplateLockedColumns'', 1, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectTemplate'', ''grdProjectTemplateCols'', 2, ''Columns'', ''prjSchedulePlanDuration,prjScheduleAssigned,prjSchedulePredecessors,prjScheduleLine,prjScheduleTrackBudgets,prjScheduleTCProjectStatus'', NULL, ''grid'', 

''[	{id:"prjSchedulePlanDuration", label:"Days"},
	{id:"prjSchedulePlanStart", label:"Plan Start"},
	{id:"prjSchedulePlanComp", label:"Plan Complete"},
	{id:"prjScheduleAssigned", label:"Assigned"},
	{id:"prjSchedulePredecessors", label:"Pred"},
	{id:"prjScheduleAllTimesheets", label:"All Time Sheets"},
	{id:"prjScheduleBillingItem", label:"Billing Item"},
	{id:"prjScheduleConstraint", label:"Constraint"},
	{id:"prjScheduleConstraintDate", label:"Constraint Date"},
	{id:"prjScheduleConstraintDayOfWeek", label:"Constraint Day Of The Week"},
	{id:"prjScheduleDescription", label:"Description"},
	{id:"prjScheduleEstHours", label:"Est Hours"},
	{id:"prjScheduleHideFromClient", label:"Hide From Client"},
	{id:"prjScheduleHourlyRate", label:"Hourly Rate"},
	{id:"prjScheduleLine", label:"Line"},
	{id:"prjScheduleMarkup", label:"Markup"},
	{id:"prjSchedulePriority", label:"Priority"},
	{id:"prjScheduleTaskScheduled", label:"Show On Schedule"},
	{id:"prjScheduleShowOnEstimate", label:"Show On Estimate"},
	{id:"prjScheduleTaskID", label:"Task ID"},
	{id:"prjScheduleTax1", label:"Tax 1"},
	{id:"prjScheduleTax2", label:"Tax 2"},
	{id:"prjScheduleTrackBudgets", label:"Track Budgets"},
	{id:"prjScheduleWorkAnyDay", label:"Work Any Day"},
	{id:"prjScheduleTimelineSection", label:"Timeline Section"},
	{id:"prjScheduleStatusDescription", label:"Status Comment"},
	{id:"prjScheduleTCProjectStatus", label:"Task Complete Project Status"},
	{id:"prjScheduleAllocHours", label:"Allocated Hours"}
 ]''
	 , NULL, NULL, null, null)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectTemplate'', ''editColumnSets'', 3, ''Edit Column Sets'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Project Spec Sheet
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectSpecSheets'', ''Spec Sheet Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSpecSheets'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSpecSheets'', ''useGridMode'', 1, ''Use Spec Sheet Grid Mode'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectSpecSheets'', ''SortByDateCreated'', 2, ''Sort Non-Grid Mode By Date Created'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectSpecSheets'', ''grdSpecSheetsCols'', 3, ''Columns'', ''specFullSpecID,specVersion,specSubject,specDescription,specCreatedBy,specDateCreated,specUpdatedBy,specDateUpdated'', NULL, ''grid'', 

''[	{id:"specSubject", label:"Subject"},
	{id:"specDescription", label:"Description"},
	{id:"specSpecID", label:"Spec ID"},
	{id:"specFullSpecID", label:"Full Spec ID"},
	{id:"specCreatedBy", label:"Created By"},
	{id:"specDateCreated", label:"Date Created"},
	{id:"specUpdatedBy", label:"Updated By"},
	{id:"specDateUpdated", label:"Date Updated"},
	{id:"specVersion", label:"Approved Version"}
 ]''
	 , NULL, NULL, ''Spec'', ''Spec'')


/*************************************************************************************************************************
Campaign Spec Sheet
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignSpecSheets'', ''Spec Sheet Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignSpecSheets'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campaignSpecSheets'', ''grdSpecSheetsCols'', 3, ''Columns'', ''specSubject,specDescription,specCreatedBy,specDateCreated,specUpdatedBy,specDateUpdated'', NULL, ''grid'', 

''[	{id:"specSubject", label:"Subject"},
	{id:"specDescription", label:"Description"},
	{id:"specSpecID", label:"Spec ID"},
	{id:"specFullSpecID", label:"Full Spec ID"},
	{id:"specCreatedBy", label:"Created By"},
	{id:"specDateCreated", label:"Date Created"},
	{id:"specUpdatedBy", label:"Updated By"},
	{id:"specDateUpdated", label:"Date Updated"}
 ]''
	 , NULL, NULL, ''Spec'', ''Spec'')


/*************************************************************************************************************************
Project Requests
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectRequestEdit'', ''Project Request Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectRequestEdit'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectRequestEdit'', ''useGridMode'', 1, ''Use Spec Sheet Grid Mode'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectRequestEdit'', ''editSpecByClient'', 2, ''Client can edit Subject/Description'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectRequestEdit'', ''resendCancelApprovedRequest'', 3, ''Cancel/Resend Approved Project Requests'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectRequestEdit'', ''useConversations'', 4, ''Use Conversations'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectRequestEdit'', ''grdSpecSheetsCols'', 5, ''Columns'', ''specSubject,specDescription,specCreatedBy,specDateCreated,specUpdatedBy,specDateUpdated'', NULL, ''grid'', 

''[	{id:"specSubject", label:"Subject"},
	{id:"specDescription", label:"Description"},
	{id:"specSpecID", label:"Spec ID"},
	{id:"specCreatedBy", label:"Created By"},
	{id:"specDateCreated", label:"Date Created"},
	{id:"specUpdatedBy", label:"Updated By"},
	{id:"specDateUpdated", label:"Date Updated"}
 ]''
	 , NULL, NULL, ''Spec'', ''Spec'')


/*************************************************************************************************************************
Task Edit ToDos
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''taskEditToDo'', ''Task Edit To Do Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''taskEditToDo'', ''EditInGrid'', 1, ''Edit To Dos directly in grid'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''taskEditToDo'', ''grdToDosCols'', 3, ''Columns'', ''toDoSubject,toDoCompleted'', NULL, ''grid'', 

''[	{id:"toDoSubject", label:"Subject"},
	{id:"toDoCompleted", label:"Completed"},
	{id:"todoUserFullName", label:"Assigned To"}
 ]''
	 , NULL, NULL, ''Activity'',''Activity'')

/*************************************************************************************************************************
Select Invoices to Pay
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''payvouchers'', ''Select Invoices To Pay Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''payvouchers'', ''H_GRID'', 0, ''Grid Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''payvouchers'', ''grdVoucherCols'', 1, ''Columns'', ''payvouchVendor,payvouchVendorID,payvouchInvoiceNumber,payvouchOriginalOpenAmount,payvouchDiscAmount,payvouchOpenAmount,payvouchCurrency'', NULL, ''grid'', 

''[
{id:"payvouchVendor", label:"Vendor"},
{id:"payvouchVendorID", label:"Vendor ID"},
{id:"payvouchInvoiceNumber", label:"Invoice Number"},
{id:"payvouchDiscAmount", label:"Discount"},
{id:"payvouch1099", label:"Exclude From 1099"},
{id:"payvouchOpenAmount", label:"Amount to Pay"},
{id:"payvouchCurrency", label:"Currency"},
{id:"payvouchGLCompany", label:"Company"},
{id:"payvouchClass", label:"Class"},
{id:"payvouchInvoiceDate", label:"Invoice Date"},
{id:"payvouchDiscountDate", label:"Discount Date"},
{id:"payvouchDueDate", label:"Due Date"},
{id:"payvouchOriginalOpenAmount", label:"Open Amount"},
{id:"payvouchCompanyType", label:"Company Type"},
{id:"payvouchPaidByClient", label:"Paid By Client"},
{id:"payvouchBilledToClient", label:"Billed to Client"},
{id:"payvouchClient", label:"Client"},
{id:"payvouchClientID", label:"Client ID"},
{id:"payvouchDaysOld", label:"Days Old"},
{id:"payvouchDescription", label:"Description"},
{id:"payvouchDateCreated", label:"Date Created"},
{id:"payvouchDateReceived", label:"Date Received"},
{id:"payvouchACHEnabled", label:"ACH Enabled"}
]''
	 , NULL, NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''payvouchers'', ''Grouping1'', 2, ''Order By 1'', ''1'', ''Vendor Name'', ''lookup'', ''Vendor Name:1|Vendor ID:2|Client Name:3|Client ID:4|Invoice Number:5|Invoice Date:6|Due Date:7|Open Amount:8|Company Type:9'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''payvouchers'', ''Grouping2'', 3, ''Order By 2'', ''0'', ''No Sort'', ''lookup'', ''No Sort:0|Vendor Name:1|Vendor ID:2|Client Name:3|Client ID:4|Invoice Number:5|Invoice Date:6|Due Date:7|Open Amount:8|Company Type:9'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''payvouchers'', ''Grouping3'', 4, ''Order By 3'', ''0'', ''No Sort'', ''lookup'', ''No Sort:0|Vendor Name:1|Vendor ID:2|Client Name:3|Client ID:4|Invoice Number:5|Invoice Date:6|Due Date:7|Open Amount:8|Company Type:9'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''payvouchers'', ''InvoicesBilledToClient'', 5, ''Invoices Billed to Client'', ''0'', ''Invoices Billed to Client'', ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''payvouchers'', ''InvoicesPaidByClient'', 6, ''Invoices Paid by Client'', ''0'', ''Invoices Paid by Client'', ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''payvouchers'', ''HideBankAccountBalances'', 7, ''Hide Bank Account Balances'', ''0'', ''Hide Bank Account Balances'', ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Select Invoices to Pay
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''paycreditcards'', ''Pay Credit Card Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''paycreditcards'', ''H_GRID'', 0, ''Grid Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paycreditcards'', ''grdVoucherCols'', 1, ''Columns'', ''payccBoughtByName,payccBoughtFrom,payccVoucherID,payccInvoiceDate,payccCurrency,payccOpenAmount,payccVoucherTotal,payccDiscount,payccReference,payccPostingDate,payccPosted,payccGLCompany,payccClass'', NULL, ''grid'', 

''[
{id:"payccBoughtByName", label:"Charged By"},
{id:"payccBoughtFrom", label:"Purchased From"},
{id:"payccVoucherID", label:"Ref #"},
{id:"payccInvoiceDate", label:"Invoice Date"},
{id:"payccCurrency", label:"Currency"},
{id:"payccOpenAmount", label:"Amount To Pay"},
{id:"payccVoucherTotal", label:"Charge Amount"},
{id:"payccDiscount", label:"Discount"},
{id:"payccReference", label:"Reference"},
{id:"payccPostingDate", label:"Posting Date"},
{id:"payccPosted", label:"Posted"},
{id:"payccGLCompany", label:"Company"},
{id:"payccClass", label:"Class"},
{id:"payccDescription", label:"Description"}
]''
	 , NULL, NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''paycreditcards'', ''HideBankAccountBalances'', 7, ''Hide Bank Account Balances'', ''0'', ''Hide Bank Account Balances'', ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Project Budget
**************************************************************************************************************************/	 

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetSettings'', ''Project Budget Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''H_BY_ITEM'', 0, ''BY ITEM'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''prjbudgetSettings'', ''ScheduleLockedColumns1'', 1, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''HITEM1'', 2, ''Labor Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetSettings'', ''grdProjectBudgetServiceCols'', 3, ''Columns'', ''prjbudCurrentBudgetHours,prjbudCurrentTotalBudget,prjbudHours,prjbudLaborGross,prjbudTotalGross,prjbudRemainingAllocatedHours'', NULL, ''grid'', 

''[
{id:"prjbudCurrentBudgetHours", label:"Current Budget Hours"},
{id:"prjbudCurrentBudgetLaborNet", label:"Current Budget Labor Net"},
{id:"prjbudCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
{id:"prjbudCurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudCurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudCurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudCurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudCOBudgetHours", label:"CO Budget Hours"},
{id:"prjbudCOBudgetLaborNet", label:"CO Budget Labor Net"},
{id:"prjbudCOBudgetLaborGross", label:"CO Budget Labor Gross"},
{id:"prjbudCOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudCOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudCOTotalBudget", label:"CO Total Budget"},
{id:"prjbudCOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudOriginalBudgetHours", label:"Original Budget Hours"},
{id:"prjbudOriginalBudgetLaborNet", label:"Original Budget Labor Net"},
{id:"prjbudOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
{id:"prjbudOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudHours", label:"Act Hours"},
{id:"prjbudHoursBilled", label:"Hours Billed"},
{id:"prjbudHoursInvoiced", label:"Hours Invoiced"},
{id:"prjbudHoursWriteOff", label:"Hours WriteOff"},
{id:"prjbudHoursAfterWriteOff", label:"Hours After WriteOff"},
{id:"prjbudHoursUnbilled", label:"Hours Unbilled"},
{id:"prjbudLaborNet", label:"Labor Net"},
{id:"prjbudLaborGross", label:"Labor Gross"},
{id:"prjbudLaborBilled", label:"Labor Billed"},
{id:"prjbudLaborInvoiced", label:"Labor Invoiced"},
{id:"prjbudLaborUnbilled", label:"Labor Unbilled"},
{id:"prjbudLaborWriteOff", label:"Labor WriteOff"},
{id:"prjbudLaborAfterWriteOff", label:"Labor After WriteOff"},
{id:"prjbudOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudExpenseWriteOff", label:"Expense WriteOff"},
{id:"prjbudExpenseBilled", label:"Expense Billed"},
{id:"prjbudExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudAdvanceBilled", label:"Advance Billed"},
{id:"prjbudAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudAmountBilled", label:"Amount Billed"},
{id:"prjbudAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudTotalCostsNet", label:"Total Costs Net"},
{id:"prjbudTotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudTotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudTotalNet", label:"Total Net"},
{id:"prjbudTotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudTotalGross", label:"Total Gross"},
{id:"prjbudTotalGrossAfterWriteOff", label:"Total Gross After WriteOff"},
{id:"prjbudRemainingAllocatedHours", label:"Remaining Allocated Hours"},
{id:"prjbudAllocatedHours", label:"Allocated Hours"},
{id:"prjbudPAllocated", label:"Percentage of Allocated"},
{id:"prjbudFutureAllocatedHours", label:"Future Allocated Hours"},
{id:"prjbudAllocatedGross", label:"Allocated Gross"},
{id:"prjbudFutureAllocatedGross", label:"Future Allocated Gross"},
{id:"prjbudFutureLaborGrossRemaining", label:"Future Labor Gross Remaining"},
{id:"prjbudHoursBilledRemaining", label:"Hours Billed Remaining"},
{id:"prjbudHoursBilledRemainingP", label:"Hours Billed Remaining %"},
{id:"prjbudHoursRemaining", label:"Hours Remaining"},
{id:"prjbudHoursRemainingP", label:"Hours Remaining %"},
{id:"prjbudHoursAfterWriteOffRemaining", label:"Hours After WriteOff Remaining"},
{id:"prjbudHoursAfterWriteOffRemainingP", label:"Hours After WriteOff Remaining %"},
{id:"prjbudLaborNetRemaining", label:"Labor Net Remaining"},
{id:"prjbudLaborNetRemainingP", label:"Labor Net Remaining %"},
{id:"prjbudLaborGrossRemaining", label:"Labor Gross Remaining"},
{id:"prjbudLaborGrossRemainingP", label:"Labor Gross Remaining %"},
{id:"prjbudLaborGrossAfterWriteOffRemaining", label:"Labor Gross After WriteOff Remaining"},
{id:"prjbudLaborGrossAfterWriteOffRemainingP", label:"Labor Gross After WriteOff Remaining %"},
{id:"prjbudCostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudCostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudCostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudCostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudGrossRemaining", label:"Gross Remaining"},
{id:"prjbudGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudBilledDifference", label:"Billed Difference"},
{id:"prjbudTransferInLabor", label:"Transfer In Labor"},
{id:"prjbudTransferOutLabor", label:"Transfer Out Labor"},
{id:"prjbudTransferInExpense", label:"Transfer In Expense"},
{id:"prjbudTransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudVarianceHours", label:"Variance Hours"},
{id:"prjbudSalesTax", label:"Sales Tax"},
{id:"prjbudTotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL)




INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''HITEM2'', 6, ''Expense Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetSettings'', ''grdProjectBudgetItemCols'', 7, ''Columns'', ''prjbudICurrentTotalBudget,prjbudITotalGross'', NULL, ''grid'', 

''[{id:"prjbudICurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudICurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudICurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudICurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudICurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudICurrentBudgetExpenseQuantity", label:"Current Budget Expense Quantity"},
{id:"prjbudICOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudICOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudICOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudICOTotalBudget", label:"CO Total Budget"},
{id:"prjbudICOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudIOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudIOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudIOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudIOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudIOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudIOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudIOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudIInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudIOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudIOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudIInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudIOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudIInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudIOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudIExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudIExpenseBilled", label:"Expense Billed"},
{id:"prjbudIExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudIActualQuantity", label:"Actual Quantity"},
{id:"prjbudIAdvanceBilled", label:"Advance Billed"},
{id:"prjbudIAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudIAmountBilled", label:"Amount Billed"},
{id:"prjbudIAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudITotalCostsNet", label:"Total Costs Net"},
{id:"prjbudITotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudITotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudITotalNet", label:"Total Net"},
{id:"prjbudITotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudITotalGross", label:"Total Gross"},
{id:"prjbudITotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudICostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudICostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudICostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudICostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudIToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudIToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudIGrossRemaining", label:"Gross Remaining"},
{id:"prjbudIGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudIBilledDifference", label:"Billed Difference"},
{id:"prjbudITransferInExpense", label:"Transfer In Expense"},
{id:"prjbudITransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudISalesTax", label:"Sales Tax"},
{id:"prjbudITotalCostsGrossAfterWriteOff", label:"Total Costs Gross After WriteOff w Open Orders"},
{id:"prjbudITotalCostsGrossAfterWriteOffNoOrder", label:"Total Costs Gross After WriteOff w/o Open Orders"},
{id:"prjbudICostsGrossAfterWriteOffRemaining", label:"Costs Gross After WriteOff Remaining"},
{id:"prjbudICostsGrossAfterWriteOffRemainingP", label:"Costs Gross After WriteOff Remaining %"},
{id:"prjbudICostsGrossAfterWriteOffNoOrderRemaining", label:"Costs Gross After WriteOff wo Order Remaining"},
{id:"prjbudICostsGrossAfterWriteOffNoOrderRemainingP", label:"Costs Gross After WriteOff wo Order Remaining %"},
{id:"prjbudITotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''H_BY_TYPE'', 8, ''BY TYPE'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''prjbudgetSettings'', ''ScheduleLockedColumns2'', 9, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetSettings'', ''grdProjectBudgetTypeCols'', 10, ''Columns'', ''prjbudYCurrentTotalBudget,prjbudYTotalGross,prjbudYRemainingAllocatedHours'', NULL, ''grid'', 

''[{id:"prjbudYCurrentBudgetHours", label:"Current Budget Hours"},
{id:"prjbudYCurrentBudgetLaborNet", label:"Current Budget Labor Net"},
{id:"prjbudYCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
{id:"prjbudYCurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudYCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudYCurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudYCurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudYCurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudYCurrentBudgetExpenseQuantity", label:"Current Budget Expense Quantity"},
{id:"prjbudYCOBudgetHours", label:"CO Budget Hours"},
{id:"prjbudYCOBudgetLaborNet", label:"CO Budget Labor Net"},
{id:"prjbudYCOBudgetLaborGross", label:"CO Budget Labor Gross"},
{id:"prjbudYCOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudYCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudYCOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudYCOTotalBudget", label:"CO Total Budget"},
{id:"prjbudYCOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudYOriginalBudgetHours", label:"Original Budget Hours"},
{id:"prjbudYOriginalBudgetLaborNet", label:"Original Budget Labor Net"},
{id:"prjbudYOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
{id:"prjbudYOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudYOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudYOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudYOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudYOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudYHours", label:"Act Hours"},
{id:"prjbudYHoursBilled", label:"Hours Billed"},
{id:"prjbudYHoursInvoiced", label:"Hours Invoiced"},
{id:"prjbudYHoursUnbilled", label:"Hours Unbilled"},
{id:"prjbudYLaborNet", label:"Labor Net"},
{id:"prjbudYLaborGross", label:"Labor Gross"},
{id:"prjbudYLaborBilled", label:"Labor Billed"},
{id:"prjbudYLaborInvoiced", label:"Labor Invoiced"},
{id:"prjbudYLaborUnbilled", label:"Labor Unbilled"},
{id:"prjbudYLaborWriteOff", label:"Labor Write Off"},
{id:"prjbudYOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudYOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudYInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudYOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudYOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudYInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudYOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudYInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudYOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudYExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudYExpenseBilled", label:"Expense Billed"},
{id:"prjbudYExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudYActualQuantity", label:"Actual Quantity"},
{id:"prjbudYAdvanceBilled", label:"Advance Billed"},
{id:"prjbudYAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudYAmountBilled", label:"Amount Billed"},
{id:"prjbudYAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudYTotalCostsNet", label:"Total Costs Net"},
{id:"prjbudYTotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudYTotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudYTotalNet", label:"Total Net"},
{id:"prjbudYTotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudYTotalGross", label:"Total Gross"},
{id:"prjbudYTotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudYRemainingAllocatedHours", label:"Remaining Allocated Hours"},
{id:"prjbudYAllocatedHours", label:"Allocated Hours"},
{id:"prjbudYPAllocated", label:"Percentage of Allocated"},
{id:"prjbudYFutureAllocatedHours", label:"Future Allocated Hours"},
{id:"prjbudYAllocatedGross", label:"Allocated Gross"},
{id:"prjbudYFutureAllocatedGross", label:"Future Allocated Gross"},
{id:"prjbudYFutureLaborGrossRemaining", label:"Future Labor Gross Remaining"},
{id:"prjbudYHoursBilledRemaining", label:"Hours Billed Remaining"},
{id:"prjbudYHoursBilledRemainingP", label:"Hours Billed Remaining %"},
{id:"prjbudYHoursRemaining", label:"Hours Remaining"},
{id:"prjbudYHoursRemainingP", label:"Hours Remaining %"},
{id:"prjbudYLaborNetRemaining", label:"Labor Net Remaining"},
{id:"prjbudYLaborNetRemainingP", label:"Labor Net Remaining %"},
{id:"prjbudYLaborGrossRemaining", label:"Labor Gross Remaining"},
{id:"prjbudYLaborGrossRemainingP", label:"Labor Gross Remaining %"},
{id:"prjbudYCostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudYCostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudYCostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudYCostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudYToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudYToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudYGrossRemaining", label:"Gross Remaining"},
{id:"prjbudYGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudYBilledDifference", label:"Billed Difference"},
{id:"prjbudYTransferInLabor", label:"Transfer In Labor"},
{id:"prjbudYTransferOutLabor", label:"Transfer Out Labor"},
{id:"prjbudYTransferInExpense", label:"Transfer In Expense"},
{id:"prjbudYTransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudYVarianceHours", label:"Variance Hours"},
{id:"prjbudYSalesTax", label:"Sales Tax"},
{id:"prjbudYHoursWriteOff", label:"Hours WriteOff"},
{id:"prjbudYHoursAfterWriteOff", label:"Hours After WriteOff"},
{id:"prjbudYLaborAfterWriteOff", label:"Labor After WriteOff"},
{id:"prjbudYHoursAfterWriteOffRemaining", label:"Hours After WriteOff Remaining"},
{id:"prjbudYHoursAfterWriteOffRemainingP", label:"Hours After WriteOff Remaining %"},
{id:"prjbudYLaborGrossAfterWriteOffRemaining", label:"Labor Gross After WriteOff Remaining"},
{id:"prjbudYLaborGrossAfterWriteOffRemainingP", label:"Labor Gross After WriteOff Remaining %"},
{id:"prjbudYTotalCostsGrossAfterWriteOff", label:"Total Costs Gross After WriteOff w Open Orders"},
{id:"prjbudYTotalCostsGrossAfterWriteOffNoOrder", label:"Total Costs Gross After WriteOff w/o Open Orders"},
{id:"prjbudYCostsGrossAfterWriteOffRemaining", label:"Costs Gross After WriteOff Remaining"},
{id:"prjbudYCostsGrossAfterWriteOffRemainingP", label:"Costs Gross After WriteOff Remaining %"},
{id:"prjbudYCostsGrossAfterWriteOffNoOrderRemaining", label:"Costs Gross After WriteOff wo Order Remaining"},
{id:"prjbudYCostsGrossAfterWriteOffNoOrderRemainingP", label:"Costs Gross After WriteOff wo Order Remaining %"},
{id:"prjbudYTotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"},
{id:"prjbudYCurrentBudgetQty", label:"Current Budget Quantity"},
{id:"prjbudYPurchasedQty", label:"Purchased Quantity"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''H_BY_TASK'', 11, ''BY TASK'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''prjbudgetSettings'', ''ScheduleLockedColumns3'', 12, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''HSUMMARY'', 13, ''Task Summary Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetSettings'', ''grdProjectBudgetTaskCols'', 14, ''Columns'', ''prjbudTCurrentTotalBudget,prjbudTTotalGross,prjbudTRemainingAllocatedHours'', NULL, ''grid'', 

''[
{id:"prjbudTPercComp", label:"% Complete"},
{id:"prjbudTCurrentBudgetHours", label:"Current Budget Hours"},
{id:"prjbudTCurrentBudgetLaborNet", label:"Current Budget Labor Net"},
{id:"prjbudTCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
{id:"prjbudTCurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudTCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudTCurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudTCurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudTCurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudTCurrentBudgetExpenseQuantity", label:"Current Budget Expense Quantity"},
{id:"prjbudTCOBudgetHours", label:"CO Budget Hours"},
{id:"prjbudTCOBudgetLaborNet", label:"CO Budget Labor Net"},
{id:"prjbudTCOBudgetLaborGross", label:"CO Budget Labor Gross"},
{id:"prjbudTCOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudTCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudTCOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudTCOTotalBudget", label:"CO Total Budget"},
{id:"prjbudTCOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudTOriginalBudgetHours", label:"Original Budget Hours"},
{id:"prjbudTOriginalBudgetLaborNet", label:"Original Budget Labor Net"},
{id:"prjbudTOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
{id:"prjbudTOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudTOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudTOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudTOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudTOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudTHours", label:"Act Hours"},
{id:"prjbudTHoursBilled", label:"Hours Billed"},
{id:"prjbudTHoursInvoiced", label:"Hours Invoiced"},
{id:"prjbudTHoursUnbilled", label:"Hours Unbilled"},
{id:"prjbudTLaborNet", label:"Labor Net"},
{id:"prjbudTLaborGross", label:"Labor Gross"},
{id:"prjbudTLaborBilled", label:"Labor Billed"},
{id:"prjbudTLaborInvoiced", label:"Labor Invoiced"},
{id:"prjbudTLaborUnbilled", label:"Labor Unbilled"},
{id:"prjbudTLaborWriteOff", label:"Labor Write Off"},
{id:"prjbudTOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudTOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudTInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudTOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudTOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudTInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudTOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudTInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudTOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudTExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudTExpenseBilled", label:"Expense Billed"},
{id:"prjbudTExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudTActualQuantity", label:"Actual Quantity"},
{id:"prjbudTAdvanceBilled", label:"Advance Billed"},
{id:"prjbudTAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudTAmountBilled", label:"Amount Billed"},
{id:"prjbudTAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudTTotalCostsNet", label:"Total Costs Net"},
{id:"prjbudTTotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudTTotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudTTotalNet", label:"Total Net"},
{id:"prjbudTTotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudTTotalGross", label:"Total Gross"},
{id:"prjbudTTotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudTRemainingAllocatedHours", label:"Remaining Allocated Hours"},
{id:"prjbudTAllocatedHours", label:"Allocated Hours"},
{id:"prjbudTPAllocated", label:"Percentage of Allocated"},
{id:"prjbudTFutureAllocatedHours", label:"Future Allocated Hours"},
{id:"prjbudTFutureLaborGrossRemaining", label:"Future Labor Gross Remaining"},
{id:"prjbudTAllocatedGross", label:"Allocated Gross"},
{id:"prjbudTFutureAllocatedGross", label:"Future Allocated Gross"},
{id:"prjbudTHoursBilledRemaining", label:"Hours Billed Remaining"},
{id:"prjbudTHoursBilledRemainingP", label:"Hours Billed Remaining %"},
{id:"prjbudTHoursRemaining", label:"Hours Remaining"},
{id:"prjbudTHoursRemainingP", label:"Hours Remaining %"},
{id:"prjbudTLaborNetRemaining", label:"Labor Net Remaining"},
{id:"prjbudTLaborNetRemainingP", label:"Labor Net Remaining %"},
{id:"prjbudTLaborGrossRemaining", label:"Labor Gross Remaining"},
{id:"prjbudTLaborGrossRemainingP", label:"Labor Gross Remaining %"},
{id:"prjbudTCostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudTCostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudTCostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudTCostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudTToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudTToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudTGrossRemaining", label:"Gross Remaining"},
{id:"prjbudTGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudTBilledDifference", label:"Billed Difference"},
{id:"prjbudTTransferInLabor", label:"Transfer In Labor"},
{id:"prjbudTTransferOutLabor", label:"Transfer Out Labor"},
{id:"prjbudTTransferInExpense", label:"Transfer In Expense"},
{id:"prjbudTTransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudTVarianceHours", label:"Variance Hours"},
{id:"prjbudTSalesTax", label:"Sales Tax"},
{id:"prjbudTHoursWriteOff", label:"Hours WriteOff"},
{id:"prjbudTHoursAfterWriteOff", label:"Hours After WriteOff"},
{id:"prjbudTLaborAfterWriteOff", label:"Labor After WriteOff"},
{id:"prjbudTHoursAfterWriteOffRemaining", label:"Hours After WriteOff Remaining"},
{id:"prjbudTHoursAfterWriteOffRemainingP", label:"Hours After WriteOff Remaining %"},
{id:"prjbudTLaborGrossAfterWriteOffRemaining", label:"Labor Gross After WriteOff Remaining"},
{id:"prjbudTLaborGrossAfterWriteOffRemainingP", label:"Labor Gross After WriteOff Remaining %"},
{id:"prjbudTTotalCostsGrossAfterWriteOff", label:"Total Costs Gross After WriteOff w Open Orders"},
{id:"prjbudTTotalCostsGrossAfterWriteOffNoOrder", label:"Total Costs Gross After WriteOff w/o Open Orders"},
{id:"prjbudTCostsGrossAfterWriteOffRemaining", label:"Costs Gross After WriteOff Remaining"},
{id:"prjbudTCostsGrossAfterWriteOffRemainingP", label:"Costs Gross After WriteOff Remaining %"},
{id:"prjbudTCostsGrossAfterWriteOffNoOrderRemaining", label:"Costs Gross After WriteOff wo Order Remaining"},
{id:"prjbudTCostsGrossAfterWriteOffNoOrderRemainingP", label:"Costs Gross After WriteOff wo Order Remaining %"},
{id:"prjbudTTotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL)


-- Task Details

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''HDETAILS'', 15, ''Task Detail Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetSettings'', ''grdProjectBudgetTaskDetailCols'', 16, ''Columns'', ''prjbudTDServiceItem,prjbudTDCurrentTotalBudget,prjbudTDTotalGross,prjbudTDRemainingAllocatedHours'', NULL, ''grid'', 

''[
{id:"prjbudTDServiceItem", label:"Item/Service"},
{id:"prjbudTDCurrentBudgetHours", label:"Current Budget Hours"},
{id:"prjbudTDCurrentBudgetLaborNet", label:"Current Budget Labor Net"},
{id:"prjbudTDCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
{id:"prjbudTDCurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudTDCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudTDCurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudTDCurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudTDCurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudTDCOBudgetHours", label:"CO Budget Hours"},
{id:"prjbudTDCOBudgetLaborNet", label:"CO Budget Labor Net"},
{id:"prjbudTDCOBudgetLaborGross", label:"CO Budget Labor Gross"},
{id:"prjbudTDCOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudTDCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudTDCOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudTDCOTotalBudget", label:"CO Total Budget"},
{id:"prjbudTDCOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudTDOriginalBudgetHours", label:"Original Budget Hours"},
{id:"prjbudTDOriginalBudgetLaborNet", label:"Original Budget Labor Net"},
{id:"prjbudTDOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
{id:"prjbudTDOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudTDOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudTDOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudTDOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudTDOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudTDHours", label:"Act Hours"},
{id:"prjbudTDHoursBilled", label:"Hours Billed"},
{id:"prjbudTDHoursInvoiced", label:"Hours Invoiced"},
{id:"prjbudTDHoursUnbilled", label:"Hours Unbilled"},
{id:"prjbudTDLaborNet", label:"Labor Net"},
{id:"prjbudTDLaborGross", label:"Labor Gross"},
{id:"prjbudTDLaborBilled", label:"Labor Billed"},
{id:"prjbudTDLaborInvoiced", label:"Labor Invoiced"},
{id:"prjbudTDLaborUnbilled", label:"Labor Unbilled"},
{id:"prjbudTDLaborWriteOff", label:"Labor Write Off"},
{id:"prjbudTDOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudTDOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudTDInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudTDOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudTDOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudTDInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudTDOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudTDInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudTDOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudTDExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudTDExpenseBilled", label:"Expense Billed"},
{id:"prjbudTDExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudTDAdvanceBilled", label:"Advance Billed"},
{id:"prjbudTDAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudTDAmountBilled", label:"Amount Billed"},
{id:"prjbudTDAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudTDTotalCostsNet", label:"Total Costs Net"},
{id:"prjbudTDTotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudTDTotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudTDTotalNet", label:"Total Net"},
{id:"prjbudTDTotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudTDTotalGross", label:"Total Gross"},
{id:"prjbudTDTotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudTDRemainingAllocatedHours", label:"Remaining Allocated Hours"},
{id:"prjbudTDAllocatedHours", label:"Allocated Hours"},
{id:"prjbudTDPAllocated", label:"Percentage of Allocated"},
{id:"prjbudTDFutureAllocatedHours", label:"Future Allocated Hours"},
{id:"prjbudTDFutureLaborGrossRemaining", label:"Future Labor Gross Remaining"},
{id:"prjbudTDAllocatedGross", label:"Allocated Gross"},
{id:"prjbudTDFutureAllocatedGross", label:"Future Allocated Gross"},
{id:"prjbudTDHoursBilledRemaining", label:"Hours Billed Remaining"},
{id:"prjbudTDHoursBilledRemainingP", label:"Hours Billed Remaining %"},
{id:"prjbudTDHoursRemaining", label:"Hours Remaining"},
{id:"prjbudTDHoursRemainingP", label:"Hours Remaining %"},
{id:"prjbudTDLaborNetRemaining", label:"Labor Net Remaining"},
{id:"prjbudTDLaborNetRemainingP", label:"Labor Net Remaining %"},
{id:"prjbudTDLaborGrossRemaining", label:"Labor Gross Remaining"},
{id:"prjbudTDLaborGrossRemainingP", label:"Labor Gross Remaining %"},
{id:"prjbudTDCostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudTDCostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudTDCostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudTDCostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudTDToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudTDToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudTDGrossRemaining", label:"Gross Remaining"},
{id:"prjbudTDGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudTDBilledDifference", label:"Billed Difference"},
{id:"prjbudTDTransferInLabor", label:"Transfer In Labor"},
{id:"prjbudTDTransferOutLabor", label:"Transfer Out Labor"},
{id:"prjbudTDTransferInExpense", label:"Transfer In Expense"},
{id:"prjbudTDTransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudTDVarianceHours", label:"Variance Hours"},
{id:"prjbudTDSalesTax", label:"Sales Tax"},
{id:"prjbudTDHoursWriteOff", label:"Hours WriteOff"},
{id:"prjbudTDHoursAfterWriteOff", label:"Hours After WriteOff"},
{id:"prjbudTDLaborAfterWriteOff", label:"Labor After WriteOff"},
{id:"prjbudTDHoursAfterWriteOffRemaining", label:"Hours After WriteOff Remaining"},
{id:"prjbudTDHoursAfterWriteOffRemainingP", label:"Hours After WriteOff Remaining %"},
{id:"prjbudTDLaborGrossAfterWriteOffRemaining", label:"Labor Gross After WriteOff Remaining"},
{id:"prjbudTDLaborGrossAfterWriteOffRemainingP", label:"Labor Gross After WriteOff Remaining %"},
{id:"prjbudTDTotalCostsGrossAfterWriteOff", label:"Total Costs Gross After WriteOff w Open Orders"},
{id:"prjbudTDTotalCostsGrossAfterWriteOffNoOrder", label:"Total Costs Gross After WriteOff w/o Open Orders"},
{id:"prjbudTDCostsGrossAfterWriteOffRemaining", label:"Costs Gross After WriteOff Remaining"},
{id:"prjbudTDCostsGrossAfterWriteOffRemainingP", label:"Costs Gross After WriteOff Remaining %"},
{id:"prjbudTDCostsGrossAfterWriteOffNoOrderRemaining", label:"Costs Gross After WriteOff wo Order Remaining"},
{id:"prjbudTDCostsGrossAfterWriteOffNoOrderRemainingP", label:"Costs Gross After WriteOff wo Order Remaining %"},
{id:"prjbudTDTotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref) 
Values (''prjbudgetSettings'', ''H_BY_TITLE'', 17, ''BY TITLE'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL, ''UseBillingTitles'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref)
Values (''prjbudgetSettings'', ''ScheduleLockedColumns4'', 18, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL, ''UseBillingTitles'')



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref) 
Values (''prjbudgetSettings'', ''HTITLE1'', 19, ''Labor Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL, ''UseBillingTitles'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1, TransPref) 
Values (''prjbudgetSettings'', ''grdProjectBudgetTitleCols'', 20, ''Columns'', ''prjbudBTCurrentBudgetHours,prjbudBTCurrentTotalBudget,prjbudBTHours,prjbudBTLaborGross,prjbudBTTotalGross,prjbudBTRemainingAllocatedHours'', NULL, ''grid'', 

''[
{id:"prjbudBTCurrentBudgetHours", label:"Current Budget Hours"},
{id:"prjbudBTCurrentBudgetLaborNet", label:"Current Budget Labor Net"},
{id:"prjbudBTCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
{id:"prjbudBTCurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudBTCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudBTCurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudBTCurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudBTCurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudBTCOBudgetHours", label:"CO Budget Hours"},
{id:"prjbudBTCOBudgetLaborNet", label:"CO Budget Labor Net"},
{id:"prjbudBTCOBudgetLaborGross", label:"CO Budget Labor Gross"},
{id:"prjbudBTCOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudBTCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudBTCOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudBTCOTotalBudget", label:"CO Total Budget"},
{id:"prjbudBTCOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudBTOriginalBudgetHours", label:"Original Budget Hours"},
{id:"prjbudBTOriginalBudgetLaborNet", label:"Original Budget Labor Net"},
{id:"prjbudBTOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
{id:"prjbudBTOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudBTOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudBTOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudBTOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudBTOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudBTHours", label:"Act Hours"},
{id:"prjbudBTHoursBilled", label:"Hours Billed"},
{id:"prjbudBTHoursInvoiced", label:"Hours Invoiced"},
{id:"prjbudBTHoursUnbilled", label:"Hours Unbilled"},
{id:"prjbudBTLaborNet", label:"Labor Net"},
{id:"prjbudBTLaborGross", label:"Labor Gross"},
{id:"prjbudBTLaborBilled", label:"Labor Billed"},
{id:"prjbudBTLaborInvoiced", label:"Labor Invoiced"},
{id:"prjbudBTLaborUnbilled", label:"Labor Unbilled"},
{id:"prjbudBTLaborWriteOff", label:"Labor Write Off"},
{id:"prjbudBTOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudBTOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudBTInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudBTOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudBTOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudBTInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudBTOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudBTInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudBTOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudBTExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudBTExpenseBilled", label:"Expense Billed"},
{id:"prjbudBTExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudBTAdvanceBilled", label:"Advance Billed"},
{id:"prjbudBTAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudBTAmountBilled", label:"Amount Billed"},
{id:"prjbudBTAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudBTTotalCostsNet", label:"Total Costs Net"},
{id:"prjbudBTTotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudBTTotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudBTTotalNet", label:"Total Net"},
{id:"prjbudBTTotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudBTTotalGross", label:"Total Gross"},
{id:"prjbudBTTotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudBTRemainingAllocatedHours", label:"Remaining Allocated Hours"},
{id:"prjbudBTAllocatedHours", label:"Allocated Hours"},
{id:"prjbudBTFutureAllocatedHours", label:"Future Allocated Hours"},
{id:"prjbudBTFutureLaborGrossRemaining", label:"Future Labor Gross Remaining"},
{id:"prjbudBTAllocatedGross", label:"Allocated Gross"},
{id:"prjbudBTPAllocated", label:"Percentage of Allocated"},
{id:"prjbudBTFutureAllocatedGross", label:"Future Allocated Gross"},
{id:"prjbudBTHoursBilledRemaining", label:"Hours Billed Remaining"},
{id:"prjbudBTHoursBilledRemainingP", label:"Hours Billed Remaining %"},
{id:"prjbudBTHoursRemaining", label:"Hours Remaining"},
{id:"prjbudBTHoursRemainingP", label:"Hours Remaining %"},
{id:"prjbudBTLaborNetRemaining", label:"Labor Net Remaining"},
{id:"prjbudBTLaborNetRemainingP", label:"Labor Net Remaining %"},
{id:"prjbudBTLaborGrossRemaining", label:"Labor Gross Remaining"},
{id:"prjbudBTLaborGrossRemainingP", label:"Labor Gross Remaining %"},
{id:"prjbudBTCostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudBTCostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudBTCostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudBTCostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudBTToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudBTToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudBTGrossRemaining", label:"Gross Remaining"},
{id:"prjbudBTGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudBTBilledDifference", label:"Billed Difference"},
{id:"prjbudBTTransferInLabor", label:"Transfer In Labor"},
{id:"prjbudBTTransferOutLabor", label:"Transfer Out Labor"},
{id:"prjbudBTTransferInExpense", label:"Transfer In Expense"},
{id:"prjbudBTTransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudBTVarianceHours", label:"Variance Hours"},
{id:"prjbudBTSalesTax", label:"Sales Tax"},
{id:"prjbudBTHoursWriteOff", label:"Hours WriteOff"},
{id:"prjbudBTHoursAfterWriteOff", label:"Hours After WriteOff"},
{id:"prjbudBTLaborAfterWriteOff", label:"Labor After WriteOff"},
{id:"prjbudBTHoursAfterWriteOffRemaining", label:"Hours After WriteOff Remaining"},
{id:"prjbudBTHoursAfterWriteOffRemainingP", label:"Hours After WriteOff Remaining %"},
{id:"prjbudBTLaborGrossAfterWriteOffRemaining", label:"Labor Gross After WriteOff Remaining"},
{id:"prjbudBTLaborGrossAfterWriteOffRemainingP", label:"Labor Gross After WriteOff Remaining %"},
{id:"prjbudBTTotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL, ''UseBillingTitles'')



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref) 
Values (''prjbudgetSettings'', ''HTITLE2'', 21, ''Expense Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL, ''UseBillingTitles'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1, TransPref) 
Values (''prjbudgetSettings'', ''grdProjectBudgetItem2Cols'', 22, ''Columns'', ''prjbudBTICurrentTotalBudget,prjbudBTITotalGross'', NULL, ''grid'', 

''[
{id:"prjbudBTICurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudBTICurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudBTICurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudBTICurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudBTICurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudBTICOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudBTICOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudBTICOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudBTICOTotalBudget", label:"CO Total Budget"},
{id:"prjbudBTICOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudBTIOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudBTIOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudBTIOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudBTIOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudBTIOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudBTIOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudBTIOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudBTIInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudBTIOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudBTIOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudBTIInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudBTIOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudBTIInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudBTIOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudBTIExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudBTIExpenseBilled", label:"Expense Billed"},
{id:"prjbudBTIExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudBTIAdvanceBilled", label:"Advance Billed"},
{id:"prjbudBTIAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudBTIAmountBilled", label:"Amount Billed"},
{id:"prjbudBTIAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudBTITotalCostsNet", label:"Total Costs Net"},
{id:"prjbudBTITotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudBTITotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudBTITotalNet", label:"Total Net"},
{id:"prjbudBTITotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudBTITotalGross", label:"Total Gross"},
{id:"prjbudBTITotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudBTICostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudBTICostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudBTICostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudBTICostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudBTIToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudBTIToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudBTIGrossRemaining", label:"Gross Remaining"},
{id:"prjbudBTIGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudBTIBilledDifference", label:"Billed Difference"},
{id:"prjbudBTITransferInExpense", label:"Transfer In Expense"},
{id:"prjbudBTITransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudBTISalesTax", label:"Sales Tax"},
{id:"prjbudBTITotalCostsGrossAfterWriteOff", label:"Total Costs Gross After WriteOff w Open Orders"},
{id:"prjbudBTITotalCostsGrossAfterWriteOffNoOrder", label:"Total Costs Gross After WriteOff w/o Open Orders"},
{id:"prjbudBTICostsGrossAfterWriteOffRemaining", label:"Costs Gross After WriteOff Remaining"},
{id:"prjbudBTICostsGrossAfterWriteOffRemainingP", label:"Costs Gross After WriteOff Remaining %"},
{id:"prjbudBTICostsGrossAfterWriteOffNoOrderRemaining", label:"Costs Gross After WriteOff wo Order Remaining"},
{id:"prjbudBTICostsGrossAfterWriteOffNoOrderRemainingP", label:"Costs Gross After WriteOff wo Order Remaining %"},
{id:"prjbudBTITotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL, ''UseBillingTitles'')



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''H_BY_PERSON'', 23, ''BY PERSON'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''prjbudgetSettings'', ''ScheduleLockedColumns5'', 24, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''HPERSON1'', 25, ''Labor Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetSettings'', ''grdProjectBudgetPersonCols'',26, ''Columns'', ''prjbudPCurrentBudgetHours,prjbudPCurrentTotalBudget,prjbudPHours,prjbudPLaborGross,prjbudPTotalGross,prjbudPRemainingAllocatedHours'', NULL, ''grid'', 

''[
{id:"prjbudPCurrentBudgetHours", label:"Current Budget Hours"},
{id:"prjbudPCurrentBudgetLaborNet", label:"Current Budget Labor Net"},
{id:"prjbudPCurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
{id:"prjbudPCurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudPCurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudPCurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudPCurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudPCurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudPCOBudgetHours", label:"CO Budget Hours"},
{id:"prjbudPCOBudgetLaborNet", label:"CO Budget Labor Net"},
{id:"prjbudPCOBudgetLaborGross", label:"CO Budget Labor Gross"},
{id:"prjbudPCOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudPCOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudPCOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudPCOTotalBudget", label:"CO Total Budget"},
{id:"prjbudPCOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudPOriginalBudgetHours", label:"Original Budget Hours"},
{id:"prjbudPOriginalBudgetLaborNet", label:"Original Budget Labor Net"},
{id:"prjbudPOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
{id:"prjbudPOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudPOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudPOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudPOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudPOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudPHours", label:"Act Hours"},
{id:"prjbudPHoursBilled", label:"Hours Billed"},
{id:"prjbudPHoursInvoiced", label:"Hours Invoiced"},
{id:"prjbudPHoursUnbilled", label:"Hours Unbilled"},
{id:"prjbudPLaborNet", label:"Labor Net"},
{id:"prjbudPLaborGross", label:"Labor Gross"},
{id:"prjbudPLaborBilled", label:"Labor Billed"},
{id:"prjbudPLaborInvoiced", label:"Labor Invoiced"},
{id:"prjbudPLaborUnbilled", label:"Labor Unbilled"},
{id:"prjbudPLaborWriteOff", label:"Labor Write Off"},
{id:"prjbudPOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudPOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudPInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudPOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudPOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudPInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudPOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudPInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudPOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudPExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudPExpenseBilled", label:"Expense Billed"},
{id:"prjbudPExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudPAdvanceBilled", label:"Advance Billed"},
{id:"prjbudPAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudPAmountBilled", label:"Amount Billed"},
{id:"prjbudPAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudPTotalCostsNet", label:"Total Costs Net"},
{id:"prjbudPTotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudPTotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudPTotalNet", label:"Total Net"},
{id:"prjbudPTotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudPTotalGross", label:"Total Gross"},
{id:"prjbudPTotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudPRemainingAllocatedHours", label:"Remaining Allocated Hours"},
{id:"prjbudPAllocatedHours", label:"Allocated Hours"},
{id:"prjbudPPAllocated", label:"Percentage of Allocated"},
{id:"prjbudPFutureAllocatedHours", label:"Future Allocated Hours"},
{id:"prjbudPAllocatedGross", label:"Allocated Gross"},
{id:"prjbudPFutureAllocatedGross", label:"Future Allocated Gross"},
{id:"prjbudPFutureLaborGrossRemaining", label:"Future Labor Gross Remaining"},
{id:"prjbudPHoursBilledRemaining", label:"Hours Billed Remaining"},
{id:"prjbudPHoursBilledRemainingP", label:"Hours Billed Remaining %"},
{id:"prjbudPHoursRemaining", label:"Hours Remaining"},
{id:"prjbudPHoursRemainingP", label:"Hours Remaining %"},
{id:"prjbudPLaborNetRemaining", label:"Labor Net Remaining"},
{id:"prjbudPLaborNetRemainingP", label:"Labor Net Remaining %"},
{id:"prjbudPLaborGrossRemaining", label:"Labor Gross Remaining"},
{id:"prjbudPLaborGrossRemainingP", label:"Labor Gross Remaining %"},
{id:"prjbudPCostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudPCostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudPCostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudPCostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudPToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudPToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudPGrossRemaining", label:"Gross Remaining"},
{id:"prjbudPGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudPBilledDifference", label:"Billed Difference"},
{id:"prjbudPTransferInLabor", label:"Transfer In Labor"},
{id:"prjbudPTransferOutLabor", label:"Transfer Out Labor"},
{id:"prjbudPTransferInExpense", label:"Transfer In Expense"},
{id:"prjbudPTransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudPVarianceHours", label:"Variance Hours"},
{id:"prjbudPSalesTax", label:"Sales Tax"},
{id:"prjbudPHoursWriteOff", label:"Hours WriteOff"},
{id:"prjbudPHoursAfterWriteOff", label:"Hours After WriteOff"},
{id:"prjbudPLaborAfterWriteOff", label:"Labor After WriteOff"},
{id:"prjbudPHoursAfterWriteOffRemaining", label:"Hours After WriteOff Remaining"},
{id:"prjbudPHoursAfterWriteOffRemainingP", label:"Hours After WriteOff Remaining %"},
{id:"prjbudPLaborGrossAfterWriteOffRemaining", label:"Labor Gross After WriteOff Remaining"},
{id:"prjbudPLaborGrossAfterWriteOffRemainingP", label:"Labor Gross After WriteOff Remaining %"},
{id:"prjbudPTotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetSettings'', ''HPERSON2'', 27, ''Expense Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetSettings'', ''grdProjectBudgetItem3Cols'', 28, ''Columns'', ''prjbudPICurrentTotalBudget,prjbudPITotalGross,prjbudPIRemainingAllocatedHours'', NULL, ''grid'', 

''[
{id:"prjbudPICurrentBudgetHours", label:"Current Budget Hours"},
{id:"prjbudPICurrentBudgetLaborNet", label:"Current Budget Labor Net"},
{id:"prjbudPICurrentBudgetLaborGross", label:"Current Budget Labor Gross"},
{id:"prjbudPICurrentBudgetExpenseNet", label:"Current Budget Expense Net"},
{id:"prjbudPICurrentBudgetExpenseGross", label:"Current Budget Expense Gross"},
{id:"prjbudPICurrentBudgetContingency", label:"Current Budget Contingency"},
{id:"prjbudPICurrentTotalBudget", label:"Current Total Budget"},
{id:"prjbudPICurrentTotalBudgetCont", label:"Current Total Budget Cont"},
{id:"prjbudPICOBudgetHours", label:"CO Budget Hours"},
{id:"prjbudPICOBudgetLaborNet", label:"CO Budget Labor Net"},
{id:"prjbudPICOBudgetLaborGross", label:"CO Budget Labor Gross"},
{id:"prjbudPICOBudgetExpenseNet", label:"CO Budget Expense Net"},
{id:"prjbudPICOBudgetExpenseGross", label:"CO Budget Expense Gross"},
{id:"prjbudPICOBudgetContingency", label:"CO Budget Contingency"},
{id:"prjbudPICOTotalBudget", label:"CO Total Budget"},
{id:"prjbudPICOTotalBudgetCont", label:"CO Total Budget Cont"},
{id:"prjbudPIOriginalBudgetHours", label:"Original Budget Hours"},
{id:"prjbudPIOriginalBudgetLaborNet", label:"Original Budget Labor Net"},
{id:"prjbudPIOriginalBudgetLaborGross", label:"Original Budget Labor Gross"},
{id:"prjbudPIOriginalBudgetExpenseNet", label:"Original Budget Expense Net"},
{id:"prjbudPIOriginalBudgetExpenseGross", label:"Original Budget Expense Gross"},
{id:"prjbudPIOriginalBudgetContingency", label:"Original Budget Contingency"},
{id:"prjbudPIOriginalTotalBudget", label:"Original Total Budget"},
{id:"prjbudPIOriginalTotalBudgetCont", label:"Original Total Budget Cont"},
{id:"prjbudPIHours", label:"Act Hours"},
{id:"prjbudPIHoursBilled", label:"Hours Billed"},
{id:"prjbudPIHoursInvoiced", label:"Hours Invoiced"},
{id:"prjbudPIHoursUnbilled", label:"Hours Unbilled"},
{id:"prjbudPILaborNet", label:"Labor Net"},
{id:"prjbudPILaborGross", label:"Labor Gross"},
{id:"prjbudPILaborBilled", label:"Labor Billed"},
{id:"prjbudPILaborInvoiced", label:"Labor Invoiced"},
{id:"prjbudPILaborUnbilled", label:"Labor Unbilled"},
{id:"prjbudPILaborWriteOff", label:"Labor Write Off"},
{id:"prjbudPIOpenOrdersNet", label:"Open Orders Net"},
{id:"prjbudPIOutsideCostsNet", label:"Outside Costs Net"},
{id:"prjbudPIInsideCostsNet", label:"Inside Costs Net"},
{id:"prjbudPIOpenOrdersGrossUnbilled", label:"Open Orders Gross Unbilled"},
{id:"prjbudPIOutsideCostsGrossUnbilled", label:"Outside Costs Gross Unbilled"},
{id:"prjbudPIInsideCostsGrossUnbilled", label:"Inside Costs Gross Unbilled"},
{id:"prjbudPIOutsideCostsGross", label:"Outside Costs Gross"},
{id:"prjbudPIInsideCostsGross", label:"Inside Costs Gross"},
{id:"prjbudPIOrderPrebilled", label:"Order Prebilled"},
{id:"prjbudPIExpenseWriteOff", label:"Expense Write Off"},
{id:"prjbudPIExpenseBilled", label:"Expense Billed"},
{id:"prjbudPIExpenseInvoiced", label:"Expense Invoiced"},
{id:"prjbudPIAdvanceBilled", label:"Advance Billed"},
{id:"prjbudPIAdvanceBilledOpen", label:"Advance Billed Open"},
{id:"prjbudPIAmountBilled", label:"Amount Billed"},
{id:"prjbudPIAmountBilledNoTax", label:"Amount Billed No Tax"},
{id:"prjbudPITotalCostsNet", label:"Total Costs Net"},
{id:"prjbudPITotalCostsGrossUnbilled", label:"Total Costs Gross Unbilled"},
{id:"prjbudPITotalCostsGross", label:"Total Costs Gross"},
{id:"prjbudPITotalNet", label:"Total Net"},
{id:"prjbudPITotalGrossUnbilled", label:"Total Gross Unbilled"},
{id:"prjbudPITotalGross", label:"Total Gross"},
{id:"prjbudPITotalGrossAfterWriteOff", label:"Total Gross After Write Off"},
{id:"prjbudPICostsNetRemaining", label:"Costs Net Remaining"},
{id:"prjbudPICostsNetRemainingP", label:"Costs Net Remaining %"},
{id:"prjbudPICostsGrossRemaining", label:"Costs Gross Remaining"},
{id:"prjbudPICostsGrossRemainingP", label:"Costs Gross Remaining %"},
{id:"prjbudPIToBillRemaining", label:"To Bill Remaining"},
{id:"prjbudPIToBillRemainingP", label:"To Bill Remaining %"},
{id:"prjbudPIGrossRemaining", label:"Gross Remaining"},
{id:"prjbudPIGrossRemainingP", label:"Gross Remaining %"},
{id:"prjbudPIBilledDifference", label:"Billed Difference"},
{id:"prjbudPITransferInLabor", label:"Transfer In Labor"},
{id:"prjbudPITransferOutLabor", label:"Transfer Out Labor"},
{id:"prjbudPITransferInExpense", label:"Transfer In Expense"},
{id:"prjbudPITransferOutExpense", label:"Transfer Out Expense"},
{id:"prjbudPIVarianceHours", label:"Variance Hours"},
{id:"prjbudPISalesTax", label:"Sales Tax"},
{id:"prjbudPITotalCostsGrossAfterWriteOff", label:"Total Costs Gross After WriteOff w Open Orders"},
{id:"prjbudPITotalCostsGrossAfterWriteOffNoOrder", label:"Total Costs Gross After WriteOff w/o Open Orders"},
{id:"prjbudPICostsGrossAfterWriteOffRemaining", label:"Costs Gross After WriteOff Remaining"},
{id:"prjbudPICostsGrossAfterWriteOffRemainingP", label:"Costs Gross After WriteOff Remaining %"},
{id:"prjbudPICostsGrossAfterWriteOffNoOrderRemaining", label:"Costs Gross After WriteOff wo Order Remaining"},
{id:"prjbudPICostsGrossAfterWriteOffNoOrderRemainingP", label:"Costs Gross After WriteOff wo Order Remaining %"},
{id:"prjbudPITotalGrossUnbilledFixedFee", label:"Total Gross Unbilled Fixed Fee"}
]''
	 , NULL, NULL, null, NULL)


/*Drill Down for Invoices Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetInvoices'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetInvoices'', ''DDInvoices'', 1, ''Invoice Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetInvoices'', ''grdBudgetDDInvoices'', 2, ''Columns'', ''prjbudDDBInvoiceNumber,prjbudDDBCustomerID,prjbudDDBInvoiceDate,prjbudDDBLineSubject,prjbudDDBAmount,prjbudDDBSalesTaxAmount,prjbudDDBTotalAmount,prjbudDDBTaskName,prjbudDDBItemName,prjbudDDBAppliedAmount'', NULL, ''grid'', 
''[
{id:"prjbudDDBInvoiceNumber",label:"Invoice Number"},
{id:"prjbudDDBCustomerID",label:"Customer ID"},
{id:"prjbudDDBInvoiceDate",label:"Invoice Date"},
{id:"prjbudDDBLineSubject",label:"Line Subject"},
{id:"prjbudDDBAmount",label:"Amount"},
{id:"prjbudDDBSalesTaxAmount",label:"Sales Tax Amount"},
{id:"prjbudDDBTotalAmount",label:"Total Amount"},
{id:"prjbudDDBTaskName",label:"Task Name"},
{id:"prjbudDDBItemName",label:"Item Name"},
{id:"prjbudDDBAppliedAmount", label:"Unapplied Amount"}
]''
, NULL, NULL, NULL, NULL)
 
/*Drill Down for Estimates Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetEstimates'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetEstimates'', ''DDEstimates'',1, ''Estimate Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetEstimates'', ''grdBudgetDDEstimates'',2, ''Columns'', ''prjbudDDEEstimateName,prjbudDDEEstimateDate,prjbudDDETaskName,prjbudDDEItemName,prjbudDDEHours,prjbudDDELaborNet,prjbudDDELaborGross,prjbudDDEQuantity,prjbudDDEExpenseNet,prjbudDDEExpenseGross,prjbudDDETotalBudget,prjbudDDEContingency,prjbudDDETotalBudgetCont,prjbudDDESalesTaxAmount,prjbudDDEVendorName'', NULL, ''grid'', 
''[
{id:"prjbudDDEEstimateName", label:"Estimate Name"},
{id:"prjbudDDEEstimateDate", label:"Estimate Date"},
{id:"prjbudDDETaskName", label:"Task Name"},
{id:"prjbudDDEItemName", label:"Item Name"},
{id:"prjbudDDEHours", label:"Hours"},
{id:"prjbudDDELaborNet", label:"Labor Net"},
{id:"prjbudDDELaborGross", label:"Labor Gross"},
{id:"prjbudDDEQuantity", label:"Quantity"},
{id:"prjbudDDEExpenseNet", label:"Expense Net"},
{id:"prjbudDDEExpenseGross", label:"Expense Gross"},
{id:"prjbudDDETotalBudget", label:"Total Budget"},
{id:"prjbudDDEContingency", label:"Contingency"},
{id:"prjbudDDETotalBudgetCont", label:"Total Budget Cont"},
{id:"prjbudDDESalesTaxAmount", label:"Sales Tax Amount"},
{id:"prjbudDDEVendorID", label:"Vendor ID"},
{id:"prjbudDDEVendorFullName", label:"Vendor Full Name"},
{id:"prjbudDDEVendorName", label:"Vendor Name"}
]''
 , NULL, NULL, NULL, NULL)

/*Drill Down for Gerneral Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetGeneral'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetGeneral'', ''DDGeneral'', 1, ''General Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetGeneral'', ''grdBudgetDDGeneral'', 2, ''Columns'', ''prjbudDDGTransactionType,prjbudDDGTransactionDate,prjbudDDGVendorID,prjbudDDGNumber,prjbudDDGDescription,prjbudDDGQuantity,prjbudDDGNetExp,prjbudDDGNetLabor,prjbudDDGGross,prjbudDDGGross2,prjbudDDGGross3,prjbudDDGTaskName,prjbudDDGItemName,prjbudDDGTitleName,prjbudDDGVendorName'', NULL, ''grid'', 
''[
{id:"prjbudDDGTransactionType", label:"Transaction Type"},
{id:"prjbudDDGTransactionDate", label:"Transaction Date"},
{id:"prjbudDDGVendorID", label:"Vendor ID"},
{id:"prjbudDDGNumber", label:"Number"},
{id:"prjbudDDGDescription", label:"Description"},
{id:"prjbudDDGQuantity", label:"Quantity"},
{id:"prjbudDDGNetExp", label:"Net Exp"},
{id:"prjbudDDGNetLabor", label:"Net Labor"},
{id:"prjbudDDGGross", label:"Total Gross"},
{id:"prjbudDDGGross2", label:"Gross"},
{id:"prjbudDDGGross3", label:"Billed"},
{id:"prjbudDDGTaskName", label:"Task Name"},
{id:"prjbudDDGItemName", label:"Item Name"},
{id:"prjbudDDGTitleName", label:"Title Name"},
{id:"prjbudDDGVendorFullName", label:"Vendor Full Name"},
{id:"prjbudDDGVendorName", label:"Vendor Name"},
]''
	 , NULL, NULL, NULL, NULL)
	 
/*Drill Down for Labor Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetLabor'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetLabor'', ''DDLabor'',1, ''Labor Settings'', NULL,NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetLabor'', ''grdBudgetDDLabor'', 2, ''Columns'', ''prjbudDDUserName,prjbudDDWorkDate,prjbudDDActualHours,prjbudDDHoursBilled,prjbudDDCostRate,prjbudDDActualRate,prjbudDDLaborNet,prjbudDDLaborGross,prjbudDDLaborBilled,prjbudDDDateBilled,prjbudDDInvoiceNumber,prjbudDDWriteOff,prjbudDDTaskName,prjbudDDServiceDescription,prjbudDDTitleDescription,prjbudDDDescription'', NULL, ''grid'', 
''[
{id:"prjbudDDUserName",label:"User Name"},
{id:"prjbudDDWorkDate",label:"Work Date"},
{id:"prjbudDDActualHours",label:"Actual Hours"},
{id:"prjbudDDHoursBilled",label:"Hours Billed"},
{id:"prjbudDDCostRate",label:"Cost Rate"},
{id:"prjbudDDActualRate",label:"Actual Rate"},
{id:"prjbudDDLaborNet",label:"Labor Net"},
{id:"prjbudDDLaborGross",label:"Labor Gross"},
{id:"prjbudDDLaborBilled",label:"Labor Billed"},
{id:"prjbudDDDateBilled",label:"Date Billed"},
{id:"prjbudDDInvoiceNumber",label:"Invoice Number"},
{id:"prjbudDDWriteOff",label:"Write Off"},
{id:"prjbudDDTaskName",label:"Task Name"},
{id:"prjbudDDServiceDescription",label:"Service Description"},
{id:"prjbudDDTitleDescription",label:"Title Description"},
{id:"prjbudDDDescription",label:"Description"}
]''
	 , NULL, NULL, NULL, NULL)

/*Drill Down for Expense Writeoff Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetExpense'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetExpense'', ''DDExpenseWriteOff'', 1, ''Expense Settings'', NULL,NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetExpense'', ''grdBudgetDDExpenseWriteOff'', 2, ''Columns'', ''prjbudDDWOTransactionType,prjbudDDWOUserName,prjbudDDWOExpenseDate,prjbudDDWOQuantity,prjbudDDWOUnitCost,prjbudDDWOTotalCost,prjbudDDWOBillableCost,prjbudDDWOAmountBilled,prjbudDDWODateBilled,prjbudDDWOWriteOff,prjbudDDWOTaskName,prjbudDDWOItemName,prjbudDDWODescription,prjbudDDWOHeaderNumber,prjbudDDWOVendorID,prjbudDDWOPurchaseOrderNumber,prjbudDDWOVendorInvoiceNumber,prjbudDDWOVendorName,prjbudDDWOVendorFullName'', NULL, ''grid'', 
''[
{id:"prjbudDDWOTransactionType", label:"Transaction Type"},
{id:"prjbudDDWOUserName", label:"User Name"},
{id:"prjbudDDWOExpenseDate", label:"Expense Date"},
{id:"prjbudDDWOQuantity", label:"Quantity"},
{id:"prjbudDDWOUnitCost", label:"Unit Cost"},
{id:"prjbudDDWOTotalCost", label:"Total Cost"},
{id:"prjbudDDWOBillableCost", label:"Billable Cost"},
{id:"prjbudDDWOAmountBilled", label:"Amount Billed"},
{id:"prjbudDDWODateBilled", label:"Date Billed"},
{id:"prjbudDDWOWriteOff", label:"Write Off"},
{id:"prjbudDDWOTaskName", label:"Task Name"},
{id:"prjbudDDWOItemName", label:"Item Name"},
{id:"prjbudDDWODescription", label:"Description"},
{id:"prjbudDDWOHeaderNumber", label:"Header Number"},
{id:"prjbudDDWOVendorID", label:"Vendor ID"},
{id:"prjbudDDWOPurchaseOrderNumber", label:"Purchase Order Number"},
{id:"prjbudDDWOVendorInvoiceNumber", label:"Vendor Invoice Number"},
{id:"prjbudDDWOVendorName", label:"Vendor Name"},
{id:"prjbudDDWOVendorFullName", label:"Vendor Full Name"},
]''
	 , NULL, NULL, NULL, NULL)
               
/*Drill Down for Advance Bill Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetAdvanceBilledOpen'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetAdvanceBilledOpen'', ''DDAdvanceBill'', 1, ''Advance Bill Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetAdvanceBilledOpen'', ''grdBudgetDDAdvanceBill'', 2, ''Columns'', ''prjbudDDABInvoiceNumber,prjbudDDABCustomerID,prjbudDDABInvoiceDate,prjbudDDABInvoiceTotalAmount,prjbudDDABAppliedAmount'', NULL, ''grid'', 
''[
{id:"prjbudDDABInvoiceNumber", label:"Invoice Number"},
{id:"prjbudDDABCustomerID", label:"Customer ID"},
{id:"prjbudDDABInvoiceDate", label:"Invoice Date"},
{id:"prjbudDDABInvoiceTotalAmount", label:"Invoice Total Amount"},
{id:"prjbudDDABAppliedAmount", label:"Unapplied Amount"}
]''
 , NULL, NULL, NULL, NULL)

/*Drill Down for Inside Costs Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetInsideCosts'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetInsideCosts'', ''DDInsideCosts'', 1, ''Inside Costs Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetInsideCosts'', ''grdBudgetDDInsideCosts'', 2, ''Columns'', ''prjbudDDICTransactionType,prjbudDDICUserName,prjbudDDICExpenseDate,prjbudDDICQuantity,prjbudDDICUnitCost,prjbudDDICTotalCost,prjbudDDICBillableCost,prjbudDDICAmountBilled,prjbudDDICDateBilled,prjbudDDICInvoiceNumber,prjbudDDICWriteOff,prjbudDDICTaskName,prjbudDDICItemName,prjbudDDICDescription,prjbudDDICVendorID,prjbudDDICPurchaseOrderNumber,prjbudDDICVendorInvoiceNumber,prjbudDDICVendorName,prjbudDDICVendorFullName'', NULL, ''grid'', 
''[
{id:"prjbudDDICTransactionType", label:"Transaction Type"},
{id:"prjbudDDICUserName", label:"User Name"},
{id:"prjbudDDICExpenseDate", label:"Expense Date"},
{id:"prjbudDDICQuantity", label:"Quantity"},
{id:"prjbudDDICUnitCost", label:"Unit Cost"},
{id:"prjbudDDICTotalCost", label:"Total Cost"},
{id:"prjbudDDICBillableCost", label:"Billable Cost"},
{id:"prjbudDDICAmountBilled", label:"Amount Billed"},
{id:"prjbudDDICDateBilled", label:"Date Billed"},
{id:"prjbudDDICInvoiceNumber", label:"Invoice Number"},
{id:"prjbudDDICWriteOff", label:"Write Off"},
{id:"prjbudDDICTaskName", label:"Task Name"},
{id:"prjbudDDICItemName", label:"Item Name"},
{id:"prjbudDDICDescription", label:"Description"},
{id:"prjbudDDICVendorID", label:"Vendor ID"},
{id:"prjbudDDICPurchaseOrderNumber", label:"Purchase Order Number"},
{id:"prjbudDDICVendorInvoiceNumber", label:"Vendor Invoice Number"},
{id:"prjbudDDICVendorName", label:"Vendor Name"},
{id:"prjbudDDICVendorFullName", label:"Vendor Full Name"}
]''
 , NULL, NULL, NULL, NULL)

/*Drill Down for Outside Costs Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetOutsideCosts'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetOutsideCosts'', ''DDOutsideCosts'', 1, ''Outside Costs Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetOutsideCosts'', ''grdBudgetDDOutsideCosts'', 2, ''Columns'', ''prjbudDDOCTransactionType,prjbudDDOCVendorID,prjbudDDOCNumber,prjbudDDOCTransactionDate,prjbudDDOCQuantity,prjbudDDOCUnitCost,prjbudDDOCTotalCost,prjbudDDOCBillableCost,prjbudDDOCDateClosed,prjbudDDOCAmountBilled,prjbudDDOCDateBilled,prjbudDDOCInvoiceNumber,prjbudDDOCWriteOff,prjbudDDOCTaskName,prjbudDDOCItemName,prjbudDDOCDescription,prjbudDDOCVendorFullName'', NULL, ''grid'', 
''[
{id:"prjbudDDOCTransactionType", label:"Transaction Type"},
{id:"prjbudDDOCVendorID", label:"Vendor ID"},
{id:"prjbudDDOCVendorName", label:"Vendor Name"},
{id:"prjbudDDOCNumber", label:"Number"},
{id:"prjbudDDOCTransactionDate", label:"Transaction Date"},
{id:"prjbudDDOCQuantity", label:"Quantity"},
{id:"prjbudDDOCUnitCost", label:"Unit Cost"},
{id:"prjbudDDOCTotalCost", label:"Total Cost"},
{id:"prjbudDDOCBillableCost", label:"Billable Cost"},
{id:"prjbudDDOCDateClosed", label:"Date Closed"},
{id:"prjbudDDOCAmountBilled", label:"Amount Billed"},
{id:"prjbudDDOCDateBilled", label:"Date Billed"},
{id:"prjbudDDOCInvoiceNumber", label:"Invoice Number"},
{id:"prjbudDDOCWriteOff", label:"Write Off"},
{id:"prjbudDDOCTaskName", label:"Task Name"},
{id:"prjbudDDOCItemName", label:"Item Name"},
{id:"prjbudDDOCDescription", label:"Description"},
{id:"prjbudDDOCVendorFullName", label:"Vendor Full Name"}
]''
 , NULL, NULL, NULL, NULL)
 
/*Drill Down for Outside Costs2 Grid Columns*/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbudgetOutsideCosts2'', ''Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbudgetOutsideCosts2'', ''DDOutsideCosts2'', 1, ''Outside Costs Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbudgetOutsideCosts2'', ''grdBudgetDDOutsideCosts2'', 2, ''Columns'', ''prjbudDDOC2TransactionType,prjbudDDOC2VendorID,prjbudDDOC2Number,prjbudDDOC2TransactionDate,prjbudDDOC2Quantity,prjbudDDOC2UnitCost,prjbudDDOC2TotalCost,prjbudDDOC2DateClosed,prjbudDDOC2AmountBilled,prjbudDDOC2DateBilled,prjbudDDOC2InvoiceNumber,prjbudDDOC2WriteOff,prjbudDDOC2TaskName,prjbudDDOC2ItemName,prjbudDDOC2Description,prjbudDDOC2PurchaseOrderNumber,prjbudDDOC2VendorInvoiceNumber,prjbudDDOC2VendorName,prjbudDDOC2VendorFullName'', NULL, ''grid'', 
''[
{id:"prjbudDDOC2TransactionType", label:"Transaction Type"},
{id:"prjbudDDOC2VendorID", label:"Vendor ID"},
{id:"prjbudDDOC2VendorName", label:"Vendor Name"},
{id:"prjbudDDOC2Number", label:"Number"},
{id:"prjbudDDOC2TransactionDate", label:"Transaction Date"},
{id:"prjbudDDOC2Quantity", label:"Quantity"},
{id:"prjbudDDOC2UnitCost", label:"Unit Cost"},
{id:"prjbudDDOC2TotalCost", label:"Total Cost"},
{id:"prjbudDDOC2DateClosed", label:"Date Closed"},
{id:"prjbudDDOC2AmountBilled", label:"Gross/Billed"},
{id:"prjbudDDOC2DateBilled", label:"Date Billed"},
{id:"prjbudDDOC2InvoiceNumber", label:"Invoice Number"},
{id:"prjbudDDOC2WriteOff", label:"Write Off"},
{id:"prjbudDDOC2TaskName", label:"Task Name"},
{id:"prjbudDDOC2ItemName", label:"Item Name"},
{id:"prjbudDDOC2Description", label:"Description"},
{id:"prjbudDDOC2PurchaseOrderNumber", label:"Purchase Order Number"},
{id:"prjbudDDOC2VendorInvoiceNumber", label:"Vendor Invoice Number"},
{id:"prjbudDDOC2VendorFullName", label:"Vendor Full Name"}
]''
 , NULL, NULL, NULL, NULL)
 



/*************************************************************************************************************************
Project FF Billing
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectFFBilling'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''H1'', 0, ''Invoice Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''AddProjectLine'', 1, ''Add top project line'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Only valid if Invoice By = Percentage of Service / Item or Billing Item. If this is checked, a summary line with the project name will be inserted at the top.'') 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''AddTaskDetails'', 2, ''Include service and item details under each task.'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Only valid if Invoice By = Percentage of Task. If this is checked, the system will create under each task, invoice lines corresponding to services or items on estimates.'') 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''AllowZeroLines'', 3, ''Include all selected lines even if 0 dollars'', ''0'', NULL, ''checkbox'', NULL, NULL, ''If this option is checked, checked zero lines will be created. If this option is not checked, checked zero lines will not be created.'') 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''GroupByBillingItem'', 4, ''Group by billing item'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Only valid if Invoice By = Percentage of Service / Item. Similar to the the TM option: One Line Per Billing Item and Item. When creating the invoice lines, expense items are grouped by billing item.'') 

 
/*By Tasks Grid Columns*/
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''ByTaskGroup'', 5, ''Invoice By Task Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectFFBilling'', ''grdTasksCols'', 6, ''Columns'', ''colTaskEstHrs,colTaskEstLabor,colTaskEstExpenses,colTaskEstTotal,colTaskActHrs,colTaskActLabor,colTaskActExpenses,colTaskActTotal,colTaskBilled,colTaskAllBilled,colTaskRemaining'', NULL, ''grid'', 
''[
{id:"colTaskEstHrs", label:"Est Hrs"},
{id:"colTaskEstLabor", label:"Est Labor"},
{id:"colTaskEstExpenses", label:"Est Exp"},
{id:"colTaskEstTotal", label:"Est Total"},
{id:"colTaskActHrs", label:"Act Hrs"},
{id:"colTaskActLabor", label:"Act Labor"},
{id:"colTaskActExpenses", label:"Act Exp"},
{id:"colTaskActTotal", label:"Act Total"},
{id:"colTaskBilled", label:"Billed"},
{id:"colTaskAllBilled", label:"Total Billed"},
{id:"colTaskRemaining", label:"Remaining"},
{id:"colTaskActLaborNet", label:"Act Labor Net"},
{id:"colTaskActExpensesNet", label:"Act Exp Net"},
{id:"colTaskActGI", label:"Act GI"}
]''
 , NULL, NULL, NULL, NULL)

 
/*By Service Grid Columns*/
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''ByServiceGroup'', 7, ''Invoice By Service Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectFFBilling'', ''grdServicesCols'', 8, ''Columns'', ''colServiceEstHrs,colServiceEstLabor,colServiceActHrs,colServiceActLabor,colServiceBilled,colServiceAllBilled,colServiceRemaining'', NULL, ''grid'', 
''[
{id:"colServiceEstHrs", label:"Est Hrs"},
{id:"colServiceEstLabor", label:"Est Labor"},
{id:"colServiceActHrs", label:"Act Hours"},
{id:"colServiceActLabor", label:"Act Labor"},
{id:"colServiceBilled", label:"Billed"},
{id:"colServiceAllBilled", label:"Total Billed"},
{id:"colServiceRemaining", label:"Remaining"},
{id:"colServiceActLaborNet", label:"Act Labor Net"},
{id:"colServiceActGI", label:"Act GI"}
]''
 , NULL, NULL, NULL, NULL)


  
/*By Items Grid Columns*/
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''ByItemGroup'', 9, ''Invoice By Items Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectFFBilling'', ''grdItemCols'', 10, ''Columns'', ''colItemEstExpenses,colItemActExpenses,colItemBilled,colItemAllBilled,colItemRemaining'', NULL, ''grid'', 
''[
{id:"colItemEstExpenses", label:"Bill Amt"},
{id:"colItemActExpenses", label:"Act Exp"},
{id:"colItemBilled", label:"Billed"},
{id:"colItemAllBilled", label:"Total Billed"},
{id:"colItemRemaining", label:"Remaining"},
{id:"colItemActExpensesNet", label:"Act Exp Net"},
{id:"colItemActGI", label:"Act GI"}
]''
 , NULL, NULL, NULL, NULL)


 
/*By Billing Items Grid Columns*/
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectFFBilling'', ''ByBillingGroup'', 11, ''Invoice By Billing Items Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectFFBilling'', ''grdBillingItemsCols'', 12, ''Columns'', ''colBIEstHrs,colBIEstLabor,colBIEstExpenses,colBIEstTotal,colBIActHrs,colBIActLabor,colBIActExpenses,colBIActTotal,colBIBilled,colBIAllBilled,colBIRemaining'', NULL, ''grid'', 
''[
{id:"colBIEstHrs", label:"Est Hrs"},
{id:"colBIEstLabor", label:"Est Labor"},
{id:"colBIEstExpenses", label:"Est Exp"},
{id:"colBIEstTotal", label:"Est Total"},
{id:"colBIActHrs", label:"Act Hours"},
{id:"colBIActLabor", label:"Act Labor"},
{id:"colBIActExpenses", label:"Act Exp"},
{id:"colBIActTotal", label:"Act Total"},
{id:"colBIBilled", label:"Billed"},
{id:"colBIAllBilled", label:"Total Billed"},
{id:"colBIRemaining", label:"Remaining"},
{id:"colBIActLaborNet", label:"Act Labor Net"},
{id:"colBIActExpensesNet", label:"Act Exp Net"},
{id:"colBIActGI", label:"GI"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Project TM Billing transactions grids
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''prjbillTransactions'', ''Project Billing Detail Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H1'', 0, ''Unbilled Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsUnbilledCols'', 1, ''Columns'', ''prjbillxTransactionDate,prjbillxDescription,prjbillxPosted,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullNameprjbillxItemFullName,prjbillxWIPInBatch'', NULL, ''grid'', 

''[
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxWIPInBatch", label:"WIP In Batch"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"},
{id:"prjbillxAttachmentCount", label:"Attachments"},
{id:"prjbillxPosted", label:"Posted"},
{id:"prjbillxPostingDate", label:"Posting Date"}
]''
	 , NULL, NULL, null, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H2'', 2, ''Unapproved Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsUnapprovedCols'', 3, ''Columns'', ''prjbillxTransactionDate,prjbillxDescription,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName'', NULL, ''grid'', 

''[
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"},
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H3'', 4, ''Billed Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsBilledCols'', 5, ''Columns'', ''prjbillxBillingInvoiceNumber,prjbillxDateBilled,prjbillxAmountBilled,prjbillxTransactionDate,prjbillxDescription,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName,prjbillxWIPInBatch,prjbillxWIPOutBatch'', NULL, ''grid'', 

''[
{id:"prjbillxBillingInvoiceNumber", label:"Invoice Number"},
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxDateBilled", label:"Date Billed"},
{id:"prjbillxAmountBilled", label:"Amount Billed"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxWIPInBatch", label:"WIP In Batch"},
{id:"prjbillxWIPOutBatch", label:"WIP Out Batch"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H4'', 6, ''Mark as Billed Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsMABCols'', 7, ''Columns'', ''prjbillxTransactionDate,prjbillxDescription,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName,prjbillxWIPInBatch,prjbillxWIPOutBatch,prjbillxDateBilled,prjbillxAmountBilled'', NULL, ''grid'', 

''[
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxWIPInBatch", label:"WIP In Batch"},
{id:"prjbillxWIPOutBatch", label:"WIP Out Batch"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"},
{id:"prjbillxDateBilled", label:"Date Billed"},
{id:"prjbillxAmountBilled", label:"Amount Billed"}
]''
	 , NULL, NULL, null, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H5'', 8, ''Write Off Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsWOCols'', 9, ''Columns'', ''prjbillxTransactionDate,prjbillxDescription,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName,prjbillxWIPInBatch,prjbillxWIPOutBatch,prjbillxDateBilled,prjbillxWriteOffReason,prjbillxWriteOffComment'', NULL, ''grid'', 

''[
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxWIPInBatch", label:"WIP In Batch"},
{id:"prjbillxWIPOutBatch", label:"WIP Out Batch"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"},
{id:"prjbillxDateBilled", label:"Write Off Date"},
{id:"prjbillxWriteOffComment", label:"Write Off Comment"},
{id:"prjbillxWriteOffReason", label:"Write Off Reason"}
]''
	 , NULL, NULL, null, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H6'', 10, ''On Hold Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsOnHoldCols'', 11, ''Columns'', ''prjbillxTransactionDate,prjbillxDescription,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName,prjbillxWIPInBatch'', NULL, ''grid'', 

''[
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxWIPInBatch", label:"WIP In Batch"},
{id:"prjbillxWIPOutBatch", label:"WIP Out Batch"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H7'', 12, ''Transferred Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsTransferredCols'', 13, ''Columns'', ''prjbillxTransactionDate,prjbillxDescription,prjbillxTransferInDate,prjbillxTransferOutDate,prjbillxTransferComment,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName'', NULL, ''grid'', 

''[
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxWIPInBatch", label:"WIP In Batch"},
{id:"prjbillxWIPOutBatch", label:"WIP Out Batch"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"},
{id:"prjbillxTransferOutDate", label:"Transfer Out Date"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''prjbillTransactions'', ''H8'', 14, ''Adjusted Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''prjbillTransactions'', ''grdbillTransactionsAdjustedCols'', 15, ''Columns'', ''prjbillxTransactionDate,prjbillxDescription,prjbillxTransferInDate,prjbillxTransferOutDate,prjbillxTransferComment,prjbillxQuantity,prjbillxHours,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName'', NULL, ''grid'', 

''[
{id:"prjbillxTransactionDate", label:"Transaction Date"},
{id:"prjbillxDescription", label:"Vendor/Person"},
{id:"prjbillxTransactionComments", label:"Transaction Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxHours", label:"Hours"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"},
{id:"prjbillxClassFullName", label:"Class"},
{id:"prjbillxSalesAccountFullName", label:"Sales GL Account"},
{id:"prjbillxWIPInBatch", label:"WIP In Batch"},
{id:"prjbillxWIPOutBatch", label:"WIP Out Batch"},
{id:"prjbillxTransferComment", label:"Transfer Comment"},
{id:"prjbillxTransferInDate", label:"Transfer In Date"},
{id:"prjbillxTransferOutDate", label:"Transfer Out Date"}
]''
	 , NULL, NULL, null, NULL)

/*************************************************************************************************************************
Sales Dashboard
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''salesDashboard'', ''Dashboard Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''DashboardSettings'', 0, ''Dashboard Sections'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''OppByStage'', 1, ''Opportunity By Stage'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''OppByWWP'', 2, ''Opportunity By WWP'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''Weighted'', 3, ''Weighted Opportunity Amounts'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''OppTwitter'', 4, ''Twitter Feeds'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''NeglectedOpps'', 5, ''Neglected Opportunities'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''SalesTarget'', 6, ''Sales Target'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboard'', ''ShowOtherSalesPeople'', 7, ''Show Other Sales People'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)



INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''salesDashboardDrilldown'', ''Drilldown Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboardDrilldown'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''salesDashboardDrilldown'', ''Weighted'', 1, ''Weighted Opportunity Amounts'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''salesDashboardDrilldown'', ''byStage'', 2, ''Columns'', ''Subject,ContactName,SaleAmount,AGI,ActivitySubject,Probability,CurrentStatus'', NULL, ''grid'', 
''[	{id:"Subject", label:"Subject"},
	{id:"ContactName", label:"Contact Name"},
    {id:"FolderName", label:"Folder Name"},
    {id:"DateAdded", label:"Date Added"},
    {id:"DateUpdated", label:"Date Updated"},

    {id:"SaleAmount", label:"Sale Amount"},
    {id:"Labor", label:"Labor"},
    {id:"OutsideCostsGross", label:"Production Amount"},
    {id:"OutsideCostsPerc", label:"Production Margin"},
    {id:"MediaGross", label:"Media Amount"},
    {id:"MediaPerc", label:"Media Margin"},
    {id:"AGI", label:"AGI"},

    {id:"Months", label:"Months"},

    {id:"ActivitySubject", label:"Next Conversation"},
    {id:"LeadStageName", label:"Stage"},
    {id:"Probability", label:"Probability"},

    {id:"CurrentStatus", label:"Next Steps"},
    {id:"EstCloseDate", label:"Forecasted Close Date"},

    {id:"WWPCurrentLevel", label:"WWP Level"},
    {id:"WWPNeedSupplyComment", label:"Need : Supply"},
    {id:"WWPTimelineComment", label:"Has a Timeline"},
    {id:"WWPBudgetComment", label:"Has a Budget"},
    {id:"WWPDecisionMakersComment", label:"Decision Makers"}
 ]''
 , NULL, NULL, NULL, NULL)


 /*************************************************************************************************************************
Opportunity Add/Edit
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''opportunitySettings'', ''Opportunity Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''RequiredFields'', 0, ''Required Fields'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''RequireForecastedCloseDate'', 1, ''Require Forecasted Close Date'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''RequireGLCompany'', 2, ''Require GL Company'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''RequireProjectType'', 3, ''Require Project Type'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''RequireOpportunityOwner'', 4, ''Require Opportunity Owner'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''RequirePrimaryContact'', 5, ''Require Primary Contact'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''RequireOutcome'', 6, ''Require Outcome When Status Is Inactive'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''Exclusions'', 7, ''Exclusions'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''opportunitySettings'', ''ExcludeVendors'', 8, ''Exclude Vendors'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Vendors that are not also clients will be excluded from the Company Dropdown.'')


/*************************************************************************************************************************
Campaign Budget
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignBudget'', ''Campaign Budget Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignBudget'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''campaignBudget'', ''LockedColumns'', 1, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campaignBudget'', ''grdCampaignBudgetsCols'', 1, ''Columns'', ''campBudgetDisplayName,campBudgetC_AmountBilled,campBudgetCS_AmountBilled,campBudgetC_ToBillRemaining,campBudgetCurrentBudgetHours,campBudgetCurrentTotalBudgetWithTax,campBudgetC_CurrentBudgetHours,campBudgetC_CurrentTotalBudget,campBudgetC_CurrentTotalBudgetWithTax,campBudgetHours,campBudgetExpenseBilled,campBudgetExpenseInvoiced,campBudgetAmountBilled,campBudgetAllocatedHours,campBudgetTotalGross,campBudgetToBillRemaining'', NULL, ''grid'', 
''[  {id:"campBudgetDisplayName", label:"Display Name"},
	{id:"campBudgetC_AmountBilled", label:"Campaign Amount Billed"},
	{id:"campBudgetCS_AmountBilled", label:"Campaign Segment Amount Billed"},
	{id:"campBudgetC_ToBillRemaining", label:"Campaign To Bill Remaining"},
	{id:"campBudgetC_AdvanceBilled", label:"Campaign Advance Billed"},
	{id:"campBudgetC_AdvanceBilledOpen", label:"Campaign Advance Billed Open"},
	{id:"campBudgetC_AdvanceBilledUnapplied", label:"Campaign Advance Billed Unapplied"},
	{id:"campBudgetCS_AdvanceBilled", label:"Campaign Segment Advance Billed"},
	{id:"campBudgetCurrentBudgetHours", label:"Project Current Budget Hours"},
	{id:"campBudgetCurrentBudgetLaborNet", label:"Project Current Budget Labor Net"},
	{id:"campBudgetCurrentBudgetLaborGross", label:"Project Current Budget Labor Gross"},
	{id:"campBudgetCurrentBudgetExpenseNet", label:"Project Current Budget Expense Net"},
	{id:"campBudgetCurrentBudgetExpenseGross", label:"Project Current Budget Expense Gross"},
	{id:"campBudgetCurrentBudgetContingency", label:"Project Current Budget Contingency"},
	{id:"campBudgetCurrentTotalBudget", label:"Project Current Total Budget"},
	{id:"campBudgetCurrentTotalBudgetWithTax", label:"Project Current Total Budget With Tax"},
	{id:"campBudgetCurrentTotalBudgetCont", label:"Project Current Total Budget Cont"},
	{id:"campBudgetCurrentTotalBudgetContWithTax", label:"Project Current Total Budget Cont With Tax"},
	{id:"campBudgetProjectToBillRemainingNoTax", label:"Project To Bill Remaining No Tax"},
	{id:"campBudgetProjectToBillRemainingWithTax", label:"Project To Bill Remaining with Tax"},
	{id:"campBudgetCOBudgetHours", label:"Project CO Budget Hours"},
	{id:"campBudgetCOBudgetLaborNet", label:"Project CO Budget Labor Net"},
	{id:"campBudgetCOBudgetLaborGross", label:"Project CO Budget Labor Gross"},
	{id:"campBudgetCOBudgetExpenseNet", label:"Project CO Budget Expense Net"},
	{id:"campBudgetCOBudgetExpenseGross", label:"Project CO Budget Expense Gross"},
	{id:"campBudgetCOBudgetContingency", label:"Project CO Budget Contingency"},
	{id:"campBudgetCOTotalBudget", label:"Project CO Total Budget"},
	{id:"campBudgetCOTotalBudgetWithTax", label:"Project CO Total Budget With Tax"},
	{id:"campBudgetCOTotalBudgetCont", label:"Project CO Total Budget Cont"},
	{id:"campBudgetCOTotalBudgetContWithTax", label:"Project CO Total Budget Cont With Tax"},
	{id:"campBudgetOriginalBudgetHours", label:"Project Original Budget Hours"},
	{id:"campBudgetOriginalBudgetLaborNet", label:"Project Original Budget Labor Net"},
	{id:"campBudgetOriginalBudgetLaborGross", label:"Project Original Budget Labor Gross"},
	{id:"campBudgetOriginalBudgetExpenseNet", label:"Project Original Budget Expense Net"},
	{id:"campBudgetOriginalBudgetExpenseGross", label:"Project Original Budget Expense Gross"},
	{id:"campBudgetOriginalBudgetContingency", label:"Project Original Budget Contingency"},
	{id:"campBudgetOriginalTotalBudget", label:"Project Original Total Budget"},
	{id:"campBudgetOriginalTotalBudgetWithTax", label:"Project Original Total Budget With Tax"},
	{id:"campBudgetOriginalTotalBudgetCont", label:"Project Original Total Budget Cont"},
	{id:"campBudgetOriginalTotalBudgetContWithTax", label:"Project Original Total Budget Cont With Tax"},
	{id:"campBudgetC_CurrentBudgetHours", label:"Campaign Current Budget Hours"},
	{id:"campBudgetC_CurrentBudgetLaborNet", label:"Campaign Current Budget Labor Net"},
	{id:"campBudgetC_CurrentBudgetLaborGross", label:"Campaign Current Budget Labor Gross"},
	{id:"campBudgetC_CurrentBudgetExpenseNet", label:"Campaign Current Budget Expense Net"},
	{id:"campBudgetC_CurrentBudgetExpenseGross", label:"Campaign Current Budget Expense Gross"},
	{id:"campBudgetC_CurrentBudgetContingency", label:"Campaign Current Budget Contingency"},
	{id:"campBudgetC_CurrentTotalBudget", label:"Campaign Current Total Budget"},
	{id:"campBudgetC_CurrentTotalBudgetWithTax", label:"Campaign Current Total Budget With Tax"},
	{id:"campBudgetC_CurrentTotalBudgetCont", label:"Campaign Current Total Budget Cont"},
	{id:"campBudgetC_CurrentTotalBudgetContWithTax", label:"Campaign Current Total Budget Cont With Tax"},
	{id:"campBudgetC_COBudgetHours", label:"Campaign CO Budget Hours"},
	{id:"campBudgetC_COBudgetLaborNet", label:"Campaign CO Budget Labor Net"},
	{id:"campBudgetC_COBudgetLaborGross", label:"Campaign CO Budget Labor Gross"},
	{id:"campBudgetC_COBudgetExpenseNet", label:"Campaign CO Budget Expense Net"},
	{id:"campBudgetC_COBudgetExpenseGross", label:"Campaign CO Budget Expense Gross"},
	{id:"campBudgetC_COBudgetContingency", label:"Campaign CO Budget Contingency"},
	{id:"campBudgetC_COTotalBudget", label:"Campaign CO Total Budget"},
	{id:"campBudgetC_COTotalBudgetWithTax", label:"Campaign CO Total Budget With Tax"},
	{id:"campBudgetC_COTotalBudgetCont", label:"Campaign CO Total Budget Cont"},
	{id:"campBudgetC_COTotalBudgetContWithTax", label:"Campaign CO Total Budget Cont With Tax"},
	{id:"campBudgetC_OriginalBudgetHours", label:"Campaign Original Budget Hours"},
	{id:"campBudgetC_OriginalBudgetLaborNet", label:"Campaign Original Budget Labor Net"},
	{id:"campBudgetC_OriginalBudgetLaborGross", label:"Campaign Original Budget Labor Gross"},
	{id:"campBudgetC_OriginalBudgetExpenseNet", label:"Campaign Original Budget Expense Net"},
	{id:"campBudgetC_OriginalBudgetExpenseGross", label:"Campaign Original Budget Expense Gross"},
	{id:"campBudgetC_OriginalBudgetContingency", label:"Campaign Original Budget Contingency"},
	{id:"campBudgetC_OriginalTotalBudget", label:"Campaign Original Total Budget"},
	{id:"campBudgetC_OriginalTotalBudgetWithTax", label:"Campaign Original Total Budget With Tax"},
	{id:"campBudgetC_OriginalTotalBudgetCont", label:"Campaign Original Total Budget Cont"},
	{id:"campBudgetC_OriginalTotalBudgetContWithTax", label:"Campaign Original Total Budget Cont With Tax"},
	{id:"campBudgetHours", label:"Project Actual Hours"},
	{id:"campBudgetHoursBilled", label:"Project Hours Billed"},
	{id:"campBudgetHoursInvoiced", label:"Project Hours Invoiced"},
	{id:"campBudgetHoursUnbilled", label:"Project Hours Unbilled"},
	{id:"campBudgetLaborNet", label:"Project Labor Net"},
	{id:"campBudgetLaborGross", label:"Project Labor Gross"},
	{id:"campBudgetLaborBilled", label:"Project Labor Billed"},
	{id:"campBudgetLaborInvoiced", label:"Project Labor Invoiced"},
	{id:"campBudgetLaborUnbilled", label:"Project Labor Unbilled"},
	{id:"campBudgetLaborWriteOff", label:"Project Labor Write Off"},
	{id:"campBudgetLaborHoursWriteOff", label:"Project Labor Hours Write Off"},
	{id:"campBudgetOpenOrdersNet", label:"Project Open Orders Net"},
	{id:"campBudgetOutsideCostsNet", label:"Project Outside Costs Net"},
	{id:"campBudgetInsideCostsNet", label:"Project Inside Costs Net"},
	{id:"campBudgetOpenOrdersGrossUnbilled", label:"Project Open Orders Gross Unbilled"},
	{id:"campBudgetOutsideCostsGrossUnbilled", label:"Project Outside Costs Gross Unbilled"},
	{id:"campBudgetInsideCostsGrossUnbilled", label:"Project Inside Costs Gross Unbilled"},
	{id:"campBudgetOutsideCostsGross", label:"Project Outside Costs Gross"},
	{id:"campBudgetInsideCostsGross", label:"Project Inside Costs Gross"},
	{id:"campBudgetOrderPrebilled", label:"Project Order Prebilled"},
	{id:"campBudgetExpenseWriteOff", label:"Project Expense Write Off"},
	{id:"campBudgetExpenseBilled", label:"Project Expense Billed"},
	{id:"campBudgetExpenseInvoiced", label:"Project Expense Invoiced"},
	{id:"campBudgetAdvanceBilled", label:"Project Advance Billed"},
	{id:"campBudgetAdvanceBilledOpen", label:"Project Advance Billed Open"},
	{id:"campBudgetAmountBilled", label:"Project Amount Billed"},
	{id:"campBudgetAmountBilledNoTax", label:"Project Amount Billed No Tax"},
	{id:"campBudgetAllocatedHours", label:"Project Allocated Hours"},
	{id:"campBudgetTotalCostsNet", label:"Project Total Costs Net"},
	{id:"campBudgetTotalCostsGrossUnbilled", label:"Project Total Costs Gross Unbilled"},
	{id:"campBudgetTotalCostsGross", label:"Project Total Costs Gross"},
	{id:"campBudgetTotalNet", label:"Project Total Net"},
	{id:"campBudgetTotalGrossUnbilled", label:"Project Total Gross Unbilled"},
	{id:"campBudgetTotalGross", label:"Project Total Gross"},
	{id:"campBudgetTotalGrossAfterWriteOff", label:"Project Total Gross After Write Off"},
	{id:"campBudgetHoursBilledRemaining", label:"Project Hours Billed Remaining"},
	{id:"campBudgetHoursRemaining", label:"Project Hours Remaining"},
	{id:"campBudgetHoursRemainingP", label:"Project Hours Remaining %"},
	{id:"campBudgetLaborNetRemaining", label:"Project Labor Net Remaining"},
	{id:"campBudgetLaborGrossRemaining", label:"Project Labor Gross Remaining"},
	{id:"campBudgetLaborGrossRemainingP", label:"Project Labor Gross Remaining %"},
	{id:"campBudgetCostsNetRemaining", label:"Project Costs Net Remaining"},
	{id:"campBudgetCostsGrossRemaining", label:"Project Costs Gross Remaining"},
	{id:"campBudgetCostsGrossRemainingP", label:"Project Costs Gross Remaining %"},
	{id:"campBudgetToBillRemaining", label:"Project To Bill Remaining"},
	{id:"campBudgetGrossRemaining", label:"Project Gross Remaining"},
    {id:"campBudgetGrossRemainingP", label:"Project Gross Remaining %"},
	{id:"campBudgetBilledDifference", label:"Project Billed Difference"},
	{id:"campBudgetRemainingAllocatedHours", label:"Project Allocated Hours Remaining"},
	{id:"campBudgetCampaignBudgetRemaining", label:"Campaign Budget Remaining"},
	{id:"campBudgetGrossRemainingCP", label:"Campaign Gross Remaining %"},
	{id:"campBudgetCampaignBudgetActualRemaining", label:"Campaign Budget Actual Remaining"},
	{id:"campBudgetCampaignBudgetActualHoursRemaining", label:"Campaign Budget Actual Hours Remaining"},
	{id:"campBudgetCampaignBudgetHoursRemaining", label:"Campaign Budget Hours Remaining"},
	{id:"campBudgetHoursRemainingCP", label:"Campaign Hours Remaining %"},	
	{id:"campBudgetLaborAfterWriteOff", label:"Project Labor Gross After WriteOff"},
	{id:"campBudgetLaborGrossAfterWriteOffRemaining", label:"Project Labor Gross After WriteOff Remaining"},
	{id:"campBudgetCostsGrossAfterWriteOffRemaining", label:"Project Costs Gross After WriteOff Remaining"},
	{id:"campBudgetGetLaborRateFrom", label:"Get Labor Rate From"},
	{id:"campBudgetProjectHoursAfterWriteoff ", label:"Project Hours After Writeoff"},
	{id:"campBudgetProjectHoursWriteoff ", label:"Project Hours Writeoff"},
	{id:"campBudgetProjectStatus ", label:"Project Status"},
	{id:"campBudgetCampaignBudgetUnbilledProjectRemaining", label:"Remaining Camp Budget Unbilled (Project)"}
 ]''
 , NULL, NULL, NULL, NULL)



 /*************************************************************************************************************************
Campaign Budget Detail
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignBudgetDetail'', ''Budget Detail Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignBudgetDetail'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''campaignBudgetDetail'', ''ScheduleLockedColumns'', 1, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campaignBudgetDetail'', ''grdCampaignBudgetDetailCols'', 1, ''Columns'', ''campBudDtlItemName,campBudDtlCurrentTotalBudget,campBudDtlCampaignCurrentTotalBudget,campBudDtlCampaignCurrentTotalBudgetWithTax,campBudDtlCampaignOriginalTotalBudgetWithTax,campBudDtlCurrentBudgetHours,campBudDtlCampaignCurrentBudgetHours,campBudDtlHours,campBudDtlAllocatedHours,campBudDtlExpenseBilled,campBudDtlExpenseInvoiced,campBudDtlTotalGross,campBudDtlAmountBilled,campBudDtlLaborUnbilled,campBudDtlToBillRemaining'', NULL, ''grid'', 
''[  {id:"campBudDtlItemID", label:"Item ID"},
	{id:"campBudDtlItemName", label:"Item Name"},
	{id:"campBudDtlDepartmentName", label:"Department Name"},
	{id:"campBudDtlWorkTypeID", label:"Work Type ID"},
	{id:"campBudDtlWorkTypeName", label:"Work Type Name"},
	{id:"campBudDtlWorkTypeDisplayOrder", label:"Work Type Display Order"},
	{id:"campBudDtlHours", label:"Project Act Hours"},
	{id:"campBudDtlHoursApproved", label:"Project Hours Approved"},
	{id:"campBudDtlHoursBilled", label:"Project Hours Billed"},
	{id:"campBudDtlHoursInvoiced", label:"Project Hours Invoiced"},
	{id:"campBudDtlHoursUnbilled", label:"Project Hours Unbilled"},
	{id:"campBudDtlLaborNet", label:"Project Labor Net"},
	{id:"campBudDtlLaborNetApproved", label:"Project Labor Net Approved"},
	{id:"campBudDtlLaborGross", label:"Project Labor Gross"},
	{id:"campBudDtlLaborGrossApproved", label:"Project Labor Gross Approved"},
	{id:"campBudDtlLaborUnbilled", label:"Project Labor Unbilled"},
	{id:"campBudDtlLaborBilled", label:"Project Labor Billed"},
	{id:"campBudDtlLaborInvoiced", label:"Project Labor Invoiced"},
	{id:"campBudDtlLaborWriteOff", label:"Project Labor Write Off"},
	{id:"campBudDtlLaborHoursWriteOff", label:"Project Labor Hours Write Off"},
	{id:"campBudDtlAmountBilled", label:"Project Amount Billed"},
	{id:"campBudDtlAmountBilledNoTax", label:"Project Amount Billed No Tax"},
	{id:"campBudDtlAdvanceBilled", label:"Project Advance Billed"},
	{id:"campBudDtlAdvanceBilledOpen", label:"Project Advance Billed Open"},
	{id:"campBudDtlAllocatedHours", label:"Project Allocated Hours"},
	{id:"campBudDtlOutsideCostsNet", label:"Project Outside Costs Net"},
	{id:"campBudDtlInsideCostsNet", label:"Project Inside Costs Net"},
	{id:"campBudDtlOpenOrdersGrossUnbilled", label:"Project Open Orders Gross Unbilled"},
	{id:"campBudDtlOutsideCostsGrossUnbilled", label:"Project Outside Costs Gross Unbilled"},
	{id:"campBudDtlInsideCostsGrossUnbilled", label:"Project Inside Costs Gross Unbilled"},
	{id:"campBudDtlOutsideCostsGross", label:"Project Outside Costs Gross"},
	{id:"campBudDtlInsideCostsGross", label:"Project Inside Costs Gross"},
	{id:"campBudDtlExpenseWriteOff", label:"Project Expense Write Off"},
	{id:"campBudDtlExpenseBilled", label:"Project Expense Billed"},
	{id:"campBudDtlExpenseInvoiced", label:"Project Expense Invoiced"},
	{id:"campBudDtlCurrentBudgetHours", label:"Project Current Budget Hours"},
	{id:"campBudDtlCurrentBudgetLaborNet", label:"Project Current Budget Labor Net"},
	{id:"campBudDtlCurrentBudgetLaborGross", label:"Project Current Budget Labor Gross"},
	{id:"campBudDtlCurrentBudgetExpenseNet", label:"Project Current Budget Expense Net"},
	{id:"campBudDtlCurrentBudgetExpenseGross", label:"Project Current Budget Expense Gross"},
	{id:"campBudDtlCurrentBudgetContingency", label:"Project Current Budget Contingency"},
	{id:"campBudDtlCurrentTotalBudget", label:"Project Current Total Budget"},
	{id:"campBudDtlCurrentTotalBudgetCont", label:"Project Current Total Budget Cont"},
	{id:"campBudDtlCurrentTotalBudgetWithTax", label:"Project Current Total Budget With Tax"},
	{id:"campBudDtlCurrentTotalBudgetContWithTax", label:"Project Current Total Budget Cont With Tax"},
	{id:"campBudDtlCOBudgetHours", label:"Project CO Budget Hours"},
	{id:"campBudDtlCOBudgetLaborNet", label:"Project CO Budget Labor Net"},
	{id:"campBudDtlCOBudgetLaborGross", label:"Project CO Budget Labor Gross"},
	{id:"campBudDtlCOBudgetExpenseNet", label:"Project CO Budget Expense Net"},
	{id:"campBudDtCOBudgetExpenseGross", label:"Project CO Budget Expense Gross"},
	{id:"campBudDtlCOBudgetContingency", label:"Project CO Budget Contingency"},
	{id:"campBudDtlCOTotalBudget", label:"Project CO Total Budget"},
	{id:"campBudDtlCOTotalBudgetCont", label:"Project CO Total Budget Cont"},
	{id:"campBudDtlCOTotalBudgetWithTax", label:"Project CO Total Budget With Tax"},
	{id:"campBudDtlCOTotalBudgetContWithTax", label:"Project CO Total Budget Cont With Tax"},
	{id:"campBudDtlOriginalBudgetHours", label:"Project Original Budget Hours"},
	{id:"campBudDtlOriginalBudgetLaborNet", label:"Project Original Budget Labor Net"},
	{id:"campBudDtlOriginalBudgetLaborGross", label:"Project Original Budget Labor Gross"},
	{id:"campBudDtlOriginalBudgetExpenseNet", label:"Project Original Budget Expense Net"},
	{id:"campBudDtlOriginalBudgetExpenseGross", label:"Project Original Budget Expense Gross"},
	{id:"campBudDtlOriginalBudgetContingency", label:"Project Original Budget Contingency"},
	{id:"campBudDtlOriginalTotalBudget", label:"Project Original Total Budget"},
	{id:"campBudDtlOriginalTotalBudgetCont", label:"Project Original Total Budget Cont"},
	{id:"campBudDtlOriginalTotalBudgetWithTax", label:"Project Original Total Budget With Tax"},
	{id:"campBudDtlOriginalTotalBudgetContWithTax", label:"Project Original Total Budget Cont With Tax"},
	{id:"campBudDtlCampaignCurrentBudgetHours", label:"Campaign Current Budget Hours"},
	{id:"campBudDtlCampaignCurrentBudgetLaborNet", label:"Campaign Current Budget Labor Net"},
	{id:"campBudDtlCampaignCurrentBudgetLaborGross", label:"Campaign Current Budget Labor Gross"},
	{id:"campBudDtlCampaignCurrentBudgetExpenseNet", label:"Campaign Current Budget Expense Net"},
	{id:"campBudDtlCampaignCurrentBudgetExpenseGross", label:"Campaign Current Budget Expense Gross"},
	{id:"campBudDtlCampaignCurrentBudgetContingency", label:"Campaign Current Budget Contingency"},
	{id:"campBudDtlCampaignCurrentTotalBudget", label:"Campaign Current Total Budget"},
	{id:"campBudDtlCampaignCurrentTotalBudgetWithTax", label:"Campaign Current Total Budget With Tax"},
	{id:"campBudDtlCampaignCurrentTotalBudgetCont", label:"Campaign Current Total Budget Cont"},
	{id:"campBudDtlCampaignCurrentTotalBudgetContWithTax", label:"Campaign Current Total Budget Cont With Tax"},
	{id:"campBudDtlCampaignCOBudgetHours", label:"Campaign CO Budget Hours"},
	{id:"campBudDtlCampaignCOBudgetLaborNet", label:"Campaign CO Budget Labor Net"},
	{id:"campBudDtlCampaignCOBudgetLaborGross", label:"Campaign CO Budget Labor Gross"},
	{id:"campBudDtlCampaignCOBudgetExpenseNet", label:"Campaign CO Budget Expense Net"},
	{id:"campBudDtlCampaignCOBudgetExpenseGross", label:"Campaign CO Budget Expense Gross"},
	{id:"campBudDtlCampaignCOBudgetContingency", label:"Campaign CO Budget Contingency"},
	{id:"campBudDtlCampaignCOTotalBudget", label:"Campaign CO Total Budget"},
	{id:"campBudDtlCampaignCOTotalBudgetWithTax", label:"Campaign CO Total Budget With Tax"},
	{id:"campBudDtlCampaignCOTotalBudgetCont", label:"Campaign CO Total Budget Cont"},
	{id:"campBudDtlCampaignCOTotalBudgetContWithTax", label:"Campaign CO Total Budget Cont With Tax"},
	{id:"campBudDtlCampaignOriginalBudgetHours", label:"Campaign Original Budget Hours"},
	{id:"campBudDtlCampaignOriginalBudgetLaborNet", label:"Campaign Original Budget Labor Net"},
	{id:"campBudDtlCampaignOriginalBudgetLaborGross", label:"Campaign Original Budget Labor Gross"},
	{id:"campBudDtlCampaignOriginalBudgetExpenseNet", label:"Campaign Original Budget Expense Net"},
	{id:"campBudDtlCampaignOriginalBudgetExpenseGross", label:"Campaign Original Budget Expense Gross"},
	{id:"campBudDtlCampaignOriginalBudgetContingency", label:"Campaign Original Budget Contingency"},
	{id:"campBudDtlCampaignOriginalTotalBudget", label:"Campaign Original Total Budget"},
	{id:"campBudDtlCampaignOriginalTotalBudgetWithTax", label:"Campaign Original Total Budget With Tax"},
	{id:"campBudDtlCampaignOriginalTotalBudgetCont", label:"Campaign Original Total Budget Cont"},
	{id:"campBudDtlCampaignOriginalTotalBudgetContWithTax", label:"Campaign Original Total Budget Cont With Tax"},
	{id:"campBudDtlTotalCostsNet", label:"Project Total Costs Net"},
	{id:"campBudDtlTotalCostsGrossUnbilled", label:"Project Total Costs Gross Unbilled"},
	{id:"campBudDtlTotalCostsGross", label:"Project Total Costs Gross"},
	{id:"campBudDtlTotalNet", label:"Project Total Net"},
	{id:"campBudDtlTotalGrossUnbilled", label:"Project Total Gross Unbilled"},
	{id:"campBudDtlTotalGross", label:"Project Total Gross"},
	{id:"campBudDtlTotalGrossAfterWriteOff", label:"Project Total Gross After Write Off"},
	{id:"campBudDtlHoursBilledRemaining", label:"Project Hours Billed Remaining"},
	{id:"campBudDtlHoursRemaining", label:"Project Hours Remaining"},
	{id:"campBudDtlHoursRemainingP", label:"Project Hours Remaining %"},
	{id:"campBudDtlLaborNetRemaining", label:"Project Labor Net Remaining"},
	{id:"campBudDtlLaborGrossRemaining", label:"Project Labor Gross Remaining"},
	{id:"campBudDtlLaborGrossRemainingP", label:"Project Labor Gross Remaining %"},
	{id:"campBudDtlCostsNetRemaining", label:"Project Costs Net Remaining"},
	{id:"campBudDtlCostsGrossRemaining", label:"Project Costs Gross Remaining"},
	{id:"campBudDtlCostsGrossRemainingP", label:"Project Costs Gross Remaining %"},
	{id:"campBudDtlToBillRemaining", label:"Project To Bill Remaining"},
	{id:"campBudDtlGrossRemaining", label:"Project Gross Remaining"},
	{id:"campBudDtlGrossRemainingP", label:"Project Gross Remaining %"},
	{id:"campBudDtlBilledDifference", label:"Project Billed Difference"}
 ]''
 , NULL, NULL, NULL, NULL)


 /*************************************************************************************************************************
Campaign Billing transactions grids
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campBillTransactions'', ''Campaign Billing Detail Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campBillTransactions'', ''H1'', 0, ''% of Service/Item Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campBillTransactions'', ''grdServicesItemsCols'', 1, ''Columns'', ''colServiceDescription,colServicePercent,colServiceBillAmt,colServiceEstHrs,colServiceEstLabor,colServiceEstExpenses,colServiceEstTotal,colServiceActHrs,colServiceActLabor,colServiceActExpenses,colServiceActTotal,colServiceBilled,colServiceRemaining'', NULL, ''grid'', 

''[
{id:"colServiceDescription", label:"Item/Service"},
{id:"colServicePercent", label:"%"},
{id:"colServiceBillAmt", label:"Bill Amt"},
{id:"colServiceEstHrs", label:"Est Hrs"},
{id:"colServiceEstLabor", label:"Est Labor"},
{id:"colServiceEstExpenses", label:"Est Exp"},
{id:"colServiceEstTotal", label:"Est Total"},
{id:"colServiceActHrs", label:"Act Hrs"},
{id:"colServiceActLabor", label:"Act Labor"},
{id:"colServiceActExpenses", label:"Act Exp"},
{id:"colServiceActTotal", label:"Act Total"},
{id:"colServiceBilled", label:"Billed"},
{id:"colServiceRemaining", label:"Remaining"},
{id:"colProjTotalGrossUnbilled", label:"Total Gross Unbilled"}
]''
	 , NULL, NULL, null, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campBillTransactions'', ''H2'', 2, ''% of Project Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campBillTransactions'', ''grdProjectsCols'', 3, ''Columns'', ''colProjName,colProjPercent,colProjBillAmt,colProjEstHrs,colProjEstLabor,colProjEstExpenses,colProjEstTotal,colProjActHrs,colProjActLabor,colProjActExpenses,colProjActTotal,colProjBilled,colProjRemaining'', NULL, ''grid'', 

''[
{id:"colProjName", label:"Project"},
{id:"colProjPercent", label:"%"},
{id:"colProjBillAmt", label:"Bill Amt"},
{id:"colProjEstHrs", label:"Est Hrs"},
{id:"colProjEstLabor", label:"Est Labor"},
{id:"colProjEstExpenses", label:"Est Exp"},
{id:"colProjEstTotal", label:"Est Total"},
{id:"colProjActHrs", label:"Act Hrs"},
{id:"colProjActLabor", label:"Act Labor"},
{id:"colProjActExpenses", label:"Act Exp"},
{id:"colProjActTotal", label:"Act Total"},
{id:"colProjBilled", label:"Billed"},
{id:"colProjRemaining", label:"Remaining"},
{id:"colProjTotalGrossUnbilled", label:"Total Gross Unbilled"}
]''
	 , NULL, NULL, null, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campBillTransactions'', ''H3'', 4, ''% of Segment Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campBillTransactions'', ''grdSegmentsCols'', 5, ''Columns'', ''colSegName,colSegPercent,colSegBillAmt,colSegEstHrs,colSegEstLabor,colSegEstExpenses,colSegEstTotal,colSegActHrs,colSegActLabor,colSegActExpenses,colSegActTotal,colSegBilled,colSegRemaining'', NULL, ''grid'', 

''[
{id:"colSegName", label:"Segment"},
{id:"colSegPercent", label:"%"},
{id:"colSegBillAmt", label:"Bill Amt"},
{id:"colSegEstHrs", label:"Est Hrs"},
{id:"colSegEstLabor", label:"Est Labor"},
{id:"colSegEstExpenses", label:"Est Exp"},
{id:"colSegEstTotal", label:"Est Total"},
{id:"colSegActHrs", label:"Act Hrs"},
{id:"colSegActLabor", label:"Act Labor"},
{id:"colSegActExpenses", label:"Act Exp"},
{id:"colSegActTotal", label:"Act Total"},
{id:"colSegBilled", label:"Billed"},
{id:"colSegRemaining", label:"Remaining"},
{id:"colProjTotalGrossUnbilled", label:"Total Gross Unbilled"}
]''
	 , NULL, NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campBillTransactions'', ''H4'', 6, ''Extras Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campBillTransactions'', ''grdTransactionDetailCols'', 7, ''Columns'', ''prjbillxProjectFullName,prjbillxTransactionDate,prjbillxDescription,prjbillxTransactionComments,prjbillxQuantity,prjbillxUnitRate,prjbillxTotalCost,prjbillxBillableCost,prjbillxTaskFullName,prjbillxItemFullName,prjbillxDepartmentName'', NULL, ''grid'', 

''[
{id:"prjbillxProjectFullName", label:"Project"},
{id:"prjbillxTransactionDate", label:"Date"},
{id:"prjbillxDescription", label:"Description"},
{id:"prjbillxTransactionComments", label:"Comments"},
{id:"prjbillxQuantity", label:"Quantity"},
{id:"prjbillxUnitRate", label:"Unit Rate"},
{id:"prjbillxTotalCost", label:"Net"},
{id:"prjbillxBillableCost", label:"Gross"},
{id:"prjbillxTaskFullName", label:"Task"},
{id:"prjbillxItemFullName", label:"Item/Service"},
{id:"prjbillxDepartmentName", label:"Department"}
]''
	 , NULL, NULL, null, NULL)


/*************************************************************************************************************************
Campaign Production Dash
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''productionCampDash'', ''Campaigns Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''H1'', 0, ''My Campaigns Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''Active'', 1, ''Active Campaigns Only'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''OpenExpanded'', 2, ''Expand Campaigns When Opened'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''AEKeys'', 3, ''Account Manager'', ''-1'', ''All'', ''selectlist'', NULL, ''selectlist.User'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''ProjectManagerKeys'', 4, ''Project Manager'', ''-1'', ''All'', ''selectlist'', NULL, ''selectlist.User'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''GLCompanyID'', 5, ''GL Company'', ''-1'', ''All'', ''lookup'', NULL, ''lookup.GLCompany'', NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''BudgetWarning'', 6, ''Budget Warning'', ''80'', NULL, ''number'', NULL, null, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''GroupBy'', 7, ''Group By'', ''CustomerFullName'', ''Client'', ''lookup'', ''No Grouping:NoGrouping|Client:CustomerFullName|Account Manager:AEFullName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampDash'', ''GroupByDir'', 8, ''Group Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''productionCampDash'', ''grdCampProductionDashCols'', 6, ''Columns'', ''prodCampDashCampaignFullName,prodCampDashClientName,prodCampDashDescription,prodCampDashStartDate,prodCampDashEndDate,prodCampDashProjectTaskStatus,prodCampDashFinancialStatusImage'', NULL, ''grid'', 

''[{id:"prodCampDashCampaignFullName", label:"Campaign Full Name"},
	{id:"prodCampDashClientName", label:"Client Name"},
	{id:"prodCampDashDescription", label:"Description"},	
	{id:"prodCampDashStartDate", label:"Start Date"},
	{id:"prodCampDashEndDate", label:"End Date"},
	{id:"prodCampDashProjectTaskStatus", label:"Campaign Status"},
	{id:"prodCampDashFinancialStatusImage", label:"Financial Status"},
	{id:"prodCampDashPrimaryContact", label:"Primary Contact"},
	{id:"prodCampDashAEName", label:"Account Manager"},
	{id:"prodCampDashObjective", label:"Objective"},
	{id:"prodCampDashCampaignID", label:"Campaign ID"},
	{id:"prodCampDashCampaignName", label:"Campaign Name"},
	{id:"prodCampDashCustomerID", label:"Client ID"},
	{id:"prodCampDashGLCompanyName", label:"GL Company Name"},
	{id:"prodCampDashGLCompanyID", label:"GL Company ID"},
	{id:"prodCampaignDashOfficeName", label:"Office Name"},	
	{id:"prodCampDashBillBy", label:"Bill By"},
	{id:"prodCampDashMultipleSegments", label:"Use Multiple Segments"},
	{id:"prodCampDashActive", label:"Active"},
	{id:"prodCampDashCurrencyID", label:"Currency ID"},
	{id:"prodCampDashProductName", label:"Product Name"},
	{id:"prodCampDashDivisionName", label:"Division Name"},
	{id:"prodCampDashCampaignBudgetNet", label:"Campaign Budget Net"},
	{id:"prodCampDashCampaignBudgetGross", label:"Campaign Budget Gross"},
	{id:"prodCampDashCampaignBudgetLaborGross", label:"Campaign Budget Labor Gross"},
	{id:"prodCampDashCampaignBudgetLaborNet", label:"Campaign Budget Labor Net"},
	{id:"prodCampDashCampaignBudgetHours", label:"Campaign Budget Hours"},
	{id:"prodCampDashCampaignBudgetExpenseGross", label:"Campaign Budget Expense Gross"},
	{id:"prodCampDashCampaignBudgetExpenseNet", label:"Campaign Budget Expense Net"},	
	{id:"prodCampDashCampaignBudgetQty", label:"Campaign Budget Qty"},	
	{id:"prodCampDashCampaignAmountBilled", label:"Campaign Amount Billed"},
	{id:"prodCampDashDeliverables", label:"Deliverables"},
	{id:"prodCampDashPMName", label:"Project Manager"},
	{id:"prodCampDashOpportunityFullName", label:"Opportunity Full Name"},
	{id:"prodCampDashLaborHours", label:"Labor Hours"},
	{id:"prodCampDashBudgetLaborHours", label:"Budget Labor Hours"},
	{id:"prodCampDashProjectAllocatedHours", label:"Project Allocated Hours"},
	{id:"prodCampDashLeadStageName", label:"Opportunity Stage"},
	{id:"prodCampDashLeadStatusName", label:"Opportunity Status"},
	{id:"prodCampDashLaborGross", label:"Labor Gross"}
]''
	 , NULL, NULL,''Campaign'',''Campaign'')




/*************************************************************************************************************************
Campaign Production PROJECTS
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''productionCampProjects'', ''Campaigns Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''productionCampProjects'', ''H1'', 0, ''Project Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''productionCampProjects'', ''grdCampaignProjectsCols'', 6, ''Columns'', ''campaignDisplayName,campaignProjectStatus,campaignAccountManager,campaignPrimaryContact,campaignProjectDueDate'', NULL, ''grid'', 

''[{id:"campaignDisplayName", label:"Projects"},
	{id:"campaignProjectStatus", label:"Project Status"},
	{id:"campaignAccountManager", label:"Account Manager"},		
	{id:"campaignPrimaryContact", label:"Primary Contact"},
	{id:"campaignProjectManager", label:"Project Manager"},
	{id:"campaignProjectDivision", label:"Division"},
	{id:"campaignProjectProduct", label:"Product"},
	{id:"campaignProjectDueDate", label:"Project Due Date"},
	{id:"campaignProjectType", label:"Project Type"}
]''
	 , NULL, NULL,NULL,NULL)



/*************************************************************************************************************************
Campaign Dashboard 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignDashBoard'', ''Campaign Dashboard Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardSettings'', 0, ''Dashboard Sections'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardDescription'', 1, ''Campaign Description'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardDailyFeed'', 2, ''Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardBurnChart'', 3, ''Burn Chart'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardDiary'', 4, ''Recent Diary Posts'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardCustomFields'', 5, ''Custom Fields'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardDeliverables'', 6, ''Deliverables'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignDashBoard'', ''CampDashboardSnapshot'', 7, ''Campaign Snapshot'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Campaign Edit 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignEdit'', ''Edit Campaign Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignEdit'', ''DisableEditingCampaignID'', 1, ''Disable the editing of the Campaign ID'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)



/*************************************************************************************************************************
Campaign Estimate List
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''estimateCampaignList'', ''Estimate List Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateCampaignList'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''estimateCampaignList'', ''gridCols'', 1, ''Columns'', ''EstimateFullName,EstimateNumber,ChangeOrder,DateAdded,EnteredByName,ExternalApprovalStatus,ExternalApproverName,InternalApprovalStatus,EstimateTotal'', NULL, ''grid'', 
''[	{id:"ChangeOrder", label:"Change Order"},
	{id:"DateAdded", label:"Date Added"},
	{id:"EnteredByName", label:"Entered By"},
	{id:"EstTypeDesc", label:"Est Type"},
	{id:"EstimateFullName", label:"Estimate Name"},
	{id:"EstimateNumber", label:"Estimate Number"},
	{id:"EstimateDescription", label:"Estimate Description"},
	{id:"ExternalApprovalStatus", label:"External Approval Status"},
	{id:"ExternalApproverName", label:"External Approver Name"},
	{id:"ExternalComments", label:"External Comments"},
	{id:"InternalApprovalStatus", label:"Internal Approval Status"},
	{id:"InternalApproverName", label:"Internal Approver Name"},
	{id:"InternalComments", label:"Internal Comments"},
	{id:"Revision", label:"Revision"},
	{id:"EstimateTotal", label:"Estimate Total"},
	{id:"ExpenseGross", label:"Expense Gross"},
	{id:"ExpenseNet", label:"Expense Net"},
	{id:"Hours", label:"Hours"},
	{id:"LaborGross", label:"Labor Gross"},
	{id:"LaborNet", label:"Labor Net"},
	{id:"SalesTax2Amount", label:"Sales Tax2 Amount"},
	{id:"SalesTaxAmount", label:"Sales Tax Amount"},
	{id:"TaxableTotal", label:"Taxable Total"},
	{id:"Total", label:"Total"}
 ]''
	 , NULL, NULL, null, NULL)

/*************************************************************************************************************************
Campaign Add
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignAdd'', ''Add Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignAdd'', ''ManualID'', 0, ''Manually Add Campaign ID'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignAdd'', ''ShowAccountManager'', 1, ''Show Account Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref) 
Values (''campaignAdd'', ''ShowProjectManager'', 2, ''Show Project Manager'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''ShowProjectManager'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignAdd'', ''StartDateEndDateRequired'', 3, ''Require Start Date / End Date'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
Campaign Budget Analysis
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignBudgetAnalysis'', ''Campaign Budget Analysis Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignBudgetAnalysis'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''campaignBudgetAnalysis'', ''LockedColumns'', 1, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campaignBudgetAnalysis'', ''grdCampaignBudgetAnalysisCols'', 1, ''Columns'', ''campBudgetDisplayName,campBudgetC_AmountBilled,campBudgetCS_AmountBilled,campBudgetC_ToBillRemaining,campBudgetCurrentBudgetHours,campBudgetCurrentTotalBudgetWithTax,campBudgetC_CurrentBudgetHours,campBudgetC_CurrentTotalBudget,campBudgetC_CurrentTotalBudgetWithTax,campBudgetHours,campBudgetExpenseBilled,campBudgetExpenseInvoiced,campBudgetAmountBilled,campBudgetAllocatedHours,campBudgetTotalGross,campBudgetToBillRemaining'', NULL, ''grid'', 
''[  {id:"campBudgetDisplayName", label:"Display Name"},
	{id:"campBudgetC_AmountBilled", label:"Campaign Amount Billed"},
	{id:"campBudgetCS_AmountBilled", label:"Campaign Segment Amount Billed"},
	{id:"campBudgetC_ToBillRemaining", label:"Campaign To Bill Remaining"},
	{id:"campBudgetC_AdvanceBilled", label:"Campaign Advance Billed"},
	{id:"campBudgetC_AdvanceBilledOpen", label:"Campaign Advance Billed Open"},
	{id:"campBudgetC_AdvanceBilledUnapplied", label:"Campaign Advance Billed Unapplied"},
	{id:"campBudgetCS_AdvanceBilled", label:"Campaign Segment Advance Billed"},
	{id:"campBudgetCurrentBudgetHours", label:"Project Current Budget Hours"},
	{id:"campBudgetCurrentBudgetLaborNet", label:"Project Current Budget Labor Net"},
	{id:"campBudgetCurrentBudgetLaborGross", label:"Project Current Budget Labor Gross"},
	{id:"campBudgetCurrentBudgetExpenseNet", label:"Project Current Budget Expense Net"},
	{id:"campBudgetCurrentBudgetExpenseGross", label:"Project Current Budget Expense Gross"},
	{id:"campBudgetCurrentBudgetContingency", label:"Project Current Budget Contingency"},
	{id:"campBudgetCurrentTotalBudget", label:"Project Current Total Budget"},
	{id:"campBudgetCurrentTotalBudgetWithTax", label:"Project Current Total Budget With Tax"},
	{id:"campBudgetCurrentTotalBudgetCont", label:"Project Current Total Budget Cont"},
	{id:"campBudgetCurrentTotalBudgetContWithTax", label:"Project Current Total Budget Cont With Tax"},
	{id:"campBudgetProjectToBillRemainingNoTax", label:"Project To Bill Remaining No Tax"},
	{id:"campBudgetProjectToBillRemainingWithTax", label:"Project To Bill Remaining with Tax"},
	{id:"campBudgetCOBudgetHours", label:"Project CO Budget Hours"},
	{id:"campBudgetCOBudgetLaborNet", label:"Project CO Budget Labor Net"},
	{id:"campBudgetCOBudgetLaborGross", label:"Project CO Budget Labor Gross"},
	{id:"campBudgetCOBudgetExpenseNet", label:"Project CO Budget Expense Net"},
	{id:"campBudgetCOBudgetExpenseGross", label:"Project CO Budget Expense Gross"},
	{id:"campBudgetCOBudgetContingency", label:"Project CO Budget Contingency"},
	{id:"campBudgetCOTotalBudget", label:"Project CO Total Budget"},
	{id:"campBudgetCOTotalBudgetWithTax", label:"Project CO Total Budget With Tax"},
	{id:"campBudgetCOTotalBudgetCont", label:"Project CO Total Budget Cont"},
	{id:"campBudgetCOTotalBudgetContWithTax", label:"Project CO Total Budget Cont With Tax"},
	{id:"campBudgetOriginalBudgetHours", label:"Project Original Budget Hours"},
	{id:"campBudgetOriginalBudgetLaborNet", label:"Project Original Budget Labor Net"},
	{id:"campBudgetOriginalBudgetLaborGross", label:"Project Original Budget Labor Gross"},
	{id:"campBudgetOriginalBudgetExpenseNet", label:"Project Original Budget Expense Net"},
	{id:"campBudgetOriginalBudgetExpenseGross", label:"Project Original Budget Expense Gross"},
	{id:"campBudgetOriginalBudgetContingency", label:"Project Original Budget Contingency"},
	{id:"campBudgetOriginalTotalBudget", label:"Project Original Total Budget"},
	{id:"campBudgetOriginalTotalBudgetWithTax", label:"Project Original Total Budget With Tax"},
	{id:"campBudgetOriginalTotalBudgetCont", label:"Project Original Total Budget Cont"},
	{id:"campBudgetOriginalTotalBudgetContWithTax", label:"Project Original Total Budget Cont With Tax"},
	{id:"campBudgetC_CurrentBudgetHours", label:"Campaign Current Budget Hours"},
	{id:"campBudgetC_CurrentBudgetLaborNet", label:"Campaign Current Budget Labor Net"},
	{id:"campBudgetC_CurrentBudgetLaborGross", label:"Campaign Current Budget Labor Gross"},
	{id:"campBudgetC_CurrentBudgetExpenseNet", label:"Campaign Current Budget Expense Net"},
	{id:"campBudgetC_CurrentBudgetExpenseGross", label:"Campaign Current Budget Expense Gross"},
	{id:"campBudgetC_CurrentBudgetContingency", label:"Campaign Current Budget Contingency"},
	{id:"campBudgetC_CurrentTotalBudget", label:"Campaign Current Total Budget"},
	{id:"campBudgetC_CurrentTotalBudgetWithTax", label:"Campaign Current Total Budget With Tax"},
	{id:"campBudgetC_CurrentTotalBudgetCont", label:"Campaign Current Total Budget Cont"},
	{id:"campBudgetC_CurrentTotalBudgetContWithTax", label:"Campaign Current Total Budget Cont With Tax"},
	{id:"campBudgetC_COBudgetHours", label:"Campaign CO Budget Hours"},
	{id:"campBudgetC_COBudgetLaborNet", label:"Campaign CO Budget Labor Net"},
	{id:"campBudgetC_COBudgetLaborGross", label:"Campaign CO Budget Labor Gross"},
	{id:"campBudgetC_COBudgetExpenseNet", label:"Campaign CO Budget Expense Net"},
	{id:"campBudgetC_COBudgetExpenseGross", label:"Campaign CO Budget Expense Gross"},
	{id:"campBudgetC_COBudgetContingency", label:"Campaign CO Budget Contingency"},
	{id:"campBudgetC_COTotalBudget", label:"Campaign CO Total Budget"},
	{id:"campBudgetC_COTotalBudgetWithTax", label:"Campaign CO Total Budget With Tax"},
	{id:"campBudgetC_COTotalBudgetCont", label:"Campaign CO Total Budget Cont"},
	{id:"campBudgetC_COTotalBudgetContWithTax", label:"Campaign CO Total Budget Cont With Tax"},
	{id:"campBudgetC_OriginalBudgetHours", label:"Campaign Original Budget Hours"},
	{id:"campBudgetC_OriginalBudgetLaborNet", label:"Campaign Original Budget Labor Net"},
	{id:"campBudgetC_OriginalBudgetLaborGross", label:"Campaign Original Budget Labor Gross"},
	{id:"campBudgetC_OriginalBudgetExpenseNet", label:"Campaign Original Budget Expense Net"},
	{id:"campBudgetC_OriginalBudgetExpenseGross", label:"Campaign Original Budget Expense Gross"},
	{id:"campBudgetC_OriginalBudgetContingency", label:"Campaign Original Budget Contingency"},
	{id:"campBudgetC_OriginalTotalBudget", label:"Campaign Original Total Budget"},
	{id:"campBudgetC_OriginalTotalBudgetWithTax", label:"Campaign Original Total Budget With Tax"},
	{id:"campBudgetC_OriginalTotalBudgetCont", label:"Campaign Original Total Budget Cont"},
	{id:"campBudgetC_OriginalTotalBudgetContWithTax", label:"Campaign Original Total Budget Cont With Tax"},
	{id:"campBudgetHours", label:"Project Actual Hours"},
	{id:"campBudgetHoursBilled", label:"Project Hours Billed"},
	{id:"campBudgetHoursInvoiced", label:"Project Hours Invoiced"},
	{id:"campBudgetHoursUnbilled", label:"Project Hours Unbilled"},
	{id:"campBudgetLaborNet", label:"Project Labor Net"},
	{id:"campBudgetLaborGross", label:"Project Labor Gross"},
	{id:"campBudgetLaborBilled", label:"Project Labor Billed"},
	{id:"campBudgetLaborInvoiced", label:"Project Labor Invoiced"},
	{id:"campBudgetLaborUnbilled", label:"Project Labor Unbilled"},
	{id:"campBudgetLaborWriteOff", label:"Project Labor Write Off"},
	{id:"campBudgetLaborHoursWriteOff", label:"Project Labor Hours Write Off"},
	{id:"campBudgetOpenOrdersNet", label:"Project Open Orders Net"},
	{id:"campBudgetOutsideCostsNet", label:"Project Outside Costs Net"},
	{id:"campBudgetInsideCostsNet", label:"Project Inside Costs Net"},
	{id:"campBudgetOpenOrdersGrossUnbilled", label:"Project Open Orders Gross Unbilled"},
	{id:"campBudgetOutsideCostsGrossUnbilled", label:"Project Outside Costs Gross Unbilled"},
	{id:"campBudgetInsideCostsGrossUnbilled", label:"Project Inside Costs Gross Unbilled"},
	{id:"campBudgetOutsideCostsGross", label:"Project Outside Costs Gross"},
	{id:"campBudgetInsideCostsGross", label:"Project Inside Costs Gross"},
	{id:"campBudgetOrderPrebilled", label:"Project Order Prebilled"},
	{id:"campBudgetExpenseWriteOff", label:"Project Expense Write Off"},
	{id:"campBudgetExpenseBilled", label:"Project Expense Billed"},
	{id:"campBudgetExpenseInvoiced", label:"Project Expense Invoiced"},
	{id:"campBudgetAdvanceBilled", label:"Project Advance Billed"},
	{id:"campBudgetAdvanceBilledOpen", label:"Project Advance Billed Open"},
	{id:"campBudgetAmountBilled", label:"Project Amount Billed"},
	{id:"campBudgetAmountBilledNoTax", label:"Project Amount Billed No Tax"},
	{id:"campBudgetAllocatedHours", label:"Project Allocated Hours"},
	{id:"campBudgetTotalCostsNet", label:"Project Total Costs Net"},
	{id:"campBudgetTotalCostsGrossUnbilled", label:"Project Total Costs Gross Unbilled"},
	{id:"campBudgetTotalCostsGross", label:"Project Total Costs Gross"},
	{id:"campBudgetTotalNet", label:"Project Total Net"},
	{id:"campBudgetTotalGrossUnbilled", label:"Project Total Gross Unbilled"},
	{id:"campBudgetTotalGross", label:"Project Total Gross"},
	{id:"campBudgetTotalGrossAfterWriteOff", label:"Project Total Gross After Write Off"},
	{id:"campBudgetHoursBilledRemaining", label:"Project Hours Billed Remaining"},
	{id:"campBudgetHoursRemaining", label:"Project Hours Remaining"},
	{id:"campBudgetHoursRemainingP", label:"Project Hours Remaining %"},
	{id:"campBudgetLaborNetRemaining", label:"Project Labor Net Remaining"},
	{id:"campBudgetLaborGrossRemaining", label:"Project Labor Gross Remaining"},
	{id:"campBudgetLaborGrossRemainingP", label:"Project Labor Gross Remaining %"},
	{id:"campBudgetCostsNetRemaining", label:"Project Costs Net Remaining"},
	{id:"campBudgetCostsGrossRemaining", label:"Project Costs Gross Remaining"},
	{id:"campBudgetCostsGrossRemainingP", label:"Project Costs Gross Remaining %"},
	{id:"campBudgetToBillRemaining", label:"Project To Bill Remaining"},
	{id:"campBudgetGrossRemaining", label:"Project Gross Remaining"},
    {id:"campBudgetGrossRemainingP", label:"Project Gross Remaining %"},
	{id:"campBudgetBilledDifference", label:"Project Billed Difference"},
	{id:"campBudgetRemainingAllocatedHours", label:"Project Allocated Hours Remaining"},
	{id:"campBudgetCampaignBudgetRemaining", label:"Campaign Budget Remaining"},
	{id:"campBudgetGrossRemainingCP", label:"Campaign Gross Remaining %"},
	{id:"campBudgetCampaignBudgetActualRemaining", label:"Campaign Budget Actual Remaining"},
	{id:"campBudgetLaborRemaining", label:"Campaign Budget Labor Remaining"},
	{id:"campBudgetExpenseRemaining", label:"Campaign Budget Expense Remaining"},
	{id:"campBudgetCampaignBudgetActualHoursRemaining", label:"Campaign Budget Actual Hours Remaining"},
	{id:"campBudgetCampaignBudgetHoursRemaining", label:"Campaign Budget Hours Remaining"},
	{id:"campBudgetHoursRemainingCP", label:"Campaign Hours Remaining %"},	
	{id:"campBudgetLaborAfterWriteOff", label:"Project Labor Gross After WriteOff"},
	{id:"campBudgetLaborGrossAfterWriteOffRemaining", label:"Project Labor Gross After WriteOff Remaining"},
	{id:"campBudgetCostsGrossAfterWriteOffRemaining", label:"Project Costs Gross After WriteOff Remaining"},
	{id:"campBudgetGetLaborRateFrom", label:"Get Labor Rate From"},
	{id:"campBudgetProjectHoursAfterWriteoff ", label:"Project Hours After Writeoff"},
	{id:"campBudgetProjectHoursWriteoff ", label:"Project Hours Writeoff"},
	{id:"campBudgetProjectStatus ", label:"Project Status"},
	{id:"campBudgetCampaignBudgetUnbilledProjectRemaining", label:"Remaining Camp Budget Unbilled (Project)"}
 ]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Traffic Resource Manager
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''trafficRM'', ''Resource Manager Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''MaxHours'', 1, ''Max Daily Hours'', ''8'', NULL, ''number'', NULL, null, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''WarningThreshold'', 2, ''Warning Threshold'', ''5'', NULL, ''number:n0'', NULL, null, ''This is the number of hours left that will trigger a yellow status bar'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''CriticalThreshold'', 3, ''Critical Threshold'', ''0'', NULL, ''number:n0'', NULL, null, ''This is the number of hours left that will trigger a red status bar'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''ShorthandUserTiles'', 4, ''Shorthand User Tiles'', ''0'', NULL, ''checkbox'', NULL, null, ''This is a condensed view which only shows the initials so more people fit on a screen'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''UseTaskCountNotHours'', 5, ''Use Task Count Instead of Hours'', ''0'', NULL, ''checkbox'', NULL, null, ''This will show user totals based on task count instead of hours'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''PredCompOnly'', 6, ''Completed Predecessors Only'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''openToDoOnly'', 6, ''Open To Do Items Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''openDeliverablesOnly'', 6, ''Open Deliverables Only'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''ShowUnassignedTasks'', 7, ''Show Unassigned Tasks'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will show tasks that are not assigned to anyone or any service.'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''ShowAssignmentZeroAllocated'', 8, ''Show Assignments With Zero Allocated'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will show task assignments regardless of how many hours are assigned. Use this option if you do not allocate hours to people.'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''GroupBy'', 9, ''Group Unassigned Tasks By'', ''ProjectFullName'', ''Project'', ''lookup'', ''Project:ProjectFullName|Campaign:CampaignName|Client:ClientName|Task Name:TaskName|Summary Task:SummaryTaskName|Service:ServiceName'', NULL, NULL)
--INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
--Values (''trafficRM'', ''HideEnterTime'', 10, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''DisableDragDrop'', 10, ''Disable Drag and Drop'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficRM'', ''AutoExpandTaskGrid'', 11, ''Auto Expand Tasks'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
/*************************************************************************************************************************
Traffic Calendar
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''trafficCalendar'', ''Traffic Calendar Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''H1'', 0, ''Grid Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''trafficCalendar'', ''grdTrafficCalendarCols'', 1, ''Columns'', ''colPlanStart,colPlanComplete,colPercentComplete,colTaskID,colConstraint,colBudgetHours'', NULL, ''grid'', 
''[	{id:"colPlanStart", label:"Plan Start"},
	{id:"colPlanComplete", label:"Plan Complete"},
	{id:"colTaskStatus", label:"Status"},
	{id:"colPercentComplete", label:"%"},
	{id:"colTaskID", label:"ID"},
	{id:"colConstraint", label:"Constraint"},
	{id:"colBudgetHours", label:"Budget Hours"},
	{id:"colActualHours", label:"Actual Hours"},
	{id:"colAllocatedHours", label:"Allocated Hours"},
	{id:"colAssignedNames", label:"Assigned"},
	{id:"colAllToDos", label:"All To Dos"},
	{id:"colOpenToDos", label:"Open To Dos"},
	{id:"colPlanDuration", label:"Days"},
	{id:"colActualStart", label:"Actual Start"},
	{id:"colActualComplete", label:"Actual Complete"},
	{id:"colBaseStart", label:"Orig Start"},
	{id:"colBaseComplete", label:"Orig Complete"},
	{id:"colHideFromClient", label:"Hide From Client"},
	{id:"colPriority", label:"Priority"},
	{id:"colDescription", label:"Description"},
	{id:"colProject", label:"Project"},
	{id:"colCampaign", label:"Campaign"},
	{id:"colSegmentName", label:"Campaign Segment"},
	{id:"colConstraintDate", label:"Constraint Date"},
	{id:"colDueComment", label:"Due Comment"},
	{id:"colTimelineSegment", label:"Timeline Segment"},
	{id:"colEventStart", label:"Start Time"},
	{id:"colEventEnd", label:"End Time"},
	{id:"colPercCompSeparate", label:"Track Seperately"},
	{id:"colComments", label:"Status Comment"},
	{id:"colDueBy", label:"Due By Comment"},
	{id:"colSumTaskName", label:"Summary Task Name"}
 ]''
 , NULL, NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''ExpandCollapse'', 2, ''Collapsed / Expanded Mode'', ''1'', ''Partial'', ''lookup'', ''Collapsed:0|Partial:1|Expanded:2'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''H2'', 3, ''Calendar Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''UseTimelineColors'', 4, ''Use Timeline Section Colors on Calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''IncludeProjects'', 5, ''Include Projects on Calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''IncludeSummaryTasks'', 6, ''Include Summary Tasks on Calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''IncludeDetailTasks'', 7, ''Include Detail Tasks on Calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''UseEndDates'', 8, ''Show End Dates Only on Calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''ShowProjectNames'', 9, ''Show Project Names on Calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''trafficCalendar'', ''ShowProjectNumbers'', 10, ''Show Project Numbers on Calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

 /*************************************************************************************************************************
Staff Schedule Details
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''staffScheduleDetail'', ''Staff Schedule Details'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''staffScheduleDetail'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''staffScheduleDetail'', ''grdStaffScheduleDetailBucketCols'', 3, ''Columns'', ''stfSchdDtlSTPlanStart,stfSchdDtlSTPlanComplete,stfSchdDtlSTPlanDuration,stfSchdDtlSTHours,stfSchdDtlSTActualHours,stfSchdDtlSTRemaining,stfSchdDtlSTBucketHours,stfSchdDtlSTPercomp'', NULL, ''grid'', 
''[	{id:"stfSchdDtlSTPlanStart", label:"Plan Start"},
	{id:"stfSchdDtlSTPlanComplete", label:"Plan Complete"},
	{id:"stfSchdDtlSTPlanDuration", label:"Days"},
	{id:"stfSchdDtlSTHours", label:"Hours"},
	{id:"stfSchdDtlSTActualHours", label:"Actual"},
	{id:"stfSchdDtlSTRemaining", label:"Remaining"},
	{id:"stfSchdDtlSTBucketHours", label:"Hours Per Period"},
	{id:"stfSchdDtlSTPercomp", label:"%"},
	{id:"stfSchdDtlSTSummaryTask", label:"Summary Task"},
	{id:"stfSchdDtlSTProjectFN", label:"Project"},
	{id:"stfSchdDtlSTUserService", label:"Service"},
	{id:"stfSchdDtlSTProjectStatus", label:"Project Status"},
	{id:"stfSchdDtlSTComments", label:"Comments"}
 ]''
 , NULL, NULL, NULL, NULL)


 
 /*************************************************************************************************************************
Staff Schedule Day Details
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''staffScheduleDayDetail'', ''Staff Schedule Day Details'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''staffScheduleDayDetail'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''staffScheduleDayDetail'', ''grdStaffScheduleDayDetailBucketCols'', 3, ''Columns'', ''stfSchdDtlSTPlanStart,stfSchdDtlSTPlanComplete,stfSchdDtlSTPlanDuration,stfSchdDtlSTHours,stfSchdDtlSTActualHours,stfSchdDtlSTBucketHours,stfSchdDtlSTRemaining,stfSchdDtlSTPercomp'', NULL, ''grid'', 
''[	{id:"stfSchdDtlSTSummaryTask", label:"Summary Task"},
	{id:"stfSchdDtlSTUserService", label:"Service"},
	{id:"stfSchdDtlSTProjectStatus", label:"Project Status"},
	{id:"stfSchdDtlSTPlanStart", label:"Plan Start"},
	{id:"stfSchdDtlSTPlanComplete", label:"Plan Complete"},
	{id:"stfSchdDtlSTPlanDuration", label:"Days"},
	{id:"stfSchdDtlSTHours", label:"Hours"},
	{id:"stfSchdDtlSTActualHours", label:"Actual"},
	{id:"stfSchdDtlSTRemaining", label:"Remaining"},
	{id:"stfSchdDtlSTBucketHours", label:"Hours Per Day"},
	{id:"stfSchdDtlSTPercomp", label:"%"},	
	{id:"stfSchdDtlSTComments", label:"Comments"},
	{id:"stfSchdDtlSTTrafficComments", label:"Traffic Comments"},
	{id:"stfSchdDtlSTDateTaskAssigned", label:"Date Task Assigned"},
	{id:"stfSchdDtlSTTaskDescription", label:"Task Description"},
	{id:"stfSchdDtlSTDueBy", label:"Due By Comment"},
	{id:"stfSchdDtlSTPredComplete", label:"Predecessors Complete"},
	{id:"stfSchdDtlSTConstraintName", label:"Constraint"},
	{id:"stfSchdDtlSTConstraintDate", label:"Constraint Date"},
	{id:"stfSchdDtlSTProjectColor", label:"Project Color"}
 ]''
 , NULL, NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''staffScheduleDayDetail'', ''HideZeroHourTask'', 4, ''Hide Zero Hour Tasks'', '''', NULL, ''checkbox'', NULL, NULL, ''hide zero tasks within date range'')


 
 
 /*************************************************************************************************************************
Staff Schedule Week Details
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''staffScheduleWeekDetail'', ''Staff Schedule Week Details'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''staffScheduleWeekDetail'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''staffScheduleWeekDetail'', ''grdStaffScheduleDetailBucketCols'', 3, ''Columns'', ''stfSchdDtlSTProjectFullName,userServiceName,planStart,planComplete,hours,perccomp'', NULL, ''grid'', 
''[	{id:"stfSchdDtlSTProjectFullName", label:"Project"},
	{id:"stfSchdWeelDTLSummaryTask", label:"Summary Task"},
	{id:"userServiceName", label:"Service"},
	{id:"stfSchdWeekDTLProjectStatus", label:"Project Status"},
	{id:"planStart", label:"Plan Start"},
	{id:"planComplete", label:"Plan Complete"},
	{id:"stfSchdWeekDTLPlanDuration", label:"Days"},
	{id:"hours", label:"Hours"},
	{id:"stfSchdWeekDtlActualHours", label:"Actual"},
	{id:"stfSchdWeekDTLRemaining", label:"Remaining"},
	{id:"perccomp", label:"%"},	
	{id:"stfSchdWeekDTLComments", label:"Comments"},	
	{id:"stfSchdWeekDTLDateTaskAssigned", label:"Date Task Assigned"},
	{id:"stfSchdWeekDTLTaskDescription", label:"Task Description"},
	{id:"stfSchdWeekDTLTrafficComments", label:" Traffic Comments"},
	{id:"stfSchdWeekDTLDueBy", label:"Due By Comment"},
	{id:"detailPredComplete", label:"Predecessors Complete"},
	{id:"stfSchdWeekDTLConstraintName", label:"Constraint"},
	{id:"stfSchdWeekDTLConstraintDate", label:"Constraint Date"},
	{id:"stfSchdWeekDTLProjectColor", label:"Project Color"}
 ]''
 , NULL, NULL, NULL, NULL)
  INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''staffScheduleWeekDetail'', ''HideZeroHourTask'', 4, ''Hide Zero Hour Tasks'', '''', NULL, ''checkbox'', NULL, NULL, ''hide zero tasks within date range'')


 
 
/*************************************************************************************************************************
GL Transactions Detail grids
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''glTransactionsDetail'', ''Posting Detail Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glTransactionsDetail'', ''H1'', 0, ''Accrual Detail Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

if @GLCompaniesWithForeignCurrencies = 0

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''glTransactionsDetail'', ''grdPostingDetailAccrualCols'', 1, ''Columns'', ''accrualAccountName,accrualDebit,accrualCredit,accrualProject,accrualReconciliation'', NULL, ''grid'', 

''[
{id:"accrualAccountName", label:"Account"},
{id:"accrualDebit", label:"Debit"},
{id:"accrualCredit", label:"Credit"},
{id:"accrualCurrency", label:"Currency"},
{id:"accrualExchangeRate", label:"Exch Rate"},
{id:"accrualHDebit", label:"Debit HC"},
{id:"accrualHCredit", label:"Credit HC"},
{id:"accrualGLCompany", label:"GL Company"},
{id:"accrualClass", label:"Class"},
{id:"accrualProject", label:"Project"},
{id:"accrualOffice", label:"Office"},
{id:"accrualDepartment", label:"Department"},
{id:"accrualReconciliation", label:"Reconciliation"}
]''
	 , NULL, NULL, null, NULL)

else -- add the fields specific to GL companies 

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''glTransactionsDetail'', ''grdPostingDetailAccrualCols'', 1, ''Columns'', ''accrualAccountName,accrualDebit,accrualCredit,accrualProject,accrualReconciliation'', NULL, ''grid'', 

''[
{id:"accrualAccountName", label:"Account"},
{id:"accrualDebit", label:"Debit"},
{id:"accrualCredit", label:"Credit"},
{id:"accrualCurrency", label:"Currency"},
{id:"accrualExchangeRate", label:"Exch Rate"},
{id:"accrualHDebit", label:"Debit HC"},
{id:"accrualHCredit", label:"Credit HC"},
{id:"accrualGLCompany", label:"GL Company"},
{id:"accrualGLCCurrency", label:"Company Currency"},
{id:"accrualGLCExchangeRate", label:"Company Rate"},
{id:"accrualGLCDebit", label:"Company Debit"},
{id:"accrualGLCCredit", label:"Company Credit"},
{id:"accrualClass", label:"Class"},
{id:"accrualProject", label:"Project"},
{id:"accrualOffice", label:"Office"},
{id:"accrualDepartment", label:"Department"},
{id:"accrualReconciliation", label:"Reconciliation"}
]''
	 , NULL, NULL, null, NULL)



INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glTransactionsDetail'', ''H2'', 2, ''Cash Detail Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

if @GLCompaniesWithForeignCurrencies = 0

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''glTransactionsDetail'', ''grdPostingDetailCashCols'', 3, ''Columns'', ''cashAccountName,cashDebit,cashCredit,cashProject,cashAppliedRef'', NULL, ''grid'', 

''[
{id:"cashAccountName", label:"Account"},
{id:"cashDebit", label:"Debit"},
{id:"cashCredit", label:"Credit"},
{id:"cashCurrency", label:"Currency"},
{id:"cashExchangeRate", label:"Exch Rate"},
{id:"cashHDebit", label:"Debit HC"},
{id:"cashHCredit", label:"Credit HC"},
{id:"cashGLCompany", label:"GL Company"},
{id:"cashClass", label:"Class"},
{id:"cashProject", label:"Project"},
{id:"cashOffice", label:"Office"},
{id:"cashDepartment", label:"Department"},
{id:"cashAppliedRef", label:"Applied Ref"}
]''
	 , NULL, NULL, null, NULL)

else -- add the fields specific to GL companies

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''glTransactionsDetail'', ''grdPostingDetailCashCols'', 3, ''Columns'', ''cashAccountName,cashDebit,cashCredit,cashProject,cashAppliedRef'', NULL, ''grid'', 

''[
{id:"cashAccountName", label:"Account"},
{id:"cashDebit", label:"Debit"},
{id:"cashCredit", label:"Credit"},
{id:"cashCurrency", label:"Currency"},
{id:"cashExchangeRate", label:"Exch Rate"},
{id:"cashHDebit", label:"Debit HC"},
{id:"cashHCredit", label:"Credit HC"},
{id:"cashGLCompany", label:"GL Company"},
{id:"cashGLCCurrency", label:"Company Currency"},
{id:"cashGLCExchangeRate", label:"Company Rate"},
{id:"cashGLCDebit", label:"Company Debit"},
{id:"cashGLCCredit", label:"Company Credit"},
{id:"cashClass", label:"Class"},
{id:"cashProject", label:"Project"},
{id:"cashOffice", label:"Office"},
{id:"cashDepartment", label:"Department"},
{id:"cashAppliedRef", label:"Applied Ref"}
]''
	 , NULL, NULL, null, NULL)

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''globalSearch'', ''Search Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''H1'', 0, ''Application Sections'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''ActiveProjects'', 1, ''Active Projects'', ''1'', NULL, ''checkbox'', NULL, NULL, ''Search contains Project Number, Project Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''InactiveProjects'', 2, ''Inactive Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Project Number, Project Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''ActivePlanningProjects'', 3, ''Active Planning Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Project Number, Project Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''InactivePlanningProjects'', 4, ''Inactive Planning Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Project Number, Project Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''ActiveCampaigns'', 5, ''Active Campaigns'', ''1'', NULL, ''checkbox'', NULL, NULL, ''Search contains Campaign ID, Campaign Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''InactiveCampaigns'', 6, ''Inactive Campaigns'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Campaign ID, Campaign Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Meetings'', 7, ''Meetings'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Subject'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Activities'', 8, ''Activities'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains the conversation subject only'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''ActivityNotes'', 9, ''Conversation Notes'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains the conversation notes also. This can dramatically slow down searching'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Leads'', 10, ''Leads'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains First Name, Last Name, Company Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Contacts'', 11, ''Contacts'', ''1'', NULL, ''checkbox'', NULL, NULL, ''Search contains First Name, Last Name, Company Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Companies'', 12, ''Companies'', ''1'', NULL, ''checkbox'', NULL, NULL, ''Search contains Company Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Opportunities'', 13, ''Opportunities'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Subject, First name, Last Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Invoices'', 14, ''Client Invoices'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Invoice Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Receipts'', 15, ''Receipts'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Reference Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''PurchaseOrders'', 16, ''Purchase Orders'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Purchase Order Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''VendorInvoices'', 17, ''Vendor Invoices'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Invoice Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''VendorPayments'', 18, ''Vendor Payments'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Check Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''CreditCardCharges'', 19, ''Credit Card Charges'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Invoice Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Employees'', 20, ''Employees'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains First Name, Last Name, Company Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''ProjectRequests'', 21, ''Project Requests'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Request ID, Subject'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''InsertionOrders'', 22, ''Insertion Orders'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Purchase Order Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''BroadcastOrders'', 23, ''Broadcast Orders'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Purchase Order Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''MediaEstimates'', 24, ''Media Estimates'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Estimate ID, Estimate Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''RequestQuotes'', 25, ''Request For Quotes'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Subject, Description, Project Number, Project name, Company Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''JournalEntries'', 26, ''Journal Entries'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Journal Number, Company Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''ExpenseReports'', 27, ''Expense Reports'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Expense Report Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Stations'', 28, ''Stations'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Station ID, Station Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''Publications'', 29, ''Publications'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Publication ID, Publication Name'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''ActiveEstimates'', 30, ''Active Estimates'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Estimate Name, Estimate Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''InactiveEstimates'', 31, ''Inactive Estimates'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Estimate Name, Estimate Number'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''globalSearch'', ''MediaPlans'', 32, ''Media Plans'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Search contains Plan ID, Plan Name'')

/*************************************************************************************************************************
Credit Card Connector
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''creditCardConnector'', ''Credit Card Connector'', '''', 0)

/*
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''creditCardConnector'', ''H1'', 0, ''Display Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''creditCardConnector'', ''HideClearedTransactions'', 1, ''Hide Cleared Transactions'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''creditCardConnector'', ''HideCreditTransactions'', 2, ''Hide Payments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, Required) 
Values (''creditCardConnector'', ''DateOption'', 3, ''Date Range'', ''6'', ''All'', ''lookup'', ''Due on or before Today:0|Due on or before a week from Today:1|Due on or before 2 weeks from Today:2|Start on or before Today:3|Start on or before a week from Today:4|Start on or before 2 weeks from Today:5|All:6'', NULL, NULL, 0)
*/
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''creditCardConnector'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''creditCardConnector'', ''grdEntriesCols'', 1, ''Columns'', ''transactionPostedDate,amount,payeeName,fitid,postingDate,transactionType,glCompanyID,expenseAccountNumber,billable,receipt,officeID,departmentName,project,splitProjects,task,item,class,vendor,voucher,splitVouchers,userName,memo,comment,processedStatus,salesTax,salesTaxAmount,salesTax2,salesTax2Amount'', NULL, ''grid'', 

''[	{id:"transactionPostedDate", label:"Date"},
	{id:"amount", label:"Amount"},
	{id:"payeeName", label:"Payee Name"},
	{id:"fitid", label:"FITID"},
	{id:"postingDate", label:"Posting Date"},
	{id:"transactionType", label:"Transaction Type"},
	{id:"glCompanyID", label:"GL Company"},
	{id:"expenseAccountNumber", label:"Expense Account Number"},
	{id:"billable", label:"Billable"},
	{id:"receipt", label:"Receipt"},
	{id:"overhead", label:"Overhead"},
	{id:"officeID", label:"Office"},
	{id:"departmentName", label:"Department Name"},
	{id:"project", label:"Project"},
	{id:"splitProjects", label:"Split Projects"},
	{id:"task", label:"Task"},
	{id:"item", label:"Item"},
	{id:"class", label:"Class"},
	{id:"vendor", label:"Vendor"},
	{id:"voucher", label:"Invoice Number"},
	{id:"splitVouchers", label:"Split Invoices"},
	{id:"splitOrders", label:"Orders"},
	{id:"userName", label:"Charged By"},
	{id:"memo", label:"Memo"},
	{id:"comment", label:"Comment"},
	{id:"processedStatus", label:"Status"},
	{id:"salesTax", label:"Sales Tax"},
	{id:"salesTaxAmount", label:"Sales Tax Amount"},
	{id:"salesTax2", label:"Sales Tax2"},
	{id:"attachmentCount", label:"Attachment Count"},
	{id:"salesTax2Amount", label:"Sales Tax2 Amount"},
    {id:"markUp", label:"Markup"},
	{id:"chargeRef", label:"Charge Reference"}
 ]''
	 , NULL, NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''creditCardConnector'', ''NumberOfDigits'', 2, ''Number of characters to check for duplicate entries'', 20, NULL, ''number:n0'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''creditCardConnector'', ''ShowExpenseReportItems'', 3, ''Show Expense Report Items'', 1, NULL, ''checkbox'', NULL, NULL, NULL)
/*************************************************************************************************************************
Credit Card Connector - UnMatched Charges
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''unMatchedCharges'', ''Unmatched Charges'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''unMatchedCharges'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''unMatchedCharges'', ''grdUnMatchedChargesCols'', 1, ''Columns'', ''invoiceDateMatchedCharges,invoiceNumberMatchedCharges,voucherTotalMatchedCharges,projectFullNameMatchedCharges,vendorFullNameMatchedCharges,purchasedFromMatchedCharges,description'', NULL, ''grid'', 
''[  {id:"invoiceDateMatchedCharges", label:"Date"},
    {id:"invoiceNumberMatchedCharges", label:"Invoice Number"},
	{id:"voucherTotalMatchedCharges", label:"Total"},
	{id:"projectFullNameMatchedCharges", label:"Project"},
	{id:"vendorFullNameMatchedCharges", label:"Vendor"},
	{id:"purchasedFromMatchedCharges", label:"Purchased From"},
	{id:"description", label:"Description"}
 ]''
	 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Credit Card Connector - Split Projects Panel
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''editProjects'', ''Split Projects'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''editProjects'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''editProjects'', ''grdSplitProjectsCols'', 1, ''Columns'', ''projectSplitProjects,taskSplitProjects,glCompanyIDSplitProjects,classSplitProjects,itemSplitProjects,descriptionSplitProjects,markupSplitProjects,expenseAccountSplitProjects,amountSplitProjects'', NULL, ''grid'', 
''[  {id:"projectSplitProjects", label:"Project"},
    {id:"taskSplitProjects", label:"Task"},
	{id:"glCompanyIDSplitProjects", label:"GL Company"},
	{id:"classSplitProjects", label:"Class"},	
	{id:"itemSplitProjects", label:" Item Name"},
	{id:"descriptionSplitProjects", label:"Description"},
	{id:"markupSplitProjects", label:"Markup"},
	{id:"expenseAccountSplitProjects", label:"Expense Account"},
	{id:"amountSplitProjects", label:"Amount"}
	
 ]''
	 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Notifications 
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''myNotifications'', ''Notifications Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''myNotificationsSettings'', 0, ''Notification Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiTimeSheets'', 1, ''Time Sheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiTimeUnsubmitted'', 2, ''Unsubmitted Time Sheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiExpenseReports'', 3, ''Expense Reports'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiPurchaseOrders'', 4, ''Purchase Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiInsertionOrders'', 5, ''Insertion Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiBroadcastOrders'', 6, ''Broadcast Orders'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiVendorInvoices'', 7, ''Vendor Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiCreditCC'', 8, ''Credit Card Charges'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiCreditCCC'', 9, ''Credit Card Connector'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiClientInvoices'', 10, ''Client Invoices'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiEstimates'', 11, ''Estimates'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiProjectRequests'', 12, ''Project Requests'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiBillingToReview'', 13, ''Billing Worksheets To Review'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiBillingToApprove'', 14, ''Billing Worksheets To Approve'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiMyMeetings'', 15, ''My Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiOthersMeetings'', 16, ''Others Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiDeliverables'', 17, ''Deliverables'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiShowRejected'', 18, ''Show Rejected Items'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiBackupApprovals'', 19, ''Backup Approvals'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiChanges'', 20, ''Change Request'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiTrackingForms'', 21, ''Tracking Forms'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiSystemMessages'', 22, ''Show Unread System Messages'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myNotifications'', ''NotiForecasts'', 23, ''Revenue Forecasts'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************
Approvals
**************************************************************************************************************************/
-- Timesheet Approvals
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''timesheetApprovals'', ''Time Sheet Approvals'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timesheetApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''timesheetApprovals'', ''grdTimesheetApprovalsCols'', 1, ''Columns'', ''reference,startDate,endDate,totalHours,totalPauseHours,approvalComments'', NULL, ''grid'', 
''[	{id:"reference", label:"Name"},
	{id:"startDate", label:"Start Date"},
	{id:"endDate", label:"End Date"},
	{id:"totalHours", label:"Hours"},
	{id:"totalPauseHours", label:"Hours Paused"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"totalBillableHours", label:"Billable Hours"},
	{id:"totalNonBillableHours", label:"Non Billable Hours"}
 ]''
 , NULL, NULL, NULL, NULL)

-- Expense Report Approvals
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''expensesApprovals'', ''Expense Report Approvals'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''expensesApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''expensesApprovals'', ''grdExpenseApprovalsCols'', 1, ''Columns'', ''userName,notifyEmail,reference,startDate,endDate,totalCost,approvalComments'', NULL, ''grid'', 
''[	{id:"userName", label:"Name"},
    {id:"notifyEmail", label:"Email"},
    {id:"reference", label:"Number"},
	{id:"startDate", label:"Start Date"},
	{id:"endDate", label:"End Date"},
	{id:"totalCost", label:"Total Cost"},
	{id:"approvalComments", label:"Your Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

-- Billing Worksheet Approvals 
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingWorksheetsApprovals'', ''Billing Worksheet Approvals'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingWorksheetsApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''billingWorksheetsApprovals'', ''grdBillingWorksheetsCols'', 1, ''Columns'', ''reference,project,methodName,toBill,budget,amountBilled,approvalComments,dueDate'', NULL, ''grid'', 
''[	{id:"reference", label:"ID"},
    {id:"project", label:"Project"},
    {id:"methodName", label:"Type"},
	{id:"toBill", label:"to Bill"},
	{id:"budget", label:"Budget"},
	{id:"amountBilled", label:"Amount Billed"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"clientID", label:"Client ID"},
	{id:"clientName", label:"Client Name"},
	{id:"campaignFullNameName", label:"Campaign Full Name"},
	{id:"productName", label:"Project Product Name"},
	{id:"divisionName", label:"Project Division Name"},
	{id:"projectBillingStatus", label:"Project Billing Status"},
	{id:"projectStatus", label:"Project Status"},
	{id:"worksheetComments", label:"Worksheet Comment"},
	{id:"dueDate", label:"Due Date"}
 ]''
 , NULL, NULL, NULL, NULL)
 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingWorksheetsApprovals'', ''groupByClient'', 2, ''Group By Client'', 0 , NULL, ''checkbox'', NULL, NULL, NULL)



-- Voucher Approvals
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''voucherApprovals'', ''Vendor Invoice Approvals'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''voucherApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''voucherApprovals'', ''grdVoucherApprovalsCols'', 1, ''Columns'', ''reference,invoiceDate,vendorName,voucherTotal,description,approvalComments,projectFullName'', NULL, ''grid'', 
''[	{id:"reference", label:"Invoice Number"},
	{id:"invoiceDate", label:"Invoice Date"},
	{id:"vendorName", label:"Purchased From"},
	{id:"voucherTotal", label:"Voucher Total"},
	{id:"salesTaxAmount", label:"Sales Tax Total"},
	{id:"description", label:"Description"},
	{id:"createdBy", label:"Created By"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"projectNumber", label:"Project Number"},
	{id:"projectFullName", label:"Project Full Name"},
	{id:"approverName", label:"Approver Name"}
 ]''
 , NULL, NULL, NULL, NULL)

  -- Voucher CC Approvals - aka Credit Card
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''voucherCCApprovals'', ''Credit Card Approvals'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''voucherCCApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''voucherCCApprovals'', ''grdChargesCols'', 1, ''Columns'', ''reference,chargeDate,vendor,purchasedBy,purchasedFrom,voucherTotal,approvalComments'', NULL, ''grid'', 
''[	{id:"reference", label:"Reference"},
	{id:"chargeDate", label:"Charge Date"},
	{id:"vendor", label:"Vendor"},
	{id:"purchasedBy", label:"Purchased By"},
	{id:"purchasedFrom", label:"Purchased From"},
	{id:"voucherTotal", label:"Net Amount"},
	{id:"voucherID", label:"VoucherID"},
	{id:"createdBy", label:"Created By"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"voucherDescription", label:"Description"},
	{id:"creditCardNumber", label:"Credit Card Number"},
	{id:"postingDate", label:"Posting Date"}	
 ]''
 , NULL, NULL, NULL, NULL)

 -- Journal Entry Approvals
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''jeApprovals'', ''Journal Entry Approvals'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''jeApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''jeApprovals'', ''grdJEApprovalsCols'', 1, ''Columns'', ''reference,postingDate,approvalComments,rejectionComments,approverName'', NULL, ''grid'', 
''[	{id:"reference", label:"Journal Entry Number"},
	{id:"postingDate", label:"Posting Date"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"rejectionComments", label:"Reject Number"},
	{id:"approverName", label:"Approver"}
 ]''
 , NULL, NULL, NULL, NULL)

-- Calendar
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''calendar'', ''Calendar Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''SendNotification'', 1, ''Send Notifications'', ''0'', ''Always'', ''lookup'', ''Always:0|Ask:1|Never:2'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''GroupOther'', 2, ''Group other calendars'', '''', ''No Grouping'', ''lookup'', ''No Grouping:|Department:DepartmentName|Office:OfficeName'', NULL, NULL) 

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''ShowLegend'', 3, ''Show legend with calendar'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''WorkWeek'', 4, ''Display work week in week view'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''Show12Hour'', 5, ''Show 12 hour day'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''PartialDaySolidColor'', 6, ''Show non-All Day meetings as solid color'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calendar'', ''ReminderTime'', 7, ''Default reminder time'', ''30'', NULL, ''lookup'', 
		''No Reminder:0'' +
        ''|5 Minutes Before:5'' +
        ''|10 Minutes Before:10'' +
        ''|15 Minutes Before:15'' +
        ''|30 Minutes Before:30'' +
        ''|1 Hour Before:60'' +
        ''|2 Hours Before:120'' +
        ''|3 Hours Before:180'' +
        ''|4 Hours Before:240'' +
        ''|5 Hours Before:300'' +
        ''|6 Hours Before:360'' +
        ''|7 Hours Before:420'' +
        ''|8 Hours Before:480'' +
        ''|9 Hours Before:540'' +
        ''|10 Hours Before:600'' +
        ''|11 Hours Before:660'' +
        ''|0.5 Days Before:720'' +
        ''|18 Hours Before:1080'' +
        ''|1 Day Before:1440'' +
        ''|2 Days Before:2880'' +
        ''|3 Days Before:4320'' +
        ''|4 Days Before:5760'' +
        ''|5 Days Before:7200'' +
        ''|6 Days Before:8640'' +
        ''|1 Week Before:10080'' +
        ''|2 Weeks Before:20160|'', NULL, NULL) 

 -- deliverable Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''deliverableApprovals'', ''Deliverable Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''deliverableApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''deliverableApprovals'', ''grdDeliverablesCols'', 1, ''Columns'', ''project,deliverableName,roundName,dueDate'', NULL, ''grid'', 
''[	{id:"project", label:"Project"},
	{id:"deliverableName", label:"Name"},
	{id:"roundName", label:"Round"},
	{id:"dueDate", label:"Due Date"},
	{id:"instructions", label:"Instructions"},
	{id:"dateSent", label:"Date/Time Sent"},
	{id:"currentStep", label:"Current Step"},
	{id: "taskFullName", label:"Task"} 
 ]''
 , NULL, NULL, NULL, NULL)

  -- Broadcast Order Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''broadcastOrderApprovals'', ''Broadcast Order Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''broadcastOrderApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''broadcastOrderApprovals'', ''grdBCOrdersCols'', 1, ''Columns'', ''reference,poDate,vendorName,netCost,approvalComments'', NULL, ''grid'', 
''[	{id:"reference", label:"BO Number"},
	{id:"poDate", label:"BO Date"},
	{id:"vendorName", label:"Vendor"},
	{id:"netCost", label:"Net Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"projectName", label:"Project Name"},
	{id:"clientName", label:"Client Name"},
	{id:"createdBy", label:"Created By"},
	{id:"approvalComments", label:"Your Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

 -- estimate Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''estimateApprovals'', ''Estimate Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''estimateApprovals'', ''grdEstimatesCols'', 1, ''Columns'', ''reference,project,methodName,estimateTotal,approvalComments'', NULL, ''grid'', 
''[	{id:"reference", label:"ID"},
	{id:"project", label:"Project"},
	{id:"methodName", label:"Type"},
	{id:"estimateTotal", label:"Total"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"clientName", label:"Client Name"}
 ]''
 , NULL, NULL, NULL, NULL)

 -- Insertion Order Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''insertionOrderApprovals'', ''Insertion Order Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''insertionOrderApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''insertionOrderApprovals'', ''grdIOOrdersCols'', 1, ''Columns'', ''reference,poDate,vendorName,netCost,approvalComments'', NULL, ''grid'', 
''[	{id:"reference", label:"IO Number"},
	{id:"poDate", label:"IO Date"},
	{id:"vendorName", label:"Vendor"},
	{id:"netCost", label:"Net Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"projectName", label:"Project Name"},
	{id:"clientName", label:"Client Name"},
	{id:"createdBy", label:"Created By"},
	{id:"approvalComments", label:"Your Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

 
 -- Invoice Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''invoiceApprovals'', ''Invoice Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''invoiceApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''invoiceApprovals'', ''grdInvoicesCols'', 1, ''Columns'', ''reference,invoiceDate,client,invoiceTotal,projectNumber,approvalComments'', NULL, ''grid'', 
''[	{id:"reference", label:"Invoice Number"},
	{id:"invoiceDate", label:"Invoice Date"},
	{id:"client", label:"Client"},
	{id:"invoiceTotal", label:"Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"createdBy", label:"Created By"},
	{id:"approvalComments", label:"Your Comments"}
 ]''

 , NULL, NULL, NULL, NULL)

--Project Request Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectRequestApprovals'', ''Project Request Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectRequestApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectRequestApprovals'', ''grdProjectRequestCols'', 1, ''Columns'', ''reference,companyName,subject,requestedBy,dateActivated,dueDate,projectDueDate,assignedUser'', NULL, ''grid'', 
''[	{id:"reference", label:"ID"},
	{id:"companyName", label:"Client"},
	{id:"subject", label:"Project Name"},
	{id:"requestedBy", label:"Requested By"},
	{id:"dateActivated", label:"Date Activated"},
	{id:"dueDate", label:"Due"},
	{id:"projectDueDate", label:"Project Due Date"},
	{id:"assignedUser", label:"Assigned User"},
	{id:"lastComment", label:"Last Comment"},
	{id:"projectDescription", label:"Project Description"},
	{id:"campaignID", label:"Campaign ID"},
	{id:"campaignName", label:"Campaign Name"}
 ]''
 , NULL, NULL, ''RequestDef'', NULL)

-- Purchase Order Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''purchaseOrderApprovals'', ''Purchase Order Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchaseOrderApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''purchaseOrderApprovals'', ''grdPOOrdersCols'', 1, ''Columns'', ''reference,poDate,vendorName,netCost,approvalComments'', NULL, ''grid'', 
''[	{id:"reference", label:"PO Number"},
	{id:"poDate", label:"PO Date"},
	{id:"vendorName", label:"Vendor"},
	{id:"netCost", label:"Net Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"projectName", label:"Project Name"},
	{id:"projectFullName", label:"Project Full Name"},
	{id:"clientName", label:"Client Name"},
	{id:"createdBy", label:"Created By"},
	{id:"approvalComments", label:"Your Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

-- My Meeting Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''myMeetingApprovals'', ''My Meeting Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''myMeetingApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1)
Values (''myMeetingApprovals'', ''grdMeetingCols'', 1, ''Columns'', ''reference,eventStart,eventEnd,attendee,location'', NULL, ''grid'', 
''[	{id:"reference", label:"Meeting"},
	{id:"eventTime", label:"Time"},
	{id:"attendee", label:"Attendee"},
	{id:"location", label:"Location"}
 ]''
 , NULL, NULL, NULL, NULL)

-- Other Meeting Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''otherMeetingApprovals'', ''Other Meeting Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''otherMeetingApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1)
Values (''otherMeetingApprovals'', ''grdMeetingCols'', 1, ''Columns'', ''reference,eventStart,eventEnd,attendee,location'', NULL, ''grid'', 
''[	{id:"reference", label:"Meeting"},
	{id:"eventTime", label:"Time"},
	{id:"attendee", label:"Attendee"},
	{id:"location", label:"Location"}
 ]''
 , NULL, NULL, NULL, NULL)

 -- Submitted Meeting Approvals
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''submittedMeetingApprovals'', ''My Meeting Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''submittedMeetingApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1)
Values (''submittedMeetingApprovals'', ''grdMeetingCols'', 1, ''Columns'', ''reference,eventStart,eventEnd,createdBy,location'', NULL, ''grid'', 
''[	{id:"reference", label:"Meeting"},
	{id:"eventTime", label:"Time"},
	{id:"createdBy", label:"Created By"},
	{id:"location", label:"Location"}
 ]''
 , NULL, NULL, NULL, NULL)

 --Change Request Approval
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''changeRequestApprovals'', ''Change Request Approval'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''changeRequestApprovals'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''changeRequestApprovals'', ''grdChangeRequestCols'', 1, ''Columns'', ''changeFullName,companyName,subject,requestedBy,dateActivated,dueDate,assignedUser,approvalComments,'', NULL, ''grid'', 
''[	{id:"changeFullName", label:"ID"},
	{id:"companyName", label:"Client"},
	{id:"projectName", label:"Project Name"},
	{id:"subject", label:"Subject"},
	{id:"requestedBy", label:"Requested By"},
	{id:"dateActivated", label:"Date Activated"},
	{id:"dueDate", label:"Due"},
	{id:"assignedUser", label:"Assigned User"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"lastComment", label:"Last Comment"},
	{id:"description", label:"Description"},
	{id:"changeType", label:"Type"},
	{id:"entityNumber", label:"Entity ID"},
	{id:"entityName", label:"Entity Name"},
	{id:"entityFullName", label:"Entity Full Name"}
	]''
	, NULL, NULL, ''ChangeDef'', NULL)

 /*************************************************************************************************************************
Rejections
**************************************************************************************************************************/
-- Timesheet Rejections
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''timesheetRejections'', ''Time Sheet Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timesheetRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''timesheetRejections'', ''grdTimesheetApprovalsCols'', 1, ''Columns'', ''reference,startDate,endDate,totalHours,totalPauseHours,rejectionComments'', NULL, ''grid'', 
''[	{id:"reference", label:"Name"},
	{id:"startDate", label:"Start Date"},
	{id:"endDate", label:"End Date"},
	{id:"totalHours", label:"Hours"},
	{id:"totalPauseHours", label:"Hours Paused"},
	{id:"rejectionComments", label:"Reject Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

-- Expense Report Rejections
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''expensesRejections'', ''Expense Report Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''expensesRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''expensesRejections'', ''grdExpenseApprovalsCols'', 1, ''Columns'', ''userName,reference,startDate,endDate,totalCost,rejectionComments'', NULL, ''grid'', 
''[	{id:"userName", label:"Name"},
    {id:"reference", label:"Number"},
	{id:"startDate", label:"Start Date"},
	{id:"endDate", label:"End Date"},
	{id:"totalCost", label:"Total Cost"},
	{id:"rejectionComments", label:"Reject Comments"},
	{id:"creditCardNumber", label:"Credit Card Number"}
 ]''
 , NULL, NULL, NULL, NULL)


-- Voucher Rejections
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''voucherRejections'', ''Vendor Invoice Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''voucherRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''voucherRejections'', ''grdVoucherApprovalsCols'', 1, ''Columns'', ''reference,invoiceDate,vendorName,voucherTotal,description,rejectionComments,projectNumber'', NULL, ''grid'', 
''[	{id:"reference", label:"Invoice Number"},
	{id:"invoiceDate", label:"Invoice Date"},
	{id:"vendorName", label:"Purchased From"},
	{id:"voucherTotal", label:"Voucher Total"},
	{id:"salesTaxAmount", label:"Sales Tax Total"},
	{id:"description", label:"Description"},
	{id:"createdBy", label:"Created By"},
	{id:"rejectionComments", label:"Rejection Comments"},
	{id:"projectNumber", label:"Project Number"}
 ]''
 , NULL, NULL, NULL, NULL)

  -- Voucher CC Rejections - aka Credit Card
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''voucherCCRejections'', ''Credit Card Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''voucherCCRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''voucherCCRejections'', ''grdChargesCols'', 1, ''Columns'', ''reference,chargeDate,vendor,purchasedBy,purchasedFrom,voucherTotal,rejectionComments'', NULL, ''grid'', 
''[	{id:"reference", label:"Reference"},
	{id:"chargeDate", label:"Charge Date"},
	{id:"vendor", label:"Vendor"},
	{id:"purchasedBy", label:"Purchased By"},
	{id:"purchasedFrom", label:"Purchased From"},
	{id:"voucherTotal", label:"Net Amount"},
	{id:"voucherID", label:"VoucherID"},
	{id:"createdBy", label:"Created By"},
	{id:"rejectionComments", label:"Rejection Comments"},
	{id:"voucherDescription", label:"Description"},
	{id:"creditCardNumber", label:"Credit Card Number"}
 ]''
 , NULL, NULL, NULL, NULL)

  -- Journal Entry Rejections
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''jeRejections'', ''Journal Entry Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''jeRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''jeRejections'', ''jeRejections'', 1, ''Columns'', ''reference,postingDate,approvalComments,rejectionComments,approverName'', NULL, ''grid'', 
''[	{id:"reference", label:"Journal Entry Number"},
	{id:"postingDate", label:"Posting Date"},
	{id:"approvalComments", label:"Your Comments"},
	{id:"rejectionComments", label:"Reject Number"},
	{id:"approverName", label:"Approver"}
 ]''
 , NULL, NULL, NULL, NULL)

  -- Broadcast Order Rejection
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''broadcastOrderRejections'', ''Broadcast Order Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''broadcastOrderRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''broadcastOrderRejections'', ''grdBCOrdersCols'', 1, ''Columns'', ''reference,poDate,vendorName,netCost,rejectionComments'', NULL, ''grid'', 
''[	{id:"reference", label:"BO Number"},
	{id:"poDate", label:"BO Date"},
	{id:"vendorName", label:"Vendor"},
	{id:"netCost", label:"Net Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"projectName", label:"Project Name"},
	{id:"clientName", label:"Client Name"},
	{id:"createdBy", label:"Created By"},
	{id:"rejectionComments", label:"Reject Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

 -- estimate Rejections
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''estimateRejections'', ''Estimate Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''estimateRejections'', ''grdEstimatesCols'', 1, ''Columns'', ''reference,project,methodName,estimateTotal,rejectionComments'', NULL, ''grid'', 
''[	{id:"reference", label:"ID"},
	{id:"project", label:"Project"},
	{id:"methodName", label:"Type"},
	{id:"estimateTotal", label:"Total"},
	{id:"rejectionComments", label:"Reject Comments"},
	{id:"clientName", label:"Client Name"}
 ]''
 , NULL, NULL, NULL, NULL)

 -- Insertion Order Rejection
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''insertionOrderRejections'', ''Insertion Order Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''insertionOrderRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''insertionOrderRejections'', ''grdIOOrdersCols'', 1, ''Columns'', ''reference,poDate,vendorName,netCost,rejectionComments'', NULL, ''grid'', 
''[	{id:"reference", label:"IO Number"},
	{id:"poDate", label:"IO Date"},
	{id:"vendorName", label:"Vendor"},
	{id:"netCost", label:"Net Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"projectName", label:"Project Name"},
	{id:"clientName", label:"Client Name"},
	{id:"createdBy", label:"Created By"},
	{id:"rejectionComments", label:"Reject Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

 
 -- Invoice Rejection
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''invoiceRejections'', ''Invoice Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''invoiceRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''invoiceRejections'', ''grdInvoicesCols'', 1, ''Columns'', ''reference,invoiceDate,client,invoiceTotal,projectNumber,rejectionComments'', NULL, ''grid'', 
''[	{id:"reference", label:"Invoice Number"},
	{id:"invoiceDate", label:"Invoice Date"},
	{id:"client", label:"Client"},
	{id:"invoiceTotal", label:"Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"createdBy", label:"Created By"},
	{id:"rejectionComments", label:"Reject Comments"}
 ]''

 , NULL, NULL, NULL, NULL)
-- Purchase Order Rejection
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''purchaseOrderRejections'', ''Purchase Order Rejections'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchaseOrderRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''purchaseOrderRejections'', ''grdPOOrdersCols'', 1, ''Columns'', ''reference,poDate,vendorName,netCost,rejectionComments'', NULL, ''grid'', 
''[	{id:"reference", label:"PO Number"},
	{id:"poDate", label:"PO Date"},
	{id:"vendorName", label:"Vendor"},
	{id:"netCost", label:"Net Amount"},
	{id:"projectNumber", label:"Project Number"},
	{id:"projectName", label:"Project Name"},
	{id:"clientName", label:"Client Name"},
	{id:"createdBy", label:"Created By"},
	{id:"rejectionComments", label:"Reject Comments"}
 ]''
 , NULL, NULL, NULL, NULL)

 --Project Request Rejections
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectRequestRejections'', ''Project Request Rejection'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectRequestRejections'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectRequestRejections'', ''grdProjectRequestCols'', 1, ''Columns'', ''reference,companyName,subject,projectDueDate'', NULL, ''grid'', 
''[	{id:"reference", label:"ID"},
	{id:"companyName", label:"Client"},
	{id:"subject", label:"Project Name"},
	{id:"projectDueDate", label:"Project Due Date"},
	{id:"projectDescription", label:"Project Description"},
	{id:"campaignID", label:"Campaign ID"},
	{id:"campaignName", label:"Campaign Name"}
 ]''
 , NULL, NULL, ''RequestDef'', NULL)
 /*************************************************************************************************************************
Unsubmitted
**************************************************************************************************************************/
-- Timesheets Unsubmitted
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''timesheetUnsubmitted'', ''Time Sheet Unsubmitted'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''timesheetUnsubmitted'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
--Values (''timesheetUnsubmitted'', ''grdTimesheetCols'', 1, ''Columns'', ''reference,startDate,endDate,totalHours'', NULL, ''grid'', 
Values (''timesheetUnsubmitted'', ''grdTimesheetCols'', 1, ''Columns'', ''startDate,endDate,totalHours,totalPauseHours'', NULL, ''grid'', 
''[
	{id:"startDate", label:"Start Date"},
	{id:"endDate", label:"End Date"},
	{id:"totalHours", label:"Hours"},
	{id:"totalPauseHours", label:"Hours Paused"}
 ]''
 , NULL, NULL, NULL, NULL)
/*************************************************************************************************************************
  Company Settings
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''companySettings'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companySettings'', ''H1'', 0, ''Exclude From History'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companySettings'', ''hideActivities'', 1, ''Activities'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companySettings'', ''hideOpenActivities'', 2, ''Open Activities'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companySettings'', ''hideClosedActivities'', 3, ''Completed Activities'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companySettings'', ''hideMeetings'', 4, ''Meetings'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companySettings'', ''hideProjectItems'', 5, ''Project Items'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companySettings'', ''hideTaskItems'', 6, ''Task Items'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
  Contact Settings
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''contactSettings'', ''System Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''contactSettings'', ''H1'', 0, ''Exclude From History'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''contactSettings'', ''hideActivities'', 1, ''Activities'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''contactSettings'', ''hideOpenActivities'', 2, ''Open Activities'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''contactSettings'', ''hideClosedActivities'', 3, ''Completed Activities'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''contactSettings'', ''hideMeetings'', 4, ''Meetings'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''contactSettings'', ''hideProjectItems'', 5, ''Project Items'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''contactSettings'', ''hideTaskItems'', 6, ''Task Items'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''contactSettings'', ''hidePastCompanies'', 7, ''Past Companies'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL,''showPreviousCompany'')


/*************************************************************************************************************************
Estimate Edit Labor Drilldown
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''estimateEdit'', ''Estimate Edit Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''H1'', 0, ''Estimate Summary'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowProfit'', 1, ''Show the Profit Breakout'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowLaborSum'', 2, ''Show the Labor Summary'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowContingency'', 3, ''Show Contingency'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''H2'', 4, ''Labor Entry Grid'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowCostRate'', 5, ''Show labor cost rate'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Only if the user has appropriate rights'') 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowServiceCode'', 6, ''Show labor service code'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowServicesZeroAmounts'', 7, ''Show services with zero amounts'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowServicesZeroRates'', 8, ''Show services with zero rates'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowExpenses'', 9, ''Show Expenses in Labor Breakout'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateEdit'', ''EstShowLine'', 10, ''Show Line number'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 


/*************************************************************************************************************************
Print Check  exec spConvertAppSeed
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''printCheck'', ''Print Check Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''printCheck'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''printCheck'', ''showACH'', 1, ''Use ACH'', ''0'', NULL, ''checkbox'', NULL, NULL, ''ACH - Automated Clearing House file for electronic fund transfers in the US'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''printCheck'', ''showBacs'', 2, ''Use BACS'', ''0'', NULL, ''checkbox'', NULL, NULL, ''BACS or Banker Automated Clearing Services, used in the United Kingdom'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''printCheck'', ''showPAIN'', 3, ''Use PAIN.001'', ''0'', NULL, ''checkbox'', NULL, NULL, ''PAIN.001 v3 - XML Payment Initiation file that describes credit transfers in the Eurozone'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''printCheck'', ''showABA'', 4, ''Use ABA'', ''0'', NULL, ''checkbox'', NULL, NULL, ''ABA - Australian Banking Authority file for electronic fund transfers in the Australia'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''printCheck'', ''showVisa'', 5, ''Use CSI vCard'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''printCheck'', ''csiTestSite'', 6, ''Use CSI Test Site'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''showVisa'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''printCheck'', ''showFastPay'', 7, ''Use FastPay'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Fast Pay'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''printCheck'', ''showCoupa'', 8, ''Use Coupa'', ''0'', NULL, ''checkbox'', NULL, NULL, ''Coupa'')


/*************************************************************************************************************************
Mass Billing
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''massBilling'', ''Mass Billing Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''massBilling'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''massBilling'', ''BillMediaSeparately'', 1, ''Bill Media Separately'', ''1'', NULL, ''checkbox'', NULL, NULL, ''If this is checked, the user is assumed to use media mass billing separately and the media orders will not be pulled by default in the T&M mass billing'') 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''massBilling'', ''ExcludeCampaignProjects'', 2, ''Exclude Campaign Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, ''If this is checked, we exclude projects linked to a campaign where the campaign is set to Bill by Campaign.'') 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''massBilling'', ''IncludeOHClients'', 3, ''Include Overhead Clients'', ''1'', NULL, ''checkbox'', NULL, NULL, ''If this is checked, we include Overhead Clients.'') 


/*************************************************************************************************************************
Client Billing
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''clientInvoiceLine'', ''Client Invoice Line Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientInvoiceLine'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''clientInvoiceLine'', ''grdInvoiceLineCols'', 1, ''Columns'', ''il_ProjectKey,il_TaskKey,il_SalesGLAccountKey,il_Quantity,il_UnitCost,il_TotalCost,il_Taxable,il_Taxable2'', NULL, ''grid'', 

''[	{id:"il_ProjectKey", label:"Project"},
	{id:"il_TaskKey", label:"Task"},
	{id:"il_SalesGLAccountKey", label:"Sales GL Account"},
	{id:"il_Quantity", label:"Quantity"},
	{id:"il_UnitCost", label:"Unit Amt"},
	{id:"il_TotalCost", label:"Total Amt"},
	{id:"il_Taxable", label:"Taxable"},
	{id:"il_Taxable2", label:"Taxable2"},
	{id:"il_SalesTax1Amount", label:"Tax 1 Amt"},
	{id:"il_SalesTax2Amount", label:"Tax 2 Amt"},
	{id:"il_SalesTaxAmount", label:"Other Tax Amt"},
	{id:"il_ClassKey", label:"Class"},
	{id:"il_OfficeKey", label:"Office"},
	{id:"il_ShortDescription", label:"Description"},
	{id:"il_ItemService", label:"Item/Service"},
	{id:"il_ItemKey", label:"Item"},
	{id:"il_ServiceKey", label:"Service"},
	{id:"il_WorkTypeKey", label:"Billing Item"},
	{id:"il_DisplayOption", label:"Display Option"},
	{id:"il_RetainerKey", label:"Retainer"},
	{id:"il_DepartmentKey", label:"Department"}
 ]''
	 , NULL, NULL, null, NULL)


INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''clientInvoiceExpense'', ''Expense Line Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientInvoiceExpense'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''clientInvoiceExpense'', ''grdExpenseCols'', 1, ''Columns'', ''invExpenseSource,invExpenseProjectFullName,invExpenseItem,invExpenseAmount,invExpenseBillComments,invExpenseDescription,invExpenseSalesAccount'', NULL, ''grid'', 

''[	{id:"invExpenseSource", label:"Source"},
	{id:"invExpenseProjectFullName", label:"Project"},
	{id:"invExpenseItem", label:"Billed Item"},
	{id:"invExpenseAmount", label:"Billed Amount"},
	{id:"invExpenseBilledVariance", label:"Billed Variance"},
	{id:"invExpenseBillComments", label:"Billed Comments"},
	{id:"invExpenseDescription", label:"Description"},
	{id:"invExpenseDate", label:"Date"},
	{id:"invExpenseReason", label:"Reason"},
	{id:"invExpenseQuantity", label:"Qty"},
	{id:"invExpenseUnitCost", label:"Unit Cost"},
	{id:"invExpenseTotalCost", label:"Net"},
	{id:"invExpenseBillableCost", label:"Gross"},
	{id:"invExpenseVariance", label:"Variance"},
	{id:"invExpenseComments", label:"Comments"},
	{id:"invVendorName", label:"Vendor Name"},
	{id:"invPurchasedFrom", label:"Purchased From"},
	{id:"invExpenseSalesAccount", label:"Sales Account"}
 ]''
	 , NULL, NULL, null, NULL)


INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''clientInvoiceLabor'', ''Labor Line Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientInvoiceLabor'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''clientInvoiceLabor'', ''grdLaborCols'', 1, ''Columns'', ''laborPerson,laborProjectFullName,laborBilledService,laborBilledHours,laborBilledRate,laborBilledAmount,laborActualHours,laborActualRate,laborActualAmount,laborBilledComments,laborDate,laborTimesheetComments,laborSalesAccount'', NULL, ''grid'', 

''[	{id:"laborPerson", label:"Person"},
	{id:"laborProjectFullName", label:"Project"},
	{id:"laborBilledService", label:"Billed Service"},
	{id:"laborBilledHours", label:"Billed Hours"},
	{id:"laborBilledRate", label:"Billed Rate"},
	{id:"laborBilledAmount", label:"Billed Amount"},
	{id:"laborActualHours", label:"Actual Hours"},
	{id:"laborActualRate", label:"Actual Rate"},
	{id:"laborActualAmount", label:"Actual Amount"},
	{id:"laborBilledComments", label:"Billed Comments"},
	{id:"laborDate", label:"Date"},
	{id:"laborTimesheetComments", label:"Timesheet Comments"},
    {id:"laborSalesAccount", label:"Sales Account"}
 ]''
	 , NULL, NULL, null, NULL)

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) VALUES(''billingTransactions'', ''Billing Transaction Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
VALUES (''billingTransactions'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
VALUES (''billingTransactions'', ''grdTransactionDetailCols'', 1, ''Columns'', ''colTransactionDate,colDescription,colHours,colUnitCost,colNet,colGross,colItem,colPostedToWIP,colPostingDate,colTaskName,colEditedBy,colBillAction,colComments,colEditComments,colBillingComments'', NULL, ''grid'', 

''[
	{id:"colTransactionDate", label:"Date"},
	{id:"colDescription", label:"Vendor/Person"},
	{id:"colTransactionComments", label:"Transaction Comments"},
	{id:"colHours", label:"Qty"},
	{id:"colUnitCost", label:"Unit Cost"},
	{id:"colNet", label:"Net"},
	{id:"colGross", label:"Gross"},
	{id:"colItem", label:"Item"},
	{id:"colPostedToWIP", label:"Posted to WIP"},
	{id:"colPostingDate", label:"Posting Date"},
	{id:"colTaskName", label:"Task"},
	{id:"colEditedBy", label:"Edited"},
	{id:"colBillAction", label:"Action"},
	{id:"colComments", label:"Comments"},
	{id:"colEditComments", label:"Edit Comments"},
	{id:"colBillingComments", label:"Billing Comments"},
	{id:"invSalesTaxAmount", label:"Sales Tax Amount"},
	{id:"invProfit", label:"Profit"},
	{id:"invVendorName", label:"Vendor Name"},
	{id:"colBillMediaPub", label:"Pub/Station"},
	{id:"colWriteOffReasons", label:"Write Off Reasons"}
]''
	, NULL, NULL
)

/*************************************************************************************************************************
Advance Billings
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''advanceBilling'', ''Advance Billings Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''advanceBilling'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''advanceBilling'', ''grdAddAdvanceBill'', 1, ''Columns'', ''referenceNumber_u,project_u,clientName_u,checkDate_u'', NULL, ''grid'', 
''[	{id:"referenceNumber_u", label:"Invoice"},
    {id:"project_u", label:"Project"},
	{id:"clientName_u", label:"Client Name"},
	{id:"checkDate_u", label:"Invoice Date"},  
	{id:"checkAmount_u", label:"Amount"},
	{id:"unappliedAmount_u", label:"Open"},
	{id:"amount_u", label:"Applied"},
	{id:"openSalesTax_u", label:"Open Sales Tax"},
	{id:"posted_u", label:"Posted"},
	{id:"Campaign_u", label:"Campaign"}
 ]''
 , NULL, NULL, NULL, NULL)

 --#699885-AP - Apply advance bill screen
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''advanceBillDetail'', ''Advance Billings Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''advanceBillDetail'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''advanceBillDetail'', ''grdAdvanceBill'', 1, ''Columns'', ''referenceNumber,checkDate,checkAmount,unappliedAmount,amount,openSalesTax,appliedSalesTax,fromAB,effective,posted,project,campaign'', NULL, ''grid'', 
 ''[ {id:"referenceNumber", label:"Invoice #"},
	{id:"checkDate", label:"Invoice Date"},
	{id:"checkAmount", label:"Billed"},  
	{id:"unappliedAmount", label:"Remaining"},
	{id:"amount", label:"Applied"},
	{id:"openSalesTax", label:"Open Sales Tax"},
	{id:"appliedSalesTax", label:"Applied Sales Tax"},
	{id:"fromAB", label:"Applied From"},
	{id:"effective", label:"Effective"},
	{id:"posted", label:"Posted"},
	{id:"project", label:"Project"},
	{id:"campaign", label:"Campaign"}
  ]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Client Portal
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''clientPortal'', ''System Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''H1'', 1, ''Dashboard Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, Required)
Values (''clientPortal'', ''DateOptionClient'', 3, ''Date Range'', ''6'', ''All'', ''lookup'', ''Due on or before Today:0|Due on or before a week from Today:1|Due on or before 2 weeks from Today:2|Start on or before Today:3|Start on or before a week from Today:4|Start on or before 2 weeks from Today:5|All:6'', NULL, NULL, 1) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''sortByDueDate'', 4, ''Sort Assigned Tasks by Due Date (Default is by Project Number)'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''H2'', 8, ''Project Details'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''client_schedule'', 9, ''View the project schedule'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showSpecs'', 10, ''Show Spec Sheets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showDeliverables'', 11, ''Show Deliverables'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showFiles'', 12, ''Show Files'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showEstimates'', 13, ''Show Estimates'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showNextSteps'', 14, ''Show Next Steps'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showConv'', 15, ''Show Conversations'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''client_editNotes'', 16, ''Start new conversations'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''client_completeTasks'', 17, ''Allow clients to complete assigned tasks'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showTeam'', 18, ''Show Project Team'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
if @LoadBeta = 1
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showToDo'', 19, ''Show Project To Dos'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField) 
Values (''clientPortal'', ''AddToDo'', 20, ''Add Project To Dos'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL, ''showToDo'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showProjectStatus'', 21, ''Show Project Status'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showProjectView'', 22, ''Show Project Views'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showDueComments'', 23, ''Show Due Comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showProjectList'', 24, ''Show Assigned Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showAssignments'', 25, ''Show Assigned Tasks'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, Required)
Values (''clientPortal'', ''taskDatesToShow'', 26, ''Task Dates to Show'', ''1'', ''Due Dates'', ''lookup'', ''Start Dates:0|Due Dates:1|Both:2'', NULL, NULL, 1) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''sortByTaskDueDate'', 27, ''Sort Tasks by Due Date'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCompletePct'', 28, ''Show Schedule Complete Percent'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''H3'', 29, ''Budget'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showBudgetTotal'', 30, ''Show the Total Budget'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showActual'', 31, ''Show the Total Actual and Remaining'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showActualHours'', 32, ''Show Actual Hours to Date'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showBilled'', 33, ''Show Billed to Date'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''H4'', 34, ''Campaign Details'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCampaignProjAndSeg'', 35, ''Show Projects and Segments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCampaignSpecs'', 36, ''Show Spec Sheets'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCampaignDeliverables'', 37, ''Show Deliverables'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCampaignFiles'', 38, ''Show Files'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCampaignConv'', 39, ''Show Conversations'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL) 
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''client_editCampaignNotes'', 40, ''Start new conversations'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCampaignView'', 41, ''Show Campaign Views'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''H5'', 42, ''Project Request Details'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showRequestView'', 43, ''Show Project Request Views'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''H6'', 44, ''Invoice Details'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showCurrentInvoices'', 45, ''Show Current Invoices'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showClosedInvoices'', 46, ''Show Closed Invoices'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showInvoicesForAssignedProjects'', 47, ''Show Invoices for Assigned Projects'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showInvoicesForCompany'', 48, ''Show Invoices for Company'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showInvoicesForParentCompany'', 49, ''Show Invoices for Parent Company'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''clientPortal'', ''showInvoicesForChildCompany'', 50, ''Show Invoices for Child Company'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
/*************************************************************************************************************************
Client Portal Request List
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''clientRequestList'', ''Project Request List'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''clientRequestList'', ''grdListCols'', 1, ''Columns'', ''cr_RequestID,cr_Subject,cr_DueDate,cr_ReasonName'', NULL, ''grid'', 
''[	{id:"cr_RequestID", label:"Request ID"},
	{id:"cr_DateAdded", label:"Date Added"},
	{id:"cr_RequestedBy", label:"Requested By"},
	{id:"cr_NotifyEmail", label:"Email to Notify"},
	{id:"cr_Subject", label:"Subject"},
	{id:"cr_ClientProjectNumber", label:"Client Project Number"},
	{id:"cr_ProjectNumber", label:"Project Number"},
	{id:"cr_ProjectDescription", label:"Project Description"},
	{id:"cr_DueDate", label:"Due Date"},
	{id:"cr_DateCancelled", label:"Date Cancelled"},
	{id:"cr_UpdatedBy", label:"Last Updated By"},
	{id:"cr_ReasonName", label:"Rejection Reason"},
	{id:"cr_RejectionDescription", label:"Rejection Description"}
 ]''
 , NULL, NULL, ''RequestDef'', NULL)



/*************************************************************************************************************************
Generate Billing Worksheets
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''generateBillingWorksheets'', ''Generate Billing Worksheets'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''DaysToReview'', 1, ''Days to review a worksheet'', 1, NULL, ''number:n0'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''DateOption'', 2, ''Select by Invoice date or posting date'', 1, NULL, ''lookup'', ''Invoice Date:1|Posting Date:2'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''ExpenseReports'', 3, ''Expense Reports'', 0, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''PurchaseOrders'', 4, ''Purchase Orders'', 0, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''IncludeZeroAmounts'', 5, ''Include T&M Zero Amounts'', 1, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''MarkTMZeroBilled'', 6, ''Mark T&M Zero Amounts as Billed'', 0, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''IncludeZeroAmountsFF'', 7, ''Include Fixed Fee Zero Unbilled'', 1, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''OpenOrdersOnly'', 8, ''Open Orders Only'', 1, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''IncludeOverheadClients'', 9, ''Include Overhead Clients'', 1, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''InsertionOrders'', 10, ''Insertion Orders'', 0, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''BroadcastOrders'', 11, ''Broadcast Orders'', 0, NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''generateBillingWorksheets'', ''ApproverIsAM'', 12, ''Approver is'', 1, ''Account Manager'', ''lookup'', ''Account Manager:1|Project Manager:0|Billing Manager:2'', NULL, NULL)

/*************************************************************************************************************************
Receipts Add
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''receiptAddSession'', ''Receipt Add Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''receiptAddSession'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''receiptAddSession'', ''PostOnSave'', 1, ''Post All New Receipts'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''receiptAddSession'', ''IncrementDepositID'', 2, ''Auto Increment Deposit ID'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)




/*************************************************************************************************************************
Payment Add
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''paymentAddSession'', ''Payment Add Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''paymentAddSession'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''paymentAddSession'', ''PostOnSave'', 1, ''Post All New Payments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''paymentAddSession'', ''H_GRID'', 3, ''Grid Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentAddSession'', ''grdPaymentInvoicesCol'', 4, '' Invoice Columns'', ''addInvoiceInvoiceNumber,addInvoiceInvoiceDate,addInvoiceAmountOpen,addInvoiceDiscount,addInvoiceApplied,addInvoiceExclude'', NULL, ''grid'', 

''[
{id:"addInvoiceInvoiceNumber", label:"Invoice #"},
{id:"addInvoiceInvoiceDate", label:"Invoice Date"},
{id:"addInvoiceAmountOpen", label:"Open"},
{id:"addInvoiceDiscount", label:"Discount"},
{id:"addInvoiceApplied", label:"Applied"},
{id:"addInvoiceExclude", label:"Exclude From 1099"},
{id:"addInvoiceDescription", label:"Description"},
{id:"addInvoiceVoucherTotal", label:"Invoice Total"},
{id:"addInvoiceVoucherPaid", label:"Voucher Amount Paid"},
{id:"addInvoiceOpenDiscount", label:"Open Discount"}
]''
	 , NULL, NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentAddSession'', ''grdCCChargesCol'', 5, ''CC Charge Columns'', ''addCCCVoucherID,addCCCInvoiceDate,addCCCBoughtByName,addCCCBoughtFrom,addCCCAmountOpen,addCCCDiscount,addCCCApplied,cccVoucherTotal,addCCCInvoiceNumber'', NULL, ''grid'', 

''[
{id:"addCCCVoucherID", label:"Ref #"},
{id:"addCCCInvoiceDate", label:"Charge Date"},
{id:"addCCCBoughtByName", label:"Purchased By"},
{id:"addCCCBoughtFrom", label:"Purchased From"},
{id:"addCCCAmountOpen", label:"Open"},
{id:"addCCCDiscount", label:"Discount"},
{id:"addCCCApplied", label:"Amount"},
{id:"addCCCInvoiceNumber", label:"Charge Reference"},
{id:"addCCCDescription", label:"Description"},
{id:"addCCCVoucherTotal", label:"Charge Total"},
{id:"addCCCVoucherPaid", label:"Charge Amount Paid"}
]''
	 , NULL, NULL, null, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentAddSession'', ''grdExpensesCol'', 6, ''Expense Columns'', ''expenseGLAccount,expenseAmount,expenseSaleTax,expenseExclude'', NULL, ''grid'', 

''[
{id:"expenseGLAccount", label:"GL Account"},
{id:"expenseClass", label:"Class"},
{id:"expenseOffice", label:"Office"},
{id:"expenseDepartment", label:"Department"},
{id:"expenseGLCompany", label:"GL Company"},
{id:"expenseQuantity", label:"Quantity"},
{id:"expenseUnit", label:"Unit Amount"},
{id:"expenseSaleTax", label:"Sales Taxes"},
{id:"expenseAmount", label:"Amount"},
{id:"expenseExclude", label:"Exclude From 1099"},
{id:"expenseDescription", label:"Description"}
]''
	 , NULL, NULL, null, NULL)


/*************************************************************************************************************************
Payment Edit
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''paymentEditDetail'', ''Payment Edit Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''paymentEditDetail'', ''H_GRID'', 0, ''Grid Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

if @GLCompaniesWithForeignCurrencies = 0

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentEditDetail'', ''grdInvoicesCol'', 1, '' Invoice Columns'', ''invInvoiceNumber,invInvoiceDate,invOpen,invDiscount,invApplied,invExclude'', NULL, ''grid'', 

''[
{id:"invInvoiceNumber", label:"Invoice Number"},
{id:"invInvoiceDate", label:"Invoice Date"},
{id:"invOpen", label:"Open"},
{id:"invDiscount", label:"Discount"},
{id:"invApplied", label:"Applied"},
{id:"invExclude", label:"Exclude From 1099"},
{id:"invDescription", label:"Description"},
{id:"invVoucherTotal", label:"Invoice Total"},
{id:"invVoucherPaid", label:"Voucher Amount Paid"},
{id:"invOpenDiscount", label:"Open Discount"}
]''
	 , NULL, NULL, null, NULL)

else


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentEditDetail'', ''grdInvoicesCol'', 1, '' Invoice Columns'', ''invInvoiceNumber,invInvoiceDate,invOpen,invDiscount,invApplied,invExclude'', NULL, ''grid'', 

''[
{id:"invInvoiceNumber", label:"Invoice Number"},
{id:"invInvoiceDate", label:"Invoice Date"},
{id:"invOpen", label:"Open"},
{id:"invDiscount", label:"Discount"},
{id:"invApplied", label:"Applied"},
{id:"invExclude", label:"Exclude From 1099"},
{id:"invDescription", label:"Description"},
{id:"invVoucherTotal", label:"Invoice Total"},
{id:"invVoucherPaid", label:"Voucher Amount Paid"},
{id:"invOpenDiscount", label:"Open Discount"},
{id:"invGLCCurrencyID", label:"Company Currency"},
{id:"invGLCExchangeRate", label:"Company Exch Rate"} 
]''
	 , NULL, NULL, null, NULL)

if @GLCompaniesWithForeignCurrencies = 0

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentEditDetail'', ''grdCCCsColCol'', 2, ''CC Charge Columns'', ''cccVoucherID,cccInvoiceDate,cccPurchaseBy,cccPurchaseFrom,cccAmountOpen,cccDiscount,cccAmount,cccVoucherTotal,cccInvoiceNumber'', NULL, ''grid'', 

''[
{id:"cccVoucherID", label:"Ref #"},
{id:"cccInvoiceDate", label:"Charge Date"},
{id:"cccPurchaseBy", label:"Purchased By"},
{id:"cccPurchaseFrom", label:"Purchased From"},
{id:"cccAmountOpen", label:"Open"},
{id:"cccDiscount", label:"Discount"},
{id:"cccAmount", label:"Amount"},
{id:"cccVoucherTotal", label:"Charge Total"},
{id:"cccInvoiceNumber", label:"Charge Reference"},
{id:"cccDescription", label:"Description"},
{id:"cccVoucherPaid", label:"Charge Amount Paid"}
]''
	 , NULL, NULL, null, NULL)

else

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentEditDetail'', ''grdCCCsColCol'', 2, ''CC Charge Columns'', ''cccVoucherID,cccInvoiceDate,cccPurchaseBy,cccPurchaseFrom,cccAmountOpen,cccDiscount,cccAmount,cccVoucherTotal,cccInvoiceNumber'', NULL, ''grid'', 

''[
{id:"cccVoucherID", label:"Ref #"},
{id:"cccInvoiceDate", label:"Charge Date"},
{id:"cccPurchaseBy", label:"Purchased By"},
{id:"cccPurchaseFrom", label:"Purchased From"},
{id:"cccAmountOpen", label:"Open"},
{id:"cccDiscount", label:"Discount"},
{id:"cccAmount", label:"Amount"},
{id:"cccVoucherTotal", label:"Charge Total"},
{id:"cccInvoiceNumber", label:"Charge Reference"},
{id:"cccDescription", label:"Description"},
{id:"cccVoucherPaid", label:"Charge Amount Paid"},
{id:"cccGLCCurrencyID", label:"Company Currency"},
{id:"cccGLCExchangeRate", label:"Company Exch Rate"} 
]''
	 , NULL, NULL, null, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentEditDetail'', ''grdPrePaymentsCol'', 3, ''Prepay Columns'', ''preInvoiceNumber,preInvoiceDate,prePostingDate,preAmount,preExclude,preDiscount,preDescription'', NULL, ''grid'', 

''[
{id:"preInvoiceNumber", label:"Invoice #"},
{id:"preInvoiceDate", label:"Charge Date"},
{id:"prePostingDate", label:"Posting Date"},
{id:"preAmount", label:"Amount"},
{id:"preExclude", label:"Excluded from 1099"},
{id:"preDiscount", label:"Discount"},
{id:"preDescription", label:"Description"}
]''
	 , NULL, NULL, null, NULL)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''paymentEditDetail'', ''grdExpensesCol'', 4, ''Expense Columns'', ''expenseGLAccount,expenseAmount,expenseSaleTax,expenseExclude'', NULL, ''grid'', 

''[
{id:"expenseGLAccount", label:"GL Account"},
{id:"expenseClass", label:"Class"},
{id:"expenseOffice", label:"Office"},
{id:"expenseDepartment", label:"Department"},
{id:"expenseGLCompany", label:"GL Company"},
{id:"expenseQuantity", label:"Quantity"},
{id:"expenseUnit", label:"Unit Amount"},
{id:"expenseSaleTax", label:"Sales Taxes"},
{id:"expenseAmount", label:"Amount"},
{id:"expenseExclude", label:"Exclude From 1099"},
{id:"expenseDescription", label:"Description"}
]''
	 , NULL, NULL, null, NULL)

/*************************************************************************************************************************
Accrued Order Detail
**************************************************************************************************************************/


INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''accruedOrderDetail'', ''Accrued Order Detail'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''accruedOrderDetail'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''accruedOrderDetail'', ''grdOrders'', 1, ''Columns'', ''orderPurchaseOrderNumber,orderVendorName,orderClientName,orderPODate,orderPOClosed,orderTotalCost,orderAccruedCost,orderPrebillAmount,orderBalance,mediaPlanFullName'', NULL, ''grid'', 
''[	{id:"orderPurchaseOrderNumber", label:"Order #"},
	{id:"orderVendorName", label:"Vendor"},
	{id:"orderClientName", label:"Client"},
	{id:"orderPODate", label:"Order Date"},
	{id:"orderPOClosed", label:"Closed"},
	{id:"orderDetailDateRange", label:"Detail Date Range"},
	{id:"orderAccruedCost", label:"Amt Accrued"},
	{id:"orderPrebillAmount", label:"Amt Unaccrued"},
	{id:"orderBalance", label:"Balance"},
	{id:"orderTotalCost", label:"Net Cost"},
	{id:"orderOpenAmount", label:"Open Amount"},
	{id:"orderARPaidInFull", label:"AR Paid in Full"},
	{id:"orderProjectName", label:"Project Name"},
	{id:"orderEstimateName", label:"Media Estimate Name"},
	{id:"orderStationName", label:"Station / Pub"},
	{id:"orderCampaignName", label:"Campaign Name"},
	{id:"mediaPlanFullName", label:"Media Plan Full Name"}
 ]''
, NULL, NULL, NULL, NULL)


/*************************************************************************************************************************
Financial GL drill down
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''financialGLDrillDown'', ''Financial GL Drill Down'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''financialGLDrillDown'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)

if @GLCompaniesWithForeignCurrencies = 0

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''financialGLDrillDown'', ''grdFinancialGLDDResultsCols'', 1, ''Columns'', ''postingStatus,entity,accountNumberName,reference,memo,currencyID,balance,cAmount,cDebit,cCredit'', NULL, ''grid'', 
''[  {id:"postingStatus", label:"Posting Status"},
	{id:"entity", label:"Type"},
    {id:"accountNumberName", label:"Account Number"},
	{id:"transactionDate", label:"Date"},
    {id:"reference", label:"Reference"},
	{id:"memo", label:"Memo"},
	{id:"currencyID", label:"CurrencyID"},
	{id:"balance", label:"Balance"},
	{id:"cAmount", label:"Amount"},
    {id:"cDebit", label:"Debit"},
	{id:"cCredit", label:"Credit"},
    {id:"amount", label:"Amount (HC)"},
    {id:"debit", label:"Debit (HC)"},
    {id:"credit", label:"Credit (HC)"},
	{id:"companyName", label:"Name"},
    {id:"clientID", label:"Client ID"},
	{id:"clientName", label:"Client Name"},
    {id:"vendorID", label:"Vendor ID"},
	{id:"vendorName", label:"Vendor Name"},
    {id:"classID", label:"Class ID"},
    {id:"className", label:"Class Name"},
    {id:"gLCompanyID", label:"Company ID"},
    {id:"gLCompanyName", label:"Company Name"},
    {id:"officeID", label:"Office ID"},
    {id:"officeName", label:"Office Name"},
    {id:"projectNumber", label:"Project Number"},
    {id:"projectName", label:"Project Name"},
    {id:"departmentName", label:"Department Name"},
    {id:"voucherID", label:"Unique Auto Number"},
	{id:"exchangeRate", label:"Exchange Rate"},
	{id:"debitRevalue", label:"Debit Revalued"},
	{id:"creditRevalue", label:"Credit Revalued"}, 
	{id:"amountRevalue", label:"Amount Revalued"},
	{id:"campaignID", label:"Campaign ID"}
 ]''
 , NULL, NULL, ''PO_Detail'', ''PO_Detail'')

 else -- use for GL companies with foreign currencies

 INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''financialGLDrillDown'', ''grdFinancialGLDDResultsCols'', 1, ''Columns'', ''postingStatus,entity,accountNumberName,reference,memo,currencyID,balance,cAmount,cDebit,cCredit'', NULL, ''grid'', 
''[  {id:"postingStatus", label:"Posting Status"},
	{id:"entity", label:"Type"},
    {id:"accountNumberName", label:"Account Number"},
	{id:"transactionDate", label:"Date"},
    {id:"reference", label:"Reference"},
	{id:"memo", label:"Memo"},
	{id:"currencyID", label:"CurrencyID"},
	{id:"balance", label:"Balance"},
	{id:"cAmount", label:"Amount"},
    {id:"cDebit", label:"Debit"},
	{id:"cCredit", label:"Credit"},
    {id:"amount", label:"Amount (HC)"},
    {id:"debit", label:"Debit (HC)"},
    {id:"credit", label:"Credit (HC)"},
	{id:"companyName", label:"Name"},
    {id:"clientID", label:"Client ID"},
	{id:"clientName", label:"Client Name"},
    {id:"vendorID", label:"Vendor ID"},
	{id:"vendorName", label:"Vendor Name"},
    {id:"classID", label:"Class ID"},
    {id:"className", label:"Class Name"},
    {id:"gLCompanyID", label:"Company ID"},
    {id:"gLCompanyName", label:"Company Name"},
    {id:"officeID", label:"Office ID"},
    {id:"officeName", label:"Office Name"},
    {id:"projectNumber", label:"Project Number"},
    {id:"projectName", label:"Project Name"},
    {id:"departmentName", label:"Department Name"},
    {id:"voucherID", label:"Unique Auto Number"},
	{id:"exchangeRate", label:"Exchange Rate"},
	{id:"debitRevalue", label:"Debit Revalued"},
	{id:"creditRevalue", label:"Credit Revalued"}, 
	{id:"amountRevalue", label:"Amount Revalued"},
	{id:"campaignID", label:"Campaign ID"},
	{id:"gLCCurrencyID", label:"Company Currency"},
	{id:"gLCExchangeRate", label:"Company Exchange Rate"},
	{id:"gLCAmount", label:"Amount (Company)"},
	{id:"gLCDebit", label:"Debit (Company)"},
	{id:"gLCCredit", label:"Credit (Company)"}
 ]''
 , NULL, NULL, ''PO_Detail'', ''PO_Detail'')



/*************************************************************************************************************************
CONNECTIONS - Contacts
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsContacts'', ''Connections - Contacts'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsContacts'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsContacts'', ''grdConnectionsContactsCols'', 1, ''Columns'', ''isPrimaryContact,contactFullName,phone1,email,personalWorkAddress1,personalWorkCity,personalWorkState,personalWorkPostalCode'', NULL, ''grid'', 
''[
	{id:"contactFullName", label:"Contact Full Name"},
	{id:"phone1", label:"Phone1"},
	{id:"phone2", label:"Phone2"},
	{id:"cell", label:"Cell"},
	{id:"email", label:"Email"},
	{id:"companyMainPhone", label:"Company Main Phone"},
	{id:"companyName", label:"Company Name"},
	{id:"userCompanyName", label:"User Company Name"},
	{id:"personalWorkAddress1", label:"Personal Work Address1"},
	{id:"personalWorkAddress2", label:"Personal Work Address2"},
	{id:"personalWorkAddress3", label:"Personal Work Address3"},
	{id:"personalWorkCity", label:"Personal Work City"},
	{id:"personalWorkState", label:"Personal Work State"},
	{id:"personalWorkPostalCode", label:"Personal Work Postal Code"},
	{id:"personalWorkCountry", label:"Personal Work Country"},
	{id:"homeAddress1", label:"Home Address1"},
	{id:"homeAddress2", label:"Home Address2"},
	{id:"homeAddress3", label:"Home Address3"},
	{id:"homeCity", label:"Home City"},
	{id:"homeState", label:"Home State"},
	{id:"homePostalCode", label:"Home Postal Code"},
	{id:"homeCountry", label:"Home Country"},
	{id:"companyAddress1", label:"Company Address1"},
	{id:"companyAddress2", label:"Company Address2"},
	{id:"companyAddress3", label:"Company Address3"},
	{id:"companyCity", label:"Company City"},
	{id:"companyState", label:"Company State"},
	{id:"companyPostalCode", label:"Company Postal Code"},
	{id:"companyCountry", label:"Company Country"},
	{id:"otherAddress1", label:"Other Address1"},
	{id:"otherAddress2", label:"Other Address2"},
	{id:"otherAddress3", label:"Other Address3"},
	{id:"otherCity", label:"Other City"},
	{id:"otherState", label:"Other State"},
	{id:"otherPostalCode", label:"Other Postal Code"},
	{id:"otherCountry", label:"Other Country"},
	{id:"isFavorite", label:"Is Favorite"},
	{id:"favoriteDisplayOrder", label:"Favorite Display Order"},
	{id:"isRecent", label:"Is Recent"},
	{id:"recentSort", label:"Recent Sort"},
	{id:"firstName", label:"First Name"},
	{id:"lastName", label:"Last Name"},
	{id:"title", label:"Title"},
	{id:"linkedInURL", label:"Linked In U R L"},
	{id:"twitterID", label:"Twitter I D"},
	{id:"contractor", label:"Contractor"},
	{id:"doNotCall", label:"Do Not Call"},
	{id:"doNotFax", label:"Do Not Fax"},
	{id:"doNotEmail", label:"Do Not Email"},
	{id:"doNotMail", label:"Do Not Mail"},
	{id:"lastModified", label:"Last Modified"},
	{id:"dateAdded", label:"Date Added"},
	{id:"dateUpdated", label:"Date Updated"},
	{id:"active", label:"Active"},
	{id:"isPrimaryContact", label:"Is Primary Contact"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Opportunities
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsOpps'', ''Connections - Opps'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsOpps'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsOpps'', ''grdConnectionsOppsCols'', 1, ''Columns'', ''subject,accountManagerName,stageName'', NULL, ''grid'', 
''[
	{id:"subject", label:"Subject"},
	{id:"accountManagerName", label:"Account Manager Name"},
	{id:"stageName", label:"Stage Name"},
	{id:"projectNumber", label:"Project Number"},
	{id:"leadStatusName", label:"Lead Status Name"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Projects
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsProjects'', ''Connections - Projects'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsProjects'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsProjects'', ''grdConnectionsProjectsCols'', 1, ''Columns'', ''projectNumber,projectName,projectStatus'', NULL, ''grid'', 
''[
	{id:"projectNumber", label:"Project Number"},
	{id:"projectName", label:"Project Name"},
	{id:"projectStatus", label:"Project Status"},
	{id:"projectBillingStatus", label:"Project Billing Status"},
	{id:"projectTypeName", label:"Project Type Name"},
	{id:"createdDate", label:"Created Date"},
	{id:"ExpensesNet", label:"Net Expenses"},
	{id:"GrossExpenses", label:"Gross Expenses"},
	{id:"TotalGross", label:"Total Gross"},
	{id:"EstimateGross", label:"Estimate Gross"},
	{id:"ActualHours", label:"Actual Hours"},
	{id:"LaborGross", label:"Gross Labor"},
	{id:"LaborNet", label:"Net Labor"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Project Requests
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsProjectRequests'', ''Connections - Project Requests'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsProjectRequests'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsProjectRequests'', ''grdConnectionsProjectRequestsCols'', 1, ''Columns'', ''requestID,requestName,statusText'', NULL, ''grid'', 
''[
	{id:"requestID", label:"Request ID"},
	{id:"dateAdded", label:"Date Added"},
	{id:"dateCompleted", label:"Date Completed"},
	{id:"requestedBy", label:"Requested By"},
	{id:"notifyEmail", label:"Notify Email"},
	{id:"subject", label:"Subject"},
	{id:"clientProjectNumber", label:"Client Project Number"},
	{id:"projectDescription", label:"Project Description"},
	{id:"dueDate", label:"Due Date"},
	{id:"campaignID", label:"Campaign ID"},
	{id:"cancelled", label:"Cancelled"},
	{id:"dateSentForApproval", label:"Date Sent For Approval"},
	{id:"dateCancelled", label:"Date Cancelled"},
	{id:"dateUpdated", label:"Date Updated"},
	{id:"customerID", label:"Customer ID"},
	{id:"companyName", label:"Company Name"},
	{id:"requestName", label:"Request Name"},
	{id:"statusText", label:"Status Text"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Estimates
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsEstimates'', ''Connections - Estimates'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsEstimates'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsEstimates'', ''grdConnectionsEstimateCols'', 1, ''Columns'', ''estimateName,estimateNumber,estimateType,totalWithTax,estimateTotal'', NULL, ''grid'', 
''[
	{id:"project_Full_Name", label:"Project Full Name"},
	{id:"estimateName", label:"Estimate Name"},
	{id:"estimateNumber", label:"Estimate Number"},
	{id:"estimate_Full_Name", label:"Estimate Full Name"},
	{id:"estimateType", label:"Estimate Type"},
	{id:"totalWithTax", label:"Total With Tax"},
	{id:"estimateTotal", label:"Estimate Total"},
	{id:"internalStatusName", label:"Internal Status Name"}
]''
 , NULL, NULL, NULL, NULL)


/*************************************************************************************************************************
CONNECTIONS - Campaigns
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsCampaigns'', ''Connections - Campaigns'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsCampaigns'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsCampaigns'', ''grdConnectionsCampaignCols'', 1, ''Columns'', ''campaignID,campaignName'', NULL, ''grid'', 
''[
	{id:"campaignID", label:"Campaign ID"},
	{id:"campaignName", label:"Campaign Name"},
	{id:"campaignProjectManager", label:"Project Manager"},
	{id:"campaignAccountManager", label:"Account Manager"},
	{id:"campaignStartDate", label:"Start Date"},
	{id:"campaignEndDate", label:"End Date"}
]''
 , NULL, NULL, ''Campaign'', ''Campaign'')

/*************************************************************************************************************************
CONNECTIONS - Invoices
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsInvoices'', ''Connections - Invoices'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsInvoices'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsInvoices'', ''grdConnectionsInvoiceCols'', 1, ''Columns'', ''invoiceNumber,invoiceDate,postingDate,projectFullName,amountTotal,amountOpen'', NULL, ''grid'', 
''[
	{id:"invoiceNumber", label:"Invoice Number"},
	{id:"invoiceDate", label:"Invoice Date"},
	{id:"postingDate", label:"Posting Date"},
	{id:"projectFullName", label:"Project Full Name"},
	{id:"amountTotal", label:"Amount Total"},
	{id:"amountOpen", label:"Amount Open"},
	{id:"advanceBill", label:"Advance Bill"},
	{id:"headerComment", label:"Comments"},
	{id:"primaryContact", label:"Contact"},
	{id:"approvalStatus", label:"Approval Status"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Receipts
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsReceipts'', ''Connections - Receipts'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsReceipts'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsReceipts'', ''grdConnectionsReceiptCols'', 1, ''Columns'', ''referenceNumber,checkAmount,postingDate,dateReceived'', NULL, ''grid'', 
''[
	{id:"referenceNumber", label:"Reference Number"},
	{id:"paymentMethod", label:"Payment Method"},
	{id:"checkAmount", label:"Check Amount"},
	{id:"postingDate", label:"Posting Date"},
	{id:"dateReceived", label:"Date Received"},
	{id:"paymentDescription", label:"Payment Description"},
	{id:"unappliedAmount", label:"Unapplied Amount"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Purchase Orders
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsPurchaseOrders'', ''Connections - Purchase Orders'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsPurchaseOrders'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsPurchaseOrders'', ''grdConnectionsPurchaseOrdersCols'', 1, ''Columns'', ''poNumber,poDate,invoicedAmount'', NULL, ''grid'', 
''[
	{id:"poNumber", label:"PO Number"},
	{id:"poDate", label:"PO DateInsertion"},
	{id:"netAmount", label:"Net"},
	{id:"grossAmount", label:"Gross"},
	{id:"openAmount", label:"Open"},
	{id:"invoicedAmount", label:"Invoiced"},
	{id:"appliedAmount", label:"Applied"},
	{id:"status", label:"Status"}
]''
 , NULL, NULL, NULL, NULL)

 
/*************************************************************************************************************************
CONNECTIONS - Insertion Orders
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsInsertionOrders'', ''Connections - Insertion Orders'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsInsertionOrders'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsInsertionOrders'', ''grdConnectionsInsertionOrdersCols'', 1, ''Columns'', ''poNumber,poDate,invoicedAmount'', NULL, ''grid'', 
''[
	{id:"poNumber", label:"IO Number"},
	{id:"poDate", label:"IO Date"},
	{id:"netAmount", label:"Net"},
	{id:"grossAmount", label:"Gross"},
	{id:"openAmount", label:"Open"},
	{id:"invoicedAmount", label:"Invoiced"},
	{id:"appliedAmount", label:"Applied"},
	{id:"status", label:"Status"}
]''
 , NULL, NULL, NULL, NULL)

 
/*************************************************************************************************************************
CONNECTIONS - Broadcast Orders
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsBroadcastOrders'', ''Connections - Broadcast Orders'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsBroadcastOrders'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsBroadcastOrders'', ''grdConnectionsBroadcastOrdersCols'', 1, ''Columns'', ''poNumber,poDate,invoicedAmount'', NULL, ''grid'', 
''[
	{id:"poNumber", label:"BO Number"},
	{id:"poDate", label:"BO Date"},
	{id:"netAmount", label:"Net"},
	{id:"grossAmount", label:"Gross"},
	{id:"openAmount", label:"Open"},
	{id:"invoicedAmount", label:"Invoiced"},
	{id:"appliedAmount", label:"Applied"},
	{id:"status", label:"Status"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Credit Card Charges
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsCCCharges'', ''Connections - Credit Card Charges'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsCCCharges'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsCCCharges'', ''grdConnectionsCCChargesCols'', 1, ''Columns'', ''boughtFrom,chargeDate,chargeAmount,amountOpen'', NULL, ''grid'', 
''[
	{id:"boughtFrom", label:"Purchased From"},
	{id:"chargeDate", label:"Charge Date"},
	{id:"chargeAmount", label:"Charge Amount"},
	{id:"amountOpen", label:"Open"},
	{id:"posted", label:"Posted"},
	{id:"referenceNumber", label:"Reference Number"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Credit Card Payments
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsCCPayments'', ''Connections - Credit Card Payments'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsCCPayments'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsCCPayments'', ''grdConnectionsCCPaymentCols'', 1, ''Columns'', ''payToName,checkNumber,cashAccount,amount_cc'', NULL, ''grid'', 
''[
    {id:"payToName",label:"Pay To Name"},
	{id:"checkNumber",label:"Check Number"},
	{id:"cashAccount",label:"Cash Account"},
	{id:"checkDate_cc",label:"Payment Date"},
	{id:"amount_cc",label:"Amount Paid"},
	{id:"posted", label:"Posted"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Payments
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsVendorPayments'', ''Connections - Payments'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsVendorPayments'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsVendorPayments'', ''grdConnectionsPaymentsCols'', 1, ''Columns'', ''check_Number,check_Date,check_Amount'', NULL, ''grid'', 
''[
	{id:"check_Number", label:"Check Number"},
	{id:"check_Date", label:"Check Date"},
	{id:"check_Amount", label:"Check Amount"},
	{id:"cash_Account_Number", label:"Cash Account Number"},
	{id:"cash_Account_Name", label:"Cash Account Name"},
	{id:"cash_Account_Full_Name", label:"Cash Account Full Name"},
	{id:"posted", label:"Posted"},
	{id:"check_Memo", label:"Check Memo"},
	{id:"cleared", label:"Cleared"}

]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Vendor Invoices
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsVendorInvoices'', ''Connections - Vendor Invoices'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsVendorInvoices'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsVendorInvoices'', ''grdConnectionsVendorInvoicesCols'', 1, ''Columns'', ''invoice_Number,invoice_Date,invoice_Amount'', NULL, ''grid'', 
''[
	{id:"invoice_Number", label:"Invoice Number"},
	{id:"invoice_Amount", label:"Invoice Amount"},
	{id:"invoice_Amount_Open", label:"Invoice Amount Open"},
	{id:"invoice_AmountHC", label:"Invoice Amount HC"},
	{id:"invoice_Amount_OpenHC", label:"Amount Open HC"},
	{id:"invoice_Date", label:"Invoice Date"},
	{id:"due_Date", label:"Due Date"},
	{id:"posting_Date", label:"Posting Date"},
	{id:"invoice_Status", label:"Invoice Status"},
	{id:"invoice_Curr", label:"Currency"},
	{id:"project_Full_Name", label:"Project Full Name"},
	{id:"GL_Company", label:"GL Company"},
	{id:"station_Pub_Name", label:"Station/Publication"}	
]''
 , NULL, NULL, NULL, NULL)


/*************************************************************************************************************************
CONNECTIONS - Expense Reports
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsExpenseReports'', ''Connections - Expense Reports'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsExpenseReports'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsExpenseReports'', ''grdConnectionsExpenseReportsCols'', 1, ''Columns'', ''envelopeNumber,invoiceNumber,dateSubmitted,expenseTotal,amountPaid,status'', NULL, ''grid'', 
''[
	{id:"envelopeNumber", label:"Envelope Number"},
	{id:"invoiceNumber", label:"Invoice Number"},
	{id:"dateSubmitted", label:"Date Submitted"},
	{id:"expenseTotal", label:"Expense Total"},
	{id:"amountPaid", label:"Amount Paid"},
	{id:"status", label:"Status"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
 CONNECTIONS - Timesheets
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsTimesheets'', ''Connections - Time Sheets'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsTimesheets'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsTimesheets'', ''grdConnectionsTimesheetsCols'', 1, ''Columns'', ''startDate,endDate,totalHours,status'', NULL, ''grid'', 
''[
	{id:"startDate", label:"Start Date"},
	{id:"endDate", label:"End Date"},
	{id:"totalHours", label:"Total Hours"},
	{id:"status", label:"Status"}
]''
 , NULL, NULL, NULL, NULL)

 
/*************************************************************************************************************************
CONNECTIONS - Publications
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsPublications'', ''Connections - Publications'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsPublications'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsPublications'', ''grdConnectionsPublicationsCols'', 1, ''Columns'', ''pubStationID,pubName,pubFrequency,pubMarket,pubItem,pubLink,pubActive,pubContact'', NULL, ''grid'', 
''[
	{id:"pubStationID", label:"Publication ID"},
	{id:"pubName", label:"Publication Name"},
	{id:"pubFrequency", label:"Frequency"},
	{id:"pubMarket", label:"Market"},
	{id:"pubItem", label:"Item"},
	{id:"pubLink", label:"Link ID"},
	{id:"pubActive", label:"Active"},
	{id:"pubContact", label:"Publication Contact"}

]''
 , NULL, NULL, NULL, NULL)

 
 
/*************************************************************************************************************************
CONNECTIONS - Stations
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsStations'', ''Connections - Stations'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsStations'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsStations'', ''grdConnectionsStationsCols'', 1, ''Columns'', ''staStationID,staName,staMarket,staItem,staLink,staActive,staContact'', NULL, ''grid'', 
''[
	{id:"staStationID", label:"Station ID"},
	{id:"staName", label:"Station Name"},
	{id:"staMarket", label:"Market"},
	{id:"staItem", label:"Item"},
	{id:"staLink", label:"Link ID"},
	{id:"staActive", label:"Active"},
	{id:"staContact", label:"Station Contact"}
]''
 , NULL, NULL, NULL, NULL)

 /*************************************************************************************************************************
CONNECTIONS - banking -> Authorize.net 
**************************************************************************************************************************/
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminCompanyConnections'', ''grdAuthorizeDotNetCols'', 1, ''Columns'', ''ccProcessorID,APILoginID,APITransactionKey,CurrencyID,CCCashAccountKey'', NULL, ''grid'', 
''[
	{id:"ccProcessorID", label:"Processor ID"},
	{id:"APILoginID", label:"API Login ID"},
	{id:"APITransactionKey", label:"API Key"},
	{id:"CurrencyID", label:"Currency ID"},
	{id:"CCCashAccountKey", label:"Receipt Account"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
CONNECTIONS - Retainers
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''connectionsRetainers'', ''Connections - Retainers'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''connectionsRetainers'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''connectionsRetainers'', ''grdConnectionsRetainersCols'', 1, ''Columns'', ''retainerClientID,retainerClientName,retainerAmountPerPeriod,retainerExtraAmountBilled,retainerTotalBilled,retainerTitle'', NULL, ''grid'', 
''[
{id:  "retainerClientID", label:"Client  ID"},
{id:  "retainerClientName", label:"Client Name"},
{id:  "retainerParentCompany Name", label:"Parent Company Name"},
{id:  "retainerAccountExecutive", label:"Account Executive"},
{id:  "retainerBillingManager", label:"Billing Manager"},
{id:  "retainerTitle", label:"Title"},
{id:  "retainerNumberOfPeriods", label:"Number of Periods"},
{id:  "retainerAmountPerPeriod", label:"Amount Per Period"},
{id:  "retainerStartDate", label:"Start Date"},
{id:  "retainerFrequency", label:"Frequency"},
{id:  "retainerNextBillingDate", label:"Next Billing Date"},
{id:  "retainerLastInvoiced", label:"Last Invoiced"},
{id:  "retainerTotalBilled", label:"Total Billed"},
{id:  "retainerRetainerAmountBilled", label:"Retainer Amount Billed"},
{id:  "retainerExtraAmountBilled", label:"Extra Amount Billed"},
{id:  "retainerSalesGLAccountNumber", label:"Sales GL Account Number"},
{id:  "retainerSalesGLAccountName", label:"Sales GL Account Name"},
{id:  "retainerTotalLabor", label:"Total Labor"},
{id:  "retainerTotalExpense", label:"Total Expense"},
{id:  "retainerVariance", label:"Variance"},
{id:  "retainerActive", label:"Active"},
{id:  "retainerDescription", label:"Description"},
{id:  "retainerCompanyID", label:"Company ID"},
{id:  "retainerCompanyName", label:"Company Name"},
{id:  "retainerOfficeID", label:"Office ID"},
{id:  "retainerOfficeName", label:"Office Name"},
{id:  "retainerCurrency", label:"Currency"},
{id:  "retainerRetainerID", label:"Retainer ID"},
{id:  "retainerPeriodsRemaining", label:"Periods Remaining"},
{id:  "retainerInvoiceTemplate", label:"Invoice Template"},
{id:  "retainerLayout", label:"Layout"},
{id:  "retainerIncludeLabor", label:"Include Labor"},
{id:  "retainerIncludeExpenses", label:"Include Expenses"},
{id:  "retainerDepartmentName", label:"Department Name"},
{id:  "retainerContactName", label:"Contact Name"}
]''
 , NULL, NULL, NULL, NULL)


/*************************************************************************************************************************
Admin Screens
**************************************************************************************************************************/

/*************************************************************************************************************************
Admin Screens - Activity Type
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''activityTypeSetup'', ''Activity Type Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''activityTypeSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''activityTypeSetup'', ''grdlistCols'', 1, ''Columns'', ''typeName,active,autoRollDate,typeColor'', NULL, ''grid'', 
''[
	{id:"typeName", label:"Type Name"},
	{id:"active", label:"Active"},
	{id:"autoRollDate", label:"Auto Roll Date"},
	{id:"typeColor", label:"Display Color"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Billing Item
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''billingItemSetup'', ''Billing Item Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''billingItemSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''billingItemSetup'', ''grdlistCols'', 1, ''Columns'', ''workTypeID,workTypeName,standardPrice,description,accountName,classId,taxable,taxable2,departmentName,avalaraTaxCode,active'', NULL, ''grid'', 
''[
	{id:"workTypeID", label:"ID"},
	{id:"workTypeName", label:"Name"},
	{id:"standardPrice", label:"StarndardPrice"},
	{id:"description", label:"Description"},
	{id:"accountName", label:"Sales Account"},
	{id:"classId", label:"Class"},
	{id:"taxable", label:"Taxable"},
	{id:"taxable2", label:"Taxable2"},
	{id:"departmentName", label:"Department Name"},
	{id:"avalaraTaxCode", label:"Avalara Tax Code"},
	{id:"active", label:"Active"}
]''
 , NULL, NULL, NULL, NULL)


/*************************************************************************************************************************
Admin Screens - Calendar Resources Type
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''calResourceSetup'', ''Calendar Resources Type Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''calResourceSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''calResourceSetup'', ''grdlistCols'', 1, ''Columns'', ''resourceName'', NULL, ''grid'', 
''[
	{id:"resourceName", label:"Resource Name"}

]''
 , NULL, NULL, NULL, NULL)

 /*************************************************************************************************************************
Admin Screens - Project Type Setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''projectTypeSetup'', ''Project Type Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''projectTypeSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''projectTypeSetup'', ''grdlistCols'', 1, ''Columns'', ''projectTypeName,description,active,projectNumPrefix,nextProjNum,projectTypeColor,avalaraTaxCode'', NULL, ''grid'', 
''[
      {id:"projectTypeName", label:"Project Type"},  
      {id:"description", label:"Description"},
	  {id:"active", label:"Active"}, 
      {id:"projectNumPrefix", label:"Project Number Prefix/Suffix"}, 
	  {id:"nextProjNum", label:"Next Project Number"}, 
	  {id:"projectTypeColor",label:"Project Type Color"},
	  {id:"avalaraTaxCode", label:"Avalara Tax Code"}
]''
 , NULL, NULL, NULL, NULL)
/*************************************************************************************************************************
Admin Screens - Company Type
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''companyTypeSetup'', ''Company Type Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''companyTypeSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''companyTypeSetup'', ''grdlistCols'', 1, ''Columns'', ''companyTypeName,active'', NULL, ''grid'', 
''[
	{id:"companyTypeName", label:"Company Type Name"},
	{id:"active", label:"Active"}

]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Item Rate Sheet
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminItemRateSheet'', ''Item Rate Sheet Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminItemRateSheet'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminItemRateSheet'', ''grdlistCols'', 1, ''Columns'', ''itemRS_RateSheetName,itemRS_Active'', NULL, ''grid'', 
''[
	{id:"itemRS_RateSheetName", label:"Rate Sheet Name"},
	{id:"itemRS_Active", label:"Active"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Item Rate Sheet Details
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminItemRateSheetDetails'', ''Item Rate Sheet Detail Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminItemRateSheetDetails'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminItemRateSheetDetails'', ''grdlistCols'', 1, ''Columns'', ''itemRSD_ItemID,itemRSD_ItemName,itemRSD_UseUnitRate,itemRSD_Markup,itemRSD_UnitRate'', NULL, ''grid'', 
''[
	{id:"itemRSD_ItemID" label:"Item ID"},
	{id:"itemRSD_ItemName", label:"Item Name"},
	{id:"itemRSD_UseUnitRate", label:"Use Unit Rate"},
	{id:"itemRSD_Markup", label:"Markup/Commission"},
	{id:"itemRSD_UnitRate", label:"Unit Rate"}
]''
 , NULL, NULL, NULL, NULL)

 /*************************************************************************************************************************
Admin Screens - Medai Marekets
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''mediaMarkets'', ''Media Markets'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''mediaMarkets'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''mediaMarkets'', ''grdlistCols'', 1, ''Columns'', ''marketID,marektName,active'', NULL, ''grid'', 
''[
	{id:"marketID", label:"ID},
	{id:"marektName", label:"Description"},
	{id:"active", label:"Active"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Meeting Type
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''meetingTypeSetup'', ''Meeting Type Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''meetingTypeSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''meetingTypeSetup'', ''grdlistCols'', 1, ''Columns'', ''typeName,typeColor'', NULL, ''grid'', 
''[
	{id:"typeName", label:"Meeting Type Name"},
	{id:"typeColor", label:"Type Color"}

]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Opportunity Outcomes
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''oppOutcomeSetup'', ''Opportunity Outcome Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''oppOutcomeSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''oppOutcomeSetup'', ''grdlistCols'', 1, ''Columns'', ''leadStageName,postiveOutcome,active'', NULL, ''grid'', 
''[
	{id:"leadStageName", label:"Outcome"},
	{id:"postiveOutcome", label:"Positive Outcome"},
	{id:"active", label:"Active"}

]''
 , NULL, NULL, NULL, NULL)



 /*************************************************************************************************************************
Admin Screens - Opportunity Status
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''oppStatusSetup'', ''Opportunity Status Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''oppStatusSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''oppStatusSetup'', ''grdlistCols'', 1, ''Columns'', ''opStage_Stage,opStage_DisplayOrder,opStage_DefaultProbability,opStage_DisplayOnDashboard,opStage_UseDefaultProbability'', NULL, ''grid'', 
''[
	{id:"opStatus_LeadStatusName", label:"Lead Status Name"},
	{id:"opStatus_DisplayOrder", label:"Display Order"},
	{id:"opStatus_Active", label:"Active"}
	
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Revision Reasons
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''revisionReasons'', ''Revision Reasons'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''revisionReasons'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''revisionReasons'', ''grdlistCols'', 1, ''Columns'', ''reasonID,description,active'', NULL, ''grid'', 
''[
	{id:"reasonID", label:"ID},
	{id:"description", label:"Description"},
	{id:"active", label:"Active"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Source
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminSource'', ''Source Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminSource'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminSource'', ''grdlistCols'', 1, ''Columns'', ''sourceName,active'', NULL, ''grid'', 
''[
	{id:"sourceName", label:"Source Name"},
	{id:"active", label:"Active"}
	
	
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Service Rate Sheet
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminServiceRateSheet'', ''Servies Rate Sheet Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminServiceRateSheet'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminServiceRateSheet'', ''grdlistCols'', 1, ''Columns'', ''SheetName,active'', NULL, ''grid'', 
''[
	{id:"SheetName", label:"Rate Sheet Name"},
	{id:"active", label:"Active"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Service Rate Sheet Details
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminServiceRateSheetDetails'', ''Servies Rate Sheet Detail Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminServiceRateSheetDetails'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminServiceRateSheetDetails'', ''grdlistCols'', 1, ''Columns'', ''ServiceCode,Description,HourlyRate1,HourlyRate2,HourlyRate3,HourlyRate4,HourlyRate5'', NULL, ''grid'', 
''[
	{id:"ServiceCode" label:"Service Code"},
	{id:"Description", label:"Description"},
	{id:"HourlyRate1", label:"Rate 1"},
	{id:"HourlyRate2", label:"Rate 2"},
	{id:"HourlyRate3", label:"Rate 3"},
	{id:"HourlyRate4", label:"Rate 4"},
	{id:"HourlyRate5", label:"Rate 5"}
]'' , NULL, NULL, NULL, NULL)

 /*************************************************************************************************************************
Admin Screens - Title Rate Sheet
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminTitleRateSheet'', ''Title Rate Sheet Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminTitleRateSheet'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminTitleRateSheet'', ''grdlistCols'', 1, ''Columns'', ''SheetName,active'', NULL, ''grid'', 
''[
	{id:"SheetNamev", label:"Rate Sheet Name"},
	{id:"active", label:"Active"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Title Rate Sheet Details
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminTitleRateSheetDetails'', ''Title Rate Sheet Detail Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminTitleRateSheetDetails'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminTitleRateSheetDetails'', ''grdlistCols'', 1, ''Columns'', ''titleID,titleName,hourlyRate'', NULL, ''grid'', 
''[
	{id:"titleID" label:"Title ID"},
	{id:"titleName", label:"Title Name"},
	{id:"hourlyRate", label:"Hourly Rate"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Service Setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''serviceSetup'', ''Service Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''serviceSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''serviceSetup'', ''grdlistCols'', 1, ''Columns'', ''services_ServiceCode,services_Description,services_Active,services_Color'', NULL, ''grid'', 
''[
	{id:"services_ServiceCode", label:"Service Code"},
	{id:"services_Description", label:"Description"},
	{id:"services_Color", label:"Color"},
	{id:"services_HourlyRate1", label:"Hourly Rate1"},
	{id:"services_HourlyRate2", label:"Hourly Rate2"},
	{id:"services_HourlyRate3", label:"Hourly Rate3"},
	{id:"services_HourlyRate4", label:"Hourly Rate4"},
	{id:"services_HourlyRate5", label:"Hourly Rate5"},
	{id:"services_Active", label:"Active"},
	{id:"services_Description1", label:"Description1"},
	{id:"services_Description2", label:"Description2"},
	{id:"services_Description3", label:"Description3"},
	{id:"services_Description4", label:"Description4"},
	{id:"services_Description5", label:"Description5"},
	{id:"services_HourlyCost", label:"Hourly Cost"},
	{id:"services_Taxable", label:"Taxable"},
	{id:"services_Taxable2", label:"Taxable2"},
	{id:"services_WorkTypeID", label:"Billing Item"},
	{id:"services_ClassID", label:"Class"},
	{id:"services_DepartmentName", label:"Department"},
	{id:"services_AccessRestrictions", label:"Access Restrictions"},
	{id:"services_SalesAccountName", label:"Sales Account Name"},
	{id:"services_AvalaraTaxCode", label:"Avalara Tax Code"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Expense Report Items Setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''expenseItemsSetup'', ''Expense Items Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''expenseItemsSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''expenseItemsSetup'', ''grdItemList'', 1, ''Columns'', ''itemID,itemName,unitCost,unitRate,standardDescription,workTypeID,active'', NULL, ''grid'', 
''[
	{id:"itemID", label:"Item ID"},
	{id:"itemName", label:"Item Name"},
	{id:"unitCost", label:"Unit Cost"},
	{id:"unitRate", label:"Unit Rate"},
	{id:"markup", label:"Markup"},
	{id:"useUnitRate", label:"Use Unit Rate"},
	{id:"standardDescription", label:"Standard Description"},
	{id:"workTypeID", label:"Billing Item"},
	{id:"department", label:"Department"},
	{id:"expenseAccount", label:"Expense Account"},
	{id:"salesAccount", label:"Sales Account"},
	{id:"class", label:"Class"},
	{id:"taxable", label:"Taxable"},
	{id:"taxable2", label:"Taxable2"},
	{id:"active", label:"Active"},
	{id:"avalaraTaxCode", label:"Avalara Tax Code"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Purchase Items Setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''purchaseItemsSetup'', ''Purchase Items Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchaseItemsSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''purchaseItemsSetup'', ''grdItemList'', 1, ''Columns'', ''itemID,itemName,expenseAccount,salesAccount,unitCost,unitRate,unitDescription,standardDescription,workTypeID,active'', NULL, ''grid'', 
''[
	{id:"itemID", label:"Item ID"},
	{id:"itemName", label:"Item Name"},
	{id:"unitCost", label:"Unit Cost"},
	{id:"unitRate", label:"Unit Rate"},
	{id:"unitDescription", label:"Unit Description"},
	{id:"markup", label:"Markup"},
	{id:"useUnitRate", label:"Use Unit Rate"},
	{id:"standardDescription", label:"Standard Description"},
	{id:"workTypeID", label:"Billing Item"},
	{id:"department", label:"Department"},
	{id:"expenseAccount", label:"Expense Account"},
	{id:"salesAccount", label:"Sales Account"},
	{id:"class", label:"Class"},
	{id:"quantityOnHand", label:"Quantity On Hand"},
	{id:"taxable", label:"Taxable"},
	{id:"taxable2", label:"Taxable2"},
	{id:"active", label:"Active"},
	{id:"avalaraTaxCode", label:"Avalara Tax Code"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Broadcast Items Setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''broadcastItemsSetup'', ''Broadcast Items Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''broadcastItemsSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''broadcastItemsSetup'', ''grdItemList'', 1, ''Columns'', ''itemID,itemName,markup,standardDescription,workTypeID,active'', NULL, ''grid'', 
''[
	{id:"itemID", label:"Item ID"},
	{id:"itemName", label:"Item Name"},
	{id:"markup", label:"Commission"},
	{id:"standardDescription", label:"Standard Description"},
	{id:"workTypeID", label:"Billing Item"},
	{id:"department", label:"Department"},
	{id:"expenseAccount", label:"Expense Account"},
	{id:"salesAccount", label:"Sales Account"},
	{id:"class", label:"Class"},
	{id:"taxable", label:"Taxable"},
	{id:"taxable2", label:"Taxable2"},
	{id:"active", label:"Active"},
	{id:"avalaraTaxCode", label:"Avalara Tax Code"},
	{id:"useMarkup", label:"Use Markup"}
]''
 , NULL, NULL, NULL, NULL)

/*************************************************************************************************************************
Admin Screens - Print Items Setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''printItemsSetup'', ''Print and Digital Items'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''printItemsSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''printItemsSetup'', ''grdItemList'', 1, ''Columns'', ''itemID,itemName,markup,standardDescription,workTypeID,expenseAccount,salesAccount,active'', NULL, ''grid'', 
''[
	{id:"itemID", label:"Item ID"},
	{id:"itemName", label:"Item Name"},
	{id:"unitRate", label:"Standard Gross"},
	{id:"markup", label:"Commission"},
	{id:"standardDescription", label:"Standard Description"},
	{id:"workTypeID", label:"Billing Item"},
	{id:"department", label:"Department"},
	{id:"expenseAccount", label:"Expense Account"},
	{id:"salesAccount", label:"Sales Account"},
	{id:"class", label:"Class"},
	{id:"taxable", label:"Taxable"},
	{id:"taxable2", label:"Taxable2"},
	{id:"active", label:"Active"},
	{id:"avalaraTaxCode", label:"Avalara Tax Code"},
	{id:"useMarkup", label:"Use Markup"}
]''
 , NULL, NULL, NULL, NULL)

 /*************************************************************************************************************************
Admin Screens - GL Accounts setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''glaccountSetup'', ''GL Account Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''glaccountSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''glaccountSetup'', ''grdlistCols'', 1, ''Columns'', ''glaccount_AccountNumber,glaccount_Active,glaccount_AccountTypeAccrual,glaccount_AccountTypeCash,glaccount_PayrollExpense,glaccount_FacilityExpense,glaccount_LaborIncome'', NULL, ''grid'', 
''[
	{id:"glaccount_AccountNumber", label:"Account Number"},
	{id:"glaccount_Active", label:"Active"},
	{id:"glaccount_AccountTypeAccrual", label:"Account Type (Accrual)"},
	{id:"glaccount_AccountTypeCash", label:"Account Type (Cash)"},
	{id:"glaccount_PayrollExpense", label:"Payroll Expense"},
	{id:"glaccount_FacilityExpense", label:"Facility Expense"},
	{id:"glaccount_LaborIncome", label:"Labor Income"},
	{id:"glaccount_BankAccountNumber", label:"Bank Account Number"},
	{id:"glaccount_CurrencyID", label:"Currency"},
	{id:"glaccount_NextCheckNumber", label:"Next Check Number"},
	{id:"glaccount_DefaultCheckFormat", label:"Default Check Format"},
	{id:"glaccount_RevalueCurr", label:"Revalue Balance Sheet"},
	{id:"glaccount_Description", label:"Description"},
	{id:"glaccount_SubAccount", label:"SubAccount Of"},
	{id:"glaccount_Ebitda", label:"EBITDA Account"},
]''
 , NULL, NULL, NULL, NULL)


/*************************************************************************************************************************
Admin Screens - Purchase Order Types Setup
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''purchaseOrderTypesSetup'', ''Purchase Order Types Setup'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''purchaseOrderTypesSetup'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''purchaseOrderTypesSetup'', ''grdItemList'', 1, ''Columns'', ''purchaseOrderTypeName,description,headerFieldSet,detailFieldSet,standardHeaderText,standardFooterText,active'', NULL, ''grid'', 
''[
	{id:"purchaseOrderTypeName", label:"PO Type Name"},
	{id:"description", label:"Description"},
	{id:"headerFieldSet", label:"Default PO Header Fields"},
	{id:"detailFieldSet", label:"Default PO Line Fields"},
	{id:"standardHeaderText", label:"Standard Header Text"},
	{id:"standardFooterText", label:"Standard Footer Text"},
	{id:"active", label:"Active"}
]''
 , NULL, NULL, NULL, NULL)
 
 /*************************************************************************************************************************/

/*************************************************************************************************************************
Employees
**************************************************************************************************************************/

INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''adminEmployees'', ''Employee Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminEmployees'', ''H2'', 1, ''Display Options'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminEmployees'', ''GroupBy'', 2, ''Group By'', ''Department'', ''Department'', ''lookup'', ''No Grouping:NoGrouping|Department:Department|Security Group:SecurityGroup|Default GL Company:DefaultGLCompanyName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminEmployees'', ''GroupByDir'', 3, ''Group Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminEmployees'', ''SortBy'', 4, ''Sort By'', ''LastName'', ''Last Name'', ''lookup'', ''No Sorting:NoSorting|Department:Department|First Name:FirstName|Last Name:LastName|Security Group:SecurityGroup'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''adminEmployees'', ''SortByDir'', 5, ''Sort Order'', ''ASC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''adminEmployees'', ''grdEmployeeCols'', 6, ''Columns'', ''firstName,lastName,phone,email,active,securityGroup'', NULL, ''grid'', 
''[
	{id:"userKey", label:"User Key"},
	{id:"companyKey", label:"Company Key"},
	{id:"gLCompanyKey", label:"G L Company Key"},
	{id:"firstName", label:"First Name"},
	{id:"middleName", label:"Middle Name"},
	{id:"lastName", label:"Last Name"},
	{id:"salutation", label:"Salutation"},
	{id:"department", label:"Department"},
	{id:"phone", label:"Phone"},
	{id:"secondPhone", label:"Second Phone"},
	{id:"cellPhone", label:"Cell Phone"},
	{id:"fax", label:"Fax"},
	{id:"pager", label:"Pager"},
	{id:"title", label:"Title"},
	{id:"email", label:"Email"},
	{id:"rateLevel", label:"Rate Level"},
	{id:"securityGroup", label:"Security Group"},
	{id:"administrator", label:"Administrator"},
	{id:"userID", label:"User ID"},
	{id:"systemID", label:"System ID"},
	{id:"active", label:"Active"},
	{id:"autoAssign", label:"Auto Assign"},
	{id:"canNotBeUnassigned", label:"Can Not Be Unassigned"},
	{id:"hourlyRate", label:"Hourly Rate"},
	{id:"hourlyCost", label:"Hourly Cost"},
	{id:"monthlyCost", label:"Monthly Cost"},
	{id:"timeApprover", label:"Time Approver"},
	{id:"expenseApprover", label:"Expense Approver"},
	{id:"creditCardApprover", label:"Credit Card Approver"},
	{id:"calendarApprover", label:"Meeting Approver"},
	{id:"backupApprover", label:"Backup Approver"},
	{id:"supervisor", label:"Supervisor"},
	{id:"mySupervisor", label:"My Supervisor"},
	{id:"pOLimit", label:"PO Limit"},
	{id:"broadcastOrderLimit", label:"Broadcast Order Limit"},
	{id:"insertionOrderLimit", label:"Insertion Order Limit"},
	{id:"vendorID", label:"Vendor ID"},
	{id:"vendorFullName", label:"Vendor Full Name"},
	{id:"classID", label:"Class ID"},
	{id:"classFullName", label:"Class Full Name"},
	{id:"office", label:"Office"},
	{id:"locked", label:"Locked"},
	{id:"address1", label:"Address1"},
	{id:"address2", label:"Address2"},
	{id:"address3", label:"Address3"},
	{id:"city", label:"City"},
	{id:"state", label:"State"},
	{id:"postalCode", label:"Postal Code"},
	{id:"country", label:"Country"},
	{id:"homeAddress1", label:"Home Address1"},
	{id:"homeAddress2", label:"Home Address2"},
	{id:"homeAddress3", label:"Home Address3"},
	{id:"homeCity", label:"Home City"},
	{id:"homeState", label:"Home State"},
	{id:"homePostalCode", label:"Home Postal Code"},
	{id:"homeCountry", label:"Home Country"},
	{id:"otherAddress1", label:"Other Address1"},
	{id:"otherAddress2", label:"Other Address2"},
	{id:"otherAddress3", label:"Other Address3"},
	{id:"otherCity", label:"Other City"},
	{id:"otherState", label:"Other State"},
	{id:"otherPostalCode", label:"Other Postal Code"},
	{id:"otherCountry", label:"Other Country"},
	{id:"defaultService", label:"Default Service"},
	{id:"defaultServiceDescription", label:"Default Service Description"},
	{id:"birthday", label:"Birthday"},
	{id:"dateHired", label:"Date Hired"},
	{id:"role", label:"Role"},
	{id:"assistant", label:"Assistant"},
	{id:"assistantPhone", label:"Assistant Phone"},
	{id:"assistantEmail", label:"Assistant Email"},
	{id:"spousePartner", label:"Spouse/Partner"},
	{id:"children", label:"Children"},
	{id:"anniversary", label:"Anniversary"},
	{id:"hobbies", label:"Hobbies"},
	{id:"usageLevel", label:"Usage Level"},
	{id:"contractor", label:"Contractor"},
	{id:"defaultGLCompanyID", label:"Default GL Company ID"},
	{id:"defaultGLCompanyName", label:"Default GL Company Name"},
	{id:"billingTitleID", label:"Billing Title ID"},
	{id:"billingTitleName", label:"Billing  Title Name"},
	{id:"billingTitleFullName", label:"Billing Title Full Name"},
	{id:"lastLoggedIn", label:"Last Logged In"},
	{id:"lastLoggedOut", label:"Last Logged Out"},
	{id:"userToken", label:"User Token"},
	{id:"dateCreated", label:"Date Created"},
	{id:"defaultCulture", label:"Default Culture"},
	{id:"timeZoneDisplay", label:"Employee Time Zone"},
	{id:"createdBy", label:"Created By"}
]''
 , NULL, NULL, NULL, NULL)



/*************************************************************************************************************************
Deliverable Reviews
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''review'', ''Review Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''DisplayActualSize'', 1, ''Always load review items at actual size'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''UseAdvancedTools'', 2, ''Use Advanced Tools'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''RequireMarkupForComment'', 3, ''Require annotations for comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''ShowApprovedWithChanges'', 4, ''Show Approved with Changes as a decision'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''ShowAssignFollupUpTaskLink'', 5, ''Show Assign a Followup Task Link'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''correspondingAnnotations'', 6, ''Use corresponding annotations and comments'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''review'', ''useReplaceTextOnPDF'', 7, ''Use replace text with PDFs'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)

/*************************************************************************************************************************/



/*************************************************************************************************************************
Account Rec
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''acctRec'', ''Acct Rec Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''acctRec'', ''grdDecreaseCols'', 1, ''Decrease Columns'', ''colDTranDate,colDRef,colDMemo,colDAmount'', NULL, ''grid'', 
''[
	{id:"colDTranDate", label:"Transaction Date"},
	{id:"colDRef", label:"Reference"},
	{id:"colDMemo", label:"Memo"},
	{id:"colDPayee", label:"Payee Name"},
	{id:"colDAmount", label:"Amount"}

]''
 , NULL, NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''acctRec'', ''grdIncreaseCols'', 2, ''Increase Columns'', ''colITranDate,colIRef,colIMemo,colIAmount'', NULL, ''grid'', 
''[
	{id:"colITranDate", label:"Transaction Date"},
	{id:"colIRef", label:"Reference"},
	{id:"colIMemo", label:"Memo"},
	{id:"colIAmount", label:"Amount"}

]''
 , NULL, NULL, NULL, NULL)

 
/*************************************************************************************************************************
Add People
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''myAddPeople'', ''Add People Settings'', '''', 0)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''myAddPeople'', ''keepOpen'', 1, ''Keep panel open'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will keep the add people screen open after you select and add people so that you can select other people'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''myAddPeople'', ''autoRunStaff'', 2, ''Search for staff when the screen is opened'', ''1'', NULL, ''checkbox'', NULL, NULL, ''If you have a lot of employees, you may uncheck this option so you can first enter some search criteria rather than opening the entire list'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''myAddPeople'', ''autoRunContacts'', 3, ''Search for contacts when the screen is opened'', ''1'', NULL, ''checkbox'', NULL, NULL, ''If you have a lot of contacts, you may uncheck this option so you can first enter some search criteria rather than opening the entire list'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''myAddPeople'', ''projectTeamOnly'', 4, ''Project Team Only'', ''0'', NULL, ''checkbox'', NULL, NULL, ''This will limit the search options to just client contacts and project team and will override the search for staff when screen is open option above'')




/*************************************************************************************************************************  exec spConvertAppSeedSetting 1
deliverables Board
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''deliverablesBoard'', ''Board Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''groupBy'', 1, ''Group Grid By'', ''StatusName'', ''Deliverable Status'', ''lookup'', ''No Grouping:NoGrouping|Deliverable Status:StatusName|Type:TypeName|Deliverable Name:DeliverableName|Due Date:DueDate|Approved:IsApproved|Owner Name:OwnerName|Completed:IsCompleted'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''sortBy'', 2, ''Sort Grid By'', ''DueDate'', ''Due Date'', ''lookup'', ''Status:StatusName|Due Date:DueDate'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''sortByDir'', 3, ''Sort Direction'', ''DESC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''boardViewAllowed'', 4, ''Group Cards By'', ''Both'', NULL, ''lookup'', ''Task|Status|Both'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''filterClient'', 5, ''Show Client Filter'', ''0'', NULL, ''checkbox'', NULL, NULL, ''If you filter by client alone, you will not be able to set specific display orders'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''filterCampaign'', 6, ''Show Campaign Filter'', ''0'', NULL, ''checkbox'', NULL, NULL, ''If you filter by campaign alone, you will not be able to set specific display orders'')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''hideCompletedTasks'', 7, ''Hide Deliverables For Completed Tasks'', ''0'', NULL, ''checkbox'', NULL, NULL, '''')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''hideApprovedCompleted'', 8, ''Hide Completed Deliverables'', ''0'', NULL, ''checkbox'', NULL, NULL, '''')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesBoard'', ''hideDuplicate'', 9, ''Hide Duplicate Button'', ''0'', NULL, ''checkbox'', NULL, NULL, '''')

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''deliverablesBoard'', ''grdDeliverablesCols'', 10, ''Grid Columns'', ''colDBoardDeliverableName,colDBoardComments,colDBoardDueDate,colDBoardStatusName,colDBoardDeliverableType,colDBoardRoundName,colDBoardApprovalStatus,colDBoardOpenIssueCount'', NULL, ''grid'', 
''[   
	{id:  "colDBoardStatusName", label:"Status Name"},   
	{id:  "colDBoardDeliverableName", label:"Deliverable Name"},   
	{id:  "colDBoardProjectNumber", label:"Project Number"},  
	{id:  "colDBoardProjectName", label:"Project Name"},  
	{id:  "colDBoardTask", label:"Task Name"},  
	{id:  "colDBoardComments", label:"Conversation Count"},  
	{id:  "colDBoardDeliverableType", label:"Type"},  
	{id:  "colDBoardDescription", label:"Description"},   
	{id:  "colDBoardDueDate", label:"Due Date"},    
	{id:  "colDBoardApproved", label:"Approved"},   
	{id:  "colDBoardApprovedDate", label:"Approved Date"},
	{id:  "colDBoardCompleted", label:"Completed"},   
	{id:  "colDBoardOwnerName", label:"Owner Name"},   
	{id:  "colDBoardRoundCount", label:"Round Count"},   
	{id:  "colDBoardOpenIssueCount", label:"Open To Do Count"},   
	{id:  "colDBoardClosedIssueCount", label:"Closed To Do Count"} ,   
	{id:  "colDBoardRoundName", label:"Current Round"},   
	{id:  "colDBoardApprovalStatus", label:"Approval Status"},
	{id:  "colDBoardDeliverableID", label:"Deliverable ID"},
	{id:  "colDBoardSubject", label:"Current Step Name"}
]''
 , NULL, NULL, ''Deliverable'', ''Deliverables'')

 /*************************************************************************************************************************
Deliverables Dash
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''deliverablesDash'', ''Deliverable Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesDash'', ''showSampleImage'', 1, ''Show Sample Image'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesDash'', ''showDailyFeed'', 2, ''Show the Daily Feed'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesDash'', ''showConversations'', 3, ''Show Conversations'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesDash'', ''showToDos'', 4, ''Show To Dos'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''deliverablesDash'', ''showReviewRounds'', 5, ''Show Review Rounds'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, VisibleField)
Values (''deliverablesDash'', ''showReverseOrder'', 6, ''Show Reverse Order'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL, ''showReviewRounds'')




/*************************************************************************************************************************
ToDo Board - Need to finish updating
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''toDoBoard'', ''Board Settings'', '''', 1)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''toDoBoard'', ''groupBy'', 1, ''Group Grid By'', ''StatusName'', ''Status Name'', ''lookup'', ''No Grouping:NoGrouping|Status Name:StatusName|Project:ProjectFullName|Client:FullClientName|Assigned:AssignedUserName|Due Date:ActivityDate|Type:TypeName|Task Plan Complete Date:PlanComplete'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''toDoBoard'', ''sortBy'', 2, ''Sort Grid By'', ''StatusName'', ''Status Name'', ''lookup'', ''Status Name:StatusName|Project:ProjectFullName|Client:FullClientName|Assigned:AssignedUserName|Due Date:ActivityDate|Type:TypeName'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''toDoBoard'', ''sortByDir'', 3, ''Sort Direction'', ''DESC'', NULL, ''lookup'', ''ASC|DESC'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''toDoBoard'', ''filterClient'', 4, ''Show Client Filter'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will display the client filter'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''toDoBoard'', ''filterProject'', 5, ''Show Project Filter'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will display the project filter'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''toDoBoard'', ''filterTask'', 6, ''Show Task Filter'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will display the task filter.'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''toDoBoard'', ''filterUser'', 7, ''Show User Filter'', ''1'', NULL, ''checkbox'', NULL, NULL, ''This will display the user filter'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, TransPref)
Values (''toDoBoard'', ''filterType'', 8, ''Show Type Filter'', ''0'', NULL, ''checkbox'', NULL, NULL, ''This will display the type filter'', ''UseTypeOnToDo'')
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''toDoBoard'', ''grdToDoCols'', 9, ''Grid Columns'', ''coltodoBoardSubject,coltodoBoardProject,coltodoBoardClient,coltodoBoardAssigned,coltodoBoardNotes,coltodoBoardStatusName,coltodoBoardType'', NULL, ''grid'', 
''[   
	{id:  "coltodoBoardSubject", label:"Subject"},   
	{id:  "coltodoBoardProject", label:"Project"},   
	{id:  "coltodoBoardClient", label:"Client"},   
	{id:  "coltodoBoardAssigned", label:"Assigned"},   
	{id:  "coltodoBoardDueDate", label:"Due Date"},
	{id:  "coltodoBoardNotes", label:"Description"},
	{id:  "coltodoBoardStatusName", label:"Status Name"},
	{id:  "coltodoBoardType", label:"Type"},
	{id:  "coltodoBoardTaskFullName", label:"Task"},
	{id:  "coltodoBoardTodoID", label:"To Do ID"},
	{id:  "coltodoBoardCompleted", label:"Completed"},
	{id:  "coltodoBoardPlanComplete", label:"Task Plan Complete Date"},
	{id:   "coltodoBoardOriginatedBy", label:"Originated By"},
	{id:   "coltodoBoardCreatedBy", label:"Created By"}

]''
 , NULL, NULL, ''Activity'', ''Activity'')

 /*************************************************************************************************************************
Estimate Add
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''estimateAdd'', ''Add Estimate Settings'', '''', 0)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''estimateAdd'', ''DeliveryDateRequired'', 1, ''Require Delivery Date'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Common Timeline Options
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''commonTimeLine'', ''Timeline Settings'', '''', 0)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''commonTimeLine'', ''HideEnterTime'', 29, ''Hide enter your time for today'', ''0'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''commonTimeLine'', ''DisplayTimeEntries'', 30, ''Display Time Entries'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''commonTimeLine'', ''IncludePublicMeetings'', 31, ''Include Public Meetings'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)


/*************************************************************************************************************************
Campaign Schedule
**************************************************************************************************************************/
INSERT tAppSettingGroup(GroupID, Title, Rights, ResetSettings) Values(''campaignSchedule'', ''Campaign Schedule Grid'', '''', 1)

INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignSchedule'', ''H1'', 0, ''Settings'', NULL, NULL, ''sectionheader'', NULL, NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint)
Values (''campaignSchedule'', ''ScheduleLockedColumns'', 1, ''Locked Columns'', ''1'', ''1'', ''lookup'', ''1:1|2:2|3:3|4:4|5:5'', NULL, NULL)
INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint, CFEntity1, CFPrefix1) 
Values (''campaignSchedule'', ''grdCampaignScheduleCols'', 2, ''Columns'', ''campaignAssigned,campaignProjectStart,campaignProjectEnd,campaignPercComp'', NULL, ''grid'', 

''[	{id:"campaignAssigned", label:"Assigned"},
	{id:"campaignProjectStart", label:"Plan Start"},
	{id:"campaignProjectEnd", label:"Plan Complete"},
	{id:"campaignPercComp", label:"%"},
	{id:"campaignScheduleTaskStatus", label:"Status"},
	{id:"campaignScheduleAssignedFullName", label:"Assigned Full Name"},
	{id:"campaignSchedulePlanDuration", label:"Days"},
	{id:"campaignScheduleActualHours", label:"Actual Hours"},
	{id:"campaignSchedulePredecessors", label:"Predecessors"},
	{id:"campaignScheduleActualStart", label:"Actual Start"},
	{id:"campaignScheduleActualComplete", label:"Actual Complete"},
	{id:"campaignScheduleAllTimesheets", label:"All Time Sheets"},
	{id:"campaignScheduleBillingItem", label:"Billing Item"},
	{id:"campaignProject", label:"Project"},
	{id:"campaignSummaryTask", label:"Summary Task"},
	{id:"campaignSegment", label:"Segment"},
	{id:"campaignScheduleBOCommision", label:"BO Commission"},
	{id:"campaignScheduleConstraint", label:"Constraint"},
	{id:"campaignScheduleConstraintDate", label:"Constraint Date"},
	{id:"campaignScheduleConstraintDayOfWeek", label:"Constraint Day Of The Week"},
	{id:"campaignScheduleDescription", label:"Description"},
	{id:"campaignScheduleDueComment", label:"Due Comment"},
	{id:"campaignScheduleAllocHours", label:"Allocated Hours"},
	{id:"campaignScheduleRemainingHours", label:"Remaining Hours"},
	{id:"campaignScheduleEstHours", label:"Est Hours"},
	{id:"campaignScheduleHideFromClient", label:"Hide From Client"},
	{id:"campaignScheduleHourlyRate", label:"Hourly Rate"},
	{id:"campaignScheduleIOCommision", label:"IO Commission"},

	{id:"campaignScheduleLine", label:"Line"},
	{id:"campaignScheduleMarkup", label:"Markup"},
	{id:"campaignScheduleOrigStart", label:"Baseline Start"},
	{id:"campaignScheduleOrigComp", label:"Baseline Complete"},
	{id:"campaignSchedulePriority", label:"Priority"},
	{id:"campaignScheduleReviewed", label:"Reviewed"},
	{id:"campaignScheduleTaskScheduled", label:"Show On Schedule"},
	{id:"campaignScheduleShowOnEstimate", label:"Show On Estimate"},
	{id:"campaignScheduleStatusDescription", label:"Status Comment"},
	{id:"campaignScheduleTaskID", label:"Task ID"},
	{id:"campaignScheduleTax1", label:"Tax 1"},
	{id:"campaignScheduleTax2", label:"Tax 2"},
	{id:"campaignScheduleDateAssigned", label:"Date Assigned"},
	{id:"campaignScheduleTimeAssigned", label:"Time Assigned"},
	{id:"campaignScheduleTrackBudgets", label:"Track Budgets"},
	{id:"campaignScheduleExcludeFromStatus", label:"Exclude From Status"},
	{id:"campaignScheduleWorkAnyDay", label:"Work Any Day"},
	{id:"campaignScheduleTimelineSection", label:"Timeline Section"},
	{id:"campaignScheduleTimelineSegmentDisplayName", label:"Override Display Name"},
	{id:"campaignScheduleTCProjectStatus", label:"Task Complete Project Status"},
	{id:"campaignScheduleOpenToDos", label:"Open ToDos"}

 ]''
	 , NULL, NULL, null, null)


INSERT tAppSetting(GroupID, SessionID, DisplayOrder, Label, DefaultValue, DefaultLabel, EditorType, ValueList, LookupID, Hint) 
Values (''campaignSchedule'', ''editColumnSets'', 3, ''Edit Column Sets'', ''1'', NULL, ''checkbox'', NULL, NULL, NULL)

/* Old Comments:
|| 02/18/19  CRG 19.0.3.0 (421239) Removed PlanningMultipleTasks from the project schedule settings (it is now a setting on the project itself)
|| 02/19/19  CRG 19.0.3.0 (446583) Added Remaining Hours to projectSchedule columns
|| 02/26/19  AMP 19.0.3.0 (440082) Added Client Name and Vendor Name to the GL Drilldown
|| 02/26/19  RLS 19.0.3.0 (444491) Added Campaign Description to the campaignDashBoard
|| 02/26/19  GHL 19.0.3.0 (442017) Added currency to estimate listing (under project)
|| 02/27/19  AMP 19.0.3.0 (447860) Added Journal Entries to the Global Search option  
|| 03/04/19  GWG 19.0.3.0  Fixing group options on deliverables board
|| 03/07/19  AMP 19.0.4.0 (447900) Added Date/Time Sent to the Deliverable Approvals
|| 03/11/19  AMP 19.0.4.0 (448928) Added TaskID to Today-Creatives grid view
|| 03/13/09  AMP 19.0.4.0 (422224) Added the Approval Comments and Worksheet Comments to the BillingWorksheetsToApprove, BillingWorksheetsInReview,ReadyToCreateInvoices and BillingWorksheetsAll listings
|| 03/14/19  GHL 19.0.4.0 Added Applied spots and amount to bill on BO grid after discussion with Greg
|| 03/13/19  GWG 19.0.4.0 Adding labs to this side since they mostly affect the menus
|| 03/18/19  CRG 19.0.4.0 (449162) Added prjScheduleExcludeFromStatus to projectSchedule columns
|| 03/18/19  AMP 19.0.4.0 (449681) Added the Currency field as an available field to the projects screen.  
|| 03/20/19  MCM 19.0.4.0 (443519) Adding ToDo Board column information
|| 03/21/19  GWG 19.0.4.0 Removing platMedia, officeBlockoutCalendars, plaid, DeliverableBoard, crossProjectPreds  from labs
|| 03/25/19  RLS 19.0.4.0 (443168) Added projectFiles > ShowThumbnails
|| 03/25/19  RLB 19.0.4.0 (441482) Added change request options for project and campaign dash boards on client login
|| 03/25/19  GWG 19.0.4.0 Adding in option to show todos on the client dash and a lab for planning projects
|| 03/26/19  MFT 19.0.4.0 (446667) Added Created By columns to approval screens
|| 03/29/19  RLB 19.0.4.0 (441482) Added change request to myNotifications
|| 04/03/19  AMP 19.0.5.0 (437595) Added Vendor Name to Expenses
|| 04/03/19  AMP 19.0.5.0 (448992) Added Locked Columns to Campaign Budget
|| 04/11/19  AMP 19.0.5.0 (454685) Added Tax Amount and Profit to Expenses
|| 04/17/19  AMP 19.0.5.0 (455566) Corrected Spelling 
|| 04/17/19  AMP 19.0.5.0 (454685) Removed Tax Amount and Profit from Expenses and added Vendor Name, Tax Amount and Profit to Billing Worksheet -> To Bill-> Transaction Settings 
|| 04/18/19  RLB 19.0.5.0 (456086) fixed spelling error
|| 04/22/19  RLB 19.0.5.0 (441482) Added back in change request approvals
|| 04/22/19  RLB 19.0.5.0 (441482) Added today pm unapproved change request
|| 04/23/19  RLS 19.0.5.0 (456491) Added projectRequestRejections and NotiShowRejected in myNotifications
|| 04/23/19  RLB 19.0.5.0 (441482) Added project dashboard change request section
|| 04/30/19  RLB 19.0.5.0 (454160) Added edit column sets to project templates 
|| 04/30/19  GAR 19.0.5.0 (455939) Added system setting for hiding sample image in deliverables dash
|| 05/01/19  MCM 19.0.5.0 (443518) Added Due Date to the todo board section
|| 05/02/19  AMP 19.0.6.0 (456405) Added ''My Tasks'' to the Today-> Media page
|| 05/02/19  GAR 19.0.5.0 (457457) Added AssignedFullName to System Settings for the schedule
|| 05/02/19  GAR 19.0.5.0 (458014) Added setting for Show/Hide Handoff Tasks button
|| 05/06/19  AMP 19.0.5.0 (458012) Added Voucher Description to the Select Invoices to Pay Screen
|| 05/06/19  AMP 19.0.5.0 (452434) Added Client Name column to the Estimates section of the Approval window
|| 05/05/19  GWG 19.0.5.0 Added Version number for specs in grid mode
|| 05/13/19  GHL 19.0.6.0 (434271) Added attachment count on the transaction project billing grid
|| 05/15/19  GWG 19.0.6.0 Removing the setting to view change requests. controlled by a right
|| 05/17/19  AMP 19.0.6.0 (460415) Added Show Client Project Number to Project Add
|| 05/21/19  RLS 19.0.6.0 (460733) Added NotiTimeUnsubmitted to myNotifications
|| 05/22/19  AMP 19.0.6.0 (460354) Added Date Created and Date Received to the Select Invoices to Pay Screen
|| 05/23/19  CRG 19.0.6.0 (460946) Added IncludePlanningProjects to Project Production Dash
|| 05/30/19  GHL 19.0.6.0 Added mediaPlanDetails grid for new media plans, corrected markup and unit cost 
|| 06/04/19  RLS 19.0.7.0 Added productionDashLastTaskDueDate
|| 06/06/19  AMP 19.0.7.0 (458184) Removed Variance from Projects - Connections
|| 06/10/19  AMP 19.0.7.0 (456900) Added Expense Reports, Purchase Orders, Insertion Orders and Broadcast Orders options to the Generate Billing Worksheets System Settings screen.
|| 06/10/19  AMP 19.0.7.0 (464149) Added the following columns to the Campaign Budget screen: Project Gross Remaining %,Project Hours Remaining %,Project Labor Gross Remaining %,Project Costs Gross Remaining %
|| 06/11/19  RLB 19.0.7.0 (446229) Readd of project manager columns etc....
|| 06/12/19  MCM 19.0.7.0 (464959) Added purchased from to the client Invoice expense
|| 06/13/19  RLB 19.0.7.0 (446229) Added project manager as option to today pm project feed
|| 06/13/19  GWG 19.0.7.0 Fix group by default on deliverables board.
|| 06/14/19  GAR 19.0.7.0 (466091) Added system setting for turning on/off daily feed in today.creative
|| 06/17/19  RLB 19.0.7.0 (446229) reverted this change. Just change account manager option to a or project manager
|| 06/20/19  AMP 19.0.7.0 (461523) Changed label for the attachment count on the transaction project billing grid 
|| 06/25/19  WDF 19.0.7.0 (467442) Fixed ''Hint'' for ''projectDashBoard''...''DashboardIncludeActivities''; Changed ''myTask'' SessionID for ''In/Out Board Options'' from ''H4'' to ''H5'' due to duplicate Key error
|| 07/02/19  GWG 19.0.7.0 Added different display options for deliverables
|| 07/03/19  RLB 19.0.8.0 removed client campaign change request option. it will be ruled by client rights
|| 07/11/19  AMP 19.0.8.0 (451506) Added Comments to Estimate Expense Settings
|| 07/17/19  AMP 19.0.8.0 (456195) Added System Settings for the Project Budget DrillDowns
|| 07/18/19  AMP 19.0.8.0 (470168) Changed ''Comments'' to ''Long Description'' on Broadcast Orders
|| 07/18/19  RLS 19.0.8.0 (468559) Added HideEnterTime on all the today pages
|| 07/22/19  RLS 19.0.8.0 (468559) Change order for timeline settings to make them consistant across the Today pages (related to above)
|| 07/29/19  AMP 19.0.8.0 (470117) Added the Cash Account Number, Cash Account Name, and Cash Account Full Name to CONNECTIONS - Payments (Vendor Payments)
|| 07/30/19  RLB 19.0.8.0 (471378) Added project manager options to today creative
|| 07/30/19  AMP 19.0.8.0 (471039) Added Custom Fields for Campaigns
|| 08/02/19  AMP 19.0.9.0 (457107) Added Line to the Estimate Edit Labor Drilldown and Estimate Expense Settings
|| 08/06/19  RLB 19.0.9.0 (460882) Added customized grid option to project Billing FF
|| 08/07/19  GHL 19.0.0.0 Added error message to media plan detail grid
|| 08/12/19  GAR 19.0.9.0 (473674) Added project manager to group by and sort by in projects dash
|| 08/19/19  CRG 19.0.9.0 (475151) Modified labels in productionDash
|| 08/23/19  GAR 19.0.9.0 (475355) In client portal project requests - change project number to client project number and add project number
|| 08/29/19  GAR 19.0.9.0 (476924) Added DeliverableID column to the Deliverables board
|| 09/05/19  RLB 19.0.9.0 (476641) Added Account Manager and Project Manager to TimeEntry
|| 09/05/19  MCM 19.0.9.0 (476550) Update description verbage for ExcludeVendors on the opportunitySettings
|| 09/13/19  GHL 19.1.0.0 (479305) Added UOM columns to grdExpenseEstimateCols
|| 09/17/19  GAR 19.1.0.0 (479571) Added Show On Schedule and Show On Estimate to the template grid
|| 09/20/19  GHL 19.1.0.0 Added Deleted column to media plam details
|| 09/20/19  AMP 19.1.0.0 (477552) Added Materials Sent, and Materials Sent Date on the IO and BO''s\\

|| 09/23/19  GAR 19.1.0.0 (480171) Added Project Type Color to My Projects Settings 
|| 09/23/19  GWG 19.1.0.0 (480783) Add tran pref to hide billing titles
|| 09/26/19  RLS 19.1.0.0 (458816) Added showDueComments to clientPortal
|| 10/03/19  RLB 19.1.0.0 (469418) Added LaborGrossAfterWriteOff, LaborGrossAfterWriteOffRemaining, CostsGrossAfterWriteOffRemaining wanted TotalGrossAfterWriteOff but it seems to be there already for campaignBudget
|| 10/07/19  RLS 19.1.1.0 (480740) Change CampaignName to CampaignFullName in myTasks
|| 10/07/19  GAR 19.1.1.0 (481547) Added Project Manager to Campaigns Settings
|| 10/08/19  AMP 19.1.0.0 (464052) Added ''Backup Approvals'' to the Notification Settings
|| 10/16/19  RLS 19.0.8.0 (469411) Added NotiShowTimers to myNotifications section
|| 10/17/19  RLB 19.1.1.0 (457226) Added My Superviser
|| 10/23/19  GAR 19.1.1.0 (484469) Added Estimate Profit column to My Projects Settings
|| 10/23/19  AMP 19.1.1.0 (465917) Add Expense GL Account to Expense Reports
|| 10/30/19  RLS 19.1.1.0 (485619) Add autoRunClients in myAddPeople
|| 10/30/19  AMP 19.1.1.0 (486067) Add Client ID and Client name columns to Billing Worksheet Approvals
|| 10/30/19  GWG 19.1.1.0 Added deliverable count (productionDashDeliverables)
|| 11/14/19  AMP 19.1.2.0 (487355) Addded Campaign Name on the Billing Worksheets
|| 11/15/19  AMP 19.1.2.0 (466117) Added Unit Description Field on the Misc Costs screen
|| 11/15/19  GAR 19.1.2.0 (488065) Client Portal System Settings - the campaign show spec sheets had the wrong DisplayOrder - changed from 3 to 30
|| 11/18/19  GAR 19.1.2.0 (487501) Adding Current Step to the deliverable approvals screen
|| 11/18/19  AMP 19.1.2.0 (479932) Label changes to standardize the labels for Orders between System Setup, and Add and Edit pages. 
|| 11/20/19  GHL 19.1.2.0 Added media plan detail history count
|| 11/22/19  RLB 19.1.2.0 (469047) added pred complete column to staff schedule day detail 
|| 11/22/19  RLB 19.1.2.0 (476758) Added option to copy time sheets to user time entry page
|| 12/02/19  RLS 19.1.2.0 (487506) Removed NotiShowTimers to myNotifications section
|| 12/4/19   GWG 19.1.2.0 Adding a conversation column for deliverables
|| 12/12/19  GAR 20.0.1.0 (469720) Moved the Hand Off Tasks setting from production assignment settings to creatives today settings
|| 12/17/19  RLB 20.0.1.0 (487336) removed client portal option to see all projects since a right will not control that
|| 12/30/19  RLB 20.0.1.0 (486087) Added hint to tile view on today creative
|| 01/02/20  MCM 20.0.1.0 (464614) Added show labor summary to the estimate edit
|| 01/02/20  AMP 20.0.1.0 (493508) Added Description to the GL Account Setup screen
|| 01/02/20  GHL 20.0.1.0 (493640) Changed the order/number of mediaPlanDetails columns after review by Dave Arnold
|| 01/02/20  MFT 20.0.2.0 (478136) Added ABA option for Autrailan electronic bank transfer payments
|| 01/17/20  AMP 20.0.2.0 (495297) Added settings for the Credit Card Connector - on the Unmatched Charges Panel
|| 01/20/20  RLS 20.0.2.0 (479118) Added CopyEstimates and CopyFiles in the projectAdd section
|| 01/30/20  AMP 20.0.3.0 (498114) Added setting in the Schedule screen of the Project to Show Burn Chart (enabled by default) 
|| 02/04/20  GAR 20.0.3.0 (498506) Added Status Name as a column option in the To Do board settings
|| 02/07/20  GAR 20.0.3.0 (499184) Added Open Deliverables Only flag to Creatives Today - My Task Options
|| 02/12/20  MCM 20.0.3.0 (467817) Added ShowExpenseReportItems to credit card connector in order to hide expense report items
|| 02/25/20  GAR 20.0.3.0 (503504) Added Task Complete Project Status to project template grid settings
|| 02/25/20  GAR 20.0.4.0 (500265) Added Show Assign a Followup Task Link right in deliverable reviews
|| 02/27/20  MCM 20.0.4.0 (469227) Added ability to group by client for the billingWorksheetsApprovals
|| 02/28/20  GWG 20.0.4.0  Changed deliverablesBoard to prompt to blow user settings
|| 03/06/20  GAR 20.0.4.0 (505536) Added Current Budget Quantity and Purchased Quantity fields to the Project Budget - By Type
|| 03/11/20  GAR 20.0.4.0 (472155) Added Client can Resend / Cancel an Approved Request to project request settings
|| 03/12/20  AMP 20.0.4.0 (504078) Added Write Off Reasons to Billing Transaction Settings
|| 03/13/20  GAR 20.0.4.0 (505771) Added sortByDueDate to the client portal settings
|| 03/18/20  GAR 20.0.4.0 (506143) Added project start date and project complete date to creatives today grid
|| 03/30/20  GAR 20.0.4.0 (502095) In the Schedule grid, rename the columns Original Start and Original Complete to Baseline Start and Baseline Complete
|| 03/31/20  RLS 20.0.4.0 (440975) Added Require Start Date / Due Date in the projectAdd section
|| 03/31/20  RLS 20.0.4.0 (440975) Added new section estimateAdd adn in it, Require Delivery Date
|| 04/08/20  GAR 20.0.4.0 (506720) Change system settings for new deliverable page to have to dos, time, and conversations hidden by default
|| 04/09/20  RLB 20.0.5.0 (508861) Added show project request views to client portal
|| 04/14/20  GAR 20.0.5.0 (510589) Added planning projects to system settings for global search
|| 04/14/20  MCM 20.0.5.0 (471784) Added Mass Billing "Include Overhead Clients" so can filter it out
|| 05/01/20  RLS 20.0.6.0 (505989) Added Hints to all the items in groupID globalSearch
|| 05/01/20  AMP 20.0.7.0 (477845) Added ''Show Spec Sheets'' and ''Show Attachments'' to IO''s and BO''s
|| 05/05/20  AMP 20.0.6.0 (513817) Added Description to Unposted Transactions
|| 05/06/20  RLB 20.0.6.0 (494017) added overworked assignments option to today pm
|| 05/11/20  RLS 20.0.6.0 (505989) Changed the verbiage of the hints for groupID globalSearch
|| 05/12/20  RLS 20.0.6.0 (513828) Added Show Next Steps on right and Show Status Notes on right to projectDashBoard
|| 05/13/20  RLB 20.0.6.0 (514574) Added system setting to campaign projects page
|| 05/14/20  MCM 20.0.6.0 (491375) Added client portal invoice options
|| 05/22/20  RLS 20.0.6.0 (516299) Added StartDateEndDateRequired to campaignAdd
|| 05/28/20  AMP 20.0.6.0 (514609) Added Budget column to the Billing Worksheets (Worksheets in Review)
|| 06/02/20  RLS 20.0.6.0 (517053) Added SortConversations to all of the Today pages
|| 06/04/20  AMP 20.0.7.0 (515624) Added Date Created 
|| 06/08/20  RLS 20.0.7.0 (515357) OptionName and SelectedOption to estimateList
|| 06/09/20  RLS 20.0.7.0 (517205) Added colDBoardSubject to the deliverablesBoard
|| 06/29/20  RLS 20.0.7.0 (518686) Added productionDashGLCompanySource to grdProductionDash
|| 06/30/20  AMP 20.0.8.0 (517117) Add Pay To Name field from check
|| 07/06/20  GHL 20.0.8.0 Added Order ID to mediaPlanDetails
|| 08/04/20  RLB 20.0.9.0 (479157) Added Show Estimates on Client Portal
|| 08/04/20  GAR 20.0.6.0 (517761) Added ShowProjectManager to campaignAdd
|| 08/19/20  GAR 20.0.9.0 (526380) Added Project Due Date to campaign settings
|| 08/28/20  RLS 20.0.9.0 (525634) Added prodCampDashDeliverables
|| 08/31/20  RLS 20.0.9.0 (525753) Added productionDashLastTimeEntry
|| 08/31/20  GAR 20.1.0.0 (526908) Added Key People to My Projects Settings 
|| 09/09/20  GAR 20.1.0.0 (528577) Added Use Conversations setting to project request settings
|| 09/14/20  RLS 20.1.0.0 (528009) Added prodCampDashOpportunityFullName
|| 10/01/20  WDF 20.1.1.0 (531698)  Added ''NoGrouping'' as a key to ''timeEntry''.
|| 10/05/20  RLB 20.1.1.0 (531647) removing options to remove first column on all project budget grids since it is needed
|| 10/08/20  GAR 20.1.1.0 (530355) Added project number as an available column in the Vendor Invoice Approvals and Rejections settings grids
|| 10/13/20  MCM 20.1.1.0 (524234) Added show all invoices waiting for approval - not just ones where I''m the approver
|| 10/13/20  GHL 20.1.1.0 (529464) Added FF campaign mass billing to Billing Today
|| 10/13/20  AMP 20.1.1.0 (498290) Added SubAccount Of to the GL Account Setup Screen
|| 10/21/20  GAR 20.1.1.0 (534408) Removed PProject Change Requests lab
|| 10/22/20  RLS 20.1.1.1 (530509) Added campaignFullNameName, productName, divisionName, projectBillingStatus, projectStatus to ''grdBillingWorksheetsCols''
|| 10/23/20  RLS 20.1.1.1 (532874) Added "To Do ID" to the coltodoBoard columns
|| 10/27/20  RLB 20.1.1.0 (534454) Added open deliverables
|| 10/29/20  GAR 20.1.2.0 (533018) Added Labor Hours, Budget Labor Hours, and Project Allocated Hours to the Campaigns Settings grid
|| 11/17/20  AMP 21.0.1.0 (534968) Added Department to the Client Invoice Line 
|| 11/23/20  RLS 21.1.2.0 (537478) Added Allocated Hours to the project template schedule (''projectTemplate'' section)
|| 12/07/20  RLB 21.0.1.0 (531678) Added current approver to scheduledTransactions
|| 12/08/20  GHL 21.0.1.0 (536860) Added forecast detail grid columns (+ proj type)
|| 12/11/20  RLS 20.0.1.0 (538620) Added prodCampDashLeadStageName and prodCampDashLeadStageName columns
|| 12/11/20  AMP 21.0.1.0 (538425) Added Vendor Name to the Project Budget Analysis Report - Outside Costs drilldown
|| 12/17/20  GAR 21.0.1.0 (538022) Added Checkbox to group / not group by date in expense reports
|| 01/04/21  GAR 21.0.2.0 (535624) Added custom fields to the client portal project request status listings
|| 01/15/21  RLS 21.0.2.0 (542067) Added services_AccessRestrictions to the Admin Screens - Service Setup section
|| 01/20/21  GAR 21.0.2.0 (543934) Added Labor Gross to campaigns settings
|| 01/21/21  AMP 21.03.14.0000 (544090) Added the Accrued Amount field to the Vendor Invoices screen for the lines
|| 01/28/21  GHL 21.03.14.0000 (526158) Added split orders on cc connector 
|| 02/08/21  MCM 21.03.14.0000 (546918) Fixed spelling with colDetailOrderDate in ioTraffic
|| 02/24/21  RLB 21.03.14 (545442) removed grouping option on Accrued Order Detail 
|| 03/02/21  AMP 21.05.16.0000(546279) Added # Remaining field for the Scheduled Transactions view
|| 03/03/21  RLB 21.04.18 (544932) Added Total Gross Unbilled to projects production dash
|| 03/05/21  RLB 21.04.18 (550876) Added display options for deliverable board for completed tasks and approved or completed delivrables
|| 03/18/21  RLB 21.04.18 (552161) Added Completed to deliverable board dash
|| 03/18/21  WDF 21.04.18 (551861) Added Item/Service to Task Detail Settings
|| 03/18/21  GHL 21.04.18 (547004) Added Vendor Currency to the estimate expenses
|| 03/19/21  GHL 21.04.18 (546926) Added Total Before % (id = fdetail_totalbefore) to forecast grid
|| 03/24/21  RLB 21.04.18 (549892) Added Hide Duplicate button to Deliverable Dash and removed timesheet option on del dash 2 moved to trans pref
|| 04/06/21  GHL 21.04.18 (554332) Changed Split Orders to Orders on cc connector
|| 04/16/21  RLB 21.05.16 (549134) Added shwo unread system messages to notifications
|| 04/27/21  GHL 21.05.16 (555670) Added setting to hide bank account balances in AP (HideBankAccountBalances)
|| 04/30/21  WDF 21.05.16 (557033) Replace the incorrect title for tAppSettingGroup of ''printItemsSetup''
|| 05/07/21  WDF 21.06.20 (555495) Added columns todoType and todoStatus to group productionAssignment
|| 05/12/21  GAR 21.06.20 (558461) Changed client legacy rights over to system settings (client_projectlist = showProjectList, client_assignments = showAssignments)
|| 06/02/21  GAR 21.07.18 (559051) Add a setting on the review round tab of the deliverable to show latest round first - deliverablesDash, showReverseOrder
|| 06/07/21  CRG 21.07.18 (544844) Added Default Culture to adminEmployees columns
|| 06/08/21  GAR 21.07.18 (559917) Added To Do due date to assignment to do grid - Assignment To Do Settings
|| 06/09/21  AMP 21.07.18.0000 (554517) Change label on Billing Transactions from Description to Vendor/Person, and Added column Transaction Comments
|| 06/15/21  WDF 21.07.18 (560349) Added coltodoBoardType to GroupID ''toDoBoard''
|| 06/17/21  RLB 21.07.18 (548863) Added Summary Task Name to traffic calendar
|| 06/23/21  AMP 21.07.18.0000 (549387) Added Expense Reports to the Global Search option
|| 06/24/21  AMP 21.07.18.0000 (562316) Added Publication/Station to System Settings to be displayed on the Vendor Invoice Lines for IO/BO''s  
|| 06/25/21  RLB 21.07.18 (560670) Added new common Timeline options
|| 07/01/21  RLB 21.08.15 (562793) Added new campaign schedule options
|| 07/19/21  RLS 21.08.15 (559791) Added to the ''myTasks'' section: group by TaskUserStatusName and column mytaskTaskUserStatusName
|| 07/19/22  GHL 21.08.15 (560579) Added Posted column to project billing grid
|| 08/04/21  MCM 21.09.19 (566562) Added CurrentTotalBudgetNoTax to prjbudgetSettings
|| 08/10/21  GHL 21.09.19 (567346) Added DashboardShowClosedBilling to project dashboard
|| 08/20/21  MCM 21.09.19 (564526) Added UnsubmittedOrders to purchasingToday
|| 08/26/21  MCM 21.09.19 (562437) Removed ''Print Selected Spec Sheets'' from ''projectDashBoard''
|| 08/27/21  MCM 21.09.19 (566456) Added HoursUnbilled to project budget columns
|| 08/31/21  RLS 21.09.19 (566254) Added productionDashAllocatedHours
|| 09/01/21  RLS 21.09.19 (565860) Added coltodoBoardTaskFullName
|| 09/02/21  GAR 21.10.17 (569710) Changed description for DashboardProfitabilitySR and DashboardSnapshotSR to remove ''on the right'' from the description
|| 09/07/21  GHL 21.10.17 (451878) Added commented out grids for 451878, uncomment out when we deploy 451878
||                        doing this because this sp changes constantly
|| 09/29/21  MCM 21.10.17 (571693) added ebitda to the glaccounts
|| 10/06/21  AMP 21.11.14 (573200) Added GLCompany to CONNECTIONS - Vendor Invoices
|| 10/14/21  RLB 21.11.14 (568263) Adding project manager and campaign CF''s to campaign dash board connections
|| 10/19/21  GHL 21.11.14 (572385) Added ApproverIsAM for billing worksheets
|| 10/20/21  AMP 21.12.19 (574400) Added ''active'' column to the Admin Screens - Company Type
|| 10/20/21  RLS 21.12.19 (568009) Added VendorID and VendorFullName to the grid cols in the prjbudgetEstimates section and VendorFullName to the prjbudgetGeneral section
|| 10/14/21  RLB 21.11.21 (568263A) Adding account manager dash board connections
|| 11/22/21  MCM 21.12.x  (578053) Added campBudgetLaborHoursWriteOff
|| 12/14/21  GHL 22.12.00 (574154) Added payvouch1099 for col Exclude From 1099 when paying vouchers
|| 12/17/21  RLB 22.01.16 (578277) Added new grouping field ParentClientName from project client on productionDash
|| 12/21/21  GHL 22.01.16 (564964) Added ProjectFullName for VI approvals
|| 12/21/21  AMP 22.01.16 (577578) Added System Settings for Advance Billings 
|| 01/03/22  AMP 22.02.20 (582124) Added ''Contact'' to the Connections-> Invoices
|| 01/19/22  GHL 22.02.00 (583350) Added Addable transactions to billing worksheets to review
|| 02/02/22  RLS 22.02.20 (582600) Added timeZoneDisplay to grdEmployeeCols
|| 02/03/22  AMP xx.xx.xx (DEV2506-486) Changed ''ToDos'' to ''Issues'' on the Deliverables Dash
|| 02/08/22  AMP 22.03.20 (583455) Added Station Contact to the Station Connections listing
|| 02/10/22  AMP xx.xx.xx (DEV2506-486) Reverted Previous Change on the Deliverables Dash from ''Issues'' back to ''ToDos''
|| 02/15/22  RLS 22.03.20 (585537) Added IAmAM and IAmPM to the productionDash section
|| 02/15/22  WDF 22.03.20 (586670) Added ''productionDashPlanning''
|| 02/16/22  MCM 22.03.20 (582548) added CampaignID to grdFinancialGLDDResults
|| 02/17/22  AMP 22.03.20 (586206) Added ''Cleared'' to the CONNECTIONS - Payments
|| 02/17/22  AMP 22.03.20 (583455) Added Publication Contact to the Publication Connections listing
|| 02/18/22  WDF 22.03.20 (589015) Added fields to ''productionDashPlanning''
|| 02/21/22  WDF 22.03.20 (588477) Added ''ScheduleLockedColumns'' to ''campaignBudgetDetail''
|| 02/21/22  RLB 22.03.20 (587756) Aadded planned project name, number and full name to productionDashPlanning
|| 02/24/22  GHL 22.03.20 (589427) Removed Open To Dos from planning projects because todos are not used with PPs 
|| 02/24/22  AMP 22.03.20 (588429) Added Project Manger to the Forecast Detail Grid
|| 03/04/22  GHL 22.04.20 (589782) Added Created By to Post Transactions page
|| 04/14/22  AMP 22.04.17 (589401) Added Stations and Publications to the Global Search
|| 04/15/22  AMP 22.04.17 (587510) Added VendorID, VendorName, VendorFullName for the drill down cost fields on the Project Budget Analysis Report
|| 03/21/22  CRG 22.04.17 (588480) Added DisableDragDrop to trafficRM
|| 03/28/22  GHL 22.04.17 (451878) Added variable @GLCompaniesWithForeignCurrencies to use for GL companies using foreign currencies
||                         Change value to 1 when 451878 goes live 
|| 04/12/22  GAR 22.05.15 (592290) Added sort by project task due date setting in client portal / project details
|| 04/12/22  RLB 22.05.15 (587411) change labor for option to filter completed on deliverablesBoard
|| 04/18/22  WDF 22.05.15 (591615) change ProjectStatus and ProjectBillingStatus to SelectList on productionDash
|| 04/18/22  CRG 22.05.15 (565772) Added DefaultTrackBudget to projectSchedule
|| 04/18/22  WDF 22.05.15 (595682) Added hideCompletePct to clientPortal
|| 05/09/22  WDF 22.05.15 (595682B) Change hideCompletePct to showCompletePct in clientPortal
|| 05/13/22  RLB 22.06.19 (590887) Added to do board setting for hiding Client, project etc.. and added type to grouping and sorting options
|| 05/24/22  RLS 22.06.19 (596984) Added productionDashRemainingLaborBudget and productionDashRemainingExpenseBudget. Also fixed a typo in Current Budget Expense Gross in productionDash and in productionDashPlanning
|| 05/23/22  RLB 22.06.19 (599630) added fields for new multirow update
|| 06/15/22  RLB 22.07.17 (595567) Added tracking forms options to myNotifications
|| 06/21/22  RLB 22.07.17 (599080) Added staff schedule week detail 
|| 06/27/22  WDF 22.07.17 (603776) Added KeyPeople to ''myTasks'' group
|| 07/05/22  GAR 22.07.17 (598563) Added CustomerID, CompanyName, CampaignID, and CampaignName to ioTraffic and boTraffic grids
|| 07/07/22  AMP 22.07.24 (604434) Added Retainer Name to Production Dash
|| 07/11/22  GAR 22.08.14 (600901) Added forecast detail grid column project end date
|| 07/12/22  RLS 22.08.14 (604984) Added showProjectTrackingForms to the projectDashBoard section
|| 07/27/22  GHL 22.08.14 (451878) Setting now @GLCompaniesWithForeignCurrencies = 1 to display info on GL companies diff currency
|| 08/04/22  AMP 22.09.18 (606737) Added Billing Method to the Production Dash
|| 08/18/22  GAR 22.09.18 (609310) Added approver name as an available column in the Vendor Invoice Approvals grid
|| 09/02/22  RLB 22.09.18 (608687,608688) Added to option on deliverable review page
|| 09/19/22  RLS 22.10.16 (610385) Added totalPauseHours to TimesheetApprovals, TimesheetRejections and TimesheetUnsubmitted
|| 09/19/22  RLS 22.10.16 (612766) Added timesheetUnsubmitted
|| 09/20/22  GAR 22.10.16 (DEV2605) Added services_AvalaraTaxCode to the Admin Screens - Service Setup section
|| 09/21/22  RLB 22.10.16 (608687) changed label
|| 09/21/22  GAR 22.10.16 (DEV2605) Added avalaraTaxCode to the Admin Screens - Billing Item Setup section
|| 09/21/22  GAR 22.10.16 (DEV2605) Added avalaraTaxCode to the Admin Screens - Project Type Setup section
|| 10/24/22  AMP 22.12.18 (610063)  Added Materials Sent and Materials Sent Date to the Broadcast(boTraffic) and Print(ioTraffic)
|| 10/25/22  GAR 22.12.18 (616959)  Added Budget Amount to Worksheets to Approve (billingToday_7)
|| 11/09/22  GAR 22.12.18 (618114)  Added Conversations Count to Project Schedule
|| 11/14/22  RLB 22.12.18 (618115)  maybe project type into a select list on myTasks
|| 11/30/22  RLS 22.12.18 (618630)  Added InternalApprovalDate field to the estimateList section
|| 12/05/22  AMP 23.01.15 (618868)  Added Total with Tax to Vendor Invoices
|| 12/08/22  GAR 23.01.15 (622519)  Added Campaign Edit seetting - to prevent Campaign ID from being edited
|| 12/19/22  RLB 23.01.15 (623076) added ProjectToBillRemainingNoTax and ProjectToBillRemainingWithTax to campaignBudget
|| 01/10/23  GAR 23.02.19 (DEV2605) Added avalaraTaxCode to the Admin Screens - Broadcast Items Setup, Print and Digital Items, Purchase Items Setup, Expense Report Items sections
|| 01/11/23  RLS 23.02.19 (622336)  Added ActiveEstimates and InactiveEstimates to globalsearch
|| 01/11/23  GAR 22.02.19 (624263)  Added ApprovedTotal to Estimate List Settings
|| 01/19/23  MCM 22.02.19 (612387)  Added InvoiceOpenAmount to Accrued Order Settings
|| 01/25/23  RLS 23.02.19 (626814)  Added ACH Enabled to payvouchers
|| 03/10/23  RLB 23.04.16 (629165)  added service color to serviceSetup
|| 03/15/23  RLS 23.04.16 (628601)  Added StartDate and EndDate to the connectionsCampaigns section
|| 11/14/22  RLB 23.04.16 (632084)  added timeline segment to mytask
|| 03/23/23  MCM 23.04.16 (630378)  Added journal entry approval items
|| 03/29/23  RLS 23.04.16 (631456)  Added campBudgetGetLaborRateFrom
|| 04/03/23  RLB 23.05.14 (633964)  Added Produce Name to productionDash, productionDashPlanning and myTasks
|| 04/05/22  MAS 23.05.14 (629790)  Added Credit Card Connector Comment
|| 04/05/23  AMP 23.05.14 (631585)  Corrected the order under Today Purchasing -> My Open Items Only will be displayed under Open Items
|| 04/03/23  RLB 23.05.14 (632548)  adding traffic comment to staffScheduleWeekDetail and staffScheduleDayDetail
|| 04/12/23  GAR 23.05.14 (631174)  Added Show Contingency to the Estimate Edit Settings.
|| 04/17/23  RLB 23.05.14 (632486)  Added add project to dos to clientPortal
|| 04/19/23  RLB 23.05.14 (633165)  Added added options for  Open To Do Items Only and Open Deliverables Only to Traffic RM
|| 04/19/23  RLS 23.05.14 (631259)  Added campBudgetProjectHoursAfterWriteoff
|| 05/12/23  AMP 23.06.18 (632148)  Added ''Days Out From Today'' to Today Media -> Orders Needing Attention
|| 05/26/23  CRG 23.06.18 (622919)  Added ''No Time Entry'' column to the projectSchedule grid
|| 06/02/23  RLS 23.07.16 (634668)  Added ProjectStatus to the campign budget section
|| 06/07/23  AMP 23.08.20 (633543)  Added Scheduled to Misc Costs section
|| 06/27/23  RLB 23.07.16 (631684)  Added Show other sales person option on salesDashboard
|| 06/29/23  AMP 23.09.17 (637168)  Added Detail Date Range to the Accrued Order Detail section
|| 06/30/23  AMP 23.07.23 (644091)  Added GL Company to Production Dash 
|| 07/10/23  AMP 23.08.20 (636196)  Added Marked as Billed Expenses and Marked as Billed Labor to Billing Today
|| 07/10/23  AMP 24.01.14 (644720)  Added Posting Date to the Approvals -> Credit Card Approval
|| 07/12/23  RLS 23.08.20 (644618)  Added PlanningProjectName to productionDash
|| 07/14/23  AMP 23.09.17 (637239)  Added Total Budget to the Forecast Details Settings
|| 08/01/23  AMP 23.09.17 (635756)  Added Markup to the Credit Card Connector
|| 08/22/23  CRG 23.09.17 (641607)  Added ShowPlanningProject to Add Project Settings
|| 08/25/23  RLB 23.09.17 (649026)  Added CampaignBudgetHoursRemainingP and CampaignBudgetRemainingP on campaignBudget removed and changed
|| 09/05/23  RLB 23.10.15 (649724)  Added project Type to productionCampProjects
|| 09/06/23  AMP 23.10.15 (650736)  Added Descripiton to the Unapproved Transactions
|| 09/15/23  AMP 23.10.15 (635756)  Added the More menu for the display options to the Split Projects Panel on the Credit Card Connector
|| 09/21/23  MCM 23.10.15 (651682)  removing CampaignBudgetHoursRemainingP and CampaignBudgetRemainingP on campaignBudget since they''re not sure about 649026
|| 09/27/23  RLS 23.10.15 (650572)  Added mytaskNextSteps to the My Tasks section
|| 09/27/23  RLB 23.10.15 (651884)  Added project column to trafficCalendar and project, Summary task and Segment to campaignSchedule
|| 09/29/23  AMP 23.10.15 (631719)  Added the ability to modify the custom fields on the IO and BO traffic screens in the grid
|| 10/02/23  MCM 23.10.15 (628804)  Added FastPay and Coupa to the Print Checks Payment Types
|| 10/04/23  CRG 23.11.19 (647340)  Added Must Finish On when Pred Complete to Project Schedule grid
|| 10/18/23  RLB 23.09.17 (649026)  Added campBudgetGrossRemainingCP and campBudgetHoursRemainingCP on campaignBudget
|| 10/20/23  RLS 23.11.19 (650272)  Added campBudgetCampaignBudgetUnbilledProjectRemaining to campaignBudget
|| 10/27/23  AMP 23.12.17 (651259)  Added Charge Reference to the Credit Card Connector
|| 11/08/23  AMP 23.12.17 (648523)  Added Billing Manager to the Generate Billing Worksheets
|| 12/06/23  CRG 24.01.14 (658230)  Changed label for prjScheduleNoTimeEntry
|| 12/18/23  RLB 24.01.14 (656836)  added conversation filter to today pages Only show Project Conversations sent to me that have the project tab
|| 12/21/23  AMP 24.01.21 (657972)  Added Project Status to the Forecast Detail Grid
*/
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[vProjectCosts]'
GO
IF OBJECT_ID(N'[dbo].[vProjectCosts]', 'V') IS NOT NULL
EXEC sp_executesql N'


/*
  || When     Who Rel     What
  || 05/23/07 GHL 8.422  Added rounding of PO TotalCost to fix rounding errors in reports. Bug 9306
  || 07/09/07 GHL 8.5    Added restriction of ER where VoucherDetailKey is null
  || 07/10/07 QMD 8.5    Expense Type reference changed to tItem
  || 02/01/08 GHL 8.5   (20123)  Removed restriction of ER where VoucherDetailKey is nul
  ||                     Added LinkVoucherDetailKey
  || 02/19/08 GHL 8.5    Added rtrim(EnvelopeNumber) to look better on reports
  || 02/19/08 GHL 8.5    (21165) Added Expense receipt info for VI in Comments section now
  || 04/10/08 GHL 8.508  (24671) Changed join type between tItem and tExpenseReceipt (case no item)
  || 10/15/08 GHL 10.010 (36763) Corrected BillableCost for IO/BO to account for po.BillAt
  || 08/27/09 GHL 10.5   Added Transfer logic
  || 01/12/11 GHL 10.540 (99925) Added hint on tTime to use IX_tTime_8 because transactions.aspx on APP2
  ||                     causes tTime table scan. Also added TransferToKey to IX_tTime_8
  || 07/28/11 GHL 10.546 (117156) Added TransferInDate to help out with debugging
  || 04/26/13 GHL 10.567 Placed Nolock hints when querying tInvoice/tInvoiceLine
  || 05/15/13 GWG 10.568 Fixed display w a null last name
  || 10/08/13 GHL 10.573 Using now Net = PTotalCost for multi currency 
  || 12/05/13 RLB 10.575 (197891) Added SummaryTaskKey for new billing transactions screen
  || 11/06/14 GAR 10.586 (235409) Fixed formatting issues on the description lines for vouchers.  Instead of 
  ||					 having a ? as a placeholder, we will just not show anything.
  || 02/26/16 WDF 10.601 (291046) Added PurchasedByName for ''Voucher/Vendor Invoice'' Credit Card
  || 06/13/16 GHL 10.605 (296534) TransactionDate = tVoucher.InvoiceDate not tExpenseReceipt.ExpenseDate
  ||                      for vouchers linked to expense receipts
  || 07/19/16 GHL 10.606 (306695) labor net = ActualHours * CostRate instead of ActualHours * ActualRate
  ||                      Added additional field TotalCostNet  
  || 08/15/16 GHL 10.607  Added WriteOffComment and WriteOffReason for MN''s todo
  || 07/02/18 GHL 18.700  Added default Transaction Date for orders if POKind >2
  || 07/30/18 MCM 18.800 (410969) Added Purchased from to the credit card transactions
  || 11/08/18 GHL 18.930  Added Exchange Rate to convert to home currency (initially for budget warning)
  || 11/27/19 AMP 20.0.2.0 (467276) Added ''-'' between Task ID and Task Name
  || 09/02/20 RLB 20.1.0.0 (523772) making anything using user name common format 
  || 02/28/22 RLS 22.03.20 (523772) Added data type specifier (N) to string literals
  || 06/06/22 GHL 22.05.00 (598186) Use isnull(er.Description, '''') instead of er.Description to avoid null descriptions 
  || 01/16/24 AMP 24.02.18 (658372) Change the Project > Billing screen so that the CC charges are listed as Credit Card Charges to 
  ||                                stay consistent with the Billing Worksheets
  || 03/16/26 AMP 26.05.17 (723587) Added the Purchased By to the Credit Card Charge Description field
  || 06/02/26 GAR 26.07.19 (728742) Adding PostingDate to unbilled charges on the project billing screen
  */


ALTER VIEW [dbo].[vProjectCosts]

as
Select
	N''LABOR'' as Type
	,N''Labor'' as TypeName
	,ts.CompanyKey
	,Cast(t.TimeKey as varchar(200)) as TranKey
	,t.ProjectKey
	,t.TaskKey
	,t.TransferInDate
	,t.DateBilled
	,ta.TaskID as TaskID
	,ta.TaskName
	,ta.TaskID + '' - '' + ta.TaskName as TaskFullName
	,ta.SummaryTaskKey
	,s.ServiceCode as ItemID
	,s.Description as ItemName
	,s.ServiceCode + '' - '' + s.Description as ItemFullName
	,s.ServiceKey as ItemKey
	,ActualHours as Quantity
	,ActualRate as UnitCost
	,ROUND(ActualHours * CostRate, 2) as TotalCostNet
	,ROUND(ActualHours * ActualRate, 2) as TotalCost
	,ROUND(ActualHours * ActualRate, 2) as BillableCost
	,ISNULL(ROUND(BilledHours * BilledRate, 2), 0) as AmountBilled
	,LTRIM(RTRIM(ISNULL(u.FirstName + '' '','''')  + ISNULL(u.LastName,''''))) AS Description
	,ta.TaskName as Description2
	,LTRIM(RTRIM(ISNULL(u.FirstName + '' '','''')  + ISNULL(u.LastName,''''))) AS PersonItem
	,WorkDate as TransactionDate
	,WorkDate as TransactionDate2
	,InvoiceLineKey
	,Case When ISNULL(t.InvoiceLineKey, 0) = 0 then NULL
		else
			(Select rtrim(ltrim(InvoiceNumber))
				from tInvoice (nolock) 
				inner join tInvoiceLine (nolock) on tInvoice.InvoiceKey = tInvoiceLine.InvoiceKey 
				Where InvoiceLineKey = t.InvoiceLineKey) 
		end as BillingInvoiceNumber
	,Case ts.Status When 4 then
		Case
		When WriteOff = 1 Then ''Writeoff''
		When WriteOff = 0 and InvoiceLineKey >= 0 then ''Billed''
		When WriteOff = 0 and InvoiceLineKey is null then ''UnBilled''
		END 
	Else
		''Unapproved'' END as BillingStatus
	,WIPPostingInKey
	,WIPPostingOutKey
	,t.WriteOff as WriteOff
	,t.WriteOffComment as WriteOffComment
	,case when t.WriteOff = 1 then isnull(wor.ReasonName, ''No Reason'') else null end as WriteOffReasonName
	,ts.Status as Status
	,t.TransferComment
	,t.Comments
	,t.Comments AS TransactionComments
	,ISNULL(t.OnHold, 0) AS OnHold
    ,NULL as LinkVoucherDetailKey
    ,NULL AS [PurchasedByName]
	,t.ExchangeRate
	,NULL As PostingDate
from 
	tTime t with (index=IX_tTime_8, nolock)
	inner join tTimeSheet ts (nolock) on t.TimeSheetKey = ts.TimeSheetKey
	inner join tUser u (nolock) on t.UserKey = u.UserKey
	left outer join tTask ta (nolock) on t.TaskKey = ta.TaskKey
	left outer join tService s (nolock) on t.ServiceKey = s.ServiceKey
	left outer join tWriteOffReason wor (nolock) on t.WriteOffReasonKey = wor.WriteOffReasonKey 
where t.TransferToKey is null

Union ALL

Select
	N''EXPRPT'' as Type
	,N''Expense Report'' as TypeName
	,ee.CompanyKey
	,Cast(er.ExpenseReceiptKey as varchar(200)) as TranKey
	,er.ProjectKey
	,er.TaskKey
	,er.TransferInDate
	,er.DateBilled
	,ta.TaskID as TaskID
	,ta.TaskName
	,ta.TaskID + '' - '' + ta.TaskName as TaskFullName
	,ta.SummaryTaskKey
	,i.ItemID
	,i.ItemName
	,i.ItemID + '' - '' + i.ItemName as ItemFullName
	,i.ItemKey
	,er.ActualQty as Quantity
	,er.ActualUnitCost as UnitCost
	,er.PTotalCost as TotalCostNet
	,er.PTotalCost as TotalCost
	,er.BillableCost as BillableCost
	,ISNULL(er.AmountBilled,0)
	,''Person: '' + LTRIM(RTRIM(ISNULL(u.FirstName + '' '','''')  + ISNULL(u.LastName,'''')))  + '' Report: '' + rtrim(ee.EnvelopeNumber) + '' '' + isnull(er.Description,'''')  as Description
	,er.Description as Description2
	,i.ItemName as PersonItem
	,er.ExpenseDate as TransactionDate
	,er.ExpenseDate as TransactionDate2
	,er.InvoiceLineKey
	,Case When ISNULL(er.InvoiceLineKey, 0) = 0 then NULL
		else
			(Select rtrim(ltrim(InvoiceNumber)) 
				from tInvoice (nolock) 
				inner join tInvoiceLine (nolock) on tInvoice.InvoiceKey = tInvoiceLine.InvoiceKey 
				Where InvoiceLineKey = er.InvoiceLineKey) 
		end as BillingInvoiceNumber	
	,Case ee.Status When 4 then Case
		When WriteOff = 1 Then ''Writeoff''
		When WriteOff = 0 and InvoiceLineKey >= 0 then ''Billed''
		When WriteOff = 0 and InvoiceLineKey is null then ''UnBilled''
		END Else ''Unapproved'' END as BillingStatus
	,WIPPostingInKey
	,WIPPostingOutKey
	,er.WriteOff as WriteOff
	,er.WriteOffComment as WriteOffComment
	,case when er.WriteOff = 1 then isnull(wor.ReasonName, ''No Reason'') else null end as WriteOffReasonName
	,ee.Status as Status
	,er.TransferComment
	,NULL AS Comments
	,er.Comments AS TransactionComments
	,ISNULL(er.OnHold, 0) 
	,er.VoucherDetailKey as LinkVoucherDetailKey
    ,NULL AS [PurchasedByName]
	,ee.ExchangeRate
	,NULL As PostingDate
from
	tExpenseReceipt er (nolock)
	inner join tExpenseEnvelope ee (nolock) on ee.ExpenseEnvelopeKey = er.ExpenseEnvelopeKey
	inner join tUser u (nolock) on ee.UserKey = u.UserKey
	left outer join tTask ta (nolock) on er.TaskKey = ta.TaskKey
	left outer join tItem i (nolock) on er.ItemKey = i.ItemKey
	left outer join tWriteOffReason wor (nolock) on er.WriteOffReasonKey = wor.WriteOffReasonKey
where er.TransferToKey is null

Union ALL

Select
	N''MISCCOST'' as Type
	,N''Misc Cost'' as TypeName
	,p.CompanyKey
	,Cast(mc.MiscCostKey as varchar(200)) as TranKey
	,mc.ProjectKey
	,mc.TaskKey
	,mc.TransferInDate
	,mc.DateBilled
	,ta.TaskID as TaskID
	,ta.TaskName
	,ta.TaskID + '' - '' + ta.TaskName as TaskFullName
	,ta.SummaryTaskKey
	,i.ItemID
	,i.ItemName
	,i.ItemID + '' - '' + i.ItemName as ItemFullName
	,i.ItemKey
	,mc.Quantity
	,mc.UnitCost
	,mc.TotalCost as TotalCostNet
	,mc.TotalCost
	,mc.BillableCost
	,ISNULL(mc.AmountBilled,0)
	,mc.ShortDescription as Description
	,mc.ShortDescription as Description2
	,i.ItemName as PersonItem
	,mc.ExpenseDate as TransactionDate
	,mc.ExpenseDate as TransactionDate2
	,mc.InvoiceLineKey
	,Case When ISNULL(mc.InvoiceLineKey, 0) = 0 then NULL
		else
			(Select rtrim(ltrim(InvoiceNumber)) 
				from tInvoice (nolock) 
				inner join tInvoiceLine (nolock) on tInvoice.InvoiceKey = tInvoiceLine.InvoiceKey 
				Where InvoiceLineKey = mc.InvoiceLineKey) 
		end as BillingInvoiceNumber
	,Case
		When WriteOff = 1 Then ''Writeoff''
		When WriteOff = 0 and InvoiceLineKey >= 0 then ''Billed''
		When WriteOff = 0 and InvoiceLineKey is null then ''UnBilled''
		END as BillingStatus
	,WIPPostingInKey
	,WIPPostingOutKey
	,mc.WriteOff as WriteOff
	,mc.WriteOffComment as WriteOffComment
	,case when mc.WriteOff = 1 then isnull(wor.ReasonName, ''No Reason'') else null end as WriteOffReasonName
	,4 as Status
	,mc.TransferComment
	,NULL AS Comments
	,mc.LongDescription AS TransactionComments
	,ISNULL(mc.OnHold, 0) 
    ,NULL as LinkVoucherDetailKey
    ,NULL AS [PurchasedByName]
	,mc.ExchangeRate
	,NULL As PostingDate
from
	tMiscCost mc (nolock)
	inner join tProject p (nolock) on mc.ProjectKey = p.ProjectKey
	left outer join tTask ta (nolock) on mc.TaskKey = ta.TaskKey
	left outer join tItem i (nolock) on mc.ItemKey = i.ItemKey
	left outer join tWriteOffReason wor (nolock) on mc.WriteOffReasonKey = wor.WriteOffReasonKey
where mc.TransferToKey is null

Union ALL

Select
	N''VOUCHER'' as Type
	,N''Vendor Invoice'' as TypeName
	,v.CompanyKey
	,Cast(vd.VoucherDetailKey as varchar(200)) as TranKey
	,vd.ProjectKey
	,vd.TaskKey
	,vd.TransferInDate
	,vd.DateBilled
	,ta.TaskID as TaskID
	,ta.TaskName
	,ta.TaskID + '' - '' + ta.TaskName as TaskFullName
	,ta.SummaryTaskKey
	,i.ItemID
	,i.ItemName
	,i.ItemID + '' - '' + i.ItemName as ItemFullName
	,i.ItemKey
	,vd.Quantity
	,vd.UnitCost
	,vd.PTotalCost as TotalCostNet
	,vd.PTotalCost as TotalCost
	,vd.BillableCost
	,ISNULL(vd.AmountBilled,0)	
	,ISNULL(''VendorID: '' + c.VendorID, '''') + ISNULL('' - '' + c.CompanyName + ''; '', '''') + ISNULL(''Invoice: '' + v.InvoiceNumber + ''; '', '''') + ISNULL(vd.ShortDescription, '''') as Description	
	,ISNULL(''VendorID: '' + c.VendorID, '''') + ISNULL('' - '' + c.CompanyName + ''; '', '''') + ISNULL(''Invoice: '' + v.InvoiceNumber + ''; '', '''') + ISNULL(vd.ShortDescription, '''') as Description2
	,i.ItemName as PersonItem
	,v.InvoiceDate as TransactionDate
	,v.InvoiceDate as TransactionDate2
	,vd.InvoiceLineKey
	,Case When ISNULL(vd.InvoiceLineKey, 0) = 0 then NULL
		else
			(Select rtrim(ltrim(InvoiceNumber)) 
				from tInvoice (nolock) 
				inner join tInvoiceLine (nolock) on tInvoice.InvoiceKey = tInvoiceLine.InvoiceKey 
				Where InvoiceLineKey = vd.InvoiceLineKey) 
		end as BillingInvoiceNumber
	,Case v.Status When 4 Then Case
		When vd.WriteOff = 1 Then ''Writeoff''
		When vd.WriteOff = 0 and vd.InvoiceLineKey >= 0 then ''Billed''
		When vd.WriteOff = 0 and vd.InvoiceLineKey is null then ''UnBilled''
		END ELSE ''Unapproved'' END as BillingStatus
	,vd.WIPPostingInKey
	,vd.WIPPostingOutKey
	,vd.WriteOff as WriteOff
	,vd.WriteOffComment as WriteOffComment
	,case when vd.WriteOff = 1 then isnull(wor.ReasonName, ''No Reason'') else null end as WriteOffReasonName
	,v.Status as Status
	,vd.TransferComment
	,CASE WHEN er.ExpenseReceiptKey IS NULL THEN NULL
	ELSE	'' -- Converted from expense receipt -- Person: '' + LTRIM(RTRIM(ISNULL(u.FirstName + '' '','''')  + ISNULL(u.LastName,'''')))  + '' Report: '' + rtrim(ee.EnvelopeNumber) + '' '' + er.Description
	END AS Comments
	,vd.ShortDescription AS TransactionComments
	,ISNULL(vd.OnHold, 0) 
    ,NULL as LinkVoucherDetailKey
    ,Case v.CreditCard
       WHEN 1 THEN u2.FirstName + '' '' + u2.LastName
       ELSE NULL  
     END AS [PurchasedByName]
	,v.ExchangeRate
	,v.PostingDate As PostingDate
from
	tVoucherDetail vd (nolock)
	inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey
	inner join tCompany c (nolock) on v.VendorKey = c.CompanyKey
	left outer join tTask ta (nolock) on vd.TaskKey = ta.TaskKey
	left outer join tItem i (nolock) on vd.ItemKey = i.ItemKey
	left outer join tExpenseReceipt er (nolock) on vd.VoucherDetailKey = er.VoucherDetailKey
	left outer join tExpenseEnvelope ee (nolock) on er.ExpenseEnvelopeKey = ee.ExpenseEnvelopeKey
	left outer join tUser u (nolock) on ee.UserKey = u.UserKey
	left outer join tUser u2 (nolock) on v.BoughtByKey = u2.UserKey
	left outer join tWriteOffReason wor (nolock) on vd.WriteOffReasonKey = wor.WriteOffReasonKey
where vd.TransferToKey is null
and v.CreditCard = 0

Union ALL

Select
	N''CREDIT CARD CHARGE'' as Type
	,N''Credit Card Charge'' as TypeName
	,v.CompanyKey
	,Cast(vd.VoucherDetailKey as varchar(200)) as TranKey
	,vd.ProjectKey
	,vd.TaskKey
	,vd.TransferInDate
	,vd.DateBilled
	,ta.TaskID as TaskID
	,ta.TaskName
	,ta.TaskID + '' - '' + ta.TaskName as TaskFullName
	,ta.SummaryTaskKey
	,i.ItemID
	,i.ItemName
	,i.ItemID + '' - '' + i.ItemName as ItemFullName
	,i.ItemKey
	,vd.Quantity
	,vd.UnitCost
	,vd.PTotalCost as TotalCostNet
	,vd.PTotalCost as TotalCost
	,vd.BillableCost
	,ISNULL(vd.AmountBilled,0)	
    ,ISNULL(''Credit Card Charge: '' + c.VendorID, '''') + ISNULL('' - '' + c.CompanyName + ''; '', '''') 
	+ ISNULL(''Purchased From: '' + v.BoughtFrom + ''; '', '''') 
	+ ISNULL(''Purchased By: '' + u2.FirstName + '' '' + u2.LastName + ''; '', '''') 
	+ ISNULL(''Invoice: '' + v.InvoiceNumber + ''; '', '''') 
	+ ISNULL(vd.ShortDescription, '''') 
	As Description	
	,ISNULL(''Credit Card Charge: '' + c.VendorID, '''') 
	+ ISNULL('' - '' + c.CompanyName + ''; '', '''') 
	+ ISNULL(''Purchased From: '' + v.BoughtFrom + ''; '', '''')
	+ ISNULL(''Purchased By: '' + u2.FirstName + '' '' + u2.LastName + ''; '', '''') 
	+ ISNULL(''Invoice: '' + v.InvoiceNumber + ''; '', '''')
	+ ISNULL(vd.ShortDescription, '''') 
	As Description2
	,i.ItemName as PersonItem
	,v.InvoiceDate as TransactionDate
	,v.InvoiceDate as TransactionDate2
	,vd.InvoiceLineKey
	,Case When ISNULL(vd.InvoiceLineKey, 0) = 0 then NULL
		else
			(Select rtrim(ltrim(InvoiceNumber)) 
				from tInvoice (nolock) 
				inner join tInvoiceLine (nolock) on tInvoice.InvoiceKey = tInvoiceLine.InvoiceKey 
				Where InvoiceLineKey = vd.InvoiceLineKey) 
		end as BillingInvoiceNumber
	,Case v.Status When 4 Then Case
		When vd.WriteOff = 1 Then ''Writeoff''
		When vd.WriteOff = 0 and vd.InvoiceLineKey >= 0 then ''Billed''
		When vd.WriteOff = 0 and vd.InvoiceLineKey is null then ''UnBilled''
		END ELSE ''Unapproved'' END as BillingStatus
	,vd.WIPPostingInKey
	,vd.WIPPostingOutKey
	,vd.WriteOff as WriteOff
	,vd.WriteOffComment as WriteOffComment
	,case when vd.WriteOff = 1 then isnull(wor.ReasonName, ''No Reason'') else null end as WriteOffReasonName
	,v.Status as Status
	,vd.TransferComment
	,CASE WHEN er.ExpenseReceiptKey IS NULL THEN NULL
	ELSE	'' -- Converted from expense receipt -- Person: '' + LTRIM(RTRIM(ISNULL(u.FirstName + '' '','''')  + ISNULL(u.LastName,'''')))  + '' Report: '' + rtrim(ee.EnvelopeNumber) + '' '' + er.Description
	END AS Comments
	,vd.ShortDescription AS TransactionComments
	,ISNULL(vd.OnHold, 0) 
    ,NULL as LinkVoucherDetailKey
    ,Case v.CreditCard
       WHEN 1 THEN u2.FirstName + '' '' + u2.LastName
       ELSE NULL  
     END AS [PurchasedByName]
	,v.ExchangeRate
	,v.PostingDate As PostingDate
from
	tVoucherDetail vd (nolock)
	inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey
	inner join tCompany c (nolock) on v.VendorKey = c.CompanyKey
	left outer join tTask ta (nolock) on vd.TaskKey = ta.TaskKey
	left outer join tItem i (nolock) on vd.ItemKey = i.ItemKey
	left outer join tExpenseReceipt er (nolock) on vd.VoucherDetailKey = er.VoucherDetailKey
	left outer join tExpenseEnvelope ee (nolock) on er.ExpenseEnvelopeKey = ee.ExpenseEnvelopeKey
	left outer join tUser u (nolock) on ee.UserKey = u.UserKey
	left outer join tUser u2 (nolock) on v.BoughtByKey = u2.UserKey
	left outer join tWriteOffReason wor (nolock) on vd.WriteOffReasonKey = wor.WriteOffReasonKey
where vd.TransferToKey is null
and v.CreditCard = 1


UNION ALL

Select
	N''ORDER'' as Type
	,Case po.POKind When 0 then N''Purchase Order''
					When 1 then N''Insertion Order''
					When 2 then N''Broadcast Order'' end as TypeName
	,po.CompanyKey
	,cast(pod.PurchaseOrderDetailKey as varchar(200)) as TranKey
	,pod.ProjectKey
	,pod.TaskKey
	,pod.TransferInDate
	,pod.DateBilled
	,ta.TaskID as TaskID
	,ta.TaskName
	,ta.TaskID + '' - '' + ta.TaskName as TaskFullName
	,ta.SummaryTaskKey
	,i.ItemID
	,i.ItemName
	,i.ItemID + '' - '' + i.ItemName as ItemFullName
	,i.ItemKey
	,pod.Quantity
	,pod.UnitCost
	,ROUND(pod.PTotalCost, 2) as TotalCostNet
	,ROUND(pod.PTotalCost, 2) as TotalCost
	,CASE po.BillAt 
		WHEN 0 THEN ISNULL(pod.BillableCost, 0)
		WHEN 1 THEN ISNULL(pod.PTotalCost,0)
		WHEN 2 THEN ISNULL(pod.BillableCost,0) - ISNULL(pod.PTotalCost,0) 
	END as BillableCost
	,ISNULL(pod.AmountBilled,0)
	,''Vendor: '' + c.VendorID + '' - '' + c.CompanyName + '' Order: '' + po.PurchaseOrderNumber + '' '' + ISNULL(pod.ShortDescription, '''') as Description
	,''Vendor: '' + c.VendorID + '' - '' + c.CompanyName + '' Order: '' + po.PurchaseOrderNumber + '' '' + ISNULL(pod.ShortDescription, '''') as Description2
	,i.ItemName as PersonItem
	 ,Case po.POKind When 0 then CONVERT( VARCHAR(50), po.PODate, 101)
			When 1 then CONVERT( VARCHAR(50), pod.DetailOrderDate, 101) 
			When 2 then CONVERT( VARCHAR(50), pod.DetailOrderDate, 101)
			Else CONVERT( VARCHAR(50), po.PODate, 101)
              End As TransactionDate
	 ,Case po.POKind When 0 then CONVERT( VARCHAR(50), po.PODate, 101)
			When 1 then CONVERT( VARCHAR(50), pod.DetailOrderDate, 101) 
			When 2 then CONVERT( VARCHAR(50), pod.DetailOrderEndDate, 101)
			Else CONVERT( VARCHAR(50), po.PODate, 101)
              End As TransactionDate2
	,pod.InvoiceLineKey
	,Case When ISNULL(pod.InvoiceLineKey, 0) = 0 then NULL
		else
			(Select rtrim(ltrim(InvoiceNumber)) 
				from tInvoice (nolock) 
				inner join tInvoiceLine (nolock) on tInvoice.InvoiceKey = tInvoiceLine.InvoiceKey 
				Where InvoiceLineKey = pod.InvoiceLineKey) 
		end as BillingInvoiceNumber
	,Case po.Status When 4 Then Case
		When InvoiceLineKey >= 0 then ''Billed''
		When InvoiceLineKey is null then ''UnBilled''
		END ELSE ''Unapproved'' END as BillingStatus
	,0
	,0
	,0
	,null
	,null
	,po.Status
	,pod.TransferComment
	,NULL AS Comments
	,pod.LongDescription AS TransactionComments
	,ISNULL(pod.OnHold, 0) 
    ,NULL as LinkVoucherDetailKey
    ,NULL AS [PurchasedByName]
	,po.ExchangeRate
	,NULL As PostingDate
from
	tPurchaseOrderDetail pod (nolock)
	inner join tPurchaseOrder po (nolock) on po.PurchaseOrderKey = pod.PurchaseOrderKey
	inner join tCompany c (nolock) on po.VendorKey = c.CompanyKey
	left outer join tTask ta (nolock) on pod.TaskKey = ta.TaskKey
	left outer join tItem i (nolock) on pod.ItemKey = i.ItemKey
Where
	(InvoiceLineKey > 0 or (ISNULL(AppliedCost, 0) = 0 and pod.Closed = 0))
and pod.TransferToKey is null



'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spConvertAppSeedLab]'
GO
IF OBJECT_ID(N'[dbo].[spConvertAppSeedLab]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spConvertAppSeedLab]
(
	@LoadBeta int = 0
)
AS

/*
|| spConvertAppSeedLab 1
|| When      Who Rel      What
||
|| Previous Comments moved to the end of this SP
|| 02/18/19  CRG 19.0.3.0 (421239) Removed PlanningMultipleTasks from the project schedule settings (it is now a setting on the project itself)
|| 02/19/19  CRG 19.0.3.0 (446583) Added Remaining Hours to projectSchedule columns
|| 02/26/19  AMP 19.0.3.0 (440082) Added Client Name and Vendor Name to the GL Drilldown
|| 02/26/19  RLS 19.0.3.0 (444491) Added Campaign Description to the campaignDashBoard
|| 02/26/19  GHL 19.0.3.0 (442017) Added currency to estimate listing (under project)
|| 02/27/19  AMP 19.0.3.0 (447860) Added Journal Entries to the Global Search option
|| 03/04/19  GWG 19.0.3.0  Fixing group options on deliverables board
|| 03/07/19  AMP 19.0.4.0 (447900) Added Date/Time Sent to the Deliverable Approvals
|| 03/11/19  AMP 19.0.4.0 (448928) Added TaskID to Today-Creatives grid view
|| 03/13/09  AMP 19.0.4.0 (422224) Added the Approval Comments and Worksheet Comments to the BillingWorksheetsToApprove, BillingWorksheetsInReview,ReadyToCreateInvoices and BillingWorksheetsAll listings
|| 03/14/19  GHL 19.0.4.0 Added Applied spots and amount to bill on BO grid after discussion with Greg
|| 03/13/19  GWG 19.0.4.0 Adding labs to this side since they mostly affect the menus
|| 03/18/19  CRG 19.0.4.0 (449162) Added prjScheduleExcludeFromStatus to projectSchedule columns
|| 03/18/19  AMP 19.0.4.0 (449681) Added the Currency field as an available field to the projects screen.
|| 03/20/19  MCM 19.0.4.0 (443519) Adding ToDo Board column information
|| 03/21/19  GWG 19.0.4.0 Removing platMedia, officeBlockoutCalendars, plaid, DeliverableBoard, crossProjectPreds  from labs
|| 03/25/19  RLS 19.0.4.0 (443168) Added projectFiles > ShowThumbnails
|| 03/25/19  RLB 19.0.4.0 Added change request options for project and campaign dash boards on client login
|| 03/25/19  GWG 19.0.4.0 Adding in option to show todos on the client dash and a lab for planning projects
|| 03/26/19  MFT 19.0.4.0 (446667) Added Created By columns to approval screens
|| 06/24/19  GAR 19.0.7.0 (416773) Changed description of global file search to File Search / Delete
|| 08/09/19  CRG 19.0.8.0 (454914) Added usePivot lab
|| 08/26/19  GAR 19.0.9.0 (429222) Removed File Search / Delete from labs.
|| 09/25/19  GWG 19.1.00  Moved deliverables to labs
|| 11/15/19  GWG 19.1.2.0 Adding media plans
|| 01/31/20  MFT 20.0.2.0 (478136) Adding ABA
|| 02/05/20  MCM 20.0.2.0 (499413) Added Credit Card Receipts
|| 04/01/20  WDF 20.0.4.0 (499413) Added Merge Duplicates
|| 06/12/20  MCM 20.0.7.0 (518930) Removed Credit card receipts from beta
|| 07/01/20  MFT 20.0.7.0 (486491) Added newLayoutDesignPlatinum
|| 07/27/20  RLB 20.0.8.0 (523358) removed beta tag on change requests
|| 08/06/20  GWG 20.0.9.0  Move merge dupes to labs
|| 09/17/20  RLB 20.1.0.0 (519667) Removed Tracking Forms Beta Tag
|| 09/22/20  CRG 20.1.0.0 (530562) Removed Pivot Table lab
|| 10/21/20  GAR 20.1.1.0 (534408) Removed PProject Change Requests lab
|| 12/04/20  GWG 20.1.2.0  Moved planning projects into general labs
|| 12/14/20  MFT 21.01.17  (530937) Removed NewLayoutDesign (7) and newLayoutDesignPlatinum (106) labs
|| 01/26/21  GAR 21.02.14  (545516) Removed mergeDuplicates (104) lab
|| 03/31/21  GAR 21.04.18.0000 (552751) Remove Planning Projects from labs
|| 04/06/21  GWG 21.04.18  Added newemailto for testing email to control
|| 05/06/21  GHL 21.06.20  (557067) Added newaddvendorinvoice for new Add Vendor Invoice function
|| 05/11/21  MCM 21.06.20  (558000) Added Excel Power Query lab
|| 06/30/21  MCM 21.07.18  (562958) Removed excel power query lab
|| 08/05/21  CRG 21.09.19  (556855) Added real time notification lab
|| 08/06/21  QMD 21.09.19  (DEV2364) Added rich text editor lab
|| 09/14/21  CRG 21.09.19  (556855) Added a customization to the RTN lab
|| 09/27/21  GAR 21.10.17  (DEV2501) Added a lab for Slack integration
|| 10/12/21  MCM 21.11.X   (574012) Removed newemailto
|| 10/26/21  CRG 21.11.14  Per Greg, I''ve removed the customization on the RTN lab
|| 11/23/21  GAR 21.12.19  Added a customization code to the Slack lab
|| 01/05/22  RLB 22.01.23  (582824) removed deliverables board
|| 03/30/22  RLB 22.04.17  (592293) removed Tracking Forms
|| 04/13/22  GHL 22.04.17  (451878) added GL companies with foreign currency
|| 07/27/22  RLB 22.08.14  (606866) move to labs from beta
|| 07/28/22  GHL 22.08.14  (607098) added lab for overtime
|| 08/25/22  KMC 22.12.18  Adding lab for Avalara Sales Tax integration, but leaving commented out until release - needed to turn Beta on
|| 10/11/22  MCM 22.11.x   (605911) added lab for receiptProcessCC
|| 11/10/22  GAR 22.11.20  (618885) Remove Slack from Beta in labs
|| 11/30/22  GAR 22.12.18  (622203) Spelling corrections in text editor lab
|| 12/20/22  GAR 23.01.15  (623756) Remove RTN from Beta in labs
|| 02/22/23  MCM 23.03.x   (630378) Added lab for journal entry approval process
|| 05/02/23  CRG 23.06.18  (630097) Added lab for two factor authentication
|| 05/04/23  MCM 23.06.18  (638917) Removed journal entry approval process from lab
|| 07/30/23  RLB 23.08.20  (646957) moved two factor authentication to a lab
|| 08/29/23  CRG 23.09.17  (649970) Removed two factor authentication from labs
|| 06/20/24  AMP 24.07.14  (671674) Added lab for Existing Invoices link
|| 07/26/24  MFT 24.08.00  (664163) Added lab for CanadianACH
|| 07/30/24  CRG 24.08.18  (679347) Removed RTN lab
|| 08/28/24  MCM 24.09.15  (680536) Added lab for MultiCurrCCBill (Multi Currency Credit Card billing)
|| 01/23/25  AMP 25.02.16  (679537) Removed existing invoices from labs
|| 01/24/25  MCM 25.02.16  (693257) Removed allow GL Companies from Beta in Labs
|| 02/21/25  GAR 25.XX.XX  (688217) Added a new lab for using the new project dashboard
|| 04/12/25  GWG 25.04.XX  Adding a lab for the new themes
|| 05/06/25  GAR 25.06.15  (701013) Remove Avalara from Beta in labs
|| 08/11/25  AMP 25.09.14  (707231) Removed Beta from Media Plans
|| 10/14/25  QMD 25.11.14  (xxxxxx) Added AI lab
|| 01/05/26  MCM 26.01.18  (718694) Removed allow GL Companies from Beta in Labs...again
|| 01/09/26  CRG 26.02.15  (548907) Added Recurring Tasks lab
|| 01/12/26  CRG 26.02.15  (548907) Made Recurring Tasks lab Beta
|| 03/03/26  RLB 26.04.19  (718338) removed Media plan lab
|| 03/19/26  QMD 26.04.19  (724849) Added timesuggestlab
|| 04/08/26  MAS 26.05.17  (714824) Added AI Conversation lab
|| 04/16/26  CRG 26.05.17  (721964) Added Automation lab
|| 04/22/26  MFT 26.05.00  (726644) removed useABALab, canadianACH (now customizations) & vPayment
|| 05/18/26  CRG 26.05.17  Made Automation lab Beta
|| 05/19/26  GWG 26.05.17  Added emailtemplates lab
|| 06/02/26  GWG 26.06.21  Adding timerpill and sidemenu labs
|| 06/25/26  RLS 26.07.19  (731609) Moved recurringTasks, automation, and emailtemplates to ''moved out (general release)''
*/


DELETE tLab

-- moved out (general release)
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (113,  0, 1, ''slack'', ''Use the Slack integration'', ''This enables integration with Slack.  You will be able to set up a connection to a Slack account and create channels from projects and send diary conversations to a Slack channel.'', '''')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription) Values (65,  1, 1, ''vPayment'', ''(BETA) American Express vPayment process'', '''')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription) Values (102,  1, 1, ''useABALab'', ''(BETA) Use ABA Payments (Australia)'', ''Enables setup fields so ABA files may be generated to be submitted to Australian financial institutions.'')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription) Values (121,  1, 1, ''canadianACH'', ''(BETA) Generate ACH files using the Canadian banking specifications'', ''When enabled, ACH files will be generated using the Canadian banking specifications'')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (114,  0, 1, ''glcompanydiffcurrency'', ''Allow GL companies to have foreign currency'', ''This allows you to have GL companies with a currency different from your home currency'', '''')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (115,  0, 1, ''trackovertime'', ''Track Overtime'', ''This allows you to track overtime with a different cost rate'', '''')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (116,  0, 1, ''avalara'', ''Avalara Sales Tax'', ''This enables integration with Avalara for real time calculation of sales tax'', '''')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (117,  0, 1, ''receiptProcessCC'', ''Receipt Credit Card'', ''This enables users to process multiple receipts with credit card'', '''')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription) Values (122,  0, 1, ''multiCurrCCBill'', ''Multi Currency Credit Card Billing'', ''This allows clients to pay in multi currency.  Currently for authoriz.net with multiple gateways (1 for each currency)'')
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (126,  0, 0, ''recurringTasks'', ''Recurring Tasks'', ''This will allow you to set up recurring tasks on the project schedule.'', '''')  -- moved out (general release) 06/25/26
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (128,  1, 0, ''automation'', ''Automation (BETA)'', ''This will allow you to set up automation rules.'', '''')  -- moved out (general release) 06/25/26
--INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (130,  1, 0, ''emailtemplates'', ''(BETA) Email Templates'', ''This allows you to generate project conversations with templated information from the project.'', '''')  -- moved out (general release) 06/25/26


-- In review to remove
INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription) Values (112,  0, 1, ''richTextEditor'', ''Rich Text Editor'', ''The next text editor form will support the ability to cut and paste with the same style from different applications. Please see the help guide for further information and limitations.'')
INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription) Values (108,  0, 1, ''newaddvendorinvoice'', ''New Add Vendor Invoice'', '''')


-- Labs
INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (123,  0, 1, ''newProjectDashboard'', ''New Project Dashboard'', ''This enables the new project dashboard that is more interactive and configurable.'', '''')

INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (124,  0, 1, ''systemThemes'', ''New System Display Themes'', ''This allows you to select one of the new display themes. We do not suggest setting the company wide theme as this will change the display for everyone in your company.'', '''')

INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (125,  0, 1, ''ai'', ''AI Feature Testing'', ''This will allow you to test different AI features within the application.'', ''AI'')

INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (131,  0, 0, ''timerpill'', ''Persistent timer widget'', ''This enables a timer widget in the bottom right corner of your screen that is visible at all times.'', '''')

INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (132,  0, 0, ''sidenav'', ''New Side Navigation'', ''This enables the new side menu and header bar'', '''')

-- Beta Items

--  NOT MERGED IN YET INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (127,  1, 1, ''timesuggest'', ''Auto Suggest Time Entries'', ''The application will suggest time entries.'', '''')

--  NOT MERGED IN YET INSERT tLab(LabKey, Beta, DisplayOrder, LabID, LabName, LabDescription, Customization) Values (129,  1, 0, ''aiConversation'', ''(BETA) AI Conversations'', ''This enables the new conversation AI feature within the application.'', '''')


-- active plat betas   **************   Next Key: 133  *****************  exec spConvertAppSeed 1
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskUserStatusDeleteGroup]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskUserStatusDeleteGroup]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptTaskUserStatusDeleteGroup]
	@Entity varchar(50) = ''securitygroup''
	,@EntityKey int

AS
/*
|| When       Who Rel      What
|| 05/13/16   GAR 10.6.0.4 Added for deleting task user status groups
|| 06/01/26   RLS 26.07.19 (729817) Protect against CompanyTaskUserStatusKey being 0 (needs to be NULL for Default Status)
*/	

	-- Need to update tTaskUser records since the old status records are no longer available.
	UPDATE tTaskUser
	SET TaskUserStatusKey = CASE WHEN ISNULL(tus1.CompanyTaskUserStatusKey, 0) = 0 THEN NULL ELSE tus1.CompanyTaskUserStatusKey END
	FROM tTaskUser (NOLOCK)
	INNER JOIN tTaskUserStatus tus1 (NOLOCK) ON tTaskUser.TaskUserStatusKey = tus1.TaskUserStatusKey
		LEFT OUTER JOIN tTaskUserStatus tus2 (NOLOCK)
			ON tus1.CompanyTaskUserStatusKey = tus2.TaskUserStatusKey
	WHERE tus1.EntityKey = @EntityKey
		AND tus1.Entity = @Entity
	
	DELETE
	FROM
		tTaskUserStatus
	WHERE
		Entity = @Entity
		AND EntityKey = @EntityKey

	
 '
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[tLayoutItems]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[tLayoutItems]', N'URL') IS NULL
ALTER TABLE [dbo].[tLayoutItems] ADD[URL] [nvarchar] (512) NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spProcessWIPWorksheetGetTabDetails]'
GO
IF OBJECT_ID(N'[dbo].[spProcessWIPWorksheetGetTabDetails]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[spProcessWIPWorksheetGetTabDetails]
	(
	@ProjectKey int
	,@GroupBy int = 0					-- 0: Group by Task, 1: Group by Item
	,@StartDate smalldatetime = null
	,@EndDate smalldatetime = null
	,@TabIndex int
	,@TaskKey int
	,@Entity varchar(20)
	,@EntityKey int
	,@ShowAll tinyint
	,@PostedOnly tinyint = 0 -- Posted Vendor Invoices Only 
	)
	
AS --Encrypt

/*
|| When     Who Rel    What
|| 04/02/13 GHL 10.566 Creation to support the tabs on the new billing screen in project central
|| 12/05/13 RLB 10.575 (197891) will pull data for a summary task now
|| 04/09/14 GHL 10.578 (212425) Added ProjectKey when querying tTime for ActualRate 
|| 04/25/14 GHL 10.579 (214165) If WIPPostingOutKey <> 0, you cannot select trans marked as billed or written off
|| 05/08/14 GHL 10.579 (215631) Fixed problem with summary task. If TaskKey = 0 all tasks under the root were queried
|| 09/16/14 GHL 10.584 (229804) Added substring(field, 1, len) when inserting strings
|| 11/20/14 GHL 10.586 Allowing now time entries posted to wip, to be edited on the Unbilled screen
|| 11/21/14 GHL 10.586 Setting Hours distinctively from Quantity based on Type
|| 01/06/15 GHL 10.588 Taking in account preference UndoWOAfterWIP (enhancement Abelson Taylor)
||                     here we can select (and undo WO) if UndoWOAfterWIP = 1
|| 02/26/15 GHL 10.589 Added transferred adjustments for new tab (users must be able to change transfer dates)
|| 06/09/15 WDF 10.593 (258640) Add @ShowAll to expand ''Display All Detail Transactions'' on T&M screen to all tabs 
|| 01/28/16 GHL 10.600 Reusing now this sp for the Unbilled case + added Entity/EntityKey to compare with summary by item in wjapp
|| 02/01/16 GHL 10.600 Added RateLevel to edit on wjapp + default transfer date
|| 02/01/16 GHL 10.600 Mark billed transactions as not selectable
|| 02/05/16 GHL 10.600 Addded TransferOutDate for transferred fields for wjapp because we only have 1 detail grid in wjapp
||                     Flex has 8 detail grids and uses date field DateBilled and calls it TransferOutDate on the grid  
|| 02/26/16 WDF 10.601 (291046) Added PurchasedByName for ''Voucher/Vendor Invoice'' Credit Card
|| 05/27/16 WDF 10.604 (302016) In ''get some defaults from item and services'', the select from tService should be ''= @kTypeLabor''
|| 07/19/16 GHL 10.606 (306695) labor net = ActualHours * CostRate instead of ActualHours * ActualRate 
||                      pull from vProjectCosts TotalCostNet and TotalCost
||                      Platinum/wjapp will use TotalCostNet, Flex will use TotalCost
|| 10/19/16 WDF 10.609 (317301) Flex will now use TotalCostNet rather than TotalCost (Reference Issue 306695)
|| 05/13/19 GHL 19.600 (434271) Added Attachment count and Credit Card flag to show on the billing grid the 
||                      number of attachments for vouchers and voucher details
|| 06/20/19 AMP 19.0.7.0 (461523) Modified Attachment count to include attachments on credit card charges 
|| 11/21/19 GHL 19.120 (480007) Added CostRate to be able to change it on project billing
|| 07/22/20 GHL 20.089 (522256) Returning now CanSplit flag for expense splits (even if posted)
|| 12/04/20 GHL 20.120  (539197) Added check of Project key = 0
|| 01/28/21 RLS 21.0.2.0 (546075) Changed [Comments] varchar(2000) null to [Comments] nvarchar(2000) null
|| 02/16/21 RLS 21.0.3.0 (535729) changed TaskName and TaskFullName to nvarchar
|| 03/05/21 RLS 21.0.4.0 (546075) changed TransactionComments to nvarchar
|| 06/29/21 RLS 21.0.7.0 (563399) changed [Description] and [Description2] to nvarchar
|| 07/22/21 GHL 21.0.8.0 (560579) Added Posted Vendor Invoices Only parameter 
|| 08/31/21 RLS 21.0.7.0 (564254) changed ItemID,ItemName,ItemFullName and TaskID to nvarchar
|| 10/13/21 RLB 21.11.14 (571397) added ProjectOrder for task sorting correctly
|| 05/06/22 GHL 22.05.00 (598279) Using TranKey as Int instead of varchar
|| 07/20/22 GHL 22.08.00 (604153) Added overtime for labor
|| 2/13/24 AMP 24.02.18 (658372) Change the Project > Billing screen so that the CC charges are listed as Credit Card Charges to 
||                                stay consistent with the Billing Worksheets
||03/13/24 AMP 24.03.17 (667070) Bug fix for PO''s showing up as credit card charge
||09/11/24 MCM 24.10.xx (682851) Updated logic changing type to "Credit Card Charge" only when it''s a voucher.  We were changing a miscCost when we shouldn''t have
||06/02/26 GAR 26.07.19 (728742) Adding PostingDate to unbilled charges on the project billing screen
*/

	SET NOCOUNT ON

	if isnull(@ProjectKey, 0) = 0
		return 1

	-- Index of tabs on the screen
	declare @kTabUnbilled int							select @kTabUnbilled = 0
	declare @kTabUnapproved int							select @kTabUnapproved = 1
	declare @kTabBilled int								select @kTabBilled = 2
	declare @kTabMarkedAsBilled int						select @kTabMarkedAsBilled = 3
	declare @kTabWriteOff int							select @kTabWriteOff = 4
	declare @kTabOnHold int								select @kTabOnHold = 5
	declare @kTabTransferred int						select @kTabTransferred = 6
	declare @kTabTransferredAdj int						select @kTabTransferredAdj = 7 

	-- Billing Status in vProjectCosts
	declare @kBillingStatusUnapproved varchar(20)		select @kBillingStatusUnapproved = ''Unapproved''
	declare @kBillingStatusBilled varchar(20)			select @kBillingStatusBilled = ''Billed''
	declare @kBillingStatusUnbilled varchar(20)			select @kBillingStatusUnbilled = ''UnBilled''
	declare @kBillingStatusWriteOff varchar(20)			select @kBillingStatusWriteOff = ''Writeoff''
	-- this is a new one which I added to capture the transferred transactions
	declare @kBillingStatusTransferred varchar(20)		select @kBillingStatusTransferred = ''Transferred''
	
	-- Types in vProjectCosts
	declare @kTypeLabor varchar(20)						select @kTypeLabor = ''LABOR''
	declare @kTypeExpenseReport varchar(20)				select @kTypeExpenseReport = ''EXPRPT''
	declare @kTypeMiscCost varchar(20)					select @kTypeMiscCost = ''MISCCOST''
	declare @kTypeVoucher varchar(20)					select @kTypeVoucher = ''VOUCHER''
	declare @kTypeOrder varchar(20)						select @kTypeOrder = ''ORDER''
	declare @kTypeCreditCardCharge varchar(20)          select @kTypeCreditCardCharge = ''CREDIT CARD CHARGE''
	
	declare @kGroupByTask int							select @kGroupByTask = 0
	declare @kGroupByItem int							select @kGroupByItem = 1

	if @StartDate is null
		select @StartDate = ''01/01/1900''
	if @EndDate is null
		select @EndDate = ''01/01/2070''

	-- only use the PostedOnly flag if we this is the Unbilled tab
	if @TabIndex <> @kTabUnbilled
		select @PostedOnly = 0

	declare @ProjectClassKey int, @CompanyKey int
	select @ProjectClassKey = ClassKey, @CompanyKey = CompanyKey from tProject (nolock) where ProjectKey = @ProjectKey

	declare @UndoWOAfterWIP int
	select @UndoWOAfterWIP = UndoWOAfterWIP from tPreference (nolock) where CompanyKey = @CompanyKey 
	select @UndoWOAfterWIP = isnull(@UndoWOAfterWIP, 0)

	create table #transaction (
		-- Copy of vProjectCosts
	  [Type] varchar(20) null
      ,[TypeName] varchar(20) null
      ,[TranKey] varchar(200) null
      ,[ProjectKey] int null
      ,[TaskKey] int null
      ,[TransferInDate] smalldatetime null
	  ,[TransferOutDate] smalldatetime null
      ,[DateBilled] smalldatetime null
      ,[TaskID] nvarchar(30) null
      ,[TaskName] nvarchar(500) null
      ,[TaskFullName] nvarchar(533) null
      ,[ItemID] nvarchar(50) null
      ,[ItemName] nvarchar(200) null
      ,[ItemFullName] nvarchar(253) null
      ,[ItemKey] int null
      ,[ProjectOrder] int null
      ,[Quantity] decimal(24,4) null
	  ,[Hours] decimal(24,4) null
      ,[UnitCost] money null				-- this contains tTime.ActualRate, not tTime.CostRate
      ,[TotalCostNet] decimal(38,6) null
      ,[TotalCost] decimal(38,6) null
      ,[BillableCost] decimal(38,6) null
      ,[AmountBilled] decimal(38,6) null
      ,[Description] nvarchar(2500) null
      ,[Description2] nvarchar(2500) null
      ,[PersonItem] nvarchar(201) null
      ,[TransactionDate] smalldatetime null
      ,[TransactionDate2] smalldatetime null
      ,[InvoiceLineKey] int null
      ,[BillingInvoiceNumber] varchar(35) null
      ,[BillingStatus] varchar(10) null
      ,[WIPPostingInKey] int null
      ,[WIPPostingOutKey] int null
      ,[WriteOff] int null
      ,[Status] int null
      ,[TransferComment] varchar(500) null
      ,[Comments] nvarchar(2000) null
      ,[TransactionComments] nvarchar(2000) null -- truncate from 6000 to 2000
      ,[PurchasedByName] varchar(201) null 
      ,[OnHold] tinyint null
	  ,[PostingDate] smalldatetime null

	  -- for write offs only
	  ,[WriteOffReasonName] varchar(200) null
	  ,[WriteOffComment] varchar(500) null

	  -- these are not part of vProjectCosts and will need extra queries
	  ,RateLevel int
	  ,UnitRate money null
	  ,CostRate money null -- 480007 this is for wongdoody to modify the tTime.CostRate on the billing screen 
	  ,DepartmentKey int null
	  ,ClassKey int null
	  ,SalesAccountKey int null
	  ,BillingID int null
	  ,CanEdit int null
	  ,CanSelect int null
	  ,CanSplit int null			-- added for 522256 can we split the vendor invoice details?
	  ,AttachmentCount int null		-- added for 434276
	  ,CreditCard int null			-- added for 434276
	  ,HeaderTranKey int null		-- added for 434276 this is the transaction key of the header to drilldown
	  ,Posted int null              -- is the vendor invoice posted?
	  ,TranKeyInt int null			-- we will convert varchar TranKey to Int to speedup the queries for expenses
	  ,Overtime int null            -- is labor overtime	  
	  )


/*
in vProjectCosts:
Bill Status |Unapproved    WriteOff       Billed      Unbilled
--------------------------------------------------------------
Status      | <4           4              4           4
WriteOff    |              1              0           0
ILK         |                            >=0          null

In this SP:
Tab         | Unbilled     Unapproved     Billed      MarkedAsBilled     WO       OnHold       Transferred
----------------------------------------------------------------------------------------------------------
Bill Status | Unbilled     Unapproved     Billed       Billed           WriteOff
On Hold     | 0            0                                                      1
ILK         |                             >0            0          
TTK         |                                                                                  TTK > 0
            |
CanEdit     |If WIK = 0     If Not Order  No           No               No        No            No
            |And WOK = 0
			|And Not Order
*/

	-- handle [No Task] case
	if @TaskKey = -1
		select @TaskKey = 0
	
	-- This SP will not be called for UnBilled detail
	-- That is handled in spProcessWIPWorksheetGetTabs
	if @TabIndex = @kTabUnbilled
		insert #transaction (
		   [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] 
		  ,[PostingDate]
			)
		select 
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1,2000) 
		  ,substring(TransactionComments, 1, 2000) 
		  ,[PurchasedByName] 
		  ,[OnHold]  
		  ,[PostingDate]
		from   vProjectCosts
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and    BillingStatus = @kBillingStatusUnbilled 
		and    OnHold = 0		
		and		(    
				(@GroupBy = @kGroupByTask and 
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				)
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				or @ShowAll = 1
				)

	else if @TabIndex = @kTabUnapproved
		insert #transaction (
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] )
		select 
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1, 2000) 
		  ,substring(TransactionComments, 1, 2000)
		  ,[PurchasedByName] 
		  ,[OnHold] 
		from   vProjectCosts
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and    BillingStatus = @kBillingStatusUnapproved and OnHold = 0
		and		(    
				(@GroupBy = @kGroupByTask and
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				 )
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				 or (@ShowAll = 1)
				)

	else if @TabIndex = @kTabBilled
		insert #transaction (
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] )
		select   
			[Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1, 2000) 
		  ,substring(TransactionComments, 1, 2000)
		  ,[PurchasedByName] 
		  ,[OnHold]  
		from   vProjectCosts
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and    BillingStatus = @kBillingStatusBilled and InvoiceLineKey > 0
		and		(    
				(@GroupBy = @kGroupByTask and 
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				)
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				or (@ShowAll = 1)
				)

	else if @TabIndex = @kTabMarkedAsBilled
		insert #transaction (
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] )
		select 
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1, 2000) 
		  ,substring(TransactionComments, 1, 2000)
		  ,[PurchasedByName] 
		  ,[OnHold]  
		from   vProjectCosts
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and    BillingStatus = @kBillingStatusBilled and InvoiceLineKey = 0
		and		(    
				(@GroupBy = @kGroupByTask and 
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				)
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				or (@ShowAll = 1)
				)

	else if @TabIndex = @kTabWriteOff
		insert #transaction (
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] 
		  ,[WriteOffReasonName] 
		  ,[WriteOffComment] 
		  )
		select 
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1, 2000) 
		  ,substring(TransactionComments, 1, 2000)
		  ,[PurchasedByName] 
		  ,[OnHold]  
		  ,[WriteOffReasonName] 
		  ,[WriteOffComment]
		from   vProjectCosts
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and    BillingStatus = @kBillingStatusWriteOff
		and		(    
				(@GroupBy = @kGroupByTask and 
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				)
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				or (@ShowAll = 1)
				)

	else if @TabIndex = @kTabOnHold
		insert #transaction (
			  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] )
		select 
		  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1, 2000) 
		  ,substring(TransactionComments, 1, 2000)
		  ,[PurchasedByName] 
		  ,[OnHold]  
		from   vProjectCosts
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and    OnHold = 1
		and		(    
				(@GroupBy = @kGroupByTask and 
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				)
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				or (@ShowAll = 1)
				)

	else if @TabIndex = @kTabTransferred
		insert #transaction (
			  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[TransferOutDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] )
		select 
			  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1, 2000) 
		  ,substring(TransactionComments, 1, 2000)
		  ,[PurchasedByName] 
		  ,[OnHold] 
		from   vProjectCostsTransfer
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and		(    
				(@GroupBy = @kGroupByTask and 
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				)
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				or (@ShowAll = 1)
				)

	else if @TabIndex = @kTabTransferredAdj
		insert #transaction (
			  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[TransferOutDate] 
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCost]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,[Description] 
		  ,[Description2] 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,[TransferComment] 
		  ,[Comments] 
		  ,[TransactionComments] 
		  ,[PurchasedByName] 
		  ,[OnHold] )
		select 
			  [Type] 
		  ,[TypeName] 
		  ,[TranKey]
		  ,[ProjectKey]
		  ,[TaskKey] 
		  ,[TransferInDate] 
		  ,[DateBilled]  
		  ,[DateBilled] 
		  ,[TaskID] 
		  ,[TaskName] 
		  ,[TaskFullName] 
		  ,[ItemID] 
		  ,[ItemName] 
		  ,[ItemFullName] 
		  ,[ItemKey] 
		  ,[Quantity] 
		  ,[UnitCost]
		  ,[TotalCostNet]
		  ,[TotalCostNet]
		  ,[BillableCost] 
		  ,[AmountBilled] 
		  ,substring([Description], 1, 2500) 
		  ,substring([Description2], 1, 2500) 
		  ,[PersonItem] 
		  ,[TransactionDate] 
		  ,[TransactionDate2] 
		  ,[InvoiceLineKey] 
		  ,[BillingInvoiceNumber] 
		  ,[BillingStatus] 
		  ,[WIPPostingInKey]
		  ,[WIPPostingOutKey] 
		  ,[WriteOff] 
		  ,[Status] 
		  ,substring([TransferComment], 1, 500) 
		  ,substring([Comments], 1, 2000) 
		  ,substring(TransactionComments, 1, 2000)
		  ,[PurchasedByName] 
		  ,[OnHold]  
		from   vProjectCostsTransferAdj
		where  ProjectKey = @ProjectKey
		and    TransactionDate >= @StartDate
		and    TransactionDate <= @EndDate
		and    LinkVoucherDetailKey IS NULL -- Remove ERs linked to VI
		and		(    
				(@GroupBy = @kGroupByTask and 
					(isnull(TaskKey, 0) = @TaskKey or (@TaskKey <> 0 And isnull(SummaryTaskKey, 0) = @TaskKey ))
				)
				or	(@GroupBy = @kGroupByItem and 
						(
						(@Entity = ''tService'' and Type = @kTypeLabor and isnull(ItemKey, 0) = @EntityKey)
						or
						(@Entity = ''tItem'' and Type <> @kTypeLabor and isnull(ItemKey, 0) = @EntityKey) 			
						)
					)
				or (@ShowAll = 1)
				)

	-- no convert the TranKey to an Int
	update #transaction
	set    #transaction.TranKeyInt = cast(#transaction.TranKey as Int)
	where  #transaction.Type <> @kTypeLabor

    -- get some defaults from item and services
	update #transaction
	set    #transaction.DepartmentKey = i.DepartmentKey
	      ,#transaction.SalesAccountKey = i.SalesAccountKey
		  ,#transaction.ClassKey = i.ClassKey
	from   tItem i (nolock)
	where  #transaction.ItemKey = i.ItemKey
	and    #transaction.Type <> @kTypeLabor

	update #transaction
	set    #transaction.DepartmentKey = s.DepartmentKey
	      ,#transaction.SalesAccountKey = s.GLAccountKey
		  ,#transaction.ClassKey = s.ClassKey
	from   tService s (nolock)
	where  #transaction.ItemKey = s.ServiceKey
	and    #transaction.Type = @kTypeLabor

	update #transaction 
	set    #transaction.BillingID = null

	update #transaction
	set    #transaction.ProjectOrder = ta.ProjectOrder
	from   tTask ta (nolock)
	where  #transaction.TaskKey = ta.TaskKey

	if exists (select 1 from #transaction where Type = @kTypeLabor)
	begin
		update #transaction 
		set    #transaction.UnitRate = t.ActualRate
			  ,#transaction.CostRate = t.CostRate
		      ,#transaction.RateLevel = t.RateLevel
			  ,#transaction.Overtime = t.Overtime
		from   tTime t (nolock)
		where  #transaction.TranKey = cast(t.TimeKey as varchar(200))
		and    #transaction.Type = @kTypeLabor
		and    t.ProjectKey = @ProjectKey

		update #transaction 
		set    #transaction.BillingID = b.BillingID
		from   tBilling b (nolock)
		inner  join tBillingDetail bd (nolock) on b.BillingKey = bd.BillingKey
		where  #transaction.Type = @kTypeLabor
		and    #transaction.TranKey = cast(bd.EntityGuid as varchar(200))  
		AND    b.CompanyKey = @CompanyKey
		AND    b.Status < 5

	end

	if exists (select 1 from #transaction where Type = @kTypeExpenseReport)
	begin
		update #transaction 
		set    #transaction.UnitRate = t.ActualCost
		from   tExpenseReceipt t (nolock)
		where  #transaction.TranKeyInt = t.ExpenseReceiptKey
		and    #transaction.Type = @kTypeExpenseReport

		update #transaction 
		set    #transaction.BillingID = b.BillingID
		from   tBilling b (nolock)
		inner  join tBillingDetail bd (nolock) on b.BillingKey = bd.BillingKey
		where  #transaction.Type = @kTypeExpenseReport
		and    #transaction.TranKeyInt = bd.EntityKey  
		AND    b.CompanyKey = @CompanyKey
		AND    b.Status < 5
		AND    bd.Entity = ''tExpenseReceipt''
	end

	if exists (select 1 from #transaction where Type = @kTypeMiscCost)
	begin
		update #transaction 
		set    #transaction.UnitRate = t.UnitRate
			  ,#transaction.DepartmentKey = t.DepartmentKey 
 		from   tMiscCost t (nolock)
		where  #transaction.TranKeyInt = t.MiscCostKey
		and    #transaction.Type = @kTypeMiscCost

		update #transaction 
		set    #transaction.BillingID = b.BillingID
		from   tBilling b (nolock)
		inner  join tBillingDetail bd (nolock) on b.BillingKey = bd.BillingKey
		where  #transaction.Type = @kTypeMiscCost
		and    #transaction.TranKeyInt = bd.EntityKey  
		AND    b.CompanyKey = @CompanyKey
		AND    b.Status < 5
		AND    bd.Entity = ''tMiscCost''
	end
	
	update #transaction
	    set #transaction.CreditCard = v.CreditCard,
		    #transaction.Type = ''CREDIT CARD CHARGE'',
			#transaction.TypeName = ''Credit Card Charge'',
			#transaction.HeaderTranKey = v.VoucherKey
		from   tVoucherDetail vd (nolock)
			   inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey
			   inner join tPurchaseOrderDetail pod (nolock) on pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey
		where  #transaction.TranKeyInt = pod.PurchaseOrderDetailKey 	
		and #transaction.Type = ''VOUCHER''
		and v.CreditCard = 1
		
	if exists (select 1 from #transaction where Type = @kTypeCreditCardCharge)
	begin	
		update #transaction 
		set    #transaction.UnitRate = t.UnitRate
			  ,#transaction.DepartmentKey = t.DepartmentKey
			  ,#transaction.ClassKey = t.ClassKey 
			  ,#transaction.Posted = case when v.Posted = 0 then 0 else v.Posted end -- better to show null on grid 
	 	from   tVoucherDetail t (nolock)
			   inner join tVoucher v (nolock) on t.VoucherKey = v.VoucherKey
		where  #transaction.TranKeyInt = t.VoucherDetailKey 
		and    #transaction.Type = @kTypeCreditCardCharge
		and    v.CreditCard = 1

		-- Do we want posted invoices only?
		if @PostedOnly = 1
		begin
			delete #transaction
			where  [Type] = @kTypeCreditCardCharge
			and  isnull(Posted, 0) = 0
			and CreditCard = 1
		end	

		update #transaction 
		set    #transaction.BillingID = b.BillingID
		from   tBilling b (nolock)
		inner  join tBillingDetail bd (nolock) on b.BillingKey = bd.BillingKey
		where  #transaction.Type = @kTypeCreditCardCharge
		and    #transaction.TranKeyInt = bd.EntityKey  
		AND    b.CompanyKey = @CompanyKey
		AND    b.Status < 5
		AND    bd.Entity = ''tVoucherDetail''
		AND    CreditCard = 1
	end
	   
	if exists (select 1 from #transaction where Type = @kTypeVoucher)
	begin
		update #transaction 
		set    #transaction.UnitRate = t.UnitRate
			  ,#transaction.DepartmentKey = t.DepartmentKey
			  ,#transaction.ClassKey = t.ClassKey 
			  ,#transaction.Posted = case when v.Posted = 0 then null else v.Posted end -- better to show null on grid 
 		from   tVoucherDetail t (nolock)
			   inner join tVoucher v (nolock) on t.VoucherKey = v.VoucherKey
		where  #transaction.TranKeyInt = t.VoucherDetailKey 
		and    #transaction.Type = @kTypeVoucher		

		-- Do we want posted invoices only?
		if @PostedOnly = 1
		begin
			delete #transaction
			where  [Type] = @kTypeVoucher
			and  isnull(Posted, 0) = 0
		end

		update #transaction 
		set    #transaction.BillingID = b.BillingID
		from   tBilling b (nolock)
		inner  join tBillingDetail bd (nolock) on b.BillingKey = bd.BillingKey		
		where  #transaction.Type = @kTypeVoucher
		and    #transaction.TranKeyInt = bd.EntityKey  
		AND    b.CompanyKey = @CompanyKey
		AND    b.Status < 5
		AND    bd.Entity = ''tVoucherDetail''		
	end

	if exists (select 1 from #transaction where Type = @kTypeOrder)
	begin
		update #transaction 
		set    #transaction.UnitRate = t.UnitRate
			  ,#transaction.DepartmentKey = t.DepartmentKey
			  ,#transaction.ClassKey = t.ClassKey 
 		from   tPurchaseOrderDetail t (nolock)
		where  #transaction.TranKeyInt = t.PurchaseOrderDetailKey
		and    #transaction.Type = @kTypeOrder
	
		update #transaction 
		set    #transaction.BillingID = b.BillingID
		from   tBilling b (nolock)
		inner  join tBillingDetail bd (nolock) on b.BillingKey = bd.BillingKey
		where  #transaction.Type = @kTypeOrder
		and    #transaction.TranKeyInt = bd.EntityKey  
		AND    b.CompanyKey = @CompanyKey
		AND    b.Status < 5
		AND    bd.Entity = ''tPurchaseOrderDetail''

	end

	-- Split the quantities and hours
	update #transaction
	set    Hours = Quantity 
	where  Type = @kTypeLabor

	update #transaction
	set    Quantity = 0 
	where  Type = @kTypeLabor

	update #transaction
	set    Hours = 0 
	where  Type <> @kTypeLabor	
	
	update #transaction
	set CanEdit = 0

	if @TabIndex =@kTabUnapproved
		update #transaction
		set    CanEdit = 1
		where  Type <> @kTypeOrder

	if @TabIndex =@kTabUnbilled
	begin
		-- allow editing of time entries even if posted to WIP
		update #transaction
		set    CanEdit = 1
		--where  Type <> @kTypeOrder and WIPPostingInKey = 0 and WIPPostingOutKey = 0
		where  Type = @kTypeLabor-- If posted to WIP we will do a transfer
		and    BillingID is null -- but make sure they are not on a BWS

		-- but do not show if on a billing worksheet
		delete #transaction where BillingID is not null 

		update #transaction
		set    CanEdit = 1
		where  Type = @kTypeLabor and WIPPostingInKey = 0 and WIPPostingOutKey = 0
		-- if not posted to WIP, we are not going to do a transfer, so do not check the BillingID

		update #transaction
		set    CanEdit = 1
		where  Type not in ( @kTypeOrder, @kTypeLabor) 
		and    WIPPostingInKey = 0 and WIPPostingOutKey = 0

		-- we can split the voucher details if unbilled and the linked POD are not billed
		update #transaction
		set    #transaction.CanSplit = 1
		from   #transaction
			inner join tVoucherDetail vd (nolock) on #transaction.TranKeyInt = vd.VoucherDetailKey
			inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey
		    left outer join tPurchaseOrderDetail pod (nolock) on vd.PurchaseOrderDetailKey = pod.PurchaseOrderDetailKey
	    where  #transaction.Type in (@kTypeVoucher, @kTypeCreditCardCharge)
		and    isnull(pod.InvoiceLineKey,0) = 0  -- the linked PO must be unbilled also
		--and    v.Posted = 0					      -- this could be a problem for some
		and    isnull(vd.TotalCost,0) > 0	      -- not 0 because we need to divide by TotalCost, must have something to split
		and    isnull(vd.BillableCost,0) > 0      -- must have something to split 
	end

	update #transaction
		set CanSelect = 1

	if @TabIndex =@kTabMarkedAsBilled 
		update #transaction
		set    CanSelect = 0
		where  WIPPostingOutKey <> 0

	if @TabIndex =@kTabWriteOff And @UndoWOAfterWIP = 0 
		update #transaction
		set    CanSelect = 0
		where  WIPPostingOutKey <> 0

	if @TabIndex in ( @kTabTransferred, @kTabTransferredAdj)
	begin
		-- do not allow the selection of reversals because the Change Transfer Date function works off the original trans only
		update #transaction
		set    CanSelect = 0
		where  WIPPostingInKey = -99
	end
	 
	if @TabIndex =@kTabBilled 
		update #transaction
		set    CanSelect = 0
	
	-- when unbilled, pull number of attachments for vouchers + voucher details
	if @TabIndex = @kTabUnbilled
	begin
-- we need the voucher key and credit card flag for the drill downs
	    update #transaction
		set    #transaction.HeaderTranKey = vd.VoucherKey
		from   tVoucher v (nolock)
			inner join tVoucherDetail vd (nolock) on vd.VoucherKey = v.VoucherKey
		where  #transaction.Type in (@kTypeVoucher, @kTypeCreditCardCharge)
		and    #transaction.TranKeyInt = vd.VoucherDetailKey	
		

		update #transaction
			set    AttachmentCount = isnull(( 
			select count(*) from tAttachment (nolock) where AssociatedEntity = ''tVoucher'' 
				and EntityKey = #transaction.HeaderTranKey 
			),0)
			+
			isnull(( 
			select count(*) from tAttachment (nolock) where AssociatedEntity = ''tVoucherDetail'' 
				and EntityKey  = #transaction.TranKeyInt
			),0)	
		where  #transaction.Type in (@kTypeVoucher, @kTypeCreditCardCharge)

	end
	

	select t.*
	      ,d.DepartmentName
		  ,isnull(c.ClassID + '' - '', '''') + c.ClassName as ClassFullName
		  ,gla.AccountNumber + '' - '' + gla.AccountName as SalesAccountFullName
		  ,wipin.Comment as WIPInBatch
		  ,wipout.Comment as WIPOutBatch
		  ,case when CanEdit = 1 then ''Click to edit'' else null end as EditIcon 
		  ,case when CanSelect = 1 then 0 else 1 end as CannotSelect -- needed for WJAPP grids (need to NOT/NEGATE it)
		  ,0 as tagged
		  , convert(datetime,  convert(varchar(10), getdate(), 101), 101) as TransferDate -- default to today if we transfer
		  -- set Entity and EntityKey to facilitate comparisons with summary by item
		  ,case when t.Type = ''LABOR'' then ''tService'' else ''tItem'' end as Entity
		  ,isnull(t.ItemKey, 0) as EntityKey 
	from   #transaction t (nolock)
	left outer join tDepartment d (nolock) on t.DepartmentKey = d.DepartmentKey
	left outer join tClass c (nolock) on t.ClassKey = c.ClassKey
	left outer join tWIPPosting wipin (nolock) on t.WIPPostingInKey = wipin.WIPPostingKey
	left outer join tWIPPosting wipout (nolock) on t.WIPPostingOutKey = wipout.WIPPostingKey
	left outer join tGLAccount gla (nolock) on t.SalesAccountKey = gla.GLAccountKey

return 1
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[vListing_Company]'
GO
IF OBJECT_ID(N'[dbo].[vListing_Company]', 'V') IS NOT NULL
EXEC sp_executesql N'ALTER VIEW [dbo].[vListing_Company]
AS  

/*
  || When     Who Rel     What
  || 10/16/06 WES 8.3567  Added Comments field
  || 10/16/06 WES 8.3567  Added Date Added field
  || 03/27/07 RTC 8.4.1   (7434) Added Invoice Template, Default Billing Method, One Invoice Per,
                          One Line Per, Default Terms, Estimate Template, Get Rate From Labor, Get Rate From Expenses,
 						  Item Rate Sheet, Item Markup, Prebill Insertions At, Prebill Broadcast At
  || 05/07/07 CRG 8.4.3   (9029) Added Sales Tax 1 and Sales Tax 2
  || 10/4/07  GWG 8.4.3   Added Labor Rate Sheet, modified name of item rate sheet to expense rate sheet
  || 11/06/07 CRG 8.5     (13138) Added Account Team
  || 02/08/08 CRG 1.0.0.0 Added Created By, Date Updated, Last Modified By
  || 02/29/08 CRG 1.0.0.0 Added ASC_Selected
  || 03/27/08 GWG 8.5     Added Vendor Discount Percent and days
  || 07/29/08 GHL 1.0.0.5 Added CMFolderKey since it affects the rights
  || 02/09/09 GWG 10.5	  Made cmfolderkey force to 0 so that a no folder check can be made.
  || 03/11/09 MAS 10.5	  Added Last and Next Activity columns, renamed columns, removed user_defined columns.
  || 04/03/09 GWG 10.5    Minor fixes to views
  || 04/29/09 RLB 10.024  (50919) Pulling just date on b.DateAdded
  || 04/30/09 CRG 10.500  Added Next/Last Activity Types, Days Since Last Activity, and No Activity Since
  || 9/22/09  CRG 10.511  (63789) Added new options for DefaultARLineFormat
  || 09/24/09 RLB 10.511  (63767) wrapped c.Type1099 in isnull was not displaying no in listing when it was null
  || 01/19/10 RLB 10.517  (72560) Added Over Head Client to the listing
  || 06/11/10 GWG 10.531  (82828) Fixed the Date converted. should come from the primary cont. not acct manager.
  || 07/09/10 RLB 10.532  (82828) changed Date Converted to the Companies Date Converted.
  || 10/06/10 RLB 10.536   added Primary Contact Phone 1 and 2
  || 11/1/10  RLB 10.537  (89516) Added DBA for voucher listing
  || 03/30/12 RLB 10.554  (138232) Added Default Expense Account
  || 05/03/12 RLB 10.555  (126104) Added Default Sales Account
  || 12/07/12 WDF 10.563  (161600) Added Default GL Company
  || 02/13/13 WDF 10.565  (168570) [Last Modified By] using the wrong alias of [Created By]
  || 03/25/13 WDF 10.566  (172384) Added [Account Manager Active]
  || 06/28/13 GHL 10.569  (182649) Added [Vendor Accepts Credit Cards]
  || 02/13/14 WDF 10.577  (206358) Added [One Payment Per Invoice] and [Print DBA On Check]
  || 04/09/14 GHL 10.579  Added CurrencyID
  || 07/18/14 WDF 10.582  Added IO/BC Commission 
  || 09/26/14 WDF 10.584  (Abelson Taylor) Added Billing Title and Billing Title Rate Sheet to GetRateFrom
  || 10/15/14 WDF 10.585  (Abelson Taylor) Added Title Rate Sheet
  || 11/17/14 GAR 10.586  (236376) Added option 9 to [One Line Item Per] because it wasn''t being populated in 
  ||					  the companies listing screen when that option was chosen.
  || 01/28/15 GHL 10.588  Added new Line Formats for Abelson Taylor
  || 01/30/15 WDF 10.588  (244159) Added Billing Name and Email Invoices To
  || 02/10/15 KMC 10.589  (245859) Added Default AP Account
  || 02/11/15 KMC 10.589  (245859) Added Vendor Sales Tax 1 and Vendor Sales Tax 2
  || 03/05/15 GWG 10.590  Added Credit Card info
  || 05/05/15 KMC 10.591  (252479) Added masking of EINNumber on tCompany
  || 05/14/15 QMD 10.592  (256902) Tweaked ein masking slightly
  || 07/01/15 WDF 10.593  (262005) Added Payment Address
  || 09/27/15 GWG 10.5.9.6 change next and last act date to DateModified
  || 11/11/15 GWG 10.5.9.7 Revert the next last act date change
  || 01/13/16 WDF 10.6.0.0 (285154) Added [On Hold]
  || 01/28/16 MCM 10.6.0.0 (274838) Added Billing Manager
  || 03/18/16 WDF 10.6.0.0 (293854) Added [Default Layout Name]
  || 12/19/16 MAS 10.6.0.0 (322283) Added [Vendor Accepts VCards]
  || 08/02/17 WDF 10.6.1.8 (357243) Added [Default Office]
  || 02/19/18 GAR 18.3.0.0  (373196) Added No Folder as NULL option to aid in searching
  || 06/19/18 GHL 18.7.0.0 (406799) Added One Line Per (Fixed Fee) or FF line format
  || 07/25/18 RLB 18.8.0   (401369) Added Default Project Hourly Rate
  || 10/08/18 GHL 18.920   (349590) Added Labor Taxable
  || 11/02/18 WDF 19.2.0   (401369) Changed ''One Line Item Per (Fixed Fee)'' to ''One Line Item Per Fixed Fee'' because
                                    it was being translated to ''One Line Item Per _x0028_Fixed Fee_x0029_'' in Flash
                                    and causes all data from the following fields to be pulled into that field in Platinum.
  || 12/03/18 MCM 19.1.0   (432358) Removed "Vendor Credit Cards Accepted" since duplicate of "Accepts Credit Cards".  Also Changed from "Vendor Accepts VCards" to "Accepts VPay"
  || 04/02/19 RLB 19.0.4.0 (453535) added Date Added With Time since date add is stripped of time for filtering
  || 06/03/19 AMP 19.0.7.0 (463228) Added Default AR Account
  || 06/06/19 RLB 19.0.7.0 (446229) Adding Project Manager
  || 07/19/19 GAR 19.0.8.0 (470896) Adding NextProjectNum
  || 01/03/20 GAR 20.0.2.0 (493902) Added Primary Contact Email 
  || 01/16/20 AMP 20.0.2.0 (495449) Added Credit Card Exp Date column
  || 02/25/20 MCM 20.0.3.0 (502409) Updated logic of "Client Rate" column.  Only return value if get rate from = project (ie 2).  
  || 03/18/20 AMP 20.0.4.0 (507139) Added "Allow Credit Card Payments Online"
  || 04/08/20 MCM 20.0.5.0 (509727) Added "ACH Enabled"
  || 05/01/20 RLB 20.0.6.0 (513837) wrapped primary contact fist and last names
  || 06/16/20 MCM 20.0.7.0 (519216) Added IsNull around first and last name of "Email Invoices To"
  || 06/23/20 RLS 20.6.0.0  (517148) Added TwitterID
  || 08/18/20 MCM 20.0.9.0 (475239) Added companymetrics fields
  || 08/24/20 RLS 20.0.9.0 (522703) Added [Next Campaign Number]
  || 09/02/20 RLB 20.1.0.0 (523772) making anything using user name common format
  || 09/25/20 MFT 20.1.1.0 (528335) Added NEC to Type1099 enum
  || 01/26/21 AMP 22.02.14 (544997) Added Default Approver Person
  || 12/20/21 MCM 22.02.14 (581037) Added ACH Email 
  || 01/27/22 GHL 22.02.20 (564369) Added Active Client and Active Vendor new fields
  || 09/16/22 GAR 22.10.16 (612270) Added GL Company Access Restrictions
  || 05/12/23 AMP 23.06.18 (629929) Added "Allow ACH Payments Online"
  || 06/14/23 GAR 23.07.16 (632579) Added Do not use for Projects or Project Requests
  || 11/29/23 RLB 23.12.17 (653809) added UseDBAForPayment1099 
  || 01/16/24 RLS 24.02.18 (659920) Added [Bank Account Type]
  || 09/05/24 GAR 24.10.20 (682270) Added Avalara Tax Code and Description
  || 09/11/24 GAR 24.10.20 (682936) Added Avalara Tax Exempt Reason
  || 02/24/26 RLS 26.03.15 (720029) Added [Require Comments on Time Entries]
  || 04/14/26 RLS 26.05.17 (602837) Changed the logic for [One Line Item Per] to be consistant with billing.clients.edit
  || 05/15/26 AMP 26.05.17 (720174) Added Use Alternate Address for 1099
*/

SELECT
	c.OwnerCompanyKey AS OwnerCompanyKey,  
	c.CompanyKey,  
	c.Vendor,  
	c.BillableClient,   
	c.CustomFieldKey,  
	c.ContactOwnerKey,
	ISNULL(c.CMFolderKey, 0) AS CMFolderKey,
	c.CompanyKey AS ContactCompanyKey,  --Needed for defaulting information into activity
	c.PrimaryContact,
	c.CompanyName,
	LTRIM(RTRIM(ISNULL(pct.FirstName + '' '','''')  + ISNULL(pct.LastName,''''))) AS ContactName,
	c.CompanyName AS [Company Name],
	c.DBA AS [DBA],   
	c.VendorID AS [Vendor ID],   
	c.CustomerID AS [Client ID], 
	LTRIM(RTRIM(ISNULL(bc.FirstName + '' '','''')  + ISNULL(bc.LastName,''''))) AS [Email Invoices To],
	ad.Address1 AS [Mailing Address1],   
	ad.Address2 AS [Mailing Address2],   
	ad.Address3 AS [Mailing Address3],   
	ad.City AS [Mailing City],   
	ad.State AS [Mailing State],   
	ad.PostalCode AS [Mailing Postal Code],   
	ad.Country AS [Mailing Country],   
	CASE
		WHEN c.ParentCompany = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Parent Company],  
	pc.CompanyName AS [Parent Company Name],  
	CASE
		WHEN c.Vendor = 1 THEN ''YES''
		ELSE ''NO'' 
	END AS [Is a Vendor],   
	CASE 
		WHEN c.BillableClient = 1 THEN ''YES'' 
		ELSE ''NO'' 
	END AS [Is a Client],   
	CASE 
		WHEN c.GetRateFrom <> 2 then 0
		ELSE c.HourlyRate 
	END AS [Client Rate],   
	c.BillingName AS [Billing Name],
	ab.Address1 AS [Billing Address1],   
	ab.Address2 AS [Billing Address2],   
	ab.Address3 AS [Billing Address3],   
	ab.City AS [Billing City],   
	ab.State AS [Billing State],   
	ab.PostalCode AS [Billing Postal Code],   
	ab.Country AS [Billing Country],   
	c.WebSite AS [Web Site],   
	c.Phone AS [Main Phone],   
	c.Fax AS [Main Fax],   
	o.OfficeName as [Default Office],   
	CASE
		WHEN c.Active = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Active],
	CASE
		WHEN isnull(c.BillableClient,0) = 1 and isnull(c.ActiveClient,0) = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Active Client],
	CASE
		WHEN isnull(c.Vendor,0) = 1 and isnull(c.ActiveVendor,0) = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Active Vendor],    
	CASE c.Type1099 
		WHEN 1 THEN ''MISC''
		WHEN 2 THEN ''INT''
		WHEN 3 THEN ''NEC''
	END AS [Form 1099 Type],
	CASE isnull(c.Type1099, 0)
		WHEN 0 THEN ''NO''
		ELSE ''YES''
	END AS [Is 1099],  
	c.Box1099 AS [Form 1099 Box],  	
	CASE
		WHEN LEN(c.EINNumber) >= 3 THEN ''*********'' + SUBSTRING(c.EINNumber, LEN(c.EINNumber) - 2, 3)
		ELSE c.EINNumber
	END AS [EIN Number],
	ct.CompanyTypeName AS [Company Type],  
	LTRIM(RTRIM(ISNULL(u.FirstName + '' '','''')  + ISNULL(u.LastName,''''))) AS [Account Manager Full Name],
	CASE u.Active
		WHEN 1 THEN ''YES''
		ELSE ''NO'' 
	END AS [Account Manager Active],  
	LTRIM(RTRIM(ISNULL(upm.FirstName + '' '','''')  + ISNULL(upm.LastName,''''))) AS [Project Manager Full Name],
	CASE upm.Active
		WHEN 1 THEN ''YES''
		ELSE ''NO'' 
	END AS [Project Manager Active],  
	LTRIM(RTRIM(ISNULL(pct.FirstName + '' '','''')  + ISNULL(pct.LastName,''''))) AS [Primary Contact Name], 
	pct.Phone1 AS [Primary Contact Phone 1],
	pct.Phone2 AS [Primary Contact Phone 2],
	LTRIM(RTRIM(ISNULL(owner.FirstName + '' '','''')  + ISNULL(owner.LastName,''''))) AS  [Company Owner],
	c.Comments,
	c.DateConverted AS [Date Converted],
	Cast(Cast(Month(c.DateAdded) AS VARCHAR) + ''/'' + Cast(Day(c.DateAdded) AS VARCHAR) + ''/'' + Cast(Year(c.DateAdded) AS VARCHAR) AS SMALLDATETIME) AS [Date Added],
	c.DateAdded AS [Date Added With Time],
	it.TemplateName AS [Invoice Template],
	glc.GLCompanyName AS [Default Company],
	CASE c.DefaultBillingMethod
		WHEN 1 THEN ''Time and Materials''
		WHEN 2 THEN ''Fixed Fee''
		WHEN 3 THEN ''Retainer''
	END AS [Default Billing Method],
	CASE c.OneInvoicePer
		WHEN 0 THEN ''Project''
		WHEN 1 THEN ''Client''
		WHEN 2 THEN ''Parent Client''
		WHEN 3 THEN ''Division''
		WHEN 4 THEN ''Product''
		WHEN 5 THEN ''Campaign''
	END AS [One Invoice Per],

	CASE c.DefaultARLineFormat
	WHEN -1 THEN ''''
	WHEN 8 THEN ''Project then Billing Item and Item''
	WHEN 11 THEN CASE WHEN ISNULL(pref.UseBillingTitles, 0) = 1 THEN ''Title'' ELSE '''' END
	WHEN 12 THEN CASE WHEN ISNULL(pref.UseBillingTitles, 0) = 1 THEN ''Title and Service'' ELSE '''' END
	WHEN 13 THEN CASE WHEN ISNULL(pref.UseBillingTitles, 0) = 1 THEN ''Service and Title'' ELSE '''' END
	WHEN 0 THEN CASE WHEN c.OneInvoicePer = 0 THEN ''Invoice'' ELSE ''Project'' END
	WHEN 1 THEN CASE WHEN c.OneInvoicePer = 0 THEN ''Task'' ELSE ''Project and Task'' END
	WHEN 2 THEN CASE WHEN ISNULL(c.LayoutKey, 0) = 0 THEN ''Service'' ELSE ''Project and Service'' END
	WHEN 14 THEN CASE WHEN ISNULL(c.LayoutKey, 0) = 0 THEN ''Service/Item'' ELSE ''Project and Service/Item'' END
	WHEN 3 THEN CASE WHEN ISNULL(c.LayoutKey, 0) = 0 THEN ''Billing Item'' ELSE '''' END
	WHEN 9 THEN CASE WHEN c.OneInvoicePer = 0 OR ISNULL(c.LayoutKey, 0) <> 0 THEN ''Billing Item and Item'' ELSE '''' END
	ELSE ''''
END AS [One Line Item Per],

	 CASE c.DefaultFFLineFormat
			WHEN -1 THEN ''''
			WHEN 0 THEN ''One Line''
			WHEN 1 THEN ''Task''
			WHEN 2 THEN ''Service/Item''
			WHEN 3 THEN ''Billing Item''
			WHEN 4 THEN ''Billing Item and Item''
		 END AS [One Line Item Per Fixed Fee],
	CASE
		WHEN c.OnePaymentPerVoucher = 1 THEN ''YES'' 
		ELSE ''NO'' 
	END AS [One Payment Per Invoice], 
	CASE
		WHEN c.UseDBAForPayment = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Print DBA On Check], 
	CASE
		WHEN c.UseDBAForPayment1099 = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Print DBA On 1099], 
	pt.TermsDescription AS [Billing Terms],
	et.TemplateName AS [Estimate Template],
	CASE c.GetRateFrom
		WHEN 9 THEN ''Billing Title''
		WHEN 10 THEN ''Billing Title Rate Sheet''
		WHEN 1 THEN ''Client''
		WHEN 2 THEN ''Project''
		WHEN 3 THEN ''Project/User''
		WHEN 4 THEN ''Service''
		WHEN 5 THEN ''Service Rate Sheet''
		WHEN 6 THEN ''Task''
	END AS [Labor Get Rate From],
	CASE c.GetMarkupFrom
		WHEN 1 THEN ''Client''
		WHEN 2 THEN ''Project''
		WHEN 3 THEN ''Item''
		WHEN 4 THEN ''Item Rate Sheet''
		WHEN 5 THEN ''Task''
	END AS [Purchasing Get Rate From],
	rs.RateSheetName AS [Expense Rate Sheet],
	srs.RateSheetName AS [Labor Rate Sheet],
	tirs.RateSheetName AS [Title Rate Sheet],
	c.ItemMarkup AS [Purchasing Markup],
	c.IOCommission AS [IO Commission Percent], 
	c.BCCommission AS [BC Commission Percent],
	Case c.GetRateFrom When 2 then c.HourlyRate else 0 end AS [Default Project Hourly Rate],
	CASE c.IOBillAt
		WHEN 0 THEN ''Gross''
		WHEN 1 THEN ''Net''
		WHEN 2 THEN ''Commission Only''
	END AS [Prebill Insertions At],
	CASE c.BCBillAt
		WHEN 0 THEN ''Gross''
		WHEN 1 THEN ''Net''
		WHEN 2 THEN ''Commission Only''
	END AS [Prebill Broadcast At],
	st1.SalesTaxName AS [Sales Tax 1],
	st2.SalesTaxName AS [Sales Tax 2],
	gla.AccountNumber + '' - '' + gla.AccountName AS [Default Expense Account],
	gla2.AccountNumber + '' - '' + gla2.AccountName AS [Default Sales Account],
	t.TeamName AS [Account Team],
	LTRIM(RTRIM(ISNULL(cb.FirstName + '' '','''')  + ISNULL(cb.LastName,''''))) AS [Created By],
	c.DateUpdated AS [Date Updated],
	LTRIM(RTRIM(ISNULL(mb.FirstName + '' '','''')  + ISNULL(mb.LastName,''''))) [Last Modified By],
	0 AS ASC_Selected,
	c.TermsPercent AS [Vendor Discount Percent],
	c.TermsDays AS [Vendor Discount Days],
	c.TermsNet AS [Vendor Days Net Due],
	CASE
		WHEN c.Overhead = 1 THEN ''YES''
		ELSE ''NO''
	END AS [OverHead Client], 
	CASE
		WHEN c.OverheadVendor = 1 THEN ''YES''
		ELSE ''NO''
	END AS [OverHead Vendor], 
	CASE
		WHEN c.CCAccepted = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Accepts Credit Cards],
	LTRIM(RTRIM(ISNULL(sales.FirstName + '' '','''')  + ISNULL(sales.LastName,''''))) AS [Salesperson Name],
	so.SourceName AS [Company Source],
	ISNULL(folder.FolderName, ''No Folder'') AS [Folder],
	-- WWP
	CASE c.WWPCurrentLevel 
		WHEN 2 THEN ''2 - Contemplating''
		WHEN 3 THEN ''3 - Planning''
		WHEN 4 THEN ''4 - Action''
		ELSE ''1 - Unaware'' 
	END AS [WWP Current Level],
	lastActivity.ActivityDate AS [Last Activity Date],
	lastActivity.Subject AS [Last Activity Subject],
	ISNULL(lau.FirstName,'''') + '' '' + ISNULL(lau.LastName,'''') AS [Last Activity Assigned To],
	nextActivity.ActivityDate AS [Next Activity Date],
	nextActivity.Subject AS [Next Activity Subject],
	ISNULL(nau.FirstName,'''') + '' '' + ISNULL(nau.LastName,'''') AS [Next Activity Assigned To],
	atNext.TypeName AS [Next Activity Type],
	atLast.TypeName AS [Last Activity Type],
	DATEDIFF(day, lastActivity.ActivityDate, GETDATE()) AS [Days Since Last Activity],
	CASE
		WHEN DATEDIFF(day, lastActivity.ActivityDate, GETDATE()) > 90 THEN ''90 Days''
		WHEN DATEDIFF(day, lastActivity.ActivityDate, GETDATE()) > 60 THEN ''60 Days''
		WHEN DATEDIFF(day, lastActivity.ActivityDate, GETDATE()) > 30 THEN ''30 Days''
		WHEN DATEDIFF(day, lastActivity.ActivityDate, GETDATE()) > 7 THEN ''7 Days''
		ELSE NULL
	END AS [No Activity Since],
	c.CurrencyID AS [Currency],
	gla3.AccountNumber + '' - '' + gla3.AccountName AS [Default AP Account],
	gla4.AccountNumber + '' - '' + gla4.AccountName AS [Default AR Account],
	vst1.SalesTaxName AS [Vendor Sales Tax 1],
	vst2.SalesTaxName AS [Vendor Sales Tax 2],
	glcc.AccountNumber AS [Credit Card Used],
	c.EmailACHToAddress as [Email ACH to Address],
	c.EmailCCToAddress AS [Email Card Info To],
	ap.Address1 AS [Payment Address1],   
	ap.Address2 AS [Payment Address2],   
	ap.Address3 AS [Payment Address3],   
	ap.City AS [Payment City],   
	ap.State AS [Payment State],   
	ap.PostalCode AS [Payment Postal Code],   
	ap.Country AS [Payment Country],
	CASE ISNULL(c.OnHold, 0)
		WHEN 1 THEN ''YES''
		ELSE ''NO''
	END AS [On Hold],
	LTRIM(RTRIM(ISNULL(bm.FirstName + '' '','''')  + ISNULL(bm.LastName,''''))) AS [Billing Manager Name],
	lo.LayoutName as [Default Layout Name],
	CASE
		WHEN c.VCardAccepted = 1 THEN ''YES''
		ELSE ''NO''
	END AS [Accepts VPay]
	,case c.EstimateLaborTaxable
		When 0 Then ''Not Taxable''
		When 1 then ''Taxable By Task''
		When 2 then ''Taxable By Project'' 
		When 3 then ''Taxable By Service'' 
		When 4 then ''Taxable By Title'' 
	end as [Estimate Labor Taxable],
	c.NextProjectNum As [Next Project Number],
	pct.Email AS [Primary Contact Email],
	c.ExpMonth + ''/'' + c.ExpYear AS [Credit Card Exp Date],
	CASE WHEN c.CCReceipts = 1 THEN ''YES'' ELSE ''NO'' END AS [Allow Credit Card Payments Online],	
	CASE WHEN c.ACHReceipts = 1 THEN ''YES'' ELSE ''NO'' END AS [Allow ACH Payments Online],
	CASE ISNULL(c.ACHEnabled, 0)
		WHEN 1 THEN ''YES''
		ELSE ''NO''
	END AS [ACH Enabled],
	c.TwitterID as [Twitter ID],
	--Client data
	cm.ARAmt as [AR Amount],
	cm.IncomeAmount as [Income Amount],
	CASE ISNULL(cm.IncomeAmount, 0)
		WHEN 0 THEN 0
		ELSE cm.ARAmt / (cm.IncomeAmount / 365) 
	end as [Collection Period]
	,CASE 
		WHEN c.DoNotUse = 1 THEN ''YES'' 
		ELSE ''NO'' 
	END AS [Do not use for Projects or Project Requests]
	--vendor data
	,cm.TotalPurchases as [Total Purchases]
	,cm.YearPurchases as [Purchases this year]
	,cm.UnpaidBalance as [Unpaid Balance]
	,cm.ExpenseAmt as [Expense Amount]
	,cm.APAmt as [AP Amount]
	,CASE ISNULL(cm.ExpenseAmt, 0)
		WHEN 0 THEN 0
		ELSE cm.APAmt / (cm.ExpenseAmt / 365) 
	end as [Payment Period]
	,c.NextCampaignNum As [Next Campaign Number]
	,LTRIM(RTRIM(ISNULL(defaultAPApprover.FirstName + '' '','''')  + ISNULL(defaultAPApprover.LastName,''''))) AS [Default Approver Person]
	,ISNULL(LTRIM((SELECT STUFF((SELECT '', '' + GLCompanyName 
              FROM tGLCompany glc (NOLOCK)
			  INNER JOIN tGLCompanyAccess glca (NOLOCK) ON glc.GLCompanyKey = glca.GLCompanyKey AND glca.Entity = ''tCompany''
		      WHERE glca.EntityKey = c.CompanyKey
			  ORDER BY glc.GLCompanyName
              FOR XML PATH('''')) ,1,1,''''))), '''') AS [Access Restrictions]
	,ba.BankAccountType as [Bank Account Type]
	,atc.AvalaraTaxCode as [Avalara Tax Code]
	,atc.Description as [Avalara Tax Code Description]
	,c.AvalaraTaxExemptReason as [Avalara Tax Exempt Reason]
	,Case c.RequireCommentsOnTime When 1 then ''YES'' else ''NO'' end as [Require Comments on Time Entries]
	,Case c.UseAltAddress When 1 then ''YES'' else ''NO'' end as [Use Alternate Address for 1099]
FROM tCompany c (NOLOCK)  
	LEFT OUTER JOIN tCompanyType ct (NOLOCK) ON c.CompanyTypeKey = ct.CompanyTypeKey  
	LEFT OUTER JOIN tCompany pc (NOLOCK) ON c.ParentCompanyKey = pc.CompanyKey  
	LEFT OUTER JOIN tUser u (NOLOCK) ON c.AccountManagerKey = u.UserKey 
	LEFT OUTER JOIN tUser upm (NOLOCK) ON c.ProjectManagerKey = upm.UserKey       
	LEFT OUTER JOIN tUser pct (NOLOCK) ON c.PrimaryContact = pct.UserKey  
	LEFT OUTER JOIN tUser owner (NOLOCK) ON c.ContactOwnerKey = owner.UserKey  
	LEFT OUTER JOIN tUser cb (NOLOCK) ON c.CreatedBy = cb.UserKey
	LEFT OUTER JOIN tUser mb (NOLOCK) ON c.ModifiedBy = mb.UserKey
	LEFT OUTER JOIN tUser bc (NOLOCK) ON c.BillingEmailContact = bc.UserKey
	LEFT OUTER JOIN tAddress ad (NOLOCK) ON c.DefaultAddressKey = ad.AddressKey
	LEFT OUTER JOIN tAddress ab (NOLOCK) ON c.BillingAddressKey = ab.AddressKey
	LEFT OUTER JOIN tAddress ap (NOLOCK) ON c.PaymentAddressKey = ap.AddressKey
	LEFT OUTER JOIN tInvoiceTemplate it (NOLOCK) ON c.InvoiceTemplateKey = it.InvoiceTemplateKey
	LEFT OUTER JOIN tEstimateTemplate et (NOLOCK) ON c.EstimateTemplateKey = et.EstimateTemplateKey
	LEFT OUTER JOIN tPaymentTerms pt (NOLOCK) ON c.PaymentTermsKey = pt.PaymentTermsKey
	LEFT OUTER JOIN tItemRateSheet rs (NOLOCK) ON c.ItemRateSheetKey = rs.ItemRateSheetKey
	LEFT OUTER JOIN tTimeRateSheet srs (NOLOCK) ON c.TimeRateSheetKey = srs.TimeRateSheetKey
	LEFT OUTER JOIN tTitleRateSheet tirs (NOLOCK) ON c.TitleRateSheetKey = tirs.TitleRateSheetKey
	LEFT OUTER JOIN tSalesTax st1 (NOLOCK) ON c.SalesTaxKey = st1.SalesTaxKey
	LEFT OUTER JOIN tSalesTax st2 (NOLOCK) ON c.SalesTax2Key = st2.SalesTaxKey
	LEFT OUTER JOIN tSalesTax vst1 (NOLOCK) ON c.VendorSalesTaxKey = vst1.SalesTaxKey
	LEFT OUTER JOIN tSalesTax vst2 (NOLOCK) ON c.VendorSalesTax2Key = vst2.SalesTaxKey
	LEFT OUTER JOIN tTeam t (nolock) ON c.DefaultTeamKey = t.TeamKey
	LEFT OUTER JOIN tActivity lastActivity (NOLOCK) ON c.LastActivityKey = lastActivity.ActivityKey
	LEFT OUTER JOIN tUser lau (NOLOCK) ON lastActivity.AssignedUserKey = lau.UserKey
	LEFT OUTER JOIN tActivity nextActivity (NOLOCK) ON c.NextActivityKey = nextActivity.ActivityKey
	LEFT OUTER JOIN tUser nau (NOLOCK) ON nextActivity.AssignedUserKey = nau.UserKey
	LEFT OUTER JOIN tUser sales (NOLOCK) ON c.SalesPersonKey = sales.UserKey
	LEFT OUTER JOIN tCMFolder folder (NOLOCK) ON c.CMFolderKey = folder.CMFolderKey
	LEFT OUTER JOIN	tSource so (NOLOCK) on c.SourceKey = so.SourceKey
	LEFT OUTER JOIN tActivityType atNext (NOLOCK) ON nextActivity.ActivityTypeKey = atNext.ActivityTypeKey
	LEFT OUTER JOIN tActivityType atLast (NOLOCK) ON lastActivity.ActivityTypeKey = atLast.ActivityTypeKey
	LEFT OUTER JOIN tGLAccount gla (NOLOCK) ON c.DefaultExpenseAccountKey = gla.GLAccountKey
	LEFT OUTER JOIN tGLAccount gla2 (NOLOCK) ON c.DefaultSalesAccountKey = gla2.GLAccountKey
	LEFT OUTER JOIN tGLCompany glc (NOLOCK) ON c.GLCompanyKey = glc.GLCompanyKey
	LEFT OUTER JOIN tGLAccount gla3 (NOLOCK) ON c.DefaultAPAccountKey = gla3.GLAccountKey
	LEFT OUTER JOIN tGLAccount gla4 (NOLOCK) ON c.DefaultARAccountKey = gla4.GLAccountKey
	LEFT OUTER JOIN tGLAccount glcc (nolock) on c.CCAccountKey = glcc.GLAccountKey
	LEFT OUTER JOIN tUser bm (NOLOCK) on c.BillingManagerKey = bm.UserKey
	LEFT OUTER JOIN tLayout lo (NOLOCK) on c.LayoutKey = lo.LayoutKey
	LEFT OUTER JOIN tOffice o (NOLOCK) on c.OfficeKey = o.OfficeKey
	LEFT OUTER JOIN tCompanyMetrics cm (NOLOCK) on c.CompanyKey = cm.CompanyKey
	LEFT OUTER JOIN tUser defaultAPApprover (NOLOCK) ON c.DefaultAPApproverKey = defaultAPApprover.UserKey 
	LEFT OUTER JOIN tBankAccountType ba (NOLOCK) on c.BankAccountTypeKey = ba.BankAccountTypeKey
	LEFT OUTER JOIN tAvalaraTaxCode atc (NOLOCK) ON c.AvalaraTaxCodeKey = atc.AvalaraTaxCodeKey
	LEFT OUTER JOIN tPreference pref (NOLOCK) ON pref.CompanyKey = ISNULL(c.OwnerCompanyKey, c.CompanyKey)



'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptLayoutItemsUpdate]'
GO
IF OBJECT_ID(N'[dbo].[sptLayoutItemsUpdate]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptLayoutItemsUpdate]
	@LayoutReportKey int,
	@ElementID smallint,
	@ParentID smallint,
	@ReportTag varchar(50),
	@Type varchar(50),
	@Name varchar(100),
	@BackColor int,
	@BorderColor int,
	@BorderStyle varchar(50),
	@BorderLeft tinyint,
	@BorderRight tinyint,
	@BorderTop tinyint,
	@BorderBottom tinyint,
	@BorderThickness smallint,
	@Shadow tinyint,
	@X int,
	@Y int,
	@Height int,
	@Width int,
	@Text nvarchar(max),
	@ForeColor int,
	@FontFamily varchar(50),
	@FontSize smallint,
	@FontItalic tinyint,
	@FontBold tinyint,
	@FontUnderline tinyint,
	@TextAlign varchar(50),
	@LineColor int,
	@LineStyle varchar(50),
	@LineWeight tinyint,
	@X1 int,
	@Y1 int,
	@X2 int,
	@Y2 int,
	@CornerRadius smallint,
	@ShapeType varchar(50),
	@ImageAlignment varchar(50),
	@ImageMode varchar(50),
	@ImageData image,
	@DataField varchar(200),
	@ConfigData text,
	@WordWrap tinyint,
	@CanGrow tinyint,
	@CanShrink tinyint,
	@DataType varchar(50),
	@DecimalPlaces smallint,
	@ShowCurrencySymbol tinyint,
	@SuppressZeroRow tinyint,
	@URL nvarchar(512) = null

AS --Encrypt

/*
|| When      Who Rel      What
|| 03/11/10  MFT 10.5.2.0 Created
|| 3/22/10   CRG 10.5.2.0 Added WordWrap, CanGrow, and CanShrink
|| 3/23/10   CRG 10.5.2.0 Added DataType and DecimalPlaces
|| 3/24/10   CRG 10.5.2.0 Added ShowCurrencySymbol
|| 10/13/21  RLS 21.11.14 (574296) & (Deliverable 513) Changed Text to nvarchar(max)
|| 07/12/22  AMP 22.08.14 (593703) Added @SuppressZeroRow, to allow the option to hide the rows on the printed Estimate where the Total Gross is 0.00
|| 06/05/26  GAR 26.07.19 (712815) Added @URL for hyperlink controls

*/

DELETE
FROM
	tLayoutItems
WHERE
	LayoutReportKey = @LayoutReportKey AND
	ElementID = @ElementID

INSERT INTO
	tLayoutItems
	(
		LayoutReportKey,
		ElementID,
		ParentID,
		ReportTag,
		Type,
		Name,
		BackColor,
		BorderColor,
		BorderStyle,
		BorderLeft,
		BorderRight,
		BorderTop,
		BorderBottom,
		BorderThickness,
		Shadow,
		X,
		Y,
		Height,
		Width,
		Text,
		ForeColor,
		FontFamily,
		FontSize,
		FontItalic,
		FontBold,
		FontUnderline,
		TextAlign,
		LineColor,
		LineStyle,
		LineWeight,
		X1,
		Y1,
		X2,
		Y2,
		CornerRadius,
		ShapeType,
		ImageAlignment,
		ImageMode,
		ImageData,
		DataField,
		ConfigData,
		WordWrap,
		CanGrow,
		CanShrink,
		DataType,
		DecimalPlaces,
		ShowCurrencySymbol,
		SuppressZeroRow,
		URL
	)
VALUES
	(
		@LayoutReportKey,
		@ElementID,
		@ParentID,
		@ReportTag,
		@Type,
		@Name,
		@BackColor,
		@BorderColor,
		@BorderStyle,
		@BorderLeft,
		@BorderRight,
		@BorderTop,
		@BorderBottom,
		@BorderThickness,
		@Shadow,
		@X,
		@Y,
		@Height,
		@Width,
		@Text,
		@ForeColor,
		@FontFamily,
		@FontSize,
		@FontItalic,
		@FontBold,
		@FontUnderline,
		@TextAlign,
		@LineColor,
		@LineStyle,
		@LineWeight,
		@X1,
		@Y1,
		@X2,
		@Y2,
		@CornerRadius,
		@ShapeType,
		@ImageAlignment,
		@ImageMode,
		@ImageData,
		@DataField,
		@ConfigData,
		@WordWrap,
		@CanGrow,
		@CanShrink,
		@DataType,
		@DecimalPlaces,
		@ShowCurrencySymbol,
		@SuppressZeroRow,
		@URL
	)
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spRpt1099Detail]'
GO
IF OBJECT_ID(N'[dbo].[spRpt1099Detail]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spRpt1099Detail]
(
	@CompanyKey int,
	@MinAmount money,
	@StartDate smalldatetime,
	@EndDate smalldatetime,
	@GLCompanyKey INT = -1,		-- -1 All, 0 Blank or NULL, >0 valid GLCompany
	@UserKey int = null,
	@IncludeCCPayments int = NULL --CC Payments get reported on 1099-K by CC company
)

AS
--Encrypt

/*
|| When     Who Rel  What
|| 01/29/08 GHL 8.503 (20133) Take >= @MinAmount instead of > @MinAmount 
|| 10/27/08 GHL 10.011 (34982) Added GLCompanyKey param for 1099 reporting
|| 03/17/09 MFT 10.021  (40077) Added Exclude1099
|| 02/1/11  GWG 10.540 Fixed the addition of exclude 1099 was not exculding vendors where exclude from 1099 was putting them under the limit
|| 04/13/12 GHL 10.555  Added UserKey for UserGLCompanyAccess
|| 05/11/12 GHL 10.556 (142929) Added 1099 for credit cards
|| 01/09/14 GHL 10.576 (202119) Credit cards are payments
|| 03/04/14 GHL 10.578 Added conversion to home currency
|| 03/24/14 RLB 10.578 (203504) Added Exclude1099 on CC to the voucher cc calculation
|| 01/08/18 MFT 18.100 (379691) #tmpPayment.CheckNumber enlarged to 100 to accomodate ccc.InvoiceNumber
|| 01/07/20 MFT 20.020 (495245) #tmpPayment.EINNumber enlarged to 100 (!)
|| 10/15/20 MFT 20.110 (506409) Removed CC payments by default
|| 01/26/20 MFT 21.010 (545666) Put in override to use Vendor''s PaymentAddressKey over DefaultAddressKey
|| 06/23/21 MFT 21.060 (538227) Added options to exclude VCard & ACH Payments
|| 09/28/23 MCM 23.010 (628804) Added #PaymentTypes so we can search by paymentTypes
|| 09/16/24 RLB 24.10.20 (663456) Added DBA Data
|| 05/15/26 AMP 26.05.17 (720174) Added option to use company main address instead of pay to address
*/

-- 
-- CREATE TABLE #PaymentTypes (PaymentType int NULL)
Declare @HasPaymentTypes int
SET @HasPaymentTypes = 0
SELECT @HasPaymentTypes = Count(*)  From #PaymentTypes

Declare @RestrictToGLCompany int

Select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0)
	from tUser u (nolock)
	inner join tPreference p (nolock) on p.CompanyKey = ISNULL(u.OwnerCompanyKey, u.CompanyKey)
	Where u.UserKey = @UserKey

select @RestrictToGLCompany = isnull(@RestrictToGLCompany, 0)

create table #tmpPayment (
    PaymentKey int null
	,PaymentDetailKey int null
	,CompanyKey int null
	,VendorKey int null
	,CompanyName varchar(200) null
	,VendorID varchar(50) null
	,DBA varchar(200) null
	,Type1099 smallint null
	,EINNumber varchar(100) null
	,Address1 varchar(100) null
	,Address2 varchar(100) null
	,Address3 varchar(100) null
	,City varchar(100) null
	,State varchar(50) null
	,PostalCode varchar(20) null
	,Country varchar(50) null
	,CheckNumber varchar(100) null
	,PaymentAmount money null
	,PaymentDate smalldatetime null
    ,GPFlag int null		-- General Purpose flag
	,PaymentType varchar(25) null
)

-- First Pass: get all payments against regular vouchers, same as before

insert #tmpPayment(
    PaymentKey 
	,CompanyKey 
	,VendorKey 
	,CompanyName
	,VendorID 
	,DBA
	,Type1099 
	,EINNumber
	,Address1 
	,Address2 
	,Address3 
	,City 
	,State 
	,PostalCode 
	,Country 
	,CheckNumber 
	,PaymentAmount
	,PaymentDate
	,GPFlag  
	,PaymentType
	)
Select
	p.PaymentKey
	,p.CompanyKey
	,p.VendorKey
	,c.CompanyName
	,c.VendorID
	,c.DBA
	,c.Type1099
	,c.EINNumber		
	,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address1 ELSE ad.Address1 END AS Address1	
	,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address2 ELSE ad.Address2 END AS Address2
	,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address3 ELSE ad.Address3 END AS Address3
	,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.City ELSE ad.City END AS City
	,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.State ELSE ad.State END AS State
	,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.PostalCode ELSE ad.PostalCode END AS PostalCode
	,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Country ELSE ad.Country END AS Country	
	,p.CheckNumber
	, ROUND 
		(
			(
			p.PaymentAmount 
			- ISNULL((SELECT SUM(ISNULL(Exclude1099, 0)) FROM tPaymentDetail (nolock) WHERE PaymentKey = p.PaymentKey),0) 
			) 
			* isnull(p.ExchangeRate, 1)
		,2)
		AS PaymentAmount
	,p.PaymentDate
	,0
	,''Payment''
From 
	tPayment p (nolock)
	inner join tCompany c (nolock) on p.VendorKey = c.CompanyKey
	LEFT JOIN tAddress ad (nolock) ON CASE ISNULL(c.PaymentAddressKey, 0) WHEN 0 THEN c.DefaultAddressKey ELSE c.PaymentAddressKey END = ad.AddressKey
	left outer join tAddress d (nolock) ON c.DefaultAddressKey = d.AddressKey
Where 
	PaymentDate	>= @StartDate and
	PaymentDate <= @EndDate	and
	c.Type1099 > 0 and
	p.CompanyKey = @CompanyKey
	AND     (-- case when @GLCompanyKey = ALL
				(@GLCompanyKey = -1 AND 
					(
					@RestrictToGLCompany = 0 OR 
					(@RestrictToGLCompany = 1 AND p.GLCompanyKey IN (SELECT GLCompanyKey FROM tUserGLCompanyAccess (NOLOCK) WHERE UserKey = @UserKey) )
					)
				)
			--case when @GLCompanyKey = X or Blank(0)
			 OR (@GLCompanyKey != -1 AND ISNULL(p.GLCompanyKey, 0) = @GLCompanyKey)
			)
	AND (
			@HasPaymentTypes = 0
			OR
			ISNULL(p.PaymentType, 1) in (SELECT PaymentType from #PaymentTypes)
		)

-- Now remove the payments against credit cards
-- there is a special process by payment detail line for credit cards
update #tmpPayment
set    #tmpPayment.GPFlag = 1
from   tPayment p (nolock)
inner  join tPaymentDetail pd (nolock) on p.PaymentKey = pd.PaymentKey
inner  join tVoucher v (nolock) on pd.VoucherKey = v.VoucherKey
where  #tmpPayment.PaymentKey = p.PaymentKey
and    isnull(v.CreditCard, 0) = 1 

delete #tmpPayment where GPFlag = 1


-- Second Pass: insert payments against credit cards if specifially requested

-- we have to link through tVoucher.BoughtFromKey to get to the vendor
-- NOT the vendor on the payment (which is a vendor like AMEX)
-- no need to check Exclude1099 because there is no Exclude1099 when applying credit cards to payments
IF @IncludeCCPayments = 1
	insert #tmpPayment(
		PaymentKey
		,PaymentDetailKey
		,VendorKey
		,CompanyName
		,VendorID
		,DBA
		,Type1099
		,EINNumber
		,Address1
		,Address2
		,Address3
		,City
		,State
		,PostalCode
		,Country
		,CheckNumber
		,PaymentAmount
		,PaymentDate
		,PaymentType
		)
	select ccc.VoucherKey
		,ccc.VoucherKey
		,ccc.BoughtFromKey
		,c.CompanyName
		,c.VendorID
		,c.DBA
		,c.Type1099
		,c.EINNumber
		,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address1 ELSE ad.Address1 END AS Address1	
		,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address2 ELSE ad.Address2 END AS Address2
		,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address3 ELSE ad.Address3 END AS Address3
		,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.City ELSE ad.City END AS City
		,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.State ELSE ad.State END AS State
		,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.PostalCode ELSE ad.PostalCode END AS PostalCode
		,CASE  ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Country ELSE ad.Country END AS Country	
		,isnull(ccc.InvoiceNumber, ''Credit Card'')
		,ROUND 
			(
				(
				ccc.VoucherTotal  
				- (
							ISNULL((SELECT SUM(ISNULL(Exclude1099, 0)) FROM tVoucherCC vcc (nolock) WHERE vcc.VoucherCCKey = ccc.VoucherKey),0)
							+
							ISNULL((SELECT SUM(ISNULL(Exclude1099, 0)) FROM tVoucherDetail vod (nolock) WHERE vod.VoucherKey = ccc.VoucherKey),0)
					)
				) 
				* isnull(ccc.ExchangeRate, 1)
			,2)
			AS PaymentAmount
		,ccc.InvoiceDate
		,''Credit Card''
	from tVoucher ccc (nolock)
	inner join tCompany c (nolock) on ccc.BoughtFromKey = c.CompanyKey -- this is the real Vendor
	LEFT JOIN tAddress ad (nolock) ON CASE ISNULL(c.PaymentAddressKey, 0) WHEN 0 THEN c.DefaultAddressKey ELSE c.PaymentAddressKey END = ad.AddressKey
	left outer join tAddress d (nolock) ON c.DefaultAddressKey = d.AddressKey
	where ccc.InvoiceDate	>= @StartDate 
	and	  ccc.InvoiceDate <= @EndDate	
	and   c.Type1099 > 0 
	and   ccc.CompanyKey = @CompanyKey 
	and   isnull(ccc.CreditCard, 0) = 1 
	AND     (-- case when @GLCompanyKey = ALL
					(@GLCompanyKey = -1 AND 
						(
						@RestrictToGLCompany = 0 OR 
						(@RestrictToGLCompany = 1 AND ccc.GLCompanyKey IN (SELECT GLCompanyKey FROM tUserGLCompanyAccess (NOLOCK) WHERE UserKey = @UserKey) )
						)
					)
				--case when @GLCompanyKey = X or Blank(0)
				 OR (@GLCompanyKey != -1 AND ISNULL(ccc.GLCompanyKey, 0) = @GLCompanyKey)
				)	

	Delete #tmpPayment Where VendorKey in 
		(Select VendorKey from (
			Select VendorKey, Sum(PaymentAmount) as Amt from #tmpPayment Group By VendorKey ) as tbl
		Where Amt < @MinAmount)

Select * from #tmpPayment

Order By
	VendorID, CheckNumber'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAIAddUpdateProject]'
GO
IF OBJECT_ID(N'[dbo].[spApiAIAddUpdateProject]', 'P') IS NOT NULL
EXEC sp_executesql N'-- Created by GitHub Copilot in SSMS - review carefully before executing

ALTER PROCEDURE [dbo].[spApiAIAddUpdateProject]
    (
        @CompanyKey int,
        @UserKey int,
        @ProjectName nvarchar(100),
        @ProjectNumber varchar(100) = null,
        @ProjectStatusID varchar(50) = null,
        @ProjectTypeName varchar(50) = null,
        @ClientDivisionID varchar(50) = null,
        @ClientProductID varchar(50) = null,
        @OfficeID varchar(50) = null,
        @GLCompanyID varchar(50) = null,
        @ClassID varchar(50) = null,
        @Client nvarchar(500),
        @CopyProjectNumber varchar(100) = null,
        @CopyEstimate tinyint = 1,
        @EstimateInternalApproverUserID varchar(100) = null,
        @AccountManager nvarchar(500) = null,
        @TeamName varchar(50) = null,
        @LeadID varchar(50) = null,
        @ProjectColor varchar(10) = null,
        @ModelYear varchar(10) = null,
        @CampaignID varchar(50) = null,
        @Template tinyint = 0,
        @Opportunity tinyint = 0,
        @ProjectManager nvarchar(500) = null,
        @DoNotCopyAssignments int = 0,
		@EstimateLikeProjectNumber varchar(100) = null

    )
AS --Encrypt

/*
|| When      Who Rel        What
|| 01/21/26  XXX 26.02.15   Created - AI-friendly version of sptProjectCopy that accepts text IDs instead of keys
|| 01/21/26  XXX 26.02.15   Added update capability with security checks (GL Company, assignment, prjAccessAny)
|| 01/21/26  XXX 26.02.15   Added change tracking for updates (returns old/new values)
|| 04/27/26  XXX 26.02.15   Enhanced user lookup to support UserID, Email, or "FirstName LastName"
|| 04/27/26  XXX 26.02.15   Renamed parameters @AccountManagerUserID to @AccountManager, @ProjectManagerUserID to @ProjectManager
|| 05/01/26  CRG 26.05.17   Added UPPER around the lookup values
|| 05/12/26  GRY 26.06.15   Added @EstimateLikeProjectNumber to copy estimate+tasks from a like project on create
|| 05/05/26  CRG 26.05.17   Validated required Project Type field
|| 06/08/26  GAR 26.07.19   (730440) ProjectType can be inherited from copy/template project; validation deferred until after all lookups
|| 05/28/26  AI  26.05.28   spCheckAccess (tProject) on update path replaces inline GL company + assignment checks.
|| 06/18/26  GAR 26.07.19   (730520) Added custom field key so we can get custom fields on the front end.
*/

-- Create temp error table
select * into #errors from tAPIErrorTemplate where 1 = 2

-- Declare variables for looked-up keys
DECLARE @ProjectStatusKey int
DECLARE @ProjectTypeKey int
DECLARE @ClientDivisionKey int
DECLARE @ClientProductKey int
DECLARE @OfficeKey int
DECLARE @GLCompanyKey int
DECLARE @ClassKey int
DECLARE @ClientKey int
DECLARE @RequestKey int
DECLARE @CopyProjectKey int
DECLARE @EstimateInternalApprover int
DECLARE @AccountManagerKey int
DECLARE @TeamKey int
DECLARE @LeadKey int
DECLARE @CampaignKey int
DECLARE @DefaultRetainerKey int
DECLARE @RetainerKey int
DECLARE @ProjectManagerKey int
DECLARE @NewProjectKey int
DECLARE @ErrorCount int
DECLARE @EstimateLikeProjectKey int

-- Security variables
DECLARE @IsUpdate int
DECLARE @ExistingProjectKey int
DECLARE @SecurityGroupKey int
DECLARE @IsAdministrator bit
DECLARE @RestrictToGLCompany int
DECLARE @CheckAssignment int

-- Set defaults
select @RequestKey = null
select @DefaultRetainerKey = null
select @RetainerKey = null
select @IsUpdate = 0
select @ExistingProjectKey = null



-- Check for fatal errors
select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
if @ErrorCount > 0
begin
    select errorType, errorCode, errorMessage, fieldName
    from #errors
    order by errorType desc, fieldName

    drop table #errors
    return -100
end

-- ========================================
-- GET USER SECURITY INFO
-- ========================================

SELECT @SecurityGroupKey = SecurityGroupKey,
       @IsAdministrator = Administrator
FROM tUser (nolock)
WHERE UserKey = @UserKey
  AND CompanyKey = @CompanyKey

if @SecurityGroupKey is null
begin
    insert into #errors (errorType, errorCode, errorMessage, fieldName)
    values (''error'', ''ACCESS_DENIED'', ''User not found or does not belong to this company.'', ''userKey'')

    select errorType, errorCode, errorMessage, fieldName
    from #errors
    order by errorType desc, fieldName

    drop table #errors
    return -103
end

-- Get security settings
select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0)
from tPreference (nolock)
where CompanyKey = @CompanyKey

-- ========================================
-- CHECK IF PROJECT EXISTS (FOR UPDATE)
-- ========================================

if @ProjectNumber is not null and LTRIM(RTRIM(@ProjectNumber)) <> ''''
begin
    select @ExistingProjectKey = ProjectKey
    from tProject (nolock)
    where CompanyKey = @CompanyKey
      and ProjectNumber = @ProjectNumber

    if @ExistingProjectKey is not null
    begin
        -- Project exists - this will be an UPDATE
        select @IsUpdate = 1
        select @NewProjectKey = @ExistingProjectKey

        -- ========================================
        -- APPLY SECURITY CHECKS FOR UPDATE - spCheckAccess (tProject)
        -- ========================================
        DECLARE @AccessOK int
        exec @AccessOK = spCheckAccess @UserKey, @CompanyKey, ''tProject'', @ExistingProjectKey
        if @AccessOK <> 1
        begin
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''error'', ''ACCESS_DENIED'', ''You do not have access to update this project.'', ''projectNumber'')

            select errorType, errorCode, errorMessage, fieldName
            from #errors
            order by errorType desc, fieldName

            drop table #errors
            return -103
        end
    end
end

if @IsUpdate = 0
begin
    -- ========================================
    -- REQUIRED FIELD VALIDATIONS
    -- ========================================

    if @ProjectName is null or LTRIM(RTRIM(@ProjectName)) = ''''
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''REQUIRED_FIELD'', ''Project name is required.'', ''projectName'')
    end

    if @Client is null or LTRIM(RTRIM(@Client)) = ''''
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''REQUIRED_FIELD'', ''Client ID is required.'', ''clientID'')
    end

end

-- Return errors if validation failed
select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
if @ErrorCount > 0
begin
	select errorType, errorCode, errorMessage, fieldName
	from #errors
	order by errorType desc, fieldName

	drop table #errors
	return -100
end

-- Create temp table for change tracking
CREATE TABLE #changes (
    ChangeID int IDENTITY(1,1) PRIMARY KEY,
    fieldName nvarchar(100),
    oldValue nvarchar(500),
    newValue nvarchar(500)
)

-- ========================================
-- LOOKUP CLIENT KEY
-- ========================================

if @Client is not null and LTRIM(RTRIM(@Client)) <> ''''
begin
    -- Try lookup by CustomerID first
    select @ClientKey = CompanyKey
    from tCompany (nolock)
    where OwnerCompanyKey = @CompanyKey
      and UPPER(CustomerID) = UPPER(@Client)
      and Active = 1
      and ActiveClient = 1

    -- If not found, try by CompanyName using LIKE
    if @ClientKey is null
    begin
        select @ClientKey = CompanyKey
        from tCompany (nolock)
        where OwnerCompanyKey = @CompanyKey
          and UPPER(CompanyName) LIKE UPPER(@Client)
          And Active = 1
          and ActiveClient = 1
    end

    if @ClientKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Client not found with ID: '' + @Client, ''clientID'')
    end
end

-- ========================================
-- LOOKUP PROJECT STATUS KEY
-- ========================================

if @ProjectStatusID is not null and LTRIM(RTRIM(@ProjectStatusID)) <> ''''
begin
    select @ProjectStatusKey = ProjectStatusKey
    from tProjectStatus (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(ProjectStatusID) = UPPER(@ProjectStatusID)

    if @ProjectStatusKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Project status not found with ID: '' + @ProjectStatusID, ''projectStatusID'')
    end
end
else
begin
    -- Get default project status
    select top 1 @ProjectStatusKey = ProjectStatusKey
    from tProjectStatus (nolock)
    where CompanyKey = @CompanyKey
      and Active = 1
      and ISNULL(IsDefault, 0) = 1
    order by DisplayOrder

    -- If no default, get first active status
    if @ProjectStatusKey is null
    begin
        select top 1 @ProjectStatusKey = ProjectStatusKey
        from tProjectStatus (nolock)
        where CompanyKey = @CompanyKey
          and Active = 1
        order by DisplayOrder
    end

    if @ProjectStatusKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''No active project status found. Please specify projectStatusID.'', ''projectStatusID'')
    end
end

-- ========================================
-- LOOKUP PROJECT TYPE KEY
-- ========================================

if @ProjectTypeName is not null and LTRIM(RTRIM(@ProjectTypeName)) <> ''''
begin
    select @ProjectTypeKey = ProjectTypeKey
    from tProjectType (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(ProjectTypeName) = UPPER(@ProjectTypeName)

    if @ProjectTypeKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Project type not found with ID: '' + @ProjectTypeName, ''projectTypeName'')
    end
end

-- ========================================
-- LOOKUP GL COMPANY KEY
-- ========================================

if @GLCompanyID is not null and LTRIM(RTRIM(@GLCompanyID)) <> ''''
begin
    select @GLCompanyKey = GLCompanyKey
    from tGLCompany (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(GLCompanyID) = UPPER(@GLCompanyID)

    if @GLCompanyKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''GL Company not found with ID: '' + @GLCompanyID, ''glCompanyID'')
    end
end

-- ========================================
-- LOOKUP OFFICE KEY
-- ========================================

if @OfficeID is not null and LTRIM(RTRIM(@OfficeID)) <> ''''
begin
    select @OfficeKey = OfficeKey
    from tOffice (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(OfficeID) = UPPER(@OfficeID)

    if @OfficeKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Office not found with ID: '' + @OfficeID, ''officeID'')
    end
end

-- ========================================
-- LOOKUP CLIENT DIVISION KEY
-- ========================================

if @ClientDivisionID is not null and LTRIM(RTRIM(@ClientDivisionID)) <> ''''
begin
    select @ClientDivisionKey = ClientDivisionKey
    from tClientDivision (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(DivisionID) = UPPER(@ClientDivisionID)

    if @ClientDivisionKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Client division not found with ID: '' + @ClientDivisionID, ''clientDivisionID'')
    end
end

-- ========================================
-- LOOKUP CLIENT PRODUCT KEY
-- ========================================

if @ClientProductID is not null and LTRIM(RTRIM(@ClientProductID)) <> ''''
begin
    select @ClientProductKey = ClientProductKey
    from tClientProduct (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(ProductID) = UPPER(@ClientProductID)

    if @ClientProductKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Client product not found with ID: '' + @ClientProductID, ''clientProductID'')
    end
end

-- ========================================
-- LOOKUP CLASS KEY
-- ========================================

if @ClassID is not null and LTRIM(RTRIM(@ClassID)) <> ''''
begin
    select @ClassKey = ClassKey
    from tClass (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(ClassID) = UPPER(@ClassID)

    if @ClassKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Class not found with ID: '' + @ClassID, ''classID'')
    end
end

-- ========================================
-- LOOKUP COPY PROJECT KEY
-- ========================================

if @CopyProjectNumber is not null and LTRIM(RTRIM(@CopyProjectNumber)) <> ''''
begin
    select @CopyProjectKey = ProjectKey
    from tProject (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(ProjectNumber) = UPPER(@CopyProjectNumber)

    if @CopyProjectKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Copy project not found with number: '' + @CopyProjectNumber, ''copyProjectNumber'')
    end
end

-- ========================================
-- FALLBACK: INHERIT PROJECT TYPE FROM COPY PROJECT
-- ========================================

-- If no ProjectType was explicitly provided but a copy/template project was given,
-- inherit the ProjectType from that project.
if @IsUpdate = 0 and @ProjectTypeKey is null and @CopyProjectKey is not null
begin
    select @ProjectTypeKey = ProjectTypeKey
    from tProject (nolock)
    where ProjectKey = @CopyProjectKey
      and CompanyKey = @CompanyKey
end

-- ProjectType is required for new projects (after all fallback attempts)
if @IsUpdate = 0 and @ProjectTypeKey is null
begin
    insert into #errors (errorType, errorCode, errorMessage, fieldName)
    values (''error'', ''REQUIRED_FIELD'', ''Project Type is required. Provide projectTypeName or a copyProjectNumber whose project has a Project Type.'', ''projectType'')
end

-- ========================================
-- LOOKUP ESTIMATE LIKE PROJECT KEY
-- ========================================

if @EstimateLikeProjectNumber is not null and LTRIM(RTRIM(@EstimateLikeProjectNumber)) <> ''''
begin
    select @EstimateLikeProjectKey = ProjectKey
    from tProject (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(ProjectNumber) = UPPER(@EstimateLikeProjectNumber)

    if @EstimateLikeProjectKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''warning'', ''NOT_FOUND'', ''Estimate like project not found with number: '' + @EstimateLikeProjectNumber + ''. Estimate will not be copied.'', ''estimateLikeProjectNumber'')
    end
end


-- ========================================
-- LOOKUP TEAM KEY
-- ========================================

if @TeamName is not null and LTRIM(RTRIM(@TeamName)) <> ''''
begin
    select @TeamKey = TeamKey
    from tTeam (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(TeamName) = UPPER(@TeamName)

    if @TeamKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Team not found with ID: '' + @TeamName, ''team'')
    end
end

-- ========================================
-- LOOKUP LEAD KEY
-- ========================================

if @LeadID is not null and LTRIM(RTRIM(@LeadID)) <> ''''
begin
    select @LeadKey = LeadKey
    from tLead (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(LeadID) = UPPER(@LeadID)

    if @LeadKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Lead not found with ID: '' + @LeadID, ''leadID'')
    end
end

-- ========================================
-- LOOKUP CAMPAIGN KEY
-- ========================================

if @CampaignID is not null and LTRIM(RTRIM(@CampaignID)) <> ''''
begin
    select @CampaignKey = CampaignKey
    from tCampaign (nolock)
    where CompanyKey = @CompanyKey
      and UPPER(CampaignID) = UPPER(@CampaignID)

    if @CampaignKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Campaign not found with ID: '' + @CampaignID, ''campaignID'')
    end
end

-- ========================================
-- LOOKUP ESTIMATE INTERNAL APPROVER KEY
-- ========================================

if @EstimateInternalApproverUserID is not null and LTRIM(RTRIM(@EstimateInternalApproverUserID)) <> ''''
begin
    select @EstimateInternalApprover = UserKey
    from tUser (nolock)
    where CompanyKey = @CompanyKey
      and UserID = @EstimateInternalApproverUserID

    if @EstimateInternalApprover is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''warning'', ''NOT_FOUND'', ''Estimate internal approver not found with user ID: '' + @EstimateInternalApproverUserID + ''. Will use default.'', ''estimateInternalApproverUserID'')
    end
end

-- ========================================
-- LOOKUP ACCOUNT MANAGER KEY
-- ========================================

if @AccountManager is not null and LTRIM(RTRIM(@AccountManager)) <> ''''
begin
    -- Try lookup by UserID first
    select @AccountManagerKey = UserKey
    from tUser (nolock)
    where CompanyKey = @CompanyKey
      and UserID = @AccountManager
      and Active = 1

    -- If not found, try by Email
    if @AccountManagerKey is null
    begin
        select @AccountManagerKey = UserKey
        from tUser (nolock)
        where CompanyKey = @CompanyKey
          and UPPER(Email) = UPPER(@AccountManager)
          and Active = 1
    end

    -- If still not found, try by "FirstName LastName"
    if @AccountManagerKey is null
    begin
        select @AccountManagerKey = UserKey
        from tUser (nolock)
        where CompanyKey = @CompanyKey
          and UPPER(LTRIM(RTRIM(FirstName))) + '' '' + UPPER(LTRIM(RTRIM(LastName))) = UPPER(@AccountManager)
          and Active = 1
    end

    -- If still not found after all attempts, log warning
    if @AccountManagerKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''warning'', ''NOT_FOUND'', ''Account manager not found with identifier: '' + @AccountManager + ''. Tried UserID, Email, and Name.'', ''accountManager'')
    end
end

-- ========================================
-- LOOKUP PROJECT MANAGER KEY
-- ========================================

if @ProjectManager is not null and LTRIM(RTRIM(@ProjectManager)) <> ''''
begin
    -- Try lookup by UserID first
    select @ProjectManagerKey = UserKey
    from tUser (nolock)
    where CompanyKey = @CompanyKey
      and UserID = @ProjectManager
      and Active = 1

    -- If not found, try by Email
    if @ProjectManagerKey is null
    begin
        select @ProjectManagerKey = UserKey
        from tUser (nolock)
        where CompanyKey = @CompanyKey
          and UPPER(Email) = UPPER(@ProjectManager)
          and Active = 1
    end

    -- If still not found, try by "FirstName LastName"
    if @ProjectManagerKey is null
    begin
        select @ProjectManagerKey = UserKey
        from tUser (nolock)
        where CompanyKey = @CompanyKey
          and UPPER(LTRIM(RTRIM(FirstName))) + '' '' + UPPER(LTRIM(RTRIM(LastName))) = UPPER(@ProjectManager)
          and Active = 1
    end

    -- If still not found after all attempts, log warning
    if @ProjectManagerKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''warning'', ''NOT_FOUND'', ''Project manager not found with identifier: '' + @ProjectManager + ''. Tried UserID, Email, and Name.'', ''projectManager'')
    end
end

-- ========================================
-- CHECK FOR ERRORS BEFORE PROCEEDING
-- ========================================

select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
if @ErrorCount > 0
begin
    select errorType, errorCode, errorMessage, fieldName
    from #errors
    order by errorType desc, fieldName

    drop table #errors
    return -101
end

-- ========================================
-- UPDATE EXISTING PROJECT OR CREATE NEW
-- ========================================

if @IsUpdate = 1
begin
    -- Capture OLD values before update (with string representations)
    DECLARE @OldProjectName nvarchar(100)
    DECLARE @OldProjectStatusID varchar(50)
    DECLARE @OldProjectStatusName nvarchar(200)
    DECLARE @OldProjectTypeName nvarchar(100)
    DECLARE @OldClientID varchar(75)
    DECLARE @OldClientName nvarchar(200)
    DECLARE @OldDivisionID varchar(50)
    DECLARE @OldDivisionName nvarchar(300)
    DECLARE @OldProductID varchar(50)
    DECLARE @OldProductName nvarchar(300)
    DECLARE @OldOfficeID nvarchar(50)
    DECLARE @OldOfficeName nvarchar(200)
    DECLARE @OldGLCompanyID varchar(50)
    DECLARE @OldGLCompanyName nvarchar(500)
    DECLARE @OldClassID varchar(50)
    DECLARE @OldClassName nvarchar(200)
    DECLARE @OldProjectColor varchar(10)
    DECLARE @OldModelYear varchar(10)
    DECLARE @OldCampaignID varchar(50)
    DECLARE @OldAccountManagerID varchar(100)
    DECLARE @OldAccountManagerName nvarchar(300)
    DECLARE @OldProjectManagerID varchar(100)
    DECLARE @OldProjectManagerName nvarchar(300)
    DECLARE @OldTeamName nvarchar(200)
    DECLARE @OldLeadID int
    DECLARE @OldLeadSubject nvarchar(200)
    DECLARE @OldTemplate tinyint
    DECLARE @OldOpportunity tinyint

    SELECT @OldProjectName = p.ProjectName,
           @OldProjectStatusID = ps.ProjectStatusID,
           @OldProjectStatusName = ps.ProjectStatus,
           @OldProjectTypeName = pt.ProjectTypeName,
           @OldClientID = c.CustomerID,
           @OldClientName = c.CompanyName,
           @OldDivisionID = cd.DivisionID,
           @OldDivisionName = cd.DivisionName,
           @OldProductID = cp.ProductID,
           @OldProductName = cp.ProductName,
           @OldOfficeID = o.OfficeID,
           @OldOfficeName = o.OfficeName,
           @OldGLCompanyID = gl.GLCompanyID,
           @OldGLCompanyName = gl.GLCompanyName,
           @OldClassID = cl.ClassID,
           @OldClassName = cl.ClassName,
           @OldProjectColor = p.ProjectColor,
           @OldModelYear = p.ModelYear,
           @OldCampaignID = ca.CampaignID,
           @OldAccountManagerID = am.UserID,
           @OldAccountManagerName = am.FirstName + '' '' + am.LastName,
           @OldProjectManagerID = pm.UserID,
           @OldProjectManagerName = pm.FirstName + '' '' + pm.LastName,
           @OldTeamName = t.TeamName,
           @OldLeadID = l.LeadID,
           @OldLeadSubject = l.Subject,
           @OldTemplate = p.Template,
           @OldOpportunity = p.Opportunity
    FROM tProject p (nolock)
    LEFT JOIN tProjectStatus ps (nolock) ON p.ProjectStatusKey = ps.ProjectStatusKey
    LEFT JOIN tProjectType pt (nolock) ON p.ProjectTypeKey = pt.ProjectTypeKey
    LEFT JOIN tCompany c (nolock) ON p.ClientKey = c.CompanyKey
    LEFT JOIN tClientDivision cd (nolock) ON p.ClientDivisionKey = cd.ClientDivisionKey
    LEFT JOIN tClientProduct cp (nolock) ON p.ClientProductKey = cp.ClientProductKey
    LEFT JOIN tOffice o (nolock) ON p.OfficeKey = o.OfficeKey
    LEFT JOIN tGLCompany gl (nolock) ON p.GLCompanyKey = gl.GLCompanyKey
    LEFT JOIN tClass cl (nolock) ON p.ClassKey = cl.ClassKey
    LEFT JOIN tCampaign ca (nolock) ON p.CampaignKey = ca.CampaignKey
    LEFT JOIN tUser am (nolock) ON p.AccountManager = am.UserKey
    LEFT JOIN tUser pm (nolock) ON p.ProjectManager = pm.UserKey
    LEFT JOIN tTeam t (nolock) ON p.TeamKey = t.TeamKey
    LEFT JOIN tLead l (nolock) ON p.LeadKey = l.LeadKey
    WHERE p.ProjectKey = @NewProjectKey

    -- UPDATE existing project
    UPDATE tProject
    SET ProjectName = @ProjectName,
        ProjectStatusKey = ISNULL(@ProjectStatusKey, ProjectStatusKey),
        ProjectTypeKey = ISNULL(@ProjectTypeKey, ProjectTypeKey),
        ClientKey = ISNULL(@ClientKey, ClientKey),
        ClientDivisionKey = ISNULL(@ClientDivisionKey, ClientDivisionKey),
        ClientProductKey = ISNULL(@ClientProductKey, ClientProductKey),
        OfficeKey = ISNULL(@OfficeKey, OfficeKey),
        GLCompanyKey = ISNULL(@GLCompanyKey, GLCompanyKey),
        ClassKey = ISNULL(@ClassKey, ClassKey),
        ProjectColor = ISNULL(@ProjectColor, ProjectColor),
        ModelYear = ISNULL(@ModelYear, ModelYear),
        CampaignKey = ISNULL(@CampaignKey, CampaignKey),
        AccountManager = ISNULL(@AccountManagerKey, AccountManager),
        ProjectManager = ISNULL(@ProjectManagerKey, ProjectManager),
        TeamKey = ISNULL(@TeamKey, TeamKey),
        LeadKey = ISNULL(@LeadKey, LeadKey),
        Template = @Template,
        Opportunity = @Opportunity,
        DateUpdated = getutcdate()
    WHERE ProjectKey = @NewProjectKey
      AND CompanyKey = @CompanyKey

    if @@ROWCOUNT = 0
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''GENERAL'', ''Failed to update project.'', ''general'')

        select errorType, errorCode, errorMessage, fieldName
        from #errors
        order by errorType desc, fieldName

        drop table #errors
        drop table #changes
        return -102
    end

    -- Track changes (compare old vs new values)
    -- Get NEW values with string representations
    DECLARE @NewProjectName nvarchar(100)
    DECLARE @NewProjectStatusID varchar(50)
    DECLARE @NewProjectStatusName nvarchar(200)
    DECLARE @NewProjectTypeName nvarchar(100)
    DECLARE @NewClientID varchar(75)
    DECLARE @NewClientName nvarchar(200)
    DECLARE @NewDivisionID varchar(50)
    DECLARE @NewDivisionName nvarchar(300)
    DECLARE @NewProductID varchar(50)
    DECLARE @NewProductName nvarchar(300)
    DECLARE @NewOfficeID nvarchar(50)
    DECLARE @NewOfficeName nvarchar(200)
    DECLARE @NewGLCompanyID varchar(50)
    DECLARE @NewGLCompanyName nvarchar(500)
    DECLARE @NewClassID varchar(50)
    DECLARE @NewClassName nvarchar(200)
    DECLARE @NewProjectColor varchar(10)
    DECLARE @NewModelYear varchar(10)
    DECLARE @NewCampaignID varchar(50)
    DECLARE @NewAccountManagerID varchar(100)
    DECLARE @NewAccountManagerName nvarchar(300)
    DECLARE @NewProjectManagerID varchar(100)
    DECLARE @NewProjectManagerName nvarchar(300)
    DECLARE @NewTeamName nvarchar(200)
    DECLARE @NewLeadID int
    DECLARE @NewLeadSubject nvarchar(200)
    DECLARE @NewTemplate tinyint
    DECLARE @NewOpportunity tinyint

    SELECT @NewProjectName = p.ProjectName,
           @NewProjectStatusID = ps.ProjectStatusID,
           @NewProjectStatusName = ps.ProjectStatus,
           @NewProjectTypeName = pt.ProjectTypeName,
           @NewClientID = c.CustomerID,
           @NewClientName = c.CompanyName,
           @NewDivisionID = cd.DivisionID,
           @NewDivisionName = cd.DivisionName,
           @NewProductID = cp.ProductID,
           @NewProductName = cp.ProductName,
           @NewOfficeID = o.OfficeID,
           @NewOfficeName = o.OfficeName,
           @NewGLCompanyID = gl.GLCompanyID,
           @NewGLCompanyName = gl.GLCompanyName,
           @NewClassID = cl.ClassID,
           @NewClassName = cl.ClassName,
           @NewProjectColor = p.ProjectColor,
           @NewModelYear = p.ModelYear,
           @NewCampaignID = ca.CampaignID,
           @NewAccountManagerID = am.UserID,
           @NewAccountManagerName = am.FirstName + '' '' + am.LastName,
           @NewProjectManagerID = pm.UserID,
           @NewProjectManagerName = pm.FirstName + '' '' + pm.LastName,
           @NewTeamName = t.TeamName,
           @NewLeadID = l.LeadID,
           @NewLeadSubject = l.Subject,
           @NewTemplate = p.Template,
           @NewOpportunity = p.Opportunity
    FROM tProject p (nolock)
    LEFT JOIN tProjectStatus ps (nolock) ON p.ProjectStatusKey = ps.ProjectStatusKey
    LEFT JOIN tProjectType pt (nolock) ON p.ProjectTypeKey = pt.ProjectTypeKey
    LEFT JOIN tCompany c (nolock) ON p.ClientKey = c.CompanyKey
    LEFT JOIN tClientDivision cd (nolock) ON p.ClientDivisionKey = cd.ClientDivisionKey
    LEFT JOIN tClientProduct cp (nolock) ON p.ClientProductKey = cp.ClientProductKey
    LEFT JOIN tOffice o (nolock) ON p.OfficeKey = o.OfficeKey
    LEFT JOIN tGLCompany gl (nolock) ON p.GLCompanyKey = gl.GLCompanyKey
    LEFT JOIN tClass cl (nolock) ON p.ClassKey = cl.ClassKey
    LEFT JOIN tCampaign ca (nolock) ON p.CampaignKey = ca.CampaignKey
    LEFT JOIN tUser am (nolock) ON p.AccountManager = am.UserKey
    LEFT JOIN tUser pm (nolock) ON p.ProjectManager = pm.UserKey
    LEFT JOIN tTeam t (nolock) ON p.TeamKey = t.TeamKey
    LEFT JOIN tLead l (nolock) ON p.LeadKey = l.LeadKey
    WHERE p.ProjectKey = @NewProjectKey

    -- Compare and insert changes
    if ISNULL(@OldProjectName, '''') <> ISNULL(@NewProjectName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''projectName'', @OldProjectName, @NewProjectName)

    if ISNULL(@OldProjectStatusName, '''') <> ISNULL(@NewProjectStatusName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''projectStatus'', @OldProjectStatusName, @NewProjectStatusName)

    if ISNULL(@OldProjectTypeName, '''') <> ISNULL(@NewProjectTypeName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''projectType'', @OldProjectTypeName, @NewProjectTypeName)

    if ISNULL(@OldClientName, '''') <> ISNULL(@NewClientName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''client'', @OldClientName, @NewClientName)

    if ISNULL(@OldDivisionName, '''') <> ISNULL(@NewDivisionName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''clientDivision'', @OldDivisionName, @NewDivisionName)

    if ISNULL(@OldProductName, '''') <> ISNULL(@NewProductName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''clientProduct'', @OldProductName, @NewProductName)

    if ISNULL(@OldOfficeName, '''') <> ISNULL(@NewOfficeName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''office'', @OldOfficeName, @NewOfficeName)

    if ISNULL(@OldGLCompanyName, '''') <> ISNULL(@NewGLCompanyName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''glCompany'', @OldGLCompanyName, @NewGLCompanyName)

    if ISNULL(@OldClassName, '''') <> ISNULL(@NewClassName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''class'', @OldClassName, @NewClassName)

    if ISNULL(@OldProjectColor, '''') <> ISNULL(@NewProjectColor, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''projectColor'', @OldProjectColor, @NewProjectColor)

    if ISNULL(@OldModelYear, '''') <> ISNULL(@NewModelYear, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''modelYear'', @OldModelYear, @NewModelYear)

    if ISNULL(@OldCampaignID, '''') <> ISNULL(@NewCampaignID, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''campaign'', @OldCampaignID, @NewCampaignID)

    if ISNULL(@OldAccountManagerName, '''') <> ISNULL(@NewAccountManagerName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''accountManager'', @OldAccountManagerName, @NewAccountManagerName)

    if ISNULL(@OldProjectManagerName, '''') <> ISNULL(@NewProjectManagerName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''projectManager'', @OldProjectManagerName, @NewProjectManagerName)

    if ISNULL(@OldTeamName, '''') <> ISNULL(@NewTeamName, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''team'', @OldTeamName, @NewTeamName)

    if ISNULL(@OldLeadSubject, '''') <> ISNULL(@NewLeadSubject, '''')
        insert into #changes (fieldName, oldValue, newValue) values (''lead'', @OldLeadSubject, @NewLeadSubject)

    if ISNULL(@OldTemplate, 0) <> ISNULL(@NewTemplate, 0)
        insert into #changes (fieldName, oldValue, newValue) values (''template'', CAST(@OldTemplate as varchar), CAST(@NewTemplate as varchar))

    if ISNULL(@OldOpportunity, 0) <> ISNULL(@NewOpportunity, 0)
        insert into #changes (fieldName, oldValue, newValue) values (''opportunity'', CAST(@OldOpportunity as varchar), CAST(@NewOpportunity as varchar))

    -- ========================================
    -- LOG CHANGES TO tActionLog
    -- ========================================

    -- Only log if there were actual changes
    if exists (select 1 from #changes)
    begin
        DECLARE @ChangeFieldName nvarchar(100)
        DECLARE @ChangeOldValue nvarchar(500)
        DECLARE @ChangeNewValue nvarchar(500)
        DECLARE @ChangeComments nvarchar(4000)
        DECLARE @LogProjectNumber varchar(100)
        DECLARE @CurrentChangeID int
        DECLARE @MaxChangeID int

        -- Get the project number for logging
        select @LogProjectNumber = ProjectNumber
        from tProject (nolock)
        where ProjectKey = @NewProjectKey

        -- Get range of change IDs
        select @CurrentChangeID = MIN(ChangeID), @MaxChangeID = MAX(ChangeID)
        from #changes

        -- Loop through changes using WHILE instead of cursor
        WHILE @CurrentChangeID <= @MaxChangeID
        BEGIN
            -- Get the current change row
            select @ChangeFieldName = fieldName,
                   @ChangeOldValue = oldValue,
                   @ChangeNewValue = newValue
            from #changes
            where ChangeID = @CurrentChangeID

            -- Only process if row exists (handles gaps in identity values)
            if @@ROWCOUNT > 0
            begin
                -- Build human-readable comments based on field name
                if @ChangeFieldName = ''projectName''
                    select @ChangeComments = ''Project Name was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''projectStatus''
                    select @ChangeComments = ''Project Status was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''projectType''
                    select @ChangeComments = ''Project Type was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''client''
                    select @ChangeComments = ''Client was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''clientDivision''
                    select @ChangeComments = ''Client Division was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''clientProduct''
                    select @ChangeComments = ''Client Product was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''office''
                    select @ChangeComments = ''Office was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''glCompany''
                    select @ChangeComments = ''GL Company was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''class''
                    select @ChangeComments = ''Class was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''projectColor''
                    select @ChangeComments = ''Project Color was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''modelYear''
                    select @ChangeComments = ''Model Year was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''campaign''
                    select @ChangeComments = ''Campaign was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''accountManager''
                    select @ChangeComments = ''Account Manager was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''projectManager''
                    select @ChangeComments = ''Project Manager was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''team''
                    select @ChangeComments = ''Team was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''lead''
                    select @ChangeComments = ''Lead was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''
                else if @ChangeFieldName = ''template''
                    select @ChangeComments = ''Template flag was changed from '' + CASE WHEN @ChangeOldValue = ''1'' THEN ''Yes'' ELSE ''No'' END + '' to '' + CASE WHEN @ChangeNewValue = ''1'' THEN ''Yes'' ELSE ''No'' END
                else if @ChangeFieldName = ''opportunity''
                    select @ChangeComments = ''Opportunity flag was changed from '' + CASE WHEN @ChangeOldValue = ''1'' THEN ''Yes'' ELSE ''No'' END + '' to '' + CASE WHEN @ChangeNewValue = ''1'' THEN ''Yes'' ELSE ''No'' END
                else
                    select @ChangeComments = @ChangeFieldName + '' was changed from "'' + ISNULL(@ChangeOldValue, ''(blank)'') + ''" to "'' + ISNULL(@ChangeNewValue, ''(blank)'') + ''"''

                -- Insert into tActionLog using sptActionLogInsert
                DECLARE @Now smalldatetime = getutcdate()

                EXEC sptActionLogInsert
                    @Entity = ''Project'',
                    @EntityKey = @NewProjectKey,
                    @CompanyKey = @CompanyKey,
                    @ProjectKey = @NewProjectKey,
                    @Action = ''Field Changed'',
                    @ActionDate = @Now, 
                    @ActionBy = @UserKey,
                    @Comments = @ChangeComments,
                    @Reference = @LogProjectNumber,
                    @SourceCompanyID = NULL,
                    @UserKey = @UserKey,
                    @CampaignKey = @CampaignKey
            end

            -- Move to next change
            select @CurrentChangeID = @CurrentChangeID + 1
        END
    end
end
else
begin
    -- CREATE new project via sptProjectCopy

    EXEC sptProjectCopy
        @UserKey = @UserKey,
        @ProjectName = @ProjectName,
        @ProjectNumber = @ProjectNumber,
        @CompanyKey = @CompanyKey,
        @ProjectStatusKey = @ProjectStatusKey,
        @ProjectTypeKey = @ProjectTypeKey,
        @ClientDivisionKey = @ClientDivisionKey,
        @ClientProductKey = @ClientProductKey,
        @OfficeKey = @OfficeKey,
        @GLCompanyKey = @GLCompanyKey,
        @ClassKey = @ClassKey,
        @ClientKey = @ClientKey,
        @RequestKey = @RequestKey,
        @CopyProjectKey = @CopyProjectKey,
        @CopyEstimate = @CopyEstimate,
        @CopyFrom = 0,
        @EstimateInternalApprover = @EstimateInternalApprover,
        @AccountManager = @AccountManagerKey,
        @TeamKey = @TeamKey,
        @LeadKey = @LeadKey,
        @ProjectColor = @ProjectColor,
        @ModelYear = @ModelYear,
        @CampaignKey = @CampaignKey,
        @DefaultRetainerKey = @DefaultRetainerKey,
        @Template = @Template,
        @Opportunity = @Opportunity,
        @RetainerKey = @RetainerKey,
        @Retainer = 0,
        @IsLegacy = 0,
        @ProjectManager = @ProjectManagerKey,
        @DoNotCopyAssignments = @DoNotCopyAssignments,
        @oIdentity = @NewProjectKey OUTPUT

    -- Check return value from sptProjectCopy
    DECLARE @ReturnValue int
    select @ReturnValue = @@ROWCOUNT

    if @NewProjectKey is null or @NewProjectKey <= 0
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''GENERAL'', ''Failed to create project. Please check input parameters.'', ''general'')

        select errorType, errorCode, errorMessage, fieldName
        from #errors
        order by errorType desc, fieldName

        drop table #errors
        return -102
    end

	 -- Copy tasks + estimate from like project when specified and no copy source was used
    if @EstimateLikeProjectKey is not null and @CopyProjectKey is null
    begin
        exec sptProjectCopyTasks
            @ProjectKey = @NewProjectKey,
            @CopyProjectKey = @EstimateLikeProjectKey,
            @CopyEstimate = 1,
            @UserKey = @UserKey,
            @DoNotCopyAssignments = 1
    end

end

-- ========================================
-- RETURN SUCCESS WITH WARNINGS (IF ANY)
-- ========================================

-- Return any warnings
select errorType, errorCode, errorMessage, fieldName
from #errors
where errorType = ''warning''

-- Get the project details (created or updated)
select p.ProjectKey as projectKey,
       p.ProjectNumber as projectNumber,
       p.ProjectName as projectName,
       p.CompanyKey as companyKey,
       c.CustomerID as clientID,
       c.CompanyName as clientName,
       ps.ProjectStatusID as projectStatusID,
       ps.ProjectStatus as projectStatusName,
       pt.ProjectTypeName as projectTypeName,
       p.Active as active,
       p.CreatedDate as dateAdded,
       p.DateUpdated as dateUpdated,
       p.CustomFieldKey as customFieldKey,
       @IsUpdate as wasUpdated
from tProject p (nolock)
left join tCompany c (nolock) on p.ClientKey = c.CompanyKey
left join tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
left join tProjectType pt (nolock) on p.ProjectTypeKey = pt.ProjectTypeKey
where p.ProjectKey = @NewProjectKey

-- Return change tracking (only for updates)
if @IsUpdate = 1
begin
    select fieldName,
           oldValue,
           newValue
    from #changes
    order by fieldName
end

drop table #errors
drop table #changes
return 1



'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptImportExportSeedApiDoco]'
GO
IF OBJECT_ID(N'[dbo].[sptImportExportSeedApiDoco]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptImportExportSeedApiDoco]

AS
/*
 exec sptImportExportSeedApiDoco
|| When			Who Rel      What

|| 01/05/24     AMP 24.01.21 (636149) Modified the Credit Card Charge for Item - If the pref is required the field will be displayed in the required field list on the import screen, also made Net Cost always a required field
|| 01/19/24     CRG 24.02.19 (655377) Added Weekly Hours to the Task Import
|| 02/21/24     CRG 24.03.17 (664040) Added CalendarApprover to the Employee Import
|| 02/21/24     RLB 24.03.17 (664982) adding Invoice Label
|| 03/20/24     MCM 24.04.xx (658620) Adding Hourly Cost for Service Rate Sheet
|| 04/05/24     MCM 24.05.19 (669368) Adding get by id for station and publication and searhFor PO and IO
|| 04/24/24		MCM 24.05.19 (670663) Adding currencyID to the glAccounts import
|| 08/08/24		MCM 24.09.x  (676638) Adding Retainer custom field entity
|| 08/20/24		MCM 24.09.x  (681078) Adding GL Company Exchange rate to the JE detail api
|| 08/21/24     GAR 24.10.x  (680406) Adding Avalara Tax Code to Services
|| 10/09/24     GAR 24.11.x  (684268) Adding a new endpoint for updating staff rates on projects
|| 11/19/24		MCM 24.12.x  (688332) Fixing the startdate and endDate for the timesheet to be header
|| 12/09/24     MCM 25.01.x  (682120) Added toCurrencyID to the Currency import
|| 12/17/24     MCM 24.17.x  (689256) Updated the GLCompanyKey to be GLCompanyID
|| 12/18/24		MCM 25.01.x  (689448) Added notes to the todo import
|| 01/10/25		MCM 25.02.x  (688779) Added additional fields for the view import
|| 03/04/25		MCM 25.04.x  (694525) Added custom fields to the activities import
|| 03/06/25		MCM 25.04.x  (692694) Added split billing to the project import
|| 04/16/25	    MCM 25.05.x  (696669) Added ability to update Credit Card Connector (Transactions aka ccEntry)
|| 05/14/25		MCM 25.06.x  (701811) Added the GL CompanyKey to the credit card connector
|| 05/30/25		MCM 25.06.x	 (702845) Added conversation search by projectNumber
|| 06/25/25		MCM 25.07.x  (700522) Added GL Budget export view
|| 07/11/25     MCM 25.08.x  (700243) Added HeaderID for PO, IO, BO
|| 08/11/25     MCM 25.09.x  (706891) Added ProjectColor to the Client import
|| 08/12/25		MCM 25.09.x  (705830) Added AssignedUserID to the todo import
|| 09/04/25     MCM 25.10.x  (709191) Added Address Name to client/company/vendor import
|| 10/07/25		MCM 25.11.x  (711735) Added Avalara Tax Code to project import
|| 10/10/25		MCM 25.11.x  (710932) Updated ToDo to allow updates and added completed field
|| 10/10/25		MCM 25.11.x  (709479) Updated timesheets with complete and reject options.
|| 12/31/25		MCM 26.01.x  (694595) Added Publication ID and Staion ID as conditionally required using SystemSettingFieldName
|| 01/14/26		MCM 26.02.x  (719575) Added Request ID to the Campaign import
|| 01/27/26		MCM 26.02.x  (719809) Added sendNotifications to the Task Import
|| 03/12/26		MCM 26.04.x  (723933) Added billable to the IO import
|| 03/18/26		MCM 26.04.x  (724666) Removed duplicate columns in the viewKey section
|| 03/24/26		MCM 26.04.x  (638176) Added Billing Schedule items
|| 04/14/26		MCM 26.05.x  (725995) Added comments to the credit card charge import
|| 04/21/26     GAR 26.05.x  (726790) Change the glCompanyKey in the Conversations import to glCompanyID
|| 05/28/26     AMP 26.06.14 (729025) Added Status to Project Requests
|| 07/08/26     MAS 26.07.19 (732561) Documented Media Plans atomic per-line validation error responses
*/
BEGIN
/*************************************************************************************************************************
tImportExport and tImportExportDetail
**************************************************************************************************************************/
delete tImportExport
delete tImportExportDetail

DECLARE @ActivityKey int = 39
DECLARE @ActivityTypeKey int = 49
DECLARE @AddressKey int = 79
DECLARE @AvalaraTaxCodeKey int = 126
DECLARE @BillingGroupKey int = 61
DECLARE @BillingScheduleKey int = 135
DECLARE @BOKey int = 77
DECLARE @CampaignKey int = 124
DECLARE @ClientKey int = 71
DECLARE @ClientPaymentsKey int = 19  --To be deprecated 1/1/2020... Use Receipts instead
DECLARE @CompanyKey int = 37
DECLARE @ContactKey int = 1
DECLARE @ConversationKey int = 116
DECLARE @ConversationSearchKey int = 131
DECLARE @CreditCardCharge int = 57
DECLARE @CreditCardConnector int = 62
DECLARE @CurrencyRateKey int = 63
DECLARE @DeliverableKey int = 80
DECLARE @EmployeeKey int = 3
DECLARE @EstimateKey int = 16
DECLARE @ExpenseReportKey int = 22
DECLARE @GLAccountKey int = 6
DECLARE @GLBudget int = 60
DECLARE @InvoiceKey int = 11
DECLARE @ItemRateSheetKey int = 59
DECLARE @IOKey int = 34
DECLARE @JEKey int = 24
DECLARE @LeadKey int = 36
DECLARE @MediaPlanKey int select @MediaPlanKey = 111
DECLARE @MediaPlanReleaseKey int select @MediaPlanReleaseKey = 113
DECLARE @MediaPlanVoucherKey int select @MediaPlanVoucherKey = 112
DECLARE @OpportunitiesKey int = 38
DECLARE @POKey int = 18
DECLARE @ProjectKey int = 13
DECLARE @ProjectStaffRatesKey int = 127
DECLARE @ProjectStatusCodeKey int = 27
DECLARE @ProjectRequestKey int = 76
DECLARE @PublicationKey int = 120
DECLARE @ReceiptsKey int = 115
DECLARE @ReportKey int =  109
DECLARE @RetainerKey int = 118
DECLARE @ServiceRateSheetKey int = 58
DECLARE @StationKey int = 122
DECLARE @TaskKey int = 69
DECLARE @TimeSheetKey int = 21
DECLARE @TimeSheetTimeKey int = 107
DECLARE @TimeSheetCompleteKey int = 132
DECLARE @TimeSheetRejectKey int = 133
DECLARE @TimeKey int = 72
DECLARE @ToDoKey int = 84
DECLARE @VendorKey int = 70
DECLARE @VendorPaymentKey int = 20
DECLARE @ViewKey int = 78
DECLARE @VoucherKey int = 12



INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ContactKey, N''Contacts'', N''contacts'', NULL, NULL, N''Contact'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@EmployeeKey, N''Employees'', N''employees'', NULL, NULL, N''Employees'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (4, N''Expense Report Items'', N''expensereportitems'', NULL, NULL, NULL, N''vExport_ExpenseReportItem'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (5, N''Purchase Items'', N''purchaseitem'', NULL, NULL, NULL, N''vExport_PurchaseItem'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@GLAccountKey, N''GL Accounts'', N''glaccounts'', NULL, NULL, NULL, N''vExport_GLAccount'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (7, N''Payment Terms'', N''paymentterms'', NULL, NULL, NULL, N''tPaymentTerms'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (8, N''Sales Tax'', N''salestaxrates'', NULL, NULL, NULL, N''vExport_SalesTax'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (9, N''Services'', N''services'', NULL, NULL, NULL, N''vExport_Service'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (10, N''Billing Items'', N''billingitems'', NULL, NULL, NULL, N''vExport_WorkType'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@InvoiceKey, N''Client Invoices'', N''invoices'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@VoucherKey, N''Vendor Invoices'', N''vouchers'', 1, N''details'', N''PO_Header|PO_Detail'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ProjectKey, N''Projects'', N''projects'', NULL, NULL, N''Project'', ''vExport_Project'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (16, N''Estimates'', N''estimates'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@POKey, N''Purchase Orders'', N''purchaseorders'', 1, N''details'', N''PO_Header|PO_Detail'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ClientPaymentsKey, N''Client Payments'', N''clientpayments'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@VendorPaymentKey, N''Vendor Payments'', N''vendorpayments'', 1, N''details'',  NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@TimeSheetKey, N''Timesheets'', N''timesheets'', 1, N''time'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ExpenseReportKey, N''Expense Reports'', N''expensereports'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (23, N''Misc Project Costs'', N''misccosts'', NULL, NULL, NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@JEKey, N''Journal Entries'', N''journalentries'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (25, N''Project Types'', N''projecttypes'', NULL, NULL, NULL, N''tProjectType'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ProjectStatusCodeKey, N''Project Status'', N''projectstatuscodes'', NULL, NULL, NULL, N''tProjectStatus'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (28, N''Departments'', N''departments'', NULL, NULL, NULL, N''tDepartment'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (29, N''Project Billing Status'', N''projectbillingcodes'', NULL, NULL, NULL, N''tProjectBillingStatus'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (31, N''Broadcast Items'', N''broadcastitems'', NULL, NULL, NULL, N''vExport_BroadcastItem'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (32, N''Print Items'', N''printitems'', NULL, NULL, NULL, N''vExport_PrintItem'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (33, N''GL Companies'', N''glcompanies'', NULL, NULL, NULL, N''vExport_GLCompany'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@IOKey, N''Insertion Orders'', N''insertionorders'', 1, N''details'', N''PO_Header|PO_Detail'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@LeadKey, N''Leads'', N''leads'', NULL, NULL, N''Company|Contact|Lead'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@CompanyKey, N''Companies'', N''companies'', NULL, NULL, N''Company'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@OpportunitiesKey, N''Opportunities'', N''opportunities'', NULL, NULL, N''Lead'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ActivityKey, N''Activities'', N''activities'', NULL, NULL, ''Activity'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (40, N''Report Groups'', N''reportgroups'', NULL, NULL, NULL, N''tReportGroup'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (41, N''Opportunity Stages'', N''opportunitystages'', NULL, NULL, NULL, N''tLeadStage'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (42, N''Opportunity Status'', N''opportunitystatus'', NULL, NULL, NULL, N''tLeadStatus'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (43, N''Opportunity Outcome'', N''opportunityoutcome'', NULL, NULL, NULL, N''tLeadOutcome'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (44, N''Company Types'', N''companytypes'', NULL, NULL, NULL, N''tCompanyType'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (45, N''Meeting Types'', N''calendartypes'', NULL, NULL, NULL, N''tCalendarType'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (46, N''Calendar Resources'', N''calendarresources'', NULL, NULL, NULL, N''tCalendarResource'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (48, N''Sources'', N''sources'', NULL, NULL, NULL, N''tSource'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ActivityTypeKey, N''Conversation Types'', N''activitytypes'', NULL, NULL, NULL, N''tActivityType'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (50, N''Payment Methods'', N''paymentmethods'', NULL, NULL, NULL, N''tCheckMethod'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (51, N''Write Off Reasons'', N''writeoffreasons'', NULL, NULL, NULL, N''tWriteOffReason'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (52, N''Standard Text'', N''standardtext'', NULL, NULL, NULL, N''tStandardText'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (53, N''Media Markets'', N''mediamarkets'', NULL, NULL, NULL, N''tMediaMarket'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (54, N''GL Classes'', N''glclasses'', NULL, NULL, NULL, N''vExport_GLClass'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (55, N''Offices'', N''offices'', NULL, NULL, NULL, N''tOffice'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (56, N''Teams'', N''teams'', NULL, NULL, NULL, N''vExport_Team'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@CreditCardCharge, N''Credit Card Charges'', N''creditcardcharges'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ServiceRateSheetKey, N''Service Rate Sheets'', N''serviceratesheets'', 1, N''details'', NULL, N''vExport_ServiceRateSheet'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ItemRateSheetKey, N''Item Rate Sheets'', N''itemratesheets'', 1, N''details'', NULL, N''vExport_ItemRateSheet'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@GLBudget, N''Financial Budgets'', N''financialbudgets'', 1, N''details'', NULL, N''vExport_GLFinancialBudget'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@BillingGroupKey, N''Billing Groups'', N''billinggroups'', NULL, NULL, NULL, N''vExport_BillingGroup'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@CreditCardConnector, N''Credit Card Connector'', N''creditcardtransactions'', NULL, NULL, NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@CurrencyRateKey, N''Currency Rates'', N''currencyrates'', NULL, NULL, NULL, N''vExport_CurrencyRate'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [Condition]) VALUES (64, N''Titles'', N''titles'', NULL, NULL, NULL, N''vExport_Title'', 1, NULL, 1, 1, 0, 0, N''System.hasCustomization(''''billingtitles'''')'')
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [Condition]) VALUES (65, N''Title Rate Sheets'', N''titleratesheets'', 1, N''details'', NULL, N''vExport_TitleRateSheet'', 1, NULL, 1, 1, 0, 0, N''System.hasCustomization(''''billingtitles'''')'')
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (67, N''Request Reject Reasons'', N''requestrejectreasons'', NULL, NULL, NULL, N''tRequestRejectReason'', 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@TaskKey, N''Tasks'', N''tasks'', 1, N''assignments'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@VendorKey, N''Vendors'', N''vendors'', NULL, NULL, N''Company'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ClientKey, N''Clients'', N''clients'', NULL, NULL, N''Company'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@TimeKey, N''Time'', N''time'', NULL, NULL, NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (73, N''Project Spec Sheets'', N''projectspecsheets'', NULL, NULL, N''Spec'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (74, N''Request Spec Sheets'', N''requestspecsheets'', NULL, NULL, N''Spec'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (75, N''Labor Budgets'', N''laborbudgets'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ProjectRequestKey, N''Project Request'', N''projectrequests'', NULL, NULL, N''RequestDef'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@BOKey, N''Broadcast Orders'', N''broadcastorders'', 1, N''details'', ''PO_Header|PO_Detail'', NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ViewKey, N''View'', N''view'', NULL, Null, NULL, NULL, 1, ''Used to import data into the tReport table'', 0, 0, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@AddressKey, N''Address'', N''address'', NULL, Null, NULL, NULL,1, ''Used to add an address to a company, vendor, or client'', 0, 0, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@DeliverableKey, N''Deliverables'', N''deliverables'', NULL, Null, N''Deliverable|DeliverableType'', NULL,1, NULL, 0, 0, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ToDoKey, N''To Do'', N''todos'', NULL, Null, N''To Do'', NULL,1, NULL, 1, 0, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ProjectStaffRatesKey, N''Project Staff Rates'', N''projectstaffrates'', NULL, Null, N''Project Staff Rates'', NULL,1, ''Used to update the staff rates on a project when the Get Rate From is Project User'', 1, 0, 1, 0)
--Just for API doco
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (100, N''Opportunities/List'', N''opportunities/list'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (101, N''Activities/Search'', N''activities/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (102, N''Companies/Search'', N''companies/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (103, N''Contacts/Search'', N''contacts/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (104, N''Employees/Search'', N''employees/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
--INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (105, N''JournalEntries/Search'', N''journalentries/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (106, N''Leads/Search'', N''leads/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@TimeSheetTimeKey, N''Timesheets/Time'', N''timesheets/time'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (108, N''Vendors/Search'', N''vendors/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@ReportKey, N''Reports'', N''reports'', NULL, Null, NULL, NULL,1 ,'''' , 1, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@MediaPlanKey, N''Media Plans'', N''mediaplans'', 1, ''details'', NULL, NULL,1 ,N''Create (POST) or update (PUT) a media plan and its detail lines. Validation is atomic: if any detail line fails validation, the entire request is rejected with HTTP 400 and nothing is saved. On failure the errors array contains one message per invalid line, each prefixed with the line number and SpotLinkID (for example: Line 2 (SpotLinkID 7308462): Invalid Item.). Possible line messages are: Invalid Item. (itemID does not match an active item for the company), Invalid Vendor. (vendorID was not found), Inactive vendor (the vendorID exists but is not active), and Invalid Station/Publication. (the stationID is not valid for the given vendor and item). Correct every reported line and resubmit; the plan is saved only when all lines are valid.'' , 1, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@MediaPlanVoucherKey, N''Media Plan Vendor Invoices'', N''mediaplanvouchers'', 1, ''details'', NULL, NULL,1 ,'''' , 1, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@ReceiptsKey, N''Receipts'', N''receipts'', 1, N''details'', NULL, NULL, 1, NULL, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@MediaPlanReleaseKey, N''Media Plan Release'', N''mediaplanrelease'', NULL, Null, NULL, NULL,1 ,'''' , 0, 0, 1, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@RetainerKey, N''Retainer'', N''retainer'', NULL, Null, N''Retainer'', NULL,1 ,'''' , 1, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@PublicationKey, N''Publication'', N''publications'', NULL, Null, NULL, NULL,1 ,'''' , 1, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@StationKey, N''Station'', N''stations'', NULL, Null, NULL, NULL,1 ,'''' , 1, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@CampaignKey, N''Campaign'', N''campaigns'', 1, N''details'', ''Campaign'', NULL,1 ,'''' , 1, 1, 1, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@ConversationKey, N''Conversation'', N''conversations'', NULL, Null, ''Activity'', NULL,1 ,''Used for import conversations.'' , 1, 1, 1, 0, 0)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@ConversationSearchKey, N''Conversations/Search'', N''Conversations/search'', NULL, Null, NULL, NULL,1, '''', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly], [Condition]) VALUES (@AvalaraTaxCodeKey, N''AvalaraTaxCodes'', NULL, NULL, Null, NULL, ''tAvalaraTaxCode'', 1 ,''Used for importing and exporting Avalara Tax Codes.'' , 0, 0, 0, 0, 1, N''System.hasCustomization(''''avalara'''')'')
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@TimeSheetCompleteKey, N''Timesheets/Complete'', N''timesheets/complete'', NULL, Null, NULL, NULL,1, ''Used for submitting/approving the timesheet.  If user has right to approve it will be approved, otherwise, it will be submitted'', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete], [DocumentationOnly]) VALUES (@TimeSheetRejectKey, N''Timesheets/Reject'', N''timesheets/reject'', NULL, Null, NULL, NULL,1, ''Used for reject a timesheet.'', 0, 0, 0, 0, 1)
INSERT [dbo].[tImportExport] ([ImportExportKey], [ImportExportID], [Endpoint], [IsParentChild], [ChildNode], [CustomFieldEntity], [TableName], [Active], [Description], [Get], [Post], [Put], [Delete]) VALUES (@BillingScheduleKey, N''Billing Schedule'', N''billingSchedule'', NULL, Null, NULL, NULL,1, ''Billing Schedule for a specified Project/Campaign'', 1, 1, 1, 0)

SET IDENTITY_INSERT [dbo].[tImportExportDetail] ON 

--Activities
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7745, @ActivityKey, N''Subject'', N''subject'', NULL, NULL, N''Subject'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7746, @ActivityKey, N''Activity Date'', N''activityDate'', NULL, NULL, N''Activity Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7747, @ActivityKey, N''Completed'', N''completed'', NULL, NULL, N''Completed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7748, @ActivityKey, N''Date Completed'', N''dateCompleted'', NULL, NULL, N''Date Completed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7749, @ActivityKey, N''Assigned To'', N''assignedUser'', NULL, NULL, N''Assigned To'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7750, @ActivityKey, N''Private'', N''private'', NULL, NULL, N''Private'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7751, @ActivityKey, N''Folder'', N''cMFolderKey'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7752, @ActivityKey, N''Activity Type'', N''activityTypeKey'', NULL, NULL, N''Activity Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7753, @ActivityKey, N''Notes'', N''notes'', NULL, NULL, N''Notes'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7754, @ActivityKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7755, @ActivityKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7756, @ActivityKey, N''Contact'', N''linkedContact'', NULL, NULL, N''Contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7757, @ActivityKey, N''Company'', N''linkedCompany'', NULL, NULL, N''Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7758, @ActivityKey, N''Opportunity'', N''linkedLead'', NULL, NULL, N''Opportunity'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7759, @ActivityKey, N''Lead'', N''linkedUserLead'', NULL, NULL, N''Lead'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7760, @ActivityKey, N''Start Time'', N''startTime'', NULL, NULL, N''Start Time'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7761, @ActivityKey, N''End Time'', N''endTime'', NULL, NULL, N''End Time'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7762, @ActivityKey, N''Reminder (minutes)'', N''reminderMinutes'', NULL, NULL, N''Reminder (minutes)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7763, @ActivityKey, N''Priority'', N''priority'', NULL, NULL, N''Priority'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7764, @ActivityKey, N''Originator'', N''originatorUserKey'', NULL, NULL, N''Originator'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7765, @ActivityKey, N''Visible To Client'', N''visibleToClient'', NULL, NULL, N''Visible To Client'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7766, @ActivityKey, N''View As'', N''activityEntity'', NULL, NULL, N''View As'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7767, @ActivityKey, N''Outcome'', N''outcome'', NULL, NULL, N''Outcome'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7768, @ActivityKey, N''GL Company'', N''glCompanyKey'', NULL, NULL, N''GL Company, Required if GL Company is required '', NULL, 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
--Activity aka Conversation Types
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7769, @ActivityTypeKey, N''Type Name'', N''typeName'', NULL, N''TypeName'', N''Type Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7770, @ActivityTypeKey, N''Display Color'', N''typeColor'', NULL, N''TypeColor'', N''Display Color'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7771, @ActivityTypeKey, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7772, @ActivityTypeKey, N''Auto Roll Date'', N''autoRollDate'', NULL, N''AutoRollDate'', N''Auto Roll Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--Address
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79001, @AddressKey, N''Company Name'', N''companyName'', NULL, NULL, N''Company Name'', NULL, 2, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79002, @AddressKey, N''Company Key'', N''companyKey'', NULL, NULL, N''Company Key'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79003, @AddressKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', NULL, 2, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79004, @AddressKey, N''Client ID'', N''clientID'', NULL, NULL, N''Client ID'', NULL, 2, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79005, @AddressKey, N''Address Name'', N''addressName'', NULL, NULL, N''Address Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79006, @AddressKey, N''Address 1'', N''address1'', NULL, NULL, N''Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79007, @AddressKey, N''Address 2'', N''address2'', NULL, NULL, N''Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79008, @AddressKey, N''Address 3'', N''address3'', NULL, NULL, N''CAddress 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79009, @AddressKey, N''City'', N''city'', NULL, NULL, N''City'', NULL, Null, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79010, @AddressKey, N''State'', N''state'', NULL, NULL, N''State'', NULL, Null, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79011, @AddressKey, N''Postal Code'', N''postalCode'', NULL, NULL, N''Postal Code'', NULL, Null, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (79012, @AddressKey, N''Country'', N''country'', NULL, NULL, N''Country'', NULL, Null, NULL, NULL, NULL, NULL, NULL)
--Billing Group
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7773, @BillingGroupKey, N''Billing Group Code'', N''billingGroupCode'', NULL, N''BillingGroupCode'', N''Billing Group Code'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7774, @BillingGroupKey, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7775, @BillingGroupKey, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7776, @BillingGroupKey, N''Comments'', N''comments'', NULL, N''Comments'', N''Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7777, @BillingGroupKey, N''GLCompany'', N''glCompanyKey'', NULL, N''GLCompanyID'', N''GLCompany, required if GL Company is required'', NULL, 2, N''GLCompanyID'', NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
-- Billing Items
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7778, 10, N''ID'', N''workTypeID'', NULL, N''WorkTypeID'', N''ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7779, 10, N''Name'', N''workTypeName'', NULL, N''WorkTypeName'', N''Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7780, 10, N''Standard Price'', N''standardPrice'', NULL, N''StandardPrice'', N''Standard Price'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7781, 10, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7782, 10, N''Sales Account Number'', N''glAccountNumber'', NULL, N''GLAccountNumber'', N''Sales Account Number'', NULL, NULL, N''AccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7783, 10, N''Display Order'', N''displayOrder'', NULL, N''DisplayOrder'', N''Display Order'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7784, 10, N''Department'', N''departmentID'', NULL, N''DepartmentName'', N''Department'', NULL, NULL, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7785, 10, N''Tax 1 Applies'', N''taxable'', NULL, N''Taxable'', N''Tax 1 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7786, 10, N''Tax 2 Applies'', N''taxable2'', NULL, N''Taxable2'', N''Tax 2 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7787, 10, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7788, 10, N''Class ID'', N''classID'', NULL, N''ClassID'', N''Class ID'', NULL, NULL, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (788800, 10, N''Avalara Tax Code'', N''avalaraTaxCodeKey'', NULL, N''AvalaraTaxCode'', N''Avalara Tax Code'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''avalara'''')'')

-- Billing Schedule
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135001, @BillingScheduleKey, N''Project Number'', N''projectNumber'', NULL, N''Project Number'', N''Project Number'', NULL, 1, NULL, NULl, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135002, @BillingScheduleKey, N''Date to Bill'', N''nextBillDate'', NULL, N''Next Bill Date'', N''Date To Bill'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135003, @BillingScheduleKey, N''Task ID'', N''taskID'', NULL, N''Task ID'', N''Set Date to bill when this task is complete'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135004, @BillingScheduleKey, N''Billing Comments'', N''comments'', NULL, N''Billing Comments'', N''Billing Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135005, @BillingScheduleKey, N''Percent Budget'', N''percentBudget'', NULL, N''Percent Budget'', N''Percent of Budget to Bill'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135006, @BillingScheduleKey, N''Dollar Amount'', N''dollarAmount'', NULL, N''Dollar Amount'', N''Dollar Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135007, @BillingScheduleKey, N''Advance Bill'', N''advanceBill'', NULL, N''Advance Bill'', N''Advance Bill'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (135008, @BillingScheduleKey, N''Campaign ID'', N''campaignID'', NULL, N''Campaign ID'', N''Campaign ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)

-- Broadcast Items
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7789, 31, N''Item ID'', N''itemID'', NULL, N''ItemID'', N''Item ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7790, 31, N''Item Name'', N''itemName'', NULL, N''ItemName'', N''Item Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7791, 31, N''Commission'', N''markup'', NULL, N''Markup'', N''Commission'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7792, 31, N''Standard Description'', N''standardDescription'', NULL, N''StandardDescription'', N''Standard Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7793, 31, N''Billing Item ID'', N''workType'', NULL, N''WorkTypeID'', N''Billing Item ID'', NULL, NULL, N''WorkTypeID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7794, 31, N''Department'', N''departmentKey'', NULL, N''DepartmentName'', N''Department, required if departments are required'', NULL, 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7795, 31, N''Expense Account Number'', N''expenseAccount'', NULL, N''ExpenseAccountNumber'', N''Expense Account Number'', NULL, NULL, N''ExpenseAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7796, 31, N''Sales Account Number'', N''salesAccount'', NULL, N''SalesAccountNumber'', N''Sales Account Number'', NULL, NULL, N''SalesAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7797, 31, N''Tax 1 Applies'', N''taxable'', NULL, N''Taxable'', N''Tax 1 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7798, 31, N''Tax 2 Applies'', N''taxable2'', NULL, N''Taxable2'', N''Tax 2 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7799, 31, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7800, 31, N''Class ID'', N''classKey'', NULL, N''ClassID'', N''Class ID, required if Class is required'', NULL, 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (780100, 31, N''Avalara Tax Code'', N''avalaraTaxCodeKey'', NULL, N''AvalaraTaxCode'', N''Avalara Tax Code'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''avalara'''')'')
--Calendar Resource
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7801, 46, N''Resource Name'', N''resourceName'', NULL, N''ResourceName'', N''Resource Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
-- Meeting aka Calendar Types
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7802, 45, N''Type Name'', N''typeName'', NULL, NULL, N''Type Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7803, 45, N''Type Color'', N''typeColor'', NULL, NULL, N''Type Color'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7804, 45, N''Display Order'', N''displayOrder'', NULL, NULL, N''Display Order'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Campaigns
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124001, @CampaignKey, N''Campaign ID'', N''campaignID'', NULL, NULL, N''Campaign ID'', N''header'', 0, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124002, @CampaignKey, N''Campaign Name'', N''campaignName'', NULL, NULL, N''Campaign Name'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124003, @CampaignKey, N''Client ID'', N''clientID'', NULL, NULL, N''Client ID'', N''header'', 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124004, @CampaignKey, N''Description'', N''description'', NULL, NULL, N''description'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124005, @CampaignKey, N''objective'', N''objective'', NULL, NULL, N''objective'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124006, @CampaignKey, N''Start Date'', N''startDate'', NULL, NULL, N''Start Date'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124007, @CampaignKey, N''End Date'', N''endDate'', NULL, NULL, N''End Date'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124008, @CampaignKey, N''Account Manager'', N''accountManager'', NULL, NULL, N''Account Manager'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124009, @CampaignKey, N''Active'', N''active'', NULL, NULL, N''Active'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124010, @CampaignKey, N''Get Actuals By'', N''getActualsBy'', NULL, NULL, N''Get Actuals By'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124011, @CampaignKey, N''Layout'', N''layout'', NULL, NULL, N''Layout'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124012, @CampaignKey, N''multipleSegments;
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124013, @CampaignKey, N''Bill By'', N''billBy'', NULL, NULL, N''Bill By'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124014, @CampaignKey, N''One Line Per'', N''oneLinePer'', NULL, NULL, N''One Line Per'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124015, @CampaignKey, N''Contact'', N''contact'', NULL, NULL, N''Contact'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124016, @CampaignKey, N''GL Company'', N''gLCompany'', NULL, NULL, N''GL Company'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124017, @CampaignKey, N''Client Division'', N''clientDivision'', NULL, NULL, N''clientDivision'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124018, @CampaignKey, N''Client Product'', N''clientProduct'', NULL, NULL, N''Client Product'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124019, @CampaignKey, N''Next Project Number'', N''nextProjectNum'', NULL, NULL, N''Next Project Number'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124020, @CampaignKey, N''Currency ID'', N''currencyID'', NULL, NULL, N''currency ID'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124021, @CampaignKey, N''Opportunity ID'', N''opportunityID'', NULL, NULL, N''Opportunity ID'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124022, @CampaignKey, N''Project Manager'', N''projectManager'', NULL, NULL, N''Project Manager'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124023, @CampaignKey, N''Use Campaign Budget'', N''useCampaignBudget'', NULL, NULL, N''Use Campaign Budget Manager'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124024, @CampaignKey, N''Expenses Not Included'', N''expensesNotIncluded'', NULL, NULL, N''Expenses Not Included'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124025, @CampaignKey, N''Bill by Percentage of'', N''billByFF'', NULL, NULL, N''Bill by Percentage of'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124030, @CampaignKey, N''Segment Name'', N''segmentName'', NULL, NULL, N''Segment Name'', N''detail'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124031, @CampaignKey, N''Segment Description'', N''segmentDescription'', NULL, NULL, N''segment Description'', N''detail'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124032, @CampaignKey, N''Segment Plan Start Date'', N''segmentPlanStartDate'', NULL, NULL, N''segment Plan Start Date'', N''detail'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124033, @CampaignKey, N''Segment Plan End Date'', N''segmentPlanEndDate'', NULL, NULL, N''segment Plan End Date'', N''detail'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124034, @CampaignKey, N''Segment Action'', N''action'', NULL, NULL, N''Segment Action - a/u/d for Add, Updated, or Delete to segment'', N''detail'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124040, @CampaignKey, N''Copy Campaign ID'', N''copyCampaignID'', NULL, NULL, N''Copy Campaign ID'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124041, @CampaignKey, N''Copy Projects'', N''copyProjects'', NULL, NULL, N''Copy Projects (yes/no) when copying a campaign'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124042, @CampaignKey, N''Copy Estimates'', N''copyEstimates'', NULL, NULL, N''Copy Estimates (yes/no) when copying a campaign'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124043, @CampaignKey, N''Client Campaign Number'', N''clientCampaignNumber'', NULL, NULL, N''Client Campaign Number'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (124045, @CampaignKey, N''Campaign Request ID'', N''requestID'', NULL, NULL, N''Campaign Request ID'', N''header'', 0, NULL, NULL, NULL, NULL, NULL)

-- Client Receipts
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7805, @ClientPaymentsKey, N''Client ID'', N''clientID'', NULL, NULL, N''Client ID'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7806, @ClientPaymentsKey, N''GL Company'', N''glCompany'', NULL, NULL, N''GL Company'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7807, @ClientPaymentsKey, N''Check Amount'', N''checkAmount'', NULL, NULL, N''Check Amount'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7808, @ClientPaymentsKey, N''Posting Date'', N''postingDate'', NULL, NULL, N''Posting Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7809, @ClientPaymentsKey, N''Reference Number'', N''referenceNumber'', NULL, NULL, N''Reference Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7810, @ClientPaymentsKey, N''Payment Method'', N''paymentMethod'', NULL, NULL, N''Payment Method'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7811, @ClientPaymentsKey, N''Receipt Date'', N''checkDate'', NULL, NULL, N''Receipt Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7812, @ClientPaymentsKey, N''Deposit ID'', N''depositID'', NULL, NULL, N''Deposit ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7813, @ClientPaymentsKey, N''Opening Transaction'', N''openingTransaction'', NULL, NULL, N''Opening Transaction'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7814, @ClientPaymentsKey, N''Cash Account Number'', N''cashAccountNumber'', NULL, NULL, N''Cash Account Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7815, @ClientPaymentsKey, N''Unapplied Payment Account Number'', N''prepayAccountNumber'', NULL, NULL, N''Unapplied Payment Account Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7816, @ClientPaymentsKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7817, @ClientPaymentsKey, N''Posted'', N''posted'', NULL, NULL, N''Posted'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7818, @ClientPaymentsKey, N''Invoice Number'', N''invoiceNumber'', NULL, NULL, N''Invoice Number'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7819, @ClientPaymentsKey, N''GL Account'', N''glAccount'', NULL, NULL, N''GL Account'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7820, @ClientPaymentsKey, N''Description (Line)'', N''description'', NULL, NULL, N''Description (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7821, @ClientPaymentsKey, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7822, @ClientPaymentsKey, N''Department'', N''department'', NULL, NULL, N''Department. Required if Department is required.'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7823, @ClientPaymentsKey, N''Amount Applied'', N''amount'', NULL, NULL, N''Amount Applied'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7824, @ClientPaymentsKey, N''Office'', N''office'', NULL, NULL, N''Office. Required if Office ie required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7825, @ClientPaymentsKey, N''Target GL Company'', N''targetGLCompany'', NULL, NULL, N''Target GL Company. Required if GL Company is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7826, @ClientPaymentsKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7827, @ClientPaymentsKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7828, @ClientPaymentsKey, N''Class ID'', N''classKey'', NULL, NULL, N''Class ID. Required if Class is required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7829, @ClientPaymentsKey, N''Class ID (Line)'', N''classKey'', NULL, NULL, N''Class ID (Line). Required if Class is required'', N''detail'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
-- Clients
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7830, @ClientKey, N''Company Name'', N''companyName'', NULL, NULL, N''Company Name'', NULL, 1, NULL, 3, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7831, @ClientKey, N''Primary Contact'', N''primaryContact'', NULL, NULL, N''Primary Contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7832, @ClientKey, N''Company Source'', N''companySource'', NULL, NULL, N''Company Source'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7833, @ClientKey, N''Company Type'', N''companyType'', NULL, NULL, N''Company Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7834, @ClientKey, N''Billing Manager'', N''billingManager'', NULL, NULL, N''Billing Manager'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7835, @ClientKey, N''Phone'', N''phone'', NULL, NULL, N''Phone'', NULL, NULL, NULL, 4, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7836, @ClientKey, N''Fax'', N''fax'', NULL, NULL, N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7837, @ClientKey, N''Web Site'', N''website'', NULL, NULL, N''Web Site'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7838, @ClientKey, N''Twitter ID'', N''twitterID'', NULL, NULL, N''Twitter ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7839, @ClientKey, N''Company Address 1'', N''address1'', NULL, NULL, N''Company Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7840, @ClientKey, N''Company Address 2'', N''address2'', NULL, NULL, N''Company Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7841, @ClientKey, N''Company Address 3'', N''address3'', NULL, NULL, N''Company Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7842, @ClientKey, N''Company City'', N''city'', NULL, NULL, N''Company City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7843, @ClientKey, N''Company State'', N''state'', NULL, NULL, N''Company State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7844, @ClientKey, N''Company Postal Code'', N''postalCode'', NULL, NULL, N''Company Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7845, @ClientKey, N''Company Country'', N''country'', NULL, NULL, N''Company Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7846, @ClientKey, N''Company Owner'', N''companyOwner'', NULL, NULL, N''Company Owner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7847, @ClientKey, N''Account Manager'', N''accountManager'', NULL, NULL, N''Account Manager'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7848, @ClientKey, N''Sales Person'', N''salesPerson'', NULL, NULL, N''Sales Person'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7849, @ClientKey, N''Folder'', N''folderName'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7850, @ClientKey, N''Active'', N''active'', NULL, NULL, N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7851, @ClientKey, N''Date Converted'', N''dateConverted'', NULL, NULL, N''Date Converted'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7852, @ClientKey, N''GL Companies'', N''glCompanies'', NULL, NULL, N''GL Companies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7853, @ClientKey, N''Comments'', N''comments'', NULL, NULL, N''Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7854, @ClientKey, N''Is a Billable Client'', N''billableClient'', NULL, NULL, N''Is a Billable *[MediaPrint6]'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7855, @ClientKey, N''Client ID'', N''customerID'', NULL, NULL, N''Client ID. Required if Billable client is true'', NULL, 2, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7856, @ClientKey, N''Overhead'', N''overhead'', NULL, NULL, N''Overhead'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7857, @ClientKey, N''Is a Parent Company'', N''parentCompany'', NULL, NULL, N''Is a Parent Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7858, @ClientKey, N''Parent Company'', N''parentCompanyName'', NULL, NULL, N''Parent Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7859, @ClientKey, N''Downloaded'', N''clientDownloaded'', NULL, NULL, N''Downloaded'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7860, @ClientKey, N''Divisions'', N''divisions'', NULL, NULL, N''Divisions'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7861, @ClientKey, N''Products'', N''products'', NULL, NULL, N''Products'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7862, @ClientKey, N''Next Project Number'', N''nextProjectNum'', NULL, NULL, N''Next Project Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7863, @ClientKey, N''Next Campaign Number'', N''nextCampaignNum'', NULL, NULL, N''Next Campaign Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7864, @ClientKey, N''Default Sales Tax ID 1'', N''salesTaxID'', NULL, NULL, N''Default Sales Tax ID 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7865, @ClientKey, N''Default Sales Tax ID 2'', N''salesTax2ID'', NULL, NULL, N''Default Sales Tax ID 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7866, @ClientKey, N''Default Sales GL Account Number'', N''defaultSalesAccount'', NULL, NULL, N''Default Sales GL Account Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7867, @ClientKey, N''Default AR Account Number'', N''defaultARAccount'', NULL, NULL, N''Default AR Account Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7868, @ClientKey, N''Invoice Template'', N''invoiceTemplate'', NULL, NULL, N''Invoice Template'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7869, @ClientKey, N''Layouts'', N''layout'', NULL, NULL, N''Default Invoice Layout'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7870, @ClientKey, N''Default Billing Method'', N''defaultBillingMethod'', NULL, NULL, N''Default Billing Method'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7871, @ClientKey, N''Expenses Not Included'', N''defaultExpensesNotIncluded'', NULL, NULL, N''Expenses Not Included'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7872, @ClientKey, N''Default Retainer'', N''defaultRetainer'', NULL, NULL, N''Default Retainer'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7873, @ClientKey, N''One Invoice Per'', N''oneInvoicePer'', NULL, NULL, N''One Invoice Per, possible values Project, Client, Parent Client, Division, Product, Campaign'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7874, @ClientKey, N''One Line Item Per'', N''defaultARLineFormat'', NULL, NULL, N''One Line Item Per'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7875, @ClientKey, N''Default Terms'', N''paymentTerms'', NULL, NULL, N''Default Terms'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7876, @ClientKey, N''Estimate Template'', N''estimateTemplate'', NULL, NULL, N''Estimate Template'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7877, @ClientKey, N''Card Holders Name'', N''cardHolderName'', NULL, NULL, N''Card Holders Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7878, @ClientKey, N''CC Number'', N''ccNumber'', NULL, NULL, N''CC Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7879, @ClientKey, N''CC Exp Month'', N''expMonth'', NULL, NULL, N''CC Exp Month'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7880, @ClientKey, N''CC Exp Year'', N''expYear'', NULL, NULL, N''CC Exp Year'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7881, @ClientKey, N''CC Verification Code'', N''cVV'', NULL, NULL, N''CC Verification Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7882, @ClientKey, N''Default Company GL'', N''glCompany'', NULL, NULL, N''Default Company GL'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7883, @ClientKey, N''Account Team'', N''defaultTeam'', NULL, NULL, N''Account Team'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7884, @ClientKey, N''Get Rate From'', N''getRateFrom'', NULL, NULL, N''Get Rate From'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7885, @ClientKey, N''Hourly Rate'', N''hourlyRate'', NULL, NULL, N''Hourly Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7886, @ClientKey, N''Rate Sheet'', N''timeRateSheet'', NULL, NULL, N''Rate Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7887, @ClientKey, N''Get Markup From'', N''getMarkupFrom'', NULL, NULL, N''Get Markup From'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7888, @ClientKey, N''Markup Pct'', N''itemMarkup'', NULL, NULL, N''Markup Pct'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7889, @ClientKey, N''IO Commission Pct'', N''ioCommission'', NULL, NULL, N''IO Commission Pct'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7890, @ClientKey, N''BC Commission Pct'', N''bcCommission'', NULL, NULL, N''BC Commission Pct'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7891, @ClientKey, N''Default Item Rate Sheet'', N''itemRateSheet'', NULL, NULL, N''Default Item Rate Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7892, @ClientKey, N''Prebill Insertions At'', N''ioBillAt'', NULL, NULL, N''Prebill Insertions At'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7893, @ClientKey, N''Prebill Broadcast At'', N''bcBillAt'', NULL, NULL, N''Prebill Broadcast At'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7894, @ClientKey, N''Default Office'', N''office'', NULL, NULL, N''Default Office'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7895, @ClientKey, N''Lock Get Labor Rate'', N''lockLaborRate'', NULL, NULL, N''Lock Get Labor Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7896, @ClientKey, N''Lock Get Markup From'', N''lockMarkupFrom'', NULL, NULL, N''Lock Get Markup From'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7897, @ClientKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7898, @ClientKey, N''Title Rate Sheet'', N''titleRateSheet'', NULL, NULL, N''Title Rate Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''billingtitles'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71001, @ClientKey, N''Billing Address Name'', N''billingAddressName'', NULL, NULL, N''Billing Address Name.  Used to populate the Billing Address on the Billing Details'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71002, @ClientKey, N''Email Invoices To'', N''billingEmailContact'', NULL, NULL, N''Email Invoices To'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71003, @ClientKey, N''Billing Name'', N''billingName'', NULL, NULL, N''Billing Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71004, @ClientKey, N''EIN Number'', N''einNumber'', NULL, NULL, N''EIN'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71005, @ClientKey, N''Estimate Labor Taxable'', N''estimateLaborTaxable'', NULL, NULL, N''Estimate Labor Taxable'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71006, @ClientKey, N''Project Manager'', N''projectManager'', NULL, NULL, N''Project Manager'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.ShowProjectManager == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71007, @ClientKey, N''One Line Item Per (Fixed Fee)'', N''defaultFFLineFormat'', NULL, NULL, N''One Line Item Per (Fixed Fee)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71008, @ClientKey, N''CC Receipts'', N''ccReceipts'', NULL, NULL, N''Allow Credit Card Payments Online'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71009, @ClientKey, N''ACH Receipts'', N''achReceipts'', NULL, NULL, N''Allow ACH Payments Online'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71010, @ClientKey, N''Primary Contact First Name'', N''primaryContactFirstName'', NULL, NULL, N''Primary Contact First Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71011, @ClientKey, N''Primary Contact Last Name'', N''primaryContactLastName'', NULL, NULL, N''Primary Contact Last Namee'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71012, @ClientKey, N''Primary Contact Email'', N''primaryContactEmail'', NULL, NULL, N''Primary Contact Email Address'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71013, @ClientKey, N''Billing Contact First Name'', N''billingContactFirstName'', NULL, NULL, N''Billing Contact First Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71014, @ClientKey, N''Billing Contact Last Name'', N''billingContactLastName'', NULL, NULL, N''Billing Contact Last Namee'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71015, @ClientKey, N''Billing Contact Email'', N''billingContactEmail'', NULL, NULL, N''Billing Contact Email Address'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71016, @ClientKey, N''Project Color'', N''projectColor'', NULL, NULL, N''Project Color in hex format (#FF0000)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (71017, @ClientKey, N''Company Address Name'', N''addressName'', NULL, NULL, N''Company Address Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Companies
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7899, @CompanyKey, N''Company Name'', N''companyName'', NULL, NULL, N''Company Name'', NULL, 1, NULL, 2, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7900, @CompanyKey, N''Primary Contact'', N''primaryContact'', NULL, NULL, N''Primary Contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7901, @CompanyKey, N''Source'', N''companySource'', NULL, NULL, N''Source'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7902, @CompanyKey, N''Company Type'', N''companyType'', NULL, NULL, N''Company Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7903, @CompanyKey, N''Main Phone'', N''phone'', NULL, NULL, N''Main Phone'', NULL, NULL, NULL, 3, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7904, @CompanyKey, N''Fax'', N''fax'', NULL, NULL, N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7905, @CompanyKey, N''WebSite'', N''website'', NULL, NULL, N''WebSite'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7906, @CompanyKey, N''Company Address 1'', N''address1'', NULL, NULL, N''Company Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7907, @CompanyKey, N''Company Address 2'', N''address2'', NULL, NULL, N''Company Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7908, @CompanyKey, N''Company Address 3'', N''address3'', NULL, NULL, N''Company Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7909, @CompanyKey, N''Company City'', N''city'', NULL, NULL, N''Company City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7910, @CompanyKey, N''Company State'', N''state'', NULL, NULL, N''Company State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7911, @CompanyKey, N''Company Postal Code'', N''postalCode'', NULL, NULL, N''Company Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7912, @CompanyKey, N''Company Country'', N''country'', NULL, NULL, N''Company Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7913, @CompanyKey, N''Company Owner'', N''companyOwner'', NULL, NULL, N''Company Owner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7914, @CompanyKey, N''Account Manager'', N''accountManager'', NULL, NULL, N''Account Manager'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7915, @CompanyKey, N''Sales Person'', N''salesPerson'', NULL, NULL, N''Sales Person'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7916, @CompanyKey, N''Folder'', N''folderName'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7917, @CompanyKey, N''Active'', N''active'', NULL, NULL, N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7918, @CompanyKey, N''Date Converted'', N''dateConverted'', NULL, NULL, N''Date Converted'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7919, @CompanyKey, N''GL Companies'', N''glCompanies'', NULL, NULL, N''GL Companies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7920, @CompanyKey, N''Comments'', N''comments'', NULL, NULL, N''Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7921, @CompanyKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7922, @CompanyKey, N''Title Rate Sheet'', N''titleRateSheet'', NULL, NULL, N''Title Rate Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''billingtitles'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3701, @CompanyKey, N''Project Manager'', N''projectManager'', NULL, NULL, N''Project Manager'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.ShowProjectManager == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3702, @CompanyKey, N''Primary Contact First Name'', N''primaryContactFirstName'', NULL, NULL, N''Primary Contact First Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3703, @CompanyKey, N''Primary Contact Last Name'', N''primaryContactLastName'', NULL, NULL, N''Primary Contact Last Namee'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3704, @CompanyKey, N''Primary Contact Email'', N''primaryContactEmail'', NULL, NULL, N''Primary Contact Email Address'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3705, @CompanyKey, N''Company Address Name'', N''addressName'', NULL, NULL, N''Company Address Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)

-- Company Type
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7923, 44, N''Company Type Name'', N''companyTypeName'', NULL, N''CompanyTypeName'', N''Company Type Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
--Contacts
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7924, @ContactKey, N''Salutation'', N''salutation'', NULL, NULL, N''Salutation'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7925, @ContactKey, N''First Name'', N''firstName'', NULL, NULL, N''First Name'', NULL, 1, NULL, 2, N''Full Name'', NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7926, @ContactKey, N''Middle Name'', N''middleName'', NULL, NULL, N''Middle Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7927, @ContactKey, N''Last Name'', N''lastName'', NULL, NULL, N''Last Name'', NULL, 1, NULL, 2, N''Full Name'', NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7928, @ContactKey, N''Title'', N''title'', NULL, NULL, N''Title'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7929, @ContactKey, N''Linked Company'', N''linkedCompanyName'', NULL, NULL, N''Linked Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7930, @ContactKey, N''Company Name'', N''userCompanyName'', NULL, NULL, N''Company Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7931, @ContactKey, N''Primary Contact'', N''primaryContact'', NULL, NULL, N''Primary Contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7932, @ContactKey, N''Twitter ID'', N''twitterID'', NULL, NULL, N''Twitter ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7933, @ContactKey, N''LinkedIn URL'', N''linkedInUrl'', NULL, NULL, N''LinkedIn URL'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7934, @ContactKey, N''Phone 1'', N''phone1'', NULL, NULL, N''Phone 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7935, @ContactKey, N''Phone 2'', N''phone2'', NULL, NULL, N''Phone 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7936, @ContactKey, N''Cell'', N''cell'', NULL, NULL, N''Cell'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7937, @ContactKey, N''Fax'', N''fax'', NULL, NULL, N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7938, @ContactKey, N''Phone Other'', N''pager'', NULL, NULL, N''Phone Other'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7939, @ContactKey, N''Email Address'', N''email'', NULL, NULL, N''Email Address'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7940, @ContactKey, N''Personal Work Address 1'', N''workAddress1'', NULL, NULL, N''Personal Work Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7941, @ContactKey, N''Personal Work Address 2'', N''workAddress2'', NULL, NULL, N''Personal Work Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7942, @ContactKey, N''Personal Work Address 3'', N''workAddress3'', NULL, NULL, N''Personal Work Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7943, @ContactKey, N''Personal Work City'', N''workCity'', NULL, NULL, N''Personal Work City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7944, @ContactKey, N''Personal Work State'', N''workState'', NULL, NULL, N''Personal Work State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7945, @ContactKey, N''Personal Work Postal Code'', N''workPostalCode'', NULL, NULL, N''Personal Work Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7946, @ContactKey, N''Personal Work Country'', N''workCountry'', NULL, NULL, N''Personal Work Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7947, @ContactKey, N''Home Address 1'', N''homeAddress1'', NULL, NULL, N''Home Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7948, @ContactKey, N''Home Address 2'', N''homeAddress2'', NULL, NULL, N''Home Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7949, @ContactKey, N''Home Address 3'', N''homeAddress3'', NULL, NULL, N''Home Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7950, @ContactKey, N''Home City'', N''homeCity'', NULL, NULL, N''Home City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7951, @ContactKey, N''Home State'', N''homeState'', NULL, NULL, N''Home State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7952, @ContactKey, N''Home Postal Code'', N''homePostalCode'', NULL, NULL, N''Home Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7953, @ContactKey, N''Home Country'', N''homeCountry'', NULL, NULL, N''Home Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7954, @ContactKey, N''Other Address 1'', N''otherAddress1'', NULL, NULL, N''Other Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7955, @ContactKey, N''Other Address 2'', N''otherAddress2'', NULL, NULL, N''Other Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7956, @ContactKey, N''Other Address 3'', N''otherAddress3'', NULL, NULL, N''Other Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7957, @ContactKey, N''Other City'', N''otherCity'', NULL, NULL, N''Other City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7958, @ContactKey, N''Other State'', N''otherState'', NULL, NULL, N''Other State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7959, @ContactKey, N''Other Postal Code'', N''otherPostalCode'', NULL, NULL, N''Other Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7960, @ContactKey, N''Other Country'', N''otherCountry'', NULL, NULL, N''Other Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7961, @ContactKey, N''Comments'', N''comments'', NULL, NULL, N''Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7962, @ContactKey, N''Date of Hire'', N''dateHired'', NULL, NULL, N''Date of Hire'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7963, @ContactKey, N''Department'', N''department'', NULL, NULL, N''Department'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7964, @ContactKey, N''Reports To'', N''reportsToName'', NULL, NULL, N''Reports To'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7965, @ContactKey, N''Assistant'', N''assistant'', NULL, NULL, N''Assistant'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7966, @ContactKey, N''Assistant Phone'', N''assistantPhone'', NULL, NULL, N''Assistant Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7967, @ContactKey, N''Assistant Email'', N''assistantEmail'', NULL, NULL, N''Assistant Email'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7968, @ContactKey, N''Birthday'', N''birthday'', NULL, NULL, N''Birthday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7969, @ContactKey, N''Spouse/Partner'', N''spouseName'', NULL, NULL, N''Spouse/Partner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7970, @ContactKey, N''Children'', N''children'', NULL, NULL, N''Children'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7971, @ContactKey, N''Anniversary'', N''anniversary'', NULL, NULL, N''Anniversary'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7972, @ContactKey, N''Hobbies'', N''hobbies'', NULL, NULL, N''Hobbies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7973, @ContactKey, N''Marketing Groups'', N''marketingLists'', NULL, NULL, N''Marketing Groups'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7974, @ContactKey, N''Preferred Contact Method'', N''contactMethod'', NULL, NULL, N''Preferred Contact Method'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7975, @ContactKey, N''Do Not Call'', N''doNotCall'', NULL, NULL, N''Do Not Call'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7976, @ContactKey, N''Do Not Email'', N''doNotEmail'', NULL, NULL, N''Do Not Email'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7977, @ContactKey, N''Do Not Mail'', N''doNotMail'', NULL, NULL, N''Do Not Mail'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7978, @ContactKey, N''Do Not Fax'', N''doNotFax'', NULL, NULL, N''Do Not Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7979, @ContactKey, N''Default GL Company'', N''glCompany'', NULL, NULL, N''Default GL Company'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7980, @ContactKey, N''Services'', N''services'', NULL, NULL, N''Services'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7981, @ContactKey, N''GL Companies'', N''glCompanies'', NULL, NULL, N''GL Companies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7982, @ContactKey, N''Billing Title ID'', N''titleID'', NULL, NULL, N''Billing Title ID'', NULL, NULL, N''BillingTitleID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7983, @ContactKey, N''Invoice Email Name'', N''invoiceEmailName'', NULL, NULL, N''Invoice Email Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7984, @ContactKey, N''Invoice Email Address'', N''invoiceEmailAddress'', NULL, NULL, N''Invoice Email Address'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7985, @ContactKey, N''System ID'', N''systemID'', NULL, NULL, N''System ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7986, @ContactKey, N''Contact Owner'', N''contactOwner'', NULL, NULL, N''Contact Owner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7987, @ContactKey, N''Folder'', N''folder'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7988, @ContactKey, N''Active'', N''active'', NULL, NULL, N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7989, @ContactKey, N''User ID'', N''userID'', NULL, NULL, N''User ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7990, @ContactKey, N''Password'', N''newPassword'', NULL, NULL, N''Password'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7991, @ContactKey, N''Security Group'', N''securityGroup'', NULL, NULL, N''Security Group'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7992, @ContactKey, N''Free Login'', N''clientVendorLogin'', NULL, NULL, N''Free Login'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7993, @ContactKey, N''Timezone Index'', N''timeZoneIndex'', NULL, NULL, N''Timezone Index'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7994, @ContactKey, N''Date Converted'', N''dateConverted'', NULL, NULL, N''Date Converted'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7995, @ContactKey, N''Role'', N''userRole'', NULL, NULL, N''Role'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyroles'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7996, @ContactKey, N''Skills'', N''skills'', NULL, NULL, N''Skills'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyskills'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (100, @ContactKey, N''Division'', N''clientDivision'', NULL, NULL, N''Division'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (101, @ContactKey, N''Product'', N''clientProduct'', NULL, NULL, N''Product'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (102, @ContactKey, N''Invoice Exclude Attachments'', N''invoiceExcludeAttachment'', NULL, NULL, N''Invoice Exclude Attachments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (103, @ContactKey, N''Do Not Use SSO Auth'', N''doNotUseSSO'', NULL, NULL, N''Do Not Use SAML/SSO Authentication'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--Credit Card Charges
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7997, @CreditCardCharge, N''Credit Card Account'', N''aPAccountNumber'', NULL, NULL, N''Credit Card Account'', N''header'', 1, N''Credit Card Account'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7998, @CreditCardCharge, N''Reference Number'', N''invoiceNumber'', NULL, NULL, N''Reference Number'', N''header'', NULL, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7999, @CreditCardCharge, N''Charge Date'', N''invoiceDate'', NULL, NULL, N''Charge Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8000, @CreditCardCharge, N''Posting Date'', N''postingDate'', NULL, NULL, N''Posting Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8001, @CreditCardCharge, N''Purchased By'', N''boughtBy'', NULL, NULL, N''Purchased By'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8002, @CreditCardCharge, N''Purchased From'', N''boughtFromID'', NULL, NULL, N''Purchased From'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8003, @CreditCardCharge, N''Approved By'', N''approvedBy'', NULL, NULL, N''Approved By'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8004, @CreditCardCharge, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8007, @CreditCardCharge, N''Opening Transaction'', N''openingTransaction'', NULL, NULL, N''Opening Transaction'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8008, @CreditCardCharge, N''Description'', N''description'', NULL, NULL, N''Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8009, @CreditCardCharge, N''Overhead Charge'', N''voucherType'', NULL, NULL, N''Overhead Charge'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8010, @CreditCardCharge, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8011, @CreditCardCharge, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8012, @CreditCardCharge, N''Office'', N''officeID'', NULL, NULL, N''Office. Required if office is required'', N''header'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition],[SystemSettingFieldName]) VALUES (8013, @CreditCardCharge, N''Item ID'', N''itemID'', NULL, NULL, N''Item ID. Required if item is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL, N''RequireItems'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8014, @CreditCardCharge, N''Quantity'', N''quantity'', NULL, NULL, N''Quantity'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8015, @CreditCardCharge, N''Unit Cost'', N''unitCost'', NULL, NULL, N''Unit Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8016, @CreditCardCharge, N''Unit Description'', N''unitDescription'', NULL, NULL, N''Unit Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8017, @CreditCardCharge, N''Net Cost'', N''totalCost'', NULL, NULL, N''Net Cost'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8018, @CreditCardCharge, N''Markup'', N''markup'', NULL, NULL, N''Markup'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8019, @CreditCardCharge, N''Unit Rate'', N''unitRate'', NULL, NULL, N''Unit Rate'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8020, @CreditCardCharge, N''Billable'', N''billable'', NULL, NULL, N''Billable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8021, @CreditCardCharge, N''Gross Cost'', N''grossAmount'', NULL, NULL, N''Gross Cost'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8022, @CreditCardCharge, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8023, @CreditCardCharge, N''Client ID'', N''clientID'', NULL, NULL, N''Client ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8024, @CreditCardCharge, N''Expense Account'', N''expenseAccountNumber'', NULL, NULL, N''Expense Account. Required if GL Acounts are required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8025, @CreditCardCharge, N''Department'', N''departmentID'', NULL, NULL, N''Department. Required if Departments are required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8026, @CreditCardCharge, N''Sales Tax Amount'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax Amount'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8027, @CreditCardCharge, N''Sales Tax Amount 2'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax Amount 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57002, @CreditCardCharge, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57003, @CreditCardCharge, N''Sales Tax 2 ID'', N''salesTax2ID'', NULL, NULL, N''Sales Tax 2 ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57004, @CreditCardCharge, N''Sales Tax Amount (line)'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax Amount (line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57005, @CreditCardCharge, N''Sales Tax Amount 2 (line)'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax Amount 2 (line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8028, @CreditCardCharge, N''Taxable (line)'', N''taxable'', NULL, NULL, N''Taxable (line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8029, @CreditCardCharge, N''Taxable 2 (line)'', N''taxable2'', NULL, NULL, N''Taxable 2 (line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8030, @CreditCardCharge, N''Line Description'', N''shortDescription'', NULL, NULL, N''Line Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8031, @CreditCardCharge, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8032, @CreditCardCharge, N''Project Exchange Rate (Line)'', N''pExchangeRateLine'', NULL, NULL, N''Exchange Rate (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8033, @CreditCardCharge, N''Class ID'', N''classID'', NULL, NULL, N''Class ID. Required if Class is required'',  N''header'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57001, @CreditCardCharge, N''Exclude from 1099'', N''exclude1099'', NULL, NULL, N''Exclude from 1099 Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL,NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57006, @CreditCardCharge, N''Class ID (Line)'', N''classID'', NULL, NULL, N''Class ID. Required if Class is required'',  N''detail'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57007, @CreditCardCharge, N''Voucher Invoice Number (Line)'', N''voucherInvoiceNumber'', NULL, NULL, N''Voucher Invoice Number (Line)'',  N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57008, @CreditCardCharge, N''Project Number (Line)'', N''projectNumber'', NULL, NULL, N''Project Number (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57009, @CreditCardCharge, N''Vendor ID (Line)'', N''vendorID'', NULL, NULL, N''Vendor ID (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57010, @CreditCardCharge, N''Markup From Project (Line)'', N''markupFromProject'', NULL, NULL, N''Markup from Project (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57011, @CreditCardCharge, N''Target GL Company (Line)'', N''targetGLCompanyID'', NULL, NULL, N''Target GL Copmpany ID (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57012, @CreditCardCharge, N''Office (Line)'', N''officeID'', NULL, NULL, N''Office (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57013, @CreditCardCharge, N''Amount to Bill'', N''amountToBill'', NULL, NULL, N''Amount to Bill'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57014, @CreditCardCharge, N''GL Company Exchange Rate'', N''glcExchangeRate'', NULL, NULL, N''GL Company Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57015, @CreditCardCharge, N''Invoice Exchange Rate'', N''invoiceExchangeRate'', NULL, NULL, N''Invoice Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57016, @CreditCardCharge, N''Net Cost (HC)'', N''hcTotalCost'', NULL, NULL, N''Net Cost (Home Currency)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57017, @CreditCardCharge, N''Project Currency ID'', N''pCurrencyID'', NULL, NULL, N''Project Currency ID'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57018, @CreditCardCharge, N''Project Currency ID (Line)'', N''pCurrencyLineID'', NULL, NULL, N''Project Currency ID (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57019, @CreditCardCharge, N''Project Exchange Rate'', N''projectExchangeRate'', NULL, NULL, N''Project Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57020, @CreditCardCharge, N''Project Net Cost'', N''pTotalCost'', NULL, NULL, N''Project Net Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57021, @CreditCardCharge, N''Invoice Currency ID'', N''currencyID'', NULL, NULL, N''Invoice Currency ID'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (57022, @CreditCardCharge, N''Comment'', N''comment'', NULL, NULL, N''Comment'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)

--Credit Card Connector.. aka credit card transactions
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8034, @CreditCardConnector, N''GL Account Number'', N''glAccountNumber'', NULL, NULL, N''GL Account Number'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8035, @CreditCardConnector, N''Amount'', N''amount'', NULL, NULL, N''Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8037, @CreditCardConnector, N''FITID'', N''fITID'', NULL, NULL, N''FITID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8038, @CreditCardConnector, N''Payee Name'', N''payeeName'', NULL, NULL, N''Payee Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8039, @CreditCardConnector, N''Memo'', N''memo'', NULL, NULL, N''Memo'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8040, @CreditCardConnector, N''Date'', N''transactionPostedDate'', NULL, NULL, N''Date Posted'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8041, @CreditCardConnector, N''Transaction Type'', N''transactionType'', NULL, NULL, N''Transaction Type'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (6201, @CreditCardConnector, N''Charged By'', N''chargedBy'', NULL, NULL, N''Charged By'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (6202, @CreditCardConnector, N''Expense Account Number'', N''expenseAccount'', NULL, NULL, N''Expense Account Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (6203, @CreditCardConnector, N''Item ID'', N''itemKey'', NULL, NULL, N''Item ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (6204, @CreditCardConnector, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company'', NUll, NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')

-- Currency Rates
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8042, @CurrencyRateKey, N''GL Company'', N''glCompanyName'', NULL, N''GLCompanyName'', N''GL Company'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8043, @CurrencyRateKey, N''Effective Date'', N''effectiveDate'', NULL, N''EffectiveDate'', N''Effective Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8044, @CurrencyRateKey, N''Exchange Rate'', N''exchangeRate'', NULL, N''ExchangeRate'', N''Exchange Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8045, @CurrencyRateKey, N''Currency'', N''currencyID'', NULL, N''CurrencyID'', N''Currency'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (63001, @CurrencyRateKey, N''ToCurrency'', N''toCurrencyID'', NULL, N''ToCurrencyID'', N''ToCurrency'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Deliverables
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80001, @DeliverableKey, N''Deliverable ID'', N''deliverableID'', NULL, NULL, N''Deliverable ID'', NULL, NULL, NULL, 1, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80002, @DeliverableKey, N''Deliverable Name'', N''deliverableName'', NULL, NULL, N''Deliverable Name'', NULL, 1, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80003, @DeliverableKey, N''Deliverable Status'', N''deliverableStatus'', NULL, NULL, N''Deliverable Status'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80004, @DeliverableKey, N''Deliverable Type'', N''deliverableType'', NULL, NULL, N''Deliverable Type'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80005, @DeliverableKey, N''Description'', N''description'', NULL, NULL, N''Description'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80006, @DeliverableKey, N''Due Date'', N''dueDate'', NULL, NULL, N''Due Date'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80007, @DeliverableKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', NULL, 1, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80008, @DeliverableKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80009, @DeliverableKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80010, @DeliverableKey, N''Approved Date'', N''approvedDate'', NULL, NULL, N''Approved Date'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField]) VALUES (80011, @DeliverableKey, N''Owner ID'', N''ownerID'', NULL, NULL, N''Owner User ID'', NULL, NULL, NULL, NULL, NULL, NULL)
-- Department
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8046, 28, N''Department Name'', N''departmentName'', NULL, N''DepartmentName'', N''Department Name'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8047, 28, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Conversation
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11601, @ConversationKey, N''Subject'', N''subject'', NULL, NULL, N''Subject'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11602, @ConversationKey, N''Activity Date'', N''activityDate'', NULL, NULL, N''Activity Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11603, @ConversationKey, N''Completed'', N''completed'', NULL, NULL, N''Completed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11604, @ConversationKey, N''Date Completed'', N''dateCompleted'', NULL, NULL, N''Date Completed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11605, @ConversationKey, N''Assigned To'', N''assignedUser'', NULL, NULL, N''Assigned To'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11606, @ConversationKey, N''Private'', N''private'', NULL, NULL, N''Private'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11607, @ConversationKey, N''Folder'', N''cMFolderKey'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11608, @ConversationKey, N''Activity Type'', N''activityType'', NULL, NULL, N''Activity Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11609, @ConversationKey, N''Notes'', N''notes'', NULL, NULL, N''Notes'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11610, @ConversationKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11611, @ConversationKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11612, @ConversationKey, N''Contact'', N''linkedContact'', NULL, NULL, N''Contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11613, @ConversationKey, N''Company'', N''linkedCompany'', NULL, NULL, N''Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11614, @ConversationKey, N''Opportunity'', N''linkedLead'', NULL, NULL, N''Opportunity'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11615, @ConversationKey, N''Lead'', N''linkedUserLead'', NULL, NULL, N''Lead'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11616, @ConversationKey, N''Start Time'', N''startTime'', NULL, NULL, N''Start Time'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11617, @ConversationKey, N''End Time'', N''endTime'', NULL, NULL, N''End Time'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11618, @ConversationKey, N''Reminder (minutes)'', N''reminderMinutes'', NULL, NULL, N''Reminder (minutes)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11619, @ConversationKey, N''Priority'', N''priority'', NULL, NULL, N''Priority'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11620, @ConversationKey, N''Originator'', N''originatorUserKey'', NULL, NULL, N''Originator'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11621, @ConversationKey, N''Visible To Client'', N''visibleToClient'', NULL, NULL, N''Visible To Client'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11622, @ConversationKey, N''View As'', N''activityEntity'', NULL, NULL, N''View As'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11623, @ConversationKey, N''Outcome'', N''outcome'', NULL, NULL, N''Outcome'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11624, @ConversationKey, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company, Required if GL Company is required '', NULL, 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')

-- Employee
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8048, @EmployeeKey, N''First Name'', N''firstName'', NULL, NULL, N''First Name'', NULL, 1, NULL, 3, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8049, @EmployeeKey, N''Middle Name'', N''middleName'', NULL, NULL, N''Middle Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8050, @EmployeeKey, N''Last Name'', N''lastName'', NULL, NULL, N''Last Name'', NULL, 1, NULL, 3, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8051, @EmployeeKey, N''Salutation'', N''salutation'', NULL, NULL, N''Salutation'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8052, @EmployeeKey, N''Title'', N''title'', NULL, NULL, N''Title'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8053, @EmployeeKey, N''Office'', N''office'', NULL, NULL, N''Office'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8054, @EmployeeKey, N''Department'', N''department'', NULL, NULL, N''Department'', NULL, NULL, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8055, @EmployeeKey, N''Is Supervisor'', N''supervisor'', NULL, NULL, N''Is Supervisor'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8056, @EmployeeKey, N''Timezone Index'', N''timeZoneIndex'', NULL, NULL, N''Timezone Index'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8057, @EmployeeKey, N''System ID'', N''systemID'', NULL, NULL, N''System ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8058, @EmployeeKey, N''Default Calendar Color'', N''defaultCalendarColor'', NULL, NULL, N''Default Calendar Color'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8059, @EmployeeKey, N''Phone'', N''phone'', NULL, NULL, N''Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8060, @EmployeeKey, N''Second Phone'', N''phone2'', NULL, NULL, N''Second Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8061, @EmployeeKey, N''Cell Phone'', N''cell'', NULL, NULL, N''Cell Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8062, @EmployeeKey, N''Fax'', N''fax'', NULL, NULL, N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8063, @EmployeeKey, N''Other'', N''pager'', NULL, NULL, N''Other'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8064, @EmployeeKey, N''Email'', N''email'', NULL, NULL, N''Email'', NULL, NULL, NULL, 2, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8065, @EmployeeKey, N''Hourly Cost'', N''hourlyCost'', NULL, NULL, N''Hourly Cost'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8066, @EmployeeKey, N''Monthly Cost'', N''monthlyCost'', NULL, NULL, N''Monthly Cost'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8067, @EmployeeKey, N''Hourly Rate'', N''hourlyRate'', NULL, NULL, N''Hourly Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8068, @EmployeeKey, N''Time Approver'', N''timeApprover'', NULL, NULL, N''Time Approver'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (810029, @EmployeeKey, N''Calendar Approver'', N''calendarApprover'', NULL, NULL, N''Meeting Approver'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8069, @EmployeeKey, N''Expense Approver'', N''expenseApprover'', NULL, NULL, N''Expense Approver'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8070, @EmployeeKey, N''Credit Card Approver'', N''creditCardApprover'', NULL, NULL, N''Credit Card Approver'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8071, @EmployeeKey, N''Backup Approver'', N''backupApprover'', NULL, NULL, N''Backup Approver'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8072, @EmployeeKey, N''Time Sheet Required'', N''timesheetRequired'', NULL, NULL, N''Time Sheet Required'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8073, @EmployeeKey, N''Require Times on Time Sheet'', N''requireUserTimeDetails'', NULL, NULL, N''Require Times on Time Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8074, @EmployeeKey, N''Require Minimum Hours'', N''requireMinimumHours'', NULL, NULL, N''Require Minimum Hours'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8075, @EmployeeKey, N''Minimum Hours Monday'', N''hoursMonday'', NULL, NULL, N''Minimum Hours Monday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8076, @EmployeeKey, N''Minimum Hours Tuesday'', N''hoursTuesday'', NULL, NULL, N''Minimum Hours Tuesday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8077, @EmployeeKey, N''Minimum Hours Wednesday'', N''hoursWednesday'', NULL, NULL, N''Minimum Hours Wednesday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8078, @EmployeeKey, N''Minimum Hours Thursday'', N''hoursThursday'', NULL, NULL, N''Minimum Hours Thursday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8079, @EmployeeKey, N''Minimum Hours Friday'', N''hoursFriday'', NULL, NULL, N''Minimum Hours Friday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8080, @EmployeeKey, N''Minimum Hours Saturday'', N''hoursSaturday'', NULL, NULL, N''Minimum Hours Saturday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8081, @EmployeeKey, N''Minimum Hours Sunday'', N''hoursSunday'', NULL, NULL, N''Minimum Hours Sunday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8082, @EmployeeKey, N''User ID'', N''userID'', NULL, NULL, N''User ID'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8083, @EmployeeKey, N''Password'', N''password'', NULL, NULL, N''Password'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8084, @EmployeeKey, N''Security Group'', N''securityGroup'', NULL, NULL, N''Security Group'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8085, @EmployeeKey, N''Active'', N''active'', NULL, NULL, N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8086, @EmployeeKey, N''Locked'', N''locked'', NULL, NULL, N''Locked'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8087, @EmployeeKey, N''Subscribe to Diary'', N''subscribeDiary'', NULL, NULL, N''Subscribe to Diary'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8088, @EmployeeKey, N''Subscribe to ToDo'', N''subscribeToDo'', NULL, NULL, N''Subscribe to ToDo'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8089, @EmployeeKey, N''Default Reviewer'', N''deliverableReviewer'', NULL, NULL, N''Default Reviewer'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8090, @EmployeeKey, N''Default Notify'', N''deliverableNotify'', NULL, NULL, N''Default Notify'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8091, @EmployeeKey, N''Date Hired'', N''dateHired'', NULL, NULL, N''Date Hired'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8092, @EmployeeKey, N''Anniversary'', N''anniversary'', NULL, NULL, N''Anniversary'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8093, @EmployeeKey, N''Birthday'', N''birthday'', NULL, NULL, N''Birthday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8094, @EmployeeKey, N''Children'', N''children'', NULL, NULL, N''Children'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8095, @EmployeeKey, N''Spouse/Partner'', N''spouseName'', NULL, NULL, N''Spouse/Partner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8096, @EmployeeKey, N''Personal Work Address 1'', N''personalWorkAddress1'', NULL, NULL, N''Personal Work Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8097, @EmployeeKey, N''Personal Work Address 2'', N''personalWorkAddress2'', NULL, NULL, N''Personal Work Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8098, @EmployeeKey, N''Personal Work Address 3'', N''personalWorkAddress3'', NULL, NULL, N''Personal Work Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8099, @EmployeeKey, N''Personal Work City'', N''personalWorkCity'', NULL, NULL, N''Personal Work City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8100, @EmployeeKey, N''Personal Work State'', N''personalWorkState'', NULL, NULL, N''Personal Work State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8101, @EmployeeKey, N''Personal Work Postal Code'', N''personalWorkPostalCode'', NULL, NULL, N''Personal Work Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8102, @EmployeeKey, N''Personal Work Country'', N''personalWorkCountry'', NULL, NULL, N''Personal Work Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8103, @EmployeeKey, N''Home Address 1'', N''homeAddress1'', NULL, NULL, N''Home Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8104, @EmployeeKey, N''Home Address 2'', N''homeAddress2'', NULL, NULL, N''Home Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8105, @EmployeeKey, N''Home Address 3'', N''homeAddress3'', NULL, NULL, N''Home Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8106, @EmployeeKey, N''Home City'', N''homeCity'', NULL, NULL, N''Home City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8107, @EmployeeKey, N''Home State'', N''homeState'', NULL, NULL, N''Home State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8108, @EmployeeKey, N''Home Postal Code'', N''homePostalCode'', NULL, NULL, N''Home Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8109, @EmployeeKey, N''Home Country'', N''homeCountry'', NULL, NULL, N''Home Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8110, @EmployeeKey, N''Other Address 1'', N''otherAddress1'', NULL, NULL, N''Other Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8111, @EmployeeKey, N''Other Address 2'', N''otherAddress2'', NULL, NULL, N''Other Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8112, @EmployeeKey, N''Other Address 3'', N''otherAddress3'', NULL, NULL, N''Other Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8113, @EmployeeKey, N''Other City'', N''otherCity'', NULL, NULL, N''Other City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8114, @EmployeeKey, N''Other State'', N''otherState'', NULL, NULL, N''Other State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8115, @EmployeeKey, N''Other Postal Code'', N''otherPostalCode'', NULL, NULL, N''Other Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8116, @EmployeeKey, N''Other Country'', N''otherCountry'', NULL, NULL, N''Other Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8117, @EmployeeKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8118, @EmployeeKey, N''PO Order Limit'', N''poLimit'', NULL, NULL, N''PO Order Limit'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8119, @EmployeeKey, N''Insertion Order Limit'', N''ioLimit'', NULL, NULL, N''Insertion Order Limit'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8120, @EmployeeKey, N''Broadcast Order Limit'', N''bcLimit'', NULL, NULL, N''Broadcast Order Limit'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8121, @EmployeeKey, N''Default GL Company'', N''defaultGLCompany'', NULL, NULL, N''Default GL Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8122, @EmployeeKey, N''Services'', N''services'', NULL, NULL, N''Services, use ; to seperate multiple'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8123, @EmployeeKey, N''Default Service'', N''defaultService'', NULL, NULL, N''Default Service'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8124, @EmployeeKey, N''GL Companies'', N''glCompanies'', NULL, NULL, N''GL Companies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8125, @EmployeeKey, N''Billing Title ID'', N''billingTitleID'', NULL, NULL, N''Billing Title ID'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''billingtitles'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3001, @EmployeeKey, N''Supervisor Name'', N''supervisorName'', NULL, NULL, N''Supervisor Name aka My Supervisor'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3002, @EmployeeKey, N''Vendor Cost'', N''vendorCost'', NULL, NULL, N''Vendor Cost if user is a vendor'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3003, @EmployeeKey, N''Require Min Hours Per Week'', N''requireMinHoursPerWeek'', NULL, NULL, N''Require Min Hours Per Week'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3004, @EmployeeKey, N''Min Hours Per Week'', N''minHoursPerWeek'', NULL, NULL, N''Minimum Hours Per Week'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3005, @EmployeeKey, N''Do Not Use SSO Auth'', N''doNotUseSSO'', NULL, NULL, N''Do Not Use SAML/SSO Authentication'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (810026, @EmployeeKey, N''Overtime Cost'', N''overtimeCost'', NULL, NULL, N''Overtime Cost'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.TrackOvertime == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (810027, @EmployeeKey, N''Overtime Vendor Cost'', N''overtimeVendorCost'', NULL, NULL, N''Overtime Vendor Cost'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.TrackOvertime == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (810028, @EmployeeKey, N''Contractor'', N''contractor'', NULL, NULL, N''Contractor'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Estimates
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8126, @EstimateKey, N''Estimate Number'', N''estimateNumber'', NULL, NULL, N''Estimate Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8127, @EstimateKey, N''Estimate Name'', N''estimateName'', NULL, NULL, N''Estimate Name'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8128, @EstimateKey, N''Estimate Type'', N''estType'', NULL, NULL, N''Estimate Type'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8129, @EstimateKey, N''Revision'', N''revision'', NULL, NULL, N''Revision'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8130, @EstimateKey, N''Change Order'', N''changeOrder'', NULL, NULL, N''Change Order'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8131, @EstimateKey, N''Contact Name'', N''contactName'', NULL, NULL, N''Contact Name'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8132, @EstimateKey, N''Project Number'', N''projectKey'', NULL, NULL, N''Project Number'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8133, @EstimateKey, N''Estimate Date'', N''estimateDate'', NULL, NULL, N''Estimate Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8134, @EstimateKey, N''Estimate Description'', N''estDescription'', NULL, NULL, N''Estimate Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8135, @EstimateKey, N''Estimate Template'', N''estimateTemplateName'', NULL, NULL, N''Estimate Template'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8136, @EstimateKey, N''User Defined 1'', N''userDefined1'', NULL, NULL, N''User Defined 1'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8137, @EstimateKey, N''User Defined 2'', N''userDefined2'', NULL, NULL, N''User Defined 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8138, @EstimateKey, N''User Defined 3'', N''userDefined3'', NULL, NULL, N''User Defined 3'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8139, @EstimateKey, N''User Defined 4'', N''userDefined4'', NULL, NULL, N''User Defined 4'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8140, @EstimateKey, N''User Defined 5'', N''userDefined5'', NULL, NULL, N''User Defined 5'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8141, @EstimateKey, N''User Defined 6'', N''userDefined6'', NULL, NULL, N''User Defined 6'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8142, @EstimateKey, N''User Defined 7'', N''userDefined7'', NULL, NULL, N''User Defined 7'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8143, @EstimateKey, N''User Defined 8'', N''userDefined8'', NULL, NULL, N''User Defined 8'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8144, @EstimateKey, N''User Defined 9'', N''userDefined9'', NULL, NULL, N''User Defined 9'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8145, @EstimateKey, N''User Defined 10'', N''userDefined10'', NULL, NULL, N''User Defined 10'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8146, @EstimateKey, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8147, @EstimateKey, N''Sales Tax ID 2'', N''salesTax2ID'', NULL, NULL, N''Sales Tax ID 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8148, @EstimateKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8149, @EstimateKey, N''Approver'', N''internalApprover'', NULL, NULL, N''Approver'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8150, @EstimateKey, N''Approval Comment'', N''internalComments'', NULL, NULL, N''Approval Comment'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8151, @EstimateKey, N''Approval Date'', N''approvalDate'', NULL, NULL, N''Approval Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8152, @EstimateKey, N''Layout Name'', N''layoutKey'', NULL, NULL, N''Layout Name'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8153, @EstimateKey, N''Labor Taxable'', N''laborTaxable'', NULL, NULL, N''Labor Taxable'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8154, @EstimateKey, N''Contingency'', N''contingency'', NULL, NULL, N''Contingency'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8155, @EstimateKey, N''Line Type'', N''lineType'', NULL, NULL, N''Line Type'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8156, @EstimateKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID. Maybe required based on estimate type'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8157, @EstimateKey, N''Service Code'', N''serviceCode'', NULL, NULL, N''Service Code. Maybe required based on estimate type'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8158, @EstimateKey, N''Person'', N''userKey'', NULL, NULL, N''Person'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8159, @EstimateKey, N''Hours'', N''hours'', NULL, NULL, N''Hours'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8160, @EstimateKey, N''Labor Net'', N''laborNet'', NULL, NULL, N''Labor Net'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8161, @EstimateKey, N''Labor Gross'', N''laborGross'', NULL, NULL, N''Labor Gross'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8162, @EstimateKey, N''Labor Rate Net'', N''laborRateNet'', NULL, NULL, N''Labor Rate Net'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8163, @EstimateKey, N''Labor Rate Gross'', N''laborRateGross'', NULL, NULL, N''Labor Rate Gross'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8164, @EstimateKey, N''Markup'', N''markup'', NULL, NULL, N''Markup'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8165, @EstimateKey, N''Expense Net'', N''expenseNet'', NULL, NULL, N''Expense Net'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8166, @EstimateKey, N''Expense Gross'', N''expenseGross'', NULL, NULL, N''Expense Gross'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8167, @EstimateKey, N''Item ID (Expense)'', N''itemKey'', NULL, NULL, N''Item ID (Expense). Maybe required based on estimate type'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8168, @EstimateKey, N''Vendor ID (Expense)'', N''vendorKey'', NULL, NULL, N''Vendor ID (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8169, @EstimateKey, N''Billable (Expense)'', N''billable'', NULL, NULL, N''Billable (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8170, @EstimateKey, N''Taxable (Expense)'', N''taxable'', NULL, NULL, N''Taxable (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8171, @EstimateKey, N''Taxable 2 (Expense)'', N''taxable2'', NULL, NULL, N''Taxable 2 (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8172, @EstimateKey, N''Quantity (Expense)'', N''quantity'', NULL, NULL, N''Quantity (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8173, @EstimateKey, N''Description (Expense)'', N''description'', NULL, NULL, N''Description (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8174, @EstimateKey, N''Unit Cost (Expense)'', N''unitCost'', NULL, NULL, N''Unit Cost (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8175, @EstimateKey, N''Unit Rate (Expense)'', N''unitRate'', NULL, NULL, N''Unit Rate (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8176, @EstimateKey, N''Unit Description (Expense)'', N''unitDescription'', NULL, NULL, N''Unit Description (Expense). Maybe required based on estimate type'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8177, @EstimateKey, N''Display Order (Expense)'', N''displayOrder'', NULL, NULL, N''Display Order (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8178, @EstimateKey, N''Class ID (Expense)'', N''classKey'', NULL, NULL, N''Class ID (Expense). Maybe required based on estimate type'', N''detail'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (16001, @EstimateKey, N''Long Description (Expense)'', N''longDescription'', NULL, NULL, N''Long Description (Expense)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
-- Expense Report Items
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8179, 4, N''Item ID'', N''itemID'', NULL, N''ItemID'', N''Item ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8180, 4, N''Item Name'', N''itemName'', NULL, N''ItemName'', N''Item Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8181, 4, N''Unit Cost'', N''unitCost'', NULL, N''UnitCost'', N''Unit Cost'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8182, 4, N''Markup'', N''markup'', NULL, N''Markup'', N''Markup'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8183, 4, N''Unit Rate'', N''unitRate'', NULL, N''UnitRate'', N''Unit Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8184, 4, N''Always use Unit Rate for Gross Amount'', N''useUnitRate'', NULL, N''UseUnitRate'', N''Always use Unit Rate for Gross Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8185, 4, N''Standard Description'', N''standardDescription'', NULL, N''StandardDescription'', N''Standard Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8186, 4, N''Use Description on Expense Report'', N''useDescription'', NULL, N''UseDescription'', N''Use Description on Expense Report'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8187, 4, N''Billing Item ID'', N''workTypeKey'', NULL, N''WorkTypeID'', N''Billing Item ID'', NULL, NULL, N''WorkTypeID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8188, 4, N''Department'', N''departmentKey'', NULL, N''DepartmentName'', N''Department. Required if Department is required'', NULL, 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8189, 4, N''Expense Account Number'', N''expenseAccountKey'', NULL, N''ExpenseAccountNumber'', N''Expense Account Number'', NULL, NULL, N''ExpenseAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8190, 4, N''Sales Account Number'', N''salesAccountKey'', NULL, N''SalesAccountNumber'', N''Sales Account Number'', NULL, NULL, N''SalesAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8191, 4, N''Tax 1 Applies'', N''taxable'', NULL, N''Taxable'', N''Tax 1 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8192, 4, N''Tax 2 Applies'', N''taxable2'', NULL, N''Taxable2'', N''Tax 2 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8193, 4, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8194, 4, N''Class ID'', N''classID'', NULL, N''ClassID'', N''Class ID'', NULL, NULL, N''ClassID. Required if Class is required'', NULL, 2, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (819400, 4, N''Avalara Tax Code'', N''avalaraTaxCodeKey'', NULL, N''AvalaraTaxCode'', N''Avalara Tax Code'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''avalara'''')'')

-- Expense Reports
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8195, @ExpenseReportKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8196, @ExpenseReportKey, N''Report Number'', N''envelopeNumber'', NULL, NULL, N''Report Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8197, @ExpenseReportKey, N''Name'', N''userName'', NULL, NULL, N''Name'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8198, @ExpenseReportKey, N''Sales Tax 1'', N''salesTaxID'', NULL, NULL, N''Sales Tax 1'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8199, @ExpenseReportKey, N''Sales Tax 2'', N''salesTax2ID'', NULL, NULL, N''Sales Tax 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8200, @ExpenseReportKey, N''Comments'', N''comments'', NULL, NULL, N''Comments'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8201, @ExpenseReportKey, N''Date'', N''expenseDate'', NULL, NULL, N''Date'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8202, @ExpenseReportKey, N''Item ID'', N''itemID'', NULL, NULL, N''Item ID. Required if Items are required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8203, @ExpenseReportKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8204, @ExpenseReportKey, N''Project Number (Line)'', N''projectNumber'', NULL, NULL, N''Project Number (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8205, @ExpenseReportKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID. Required if tasks are required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8206, @ExpenseReportKey, N''Paper Receipt'', N''paperReceipt'', NULL, NULL, N''Paper Receipt'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8207, @ExpenseReportKey, N''Quantity'', N''actualQty'', NULL, NULL, N''Quantity'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8208, @ExpenseReportKey, N''Unit Cost'', N''actualUnitCost'', NULL, NULL, N''Unit Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8209, @ExpenseReportKey, N''Net Cost'', N''actualCost'', NULL, NULL, N''Net Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8210, @ExpenseReportKey, N''Billable'', N''billable'', NULL, NULL, N''Billable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8211, @ExpenseReportKey, N''Markup'', N''markup'', NULL, NULL, N''Markup'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8212, @ExpenseReportKey, N''Unit Rate'', N''unitRate'', NULL, NULL, N''Unit Rate'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8213, @ExpenseReportKey, N''Gross Cost'', N''grossAmount'', NULL, NULL, N''Gross Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8214, @ExpenseReportKey, N''Tax1 (Line)'', N''taxable'', NULL, NULL, N''Tax1 (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8215, @ExpenseReportKey, N''Tax2 (Line)'', N''taxable2'', NULL, NULL, N''Tax2 (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8216, @ExpenseReportKey, N''Sales Tax 1 Amount'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax 1 Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8217, @ExpenseReportKey, N''Sales Tax 2 Amount'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax 2 Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8218, @ExpenseReportKey, N''Total Sales Tax Amount'', N''salesTaxAmount'', NULL, NULL, N''Total Sales Tax Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8219, @ExpenseReportKey, N''Comments (Line)'', N''commentsline'', NULL, NULL, N''Comments (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8220, @ExpenseReportKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8221, @ExpenseReportKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8222, @ExpenseReportKey, N''Exchange Rate (Line)'', N''pExchangeRate'', NULL, NULL, N''Exchange Rate (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (2201, @ExpenseReportKey, N''Approval Status'', N''approvalStatus'', NULL, NULL, N''Approval Staus - Unsubmitted, Submittted, Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
-- financial Budgets
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8223, @GLBudget, N''Budget Name'', N''budgetName'', NULL, N''BudgetName'', N''Budget Name'', N''header'', 1, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8224, @GLBudget, N''Active'', N''active'', NULL, N''Active'', N''Active'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8225, @GLBudget, N''GL Account'', N''glAccountNumber'', NULL, N''AccountNumber'', N''GL Account'', N''detail'', 1, N''AccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8226, @GLBudget, N''Client ID'', N''clientID'', NULL, N''ClientID'', N''Client ID'', N''detail'', NULL, N''CustomerID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8227, @GLBudget, N''GL Company'', N''glCompany'', NULL, N''GLCompanyID'', N''GL Company. Required if GL Company is required'', N''detail'', 2, N''GLCompanyName'', NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8228, @GLBudget, N''Office'', N''officeID'', NULL, N''OfficeID'', N''Office. Required if Office is required'', N''detail'', 2, N''OfficeName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8229, @GLBudget, N''Department'', N''department'', NULL, N''DepartmentName'', N''Department. Required if department is required'', N''detail'', 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8230, @GLBudget, N''Month 1'', N''month1'', NULL, N''Month1'', N''Month 1'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8231, @GLBudget, N''Month 2'', N''month2'', NULL, N''Month2'', N''Month 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8232, @GLBudget, N''Month 3'', N''month3'', NULL, N''Month3'', N''Month 3'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8233, @GLBudget, N''Month 4'', N''month4'', NULL, N''Month4'', N''Month 4'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8234, @GLBudget, N''Month 5'', N''month5'', NULL, N''Month5'', N''Month 5'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8235, @GLBudget, N''Month 6'', N''month6'', NULL, N''Month6'', N''Month 6'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8236, @GLBudget, N''Month 7'', N''month7'', NULL, N''Month7'', N''Month 7'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8237, @GLBudget, N''Month 8'', N''month8'', NULL, N''Month8'', N''Month 8'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8238, @GLBudget, N''Month 9'', N''month9'', NULL, N''Month9'', N''Month 9'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8239, @GLBudget, N''Month 10'', N''month10'', NULL, N''Month10'', N''Month 10'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8240, @GLBudget, N''Month 11'', N''month11'', NULL, N''Month11'', N''Month 11'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8241, @GLBudget, N''Month 12'', N''month12'', NULL, N''Month12'', N''Month 12'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8242, @GLBudget, N''Class ID'', N''classKey'', NULL, N''ClassID'', N''Class ID. Required if Class is required'', N''detail'', 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
-- GL Accounts
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8243, @GLAccountKey, N''Account Type'', N''accountType'', NULL, N''AccountTypeName'', N''Account Type'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8244, @GLAccountKey, N''Account Number'', N''accountNumber'', NULL, N''AccountNumber'', N''Account Number'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8245, @GLAccountKey, N''Account Name'', N''accountName'', NULL, N''AccountName'', N''Account Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8246, @GLAccountKey, N''Cash Account Type'', N''accountTypeCash'', NULL, N''AccountTypeNameCash'', N''Cash Account Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8247, @GLAccountKey, N''Payroll Expense Account'', N''payrollExpense'', NULL, N''PayrollExpenseYN'', N''Payroll Expense Account'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8248, @GLAccountKey, N''Facility Expense Account'', N''facilityExpense'', NULL, N''FacilityExpenseYN'', N''Facility Expense Account'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8249, @GLAccountKey, N''Labor Income'', N''laborIncome'', NULL, N''LaborIncome'', N''Labor Income'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8250, @GLAccountKey, N''Rollup Account'', N''rollup'', NULL, N''Rollup'', N''Rollup Account'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8251, @GLAccountKey, N''Sub Account Of'', N''parentAccountNumber'', NULL, N''ParentAccountNumber'', N''Sub Account Of (Enter ''''none'''', if changing from one to none)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8252, @GLAccountKey, N''Vendor ID'', N''vendorID'', NULL, N''VendorID'', N''Vendor ID. Required if the Account Type is credit card'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8253, @GLAccountKey, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8254, @GLAccountKey, N''Bank Account Number'', N''bankAccountNumber'', NULL, N''BankAccountNumber'', N''Bank Account Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8255, @GLAccountKey, N''Next Check Number'', N''nextCheckNumber'', NULL, N''NextCheckNumber'', N''Next Check Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8256, @GLAccountKey, N''No Journal Entries'', N''noJournalEntries'', NULL, N''NoJournalEntries'', N''No Journal Entries'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8257, @GLAccountKey, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (601, @GLAccountKey, N''EBITDA Account'', N''ebitdaaccount'', NULL, N''ebitdaaccount'', N''ebitdaaccount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (602, @GLAccountKey, N''Currency ID'', N''currencyID'', NULL, N''CurrencyID'', N''Currency ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- GL Classes
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8258, 54, N''Class ID'', N''classID'', NULL, N''ClassID'', N''Class ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8259, 54, N''Class Name'', N''className'', NULL, N''ClassName'', N''Class Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8260, 54, N''Office'', N''officeID'', NULL, N''DepartmentName'', N''Office'', NULL, NULL, N''OfficeName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8261, 54, N''Department'', N''departmentID'', NULL, N''OfficeID'', N''Department'', NULL, NULL, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8262, 54, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8263, 54, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--GL Companies
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8264, 33, N''Company Name'', N''glCompanyName'', NULL, N''GLCompanyName'', N''Company Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8265, 33, N''Company ID'', N''glCompanyID'', NULL, N''GLCompanyID'', N''Company ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8266, 33, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8268, 33, N''Printed Name'', N''printedName'', NULL, N''PrintedName'', N''Printed Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8269, 33, N''Phone'', N''phone'', NULL, N''Phone'', N''Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8270, 33, N''Fax'', N''fax'', NULL, N''Fax'', N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8271, 33, N''EIN Number'', N''eINNumber'', NULL, N''EINNumber'', N''EIN Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8272, 33, N''State EIN Number'', N''stateEINNumber'', NULL, N''StateEINNumber'', N''State EIN Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8273, 33, N''Web Site'', N''webSite'', NULL, N''WebSite'', N''Web Site'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8274, 33, N''Bank GL Account Number'', N''bankAccountNumber'', NULL, N''AccountNumber'', N''Bank GL Account Number'', NULL, NULL, N''AccountNumber'', NULL, NULL, NULL, NULL)
--Insertion Order
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8275, @IOKey, N''Order Number'', N''purchaseOrderNumber'', NULL, NULL, N''Order Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8276, @IOKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8277, @IOKey, N''Order Type'', N''purchaseOrderType'', NULL, NULL, N''Order Type'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8278, @IOKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number. Requierd if Link to Partner is required'', N''header'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8279, @IOKey, N''Contact'', N''contact'', NULL, NULL, N''Contact'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8280, @IOKey, N''Order Date'', N''pODate'', NULL, NULL, N''Order Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition], [SystemSettingFieldName]) VALUES (8281, @IOKey, N''Publication ID'', N''companyMediaID'', NULL, NULL, N''Publication ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL, N''IORequirePublications'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8282, @IOKey, N''Ordered By'', N''orderedBy'', NULL, NULL, N''Ordered By'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8283, @IOKey, N''Standard Header Text'', N''headerTextID'', NULL, NULL, N''Standard Header Text'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8284, @IOKey, N''Standard Footer Text'', N''footerTextID'', NULL, NULL, N''Standard Footer Text'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8285, @IOKey, N''Approver'', N''approvedBy'', NULL, NULL, N''Approver'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8286, @IOKey, N''Printing Mode'', N''orderDisplayMode'', NULL, NULL, N''Printing Mode'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8287, @IOKey, N''Print Client On Order'', N''printClientOnOrder'', NULL, NULL, N''Print Client On Order'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8288, @IOKey, N''GL Company'', N''glCompany'', NULL, NULL, N''GL Company. Required if GL Company is required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8289, @IOKey, N''Prebill At'', N''prebillAt'', NULL, NULL, N''Prebill At'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8290, @IOKey, N''Media Estimate ID'', N''mediaEstimateID'', NULL, NULL, N''Media Estimate ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8292, @IOKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8293, @IOKey, N''Project Number (Line)'', N''projectNumber'', NULL, NULL, N''Project Number (Line). Requierd if Link to Partner is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8294, @IOKey, N''Detail Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Detail Field Group ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8295, @IOKey, N''Office ID'', N''officeID'', NULL, NULL, N''Office ID. Required if Office is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8296, @IOKey, N''Item ID'', N''itemID'', NULL, NULL, N''Item ID. Required if item is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8298, @IOKey, N''Department'', N''departmentID'', NULL, NULL, N''Department'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8299, @IOKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID. Requierd if Link to Partner is required and task is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8300, @IOKey, N''Ad Number/Caption'', N''shortDescription'', NULL, NULL, N''Ad#/Caption'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8301, @IOKey, N''Comments'', N''longDescription'', NULL, NULL, N''Comments'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8302, @IOKey, N''Gross'', N''grossAmount'', NULL, NULL, N''Gross'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8303, @IOKey, N''Net Cost'', N''totalCost'', NULL, NULL, N''Net Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8304, @IOKey, N''Commission Pct'', N''markup'', NULL, NULL, N''Commission Pct'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8305, @IOKey, N''Class ID'', N''classKey'', NULL, NULL, N''Class ID. Required if Class is required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8306, @IOKey, N''Class ID (Line)'', N''classKey'', NULL, NULL, N''Class ID (Line). Required if Class is required'', N''detail'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8307, @IOKey, N''Space Close'', N''spaceClose'', NULL, NULL, N''Space Close'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8308, @IOKey, N''Materials Due'', N''materialsDue'', NULL, NULL, N''Materials Due'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8309, @IOKey, N''*[MediaPrint3]'', N''userDate3'', NULL, NULL, N''*[MediaPrint3]'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8310, @IOKey, N''*[MediaPrint4]'', N''userDate4'', NULL, NULL, N''*[MediaPrint4]'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8311, @IOKey, N''*[MediaPrint5]'', N''userDate5'', NULL, NULL, N''*[MediaPrint5]'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8312, @IOKey, N''*[MediaPrint6]'', N''userDate6'', NULL, NULL, N''*[MediaPrint6]'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (34001, @IOKey, N''Traffic Instructions'', N''trafficInstructions'', NULL, NULL, N''Traffic Instructions'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (34002, @IOKey, N''Special Instructions'', N''specialInstructions'', NULL, NULL, N''Special Instructions'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (34003, @IOKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (34004, @IOKey, N''Insertion Date'', N''detailOrderStartDate'', NULL, NULL, N''Insertion Date'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3406, @IOKey, N''Currency ID'', N''currencyID'', NULL, NULL, N''Currency ID'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3407, @IOKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3408, @IOKey, N''Exchange Rate (Line)'', N''pExchangeRate'', NULL, NULL, N''Exchange Rate (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3409, @IOKey, N''Sales Tax Amount'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3410, @IOKey, N''Sales Tax Amount 2'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax Amount 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3411, @IOKey, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3412, @IOKey, N''Sales Tax ID 2'', N''salesTax2ID'', NULL, NULL, N''Sales Tax ID 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3413, @IOKey, N''Header Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Header Field Group ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3414, @IOKey, N''Header ID'', N''headerID'', NULL, NULL, N''Header ID, used for associating header and detail fields when they do not pass in the PO Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3415, @IOKey, N''Billable'', N''billable'', NULL, NULL, N''Billable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)

-- invoices aka client invoices
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8313, @InvoiceKey, N''Invoice Number'', N''invoiceNumber'', NULL, NULL, N''Invoice Number'', N''header'', 1, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8314, @InvoiceKey, N''Client ID'', N''clientKey'', NULL, NULL, N''Client ID'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8315, @InvoiceKey, N''Contact Name'', N''contactName'', NULL, NULL, N''Contact Name'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8316, @InvoiceKey, N''Project Number'', N''projectKey'', NULL, NULL, N''Project Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8317, @InvoiceKey, N''Office'', N''officeKey'', NULL, NULL, N''Office'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8318, @InvoiceKey, N''Advance Bill'', N''advanceBill'', NULL, NULL, N''Advance Bill'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8319, @InvoiceKey, N''Invoice Date'', N''invoiceDate'', NULL, NULL, N''Invoice Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8320, @InvoiceKey, N''Posting Date'', N''postingDate'', NULL, NULL, N''Posting Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8321, @InvoiceKey, N''Due Date'', N''dueDate'', NULL, NULL, N''Due Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8322, @InvoiceKey, N''AR Account Number'', N''aRAccountKey'', NULL, NULL, N''AR Account Number. Required if GL account is required'', N''header'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8323, @InvoiceKey, N''Terms Description'', N''termsKey'', NULL, NULL, N''Terms Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8324, @InvoiceKey, N''Invoice Comment'', N''headerComment'', NULL, NULL, N''Invoice Comment'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8325, @InvoiceKey, N''Invoice Template'', N''invoiceTemplateKey'', NULL, NULL, N''Invoice Template'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8326, @InvoiceKey, N''User Defined 1'', N''userDefined1'', NULL, NULL, N''User Defined 1'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8327, @InvoiceKey, N''User Defined 2'', N''userDefined2'', NULL, NULL, N''User Defined 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8328, @InvoiceKey, N''User Defined 3'', N''userDefined3'', NULL, NULL, N''User Defined 3'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8329, @InvoiceKey, N''User Defined 4'', N''userDefined4'', NULL, NULL, N''User Defined 4'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8330, @InvoiceKey, N''User Defined 5'', N''userDefined5'', NULL, NULL, N''User Defined 5'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8331, @InvoiceKey, N''User Defined 6'', N''userDefined6'', NULL, NULL, N''User Defined 6'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8332, @InvoiceKey, N''User Defined 7'', N''userDefined7'', NULL, NULL, N''User Defined 7'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8333, @InvoiceKey, N''User Defined 8'', N''userDefined8'', NULL, NULL, N''User Defined 8'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8334, @InvoiceKey, N''User Defined 9'', N''userDefined9'', NULL, NULL, N''User Defined 9'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8335, @InvoiceKey, N''User Defined 10'', N''userDefined10'', NULL, NULL, N''User Defined 10'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8336, @InvoiceKey, N''Sales Tax ID'', N''salesTaxKey'', NULL, NULL, N''Sales Tax ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8337, @InvoiceKey, N''Sales Tax ID 2'', N''salesTax2Key'', NULL, NULL, N''Sales Tax ID 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8338, @InvoiceKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8339, @InvoiceKey, N''Approver'', N''approvedByKey'', NULL, NULL, N''Approver'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8340, @InvoiceKey, N''Approval Comment'', N''approvalComment'', NULL, NULL, N''Approval Comment'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8341, @InvoiceKey, N''Approval Date'', N''approvalDate'', NULL, NULL, N''Approval Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8342, @InvoiceKey, N''GL Company'', N''glCompanyKey'', NULL, NULL, N''GL Company. Required if GL Company is required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8343, @InvoiceKey, N''Opening Transaction'', N''openingTransaction'', NULL, NULL, N''Opening Transaction'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8344, @InvoiceKey, N''Campaign ID'', N''campaignKey'', NULL, NULL, N''Campaign ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8345, @InvoiceKey, N''Layout Name'', N''layoutKey'', NULL, NULL, N''Layout Name'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8346, @InvoiceKey, N''Alternative Payer'', N''alternativePayer'', NULL, NULL, N''Alternative Payer'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8347, @InvoiceKey, N''Billing Group'', N''billingGroup'', NULL, NULL, N''Billing Group'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8348, @InvoiceKey, N''Line Subject'', N''lineSubject'', NULL, NULL, N''Line Subject'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8349, @InvoiceKey, N''Line Description'', N''lineDescription'', NULL, NULL, N''Line Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8350, @InvoiceKey, N''Project Number (Line)'', N''projectKey'', NULL, NULL, N''Project Number (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8351, @InvoiceKey, N''Task ID'', N''taskKey'', NULL, NULL, N''Task ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8352, @InvoiceKey, N''Office (Line)'', N''officeKey'', NULL, NULL, N''Office (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8353, @InvoiceKey, N''Department'', N''departmentKey'', NULL, NULL, N''Department. Required if department is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8354, @InvoiceKey, N''Sales Account Number'', N''salesAccountKey'', NULL, NULL, N''Sales Account Number. Required if GL Account is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8355, @InvoiceKey, N''Quantity'', N''quantity'', NULL, NULL, N''Quantity'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8356, @InvoiceKey, N''Unit Amount'', N''unitAmount'', NULL, NULL, N''Unit Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8357, @InvoiceKey, N''Total Amount'', N''totalAmount'', NULL, NULL, N''Total Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (110001, @InvoiceKey, N''Total Amount (Home Currency)'', N''hcTotalAmount'', NULL, NULL, N''Total Amount (Home Currency)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (110002, @InvoiceKey, N''Class ID (line)'', N''classID'', NULL, NULL, N''Class ID (line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (110003, @InvoiceKey, N''Class ID'', N''classID'', NULL, NULL, N''Class ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)

INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8358, @InvoiceKey, N''Sales Tax Amount'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8359, @InvoiceKey, N''Sales Tax Amount 2'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax Amount 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8360, @InvoiceKey, N''Taxable'', N''taxable'', NULL, NULL, N''Taxable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8361, @InvoiceKey, N''Taxable 2'', N''taxable2'', NULL, NULL, N''Taxable 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8362, @InvoiceKey, N''Segment Name'', N''campaignSegmentKey'', NULL, NULL, N''Segment Name'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8363, @InvoiceKey, N''Retainer Title'', N''retainerKey'', NULL, NULL, N''Retainer Title'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8364, @InvoiceKey, N''Billing Item ID'', N''workTypeKey'', NULL, NULL, N''Billing Item ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8365, @InvoiceKey, N''Item Type'', N''entity'', NULL, NULL, N''Item Type'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8366, @InvoiceKey, N''Item ID'', N''entityKey'', NULL, NULL, N''Item ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8367, @InvoiceKey, N''Display Option'', N''displayOption'', NULL, NULL, N''Display Option'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8368, @InvoiceKey, N''Target GL Company'', N''targetGLCompanyKey'', NULL, NULL, N''Target GL Company'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8369, @InvoiceKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8370, @InvoiceKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (110011, @InvoiceKey, N''GL Company Exchange Rate'', N''glcExchangeRate'', NULL, NULL, N''GL Company Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11001, @InvoiceKey, N''Posted'', N''posted'', NULL, NULL, N''Posted - this will posted the invoice if true'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
-- Item Rate Sheet
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8371, @ItemRateSheetKey, N''Rate Sheet Name'', N''rateSheetName'', NULL, N''RateSheetName'', N''Rate Sheet Name'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8372, @ItemRateSheetKey, N''Active'', N''active'', NULL, N''Active'', N''Active'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8373, @ItemRateSheetKey, N''Item ID'', N''itemID'', NULL, N''ItemID'', N''Item ID'', N''detail'', 1, N''ItemID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8374, @ItemRateSheetKey, N''Markup'', N''markup'', NULL, N''Markup'', N''Markup'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8375, @ItemRateSheetKey, N''Unit Rate'', N''unitRate'', NULL, N''UnitRate'', N''Unit Rate'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
-- Journal Entries
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8376, @JEKey, N''Posting Date'', N''postingDate'', NULL, NULL, N''Posting Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8377, @JEKey, N''Journal Number'', N''journalNumber'', NULL, NULL, N''Journal Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8378, @JEKey, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company. Required if GL Company is required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8379, @JEKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8380, @JEKey, N''Auto Reversing Entry'', N''autoReverse'', NULL, NULL, N''Auto Reversing Entry'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8381, @JEKey, N''Exclude From Cash Basis'', N''excludeCashBasis'', NULL, NULL, N''Exclude From Cash Basis'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8382, @JEKey, N''Exclude From Accrual Basis'', N''excludeAccrualBasis'', NULL, NULL, N''Exclude From Accrual Basis'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8383, @JEKey, N''Intercompany DT/DF Source'', N''intercompanyAccountSource'', NULL, NULL, N''Intercompany DT/DF Source'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8384, @JEKey, N''Account Number'', N''accountNumber'', NULL, NULL, N''Account Number'', N''detail'', 1, N''AccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8385, @JEKey, N''Client ID'', N''clientKey'', NULL, NULL, N''Client ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8386, @JEKey, N''Project'', N''projectKey'', NULL, NULL, N''Project'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8387, @JEKey, N''Office'', N''officeKey'', NULL, NULL, N''Office. Required if Office is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8388, @JEKey, N''Department'', N''departmentKey'', NULL, NULL, N''Department. Required if Department is required'', N''detail'', 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8389, @JEKey, N''Debit'', N''debitAmount'', NULL, NULL, N''Debit'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8390, @JEKey, N''Credit'', N''creditAmount'', NULL, NULL, N''Credit'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8391, @JEKey, N''Memo'', N''memo'', NULL, NULL, N''Memo'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8392, @JEKey, N''Target GL Company'', N''targetGLCompanyKey'', NULL, NULL, N''Target GL Company'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8393, @JEKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8394, @JEKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8395, @JEKey, N''Exchange Rate (Line)'', N''exchangeRateLine'', NULL, NULL, N''Exchange Rate (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8396, @JEKey, N''Class ID'', N''classKey'', NULL, NULL, N''Class ID. Required if Class is required'', N''detail'', 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (24001, @JEKey, N''Posted'', N''posted'', NULL, NULL, N''Posted - Yes Or No, to automatically post'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (24002, @JEKey, N''GLC Exchange Rate'', N''glcExchangeRate'', NULL, NULL, N''GL Company Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')

-- Labor Budgets
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8397, 75, N''Budget Name'', N''budgetName'', NULL, NULL, N''Budget Name'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8398, 75, N''Active'', N''active'', NULL, NULL, N''Active'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8399, 75, N''Employee Email'', N''email'', NULL, NULL, N''Employee Email'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8400, 75, N''Comments'', N''editComments'', NULL, NULL, N''Comments'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8401, 75, N''Available Hours 1'', N''availableHours1'', NULL, NULL, N''Available Hours 1'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8402, 75, N''Target Hours 1'', N''targetHours1'', NULL, NULL, N''Target Hours 1'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8403, 75, N''Target Dollars 1'', N''targetDollars1'', NULL, NULL, N''Target Dollars 1'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8404, 75, N''Available Hours 2'', N''availableHours2'', NULL, NULL, N''Available Hours 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8405, 75, N''Target Hours 2'', N''targetHours2'', NULL, NULL, N''Target Hours 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8406, 75, N''Target Dollars 2'', N''targetDollars2'', NULL, NULL, N''Target Dollars 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8407, 75, N''Available Hours 3'', N''availableHours3'', NULL, NULL, N''Available Hours 3'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8408, 75, N''Target Hours 3'', N''targetHours3'', NULL, NULL, N''Target Hours 3'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8409, 75, N''Target Dollars 3'', N''targetDollars3'', NULL, NULL, N''Target Dollars 3'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8410, 75, N''Available Hours 4'', N''availableHours4'', NULL, NULL, N''Available Hours 4'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8411, 75, N''Target Hours 4'', N''targetHours4'', NULL, NULL, N''Target Hours 4'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8412, 75, N''Target Dollars 4'', N''targetDollars4'', NULL, NULL, N''Target Dollars 4'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8413, 75, N''Available Hours 5'', N''availableHours5'', NULL, NULL, N''Available Hours 5'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8414, 75, N''Target Hours 5'', N''targetHours5'', NULL, NULL, N''Target Hours 5'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8415, 75, N''Target Dollars 5'', N''targetDollars5'', NULL, NULL, N''Target Dollars 5'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8416, 75, N''Available Hours 6'', N''availableHours6'', NULL, NULL, N''Available Hours 6'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8417, 75, N''Target Hours 6'', N''targetHours6'', NULL, NULL, N''Target Hours 6'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8418, 75, N''Target Dollars 6'', N''targetDollars6'', NULL, NULL, N''Target Dollars 6'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8419, 75, N''Available Hours 7'', N''availableHours7'', NULL, NULL, N''Available Hours 7'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8420, 75, N''Target Hours 7'', N''targetHours7'', NULL, NULL, N''Target Hours 7'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8421, 75, N''Target Dollars 7'', N''targetDollars7'', NULL, NULL, N''Target Dollars 7'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8422, 75, N''Available Hours 8'', N''availableHours8'', NULL, NULL, N''Available Hours 8'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8423, 75, N''Target Hours 8'', N''targetHours8'', NULL, NULL, N''Target Hours 8'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8424, 75, N''Target Dollars 8'', N''targetDollars8'', NULL, NULL, N''Target Dollars 8'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8425, 75, N''Available Hours 9'', N''availableHours9'', NULL, NULL, N''Available Hours 9'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8426, 75, N''Target Hours 9'', N''targetHours9'', NULL, NULL, N''Target Hours 9'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8427, 75, N''Target Dollars 9'', N''targetDollars9'', NULL, NULL, N''Target Dollars 9'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8428, 75, N''Available Hours 10'', N''availableHours10'', NULL, NULL, N''Available Hours 10'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8429, 75, N''Target Hours 10'', N''targetHours10'', NULL, NULL, N''Target Hours 10'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8430, 75, N''Target Dollars 10'', N''targetDollars10'', NULL, NULL, N''Target Dollars 10'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8431, 75, N''Available Hours 11'', N''availableHours11'', NULL, NULL, N''Available Hours 11'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8432, 75, N''Target Hours 11'', N''targetHours11'', NULL, NULL, N''Target Hours 11'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8433, 75, N''Target Dollars 11'', N''targetDollars11'', NULL, NULL, N''Target Dollars 11'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8434, 75, N''Available Hours 12'', N''availableHours12'', NULL, NULL, N''Available Hours 12'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8435, 75, N''Target Hours 12'', N''targetHours12'', NULL, NULL, N''Target Hours 12'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8436, 75, N''Target Dollars 12'', N''targetDollars12'', NULL, NULL, N''Target Dollars 12'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--leads
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8437, @LeadKey, N''First Name'', N''firstName'', NULL, NULL, N''First Name'', NULL, NULL, NULL, 2, N''Full Name'', NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8438, @LeadKey, N''Middle Name'', N''middleName'', NULL, NULL, N''Middle Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8439, @LeadKey, N''Last Name'', N''lastName'', NULL, NULL, N''Last Name'', NULL, NULL, NULL, 2, N''Full Name'', NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8440, @LeadKey, N''Salutation'', N''salutation'', NULL, NULL, N''Salutation'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8441, @LeadKey, N''Phone 1'', N''phone1'', NULL, NULL, N''Phone 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8442, @LeadKey, N''Phone 2'', N''phone2'', NULL, NULL, N''Phone 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8443, @LeadKey, N''Cell'', N''cell'', NULL, NULL, N''Cell'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8444, @LeadKey, N''Fax'', N''fax'', NULL, NULL, N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8445, @LeadKey, N''Pager'', N''pager'', NULL, NULL, N''Pager'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8446, @LeadKey, N''Title'', N''title'', NULL, NULL, N''Title'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8447, @LeadKey, N''Email Address'', N''email'', NULL, NULL, N''Email Address'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8448, @LeadKey, N''Company'', N''companyName'', NULL, NULL, N''Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8449, @LeadKey, N''Company Main Phone'', N''companyPhone'', NULL, NULL, N''Company Main Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8450, @LeadKey, N''Company Fax'', N''companyFax'', NULL, NULL, N''Company Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8451, @LeadKey, N''Company Website'', N''companyWebsite'', NULL, NULL, N''Company Website'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8452, @LeadKey, N''Company Source'', N''companySourceKey'', NULL, NULL, N''Company Source'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8453, @LeadKey, N''Company Type'', N''companyTypeKey'', NULL, NULL, N''Company Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8454, @LeadKey, N''Business Address 1'', N''cAddress1'', NULL, NULL, N''Business Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8455, @LeadKey, N''Business Address 2'', N''cAddress2'', NULL, NULL, N''Business Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8456, @LeadKey, N''Business Address 3'', N''cAddress3'', NULL, NULL, N''Business Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8457, @LeadKey, N''Business City'', N''cCity'', NULL, NULL, N''Business City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8458, @LeadKey, N''Business State'', N''cState'', NULL, NULL, N''Business State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8459, @LeadKey, N''Business Postal Code'', N''cPostalCode'', NULL, NULL, N''Business Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8460, @LeadKey, N''Business Country'', N''cCountry'', NULL, NULL, N''Business Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8461, @LeadKey, N''Home Address 1'', N''hAddress1'', NULL, NULL, N''Home Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8462, @LeadKey, N''Home Address 2'', N''hAddress2'', NULL, NULL, N''Home Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8463, @LeadKey, N''Home Address 3'', N''hAddress3'', NULL, NULL, N''Home Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8464, @LeadKey, N''Home City'', N''hCity'', NULL, NULL, N''Home City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8465, @LeadKey, N''Home State'', N''hState'', NULL, NULL, N''Home State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8466, @LeadKey, N''Home Postal Code'', N''hPostalCode'', NULL, NULL, N''Home Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8467, @LeadKey, N''Home Country'', N''hCountry'', NULL, NULL, N''Home Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8468, @LeadKey, N''Other Address 1'', N''oAddress1'', NULL, NULL, N''Other Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8469, @LeadKey, N''Other Address 2'', N''oAddress2'', NULL, NULL, N''Other Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8470, @LeadKey, N''Other Address 3'', N''oAddress3'', NULL, NULL, N''Other Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8471, @LeadKey, N''Other City'', N''oCity'', NULL, NULL, N''Other City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8472, @LeadKey, N''Other State'', N''oState'', NULL, NULL, N''Other State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8473, @LeadKey, N''Other Postal Code'', N''oPostalCode'', NULL, NULL, N''Other Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8474, @LeadKey, N''Other Country'', N''oCountry'', NULL, NULL, N''Other Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8475, @LeadKey, N''Comments'', N''comments'', NULL, NULL, N''Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8476, @LeadKey, N''Department'', N''department'', NULL, NULL, N''Department'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8477, @LeadKey, N''Assistant'', N''assistant'', NULL, NULL, N''Assistant'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8478, @LeadKey, N''Assistant Phone'', N''assistantPhone'', NULL, NULL, N''Assistant Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8479, @LeadKey, N''Assistant Email'', N''assistantEmail'', NULL, NULL, N''Assistant Email'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8480, @LeadKey, N''Birthday'', N''birthday'', NULL, NULL, N''Birthday'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8481, @LeadKey, N''Spouse/Partner'', N''spouseName'', NULL, NULL, N''Spouse/Partner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8482, @LeadKey, N''Children'', N''children'', NULL, NULL, N''Children'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8483, @LeadKey, N''Anniversary'', N''anniversary'', NULL, NULL, N''Anniversary'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8484, @LeadKey, N''Hobbies'', N''hobbies'', NULL, NULL, N''Hobbies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8485, @LeadKey, N''Opportunity Subject'', N''opportunitySubject'', NULL, NULL, N''Opportunity Subject'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8486, @LeadKey, N''Opportunity Amount'', N''opportunityAmount'', NULL, NULL, N''Opportunity Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8487, @LeadKey, N''Opportunity Project Type'', N''opportunityProjectTypeKey'', NULL, NULL, N''Opportunity Project Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8488, @LeadKey, N''Opportunity Description'', N''opportunityDescription'', NULL, NULL, N''Opportunity Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8489, @LeadKey, N''Lead Owner'', N''ownerKey'', NULL, NULL, N''Lead Owner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8490, @LeadKey, N''Folder'', N''cMFolderKey'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8491, @LeadKey, N''Active'', N''active'', NULL, NULL, N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8492, @LeadKey, N''Timezone Index'', N''timeZoneIndex'', NULL, NULL, N''Timezone Index'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8493, @LeadKey, N''Marketing Groups'', N''marketingLists'', NULL, NULL, N''Marketing Groups'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8494, @LeadKey, N''Preferred Contact Method'', N''contactMethod'', NULL, NULL, N''Preferred Contact Method'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8495, @LeadKey, N''Do Not Call'', N''doNotCall'', NULL, NULL, N''Do Not Call'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8496, @LeadKey, N''Do Not Email'', N''doNotEmail'', NULL, NULL, N''Do Not Email'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8497, @LeadKey, N''Do Not Mail'', N''doNotMail'', NULL, NULL, N''Do Not Mail'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8498, @LeadKey, N''Do Not Fax'', N''doNotFax'', NULL, NULL, N''Do Not Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8499, @LeadKey, N''GL Company'', N''glCompanyKey'', NULL, NULL, N''GL Company. Required if GL Company is required.'', NULL, 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8500, @LeadKey, N''Role'', N''userRole'', NULL, NULL, N''Role'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyroles'''')'')
-- Media Market
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8501, 53, N''Market ID'', N''marketID'', NULL, N''MarketID'', N''Market ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8502, 53, N''Name'', N''marketName'', NULL, N''MarketName'', N''Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8503, 53, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Misc Costs
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8504, 23, N''Date'', N''expenseDate'', NULL, NULL, N''Date'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8505, 23, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8506, 23, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID. Required if "Require Tasks on Expenses" is set'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8507, 23, N''Item ID'', N''itemID'', NULL, NULL, N''Item ID. Required if "Require Items" is set'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8508, 23, N''Department'', N''departmentID'', NULL, NULL, N''Department ID.  Required if "Require Departments" is set'', NULL, 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8509, 23, N''Description'', N''shortDescription'', NULL, NULL, N''Description'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8510, 23, N''Quantity'', N''quantity'', NULL, NULL, N''Quantity'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8511, 23, N''Unit Cost'', N''unitCost'', NULL, NULL, N''Unit Cost'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8512, 23, N''Unit of Measure'', N''unitDescription'', NULL, NULL, N''Unit of Measure'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8513, 23, N''Net Amount'', N''totalCost'', NULL, NULL, N''Net Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8514, 23, N''Billable'', N''billable'', NULL, NULL, N''Billable'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8515, 23, N''Markup'', N''markup'', NULL, NULL, N''Markup'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8516, 23, N''Unit Billable Rate'', N''unitRate'', NULL, NULL, N''Unit Billable Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8517, 23, N''Gross Amount'', N''billableCost'', NULL, NULL, N''Gross Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8518, 23, N''Comments'', N''longDescription'', NULL, NULL, N''Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8519, 23, N''Billed'', N''billed'', NULL, NULL, N''Billed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8520, 23, N''Date Billed'', N''dateBilled'', NULL, NULL, N''Date Billed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8521, 23, N''Amount Billed'', N''amountBilled'', NULL, NULL, N''Amount Billed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8522, 23, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8523, 23, N''Class ID'', N''classID'', NULL, NULL, N''Class ID.  Required if "Require Class" is set'', NULL, 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8524, 55, N''Office ID'', N''officeID'', NULL, N''OfficeID'', N''Office ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8525, 55, N''Office Name'', N''officeName'', NULL, N''OfficeName'', N''Office Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8526, 55, N''Project Number Prefix'', N''projectNumPrefix'', NULL, N''ProjectNumPrefix'', N''Project Number Prefix'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8527, 55, N''Next Project Number'', N''nextProjectNum'', NULL, N''NextProjectNum'', N''Next Project Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8528, 55, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--Opportunities
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8529, @OpportunitiesKey, N''Company Name'', N''companyName'', NULL, NULL, N''Company Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8530, @OpportunitiesKey, N''Primary Contact'', N''contactName'', NULL, NULL, N''Primary Contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8531, @OpportunitiesKey, N''Opportunity Name'', N''subject'', NULL, NULL, N''Opportunity Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8532, @OpportunitiesKey, N''Opportunity Owner'', N''opportunityOwner'', NULL, NULL, N''Opportunity Owner'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8533, @OpportunitiesKey, N''Project Type'', N''projectType'', NULL, NULL, N''Project Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8534, @OpportunitiesKey, N''Folder'', N''cMFolder'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8535, @OpportunitiesKey, N''Competitors'', N''competitors'', NULL, NULL, N''Competitors'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8536, @OpportunitiesKey, N''Description'', N''comments'', NULL, NULL, N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8537, @OpportunitiesKey, N''Stage'', N''leadStageName'', NULL, NULL, N''Stage. Requied if Stage is required'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8538, @OpportunitiesKey, N''Status'', N''leadStatusName'', NULL, NULL, N''Status'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8539, @OpportunitiesKey, N''Next Steps'', N''currentStatus'', NULL, NULL, N''Next Steps'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8540, @OpportunitiesKey, N''Probability'', N''probability'', NULL, NULL, N''Probability'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8541, @OpportunitiesKey, N''Revenue'', N''saleAmount'', NULL, NULL, N''Revenue'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8542, @OpportunitiesKey, N''Production'', N''outsideCostsGross'', NULL, NULL, N''Production'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8543, @OpportunitiesKey, N''Production Margin Pct'', N''outsideCostsPercentage'', NULL, NULL, N''Production Margin Pct'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8544, @OpportunitiesKey, N''Media'', N''mediaGross'', NULL, NULL, N''Media'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8545, @OpportunitiesKey, N''Media Margin Pct'', N''mediaPercentage'', NULL, NULL, N''Media Margin Pct'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8546, @OpportunitiesKey, N''Due Date of Estimate'', N''bidDate'', NULL, NULL, N''Due Date of Estimate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8547, @OpportunitiesKey, N''Forecasted Close Date'', N''estCloseDate'', NULL, NULL, N''Forecasted Close Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8548, @OpportunitiesKey, N''Outcome'', N''leadOutcome'', NULL, NULL, N''Outcome'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8549, @OpportunitiesKey, N''Actual Close Date'', N''actualCloseDate'', NULL, NULL, N''Actual Close Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8550, @OpportunitiesKey, N''Outcome Description'', N''outcomeComment'', NULL, NULL, N''Outcome Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8551, @OpportunitiesKey, N''Date Converted'', N''dateConverted'', NULL, NULL, N''Date Converted'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8552, @OpportunitiesKey, N''Sub Amount'', N''subAmount'', NULL, NULL, N''Sub Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8553, @OpportunitiesKey, N''Margin'', N''margin'', NULL, NULL, N''Margin'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8554, @OpportunitiesKey, N''Estimate Opportunity'', N''bid'', NULL, NULL, N''Estimate Opportunity'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8555, @OpportunitiesKey, N''Start Date'', N''startDate'', NULL, NULL, N''Start Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8556, 38, N''WWP Need Supply'', N''wWPNeedSupply'', NULL, NULL, N''WWP Need Supply'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8557, 38, N''WWP Need Supply Comment'', N''wWPNeedSupplyComment'', NULL, NULL, N''WWP Need Supply Comment'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8558, 38, N''WWP Timeline'', N''wWPTimeline'', NULL, NULL, N''WWP Timeline'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8559, 38, N''WWP Timeline Comment'', N''wWPTimelineComment'', NULL, NULL, N''WWP Timeline Comment'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8560, 38, N''WWP Budget'', N''wWPBudget'', NULL, NULL, N''WWP Budget'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8561, 38, N''WWP Budget Comment'', N''wWPBudgetComment'', NULL, NULL, N''WWP Budget Comment'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8562, 38, N''WWP Decision Makers'', N''wWPDecisionMakers'', NULL, NULL, N''WWP Decision Makers'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8563, 38, N''WWP Decision Makers Comment'', N''wWPDecisionMakersComment'', NULL, NULL, N''WWP Decision Makers Comment'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8564, @OpportunitiesKey, N''GL Company'', N''glCompany'', NULL, NULL, N''GL Company. Required if GL company is required'', NULL, 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (38001, @OpportunitiesKey, N''Months'', N''months'', NULL, NULL, N''Months'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (38002, @OpportunitiesKey, N''Labor'', N''labor'', NULL, NULL, N''Labor'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (38003, @OpportunitiesKey, N''Opportunity ID'', N''opportunityID'', NULL, NULL, N''Opportunity ID - cannot be set, it auto-increments.  Used for updating records'', NULL, NULL, NULL, 1, N''Opportunity ID'', NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (38004, @OpportunitiesKey, N''Division'', N''clientDivision'', NULL, NULL, N''Client Division'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (38005, @OpportunitiesKey, N''Product'', N''clientProduct'', NULL, NULL, N''Client Product'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Opportunity Stages
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8565, 41, N''Stage'', N''leadStageName'', NULL, N''LeadStageName'', N''Stage'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8566, 41, N''Display Order'', N''displayOrder'', NULL, N''DisplayOrder'', N''Display Order'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8567, 41, N''Default Probability'', N''defaultProbability'', NULL, N''DefaultProbability'', N''Default Probability'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9410, 41, N''Display On Dashboard'', N''displayOnDashboard'', NULL, N''DisplayOnDashboard'', N''Display On Dashboard'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9411, 41, N''Use Default Probability'', N''useDefaultProbability'', NULL, N''UseDefaultProbability'', N''Default Probability'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Opportunity Status
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8568, 42, N''Status'', N''leadStatusName'', NULL, N''LeadStatusName'', N''Status'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8569, 42, N''Display Order'', N''displayOrder'', NULL, N''DisplayOrder'', N''Display Order'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8570, 42, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Opportunity Outcome
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8571, 43, N''Outcome'', N''outcome'', NULL, N''Outcome'', N''Outcome'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8572, 43, N''Positive Outcome'', N''positiveOutcome'', NULL, N''PositiveOutcome'', N''Positive Outcome'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Payment Methods
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8573, 50, N''Payment Method'', N''checkMethod'', NULL, N''CheckMethod'', N''Payment Method'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8574, 50, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Payment Terms
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8575, 7, N''Payment Term'', N''termsDescription'', NULL, N''TermsDescription'', N''Payment Term'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8576, 7, N''Days'', N''dueDays'', NULL, N''DueDays'', N''Days'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Print Items
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8577, 32, N''Item ID'', N''itemID'', NULL, N''ItemID'', N''Item ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8578, 32, N''Item Name'', N''itemName'', NULL, N''ItemName'', N''Item Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8579, 32, N''Standard Gross'', N''unitRate'', NULL, N''UnitRate'', N''Standard Gross'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8580, 32, N''Commission'', N''markup'', NULL, N''Markup'', N''Commission'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8581, 32, N''Standard Description'', N''standardDescription'', NULL, N''StandardDescription'', N''Standard Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8582, 32, N''Billing Item ID'', N''workType'', NULL, N''WorkTypeID'', N''Billing Item ID'', NULL, NULL, N''WorkTypeID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8583, 32, N''Department'', N''departmentKey'', NULL, N''DepartmentName'', N''Department. Required if Department is required'', NULL, 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8584, 32, N''Expense Account Number'', N''expenseAccount'', NULL, N''ExpenseAccountNumber'', N''Expense Account Number'', NULL, NULL, N''ExpenseAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8585, 32, N''Sales Account Number'', N''salesAccount'', NULL, N''SalesAccountNumber'', N''Sales Account Number'', NULL, NULL, N''SalesAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8586, 32, N''Tax 1 Applies'', N''taxable'', NULL, N''Taxable'', N''Tax 1 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8587, 32, N''Tax 2 Applies'', N''taxable2'', NULL, N''Taxable2'', N''Tax 2 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8588, 32, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8589, 32, N''Class ID'', N''classKey'', NULL, N''ClassID'', N''Class ID. Required if Class is required'', NULL, 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (32001, 32, N''Unit Rate'', N''unitRate'', NULL, N''UnitRate'', N''Unit Rate'', NULL, NULL, Null, NULL, NULL, NULL, Null)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (32002, 32, N''Avalara Tax Code'', N''avalaraTaxCodeKey'', NULL, N''AvalaraTaxCode'', N''Avalara Tax Code'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''avalara'''')'')

-- Project Billing Status
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8590, 29, N''Status ID'', N''projectBillingStatusID'', NULL, N''ProjectBillingStatusID'', N''Status ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8591, 29, N''Name'', N''projectBillingStatus'', NULL, N''ProjectBillingStatus'', N''Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8592, 29, N''Display Order'', N''displayOrder'', NULL, N''DisplayOrder'', N''Display Order'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8593, 29, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Projects
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8594, @ProjectKey, N''Copy Tasks from Project Number'', N''copyProjectNumber'', NULL, NULL, N''Copy Tasks from Project Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8595, @ProjectKey, N''Copy Estimate'', N''copyEstimate'', NULL, NULL, N''Copy Estimate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8597, @ProjectKey, N''Project Name'', N''projectName'', NULL, N''ProjectName'', N''Project Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8598, @ProjectKey, N''Project Number'', N''projectNumber'', NULL, N''ProjectNumber'', N''Project Number'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8599, @ProjectKey, N''Project Type'', N''projectType'', NULL, N''ProjectTypeName'', N''Project Type. May be required based on project number style'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8600, @ProjectKey, N''Project Color'', N''projectColor'', NULL, N''ProjectColor'', N''Project Color'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8601, @ProjectKey, N''Client ID'', N''client'', NULL, N''CustomerID'', N''Client ID. May be required based on project number style'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8602, @ProjectKey, N''Campaign ID'', N''campaignID'', NULL, N''CampaignID'', N''Campaign ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8603, @ProjectKey, N''Segment Name'', N''campaignSegment'', NULL, N'''', N''Segment Name '', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8604, @ProjectKey, N''Account Manager User ID'', N''accountManager'', NULL, N''Account Manager'', N''Account Manager User ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8605, @ProjectKey, N''Account Team'', N''team'', NULL, N''TeamName'', N''Account Team'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8606, @ProjectKey, N''Client Project Number'', N''clientProjectNumber'', NULL, N''ClientProjectNumber'', N''Client Project Number'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8607, @ProjectKey, N''Primary Contact Full Name'', N''billingContact'', NULL, N''BillingContact'', N''Primary Contact Full Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8608, @ProjectKey, N''Grant Contact Access Automatically'', N''assignBillingContact'', NULL, N''Billing Manager Name'', N''Grant Contact Access Automatically'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8609, @ProjectKey, N''Opportunity'', N''opportunityID'', NULL, N''Opportunity ID'', N''Opportunity'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8610, @ProjectKey, N''Project Request ID'', N''requestID'', NULL, N''Project Request ID'', N''Project Request ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8611, @ProjectKey, N''GL Company'', N''glCompanyName'', NULL, N''Company ID'', N''GL Company'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8612, @ProjectKey, N''Office'', N''office'', NULL, N''Office ID'', N''Office. Required if Office is required'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8613, @ProjectKey, N''Billing Method'', N''billingMethod'', NULL, N''Billing Method'', N''Billing Method'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8614, @ProjectKey, N''Billing Group Code'', N''billingGroupCode'', NULL, N''Billing Group Code'', N''Billing Group Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8615, @ProjectKey, N''Billing Manager'', N''billingManager'', NULL, N''Billing Manager Name'', N''Billing Manager'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8616, @ProjectKey, N''Expenses Not Included'', N''expensesNotIncluded'', NULL,N''ExpensesNotIncluded'', N''Expenses Not Included'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8617, @ProjectKey, N''Retainer'', N''retainerTitle'', NULL, N''Retainer Name'', N''Retainer'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8618, @ProjectKey, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8619, @ProjectKey, N''Status Notes'', N''statusNotes'', NULL, N''StatusNotes'', N''Status Notes'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8620, @ProjectKey, N''Next Steps'', N''detailedNotes'', NULL, N''Next Steps'', N''Next Steps'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8621, @ProjectKey, N''Project Status ID'', N''projectStatus'', NULL, N''Project Status'', N''Project Status ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8622, @ProjectKey, N''Scheduling Direction'', N''scheduleDirection'', NULL, N''ScheduleDirection'', N''Scheduling Direction'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8623, @ProjectKey, N''Start Date'', N''startDate'', NULL, N''StartDate'', N''Start Date. Required if Schedule direction of from project start'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8624, @ProjectKey, N''Due Date'', N''completeDate'', NULL, N''CompleteDate'', N''Due Date. Required if schedule direction is from project completion'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8625, @ProjectKey, N''Flight Start Date'', N''flightStartDate'', NULL, N''FlightStartDate'', N''Flight Start Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8626, @ProjectKey, N''Flight End Date'', N''flightEndDate'', NULL, N''FlightEndDate'', N''Flight End Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8627, @ProjectKey, N''Flight Interval (D/W/S)'', N''flightInterval'', NULL, N''FlightInterval'', N''Flight Interval (D/W/S)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8628, @ProjectKey, N''Billing Status ID'', N''projectBillingStatus'', NULL, N''Project Billing Status'', N''Billing Status ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8629, @ProjectKey, N''Closed'', N''closed'', NULL, N''Closed'', N''Closed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8630, @ProjectKey, N''Non Billable'', N''nonBillable'', NULL, N''NonBillable'', N''Non Billable'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8632, @ProjectKey, N''Division Name'', N''clientDivision'', NULL, N''Client Division ID'', N''Division Name. May be required based on project number style'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8633, @ProjectKey, N''Product Name'', N''clientProduct'', NULL, N''Client Product ID'', N''Product Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8634, @ProjectKey, N''Get Rate From'', N''getRateFrom'', NULL, N''Get Labor Rate From'', N''Get Rate From'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8635, @ProjectKey, N''Hourly Rate'', N''hourlyRate'', NULL, N''HourlyRate'', N''Hourly Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8636, @ProjectKey, N''Rate Sheet'', N''rateSheet'', NULL, N''Service Rate Sheet'', N''Rate Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8637, @ProjectKey, N''Auto ID Task'', N''autoIDTask'', NULL, N''AutoIDTask'', N''Auto ID Task'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8638, @ProjectKey, N''Class ID'', N''classKey'', NULL, N''Class ID'', N''Class ID. Required if Class is required'', NULL, 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8639, @ProjectKey, N''*[KEYUSER1] User ID'', N''keyPeople1'', NULL, N''Key Person 1'', N''*[KEYUSER1] User ID'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacykeypeople'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8640, @ProjectKey, N''*[KEYUSER2] User ID'', N''keyPeople2'', NULL, N''Key Person 2'', N''*[KEYUSER2] User ID'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacykeypeople'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8641, @ProjectKey, N''*[KEYUSER3] User ID'', N''keyPeople3'', NULL, N''Key Person 3'', N''*[KEYUSER3] User ID'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacykeypeople'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8642, @ProjectKey, N''*[KEYUSER4] User ID'', N''keyPeople4'', NULL, N''Key Person 4'', N''*[KEYUSER4] User ID'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacykeypeople'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8643, @ProjectKey, N''*[KEYUSER5] User ID'', N''keyPeople5'', NULL, N''Key Person 5'', N''*[KEYUSER5] User ID'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacykeypeople'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8644, @ProjectKey, N''*[KEYUSER6] User ID'', N''keyPeople6'', NULL, N''Key Person 6'', N''*[KEYUSER6] User ID'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacykeypeople'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8645, @ProjectKey, N''Model Year'', N''modelYear'', NULL, N''ModeYear'', N''Model Year'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''spark44'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8646, @ProjectKey, N''Title Rate Sheet'', N''titleRateSheetKey'', NULL, N''Title Rate Sheet'', N''Title Rate Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''billingtitles'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13001, @ProjectKey, N''Project Manager ID'', N''projectManager'', NULL, N''Project Manager'', N''Project Manager User ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13002, @ProjectKey, N''Template'', N''template'', NULL, N''Template'', N''Template - yes or no'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13003, @ProjectKey, N''Get Markup From'', N''getMarkupFrom'', NULL, N''GetMarkupFrom'', N''Get Markup From'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13004, @ProjectKey, N''Item Rate Sheet'', N''itemRateSheet'', NULL, N''Item Rate Sheet'', N''Item Rate Sheet'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13005, @ProjectKey, N''Forecast As Fixed Fee'', N''forecastAsFixedFee'', NULL, N''Forecast As Fixed Fee'', N''Forecast As Fixed Fee'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13006, @ProjectKey, N''Split Billing'', N''splitBilling'', NULL, N''splitBilling'', N''Split Billing. format clientID:# example(ACME:60|WMJ:40)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13007, @ProjectKey, N''Avalara Tax Code'', N''avalaraTaxCode'', NULL, N''Avalara Tax Code'', N''Avalara Tax Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Project Spec Sheet
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8647, 73, N''Spec Sheet ID Prefix'', N''specSheetPrefix'', NULL, NULL, N''Spec Sheet ID Prefix'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8648, 73, N''Project ID'', N''projectID'', NULL, NULL, N''Project ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8649, 73, N''Full Spec ID'', N''fullSpecID'', NULL, NULL, N''Full Spec ID'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8650, 73, N''Description'', N''description'', NULL, NULL, N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (73001, 73, N''Subject'', N''subject'', NULL, NULL, N''Subject'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)

-- Project Staff Rates
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (127000, @ProjectStaffRatesKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', NULL, 1, 1, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (127001, @ProjectStaffRatesKey, N''User Name'', N''userName'', NULL, NULL, N''User Name'', NULL, 1, 1, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (127002, @ProjectStaffRatesKey, N''Hourly Rate'', N''hourlyRate'', NULL, NULL, N''Hourly Rate'', NULL, 1, 1, NULL, NULL, NULL, NULL)

-- Project Status
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8651, @ProjectStatusCodeKey, N''Status ID'', N''projectStatusID'', NULL, N''ProjectStatusID'', N''Status ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8652, @ProjectStatusCodeKey, N''Name'', N''projectStatus'', NULL, N''ProjectStatus'', N''Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8653, @ProjectStatusCodeKey, N''Display Order'', N''displayOrder'', NULL, N''DisplayOrder'', N''Display Order'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8654, @ProjectStatusCodeKey, N''Project is Active'', N''isActive'', NULL, N''IsActive'', N''Project is Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8655, @ProjectStatusCodeKey, N''Allow Time Entries'', N''timeActive'', NULL, N''TimeActive'', N''Allow Time Entries'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8656, @ProjectStatusCodeKey, N''Allow Expense Entries'', N''expenseActive'', NULL, N''ExpenseActive'', N''Allow Expense Entries'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8657, @ProjectStatusCodeKey, N''Lock Status'', N''locked'', NULL, N''Locked'', N''Lock Status'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8658, @ProjectStatusCodeKey, N''On Hold'', N''onHold'', NULL, N''OnHold'', N''On Hold'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9271, @ProjectStatusCodeKey, N''Include In Forecast'', N''includeInForecast'', NULL, N''IncludeInForecast'', N''Include In Forecast'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (27001, @ProjectStatusCodeKey, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Project Types
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8659, 25, N''Project Type'', N''projectTypeName'', NULL, N''ProjectTypeName'', N''Project Type'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8660, 25, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8661, 25, N''Project Number Prefix'', N''projectNumPrefix'', NULL, N''ProjectNumPrefix'', N''Project Number Prefix'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8662, 25, N''Next Project Number'', N''nextProjectNum'', NULL, N''NextProjectNum'', N''Next Project Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8663, 25, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8664, 25, N''Subject1'', N''subject1'', NULL, N''Subject1'', N''Subject1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8665, 25, N''Subject2'', N''subject2'', NULL, N''Subject2'', N''Subject2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8666, 25, N''Subject3'', N''subject3'', NULL, N''Subject3'', N''Subject3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8667, 25, N''Subject4'', N''subject4'', NULL, N''Subject4'', N''Subject4'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8668, 25, N''Subject5'', N''subject5'', NULL, N''Subject5'', N''Subject5'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8669, 25, N''Subject6'', N''subject6'', NULL, N''Subject6'', N''Subject6'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8670, 25, N''Subject7'', N''subject7'', NULL, N''Subject7'', N''Subject7'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8671, 25, N''Subject8'', N''subject8'', NULL, N''Subject8'', N''Subject8'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8672, 25, N''Subject9'', N''subject9'', NULL, N''Subject9'', N''Subject9'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8673, 25, N''Subject10'', N''subject10'', NULL, N''Subject10'', N''Subject10'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8674, 25, N''Subject11'', N''subject11'', NULL, N''Subject11'', N''Subject11'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8675, 25, N''Subject12'', N''subject12'', NULL, N''Subject12'', N''Subject12'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Publication
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12001, @PublicationKey, N''Publication Name'', N''name'', NULL, N''Publication'', N''Publication Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12002, @PublicationKey, N''Publication ID'', N''publicationID'', NULL, N''publicationID'', N''Publication ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12003, @PublicationKey, N''Vendor ID'', N''vendorID'', NULL, N''VendorID'', N''Vendor ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12004, @PublicationKey, N''Media Market'', N''mediaMarket'', NULL, N''Media Market'', N''Media Market'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12005, @PublicationKey, N''Item ID'', N''item'', NULL, N''ItemID'', N''Item ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12006, @PublicationKey, N''ContactName'', N''contact'', NULL, N''Contact'', N''contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12007, @PublicationKey, N''Address 1'', N''address1'', NULL, N''address1'', N''address1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12008, @PublicationKey, N''Address 2'', N''address2'', NULL, N''address2'', N''address2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12009, @PublicationKey, N''Address 3'', N''address3'', NULL, N''address3'', N''address3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12010, @PublicationKey, N''City'', N''city'', NULL, N''city'', N''city'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12011, @PublicationKey, N''State'', N''state'', NULL, N''State'', N''state'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12012, @PublicationKey, N''Postal Code'', N''postalCode'', NULL, N''PostalCode'', N''postalCode'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12013, @PublicationKey, N''Country'', N''country'', NULL, N''Country'', N''country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12014, @PublicationKey, N''Phone'', N''phone'', NULL, N''Phone'', N''Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12015, @PublicationKey, N''Fax'', N''fax'', NULL, N''Fax'', N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12016, @PublicationKey, N''Material Address 1'', N''mAddress1'', NULL, N''mAddress1'', N''address1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12017, @PublicationKey, N''Material Address 2'', N''mAddress2'', NULL, N''mAddress2'', N''address2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12018, @PublicationKey, N''Material Address 3'', N''mAddress3'', NULL, N''mAddress3'', N''address3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12019, @PublicationKey, N''Material City'', N''mCity'', NULL, N''mCity'', N''city'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12020, @PublicationKey, N''Material State'', N''mState'', NULL, N''mState'', N''state'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12021, @PublicationKey, N''Material Postal Code'', N''mPostalCode'', NULL, N''mPostalCode'', N''postalCode'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12022, @PublicationKey, N''Material Country'', N''mCountry'', NULL, N''mCountry'', N''country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12023, @PublicationKey, N''Material Phone'', N''mPhone'', NULL, N''mPhone'', N''Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12024, @PublicationKey, N''Material Fax'', N''mFax'', NULL, N''mFax'', N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12025, @PublicationKey, N''Space Close Number'', N''spaceCloseNumDays'', NULL, N''spaceCloseNumDays'', N''Space Close Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12026, @PublicationKey, N''Material Due Number'', N''materailsDueNumDays'', NULL, N''materailsDueNumDays'', N''Material Due Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Purchase Items
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8676, 5, N''Item ID'', N''itemID'', NULL, N''ItemID'', N''Item ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8677, 5, N''Item Name'', N''itemName'', NULL, N''ItemName'', N''Item Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8678, 5, N''Unit Cost'', N''unitCost'', NULL, N''UnitCost'', N''Unit Cost'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8679, 5, N''Markup'', N''markup'', NULL, N''Markup'', N''Markup'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8680, 5, N''Unit Rate'', N''unitRate'', NULL, N''UnitRate'', N''Unit Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8681, 5, N''Always use Unit Rate for Gross Amount'', N''useUnitRate'', NULL, N''UseUnitRate'', N''Always use Unit Rate for Gross Amount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8682, 5, N''Unit Description'', N''unitDescription'', NULL, N''UnitDescription'', N''Unit Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8683, 5, N''Standard Description'', N''standardDescription'', NULL, N''StandardDescription'', N''Standard Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8684, 5, N''Billing Item ID'', N''billingItemID'', NULL, N''WorkTypeID'', N''Billing Item ID'', NULL, NULL, N''BillingItemID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8685, 5, N''Department'', N''departmentName'', NULL, N''DepartmentName'', N''Department. Required if Department is required'', NULL, 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8686, 5, N''Expense Account Number'', N''expenseAccountNumber'', NULL, N''ExpenseAccountNumber'', N''Expense Account Number'', NULL, NULL, N''ExpenseAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8687, 5, N''Sales Account Number'', N''salesAccountNumber'', NULL, N''SalesAccountNumber'', N''Sales Account Number'', NULL, NULL, N''SalesAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8688, 5, N''Quantity On Hand'', N''quantityOnHand'', NULL, N''QuantityOnHand'', N''Quantity On Hand'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8689, 5, N''Tax 1 Applies'', N''taxable'', NULL, N''Taxable'', N''Tax 1 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8690, 5, N''Tax 2 Applies'', N''taxable2'', NULL, N''Taxable2'', N''Tax 2 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8691, 5, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8692, 5, N''Class ID'', N''classID'', NULL, N''ClassID'', N''Class ID. Required if Class is required'', NULL, 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (869200, 5, N''Avalara Tax Code'', N''avalaraTaxCodeKey'', NULL, N''AvalaraTaxCode'', N''Avalara Tax Code'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''avalara'''')'')
--Purchase Order
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8693, @POKey, N''PO Number'', N''purchaseOrderNumber'', NULL, NULL, N''PO Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8694, @POKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8695, @POKey, N''PO Type'', N''purchaseOrderType'', NULL, NULL, N''PO Type'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8696, @POKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8697, @POKey, N''Contact'', N''contact'', NULL, NULL, N''Contact'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8698, @POKey, N''PO Date'', N''pODate'', NULL, NULL, N''PO Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8699, @POKey, N''Due Date'', N''dueDate'', NULL, NULL, N''Due Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8700, @POKey, N''Ordered By'', N''orderedBy'', NULL, NULL, N''Ordered By'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8701, @POKey, N''Standard Header Text'', N''headerTextID'', NULL, NULL, N''Standard Header Text'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8702, @POKey, N''Standard Footer Text'', N''footerTextID'', NULL, NULL, N''Standard Footer Text'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8703, @POKey, N''Approver'', N''approvedBy'', NULL, NULL, N''Approver'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8704, @POKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8705, @POKey, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8706, @POKey, N''Sales Tax ID 2'', N''salesTax2ID'', NULL, NULL, N''Sales Tax ID 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8707, @POKey, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8708, @POKey, N''Order Description'', N''description'', NULL, NULL, N''Order Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8709, @POKey, N''Project Number (Line)'', N''projectNumber'', NULL, NULL, N''Project Number (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8711, @POKey, N''Office'', N''officeKey'', NULL, NULL, N''Office'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8712, @POKey, N''Department'', N''departmentID'', NULL, NULL, N''Department'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8713, @POKey, N''Item ID'', N''itemID'', NULL, NULL, N''Item ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8714, @POKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8715, @POKey, N''Description'', N''shortDescription'', NULL, NULL, N''Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8716, @POKey, N''Long Description'', N''longDescription'', NULL, NULL, N''Long Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8719, @POKey, N''Quantity'', N''quantity'', NULL, NULL, N''Quantity'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8720, @POKey, N''Unit Desc'', N''unitDescription'', NULL, NULL, N''Unit Desc'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8721, @POKey, N''Markup'', N''markup'', NULL, NULL, N''Markup'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8722, @POKey, N''Billable'', N''billable'', NULL, NULL, N''Billable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8723, @POKey, N''Net Cost'', N''totalCost'', NULL, NULL, N''Net Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8724, @POKey, N''Gross Cost'', N''grossAmount'', NULL, NULL, N''Gross Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8725, @POKey, N''Sales Tax Amount'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8726, @POKey, N''Sales Tax Amount 2'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax Amount 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8727, @POKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8728, @POKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8729, @POKey, N''Exchange Rate (Line)'', N''pExchangeRate'', NULL, NULL, N''Exchange Rate (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8730, @POKey, N''Class ID'', N''classID'', NULL, NULL, N''Class ID'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8731, @POKey, N''Class ID (Line)'', N''classID'', NULL, NULL, N''Class ID (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (18001, @POKey, N''Unit Cost'', N''unitCost'', NULL, NULL, N''Unit Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (18002, @POKey, N''Unit Rate'', N''unitRate'', NULL, NULL, N''Unit Rate'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (18003, @POKey, N''Traffic Instructions'', N''trafficInstructions'', NULL, NULL, N''Traffic Instructions'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (18004, @POKey, N''Special Instructions'', N''specialInstructions'', NULL, NULL, N''Special Instructions'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (18005, @POKey, N''Detail Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Detail Field Group ID, used for selecting appropriate field group'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (18006, @POKey, N''Header Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Header Field Group ID, used for selecting appropriate field group'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (18007, @POKey, N''Header ID'', N''headerID'', NULL, NULL, N''Header ID, used for associating header and detail fields when they do not pass in the PO Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
-- Receipts
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11501, @ReceiptsKey, N''Client ID'', N''clientID'', NULL, NULL, N''Client ID'', N''header'', 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11502, @ReceiptsKey, N''GL Company'', N''glCompany'', NULL, NULL, N''GL Company'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11503, @ReceiptsKey, N''Check Amount'', N''checkAmount'', NULL, NULL, N''Check Amount'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11504, @ReceiptsKey, N''Posting Date'', N''postingDate'', NULL, NULL, N''Posting Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11505, @ReceiptsKey, N''Reference Number'', N''referenceNumber'', NULL, NULL, N''Reference Number'', N''header'', 1, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11506, @ReceiptsKey, N''Payment Method'', N''paymentMethod'', NULL, NULL, N''Payment Method'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11507, @ReceiptsKey, N''Receipt Date'', N''checkDate'', NULL, NULL, N''Receipt Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11508, @ReceiptsKey, N''Deposit ID'', N''depositID'', NULL, NULL, N''Deposit ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11509, @ReceiptsKey, N''Opening Transaction'', N''openingTransaction'', NULL, NULL, N''Opening Transaction'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11510, @ReceiptsKey, N''Cash Account Number'', N''cashAccountNumber'', NULL, NULL, N''Cash Account Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11511, @ReceiptsKey, N''Unapplied Payment Account Number'', N''prepayAccountNumber'', NULL, NULL, N''Unapplied Payment Account Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11512, @ReceiptsKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11513, @ReceiptsKey, N''Posted'', N''posted'', NULL, NULL, N''Posted'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11514, @ReceiptsKey, N''Invoice Number'', N''invoiceNumber'', NULL, NULL, N''Invoice Number'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11515, @ReceiptsKey, N''GL Account'', N''glAccount'', NULL, NULL, N''GL Account'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11516, @ReceiptsKey, N''Description (Line)'', N''description'', NULL, NULL, N''Description (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11517, @ReceiptsKey, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11518, @ReceiptsKey, N''Department'', N''department'', NULL, NULL, N''Department. Required if Department is required.'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11519, @ReceiptsKey, N''Amount Applied'', N''amount'', NULL, NULL, N''Amount Applied'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11520, @ReceiptsKey, N''Office'', N''office'', NULL, NULL, N''Office. Required if Office ie required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11521, @ReceiptsKey, N''Target GL Company'', N''targetGLCompany'', NULL, NULL, N''Target GL Company. Required if GL Company is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11522, @ReceiptsKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11523, @ReceiptsKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11524, @ReceiptsKey, N''Class ID'', N''classKey'', NULL, NULL, N''Class ID. Required if Class is required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11525, @ReceiptsKey, N''Class ID (Line)'', N''classKey'', NULL, NULL, N''Class ID (Line). Required if Class is required'', N''detail'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11526, @ReceiptsKey, N''Receipt Key'', N''receiptKey'', NULL, NULL, N''Receipt Key'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11527, @ReceiptsKey, N''Action'', N''action'', NULL, NULL, N''Action - d for deleting a row'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)

-- Report Groups
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8732, 40, N''Group Name'', N''groupName'', NULL, N''GroupName'', N''Group Name'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8733, 40, N''Display Order'', N''displayOrder'', NULL, N''DisplayOrder'', N''Display Order'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Request Reject Reasons
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8734, 67, N''Request Reject Reason'', N''reasonName'', NULL, N''ReasonName'', N''Request Reject Reason'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8735, 67, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8736, 67, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--Project Requests
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8737, @ProjectRequestKey, N''Request Prefix'', N''requestPrefix'', NULL, NULL, N''Spec Sheet ID Prefix'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8738, @ProjectRequestKey, N''Client ID'', N''clientID'', NULL, NULL, N''Client ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8740, @ProjectRequestKey, N''Notify Email'', N''notifyEmail'', NULL, NULL, N''Notify Email'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8741, @ProjectRequestKey, N''Project Due Date'', N''dueDate'', NULL, NULL, N''Project Due Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (1, @ProjectRequestKey, N''Client Project Number'', N''clientProjectNumber'', NULL, NULL, N''Client Project Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (2, @ProjectRequestKey, N''Campaign ID'', N''campaignID'', NULL, NULL, N''Campaign ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (3, @ProjectRequestKey, N''Project Name'', N''subject'', NULL, NULL, N''Project Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (4, @ProjectRequestKey, N''Project Description'', N''projectDescription'', NULL, NULL, N''Project Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (5, @ProjectRequestKey, N''Requested By'', N''requestedBy'', NULL, NULL, N''Requested By'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (6, @ProjectRequestKey, N''Request ID'', N''requestID'', NULL, NULL, N''Request ID'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7, @ProjectRequestKey, N''Status'', N''status'', NULL, NULL, N''Status'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (76007, @ProjectRequestKey, N''Skip Approval Process'', N''skipApprovalProcess'', NULL, NULL, N''Skip Approval Process (True or False) - If true, then will not send out new emails'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
-- Request Spec Sheets
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8742, 74, N''Spec Sheet ID Prefix'', N''specSheetPrefix'', NULL, NULL, N''Spec Sheet ID Prefix'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8743, 74, N''Request ID'', N''requestID'', NULL, NULL, N''Request ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8744, 74, N''Client ID'', N''clientID'', NULL, NULL, N''Client ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8745, 74, N''Full Spec ID'', N''fullSpecID'', NULL, NULL, N''Full Spec ID'', NULL, NULL, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8746, 74, N''Description'', N''description'', NULL, NULL, N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (10, 74, N''Subject'', N''subject'', NULL, NULL, N''Subject'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)

-- Retainer
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11801, @RetainerKey, N''Active'', N''active'', NULL, NULL, N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11802, @RetainerKey, N''Amount Per Period'', N''amountPerPeriod'',NULL, NULL, N''Amount Per Period'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11803, @RetainerKey, N''Billing Manager'', N''billingManager'',NULL, NULL, N''Billing Manager'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11804, @RetainerKey, N''Class'', N''classKey'',NULL, NULL, N''Class'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11805, @RetainerKey, N''Client ID'', N''client'', NULL, NULL, N''Client ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11806, @RetainerKey, N''Contact'', N''contact'',NULL, NULL, N''Contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11807, @RetainerKey, N''Cost Per Period'', N''costPerPeriod'',NULL, NULL, N''Cost Per Period'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11808, @RetainerKey, N''Currency ID'', N''currencyID'',NULL, NULL, N''Currency ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11809, @RetainerKey, N''Description'', N''description'',NULL, NULL, N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11810, @RetainerKey, N''Frequency'', N''frequency'',NULL, NULL, N''Frequency (monthly, quarterly, yearly, weekly) '', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11811, @RetainerKey, N''Include Labor'', N''includeLabor'',NULL, NULL, N''Include Labor'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11812, @RetainerKey, N''Include Expense'', N''includeExpense'',NULL, NULL, N''Include Expense'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11813, @RetainerKey, N''Invoice Approved By'', N''invoiceApprovedBy'',NULL, NULL, N''Invoice Approved By'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11814, @RetainerKey, N''Invoice Expenses Separate'', N''invoiceExpensesSeparate'',NULL, NULL, N''Invoice Expenses Separate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11815, @RetainerKey, N''Invoice Template'', N''invoiceTemplate'',NULL, NULL, N''Invoice Template'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11817, @RetainerKey, N''Last Billing Date'', N''lastBillingDate'',NULL, NULL, N''Last Billing Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11818, @RetainerKey, N''Layout'', N''layout'',NULL, NULL, N''Layout'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11819, @RetainerKey, N''Line Format'', N''lineFormat'',NULL, NULL, N''Line Format'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11820, @RetainerKey, N''Number Of Periods'', N''numberOfPeriods'',NULL, NULL, N''Number Of Periods'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11821, @RetainerKey, N''Office'', N''office'',NULL, NULL, N''Office'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11822, @RetainerKey, N''Sales Account'', N''salesAccount'',NULL, NULL, N''Sales Account'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11823, @RetainerKey, N''Start Date'', N''startDate'', NULL, NULL, N''Start Date'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11824, @RetainerKey, N''Title'', N''title'', NULL, NULL, N''Title'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (11825, @RetainerKey, N''GL Company'', N''glCompany'',NULL, NULL, N''GL Company'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Sales Tax
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8747, 8, N''Sales Tax ID'', N''salesTaxID'', NULL, N''SalesTaxID'', N''Sales Tax ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8748, 8, N''Sales Tax Name'', N''salesTaxName'', NULL, N''SalesTaxName'', N''Sales Tax Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8749, 8, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8750, 8, N''Pay To Vendor ID'', N''payTo'', NULL, N''VendorID'', N''Pay To Vendor ID'', NULL, NULL, N''PayToID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8751, 8, N''Tax Payable GL Account Number'', N''payableGLAccountKey'', NULL, N''PayableAccountNumber'', N''Tax Payable GL Account Number'', NULL, NULL, N''PayableGLAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8752, 8, N''Tax AP GL Account Number'', N''aPPayableGLAccountKey'', NULL, N''APAccountNumber'', N''Tax AP GL Account Number'', NULL, NULL, N''APPayableGLAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8753, 8, N''Tax Rate Percentage'', N''taxRate'', NULL, N''TaxRate'', N''Tax Rate Percentage'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8754, 8, N''Piggy Back Tax'', N''piggyBackTax'', NULL, N''PiggyBackTax'', N''Piggy Back Tax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8755, 8, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--Service Rate Sheet
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8756, @ServiceRateSheetKey, N''Rate Sheet Name'', N''rateSheetName'', NULL, N''RateSheetName'', N''Rate Sheet Name'', N''header'', 1, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8757, @ServiceRateSheetKey, N''Active'', N''active'', NULL, N''Active'', N''Active'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8758, @ServiceRateSheetKey, N''Service Code'', N''serviceCode'', NULL, N''ServiceCode'', N''Service Code'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8759, @ServiceRateSheetKey, N''Rate 1'', N''rate1'', NULL, N''HourlyRate1'', N''Rate 1'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8760, @ServiceRateSheetKey, N''Rate 2'', N''rate2'', NULL, N''HourlyRate2'', N''Rate 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8761, @ServiceRateSheetKey, N''Rate 3'', N''rate3'', NULL, N''HourlyRate3'', N''Rate 3'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8762, @ServiceRateSheetKey, N''Rate 4'', N''rate4'', NULL, N''HourlyRate4'', N''Rate 4'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8763, @ServiceRateSheetKey, N''Rate 5'', N''rate5'', NULL, N''HourlyRate5'', N''Rate 5'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (58004, @ServiceRateSheetKey, N''Description'', N''description'', NULL, N''Description'', N''Service Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (58005, @ServiceRateSheetKey, N''Invoice Label'', N''invoiceLabel'', NULL, N''InvoiceLabel'', N''Invoice Label'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (58003, @ServiceRateSheetKey, N''Hourly Cost'', N''hourlyCost'', NULL, N''HourlyCost'', N''Hourly Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
-- Services
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8764, 9, N''Service Code'', N''serviceCode'', NULL, N''ServiceCode'', N''Service Code'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8765, 9, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8766, 9, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8767, 9, N''Billing Item ID'', N''workTypeKey'', NULL, N''WorkTypeID'', N''Billing Item ID'', NULL, NULL, N''WorkTypeID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8768, 9, N''Department'', N''departmentKey'', NULL, N''DepartmentName'', N''Department'', NULL, NULL, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8769, 9, N''Sales Account Number'', N''glAccountKey'', NULL, N''SalesAccountNumber'', N''Sales Account Number'', NULL, NULL, N''SalesAccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8770, 9, N''Hourly Cost'', N''hourlyCost'', NULL, N''HourlyCost'', N''Hourly Cost'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8771, 9, N''Tax 1 Applies'', N''taxable'', NULL, N''Taxable'', N''Tax 1 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8772, 9, N''Tax 2 Applies'', N''taxable2'', NULL, N''Taxable2'', N''Tax 2 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8773, 9, N''Hourly Rate 1'', N''hourlyRate1'', NULL, N''HourlyRate1'', N''Hourly Rate 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8774, 9, N''Rate Description 1'', N''description1'', NULL, N''Description1'', N''Rate Description 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8775, 9, N''Hourly Rate 2'', N''hourlyRate2'', NULL, N''HourlyRate2'', N''Hourly Rate 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8776, 9, N''Rate Description 2'', N''description2'', NULL, N''Description2'', N''Rate Description 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8777, 9, N''Hourly Rate 3'', N''hourlyRate3'', NULL, N''HourlyRate3'', N''Hourly Rate 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8778, 9, N''Rate Description 3'', N''description3'', NULL, N''Description3'', N''Rate Description 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8779, 9, N''Hourly Rate 4'', N''hourlyRate4'', NULL, N''HourlyRate4'', N''Hourly Rate 4'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8780, 9, N''Rate Description 4'', N''description4'', NULL, N''Description4'', N''Rate Description 4'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8781, 9, N''Hourly Rate 5'', N''hourlyRate5'', NULL, N''HourlyRate5'', N''Hourly Rate 5'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8782, 9, N''Rate Description 5'', N''description5'', NULL, N''Description5'', N''Rate Description 5'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8783, 9, N''Class ID'', N''classKey'', NULL, N''ClassID'', N''Class ID'', NULL, NULL, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (87840, 9, N''Avalara Tax Code'', N''avalaraTaxCodeKey'', NULL, N''AvalaraTaxCode'', N''Avalara Tax Code'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''avalara'''')'')
-- Standard Text
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8784, 52, N''Type'', N''type'', NULL, N''Type'', N''Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8785, 52, N''Text Block Name'', N''textName'', NULL, N''TextName'', N''Text Block Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8786, 52, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8787, 52, N''Standard Text'', N''standardText'', NULL, N''StandardText'', N''Standard Text'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
-- Station
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12201, @StationKey, N''Station Name'', N''name'', NULL, N''StationName'', N''Station Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12202, @StationKey, N''Station ID'', N''stationID'', NULL, N''StationID'', N''Station ID'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12203, @StationKey, N''Vendor ID'', N''vendorID'', NULL, N''VendorID'', N''Vendor ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12204, @StationKey, N''Media Market'', N''mediaMarket'', NULL, N''Media Market'', N''Media Market'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12205, @StationKey, N''Item ID'', N''item'', NULL, N''ItemID'', N''Item ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12206, @StationKey, N''ContactName'', N''contact'', NULL, N''Contact'', N''contact'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12207, @StationKey, N''Address 1'', N''address1'', NULL, N''address1'', N''address1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12208, @StationKey, N''Address 2'', N''address2'', NULL, N''address2'', N''address2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12209, @StationKey, N''Address 3'', N''address3'', NULL, N''address3'', N''address3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12210, @StationKey, N''City'', N''city'', NULL, N''city'', N''city'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12211, @StationKey, N''State'', N''state'', NULL, N''State'', N''state'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12212, @StationKey, N''Postal Code'', N''postalCode'', NULL, N''PostalCode'', N''postalCode'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12213, @StationKey, N''Country'', N''country'', NULL, N''Country'', N''country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12214, @StationKey, N''Phone'', N''phone'', NULL, N''Phone'', N''Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12215, @StationKey, N''Fax'', N''fax'', NULL, N''Fax'', N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12216, @StationKey, N''Material Address 1'', N''mAddress1'', NULL, N''mAddress1'', N''address1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12217, @StationKey, N''Material Address 2'', N''mAddress2'', NULL, N''mAddress2'', N''address2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12218, @StationKey, N''Material Address 3'', N''mAddress3'', NULL, N''mAddress3'', N''address3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12219, @StationKey, N''Material City'', N''mCity'', NULL, N''mCity'', N''city'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12220, @StationKey, N''Material State'', N''mState'', NULL, N''mState'', N''state'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12221, @StationKey, N''Material Postal Code'', N''mPostalCode'', NULL, N''mPostalCode'', N''postalCode'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12222, @StationKey, N''Material Country'', N''mCountry'', NULL, N''mCountry'', N''country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12223, @StationKey, N''Material Phone'', N''mPhone'', NULL, N''mPhone'', N''Phone'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12224, @StationKey, N''Material Fax'', N''mFax'', NULL, N''mFax'', N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12225, @StationKey, N''Space Close Number'', N''spaceCloseNumDays'', NULL, N''spaceCloseNumDays'', N''Space Close Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (12226, @StationKey, N''Material Due Number'', N''materailsDueNumDays'', NULL, N''materailsDueNumDays'', N''Material Due Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)

-- Sources
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8788, 48, N''Role'', N''sourceName'', NULL, N''SourceName'', N''Role'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8789, 48, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Tasks
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8792, @TaskKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', N''header'', 1, NULL, 1, NULL, 2, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8794, @TaskKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID'', N''header'', NULL, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8795, @TaskKey, N''Task Name'', N''taskName'', NULL, NULL, N''Task Name'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8796, @TaskKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8798, @TaskKey, N''Summary Task ID'', N''summaryTaskID'', NULL, NULL, N''Summary Task ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8799, @TaskKey, N''Hourly Rate'', N''hourlyRate'', NULL, NULL, N''Hourly Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8800, @TaskKey, N''Markup'', N''markup'', NULL, NULL, N''Markup'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8801, @TaskKey, N''IO Commission'', N''ioCommission'', NULL, NULL, N''IO Commission'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8802, @TaskKey, N''BC Commission'', N''bcCommission'', NULL, NULL, N''BC Commission'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8803, @TaskKey, N''Show Desc On Est'', N''showDescOnEst'', NULL, NULL, N''Show Desc On Est'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8805, @TaskKey, N''Taxable'', N''taxable'', NULL, NULL, N''Taxable'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8806, @TaskKey, N''Taxable2'', N''taxable2'', NULL, NULL, N''Taxable2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8807, @TaskKey, N''Billing Item ID'', N''workTypeID'', NULL, NULL, N''Billing Item ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8808, @TaskKey, N''Base Start'', N''baseStart'', NULL, NULL, N''Base Start'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8809, @TaskKey, N''Base Complete'', N''baseComplete'', NULL, NULL, N''Base Complete'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8810, @TaskKey, N''Plan Start'', N''planStart'', NULL, NULL, N''Plan Start'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8811, @TaskKey, N''Plan Complete'', N''planComplete'', NULL, NULL, N''Plan Complete'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8812, @TaskKey, N''Plan Duration'', N''planDuration'', NULL, NULL, N''Plan Duration'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8813, @TaskKey, N''Act Start'', N''actStart'', NULL, NULL, N''Act Start'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8814, @TaskKey, N''Act Complete'', N''actComplete'', NULL, NULL, N''Act Complete'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8815, @TaskKey, N''Perc Comp'', N''percComp'', NULL, NULL, N''Perc Comp'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8816, @TaskKey, N''Task Constraint'', N''taskConstraint'', NULL, NULL, N''Task Constraint.  Possible values are:<br> As Soon As Possible<br> As Late As Possible<br> Must Start On<br> Must Finish On<br> Finish No Earlier Than<br> Finish No Later Than<br> Start No Earlier Than<br> Start No Later Than'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8817, @TaskKey, N''Status Comments'', N''comments'', NULL, NULL, N''Status Comments'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8818, @TaskKey, N''Schedule Task'', N''scheduleTask'', NULL, NULL, N''Schedule Task'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8819, @TaskKey, N''Track Budget'', N''trackBudget'', NULL, NULL, N''Track Budget'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8821, @TaskKey, N''Hide From Client'', N''hideFromClient'', NULL, NULL, N''Hide From Client'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8822, @TaskKey, N''Allow Anyone'', N''allowAnyone'', NULL, NULL, N''Allow Anyone'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8823, @TaskKey, N''Constraint Date'', N''constraintDate'', NULL, NULL, N''Constraint Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8824, @TaskKey, N''Work Any Day'', N''workAnyDay'', NULL, NULL, N''Work Any Day'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8825, @TaskKey, N''Perc Comp Separate'', N''percCompSeparate'', NULL, NULL, N''Track Actual Dates for Each Person'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8829, @TaskKey, N''Priority'', N''priority'', NULL, NULL, N''Priority. Use Priority Name value from Task Priority Setup.<br> Or use these values:<br>H<br>M<br>L'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8831, 69, N''Event Start Date and Time'', N''eventStart'', NULL, NULL, N''Event Start Date and Time'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8832, 69, N''Event End Date and Time'', N''eventEnd'', NULL, NULL, N''Event End Date and Time'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8834, @TaskKey, N''Due By Comments'', N''dueBy'', NULL, NULL, N''Due By Comments'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8835, @TaskKey, N''Reviewed By Traffic'', N''reviewedByTraffic'', NULL, NULL, N''Reviewed By Traffic'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8836, @TaskKey, N''Predecessors Complete'', N''predecessorsComplete'', NULL, NULL, N''Predecessors Complete'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8838, @TaskKey, N''Schedule Notes'', N''scheduleNote'', NULL, NULL, N''Schedule Notes'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8839, @TaskKey, N''Constraint Day Of The Week'', N''constraintDayOfTheWeek'', NULL, NULL, N''Constraint Day Of The Week'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8840, @TaskKey, N''Exclude From Status'', N''excludeFromStatus'', NULL, NULL, N''Exclude From Status'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8841, @TaskKey, N''Allow Allocated Hours'', N''allowAllocatedHours'', NULL, NULL, N''Allow Allocated Hours'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (690, @TaskKey, N''Timeline Segment'', N''timelineSegment'', NULL, NULL, N''Timeline Segment'', N''header'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (691, @TaskKey, N''Project Status When Task Complete'', N''taskCompleteProjectStatus'', NULL, NULL, N''Project Status When Task Complete'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (692, 69, N''Assignment Comments'', N''aDescription'', NULL, NULL, N''Assignment Comments'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8842, @TaskKey, N''User ID'', N''userID'', NULL, NULL, N''User ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8843, @TaskKey, N''Detail Service Code'', N''detailServiceCode'', NULL, NULL, N''Detail Service Code'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8844, @TaskKey, N''Hours Allocated'', N''detailHours'', NULL, NULL, N''Hours Allocated'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (69003, @TaskKey, N''Weekly Hours'', N''weeklyHours'', NULL, NULL, N''Weekly Bucket Hours (separate each weekly value with a | symbol). For example "2.2|3|4.55". If specified, Hours Allocated is calculated for this assignment, and the assignment will be makred as Manually Adjusted.'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8845, @TaskKey, N''Detail Perc Comp'', N''detailPercComp'', NULL, NULL, N''Detail Perc Comp'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8846, @TaskKey, N''Detail Act Start'', N''detailActStart'', NULL, NULL, N''Detail Act Start'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8847, @TaskKey, N''Detail Act Complete'', N''detailActComplete'', NULL, NULL, N''Detail Act Complete'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8848, 69, N''Detail Reviewed By Traffic'', N''detailReviewedByTraffic'', NULL, NULL, N''Detail Reviewed By Traffic'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8849, @TaskKey, N''Manual Adjustment'', N''manualAdjustment'', NULL, NULL, N''Manual Adjustment'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8850, @TaskKey, N''APlanStart'', N''aPlanStart'', NULL, NULL, N''APlanStart'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8852, @TaskKey, N''APlan Complete'', N''aPlanComplete'', NULL, NULL, N''APlan Complete'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8853, @TaskKey, N''Action'', N''action'', NULL, NULL, N''Action'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (69001, @TaskKey, N''Predecessors'', N''predecessors'', NULL, NULL, N''Predecessors (lag), task ID comma seperated.  If want to add a lag please put it in () after the predecessor.  For example "2.1 (1)"'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (69002, @TaskKey, N''Must Finish On Pred Complete'', N''mustFinishOnPredComplete'', NULL, NULL, N''Set to Must Finish On when Predecessor is Complete'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (69004, @TaskKey, N''Send Notifications'', N''sendNotifications'', NULL, NULL, N''Send Notifications to the user assigned to the task'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
-- Teams
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8854, 56, N''Team Name'', N''teamName'', NULL, N''TeamName'', N''Team Name'', NULL, 1, NULL, 1, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8855, 56, N''User ID'', N''userID'', NULL, N''UserID'', N''User ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (56001, 56, N''User Name'', NULL, NULL, N''UserName'', N''User Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)

-- Time
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8856, @TimeKey, N''User ID'', N''userID'', NULL, NULL, N''User ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8857, @TimeKey, N''Actual Hours'', N''hours'', NULL, NULL, N''Actual Hours'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8858, @TimeKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number. May be required based on preferences'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8859, @TimeKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID. May be required based on preferences'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8860, @TimeKey, N''Service Code'', N''serviceCode'', NULL, NULL, N''Service Code. May be required based on preferences'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8861, @TimeKey, N''Date'', N''workDate'', NULL, NULL, N''Date'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8862, @TimeKey, N''Comments'', N''comments'', NULL, NULL, N''Comments. May be required based on preferences'', NULL, 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (72100, @TimeKey, N''Overtime'', N''overtime'', NULL, NULL, N''Overtime'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)


 -- Time sheet
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8863, @TimeSheetKey, N''Date'', N''workDate'', NULL, NULL, N''Date'', N''detail'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8864, @TimeSheetKey, N''Start Date & Time'', N''startDate'', NULL, NULL, N''Start Date & Time. May be required based on preferences'', N''header'', 2, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8865, @TimeSheetKey, N''End Date & Time'', N''endDate'', NULL, NULL, N''End Date & Time. May be required based on preferences'', N''header'', 2, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8866, @TimeSheetKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number. May be required based on preferences'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8867, @TimeSheetKey, N''Task ID'', N''taskId'', NULL, NULL, N''Task ID. May be required based on preferences'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8868, @TimeSheetKey, N''Service Code'', N''serviceCode'', NULL, NULL, N''Service Code. May be required based on preferences'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8869, @TimeSheetKey, N''Actual Hours'', N''hours'', NULL, NULL, N''Actual Hours'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8870, @TimeSheetKey, N''Actual Rate'', N''actualRate'', NULL, NULL, N''Actual Rate'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8871, @TimeSheetKey, N''Comments'', N''comments'', NULL, NULL, N''Comments. May be required based on preferences'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8872, @TimeSheetKey, N''Rate Level'', N''rateLevel'', NULL, NULL, N''Rate Level'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8873, @TimeSheetKey, N''Date Billed'', N''dateBilled'', NULL, NULL, N''Date Billed'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8874, @TimeSheetKey, N''Department'', N''departmentKey'', NULL, NULL, N''Department'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8875, @TimeSheetKey, N''Billing Title ID'', N''titleKey'', NULL, NULL, N''Billing Title ID'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8876, @TimeSheetKey, N''User ID'', N''userID'', NULL, NULL, N''User ID'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8877, @TimeSheetKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (21001, 21, N''Start Date'', N''startdate'', NULL, NULL, N''These are api only fields... Not used on import'', N''header'', 2, NULL, NULL, NULL, 1, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (21002, 21, N''End Date'', N''enddate'', NULL, NULL, N''These are api only fields... Not used on import'', N''header'', 2, NULL, NULL, NULL, 1, NULL)

-- Time sheet / Complete
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13201, @TimeSheetCompleteKey, N''TimeSheetKey'', N''timesheetKey'', NULL, NULL, N''timesheeetKey'', NULL, 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13202, @TimeSheetCompleteKey, N''Comments'', N''comments'', NULL, NULL, N''Approval Comments'', NULL, NULL, NULL, NULL, NULL, 1, NULL)

-- Time sheet / Reject
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13301, @TimeSheetRejectKey, N''TimeSheetKey'', N''timesheetKey'', NULL, NULL, N''timesheeetKey'', NULL, 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (13302, @TimeSheetRejectKey, N''Comments'', N''comments'', NULL, NULL, N''Rejection Comments'', NULL, NULL, NULL, NULL, NULL, 1, NULL)


-- Titles
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8878, 64, N''ID'', N''titleID'', NULL, N''TitleID'', N''ID'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8879, 64, N''Name'', N''titleName'', NULL, N''TitleName'', N''Name'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8880, 64, N''Hourly Rate'', N''hourlyRate'', NULL, N''HourlyRate'', N''Hourly Rate'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8881, 64, N''Hourly Cost'', N''hourlyCost'', NULL, N''HourlyCost'', N''Hourly Cost'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8882, 64, N''Department'', N''departmentName'', NULL, N''DepartmentName'', N''Department. Required if Department is required'', NULL, 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8883, 64, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8884, 64, N''Billing Item ID'', N''workTypeID'', NULL, N''WorkTypeID'', N''Billing Item ID'', NULL, NULL, N''WorkTypeID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8885, 64, N''Tax 1 Applies'', N''taxable'', NULL, N''Taxable'', N''Tax 1 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8886, 64, N''Tax 2 Applies'', N''taxable2'', NULL, N''Taxable2'', N''Tax 2 Applies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8887, 64, N''Service Code'', N''serviceKey'', NULL, N''ServiceCode'', N''Service Code'', NULL, NULL, N''ServiceCode'', NULL, NULL, NULL, NULL)
-- Title Rate Sheets
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8888, 65, N''Rate Sheet Name'', N''rateSheetName'', NULL, N''RateSheetName'', N''Rate Sheet Name'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8889, 65, N''Active'', N''active'', NULL, N''Active'', N''Active'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8890, 65, N''Title ID'', N''titleID'', NULL, N''TitleID'', N''Title ID'', N''detail'', 1, N''TitleID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8891, 65, N''Hourly Rate'', N''hourlyRate'', NULL, N''HourlyRate'', N''Hourly Rate'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
-- To Dos
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84001, @ToDoKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84002, @ToDoKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84003, @ToDoKey, N''Subject'', N''subject'', NULL, NULL, N''Subject'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84004, @ToDoKey, N''To Do Status'', N''status'', NULL, NULL, N''To Do Status'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84005, @ToDoKey, N''Due Date'', N''dueDate'', NULL, NULL, N''Due Date'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84006, @ToDoKey, N''Notify Emails'', N''notifyEmails'', NULL, NULL, N''Notify Emails, separate with ; if multiple'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84007, @ToDoKey, N''To Do Type'', N''type'', NULL, NULL, N''To Do Type'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84008, @ToDoKey, N''Notes'', N''notes'', NULL, NULL, N''Notes'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84009, @ToDoKey, N''Assigned User ID'', N''assignedUserID'', NULL, NULL, N''Assigned User ID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (84010, @ToDoKey, N''Completed'', N''completed'', NULL, NULL, N''Completed'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Vouchers
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8892, @VoucherKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8893, @VoucherKey, N''Invoice Number'', N''invoiceNumber'', NULL, NULL, N''Invoice Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8894, @VoucherKey, N''Invoice Date'', N''invoiceDate'', NULL, NULL, N''Invoice Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8895, @VoucherKey, N''Posting Date'', N''postingDate'', NULL, NULL, N''Posting Date. Required if posting'', N''header'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8896, @VoucherKey, N''Due Date'', N''dueDate'', NULL, NULL, N''Due Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8897, @VoucherKey, N''Date Received'', N''dateReceived'', NULL, NULL, N''Date Received'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8898, @VoucherKey, N''AP Account'', N''apAccountNumber'', NULL, NULL, N''AP Account. Required if GL Account is required'', N''header'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8899, @VoucherKey, N''Posted'', N''posted'', NULL, NULL, N''Posted'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8900, @VoucherKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8901, @VoucherKey, N''Approved By'', N''approvedByName'', NULL, NULL, N''Approved By'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8902, @VoucherKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8903, @VoucherKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8904, @VoucherKey, N''Sales Tax Rate'', N''salesTaxID'', NULL, NULL, N''Sales Tax Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8905, @VoucherKey, N''Sales Tax Rate 2'', N''salesTax2ID'', NULL, NULL, N''Sales Tax Rate 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8906, @VoucherKey, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8907, @VoucherKey, N''Office'', N''officeID'', NULL, NULL, N''Office. Required if Office is required'', N''header'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8908, @VoucherKey, N''Opening Transaction'', N''openingTransaction'', NULL, NULL, N''Opening Transaction'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8909, @VoucherKey, N''Overhead'', N''overhead'', NULL, NULL, N''Overhead'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8910, @VoucherKey, N''Invoice Currency ID'', N''currencyID'', NULL, NULL, N''Invoice Currency ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8911, @VoucherKey, N''Invoice Exchange Rate'', N''invoiceExchangeRate'', NULL, NULL, N''Invoice Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8912, @VoucherKey, N''Project Exchange Rate'', N''projectExchangeRate'', NULL, NULL, N''Project Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8913, @VoucherKey, N''Terms Days'', N''termsDays'', NULL, NULL, N''Terms Days'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8914, @VoucherKey, N''Terms Net'', N''termsNet'', NULL, NULL, N''Terms Net'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8915, @VoucherKey, N''Terms Percent'', N''termsPercent'', NULL, NULL, N''Terms Percent'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8916, @VoucherKey, N''Item ID'', N''itemID'', NULL, NULL, N''Item ID. Required base on Voucher Type'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8917, @VoucherKey, N''Description (Line)'', N''descriptionLine'', NULL, NULL, N''Description (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8918, @VoucherKey, N''GL Account'', N''expenseAccountNumber'', NULL, NULL, N''GL Account. Required if GL Acount is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8919, @VoucherKey, N''Quantity'', N''quantity'', NULL, NULL, N''Quantity'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8920, @VoucherKey, N''Unit Description'', N''unitDescription'', NULL, NULL, N''Unit Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8921, @VoucherKey, N''Unit Cost'', N''unitCost'', NULL, NULL, N''Unit Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8922, @VoucherKey, N''Net Cost'', N''totalCost'', NULL, NULL, N''Net Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8923, @VoucherKey, N''Markup'', N''markup'', NULL, NULL, N''Markup'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8924, @VoucherKey, N''Unit Rate'', N''unitRate'', NULL, NULL, N''Unit Rate'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8925, @VoucherKey, N''Gross Cost'', N''grossAmount'', NULL, NULL, N''Gross Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8926, @VoucherKey, N''Amount to Bill'', N''amountToBill'', NULL, NULL, N''Amount to Bill'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8927, @VoucherKey, N''Billable'', N''billable'', NULL, NULL, N''Billable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8928, @VoucherKey, N''Taxable'', N''taxable'', NULL, NULL, N''Taxable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8929, @VoucherKey, N''Taxable 2'', N''taxable2'', NULL, NULL, N''Taxable 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8930, @VoucherKey, N''Sales Tax Amount'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8931, @VoucherKey, N''Sales Tax Amount 2'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax Amount 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8932, @VoucherKey, N''Purchase Order Number'', N''purchaseOrderNumber'', NULL, NULL, N''Purchase Order Number'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8933, @VoucherKey, N''Purchase Order Line Number'', N''purchaseOrderLineNumber'', NULL, NULL, N''Purchase Order Line Number'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8934, @VoucherKey, N''Last Voucher'', N''lastVoucher'', NULL, NULL, N''Last Voucher'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8935, @VoucherKey, N''Project Number (Line)'', N''projectNumber'', NULL, NULL, N''Project Number (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8936, @VoucherKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID. Required if has a project and task is required on teh project'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8937, @VoucherKey, N''Client ID (Line)'', N''clientID'', NULL, NULL, N''Client ID (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8938, @VoucherKey, N''Office (Line)'', N''officeID'', NULL, NULL, N''Office (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8939, @VoucherKey, N''Department (Line)'', N''department'', NULL, NULL, N''Department (Line). Required if Department is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8940, @VoucherKey, N''Target GL Company'', N''targetGLCompanyKey'', NULL, NULL, N''Target GL Company'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8941, @VoucherKey, N''Write Off'', N''writeOff'', NULL, NULL, N''Write Off'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8942, @VoucherKey, N''Date Billed'', N''dateBilled'', NULL, NULL, N''Date Billed'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8943, @VoucherKey, N''Amount Billed'', N''amountBilled'', NULL, NULL, N''Amount Billed'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8944, @VoucherKey, N''Flight Start Date'', N''startDate'', NULL, NULL, N''Flight Start Date'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8945, @VoucherKey, N''Flight End Date'', N''endDate'', NULL, NULL, N''Flight End Date'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8946, @VoucherKey, N''Close'', N''close'', NULL, NULL, N''Close'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8947, @VoucherKey, N''Project Currency ID'', N''pCurrencyID'', NULL, NULL, N''Project Currency ID'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8948, @VoucherKey, N''Project Currency ID (Line)'', N''pCurrencyID'', NULL, NULL, N''Project Currency ID (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8949, @VoucherKey, N''Project Exchange Rate (Line)'', N''pExchangeRate'', NULL, NULL, N''Project Exchange Rate (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8950, @VoucherKey, N''Class ID'', N''classID'', NULL, NULL, N''Class ID. Required if Class is required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8951, @VoucherKey, N''Class ID (Line)'', N''classID'', NULL, NULL, N''Class ID (Line). Required if Class is required'', N''detail'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (120001, @VoucherKey, N''Project Net Cost'', N''pTotalCost'', NULL, NULL, N''Project Net Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (120002, @VoucherKey, N''Net Cost (HC)'', N''hcTotalCost'', NULL, NULL, N''Net Cost (Home Currency)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (120003, @VoucherKey, N''GL Company Exchange Rate'', N''glcExchangeRate'', NULL, NULL, N''GL Company Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (120004, @VoucherKey, N''Detail Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Detail Field Group ID, used for selecting appropriate field group'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (120005, @VoucherKey, N''Header Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Header Field Group ID, used for selecting appropriate field group'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (120006, @VoucherKey, N''Vendor Invoice Type'', N''voucherType'', NULL, NULL, N''Vendor Invoice Type'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
--Vendor Payment
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8952, @VendorPaymentKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', N''header'', 1, N''VendorID'', 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8953, @VendorPaymentKey, N''Check Number'', N''checkNumber'', NULL, NULL, N''Check Number'', N''header'', 1, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8954, @VendorPaymentKey, N''Check Amount'', N''checkAmount'', NULL, NULL, N''Check Amount'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8955, @VendorPaymentKey, N''Check Date'', N''paymentDate'', NULL, NULL, N''Check Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8956, @VendorPaymentKey, N''Posting Date'', N''postingDate'', NULL, NULL, N''Posting Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8957, @VendorPaymentKey, N''Cash Account Number'', N''cashAccountID'', NULL, NULL, N''Cash Account Number'', N''header'', NULL, N''AccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8958, @VendorPaymentKey, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company. Required if GL Company is required'', N''header'', 2, N''GLCompanyName'', NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8959, @VendorPaymentKey, N''Pay to Name'', N''payToName'', NULL, NULL, N''Pay to Name'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8960, @VendorPaymentKey, N''Pay to Address 1'', N''payToAddress1'', NULL, NULL, N''Pay to Address 1'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8961, @VendorPaymentKey, N''Pay to Address 2'', N''payToAddress2'', NULL, NULL, N''Pay to Address 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8962, @VendorPaymentKey, N''Pay to Address 3'', N''payToAddress3'', NULL, NULL, N''Pay to Address 3'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8963, @VendorPaymentKey, N''Pay to Address 4'', N''payToAddress4'', NULL, NULL, N''Pay to Address 4'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8964, @VendorPaymentKey, N''Pay to Address 5'', N''payToAddress5'', NULL, NULL, N''Pay to Address 5'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8965, @VendorPaymentKey, N''Opening Transaction'', N''openingTransaction'', NULL, NULL, N''Opening Transaction'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8966, @VendorPaymentKey, N''Unapplied Payment Account Number'', N''unappliedPaymentAccountID'', NULL, NULL, N''Unapplied Payment Account Number'', N''header'', NULL, N''AccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8967, @VendorPaymentKey, N''Check Memo'', N''memo'', NULL, NULL, N''Check Memo'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8968, @VendorPaymentKey, N''Posted'', N''posted'', NULL, NULL, N''Posted'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8969, @VendorPaymentKey, N''GL Account Number'', N''glAccountID'', NULL, NULL, N''GL Account Number'', N''detail'', NULL, N''AccountNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8970, @VendorPaymentKey, N''Invoice Number'', N''invoiceNumber'', NULL, NULL, N''Invoice Number'', N''detail'', NULL, N''InvoiceNumber'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8971, @VendorPaymentKey, N''Voucher ID'', N''voucherID'', NULL, NULL, N''Voucher ID'', N''detail'', NULL, N''VoucherID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8972, @VendorPaymentKey, N''Description'', N''description'', NULL, NULL, N''Description'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8973, @VendorPaymentKey, N''Quantity'', N''quantity'', NULL, NULL, N''Quantity'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8974, @VendorPaymentKey, N''Unit Amount'', N''unitAmount'', NULL, NULL, N''Unit Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8975, @VendorPaymentKey, N''Payment Amount'', N''paymentAmount'', NULL, NULL, N''Payment Amount'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8976, @VendorPaymentKey, N''Discount Amount'', N''discAmount'', NULL, NULL, N''Discount Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8977, @VendorPaymentKey, N''Office'', N''officeID'', NULL, NULL, N''Office. Required if Office is required'', N''detail'', 2, N''OfficeName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8978, @VendorPaymentKey, N''Department'', N''departmentID'', NULL, NULL, N''Department. Required if Department is required'', N''detail'', 2, N''DepartmentName'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8979, @VendorPaymentKey, N''Exclude from 1099'', N''exclude1099'', NULL, NULL, N''Exclude from 1099'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8980, @VendorPaymentKey, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''detail'', NULL, N''SalesTaxID'', NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8981, @VendorPaymentKey, N''Target GL Company'', N''targetGLCompanyID'', NULL, NULL, N''Target GL Company'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8982, @VendorPaymentKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8983, @VendorPaymentKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8984, @VendorPaymentKey, N''Class ID'', N''classID'', NULL, NULL, N''Class ID. Required if Class is required'', N''header'', 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8985, @VendorPaymentKey, N''Class ID (detail)'', N''classID'', NULL, NULL, N''Class ID (detail). Required if Class is required'', N''detail'', 2, N''ClassID'', NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
-- Vendors
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8986, @VendorKey, N''Company Name'', N''companyName'', NULL, NULL, N''Company Name'', NULL, 1, NULL, 3, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8987, @VendorKey, N''Phone'', N''phone'', NULL, NULL, N''Phone'', NULL, NULL, NULL, 4, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8988, @VendorKey, N''Fax'', N''fax'', NULL, NULL, N''Fax'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8989, @VendorKey, N''Web Site'', N''webSite'', NULL, NULL, N''Web Site'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8990, @VendorKey, N''Company Address 1'', N''address1'', NULL, NULL, N''Company Address 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8991, @VendorKey, N''Company Address 2'', N''address2'', NULL, NULL, N''Company Address 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8992, @VendorKey, N''Company Address 3'', N''address3'', NULL, NULL, N''Company Address 3'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8993, @VendorKey, N''Company City'', N''city'', NULL, NULL, N''Company City'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8994, @VendorKey, N''Company State'', N''state'', NULL, NULL, N''Company State'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8995, @VendorKey, N''Company Postal Code'', N''postalCode'', NULL, NULL, N''Company Postal Code'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8996, @VendorKey, N''Company Country'', N''country'', NULL, NULL, N''Company Country'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8997, @VendorKey, N''Folder'', N''folderName'', NULL, NULL, N''Folder'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8998, @VendorKey, N''Active'', N''active'', NULL, NULL, N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (8999, @VendorKey, N''Date Converted'', N''dateConverted'', NULL, NULL, N''Date Converted'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9000, @VendorKey, N''Comments'', N''comments'', NULL, NULL, N''Comments'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9001, @VendorKey, N''Default Office'', N''office'', NULL, NULL, N''Default Office'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9002, @VendorKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID. Required if passing in a vendor'', NULL, 2, NULL, 2, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9003, @VendorKey, N''Overhead Vendor'', N''overheadVendor'', NULL, NULL, N''Overhead Vendor'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9004, @VendorKey, N''On Hold'', N''onHold'', NULL, NULL, N''On Hold'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9005, @VendorKey, N''Vendor Downloaded'', N''vendorDownloaded'', NULL, NULL, N''Vendor Downloaded'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9006, @VendorKey, N''Terms Percent'', N''termsPercent'', NULL, NULL, N''Terms Percent'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9007, @VendorKey, N''Terms Days'', N''termsDays'', NULL, NULL, N''Terms Days'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9008, @VendorKey, N''Terms Net'', N''termsNet'', NULL, NULL, N''Terms Net'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9009, @VendorKey, N''Default Expense Account'', N''defaultExpenseAccount'', NULL, NULL, N''Default Expense Account'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9010, @VendorKey, N''Default AP Account'', N''defaultAPAccount'', NULL, NULL, N''Default AP Account'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9011, @VendorKey, N''Default AP Approver'', N''defaultAPApprover'', NULL, NULL, N''Default AP Approver'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9012, @VendorKey, N''Default Sales Tax ID 1'', N''vendorSalesTax'', NULL, NULL, N''Default Sales Tax ID 1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9013, @VendorKey, N''Default Sales Tax ID 2'', N''vendorSalesTax2'', NULL, NULL, N''Default Sales Tax ID 2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9014, @VendorKey, N''1099 Form'', N''type1099'', NULL, NULL, N''1099 Form'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9015, @VendorKey, N''1099 Box'', N''box1099'', NULL, NULL, N''1099 Box'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9016, @VendorKey, N''FATCA Filing Requirement'', N''fATCAFilingRequirement'', NULL, NULL, N''FATCA Filing Requirement'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9017, @VendorKey, N''DBA'', N''dBA'', NULL, NULL, N''DBA'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9018, @VendorKey, N''Print DBA On Checks'', N''useDBAForPayment'', NULL, NULL, N''Print DBA On Checks'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9019, @VendorKey, N''Credit Card Account'', N''ccAccountNumber'', NULL, NULL, N''Credit Card Account'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9020, @VendorKey, N''Email Credit Card Info To'', N''emailCCToAddress'', NULL, NULL, N''Email Credit Card Info To'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9021, @VendorKey, N''Credit Card Payee Name'', N''ccPayeeName'', NULL, NULL, N''Credit Card Payee Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9022, @VendorKey, N''Accepts VPay'', N''vCardAccepted'', NULL, NULL, N''Accepts VPay'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9023, @VendorKey, N''One Payment per Invoice'', N''onePaymentPerVoucher'', NULL, NULL, N''One Payment per Invoice'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9024, @VendorKey, N''EIN Number'', N''eINNumber'', NULL, NULL, N''EIN Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9025, @VendorKey, N''Default Memo'', N''defaultMemo'', NULL, NULL, N''Default Memo'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9026, @VendorKey, N''Payment Address'', N''paymentAddress'', NULL, NULL, N''Payment Address'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9027, @VendorKey, N''Accepts Credit Cards'', N''ccAccepted'', NULL, NULL, N''Accepts Credit Cards'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9028, @VendorKey, N''Bank Account Number'', N''bankAccountNumber'', NULL, NULL, N''Bank Account Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9029, @VendorKey, N''Bank Routing Number'', N''bankRoutingNumber'', NULL, NULL, N''Bank Routing Number'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9030, @VendorKey, N''Name on Bank Account'', N''bankAccountName'', NULL, NULL, N''Name on Bank Account'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9031, @VendorKey, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (70001, @VendorKey, N''ACH Enabled'', N''achEnabled'', NULL, NULL, N''ACH Enabled'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (70002, @VendorKey, N''Company Owner'', N''companyOwner'', NULL, NULL, N''Company Owner'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (70003, @VendorKey, N''GL Companies'', N''glCompanies'', NULL, NULL, N''GL Companies'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (70004, @VendorKey, N''Email ACH Info To'', N''emailACHToAddress'', NULL, NULL, N''Email ACH Info To'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (70005, @VendorKey, N''Bank Account Type'', N''bankAccountType'', NULL, NULL, N''Bank Account Type (Checking or Saving)'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (70006, @VendorKey, N''Company Address Name'', N''addressName'', NULL, NULL, N''Company Address Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--Write Off Reasons
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9032, 51, N''Write Off Reason'', N''reasonName'', NULL, N''ReasonName'', N''Write Off Reason'', NULL, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9033, 51, N''Description'', N''description'', NULL, N''Description'', N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9034, 51, N''Active'', N''active'', NULL, N''Active'', N''Active'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Projects
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9035, 13, N''Invoice Layout'', N''invoiceLayout'', NULL, NULL, N''Invoice Layout'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9037, 13, N''Currency'', N''currencyID'', NULL, NULL, N''Currency'', NULL, NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9039, 13, N''Anyone to Charge Time'', N''anyoneChargeTime'', NULL, NULL, N''Anyone to Charge Time'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (9040, 13, N''Do Not Post WIP'', N''doNotPostWIP'', NULL, NULL, N''Do Not Post WIP'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-- Broadcast Orders
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7701, @BOKey, N''BO Number'', N''purchaseOrderNumber'', NULL, NULL, N''BO Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7702, @BOKey, N''Vendor ID'', N''vendorID'', NULL, NULL, N''Vendor ID'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7703, @BOKey, N''BO Type'', N''purchaseOrderType'', NULL, NULL, N''BO Type'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7704, @BOKey, N''Project Number'', N''projectNumber'', NULL, NULL, N''Project Number'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7705, @BOKey, N''Contact'', N''contact'', NULL, NULL, N''Contact'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7706, @BOKey, N''BO Date'', N''pODate'', NULL, NULL, N''BO Date'', N''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77007, @BOKey, N''Flight Start Date'', N''flightStartDate'', NULL, NULL, N''Flight Start Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77008, @BOKey, N''Flight End Date'', N''flightEndDate'', NULL, NULL, N''Flight End Date'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7709, @BOKey, N''Standard Header Text'', N''headerTextID'', NULL, NULL, N''Standard Header Text'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7710, @BOKey, N''Standard Footer Text'', N''footerTextID'', NULL, NULL, N''Standard Footer Text'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7711, @BOKey, N''Approver'', N''approvedBy'', NULL, NULL, N''Approver'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7712, @BOKey, N''Approved'', N''approved'', NULL, NULL, N''Approved'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7713, @BOKey, N''Sales Tax ID'', N''salesTaxID'', NULL, NULL, N''Sales Tax ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7714, @BOKey, N''Sales Tax ID 2'', N''salesTax2ID'', NULL, NULL, N''Sales Tax ID 2'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7715, @BOKey, N''GL Company'', N''glCompanyID'', NULL, NULL, N''GL Company. Required if GL Companies are required'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.prefs.UseGLCompany == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7716, @BOKey, N''Order Description'', N''description'', NULL, NULL, N''Order Description'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7717, @BOKey, N''Project Number (Line)'', N''projectNumber'', NULL, NULL, N''Project Number (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7719, @BOKey, N''Office'', N''officeKey'', NULL, NULL, N''Office. Required if Office is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7720, @BOKey, N''Department'', N''departmentID'', NULL, NULL, N''Department. Required if Department is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7721, @BOKey, N''Item ID'', N''itemID'', NULL, NULL, N''Item ID. Required if Item is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7722, @BOKey, N''Task ID'', N''taskID'', NULL, NULL, N''Task ID. Required if Task is required'', N''detail'', 2, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7724, @BOKey, N''Comments'', N''longDescription'', NULL, NULL, N''Comments'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7727, @BOKey, N''Spots'', N''spots'', NULL, NULL, N''Spots'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7728, @BOKey, N''Unit Desc'', N''unitDescription'', NULL, NULL, N''Unit Desc'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7729, @BOKey, N''Commission'', N''markup'', NULL, NULL, N''Commission'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7730, @BOKey, N''Billable'', N''billable'', NULL, NULL, N''Billable'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7731, @BOKey, N''Net Cost'', N''totalCost'', NULL, NULL, N''Net Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7733, @BOKey, N''Sales Tax Amount'', N''salesTax1Amount'', NULL, NULL, N''Sales Tax Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7734, @BOKey, N''Sales Tax Amount 2'', N''salesTax2Amount'', NULL, NULL, N''Sales Tax Amount 2'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7735, @BOKey, N''Currency ID'', N''currencyID'', NULL, NULL, N''Currency ID'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7736, @BOKey, N''Exchange Rate'', N''exchangeRate'', NULL, NULL, N''Exchange Rate'', N''header'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7737, @BOKey, N''Exchange Rate (Line)'', N''pExchangeRate'', NULL, NULL, N''Exchange Rate (Line)'', N''detail'', NULL, NULL, NULL, NULL, NULL, N''System.prefs.MultiCurrency == 1'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7738, @BOKey, N''Class ID'', N''classKey'', NULL, NULL, N''Class ID. Required if Class is required.'', N''header'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7739, @BOKey, N''Class ID (Line)'', N''classKey'', NULL, NULL, N''Class ID (Line). Required if Class is required'', N''detail'', 2, NULL, NULL, NULL, NULL, N''System.hasCustomization(''''legacyclasses'''')'')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7740, @BOKey, N''Space Close'', N''spaceClose'', NULL, NULL, N''Space Close'', N''detail'', NULL, NULL, NULL, NULL, NULL, N'''')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7741, @BOKey, N''Materials Due'', N''materialsDue'', NULL, NULL, N''Materials Due'', N''detail'', NULL, NULL, NULL, NULL, NULL, N'''')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7743, @BOKey, N''User Defined Date 3'', N''userDate3'', NULL, NULL, N''User Defined Date 3'', N''detail'', NULL, NULL, NULL, NULL, NULL, N'''')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (7744, @BOKey, N''User Defined Date 4'', N''userDate4'', NULL, NULL, N''User Defined Date 4'', N''detail'', NULL, NULL, NULL, NULL, NULL, N'''')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77077, @BOKey, N''User Defined Date 5'', N''userDate5'', NULL, NULL, N''User Defined Date 5'', N''detail'', NULL, NULL, NULL, NULL, NULL, N'''')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77078, @BOKey, N''User Defined Date 6'', N''userDate6'', NULL, NULL, N''User Defined Date 6'', N''detail'', NULL, NULL, NULL, NULL, NULL, N'''')
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77001, @BOKey, N''Unit Cost'', N''unitCost'', NULL, NULL, N''Unit Cost'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77002, @BOKey, N''Gross Amount'', N''grossAmount'', NULL, NULL, N''Gross Amount'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77003, @BOKey, N''Order Days'', N''orderDays'', NULL, NULL, N''Order Days'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77004, @BOKey, N''Order Time'', N''orderTime'', NULL, NULL, N''Order Time'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77005, @BOKey, N''Order Length'', N''orderLength'', NULL, NULL, N''Order Length'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77006, @BOKey, N''Detail Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Detail Field Group ID, used for selecting appropriate field group'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition], [SystemSettingFieldName]) VALUES (77009, @BOKey, N''Station ID'', N''stationID'', NULL, NULL, N''stationID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL, N''BCRequireStations'') 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77010, @BOKey, N''Media Estimate ID'', N''mediaEstimateID'', NULL, NULL, N''Media Estimate ID'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77011, @BOKey, N''Traffic Instructions'', N''trafficInstructions'', NULL, NULL, N''Traffic Instructions'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77012, @BOKey, N''Ordered By'', N''orderedBy'', NULL, NULL, N''Ordered By'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77013, @BOKey, N''Special Instructions'', N''specialInstructions'', NULL, NULL, N''Special Instructions'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL) 
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77014, @BOKey, N''Detail Order Start Date'', N''detailOrderStartDate'', NULL, NULL, N''Detail Order Start Date'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77015, @BOKey, N''Detail Order End Date'', N''detailOrderEndDate'', NULL, NULL, N''Detail Order End Date'', N''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77016, @BOKey, N''Header Field Group ID'', N''fieldGroupID'', NULL, NULL, N''Header Field Group ID, used for selecting appropriate field group'', N''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77017, @BOKey, N''Item Name (Program)'', N''shortDescription'', NULL, NULL, N''Item Name (Program)'', N''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (77018, @BOKey, N''Header ID'', N''headerID'', NULL, NULL, N''Header ID, used for associating header and detail fields when they do not pass in the PO Number'', N''header'', 1, NULL, NULL, NULL, 1, NULL)
-- View
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78001, @ViewKey, N''ViewKey'', N''viewKey'', NULL, NULL, N''ViewKey'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78002, @ViewKey, N''Name'', N''name'', NULL, NULL, N''Name'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78003, @ViewKey, N''ReportType'', N''reportType'', NULL, NULL, N''ReportType'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78004, @ViewKey, N''ReportFilter'', N''reportFilter'', NULL, NULL, N''ReportFilter'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78005, @ViewKey, N''Definition'', N''definition'', NULL, NULL, N''Definition'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78006, @ViewKey, N''FieldDefinition'', N''fieldDefinition'', NULL, NULL, N''FieldDefinition'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78007, @ViewKey, N''ConditionDefinition'', N''conditionDefinition'', NULL, NULL, N''ConditionDefinition'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78008, @ViewKey, N''Private'', N''private'', NULL, NULL, N''Private'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78009, @ViewKey, N''ReportHeading1'', N''reportHeading1'', NULL, NULL, N''ReportHeading1'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78010, @ViewKey, N''ReportHeading1Align'', N''reportHeading1Align'', NULL, NULL, N''ReportHeading1Align'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78011, @ViewKey, N''ReportHeading2'', N''reportHeading2'', NULL, NULL, N''ReportHeading2'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78012, @ViewKey, N''ReportHeading2Align'', N''reportHeading2Align'', NULL, NULL, N''ReportHeading2Align'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78013, @ViewKey, N''Orientation'', N''orientation'', NULL, NULL, N''Orientation'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78014, @ViewKey, N''GroupBy'', N''groupBy'', NULL, NULL, N''GroupBy'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78015, @ViewKey, N''ShowConditions'', N''showConditions'', NULL, NULL, N''ShowConditions'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78016, @ViewKey, N''ReportID'', N''reportID'', NULL, NULL, N''ReportID'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78017, @ViewKey, N''GroupByDefinition'', N''groupByDefinition'', NULL, NULL, N''GroupByDefinition'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78018, @ViewKey, N''LockedColumns'', N''lockedColumns'', NULL, NULL, N''LockedColumns'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78020, @ViewKey, N''AutoExpandGroups'', N''autoExpandGroups'', NULL, NULL, N''AutoExpandGroups'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78021, @ViewKey, N''ApplicationVersion'', N''applicationVersion'', NULL, NULL, N''ApplicationVersion'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78022, @ViewKey, N''AutoRun'', N''autoRun'', NULL, NULL, N''AutoRun'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78023, @ViewKey, N''Description'', N''description'', NULL, NULL, N''Description'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78024, @ViewKey, N''DisplayType'', N''displayType'', NULL, NULL, N''DisplayType'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78025, @ViewKey, N''TabName'', N''tabName'', NULL, NULL, N''TabName'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78026, @ViewKey, N''DataTargetUpper'', N''dataTargetUpper'', NULL, NULL, N''DataTargetUpper'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78027, @ViewKey, N''DataTargetLower'', N''dataTargetLower'', NULL, NULL, N''DataTargetLower'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78028, @ViewKey, N''MaxItemCount'', N''maxItemCount'', NULL, NULL, N''MaxItemCount'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78029, @ViewKey, N''XAxisLabel'', N''xAxisLabel'', NULL, NULL, N''XAxisLabel'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78030, @ViewKey, N''YAxisLabel'', N''yAxisLabel'', NULL, NULL, N''YAxisLabel'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78031, @ViewKey, N''ReportGroupName'', N''reportGroupName'', NULL, NULL, N''ReportGroupName'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78032, @ViewKey, N''XAxisHasCField'', N''xAxisHasCField'', NULL, NULL, N''XAxisHasCField'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78033, @ViewKey, N''YAxisHasCField'', N''yAxisHasCField'', NULL, NULL, N''YAxisHasCField'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78034, @ViewKey, N''SeriesHasCField'', N''seriesHasCField'', NULL, NULL, N''SeriesHasCField'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78035, @ViewKey, N''DefaultReportView'', N''sefaultReportView'', NULL, NULL, N''DefaultReportView'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78036, @ViewKey, N''PivotSettings'', N''pivotSettings'', NULL, NULL, N''PivotSettings'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78037, @ViewKey, N''XAxisHasCField'', N''xAxisHasCField'', NULL, NULL, N''XAxisHasCField'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78038, @ViewKey, N''YAxisHasCField'', N''yAxisHasCField'', NULL, NULL, N''YAxisHasCField'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) VALUES (78039, @ViewKey, N''SeriesHasCField'', N''seriesHasCField'', NULL, NULL, N''SeriesHasCField'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)

--Media Plans
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80015, @MediaPlanKey, N''Plan ID'', N''planID'', NULL, N''PlanID'', N''Plan ID'', ''header'', 1, NULL, 1, NULL, 1, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
--VALUES (80016, @MediaPlanKey, N''Media Plan Key'', N''mediaPlanKey'', NULL, N''MediaPlanKey'', N''Media Plan Key - only required in PUT'', ''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80017, @MediaPlanKey, N''Plan Name'', N''planName'', NULL, N''PlanName'', N''Plan Name'', ''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80019, @MediaPlanKey, N''Project Number'', N''projectNumber'', NULL, N''ProjectKey'', N''Project number'', ''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80020, @MediaPlanKey, N''Description'', N''description'', NULL, N''Description'', N''Description of the plan'', ''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80021, @MediaPlanKey, N''Item ID'', N''itemID'', NULL, N''ItemID'', N''Item ID'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80022, @MediaPlanKey, N''Vendor ID'', N''vendorID'', NULL, N''VendorID'', N''Vendor ID'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80023, @MediaPlanKey, N''Station ID'', N''stationID'', NULL, N''StationID'', N''Station ID'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80024, @MediaPlanKey, N''Spot Link ID'', N''spotLinkID'', NULL, N''SpotLinkID'', N''The ID of the media buy in your system'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80025, @MediaPlanKey, N''Description (Buy)'', N''description'', NULL, N''Description'', N''The description of the media buy'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80026, @MediaPlanKey, N''Start Date'', N''startDate'', NULL, N''StartDate'', N''The start date of the media buy'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80027, @MediaPlanKey, N''End Date'', N''endDate'', NULL, N''EndDate'', N''The end date of the media buy'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80028, @MediaPlanKey, N''Order Days'', N''orderDays'', NULL, N''OrderDays'', N''Order Days'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80029, @MediaPlanKey, N''Order Time'', N''orderTime'', NULL, N''OrderTime'', N''Order Time'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80030, @MediaPlanKey, N''Order Length'', N''orderLength'', NULL, N''OrderLength'', N''Order Length'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80031, @MediaPlanKey, N''Space Close'', N''spaceClose'', NULL, N''Date1'', N''Space Close'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80032, @MediaPlanKey, N''Materials Due'', N''materialsDue'', NULL, N''Date2'', N''Materials Due'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80033, @MediaPlanKey, N''Quantity'', N''quantity'', NULL, N''Quantity'', N''The number of spots'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80034, @MediaPlanKey, N''Cost'', N''cost'', NULL, N''Cost'', N''The total net of the media buy'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80035, @MediaPlanKey, N''Commission'', N''commission'', NULL, N''Markup'', N''Commission'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80036, @MediaPlanKey, N''Unit Rate'', N''unitRate'', NULL, N''UnitCost'', N''Unit rate'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80037, @MediaPlanKey, N''Gross'', N''gross'', NULL, N''Gross'', N''The total gross of the media buy'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80038, @MediaPlanKey, N''Amount to Bill'', N''amountToBill'', NULL, N''AmountToBill'', N''The amount to bill of the media buy'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80039, @MediaPlanKey, N''Line Number'', N''lineNumber'', NULL, N''LineNumber'', N''The line number of the media buy'', ''detail'', Null, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80040, @MediaPlanKey, N''Action'', N''action'', NULL, N''Action'', N''The action on the media buy. Only supported action for PUT is delete'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80041, @MediaPlanKey, N''Order Link ID'', N''orderLinkID'', NULL, N''OrderLinkID'', N''The ID of the media buy  order in your system'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
--VALUES (80041, @MediaPlanKey, N''Media Plan Detail Key'', N''mediaPlanDetailKey'', NULL, N''MediaPlanDetailKey'', N''Media Buy Key - only required in PUT'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)

-- Media Plan Vouchers
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
--VALUES (80050, @MediaPlanVoucherKey, N''Media Plan Vendor Invoice Key'', N''mediaPlanVoucherKey'', NULL, N''MediaPlanVoucherKey'', N''Media Plan Vendor Invoice Key - only required in PUT'', ''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80051, @MediaPlanVoucherKey, N''Plan ID'', N''planID'', NULL, N''mediaPlanKey'', N''Plan ID'', ''header'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80052, @MediaPlanVoucherKey, N''Vendor ID'', N''vendorID'', NULL, N''VendorKey'', N''Vendor ID'', ''header'', 1, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80053, @MediaPlanVoucherKey, N''Invoice Number'', N''invoiceNumber'', NULL, N''InvoiceNumber'', N''Invoice number'', ''header'', 1, NULL, 1, NULL, 1, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80054, @MediaPlanVoucherKey, N''Invoice Date'', N''invoiceDate'', NULL, N''InvoiceDate'', N''Invoice Date'', ''header'', 1, NULL, NULL, NULL, NULL, NULL)
--INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
--VALUES (80055, @MediaPlanVoucherKey, N''Media Plan Vendor Invoice Detail Key'', N''mediaPlanVoucherDetailKey'', NULL, N''MediaPlanVoucherDetailKey'', N''Vendor invoice detail Key - only required in PUT'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80055, @MediaPlanVoucherKey, N''Invoice Link ID'', N''invoiceLinkID'', NULL, N''InvoiceLinkID'', N''The ID of the vendor invoice in your system'', ''header'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80067, @MediaPlanVoucherKey, N''Bottom Line Invoice'', N''bottomLineInvoice'', NULL,N''BottomLineInvoice'', N''Is this a Bottom Line Invoice?'', ''header'', NULL, NULL, NULL, NULL, NULL, NULL)

INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80056, @MediaPlanVoucherKey, N''Link ID'', N''linkID'', NULL, N''LinkID'', N''The ID of the media vendor invoice detail in your system'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80057, @MediaPlanVoucherKey, N''Spot Link ID'', N''spotLinkID'', NULL, N''Spot LinkID'', N''The ID of the media buy in your system'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80058, @MediaPlanVoucherKey, N''Description'', N''description'', NULL, N''Description'', N''The description of the vendor invoice detail'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80060, @MediaPlanVoucherKey, N''Cost'', N''appliedCost'', NULL, N''Cost'', N''The total net of the vendor invoice detail'', ''detail'', 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80065, @MediaPlanVoucherKey, N''Action'', N''action'', NULL, N''Action'', N''The action on the vendor invoice detail. Only supported action for PUT is delete'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80066, @MediaPlanVoucherKey, N''Last Invoice'', N''lastVoucher'', NULL, N''LastVoucher'', N''This indicates that this is the last vendor invoice detail applied to a media buy'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)

INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80068, @MediaPlanVoucherKey, N''Order Link ID'', N''orderLinkID'', NULL, N''OrderLinkID'', N''The ID of the order in your system (POST and bottom line invoice only)'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80069, @MediaPlanVoucherKey, N''Invoice Total'', N''invoiceTotal'', NULL, N''InvoiceTotal'', N''The desired invoice total (POST and bottom line invoice only)'', ''detail'', NULL, NULL, NULL, NULL, NULL, NULL)

-- Media Plan release
INSERT [dbo].[tImportExportDetail] ([ImportExportDetailKey], [ImportExportKey], [ImportExportFieldName], [ApiFieldName], [BusinessClassFieldName], [DBFieldName], [Description], [Section], [Required], [ExportField], [MatchingRow], [MatchingRowLabel], [LinkField], [Condition]) 
VALUES (80070, @MediaPlanReleaseKey, N''Spot Link ID'', N''spotLinkID'', NULL, N''SpotLinkID'', N''The ID of the media buy in your system'', NULL, NULL, NULL, NULL, NULL, NULL, NULL)


SET IDENTITY_INSERT [dbo].[tImportExportDetail] OFF

----------------------------------------------------------------------
------- Update Descriptions
----------------------------------------------------------------------
	--1 Contacts
	UPDATE tImportExport SET [Description] = ''Contacts is the location of all the people in the system except for those found in the Leads area. Most will be associated with a Company, but it is not required. You are able to keep track of multiple addresses and other pertinent contact information. You are also able to view a history of each Activity and Meeting associated with the contact.''
	WHERE ImportExportKey = 1

	--3  Employees
	UPDATE tImportExport SET [Description] = ''There are a number of basic fields that need to be entered on the employee record to ensure Projects, Billing and Reporting will contain the correct information for your staff.''
	WHERE ImportExportKey = 3

	--4 Expense Report Items
	UPDATE tImportExport SET [Description] = ''Expense Report items are used on to track and categorize personal expenses incurred on the agency''''s behalf by your staff. These will typically be entered via an Expense Report, but are also available via a Vendor Voucher.''
	WHERE ImportExportKey = 4

	--5 Purchase Items
	UPDATE tImportExport SET [Description] = N''Purchase Items allow you to track and categorize outside expenses for use in Purchase Orders, Vendor Vouchers, Misc. Project Costs and Client Invoices.''
	WHERE ImportExportKey = 5

	--6 GL Accounts
	UPDATE tImportExport SET [Description] = N''The General Ledger Accounts or Chart of Accounts, form the basis of your financial records in the system. By default, Workamajig has a chart of accounts already setup for you. These are based upon industry standards as provided by Second Wind.''
	WHERE ImportExportKey = 6

	 --7 Payment Terms
	 UPDATE tImportExport SET [Description] = ''This area allows you to set the various payment terms that may be used for your client invoices.''
	 WHERE ImportExportKey = 7

	 --8 Sales Tax
	UPDATE tImportExport SET [Description] = N''Sales Tax Rates are used to automatically calculate sales tax amounts on project estimates and client invoices. Sales Tax Rates can also be linked to vendors, so you can automatically determine the amount of sales tax due at the end of the year.''
	WHERE ImportExportKey = 8

	--9 Services
	UPDATE tImportExport SET [Description] = N''Services allows you to track and categorize employee labor for use in Task Assignments, Time Entry, Tracking/Reporting, and Client Invoices.''
	 WHERE ImportExportKey = 9

	--10 Billing Items
	UPDATE tImportExport SET [Description] = ''Billing items allow you to track and organize Services, Purchase Items, Expense Report Items, and Media Items for use in project reporting and Client Invoices. The billing items allow you to group similar services and expenses and create invoice lines based upon these groups. Billing items can also be used as a way to Post Sales Amounts, on an invoice to several sales GL Accounts from a single line item on an invoice''
	WHERE ImportExportKey = 10

	--11 Invoices
	UPDATE tImportExport SET [Description] = N''These can be created manually by Adding a New Client Invoice, or generated based on your client setup and billing process such as Billing Worksheets, Mass Billing or from the individual projects Billing screen. ''
	 WHERE ImportExportKey = 11

	--12 Vendor Invoices
	UPDATE tImportExport SET [Description] = N''The vendor invoice system integrates tightly with the purchase order system so that purchase order details can be easily pulled onto a vendor invoice. It helps the Accounts Payable processing system for recording expenses to projects as well as administrative invoices''
	 WHERE ImportExportKey = 12
	--13 Projects
	UPDATE tImportExport SET [Description] = N''While projects have many aspects to them, the main purpose of a project is to track, and manage timelines that tie directly into employee''''s timesheets, and can then determine how billing is to proceed.'' 
	WHERE ImportExportKey = @ProjectKey


	--16 Estimates
	UPDATE tImportExport SET [Description] = N''In Workamajig, there are two kinds of estimates. There is a Campaign-based estimate and a Project-based estimate. In this section, the project-based estimate will be discussed.''
	WHERE ImportExportKey = 16

	--18 Purchase Order
	UPDATE tImportExport SET [Description] = N''A purchase order is used to tell a vendor that you want to purchase some item; it acts like a contract with the vendor. It is helpful in tracking expenses incurred toward a project. It allows the company to set controls on things like who could purchase items or how much can be spent on something and therefore is good for budgeting and expense tracking purposes''
	WHERE ImportExportKey = 18

	--19 Receipts, aka Client Receipts, aka client payments
	UPDATE tImportExport SET [Description] = ''DEPRECATED 1/1/2019...Please use Receipts end point moving foward.  When entering a receipt, you are able to apply all, or a portion of the amount, towards open client invoices, a designated sales account or leave as an unapplied amount to be applied towards a future invoice.''
	WHERE ImportExportKey = @ClientPaymentsKey

	--20 Vendor Payments
	UPDATE tImportExport SET [Description] = ''Vendor Payments allow you to track how much you actually pay vendors and print checks directly from Workamajig. Payments will usually be created using Menu > Payments > Select Invoices For Payment screen''
	WHERE ImportExportKey = 20

	--21 Timesheets
	UPDATE tImportExport SET [Description] = N''While the Timesheets section from the main menu navigation will give you access to all of your timesheets entered in the system.  For the API to act on behalf of another person you will need the right "View anyone''''s timesheet" or be an administrator.''
	WHERE ImportExportKey = @TimeSheetKey

	--22 Expense Reports
	UPDATE tImportExport SET [Description] = N''Expense Reports are used for staff members to track out of pocket expenses incurred while working on the company''''s behalf. Each line of the expense report is treated much like a Purchase Order, in that it can be tracked to a client project for billing purposes. Following approval, the approver can convert the expense report into a vendor invoice for reimbursement. The vendor used for the vendor invoice is defaulted from the employee record, but ultimately must be specified at the top of the expense report.''
	WHERE ImportExportKey = 22

	--23 Misc Project Costs
	UPDATE tImportExport SET [Description] = N''This area allows you to enter expenses directly into the project. There is no approval process for these items. Typically, Misc Costs are a way to take items that have been purchased in bulk by your agency and associate a portion of the cost towards a client project, such as, stock photography, DVDs/Jewel case, and copies.''
	WHERE ImportExportKey = 23

	--24 Journal Entry
	UPDATE tImportExport SET [Description] = N''Workamajig allows you to create journal entries in order to account for transactions that are not connected to a Client Invoice or Vendor Voucher, such as rent and agency payroll, or to make adjustments to your General Ledger accounts. The Total Debits - Credits: must total $0.00 for the Journal Entry to be posted to the General Ledger.''
	WHERE ImportExportKey = 24

	--25 Project Types
	UPDATE tImportExport SET [Description] = N''Project types allow you to group your projects into different categories for reporting purposes.''
	WHERE ImportExportKey = 25

	--27 Project Status
	UPDATE tImportExport SET [Description] = N''Project status codes are used to determine where a project is in an overall production status.  While each project can have a unique schedule and set of tasks that need to be completed on the project, most projects move through a similar overall flow through the business.''
	WHERE ImportExportKey = 27

	--28 Departments
	UPDATE tImportExport SET [Description] = ''Departments are used to group your information into different functional areas.  Departments can be used on several reports for filtering and grouping data. Departments are global across a company and will be the same from office to office.''
	WHERE ImportExportKey = 28

	--29 Project Billing Status
	UPDATE tImportExport SET [Description] = N''Project billing status codes are most commonly used to help determine where a project is in the billing cycle.  The project billing status code can also be used to flag the accounting group as to which projects should be billed and when they should be billed.''
	WHERE ImportExportKey = 29

	--31 Broadcast items
	UPDATE tImportExport SET [Description] = ''Broadcast Items are used to categorize your purchases of different types of broadcast purchases. These would typically include Radio and Television. The item is also used to expense the purchase to the correct expense account when a vendor invoice is billed and WIP is tracked in the general ledger.''
	WHERE ImportExportKey = 31

	--32 Print Items
	UPDATE tImportExport SET [Description] = N''Print Items are used to categorize your purchases of different types of Print purchases. These would typically include Magazine, Newspaper and Outdoor. The item is also used to expense the purchase to the correct expense account when a vendor invoice is billed and WIP is tracked in the general ledger.''
	WHERE ImportExportKey = 32

	--33 GL Companies
	UPDATE tImportExport SET [Description] = N''Workamajig has always supported multiple GL Companies as a way of segregating data into specific GL Companies for tracking and reporting purposes.  Recently, the ability to handle Intercompany transactions was added to further advance the multiple company capabilities and in doing so, the need to secure data by GL Company became necessary. The Security and Access settings are only necessary if GL Companies are being used and access to data for specific companies needs to be secured for users.''
	WHERE ImportExportKey = 33

	--34 Insertion Orders
	UPDATE tImportExport SET [Description] = N''Insertion Orders are like Purchase Orders used to place orders to Publications. Insertion Orders are entered using the gross amount and a commission percentage to determine the net amount. Insertion orders also allow you to track user definable dates on each line item of the order.''
	WHERE ImportExportKey = 34

	--36 Leads
	UPDATE tImportExport SET [Description] = N''Leads is the area of Workamajig used to track your pre-sales efforts. A lead is considered a non-qualified contact, either client or vendor. A Lead record consists of contact information at the personal and company level. Lead records are created individually, via import or via the Web to Leads feature. You are also able to track the communication history. Once a Lead has been qualified, the Lead can be converted into a Contact/Company record. ''
	WHERE ImportExportKey = 36

	--37 Companies
	UPDATE tImportExport SET [Description] = ''The Company area includes all Companies in your system, including Clients and Vendors. This area will not include any data from the Leads area. To prevent duplication of Company and Contacts, it is recommended that you first create a company, then add contacts via the new company: Contacts area.''
	WHERE ImportExportKey = 37

	--38 Opportunities
	UPDATE tImportExport SET [Description] = N''The purpose of an Opportunity is to serve as a starting point and a tracing of your project proposal. It allows you to convert to a working project.''
	WHERE ImportExportKey = 38

	--39 Activities
	UPDATE tImportExport SET [Description] = ''An activity in Workamajig is used to document "touch points" regarding Clients, Vendors, Opportunities, Projects, and Leads. You are able to notify multiple people and link the activity to multiple projects, contacts, companies, etc. to increase the visibility of the necessary information your staff needs to get their job done.''
	WHERE ImportExportKey = 39

	--40 Report Groups
	UPDATE tImportExport SET [Description] = N''Report groups are used to organize different custom reports in the system.  On the reports page, the system allows you to create an unlimited number of custom reports.  You can set up different report groups here to better organize your custom reports.''
	WHERE ImportExportKey = 40

	--41 Opportunity Stages
	UPDATE tImportExport SET [Description] = N''Opportunity stages allow you to create a sales funnel through which you can track your different opportunities and determine which state in the sales process they are currently at.''
	WHERE ImportExportKey = 41

	--42 Opportunity Status
	UPDATE tImportExport SET [Description] = N''Opportunity Status allows you to define the status of the opportunity. Typical settings are Postponed, Closed or Open.''
	WHERE ImportExportKey = 42

	--43, N''Opportunity Outcome
	UPDATE tImportExport SET [Description] = N''When tracking opportunities in the contact management system, you can use opportunity outcomes to categorize the outcome of each opportunity you enter into the system.  This can give you valuable information on your conversion statistics, as well as, how many opportunities you win versus lose, and the reasons for winning and losing them.''
	WHERE ImportExportKey = 43

	--44 Company Types
	UPDATE tImportExport SET [Description] = ''Company types are used in contact management to segment your contact database. Company types can be used to quickly find different types of companies, vendors or clients. You can add as many company types as you would like and then use them in custom listings and reports.''
	WHERE ImportExportKey = 44

	--45 Meeting Types
	UPDATE tImportExport SET [Description] = ''These apply to calendar meetings in Workamajig and allow you to define the meeting without having to include this in the subject of the meeting.''
	WHERE ImportExportKey = 45

	--46 Calendar Resources  
	UPDATE tImportExport SET [Description] = ''This section contains a list of calendars associated with the various resources you need to schedule, Ex. conference rooms and OHPs.''
	WHERE ImportExportKey = 46

	-- 48 Sources  
	UPDATE tImportExport SET [Description] = N''Source is ultimately seen as being connected to a Company record. You are able to select a Source via a Lead record:Company Info area or from the Company record:Company Info area.  After defining the Source,  you are able to use this field for reporting and grouping of records in the listing screens and reports associated with Leads, Contacts, Companies, and Opportunities. ''
	WHERE ImportExportKey = 48

	-- 49 Conversation Types 
	UPDATE tImportExport SET [Description] = ''This allows you to create a custom dropdown when using Activities and Diary posts. The main benefit being that you can run reports based on which type was chosen by the one creating the activity or Diary post.''
	WHERE ImportExportKey = 49

	 -- 50 Payment Methods  
	UPDATE tImportExport SET [Description] = N''Payment methods are used to categorize receipts from clients. Typical options would include check, cash, credit card, EFT.''
	WHERE ImportExportKey = 50

	 -- 51 Write Off Reasons 
	UPDATE tImportExport SET [Description] = N''When closing out transactions on a project, you have several Form Actions to choose from: Bill Selected Items, Mark as Billed, or Write Them Off (to name just a few). When you write off the transaction in the billing worksheet, it does not have a direct impact on the general ledger unless you are??re tracking work in progress in the ledger''
	WHERE ImportExportKey = 51

	  -- 52 Standard Text  
	  UPDATE tImportExport SET [Description] = N''This is simply where you can create a Header and/or Footer Text that is then selectable for each order.''
	 WHERE ImportExportKey = 52

	  -- 53 Media Markets  
	  UPDATE tImportExport SET [Description] = ''Media Markets are used to track stations and publications to different areas of the country, and can be used when reporting on purchases.''
	  WHERE ImportExportKey = 53

	  -- 54 GL Classes  
	  UPDATE tImportExport SET [Description] = N''GL classes are used to segment transactions posted to the general ledger.  They can be used for several different types of needs.  The most common use of classes is to segment transactions by company, department or office.  When entering transactions such as vendor invoices or client invoices, you can select different classes on each transaction at the header and the line. When the transaction is posted to the general ledger, the system will add the class from the transaction on each entry that is posted.  When running your financial reports, you will be able to filter the transactions on the report by class.''
	  WHERE ImportExportKey = 54

	  -- 55 Offices  
	  UPDATE tImportExport SET [Description] = N''Workamajig allows you to separate out Employees, Projects and project file access using office. This can be useful when reporting on chargeability and project profitability reports and controlling access to your file storage server. Offices will flow through to the general ledger when posting transactions''
	  WHERE ImportExportKey = 55

	  -- 56 Teams  
	  UPDATE tImportExport SET [Description] = N''These are referred to as Account Teams in Client and Project setup.''
	  WHERE ImportExportKey = 56

	  -- 57 Credit Card Charges 
	  UPDATE tImportExport SET [Description] = ''The Credit Card Charges feature under the Purchasing menu allows you to pay vendor invoices using a credit card, add credit card charges for purchases, reconciling credit card statements and pay your credit card bills.  You can setup a supported provider to automatically download credit card charges, import .ofx files from the credit card, or setup an import file to quickly import numerous credit card charges at once.''
	  WHERE ImportExportKey = 57

	   -- 58 Service Rate Sheets  
	   UPDATE tImportExport SET [Description] = N''Service Rate Sheets allow you to create multiple billing rates for your services. A Service Rate Sheet can be pre-assigned to the client to be used as a default for the clients projects (additional workflow setup required). This can also be used for creating Rush Rates, etc''
	   WHERE ImportExportKey = 58

	   -- 59 Item Rate Sheets  
	   UPDATE tImportExport SET [Description] = N''Purchase Item Rate Sheets are used to standardize markups for items for different clients. Item rate sheets work the same way as service rate sheets. You can set different markups for the same item on each rate sheet and then on each project, select a different rate sheet based on the client.''
	   WHERE ImportExportKey = 59

	   -- 60 Financial Budgets  
	   UPDATE tImportExport SET [Description] = N''Workamajig allows for Financial Budgets to be put into the system at a number of different levels. The budget can be used for comparison purposes when running your P&L financial reports. The following dimensions can be defined on your financial budget: GL Company, Office, Department, GL Class and Client.''
	   WHERE ImportExportKey = @GLBudget

	   -- 61 Billing Groups  
	   UPDATE tImportExport SET [Description] = N''This feature is used to group together projects for billing purposes. Though the same Billing Group can be used to identify projects across multiple projects, Workamajig will generate a Master Billing Worksheet for each client and each Billing Group identified on the individual client projects.''
	   WHERE ImportExportKey = 61

	   -- 62 Credit Card Transactions  
	   UPDATE tImportExport SET [Description] = N''The purpose of the connector is to allow you a chance to review and code your incoming charges to the correct project and other settings.''
	   WHERE ImportExportKey = 62

	   -- 63 Currency Rates  
	   UPDATE tImportExport SET [Description] = N''When entering transactions in foreign currencies, a default currency rate is pulled from a table in the database. You can manage your own exchange rates under the Admin or System Setup/GL Settings/Currency Rates screen''
	   WHERE ImportExportKey = 63

	   -- 64 Titles  
	   UPDATE tImportExport SET [Description] = N''A service is what is being performed by the user. Think of them as job titles.''
	   WHERE ImportExportKey = 64

	   -- 65 Title Rate Sheets  
	   UPDATE tImportExport SET [Description] = N''Service Rate Sheets allow you to create multiple billing rates for your services. A Service Rate Sheet can be pre-assigned to the client to be used as a default for the clients projects (additional workflow setup required). This can also be used for creating Rush Rates, etc. ''
		WHERE ImportExportKey = 65

	   -- 67 Request Reject Reasons  
	   --UPDATE tImportExport SET 
	 	 --  WHERE ImportExportKey = 67

	   -- 69 Tasks  
	   UPDATE tImportExport SET [Description] = N''Master Tasks are used to create a standard list of tasks that are used on each project. Each master task can have assignments underneath it. On a master task, you can specify default accounting information and description of work performed. Keep in mind that when using master tasks, you can only enter a task once onto the project, so you may need a Review 1, or a Review 2 set of tasks if you commonly repeat certain activities.''
		WHERE ImportExportKey = 69

	   -- 70 Vendors  
	   UPDATE tImportExport SET [Description] = ''The Vendors section within Purchasing is designed to only pull the results of "companies" that are flagged as a vendor, in the company > vendor setup screen.''
		WHERE ImportExportKey = 70

	   -- 71 Clients 
	    UPDATE tImportExport SET [Description] = ''Client refers to the term of a company record that is setup as a client.''
		WHERE ImportExportKey = @ClientKey

	   -- 72 Time  
	   UPDATE tImportExport SET [Description] = N''While the Timesheets section from the main menu navigation will give you access to all of your timesheets entered in the system.  For the API to act on behalf of another person you will need the right "View anyone''''s timesheet" or be an administrator.''
	   WHERE ImportExportKey = @TimeKey

	   -- 73 Project Spec Sheets  
	   UPDATE tImportExport SET [Description] = N''Spec Sheets have a variety of uses, they can be applied to a Project, Project Request, Opportunity, Purchase Order. However they must have a layout defined, this is done by going to Menu > Admin > System Setup > Tracking > Define Spec Sheets.''
		WHERE ImportExportKey = 73

	   -- 74 Request Spec Sheets  
	   UPDATE tImportExport SET [Description] = N''Spec Sheets have a variety of uses, they can be applied to a Project, Project Request, Opportunity, Purchase Order. However they must have a layout defined, this is done by going to Menu > Admin > System Setup > Tracking > Define Spec Sheets.''
		WHERE ImportExportKey = 74

	   -- 75 Labor Budgets  
	   UPDATE tImportExport SET [Description] = ''Labor Budgets allow you to plan the amount of hours and billable dollars your staff will generate during the year. This is helpful for forecasting labor revenue when people may work more than a standard work week. These labor budgets are then used in the Chargeability Reports and Widgets.''
		WHERE ImportExportKey = 75

	   -- 76 Project Request  
	   UPDATE tImportExport SET [Description] = N''Project Requests allow your team and clients to initiate a request for something to be done by your team. You can define multiple Project Request forms, and in addition to our standard fields, you can add Custom Fields to the initial form and link pre-built specification sheets as the additional pages to fill out''
	 	   WHERE ImportExportKey = 76

	   -- 77 Broadcast Orders  
	   UPDATE tImportExport SET Description = ''Broadcast Orders are like Purchase Orders used to place orders to Stations for broadcasting. Broadcast Orders are entered by spots for each ad, either on a weekly, daily or summary basis using the gross amount and a commission percentage to determine the net amount. Broadcast orders also allow you to track user definable dates on each line item of the order.''
	   WHERE ImportExportKey = 77

	   --79 Address
	   UPDATE tImportExport SET Description = ''Address represents the phsyical location of a company''
	   WHERE ImportExportKey = @AddressKey

	   --80 Deliverables
	   UPDATE tImportExport SET Description = N''Digital artwork internally for review before sending to your clients for their comments''
	   WHERE ImportExportKey = @DeliverableKey

	   --100 Opportunties/List
		UPDATE tImportExport SET [Description] = N''The purpose of an Opportunity is to serve as a starting point and a tracing of your project proposal. It allows you to convert to a working project.''
		WHERE ImportExportKey = 100

		--109 Reports
		UPDATE tImportExport SET [Description] = N''The purpose of Reports is to pull data out of workamajig.''
		WHERE ImportExportKey = @ReportKey

		--115 Receipts, - replaceing client payments 1/1/2020
		UPDATE tImportExport SET [Description] = ''When entering a receipt, you are able to apply all, or a portion of the amount, towards open client invoices, a designated sales account or leave as an unapplied amount to be applied towards a future invoice.''
		WHERE ImportExportKey = @ReceiptsKey

		--118 Retainer
		UPDATE tImportExport SET [Description] = ''Client Retainers.''
		WHERE ImportExportKey = @RetainerKey

	--127 Project Staff Rates
	UPDATE tImportExport SET [Description] = N''The purpose of project staff rates is to update the hourly rates per user on a project that has the Get Rate From = Project User to a custom amount.  The PUT is the only method that works with this endpoint because you can only edit, not create staff rates.'' 
	WHERE ImportExportKey = @ProjectStaffRatesKey

		---------------------------------------------------------
		--tImportExportParms
		---------------------------------------------------------
		DELETE From [tImportExportParms]
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''id'', N''Project ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''key'', N''Project Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''projectkey'', N''Project Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''searchFor'', N''search for'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''searchField'', N''search field, including "projectnumber", "projectname", "companyname", "campaignname", "description"'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeTeam'', N''Include project team, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''all'', N''include all details, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeDiary'', N''include diary, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeTodos'', N''include To Do''''s, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeTasks'', N''include Tasks, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeMiscCosts'', N''include Misc Costs, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeEstimates'', N''include Estimates, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeEstimateData'', N''include Estimate Data dataset, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeSpecSheets'', N''include Spec Sheets, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectKey, N''includeSpecSheetData'', N''Project Spec Sheet Data dataset, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (39, N''activityKey'', N''Activity Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (61, N''billingGroupKey'', N''Billing Group Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (10, N''workTypeKey'', N''Billing Item Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (31, N''broadcastItemKey'', N''Broadcast Item Key'')
		--77 broadcast order
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@BOKey, N''searchfor'', N''will search what you enter in PO number, project, or vendor'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@BOKey, N''orderKey'', N''Broadcast Order Key'')

		--33 GL Company
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (33, N''glCompanyKey'', N''GL Company Key'')
		
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (46, N''calendarResourceKey'', N''Calendar Resource Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ClientPaymentsKey, N''checkKey'', N''Check Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ClientPaymentsKey, N''clientID'', N''Client ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ClientKey, N''companyKey'', N''Client Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (37, N''companyKey'', N''Company Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (44, N''companyTypeKey'', N''Company Type Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (1, N''search'', N''search fields: "name", "companyKey", "getFavorites", "getRecents", "dateUpdated"'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (1, N''contactKey'', N''contact Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (49, N''activityTypeKey'', N''Activity Type Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (57, N''voucherKey'', N''Voucher Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (62, N''glAccountKey'', N''GL Account Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@CurrencyRateKey, N''currencyID'', N''Currency ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@CurrencyRateKey, N''startDate'', N''Start Date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@CurrencyRateKey, N''endDate'', N''End Date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (28, N''departmentKey'', N''Department Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (3, N''employeeKey'', N''Employee Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (3, N''showInactive'', N''search Inactive'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (16, N''estimateKey'', N''Estimate Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (4, N''expenseReportItemKey'', N''Expense Report Item Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (22, N''expenseReportKey'', N''Expense Report Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@GLBudget, N''glBudgetKey'', N''GL Budget Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@GLAccountKey, N''glAccountKey'', N''GL Account Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@GLAccountKey, N''glAccountNumber'', N''GL Account Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (54, N''ClassKey'', N''Class Key'')
		
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@IOKey, N''searchfor'', N''will search what you enter in PO number, project, or vendor'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@IOKey, N''purchaseOrderKey'', N''Purchase Order Key'')

		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@InvoiceKey, N''invoiceNumber'', N''Invoice Number'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ItemRateSheetKey, N''itemRateSheetKey'', N''Item Rate Sheet Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (24, N''search'', N''Search'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (24, N''journalEntryKey'', N''Journal Entry Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (75, N''laborBudgetKey'', N''Labor Budget Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (36, N''userLeadKey'', N''User Lead Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (53, N''mediaMarketKey'', N''Media Market Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (23, N''projectNumber'', N''Project Number'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (23, N''miscCostKey'', N''Misc Cost Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (55, N''officeKey'', N''Office Key'')
		--INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (38, N''list'', N''List all opportunities, "type", "range"'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (38, N''opportunityKey'', N''Opportunity Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (38, N''id'', N''Opportunity ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (43, N''opportunityOutcomeKey'', N''Opportunity Outcome Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (41, N''opportunityStageKey'', N''Opportunity Stage Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (42, N''opportunityStatusKey'', N''Opportunity Status Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (50, N''paymentMethodKey'', N''Payment Method Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (7, N''paymentTermsKey'', N''Payment Terms Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (32, N''printItemKey'', N''Print Item Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (29, N''projectBillingKey'', N''Project Billing Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (73, N''specID'', N''Spec Sheet ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (27, N''projectStatusKey'', N''Project Status Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (25, N''projectTypeKey'', N''Project Type Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (5, N''ItemID'', N''Item ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@POKey, N''searchfor'', N''will search what you enter in PO number, project, or vendor'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@POKey, N''purchaseOrderKey'', N''Purchase Order Key'')

		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (40, N''reportGroupKey'', N''Report Group Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectRequestKey, N''requestKey'', N''Request Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (74, N''specID'', N''Request Spec ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (8, N''salesTaxKey'', N''Sales Tax Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ServiceRateSheetKey, N''serviceRateSheetKey'', N''Service Rate Sheet Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (48, N''sourceKey'', N''Source Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (52, N''standardTextKey'', N''Standard Text Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (69, N''projectKey'', N''Project Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (69, N''includeTaskUser'', N''Include Task User, enter true'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (69, N''projectNumber'', N''Project Number'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (69, N''taskKey'', N''Task Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (56, N''teamKey'', N''Team Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (56, N''userId'', N''UserID of a team member'')
		-- 72 time
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''timesheetKey'', N''Timesheet Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''timeKey'', N''Time Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''status'', N''Status valid status include "unsubmitted", "submitted", "rejected", "approved"'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''userKey'', N''User Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''startdate'', N''Start Date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''enddate'', N''End Date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''includeService'', N''Include Service'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeKey, N''includeTime'', N''include Time'')
		--21 timesheet
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (21, N''timesheetKey'', N''Timesheet Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (21, N''status'', N''Status valid status include "unsubmitted", "submitted", "rejected", "approved"'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (21, N''userKey'', N''User Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (21, N''startdate'', N''Start Date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (21, N''enddate'', N''End Date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (21, N''includeService'', N''Include Service, enter 1'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (21, N''includeTime'', N''Include Time, enter 1'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (65, N''titleRateSheetKey'', N''Title Rate Sheet Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (64, N''titleKey'', N''Title Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@VoucherKey, N''voucherKey'', N''Voucher Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@VendorPaymentKey, N''paymentKey'', N''Payment Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (70, N''companyKey'', N''Company Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (51, N''writeOffReasonKey'', N''Write Off Reason Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (5, N''itemID'', N''Purchase Item ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@AddressKey, N''addressKey'', N''Address Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@DeliverableKey, N''deliverableID'', N''Deliverable ID'')
		-- 84 to do
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ToDoKey, N''todokey'', N''To Do Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ToDoKey, N''projectkey'', N''Project Key'')
		--100 opportunities/list
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (100, N''type'', N''types include "byStage", "byLevel" and "byNeglected" '')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (100, N''range'', N''for "byStage", will be stage lead stage key, for "byLevel", 1:Unaware 2:Contemplating   3:Planning  4:Action,<br> for "byNeglected" 1: last 7 days, 2: last 30 days, 3 older than 30 days'')
		--101 activities/search
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (101, N''date'', N''activity date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (101, N''mode'', N''"today","thisweek", "unread", "open", "favorites"'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (101, N''dateupdated'', N''activity date updated'')
		--102 companies/search
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (102, N''text'', N''searches company name, parent company name, vendor ID and client ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (102, N''getFavorites'', N''getFavorites - enter 1 to include your favorites'') 
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (102, N''getRecents'', N''getRecents - enter 1 to include your recents'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (102, N''dateUpdated'', N''dateUpdated'')
		--103 contacts/search
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (103, N''name'', N''name'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (103, N''getFavorites'', N''getFavorites - enter 1 to include your favorites, only use with name, dateupdated or companyKey'') 
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (103, N''getRecents'', N''getRecents - enter 1 to include your recents, only use with name, dateupdated or companyKey'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (103, N''dateUpdated'', N''dateUpdated'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (103, N''companyKey'', N''Company Key'')
		--104 employees/search
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (104, N''name'', N''Name. Can only search for one per request: name, email or userID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (104, N''showInactive'', N''Show Inactive employees'') 
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (104, N''email'', N''employees email. Can only search for one per request: name, email or userID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (104, N''userID'', N''employees UserID. Can only search for one per request: name, email or userID '')
		--105 journalentries/search
		--Not yet implemented
		--106 leads/search
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (106, N''name'', N''lead name'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (106, N''getFavorites'', N''getFavorites - enter 1 to include your favorites, only use with name, dateupdated or companyKey'') 
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (106, N''getRecents'', N''getRecents - enter 1 to include your recents, only use with name, dateupdated or companyKey'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (106, N''dateUpdated'', N''dateUpdated'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (106, N''companyKey'', N''Company Key'')
		--107 timesheets/time
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeSheetTimeKey, N''workdatemin'', N''start date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@TimeSheetTimeKey, N''workdatemax'', N''end date'')
		--108 vendors/search
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (108, N''text'', N''will search company name and vendor ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (108, N''getFavorites'', N''getFavorites - enter 1 to include your favorites'') 
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (108, N''getRecents'', N''getRecents - enter 1 to include your recents'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (108, N''dateUpdated'', N''dateUpdated'')
		--109 Reports
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ReportKey, N''ReportKey'', N''ReportKey, also the API Access Key from setting screen of the view/report'')
		--111 Media Plans
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@MediaPlanKey, N''planID'', N''Plan ID'')
		--112 Media Plan Vouchers
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@MediaPlanVoucherKey, N''vendorID'', N''Vendor ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@MediaPlanVoucherKey, N''invoiceNumber'', N''InvoiceNumber'')
		--115 Receipts
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ReceiptsKey, N''receiptKey'', N''Receipt Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ReceiptsKey, N''clientID'', N''Client ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ReceiptsKey, N''depositID'', N''Deposit ID'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ReceiptsKey, N''referenceNumber'', N''Reference Number'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ReceiptsKey, N''receiptDate'', N''Receipt Date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ReceiptsKey, N''invoiceNumber'', N''Invoice Number'')
		--116 Conversation
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ConversationKey, N''conversationKey'', N''Conversation Key'')
		--118 Retainer
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ConversationKey, N''retainerKey'', N''Retainer Key'')
		--120 PUblication
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@PublicationKey, N''publicationKey'', N''Publication Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@PublicationKey, N''publicationID'', N''Publication ID'')
		--122 Station
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@StationKey, N''stationKey'', N''Station Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@StationKey, N''stationID'', N''Station ID'')

		--124 Campaign
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@CampaignKey, N''campaignKey'', N''Campaign Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@CampaignKey, N''campaignID'', N''Campaign ID'')

		--127 Project Staff Rates
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectStaffRatesKey, N''projectKey'', N''Project Key'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ProjectStaffRatesKey, N''projectNumber'', N''Project Number'')

		--131 Conversations/search
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ConversationSearchKey, N''date'', N''activity date'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ConversationSearchKey, N''mode'', N''"today","thisweek", "unread", "open", "favorites"'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ConversationSearchKey, N''dateupdated'', N''activity date updated'')
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@ConversationSearchKey, N''projectNumber'', N''project number'')

		--135 Billing Schedule
		INSERT [dbo].[tImportExportParms] ([ImportExportKey], [ParameterName], [Description]) VALUES (@BillingScheduleKey, N''billingScheduleKey'', N''Billing Schedule Key'')
exec sptImportExportSamplesSeedDoco

/*
|| 04/28/18		MCM 18.5.0.0 Created when removed doco fields from convert app seed
|| 05/03/18		MCM 18.5.0.0 Adding in Description field values\\

|| 01/24/18     MCM 19.0.2.0 Moving data from convertAppSeed since really belong in different locations
|| 01/25/18     MCM 19.0.0.0 (442119) Added Address Info
|| 02/08/19     MCM 19.0.3.0 (441055) Change name from client payments to client receipts
|| 02/20/19     MCM 19.0.3.0 (444534) Added Exclude 1099 to the credit card charges
|| 03/14/19     MCM 19.0.4.0 (450619) Added estimateLaborTaxable to the clients 
|| 05/16/19     MCM 19.0.6.0 (454943) Added void and get by Client ID for the client payments
|| 05/22/19     RLS 19.0.6.0 (459855) Added UserName to Teams
|| 06/27/19     MCM 19.0.7.0 (467154) Added Opportunity ID to the parmaters
|| 07/08/19     MCM 19.0.8.0 (465477) Added Opportunity ID as input field for Imports and we''ll match on it.
|| 08/15/19     MCM 19.0.9.0 (435391) Added Approved to be a link field on the timesheet import
|| 08/23/19     MCM 19.0.9.0 (475644) Added custom field header info for PO, IO and BO.
|| 09/12/19     MCM 19.1.0.0 (435391) Made workDate a link field for Timesheet
|| 09/19/19     MCM 19.1.0.0 (435391) Removed billing title and department from the timesheet import
|| 09/23/19     MCM 19.1.0.0 (476967) Added deliverable information
|| 09/25/19     GHL 19.1.0.0 Added media plan + media plan voucher doco fields
|| 10/10/19     MCM 19.1.1.0 (481271) Added receipts endpoint and started phasing out client payments
|| 10/21/19     GHL 19.1.1.0 (484211) Removed tMediaPlan.POKind, added tMediaPlanVoucherDetail.LastVoucher
|| 10/28/19     MCM 19.1.1.0 (465486) Added client division and client product to the opportunity import
|| 10/29/19     MCM 19.1.1.0 (468646) Added the Service Description for service rate sheet export
|| 11/04/19     MCM 19.1.2.0 (484799) Fixed spelling of address Name on the address import
|| 11/18/19     MCM 19.1.2.0 (488559) Fixed [DBFieldName] of ''Unit Rate'' to ''UnitRate'' having ImportExportDetailKey of 32001
|| 11/26/19     MCM 20.0.1.0 (489864) Added project status active field
|| 12/02/19     GHL 20.0.1.0 Added media plan release function
|| 12/19/19     RLS 20.0.1.0 (493105) Made NotifyEmail required for ProjectRequest
|| 12/27/19     MCM 20.0.1.0 (492818) Adding the diary endpoint
|| 12/30/19     GHL 20.0.1.0 Made media plans available for import
|| 01/07/20     GAR 20.0.2.0 (488171) Added project manager to the clients and companies imports
|| 01/09/20     GHL 20.0.2.0 Changes to media plans
|| 01/15/20     MCM 20.0.2.0 (496824) Fix the comments line field on the expense report
|| 01/22/20     MCM 20.0.2.0 (49218) Chaning info from diary endpoint to conversation Endpoint
|| 01/24/20     MCM 20.0.2.0 (494033) Updated GL Account comments for none if want to remove subaccount
|| 02/10/20     MCM 20.0.3.0 (501147) Fixed spelling and made @Client
|| 02/13/20     GHL 20.0.3.0 Removed keys for the API media plan updates (we use IDs now)
|| 02/13/20     MCM 20.0.3.0 (501440) Change PO, classKey to classID
|| 02/17/20     GHL 20.0.3.0 Setting MatchRow and Put on media plans/media plan vouchers to use in Update mode
|| 02/21/20     MCM 20.0.3.0 (496256) Adding the project manager to the projects
|| 02/28/20     MCM 20.0.4.0 (504341) Added @timeKey
|| 05/01/20     MCM 20.0.6.0 (501819) Added posted to the Journal Entry to automatically post the entry
|| 06/01/20     MCM 20.0.7.0 (517369) Added skipApprovalProcess to the Project Request update
|| 06/19/20     MCM 20.0.7.0 (518055) Added defaultFFLineFormat to the Client import
|| 06/24/20     MCM 20.0.7.0 (520218) Added info about employee service delimiter a '';''
|| 06/25/20     MCM 20.0.7.0 (519140) Added ''|DeliverableType'' to CustomFieldEntity in order for all custom fields to show up
|| 07/07/20     GHL 20.0.8.0 Added OrderLinkID, InvoiceLinkID, BottomLineInvoice, InvoiceTotal to media plans 
|| 07/14/20     MCM 20.0.8.0 (521779) Updated Opportunity ID desecription.
|| 07/17/20     MCM 20.0.8.0 (522660) Added template and getMarkupFrom as a field for the project import
|| 07/28/20     MCM 20.0.8.0 (479239) Added to do info
|| 07/31/20     MCM 20.0.9.0 (522660) Added Project fields
|| 09/03/20     MCM 20.0.9.0 (528216) Updated task perc comp seperate description to indicate it goes to "Track Actual Dates for Each Person"
|| 09/11/20     MCM 20.1.0.0 (529111) Updated project Rate Sheet from timeRateSheetKey to ratesheet.
|| 10/09/20     MCM 20.1.1.0 (531998) Added Predecessors to the task import
|| 10/23/20     MCM 20.1.1.0 (534675) Added ACHEnabled to the vendor Import
|| 10/26/20     MCM 20.1.1.0 (522683) Added Retainer Import
|| 10/28/20     MCM 20.1.1.0 (531964) Added company owner to vendor, updated field to be company owner on client and company from contactOwner
|| 11/13/20     MCM 20.1.2.0 (536745) Added invoiceExcludeAttachment to contacts
|| 11/16/20     MCM 20.1.2.0 (537251) Added notifyEmails to the ToDo''s
|| 04/07/21     MCM 21.04.18 (554094) Added toDoType to the ToDo''s
|| 04/19/21	    MCM 21.05.16 (551714) Added Stations and Publications
|| 05/27/21	    MCM 21.06.20 (556803) Added Campaigns
|| 06/09/21     MCM 21.07    (561292) Added Project Export Info
|| 06/24/21     MCM 21.07    (562794) Added copy campaign fields
|| 06/28/21     MCM 21.07    (560843) Updated Campaigns so that the segment supports add/update/delete
|| 06/29/21     GHL 21.07    (563439) Cleaned up duplicates/descriptions for currency on vendor invoices 
|| 07/09/21     MCM 21.07    (563565) Added Supervisor Name to the employee import
|| 07/16/21     GHL 21.08    (565228) Added Net Cost (HC) hcTotalCost to Vendor Invoices 
|| 07/16/21     GHL 21.08    (565228) Added Total Amount (HC) hcTotalAmount to Client Invoices 
|| 07/19/21     MCM 21.08    (565174) Added forecastAsFixedFee to project import
|| 07/22/21		MCM 21.08	 (563565) Added Get Campaign by ID
|| 08/12/21     MCM 21.09    (568099) Made the PO Linked fields required
|| 09/29/21		MCM 21.10.17 (571693) added ebitda to the glaccounts
|| 11/19/21		QMD 21.12.19 (577998) changed timesheet verbage
|| 11/23/21     MCM 21.12.19 (578655) added possible values for oneinvoiceper
|| 12/07/21		MCM 21.12.19 (579940) added classID to the invoice header and details
|| 01/10/22     MCM 22.02.   (581894) Added conversations
|| 01/19/22     MCM 22.02.   (583018) Added Vendor Cost to the Employee endpoint
|| 02/01/22		MCM 22.02.	 (585206) Added RequireMinHoursPerWeek MinHoursPerWeek to employee import
|| 02/15/22		MCM 22.03.x  (587517) added includeSpecSheets to the parameters
|| 02/21/22     MCM 22.03.   (588899) Added ACHRececipts and CCReceipts for the client import
|| 03/07/22     MCM 22.03.x  (585814) Added Estimate Data and Project Spec Sheet Data to the project parameters
|| 03/28/22     MCM 22.04.x  (589336) Added doNotUseSSO (screen calls is Do Not use SAML/SSO Authentication) to contact 
|| 03/30/22     MCM 22.04.17 (593606) Added clientCampaignNumber to the Campaign
|| 03/30/22     MCM 22.04.x  (593664) Added doNotUseSSO (screen calls is Do Not use SAML/SSO Authentication) to contact 
|| 05/25/22     GHL 22.06.x  (451878) Added glcExchangeRate for client and vendor invoices
|| 06/21/22     RLS 22.07.x  (603837) Added CopyCampaignFiles to the campaigns section
|| 07/07/22     QMD 22.07.24 (602949) Added userId to the Team endpoint
|| 07/11/22     MCM 22.08.x  (595350) Added GLCompanies to the vendor 
|| 07/26/22		MCM 22.08.x  (606848) Removed action from the task import. It was for assignments and causes confustion.
|| 07/22/22     GHL 22.08.00 (604153) Added tTime.Overtime
|| 08/10/22	    MCM 22.09.x  (606828) Updated Voucher to include custom fields on both header and detail
|| 08/10/22	    RLB 22.09.x  (607677) added tVendor.EmailACHToAddress
|| 09/08/22     RLB 22.10.x  (611239) Added Subject to project spec sheet import section
|| 09/21/22     MCM 22.10.x  (612989) Adding class ID Line back into the voucher.  Accidently got removed
|| 09/21/22     RLB 22.10.x  (611076) added Vendor Overtime Cost and Overtime Cost
|| 09/21/22     RLB 22.11.x  (607483) added Contractor to employee import
|| 10/11/22     MCM 22.11.x  (613579) Updated Credit card charge fields to allow for multiple details (expenses and vouchers)
|| 11/07/22     MCM 22.12.x  (618337) updated description to descriptionLine when have to map
|| 11/17/22     MCM 22.12.x  (619769) updated the linked fields (Reference Number in credit card charges and Check Number in vendor payment) to be required as well.
|| 11/30/22     MCM 22.12.x  (613579) Added office line for the credit card charges
|| 12/05/22     MCM 22.12.x  (622066) Removed the reference number as a required field.  The vb will fill on in if none passed in.
|| 01/06/23		MCM 23.02.x  (621970) Added Primary contact and billing contact to client/company
|| 01/30/23     MCM 23.02.x  (628296) Added update ability to vendor payment and receipts
|| 02/14/23     GAR 23.04.x  (DEV2605-MAIN) Added export for Avalara Tax Codes
|| 04/04/23     MCM 23.05.x  (636756) Added bank account type to the vendor import
|| 05/24/23     CRG 23.06.18 (604775) Added documentation for new Task Priority values
|| 06/02/23		MCM 23.06.18 (639431) Added new Credit Card charge fields for multicurrency fields
|| 07/17/23		MCM 23.08.x  (643701) Added long description to the estimate import
|| 08/21/23     MCM 23.09.x  (643543) Added Predecessor Lag field to the task Import
|| 09/07/23     MCM 23.10.x  (649355) Changed name on voucher from Department to "Department (Line)"
|| 10/31/23     RLB 23.11.19 (654959) added missing parms for graph import
|| 11/08/23		MCM 23.12.x  (655841) Added MustFinishOnPredComplete to the Task
*/





END



'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spInitCountLoad]'
GO
IF OBJECT_ID(N'[dbo].[spInitCountLoad]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[spInitCountLoad]
	@List varchar(100),
	@CompanyKey int,
	@UserKey int

AS --Encrypt

/*
|| When       Who Rel		What
|| 02/26/16   RLB 10.601	Created to get all the company counts that maybe needed in Platinum.
|| 03/09/16   GHL 10.602	Added tCompanyMedia and tMediaEstimate
|| 09/11/17   WDF 10.620	(360824) Added tGLCompanyMap 
|| 10/17/19   GWG 10.110	Added tDeliverableType
|| 06/21/23   MAS 23.07.16	Removed Old Media tables
|| 09/09/25   MAS 25.00.00	Added tPromptUsage default to 1000000 token
*/


DECLARE	@SecurityGroupKey int
DECLARE @RestrictToGLCompany int
DECLARE @Administrator int
DECLARE @CurrentCount int

IF @List = ''tUserGLCompanyAccess''
BEGIN
	SELECT COUNT(*) as SelectedCount 
	FROM tUserGLCompanyAccess (nolock) 
	WHERE UserKey = @UserKey 
		 
END

IF @List = ''tItem''
BEGIN
	SELECT COUNT(*) as SelectedCount		
	FROM tItem i(nolock) 
	WHERE i.CompanyKey = @CompanyKey	
	RETURN
END

IF @List = ''tItemPC''
BEGIN
	SELECT COUNT(*) as SelectedCount		
	FROM tItem i(nolock) 
	WHERE i.CompanyKey = @CompanyKey
	and i.ItemType = 0		
	RETURN
END

IF @List = ''tItemPO''
BEGIN
	SELECT COUNT(*) as SelectedCount		
	FROM tItem i(nolock) 
	WHERE i.CompanyKey = @CompanyKey
	and i.ItemType = 1		
	RETURN
END

IF @List = ''tItemBO''
BEGIN
	SELECT COUNT(*) as SelectedCount		
	FROM tItem i(nolock) 
	WHERE i.CompanyKey = @CompanyKey
	and i.ItemType = 2		
	RETURN
END

IF @List = ''tItemER''
BEGIN
	SELECT COUNT(*) as SelectedCount		
	FROM tItem i(nolock) 
	WHERE i.CompanyKey = @CompanyKey
	and i.ItemType = 3		
	RETURN
END

IF @List = ''tService''
BEGIN

	SELECT COUNT(*) as SelectedCount	
	FROM tService (nolock) 		
	WHERE tService.CompanyKey = @CompanyKey 	
	RETURN
END

Declare @ServiceMode int
IF @List = ''tUserService''
BEGIN
	Select @SecurityGroupKey = SecurityGroupKey from tUser (nolock) Where UserKey = @UserKey
	if exists(Select null from tRight r (nolock) 
		inner join tRightAssigned ra (nolock) on r.RightKey = ra.RightKey
		Where r.RightID = ''timeallservices'' and EntityKey = @SecurityGroupKey)
		Select @ServiceMode = 1
	else
		Select @ServiceMode = 0

	if @ServiceMode = 1
		SELECT COUNT(*) as SelectedCount				
		FROM tService (nolock) 
		WHERE CompanyKey = @CompanyKey 			
	else
		SELECT COUNT(*) as SelectedCount				
		FROM tService s (nolock) 
		inner join tUserService us (nolock) on s.ServiceKey = us.ServiceKey
		WHERE CompanyKey = @CompanyKey and us.UserKey = @UserKey
	RETURN
END

IF @List = ''tTimeRateSheet''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tTimeRateSheet (nolock) 
	WHERE CompanyKey = @CompanyKey 		
	RETURN
END

IF @List = ''tTimeRateSheetDetail''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tTimeRateSheetDetail tsd (nolock) 
	inner join tTimeRateSheet ts (nolock) on tsd.TimeRateSheetKey = ts.TimeRateSheetKey
	WHERE CompanyKey = @CompanyKey

	RETURN
END

IF @List = ''tGLAccount''
BEGIN
	Select COUNT(*) as SelectedCount
	FROM tGLAccount (nolock)  			
	Where tGLAccount.CompanyKey = @CompanyKey
	AND   (isnull(tGLAccount.RestrictToGLCompany, 0) = 0
			Or 
			tGLAccount.GLAccountKey in (
                    select glca.EntityKey 
					from tGLCompanyAccess glca (nolock) 
						inner join tUserGLCompanyAccess uglca (nolock) on glca.GLCompanyKey = uglca.GLCompanyKey
					where glca.Entity = ''tGLAccount''
					and  uglca.UserKey = @UserKey
					)
			)
			
	RETURN
END


IF @List = ''tClass''
BEGIN
	SELECT COUNT(*) as SelectedCount 
	FROM tClass (nolock) 
	WHERE tClass.CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tOffice''
BEGIN
	SELECT COUNT(*) as SelectedCount		 
	FROM tOffice (nolock) 
	WHERE CompanyKey = @CompanyKey 

	RETURN
END

IF @List = ''tDepartment''
BEGIN
	SELECT COUNT(*) as SelectedCount 
	from tDepartment (nolock) 
	Where CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tGLCompany''
BEGIN
	declare @Admin int
	Select @Admin = ISNULL(Administrator, 0) from tUser (nolock) Where UserKey = @UserKey
	IF Exists(Select 1 from tPreference (nolock) Where CompanyKey = @CompanyKey and ISNULL(RestrictToGLCompany, 0) = 1) and @Admin = 0
	BEGIN
		-- add in a restriction layer if the person is not allowed to access a particular company
		SELECT COUNT(*) as SelectedCount
		FROM tGLCompany glc (nolock) 
		inner join tUserGLCompanyAccess glca (nolock) on glc.GLCompanyKey = glca.GLCompanyKey
		WHERE glc.CompanyKey = @CompanyKey and glca.UserKey = @UserKey
	END
	ELSE
	BEGIN
		SELECT COUNT(*) as SelectedCount
		FROM tGLCompany glc (nolock) 
		WHERE glc.CompanyKey = @CompanyKey 
	END
	RETURN
END

IF @List = ''tGLCompanyMap''
BEGIN
	SELECT COUNT(*) as SelectedCount 
	from tGLCompany glc (nolock) 
	inner join tGLCompanyMap glm (nolock) on glc.GLCompanyKey = glm.TargetGLCompanyKey
	LEFT JOIN tGLAccount gla (nolock) ON glc.BankAccountKey = gla.GLAccountKey
	Where glc.CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tProjectStatus''
BEGIN
	SELECT COUNT(*) as SelectedCount
	from	tProjectStatus (nolock) 
	WHERE CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tProjectBillingStatus''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tProjectBillingStatus (nolock) 
	WHERE CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tProjectType''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tProjectType (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tWorkType''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tWorkType (nolock)		
	WHERE tWorkType.CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tTaskAssignmentType''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tTaskAssignmentType (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tMasterTask''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tMasterTask (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END


IF @List = ''tVendor''
BEGIN

	BEGIN
		Select @RestrictToGLCompany = isnull(RestrictToGLCompany, 0) from tPreference (nolock) where CompanyKey = @CompanyKey

		SELECT COUNT(*) as SelectedCount 			
		FROM tCompany (nolock) 
		WHERE OwnerCompanyKey = @CompanyKey 
		AND Vendor = 1
		AND (
			@RestrictToGLCompany = 0
			Or 
			CompanyKey in (
                           select glca.EntityKey 
						   from tGLCompanyAccess glca (nolock) 
								inner join tUserGLCompanyAccess uglca (nolock) on glca.GLCompanyKey = uglca.GLCompanyKey
							where glca.Entity = ''tCompany''
							and   uglca.UserKey = @UserKey
						  )
			)
	END

	RETURN
END

IF @List = ''tClient''
BEGIN
	BEGIN
		Select @RestrictToGLCompany = isnull(RestrictToGLCompany, 0) from tPreference (nolock) where CompanyKey = @CompanyKey

		SELECT COUNT(*) as SelectedCount 
		FROM tCompany (nolock) 
		WHERE OwnerCompanyKey = @CompanyKey 
		AND BillableClient = 1
		AND (
			@RestrictToGLCompany = 0
			Or 
			CompanyKey in (
                           select glca.EntityKey 
						   from tGLCompanyAccess glca (nolock) 
								inner join tUserGLCompanyAccess uglca (nolock) on glca.GLCompanyKey = uglca.GLCompanyKey
							where glca.Entity = ''tCompany''
							and   uglca.UserKey = @UserKey
						  )
			)

	END

	RETURN
END

IF @List = ''tClientDivision''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tClientDivision (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tClientProduct''
BEGIN
	SELECT COUNT(*) as SelectedCount
	from tClientProduct (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tSecurityGroup''
BEGIN
	SELECT COUNT(*) as SelectedCount 
	FROM tSecurityGroup (nolock) 
	WHERE CompanyKey = @CompanyKey 
	RETURN
END


IF @List = ''tCampaign''
BEGIN
	SELECT COUNT(*) as SelectedCount			
	FROM tCampaign (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tLaborBudget''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tLaborBudget (nolock)
	WHERE	CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tLeadOutcome''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tLeadOutcome (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tLeadStage''
BEGIN
	SELECT COUNT(*) as SelectedCount
	from tLeadStage (nolock)
	where CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tLeadStatus''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tLeadStatus (nolock)
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tCompanyType''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tCompanyType (nolock)
	WHERE	CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tPaymentTerms''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tPaymentTerms (NOLOCK) 
	WHERE	CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tCheckMethod''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tCheckMethod (nolock)
	WHERE	CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tRequestDef''
BEGIN
	SELECT COUNT(*) as SelectedCount		
	FROM tRequestDef (NOLOCK) 
	WHERE 	CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tPurchaseOrderType''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tPurchaseOrderType (NOLOCK) 
	WHERE CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tStandardText''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tStandardText (NOLOCK) 
	WHERE	CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tItemRateSheet''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tItemRateSheet rs (nolock)
	WHERE	rs.CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tItemRateSheetDetail''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tItemRateSheetDetail rsd (nolock)
	INNER JOIN tItemRateSheet rs (nolock) ON rsd.ItemRateSheetKey = rs.ItemRateSheetKey
	WHERE	rs.CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tCalendarType''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tCalendarType (nolock) 
	WHERE CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tSkill''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tSkill (NOLOCK) 
	WHERE	CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tSkillSpecialty''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tSkillSpecialty (NOLOCK) 
	inner join tSkill (NOLOCK) on tSkill.SkillKey = tSkillSpecialty.SkillKey
	WHERE	tSkill.CompanyKey = @CompanyKey
	RETURN
END


IF @List = ''tUserSkill''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tUserSkill us (nolock)
	Inner Join tSkill s (nolock) on us.SkillKey = s.SkillKey
	WHERE s.CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tUserSkillSpecialty''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM tUserSkillSpecialty us (nolock)
	inner join tSkillSpecialty ss (nolock) on us.SkillSpecialtyKey = ss.SkillSpecialtyKey
	Inner Join tSkill s (nolock) on ss.SkillKey = s.SkillKey
	WHERE s.CompanyKey = @CompanyKey
	RETURN
END


IF @List = ''tTeam''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tTeam (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END	


IF @List = ''tMarketingList''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tMarketingList (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END	


IF @List = ''tSyncFolder''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tSyncFolder (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END					



IF @List = ''tCMFolderContact''
BEGIN
	Select @SecurityGroupKey = SecurityGroupKey from tUser (nolock) Where UserKey = @UserKey
	BEGIN
		SELECT	@CurrentCount = COUNT(*) 		
				FROM	tCMFolder f (NOLOCK)
				LEFT JOIN tCMFolderIncludeInSync iis (nolock) ON f.CMFolderKey = iis.CMFolderKey AND iis.UserKey = @UserKey
				WHERE	f.Entity = ''tUser''
				AND		f.CompanyKey = @CompanyKey
				AND		f.UserKey = @UserKey
		SELECT	@CurrentCount = COUNT(*) + @CurrentCount 
				FROM	tCMFolder f (NOLOCK)
				left outer join (Select * from tCMFolderSecurity (nolock) 
					Where Entity = ''tSecurityGroup'' and EntityKey =  @SecurityGroupKey) as securityGroup 
						on f.CMFolderKey = securityGroup.CMFolderKey
				left outer join (Select * from tCMFolderSecurity (nolock) Where Entity = ''tUser'' and EntityKey = @UserKey) as securityUser
					on f.CMFolderKey = securityUser.CMFolderKey
				LEFT JOIN tSyncFolder sf (nolock) ON f.SyncFolderKey = sf.SyncFolderKey
				LEFT JOIN tSyncFolder sfg (nolock) ON f.GoogleSyncFolderKey = sfg.SyncFolderKey
				LEFT JOIN tCMFolderIncludeInSync iis (nolock) ON f.CMFolderKey = iis.CMFolderKey AND iis.UserKey = @UserKey
				WHERE	f.Entity = ''tUser'' 
				AND		f.CompanyKey = @CompanyKey
				AND		f.UserKey = 0
		SELECT @CurrentCount as SelectedCount
	END
END



IF @List = ''tCMFolderCompany''
BEGIN
	Select @SecurityGroupKey = SecurityGroupKey from tUser (nolock) Where UserKey = @UserKey
	
	SELECT	COUNT(*) as SelectedCount
	FROM	tCMFolder f (NOLOCK)
			left outer join (Select * from tCMFolderSecurity (nolock) 
			Where Entity = ''tSecurityGroup'' and EntityKey = @SecurityGroupKey) as securityGroup 
				on f.CMFolderKey = securityGroup.CMFolderKey
			left outer join (Select * from tCMFolderSecurity (nolock) Where Entity = ''tUser'' and EntityKey = @UserKey) as securityUser
				on f.CMFolderKey = securityUser.CMFolderKey
	WHERE	f.Entity = ''tCompany'' and CompanyKey = @CompanyKey
END	


IF @List = ''tCMFolderLead''
BEGIN
	Select @SecurityGroupKey = SecurityGroupKey from tUser (nolock) Where UserKey = @UserKey
	
	SELECT	COUNT(*) as SelectedCount
	FROM	tCMFolder f (NOLOCK)
			left outer join (Select * from tCMFolderSecurity (nolock) 
			Where Entity = ''tSecurityGroup'' and EntityKey = @SecurityGroupKey) as securityGroup 
				on f.CMFolderKey = securityGroup.CMFolderKey
			left outer join (Select * from tCMFolderSecurity (nolock) Where Entity = ''tUser'' and EntityKey = @UserKey) as securityUser
				on f.CMFolderKey = securityUser.CMFolderKey
	WHERE	f.Entity = ''tUserLead'' and CompanyKey = @CompanyKey
END	

IF @List = ''tCMFolderOpportunity''
BEGIN
	Select @SecurityGroupKey = SecurityGroupKey from tUser (nolock) Where UserKey = @UserKey

	SELECT	COUNT(*) as SelectedCount
	FROM	tCMFolder f (NOLOCK)
			left outer join (Select * from tCMFolderSecurity (nolock) 
			Where Entity = ''tSecurityGroup'' and EntityKey = @SecurityGroupKey) as securityGroup 
				on f.CMFolderKey = securityGroup.CMFolderKey
			left outer join (Select * from tCMFolderSecurity (nolock) Where Entity = ''tUser'' and EntityKey = @UserKey) as securityUser
				on f.CMFolderKey = securityUser.CMFolderKey
	WHERE	f.Entity = ''tLead'' and CompanyKey = @CompanyKey
END	


IF @List = ''tCMFolderActivity''
BEGIN
	Select @SecurityGroupKey = SecurityGroupKey from tUser (nolock) Where UserKey = @UserKey

	SELECT	COUNT(*) as SelectedCount
	FROM	tCMFolder f (NOLOCK)
			left outer join (Select * from tCMFolderSecurity (nolock) Where Entity = ''tSecurityGroup'' and EntityKey = @SecurityGroupKey) as securityGroup 
				on f.CMFolderKey = securityGroup.CMFolderKey
			left outer join (Select * from tCMFolderSecurity (nolock) Where Entity = ''tUser'' and EntityKey = @UserKey) as securityUser
				on f.CMFolderKey = securityUser.CMFolderKey
	WHERE	f.Entity = ''tActivity'' and CompanyKey = @CompanyKey
			AND (UserKey = 0 or UserKey = @UserKey)
END	


IF @List = ''tSource''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tSource (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END	

IF @List = ''tUserRole''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tUserRole (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END	

IF @List = ''tDistributionGroup''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tDistributionGroup (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
	AND		(ISNULL(Personal, 0) = 0 OR UserKey = @UserKey)
END

IF @List = ''tCalendarResource''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tCalendarResource (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END


IF @List = ''tSalesTax''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tSalesTax st (NOLOCK)
	WHERE	st.CompanyKey = @CompanyKey
END	

IF @List = ''tInvoiceTemplate''
BEGIN
 SELECT COUNT(*) as SelectedCount
 FROM tInvoiceTemplate (NOLOCK)
 WHERE CompanyKey = @CompanyKey
END

IF @List = ''tEstimateTemplate''
BEGIN
	SELECT COUNT(*) as SelectedCount
	FROM	tEstimateTemplate (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END

IF @List = ''tActivityType''
BEGIN
	SELECT	COUNT(*) as SelectedCount
	FROM	tActivityType a (NOLOCK) 
	WHERE	a.CompanyKey = @CompanyKey and Active = 1
END

IF @List = ''tMediaMarket''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tMediaMarket (NOLOCK) 
	WHERE	tMediaMarket.CompanyKey = @CompanyKey
END

IF @List = ''tMediaEstimate''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tMediaEstimate (NOLOCK) 
	WHERE	tMediaEstimate.CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tMediaRevisionReason''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tMediaRevisionReason (NOLOCK) 
	WHERE	tMediaRevisionReason.CompanyKey = @CompanyKey
END

IF @List = ''tWriteOffReason''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tWriteOffReason (NOLOCK) 
	WHERE	tWriteOffReason.CompanyKey = @CompanyKey
END

IF @List = ''tRequestRejectReason''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tRequestRejectReason (NOLOCK) 
	WHERE	tRequestRejectReason.CompanyKey = @CompanyKey
END

IF @List = ''tEstimate''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tEstimate (NOLOCK) 
	WHERE	tEstimate.CompanyKey = @CompanyKey
	AND     tEstimate.ProjectKey IS NULL
	AND     tEstimate.CampaignKey IS NULL
	AND     tEstimate.LeadKey IS NULL
END

IF @List = ''POLineType''
BEGIN
  SELECT Count(*) as SelectedCount
  FROM tFieldSet (NOLOCK)
  WHERE OwnerEntityKey = @CompanyKey 
  AND AssociatedEntity = ''PO_Detail''
END

IF @List = ''tLayout''
BEGIN
	SELECT Count(*) as SelectedCount
	FROM tLayout (NOLOCK) 
	WHERE CompanyKey = @CompanyKey 
END

IF @List = ''tTimelineSegment''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tTimelineSegment (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
END

IF @List = ''tCheckFormat''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tCheckFormat (nolock)
	WHERE	CompanyKey = @CompanyKey
END

IF @List = ''ProjectTemplates''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tProject (nolock)
	WHERE	CompanyKey = @CompanyKey
	AND		Template = 1
END

IF @List = ''tFlatFile''
BEGIN
	SELECT Count(*) as SelectedCount
	FROM tFlatFile (nolock)
	WHERE CompanyKey = @CompanyKey
END

IF @List = ''tPublishCalendar''
BEGIN
	SELECT	@SecurityGroupKey = SecurityGroupKey,
			@Administrator = Administrator
	FROM	tUser (nolock)
	WHERE	UserKey = @UserKey

	SELECT	Count(*) as SelectedCount
	FROM	tPublishCalendar (nolock)
	WHERE	CompanyKey = @CompanyKey
	AND		(	@Administrator = 1
			OR	
				PublishCalendarKey IN (SELECT PublishCalendarKey FROM tPublishCalendarSecurity (nolock) WHERE SecurityGroupKey = @SecurityGroupKey)
			)
END

IF @List = ''tColumnSet''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tColumnSet (nolock)
	WHERE	CompanyKey = @CompanyKey
END

IF @List = ''tBillingGroup''
BEGIN
	select Count(*) as SelectedCount
	from tBillingGroup (nolock) 
	Where tBillingGroup.CompanyKey = @CompanyKey 	
	RETURN
END


IF @List = ''tCompanyMedia''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tCompanyMedia (NOLOCK)
	WHERE	CompanyKey = @CompanyKey
	RETURN
END

IF @List = ''tTitle''
BEGIN
	SELECT	Count(*) as SelectedCount
	FROM	tTitle (nolock) 
	WHERE	tTitle.CompanyKey = @CompanyKey
END

IF @List = ''tTitleRateSheet''
BEGIN	
	SELECT Count(*) as SelectedCount
	FROM tTitleRateSheet (nolock) 
	WHERE CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tTitleRateSheetDetail''
BEGIN
	select Count(*) as SelectedCount
	from tTitleRateSheetDetail tsd (nolock) 
	inner join tTitleRateSheet ts (nolock) on tsd.TitleRateSheetKey = ts.TitleRateSheetKey
	Where CompanyKey = @CompanyKey 
	RETURN
END

IF @List = ''tGLBudget''
	SELECT Count(*) as SelectedCount
	FROM tGLBudget
	WHERE CompanyKey = @CompanyKey


IF @List = ''tDeliverableType''
	SELECT Count(*) as SelectedCount
	FROM tDeliverableType
	WHERE CompanyKey = @CompanyKey

IF @List = ''tPromptUsage''
BEGIN
    DECLARE @YearMonth AS CHAR(7) = CONVERT(CHAR(7), GETDATE(), 120);

    SELECT TOP 1 
        ISNULL(p.AITokenLimit, 1000000) - ISNULL(pu.TotalCount, 0) AS SelectedCount
    FROM tPreference p WITH (NOLOCK)
    LEFT JOIN tPromptUsage pu WITH (NOLOCK)
        ON p.CompanyKey = pu.CompanyKey
        AND pu.YearMonth = @YearMonth
    WHERE p.CompanyKey = @CompanyKey;

	RETURN
END

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskUserRollupPercCompOnly]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskUserRollupPercCompOnly]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROC [dbo].[sptTaskUserRollupPercCompOnly]
	@TaskKey int
AS
/*
|| When     Who Rel    What
|| 07/22/21 CRG 21.08.15 (560277) Created to ensure that the perc complete is rolled up to the task properly
|| 08/09/21 CRG 21.08.15 (565222) Now returning out of SP if there are no assignments to avoid clearing the perc comp value on the task
|| 06/02/26 CRG 26.07.19 (729772) Removing the time portion from ActStart, ActComplete
*/

	DECLARE	@ScheduleTask tinyint,
			@TaskType int,
			@PercCompSeparate tinyint

	SELECT	@ScheduleTask = ScheduleTask,
			@TaskType = TaskType,
			@PercCompSeparate = PercCompSeparate
	FROM	tTask (nolock)
	WHERE	TaskKey = @TaskKey

	IF @ScheduleTask <> 1 OR @TaskType <> 2 OR @PercCompSeparate <> 1
		RETURN

	DECLARE	@TotalHours decimal(24, 4),
			@TotalHoursComp decimal(24, 4),
			@PercComp int,
			@ActStart as smalldatetime,
			@ActComplete as smalldatetime,
			@UserCount int,
			@ActCompleteCount int 

	SELECT @UserCount = COUNT(*) FROM tTaskUser (NOLOCK) WHERE TaskKey = @TaskKey

	IF @UserCount = 0
	BEGIN
		--If no assignments, just return
		SELECT	PercComp, ActStart, ActComplete, TotalAllocatedHours
		FROM	tTask (nolock)
		WHERE	TaskKey = @TaskKey

		RETURN
	END

	SELECT	@ActStart = dbo.fFormatDateNoTime(MIN(ActStart))
	FROM	tTaskUser (nolock)
	WHERE	TaskKey = @TaskKey
	AND		ActStart is not null

	SELECT @TotalHours = (SELECT 
							SUM(CASE 
									WHEN Hours IS NULL THEN 1
									WHEN Hours = 0 THEN 1
									ELSE Hours
								END) 
						FROM	tTaskUser (nolock)
						WHERE	TaskKey = @TaskKey)

	IF @TotalHours = 0 OR @TotalHours IS NULL
		SELECT @TotalHours = 1

	SELECT @TotalHoursComp = ISNULL((SELECT
										SUM((ISNULL(PercComp,0)) *
											 CASE WHEN Hours IS NULL THEN 1
												  WHEN Hours = 0 THEN 1
												  ELSE Hours
											 END)
									FROM	tTaskUser (nolock)
									WHERE	TaskKey = @TaskKey), 0)
	
	SELECT @PercComp = @TotalHoursComp / @TotalHours
		
	IF @PercComp < 0 
		SELECT @PercComp = 0
	IF @PercComp > 100
		SELECT @PercComp = 100

	SELECT	@ActCompleteCount = COUNT(*)
	FROM	tTaskUser (nolock)
	WHERE	TaskKey = @TaskKey
	AND		ActComplete is not null

	-- if PercComp or all have finished
	IF (@PercComp = 100 OR @ActCompleteCount = @UserCount) 
		SELECT	@ActComplete = dbo.fFormatDateNoTime(MAX(ActComplete))
		FROM	tTaskUser (nolock)
		WHERE	TaskKey = @TaskKey

	-- cannot leave PercComp <> 100 if we have ActComplete
	IF	@ActComplete IS NOT NULL
		SELECT @PercComp = 100
	
	-- rollup Actuals to task level	
	UPDATE	tTask
	SET		PercComp = ISNULL(@PercComp, 0),
			ActStart = @ActStart,
			ActComplete = @ActComplete,
			TotalAllocatedHours = @TotalHours
	WHERE	TaskKey = @TaskKey

	SELECT	@PercComp AS PercComp, @ActStart AS ActStart, @ActComplete AS ActComplete, @TotalHours AS TotalAllocatedHours'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spMassBillingBillAdvance]'
GO
IF OBJECT_ID(N'[dbo].[spMassBillingBillAdvance]', 'P') IS NOT NULL
EXEC sp_executesql N'

ALTER PROCEDURE [dbo].[spMassBillingBillAdvance]
	(
	@CompanyKey int
	,@UserKey int
	,@InvoiceBy int -- 0 By Project, 1 By Client, 2 By Client Parent
	,@BillingStatusKey int
	,@InvoiceDate smalldatetime
	,@PostingDate smalldatetime
	,@DefaultUIClassKey INT = NULL	-- This is already validated on the screen
	,@DefaultUIOfficeKey INT = NULL	-- This is already validated on the screen
	,@CreateAsApproved INT = 0
	)

	as --Encrypt

 /*
  || When     Who Rel     What
  || 03/03/16 GHL 10.602  Creation for new mass billing
  ||                      For projects with billing schedule, we need to create an advance bill 
  || 07/21/16 GHL 10.606 Added action logging for MN''s ToDo 
  || 10/02/17 GHL 10.621 (363756) Added default AR account from client
  || 11/15/18 GHL 18.893 (431436) Added logic for Dollar Amount on the billing schedule
  || 01/07/19 GHL 19.100 (438663) Make sure that #project.GLCompanyKey = 0 instead of null to work correctly in the loops
  || 01/27/20 GHL 20.030 (495024) Get the invoice template from the GL company if tPreference.LayoutFromGLCompany = 1
  || 06/10/21 GHL 21.060 Fixed bad join when updating tProject.ProjectBillingStatusKey
  || 03/18/22 GHL 22.040 (590582) Added support for tProject.SetTaxableOnInvoice
  || 01/09/25 MFT 25.010 (691628) Override LayoutKey defaulting to the Client when billing by Project
  || 11/04/25 MCM 25.11.x (656423) Added Liability Account Key when calling sptInvoiceInsert
  || 04/21/26 AMP 26.05.17 (718171) Added a check for Advance Bill -> Use Advance Bill Prefix set on preferences
  || 06/25/26 GAR 26.07.19 (729634) Added Comments from the billing schedule to the header comment of the invoice
 */

 /*
 Assume done and filled in vb

 create table #proj (ProjectKey int null, BillingScheduleKey int null)
 */


 create table #project (ProjectKey int null, BillingScheduleKey int null, BudgetAmount money null, BillAmount money null, TaskKey int null
	, ParentClientKey int null, ClientKey int null, LoopClientKey int null, GLCompanyKey int null, CurrencyID varchar(10) null, CurrencyKey int null)

 insert #project (ProjectKey, BillingScheduleKey, CurrencyKey)
 select ProjectKey, BillingScheduleKey, 0
 from   #proj

 update #project
 set    #project.BudgetAmount = ISNULL(p.EstLabor, 0) + ISNULL(ApprovedCOLabor, 0) + ISNULL(EstExpenses, 0) + ISNULL(ApprovedCOExpense, 0) 
       ,#project.ClientKey = p.ClientKey
	   ,#project.GLCompanyKey = isnull(p.GLCompanyKey, 0) -- not NULL for the loops
	   ,#project.CurrencyID = p.CurrencyID
 from   tProject p (nolock)
 where  p.ProjectKey = #project.ProjectKey

update #project
 set   #project.BillAmount = case when bs.PercentBudget is null then bs.DollarAmount else round((#project.BudgetAmount * bs.PercentBudget )/100.00, 2) end
      ,#project.TaskKey = bs.TaskKey
from   tBillingSchedule bs (nolock)
where  #project.BillingScheduleKey = bs.BillingScheduleKey

update #project
set    #project.ParentClientKey = c.ParentCompanyKey
from   tCompany c (nolock)
where  #project.ClientKey = c.CompanyKey 
  
If @InvoiceBy in (0, 1)
begin
	-- by project / client
	update #project
	set    LoopClientKey = ClientKey 
end

If @InvoiceBy = 2
begin
	-- by parent client
	update #project
	set    LoopClientKey = ParentClientKey

	update #project
	set    LoopClientKey = ClientKey
	where  isnull(LoopClientKey, 0) = 0 
end

-- cannot bill without a client
delete #project
where  isnull(LoopClientKey, 0) = 0 

declare @ProjectKey int
declare @GLCompanyKey int
declare @ClientKey int
declare @CurrencyID varchar(10)
declare @CurrencyKey int
declare @BillingScheduleKey int
declare @NewInvoiceKey int
declare @NewInvoiceLineKey int
declare @BillingContact varchar(100)
declare @PrimaryContactKey int 
declare @DefaultSalesAccountKey int
declare @RetVal int
declare @TodaysDate smalldatetime
declare @DueDate smalldatetime
declare @DueDays int
declare @LineSubject varchar(100)
declare @WorkTypeKey int
Declare @ARAccountKey int 
Declare @SalesGLAccountKey int 
Declare @InvoiceTemplateKey int
Declare @LayoutKey int
Declare @BillingAddressKey int
declare @CampaignKey int
declare @OfficeKey int
declare @ClassKey int
declare @BillAmount money
declare @TaskKey int
Declare @SalesTaxKey int, @SalesTax2Key int, @PaymentTermsKey int
declare @SetTaxableOnInvoice int

declare @NextTranNo varchar(100)
declare @InvoiceStatus int
declare @ApprovedByKey int

Declare @RequireClasses tinyint
declare @DefaultClassKey int
declare @DefaultARAccountKey int
declare @DefaultAdvBillAccountKey int
declare @DefaultPaymentTermsKey int
declare @PostSalesUsingDetail tinyint
declare @LayoutFromGLCompany int
declare @AdvBillAccountKey int
declare @LiabilityAccountKey int
declare @AdvanceBill tinyint

declare @HeaderComment varchar(4000)

-- Variables for logging 
declare	@Entity varchar(50),
		@EntityKey int,
		@Action varchar(200),
		@ActionDate smalldatetime,
		@ActionBy varchar(500),
		@Comments varchar(4000),
		@Reference varchar(200),
		@SourceCompanyID varchar(100),
		@LogCampaignKey int
	
	-- get company preferences
	Select @PostSalesUsingDetail  = ISNULL(PostSalesUsingDetail, 0)
			,@DefaultARAccountKey = DefaultARAccountKey
			,@DefaultAdvBillAccountKey = AdvBillAccountKey
			,@WorkTypeKey         = AdvBillItemKey
			,@RequireClasses      = ISNULL(RequireClasses, 0)
			,@DefaultClassKey     = DefaultClassKey
			,@DefaultPaymentTermsKey = PaymentTermsKey
			,@DefaultSalesAccountKey = DefaultSalesAccountKey
			,@LayoutFromGLCompany  = ISNULL(LayoutFromGLCompany,0)
			,@SetTaxableOnInvoice = isnull(SetTaxableOnInvoice, 0)
			,@AdvBillAccountKey = AdvBillAccountKey
	From tPreference (nolock)
		Where CompanyKey = @CompanyKey
			

	-- We can manufacture CurrencyKey to use in the loops
	-- CurrencyKey initialized at 0 -- Home Currency
	select @CurrencyID = ''''
	Select @CurrencyKey = 1
	while (1=1)
	begin
		select @CurrencyID = min(CurrencyID)
		from   #project
		where  CurrencyID is not null
		and    CurrencyID > @CurrencyID

		if @CurrencyID is null
			break

		update #project
		set    CurrencyKey = @CurrencyKey 
		where  CurrencyID = @CurrencyID

		select @CurrencyKey = @CurrencyKey + 1
	end


	-- If Invoice By Project
	if @InvoiceBy = 0
	begin
		select @ProjectKey = -1
		while (1=1)
		begin
			select @ProjectKey = min(ProjectKey)
			from   #project
			where  ProjectKey > @ProjectKey
			 
			if @ProjectKey is null
				break

			select @ClientKey = ClientKey
			      ,@CurrencyID = CurrencyID
				  ,@BillAmount = BillAmount
				  ,@TaskKey = TaskKey
				  ,@BillingScheduleKey = BillingScheduleKey
			from   #project (nolock)
			where ProjectKey = @ProjectKey
		
			--get invoice defaults from project
			select @BillingContact = Left(u.FirstName + '' '' + u.LastName, 100)
					,@PrimaryContactKey = u.UserKey
					,@LineSubject = p.ProjectName
					,@CampaignKey = p.CampaignKey
					,@GLCompanyKey = p.GLCompanyKey 
					,@OfficeKey = p.OfficeKey
					,@ClassKey = p.ClassKey
					,@LayoutKey = CASE WHEN p.LayoutKey = 0 THEN NULL ELSE p.LayoutKey END
			from tProject p (nolock) 
					left outer join tUser u (nolock) on p.BillingContact = u.UserKey
			where p.ProjectKey = @ProjectKey

			-- get other client defaults  
			Select @InvoiceTemplateKey = ISNULL(InvoiceTemplateKey, 0)
					,@SalesTaxKey = SalesTaxKey
					,@SalesTax2Key = SalesTax2Key
					,@SalesGLAccountKey = ISNULL(DefaultSalesAccountKey, 0)
					,@ARAccountKey = ISNULL(DefaultARAccountKey, 0)
					,@PaymentTermsKey = ISNULL(PaymentTermsKey, 0)
					,@BillingAddressKey = BillingAddressKey
					,@LayoutKey = ISNULL(@LayoutKey, LayoutKey)
			from tCompany (nolock)
			Where CompanyKey = @ClientKey

			-- get comments from the billing schedule
			Select @HeaderComment = Comments
			From tBillingSchedule (nolock)
			Where BillingScheduleKey = @BillingScheduleKey

			IF @LayoutFromGLCompany = 1 and @GLCompanyKey > 0
				select @InvoiceTemplateKey = InvoiceTemplateKey 
				from tGLCompany (nolock) where GLCompanyKey = @GLCompanyKey

			if isnull(@ClassKey, 0) = 0 and @RequireClasses = 1
				select @ClassKey = @DefaultUIClassKey
			if isnull(@ClassKey, 0) = 0 and @RequireClasses = 1
				select @ClassKey = @DefaultClassKey

			if @PaymentTermsKey = 0
				select @PaymentTermsKey = @DefaultPaymentTermsKey

			IF ISNULL(@PaymentTermsKey, 0) > 0
			BEGIN
				SELECT @DueDays = ISNULL(DueDays, 0)  -- Why are they NULL in the database ???
				FROM   tPaymentTerms (NOLOCK)
				WHERE  PaymentTermsKey = @PaymentTermsKey
		 	
				SELECT @DueDate = DATEADD(d, @DueDays, @InvoiceDate) 	
			END
			ELSE
				SELECT @DueDate = @InvoiceDate

			if isnull(@ARAccountKey, 0) = 0
				select @ARAccountKey = @DefaultARAccountKey

			-- create invoice
			-- Note: could have used sptInvoiceInsert-ProjectOneLine
			set @LiabilityAccountKey = @AdvBillAccountKey
			select @NewInvoiceKey = null

			exec @RetVal = sptInvoiceInsert
					@CompanyKey = @CompanyKey,
					@ClientKey = @ClientKey,
					@ContactName = @BillingContact,
					@PrimaryContactKey = @PrimaryContactKey,
					@AddressKey = @BillingAddressKey,
					@AdvanceBill = 1,
					@InvoiceNumber = null,
					@InvoiceDate = @InvoiceDate,
					@DueDate = @DueDate,
					@PostingDate = @PostingDate,
					@TermsKey = @PaymentTermsKey,
					@ARAccountKey = @ARAccountKey,
					@ClassKey = @ClassKey,
					@ProjectKey = @ProjectKey,
					@HeaderComment = @HeaderComment,
					@SalesTaxKey = @SalesTaxKey,
					@SalesTax2Key = @SalesTax2Key,
					@InvoiceTemplateKey = @InvoiceTemplateKey,
					@ApprovedByKey = @UserKey,
					@UserDefined1 = NULL,
					@UserDefined2 = NULL,
					@UserDefined3 = NULL,
					@UserDefined4 = NULL,
					@UserDefined5 = NULL,
					@UserDefined6 = NULL,
					@UserDefined7 = NULL,
					@UserDefined8 = NULL,
					@UserDefined9 = NULL,
					@UserDefined10 = NULL,
					@Downloaded = 0,
					@Printed = 0,
					@ParentInvoice = 0,
					@Emailed = 0,
					@CreatedByKey = @UserKey,
					@GLCompanyKey = @GLCompanyKey,
					@OfficeKey = @OfficeKey,
					@OpeningTransaction = 0,
					@LayoutKey = @LayoutKey,
					@CurrencyID = @CurrencyID,
					@ExchangeRate = 1,
					@RequestExchangeRate = 1, -- set exch rate
					@IsForRetainer = 0,
					@LiabilityAccountKey = @LiabilityAccountKey, -- **NEW PARAMETER ADDED**
					@oIdentity = @NewInvoiceKey OUTPUT -- Maps the output variable

				if @NewInvoiceKey > 0
				begin
					if @InvoiceBy in ( 0, 1) and isnull(@CampaignKey, 0) > 0 
					begin
						update tInvoice
						set    CampaignKey = @CampaignKey
						where  InvoiceKey = @NewInvoiceKey
					end

					If @CreateAsApproved = 1
					BEGIN
	
						--Check to see if the tInvoice Insert SP set the Invoice Number
						SELECT	@NextTranNo = InvoiceNumber,
						        @AdvanceBill = AdvanceBill
						FROM	tInvoice (nolock)
						WHERE	InvoiceKey = @NewInvoiceKey
	
						IF @NextTranNo IS NULL
						BEGIN
							--If the InvoiceNumber has not been set yet, get the next number
							DECLARE @TranType varchar(10) = CASE @AdvanceBill WHEN 1 THEN ''AdvBill'' ELSE ''AR'' END

							EXEC spGetNextTranNo
								@CompanyKey,
								@TranType,
								@RetVal		      OUTPUT,
								@NextTranNo 	  OUTPUT
		
							IF @RetVal <> 1
								RETURN -1
						END
	
						update tInvoice
						set	  ApprovedByKey = @UserKey
							 ,InvoiceStatus = 4 -- Approved
							 ,InvoiceNumber = @NextTranNo 
						where InvoiceKey = @NewInvoiceKey

					END
					ELSE
					BEGIN
		
						select @InvoiceStatus = InvoiceStatus
							  ,@ApprovedByKey = ApprovedByKey
						from   tInvoice (nolock)
						where  InvoiceKey = @NewInvoiceKey

						-- only if not already approved and the approver is valid, submit
						if @InvoiceStatus <> 4 And isnull(@ApprovedByKey, 0) > 0
							update tInvoice
							set    InvoiceStatus = 2
							where InvoiceKey = @NewInvoiceKey
					END -- created as approved 


					-- create invoice line
					--create single invoice line
					exec @RetVal = sptInvoiceLineInsertMassBilling
					   @NewInvoiceKey				-- Invoice Key
					  ,@ProjectKey					-- ProjectKey
					  ,@TaskKey							-- TaskKey
					  ,@LineSubject					-- Line Subject
					  ,null                 		-- Line description
					  ,1                    		-- Bill From 
					  ,1							-- Quantity
					  ,@BillAmount				-- Unit Amount
					  ,@BillAmount				-- Line Amount
					  ,2							-- line type
					  ,0							-- parent line key
					  ,@DefaultAdvBillAccountKey		-- Default Sales AccountKey
					  ,@ClassKey                    -- Class Key
					  ,0							-- Taxable
					  ,0							-- Taxable2
					  ,NULL							-- Work TypeKey
					  ,0							-- PostInDetail
					  ,NULL							-- Entity
					  ,NULL							-- EntityKey
					  ,@OfficeKey
					  ,null							--@DepartmentKey -- may need a department if department required
					  ,@NewInvoiceLineKey output

					 -- This will force the Taxable fields if the pref or the project requires them
					exec sptInvoiceSetTaxable @NewInvoiceKey, @SetTaxableOnInvoice

					-- before we leave, better to recalc the amounts in the header  
					exec sptInvoiceRecalcAmounts @NewInvoiceKey 
	
					-- Calculate the line order and position
					exec sptInvoiceOrder @NewInvoiceKey, 0, 0, 0

					if not exists (select 1 from tBillingSchedule (nolock) where InvoiceKey = @NewInvoiceKey and ProjectKey = @ProjectKey)
					update tBillingSchedule
					set    InvoiceKey = @NewInvoiceKey
					where  BillingScheduleKey = @BillingScheduleKey 
					and    tBillingSchedule.BillingKey is null
					and    tBillingSchedule.InvoiceKey is null

					if isnull(@BillingStatusKey, 0) > 0
					UPDATE tProject
					SET    tProject.ProjectBillingStatusKey = @BillingStatusKey
					WHERE  tProject.ProjectKey = @ProjectKey


					select @Entity = ''Client Invoice'',@EntityKey = @NewInvoiceKey,@Action = ''Generated'', @ActionDate = getutcdate(), @LogCampaignKey = 0

					select @Reference = i.InvoiceNumber
						  ,@SourceCompanyID = c.CustomerID
					from   tInvoice i (nolock)
						left outer join tCompany c (nolock) on i.ClientKey = c.CompanyKey
					where  i.InvoiceKey = @NewInvoiceKey

					select @Reference = isnull(@Reference,'''')
						  ,@SourceCompanyID = isnull(@SourceCompanyID,'''')
		
					-- the Invoice number may be missing if the user assign #s at approval time
					if len(@Reference) > 0
						select @Comments = ''Invoice '' + @Reference + '' was generated through mass billing as advance bill.''
					else
						select @Comments = ''Invoice was generated through mass billing as advance bill.''

					select @Comments = @Comments + ''.'' -- just to differentiate bewteen wjapp and wmj

					exec sptActionLogInsert @Entity, @EntityKey, @CompanyKey, @ProjectKey, @Action, @ActionDate, @ActionBy, @Comments, @Reference, @SourceCompanyID, @UserKey, @LogCampaignKey

				end -- invoice created

		end -- project loop

	end -- by project


	if @InvoiceBy <> 0
	begin
		-- client or parent client

		-- Need to create an invoice per:
		-- GLCompanyKey/Currency/ClientKey

		-- then create an invoice line per project

		SELECT @GLCompanyKey = -1
		WHILE (1=1)
		BEGIN
			SELECT @GLCompanyKey = MIN(GLCompanyKey) FROM #project
			WHERE GLCompanyKey > @GLCompanyKey
		
			IF @GLCompanyKey IS NULL
				BREAK

			SELECT @CurrencyKey = -1
			WHILE (1=1)
			BEGIN
				SELECT @CurrencyKey = MIN(CurrencyKey)
				FROM   #project 
				WHERE  GLCompanyKey   =  @GLCompanyKey	
				AND    CurrencyKey    >  @CurrencyKey
					
				IF @CurrencyKey IS NULL
					BREAK

				select @CurrencyID = CurrencyID from #project
				where  CurrencyKey =  @CurrencyKey -- All same currency IDs should have same key

				SELECT @ClientKey = -1
				WHILE (1=1)
				BEGIN
					SELECT @ClientKey = MIN(LoopClientKey)
					FROM   #project 
					WHERE  GLCompanyKey   =  @GLCompanyKey	
					AND    CurrencyKey    =  @CurrencyKey
					AND    LoopClientKey > @ClientKey
					 
					IF @ClientKey IS NULL
						BREAK

					-- create an invoice for the client

					-- Get the billing contact as the primary contact from the client
					select @BillingContact = Left(u.FirstName + '' '' + u.LastName, 100)
							,@PrimaryContactKey = u.UserKey
					from tCompany cl (nolock) 
						left outer join tUser u (nolock) on cl.PrimaryContact = u.UserKey
					Where cl.CompanyKey = @ClientKey

					-- get other client defaults  
					Select @InvoiceTemplateKey = ISNULL(InvoiceTemplateKey, 0)
							, @SalesTaxKey = SalesTaxKey
							, @SalesTax2Key = SalesTax2Key
							, @SalesGLAccountKey = ISNULL(DefaultSalesAccountKey, 0)
							, @PaymentTermsKey = ISNULL(PaymentTermsKey, 0)
							, @BillingAddressKey = BillingAddressKey
							, @LayoutKey = LayoutKey
					from tCompany (nolock)
					Where CompanyKey = @ClientKey

					if @LayoutFromGLCompany = 1 and @GLCompanyKey > 0
						select @InvoiceTemplateKey = InvoiceTemplateKey
							  ,@LayoutKey = LayoutKey 
						from tGLCompany (nolock) where GLCompanyKey = @GLCompanyKey

					select @ClassKey = @DefaultUIClassKey
					if isnull(@ClassKey, 0) = 0 and @RequireClasses = 1
						select @ClassKey = @DefaultClassKey

					if @PaymentTermsKey = 0
						select @PaymentTermsKey = @DefaultPaymentTermsKey

					IF ISNULL(@PaymentTermsKey, 0) > 0
					BEGIN
						SELECT @DueDays = ISNULL(DueDays, 0)  -- Why are they NULL in the database ???
						FROM   tPaymentTerms (NOLOCK)
						WHERE  PaymentTermsKey = @PaymentTermsKey
		 	
						SELECT @DueDate = DATEADD(d, @DueDays, @InvoiceDate) 	
					END
					ELSE
						SELECT @DueDate = @InvoiceDate

					exec @RetVal = sptInvoiceInsert
							@CompanyKey = @CompanyKey,
							@ClientKey = @ClientKey,
							@ContactName = @BillingContact,
							@PrimaryContactKey = @PrimaryContactKey,
							@AddressKey = @BillingAddressKey,
							@AdvanceBill = 1,
							@InvoiceNumber = null,
							@InvoiceDate = @InvoiceDate,
							@DueDate = @DueDate,
							@PostingDate = @PostingDate,
							@TermsKey = @PaymentTermsKey,
							@ARAccountKey = @DefaultARAccountKey,
							@ClassKey = @ClassKey,
							@ProjectKey = @ProjectKey,
							@HeaderComment = null,
							@SalesTaxKey = @SalesTaxKey,
							@SalesTax2Key = @SalesTax2Key,
							@InvoiceTemplateKey = @InvoiceTemplateKey,
							@ApprovedByKey = @UserKey,
							@UserDefined1 = NULL,
							@UserDefined2 = NULL,
							@UserDefined3 = NULL,
							@UserDefined4 = NULL,
							@UserDefined5 = NULL,
							@UserDefined6 = NULL,
							@UserDefined7 = NULL,
							@UserDefined8 = NULL,
							@UserDefined9 = NULL,
							@UserDefined10 = NULL,
							@Downloaded = 0,
							@Printed = 0,
							@ParentInvoice = 0,
							@Emailed = 0,
							@CreatedByKey = @UserKey,
							@GLCompanyKey = @GLCompanyKey,
							@OfficeKey = @DefaultUIOfficeKey,
							@OpeningTransaction = 0,
							@LayoutKey = @LayoutKey,
							@CurrencyID = @CurrencyID,
							@ExchangeRate = 1,
							@RequestExchangeRate = 1, -- set exch rate
							@IsForRetainer = 0,
							@LiabilityAccountKey = NULL, -- **NEW PARAMETER ADDED**
							@oIdentity = @NewInvoiceKey OUTPUT -- Maps the output variable
					 
					 if @NewInvoiceKey > 0
					 begin

						If @CreateAsApproved = 1
							BEGIN
	
								--Check to see if the tInvoice Insert SP set the Invoice Number
								SELECT	@NextTranNo = InvoiceNumber
								FROM	tInvoice (nolock)
								WHERE	InvoiceKey = @NewInvoiceKey
	
								IF @NextTranNo IS NULL
								BEGIN
									--If the InvoiceNumber has not been set yet, get the next number
									EXEC spGetNextTranNo
										@CompanyKey,
										''AR'',		-- TranType
										@RetVal		  OUTPUT,
										@NextTranNo   OUTPUT
		
									IF @RetVal <> 1
										RETURN -1
								END
	
								update tInvoice
								set	  ApprovedByKey = @UserKey
									 ,InvoiceStatus = 4 -- Approved
									 ,InvoiceNumber = @NextTranNo 
								where InvoiceKey = @NewInvoiceKey

							END
							ELSE
							BEGIN
		
								select @InvoiceStatus = InvoiceStatus
									  ,@ApprovedByKey = ApprovedByKey
								from   tInvoice (nolock)
								where  InvoiceKey = @NewInvoiceKey

								-- only if not already approved and the approver is valid, submit
								if @InvoiceStatus <> 4 And isnull(@ApprovedByKey, 0) > 0
									update tInvoice
									set    InvoiceStatus = 2
									where InvoiceKey = @NewInvoiceKey
							END -- created as approved 
					 
						-- now create 1 line per project 
						select @ProjectKey = -1

						WHILE (1=1)
						BEGIN
							SELECT @ProjectKey = MIN(ProjectKey)
							FROM   #project 
							WHERE  GLCompanyKey   =  @GLCompanyKey	
							AND    CurrencyKey    =  @CurrencyKey
							AND    LoopClientKey  = @ClientKey
							AND    ProjectKey > @ProjectKey

							IF @ProjectKey IS NULL
								BREAK
						
							select @BillAmount = BillAmount
							      ,@BillingScheduleKey = BillingScheduleKey
								  ,@TaskKey = TaskKey
							from   #project
							where  ProjectKey = @ProjectKey

							select @LineSubject = ProjectName 
							from tProject (nolock)
							where ProjectKey = @ProjectKey
							 
							 exec @RetVal = sptInvoiceLineInsertMassBilling
							   @NewInvoiceKey				-- Invoice Key
							  ,@ProjectKey					-- ProjectKey
							  ,@TaskKey							-- TaskKey
							  ,@LineSubject					-- Line Subject
							  ,null                 		-- Line description
							  ,1                    		-- Bill From 
							  ,1							-- Quantity
							  ,@BillAmount				-- Unit Amount
							  ,@BillAmount				-- Line Amount
							  ,2							-- line type
							  ,0							-- parent line key
							  ,@DefaultAdvBillAccountKey		-- Default Sales AccountKey
							  ,@ClassKey                    -- Class Key
							  ,0							-- Taxable
							  ,0							-- Taxable2
							  ,NULL							-- Work TypeKey
							  ,0							-- PostInDetail
							  ,NULL							-- Entity
							  ,NULL							-- EntityKey
							  ,@OfficeKey
							  ,null							--@DepartmentKey -- may need a department if department required
							  ,@NewInvoiceLineKey output

							  update tBillingSchedule
								set    InvoiceKey = @NewInvoiceKey
								where  BillingScheduleKey = @BillingScheduleKey 

						end -- loop on project 

						 -- This will force the Taxable fields if the pref or the project requires them
						exec sptInvoiceSetTaxable @NewInvoiceKey, @SetTaxableOnInvoice

						  -- before we leave, better to recalc the amounts in the header  
						exec sptInvoiceRecalcAmounts @NewInvoiceKey 
	
						-- Calculate the line order and position
						exec sptInvoiceOrder @NewInvoiceKey, 0, 0, 0
						
						IF @BillingStatusKey IS NOT NULL
							UPDATE tProject
							SET    tProject.ProjectBillingStatusKey = @BillingStatusKey
							FROM   #project b
							where  b.GLCompanyKey   =  @GLCompanyKey	
							AND    b.CurrencyKey    =  @CurrencyKey
							AND    b.LoopClientKey  = @ClientKey
							and    b.ProjectKey = tProject.ProjectKey 

						select @Entity = ''Client Invoice'',@EntityKey = @NewInvoiceKey,@Action = ''Generated'', @ActionDate = getutcdate(), @LogCampaignKey = 0

						select @Reference = i.InvoiceNumber
							  ,@SourceCompanyID = c.CustomerID
						from   tInvoice i (nolock)
							left outer join tCompany c (nolock) on i.ClientKey = c.CompanyKey
						where  i.InvoiceKey = @NewInvoiceKey

						select @Reference = isnull(@Reference,'''')
							  ,@SourceCompanyID = isnull(@SourceCompanyID,'''')
		
						-- the Invoice number may be missing if the user assign #s at approval time
						if len(@Reference) > 0
							select @Comments = ''Invoice '' + @Reference + '' was generated through mass billing as advance bill.''
						else
							select @Comments = ''Invoice was generated through mass billing as advance bill.''

						select @Comments = @Comments + ''.'' -- just to differentiate bewteen wjapp and wmj

						-- pass 0 for ProjectKey 
						exec sptActionLogInsert @Entity, @EntityKey, @CompanyKey, 0, @Action, @ActionDate, @ActionBy, @Comments, @Reference, @SourceCompanyID, @UserKey, @LogCampaignKey


					 end -- invoice was created

				END -- loop on client
		
						
			END -- loop on Currency
										
		END -- loop on GLCompany
		

	end -- invoice by client/parent client
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spConvertDBSeed]'
GO
IF OBJECT_ID(N'[dbo].[spConvertDBSeed]', 'P') IS NOT NULL
EXEC sp_executesql N'

ALTER PROCEDURE [dbo].[spConvertDBSeed]
(
	@LoadBeta int = 0
)
AS

/*
exec spConvertDBSeed 1
|| When      Who Rel      What
|| 8/21/09   CRG 10.5.0.8 Created to have all of the seed generating statements in one SP.
||                        Add comments here when you add a new seed value
|| 8/31/09   CRG 10.5.0.9 Added options for Today''s Meetings widget
|| 9/8/09    GWG 10.5.0.9 Added a right for editing notes for clients  (also changed some labels)
|| 10/06/09  GHL 10.5.1.2 (63999) Added prjAccessAny and prjChargeAny
|| 10/06/09  GHL 10.5.1.3 (47035) Added prjTimeCompletedTask and prjExpenseCompletedTask
|| 11/4/09   CRG 10.5.1.3 Fixed a spelling error in RightKey: 931506
|| 12/03/09  GHL 10.5.1.4 (64187) Added proj_projectscoreboard for project summary scoreboard
|| 02/08/10  GWG 10.5.1.8 Added the opportunity list as a legacy report
|| 02/10/10  GWG 10.5.1.8 Added new widget for recurring transactions (not active yet, commented out)
|| 03/18/10  MAS 10.5.2.0 Added Voucher Lab
|| 3/31/10   GWG 10.5.2.0 Fixed some wording and display orders for certain security groups
|| 04/08/10  RLB 10.5.2.1 Added Billing Add Transaction to Worksheet.
|| 04/24/10  GWG 10.5.2.1 Added a right for enabling labs and modified the labs
|| 04/27/10  GWG 10.5.2.1 Added right for CBRE report
|| 05/6/10   RLB 10.5.2.2 (80005)Changed Display Order on admin_employeehours
|| 06/17/10  GWG 10.5.3.1 Fixed a spelling error, moved schedule edit to beta and fixed a setting chargeability percentage
|| 06/17/10  GWG 10.5.3.2 Removed the client notes widget.
|| 7/8/10    GWG 10.5.3.2 Added GL Posting as a Lab
|| 08/26/10  RLB 10.5.3.4 (80063,69422)Added 2 new rights View invoice for child company and view invoices for assigned projects
|| 08/27/10  RLB 10.5.3.4 added right for new Overhead Allocation Details Report
|| 09/30/10  MFT 10.5.3.5 added Lab for Transactions and AcctRec
|| 10/03/10  MFT 10.5.3.6 added Lab for IO & PO
|| 10/10/10  GWG 10.5.3.6 Changed a description for adminviewcostrate and added some release comments
|| 10/27/10  RLB 10.5.3.7 Added a lab for WIP Aging
|| 10/28/10  GWG 10.5.3.7 Took items out of labs and rearanged stuff
|| 11/16/10  RLB 10.5.3.8 added new right group legacy
|| 12/3/10   CRG 10.5.3.9 Added labs for Diary and ToDos (commented out for now)
|| 12/10/10  GWG 10.5.3.9 Changed the default url for the rss widget
|| 01/14/11  MAS 10.5.?.? Added MobileMenu seed values
|| 02/01/11  GWG 10.5.4.0 Changed lab settings and removed a duplicate adminsetup_media in system setup
|| 03/20/11  GWG 10.5.4.2 Added a new notification (task reminder)
|| 04/18/11  GWG 10.5.4.3 Commented out project requests from the mobile menu for now
|| 06/02/11  RLB 10.5.4.5 (113014) added ProjectTypeKey for My Task widget
|| 06/28/11  RLB 10.5.4.5 (115163) added right to convert contacts and employees
|| 06/28/11  GHL 10.5.4.5 (60333) Added media billing report
|| 08/02/11  GHL 10.5.4.6 Added LabID for credit cards
|| 09/12/11  GHL 10.5.4.8 Added Rights for Credit Card charges
|| 09/22/11  GHL 10.5.4.8 (109668) Added right pyramidLaborRpt for a customization for Pyramid
|| 09/27/11  GWG 10.5.4.8 Made the metrics monitor resizable
|| 09/28/11  GHL 10.5.4.8 Added client_editprojectspecs for the Integer Group of Colorado for clients to edit project specs
||                        Added billingtimesheetunapprove for the Integer Group of Colorado to unapprove timesheets
|| 09/28/11  CRG 10.5.4.8 Removed WebDAV from the Labs. It will now just be an internal flag in tPreference that we turn on once they''re converted
|| 09/28/11  GHL 10.5.4.8 Changed wording of the right purch_usecreditcard to ''use credit card charge entry screens''
||                        to differentiate with right billingcreditcard
|| 10/25/11 RLB 10.5.4.9  (124610) Added right to edit other peoples Diary Posts
|| 11/4/11  GWG 10.5.4.9  Reordered the mobile menu
|| 11/8/11  RLB 10.5.5.0  Adding Retainer Lab
|| 12/7/11  RLB 10.5.5.1  (128080) Added openToDoOnly option on the My Task widget
|| 01/30/12 MAS 10.5.5.3  Added Financial Institution data for Credit Card downloads
|| 04/09/12 GHL 10.5.5.5  Added right to edit electronic signature on check formats
|| 04/09/12 GHL 10.5.5.5  (139284) Added rights billingtransfertran and billingwriteofftran 
|| 04/23/12 MAS 10.5.5.5  Added purch_usecreditcardconnect right
|| 05/04/12 MAS 10.5.5.5  Changed the URL connection string for AMEX
|| 6/1/12   CRG 10.5.5.6  Added publishCalendar lab
|| 6/6/12   RLB 10.5.5.6  (138325) Added Client right to see Project Misc Cost
|| 6/13/12  GHL 10.5.5.7  Added right adminsetup_glcompanyaccess to allow editing of gl compapanies access on company edit screen
|| 6/28/12  RLB 10.5.5.7  (147280) Added option on the active project widget
|| 7/16/12  CRG 10.5.5.8  Added lab for revenue forecast
|| 07/23/12 RLB 10.5.5.8  (149536) Added New right to view project revenue source
|| 07/25/12 MFT 10.5.5.8  Added new right for printing checks (purch_printchecks)
|| 07/27/12 RLB 10.5.5.8  Added new option in the Chargeablility Summary widget
|| 07/31/12 RLB 10.5.5.8  Added GL Company Option to the Cash on Hand widget
|| 07/31/12 RLB 10.5.5.8  Added GL Company Option to the Write Off Summary widget
|| 07/31/12 MFT 10.5.5.8  Added Settings value to the tWidget INSERT for Metrics Monitor
|| 07/31/12 RLB 10.5.5.8  Added GL Company Option to the Opp Pipeline widget
|| 08/07/12 RLB 10.5.5.8  Added GL Company Option to the Chargeablility percentage and HMI changes
|| 08/07/12 RLB 10.5.5.8  Added GL Company Option to the Rev Per Employee
|| 08/07/12 RLB 10.5.5.8  Added GL Company Option to the Opp Forecast widget and HMI changes
|| 08/07/12 RLB 10.5.5.8  Added GL Company Option to the Opp Outcome and HMI changes
|| 08/07/12 MFT 10.5.5.8  Added Settings value to the tWidget INSERT for Billable Efficiency
|| 08/08/12 RLB 10.5.5.8  Added GL Company Option to the Opp closed by person and HMI changes
|| 08/08/12 MFT 10.5.5.8  Added Settings value to the tWidget INSERT for Vulnerability to Loss
|| 08/08/12 RLB 10.5.5.8  Added GL Company Option to the Active Project widget
|| 08/10/12 RLB 10.5.5.8  Added GL Company Option to the Income By Service and HMI changes
|| 08/10/12 RLB 10.5.5.8  Added GL Company Option to the Repeat clients and HMI changes
|| 08/10/12 RLB 10.5.5.8  Added GL Company Option to the Revenue Trend and HMI changes
|| 08/11/12 QMD 10.5.5.9  Added lab for google contacts and google calendar v3
|| 08/15/12 KMC 10.5.5.9  (151654) Updated the insert into tWidget for Revenure Trend Widget (ID=36) and default
||                        the year node to blank in the XML string.  Also updated MetricsRevenueTrend.mxml to set the
||                        year to the current year if it is blank
|| 08/20/12 RLB 10.5.5.9  (152004) Added rights to merge Leads, Contacts and Companies
|| 08/20/12 MFT 10.5.5.9  Added GL Company Option to the tWidget for Markup By Item and Company Calendar
|| 09/11/12 CRG 10.5.6.0  Added lab for P&L Custom Layouts
|| 09/18/12 MFT 10.5.6.0  Added right hmiProjectResourceUtilization for HMI custom report
|| 09/24/12 RLB 10.5.6.0  Added right to Unpost for HMI
|| 10/02/12 KMC 10.5.6.0  (134065) Added Account Balances widget
|| 10/05/12 WDF 10.5.6.0  (150044) Added ''Project Billable Hours Summary'' report
|| 10/25/12 MFT 10.5.6.1  (156391) Added right for Project Reconciliation Summary
|| 11/20/12 WDF 10.5.6.2  Added Settings value ''ShowInActive''to the tWidget INSERT for Opportunity Pipeline, Opportunity Forecast, Revenue Trend, Activity Counts
|| 11/26/12 RLB 10.5.6.2  added description on Deliverable Lab stating that Web Dav Is required to use
|| 11/29/12 QMD 10.5.6.2  Added lab for new emma and google caldav
|| 12/7/12  GWG 10.5.6.3  Added All projects to the over budget calculation
|| 02/14/13 KMC 10.5.6.5  Removed googleCalendarV3 from Labs
|| 03/01/13 RLB 10.5.6.5  Add lab for project time line
|| 03/15/13 GWG 10.5.6.6  Pulled a number of things out of labs
|| 03/20/13 MAS 10.5.6.6  Added activity widget
|| 03/27/13 RLB 10.5.6.6  Added Timeline Widget and lab
|| 04/23/13 RLB 10.5.6.7  Added right to see non project related events on the dialy feed widget
|| 04/29/13 RLB 10.5.6.7  (175860) Added right to view Project Setup Accounting Tab
|| 06/06/13 MFT 10.5.6.9  Added lab for PrintMedia
|| 06/11/13 CRG 10.5.6.9  Added new Media rights
|| 07/03/13 QMD 10.5.6.9  Added new Mobile App (Expense Reports)
|| 07/09/13 MFT 10.5.6.9  Added new tFinancialInstitution row (13)
|| 07/09/13 KMC 10.5.7.0  (184557) Added new right purch_approvecreditcardcharge for approving credit card charges
|| 07/23/13 MFT 10.5.6.9  Added new tFinancialInstitution row (14)
|| 08/23/13 GHL 10.5.7.1  Added 2 multicurrency gains and losses reports
|| 08/26/13 GHL 10.5.7.1  Added right to view forecasts from other AEs
|| 08/27/13 GHL 10.5.7.1  Added right to view forecasts
|| 09/03/13 GHL 10.5.7.2  Added USD currency
|| 09/03/13 RLB 10.5.7.2  (187734) Added right to view customfields on project dashboard
|| 09/06/13 GHL 10.5.7.2  Added multicurrency lab
|| 09/17/13 MFT 10.5.7.2  Added right 61700/purch_approvemyprojectvoucher to approve vendor invoices on projects assigned to 
|| 09/17/13 CRG 10.5.7.2  Added LockQty to Pages value in tMediaUnitType
|| 10/21/13 GHL 10.5.7.3  Added right to maintain currency rates
|| 10/24/13 WDF 10.5.7.3  (171844) Added new right prjViewTran for viewing the Project Transaction screens 
|| 10/31/13 MFT 10.5.7.3  Added new right prjnotesedit and changed prjnotes to Add only, reorganized project, admin rights to be together
|| 11/07/13 MFT 10.5.7.4  Added new right media_printbuysched
|| 11/11/13 WDF 10.5.7.4  (195542) Added new rights specificially for ToDos
|| 02/06/14 MFT 10.5.7.7  Changed media_printbuysched to media_printbuycal;Added media_printbuyblock & media_printbuygrid
|| 02/18/14 CRG 10.5.7.7  Fixed the POKind on the tMediaUnitType seeding
|| 03/06/14 WDF 10.5.7.8  (124798) Added new right ''acct_client_gl_pl_ytd'' to split out Client P&L from Corp P&L
|| 03/25/14 GWG 10.5.7.8  Removed bank of america because of errors
|| 04/15/14 GWG 10.5.7.9  Added correct bofa url information
|| 04/17/14 KMC 10.5.7.9  (213294) Removed the lab/beta for deliverables
|| 04/29/14 MAS 10.5.7.9  Added adminUserSettings right 
|| 05/01/14 PLC 10.5.7.9  Added defaults Print USer dates 1 and 2 
|| 05/06/14 GHL 10.5.8.0  Changed INSERT 000 to INSERT (000) for media unit 
|| 05/14/14 GHL 10.5.8.0  Enabled the currency rate admin screen
|| 05/30/14 GHL 10.5.8.0  (218161) Removed lab NewLayoutBilling, we only use NewLayoutDesign now
|| 06/05/14 QMD 10.5.8.0  (218393) Added new right prjAssignTasksToMe
|| 06/09/14 RLB 10.5.8.1  (216811) Removed Bank of America from tFinancialInstitution
|| 06/26/14 KMC 10.5.8.1  (220472) Added right for viewing the Billing tab in project central, right ID 90926/prjDashBilling.
|| 07/02/14 QMD 10.5.8.1  (218393) Removed right prjAssignTasksToMe
|| 07/02/14 QMD 10.5.8.1  (220670) Added new right prjQuickAddTask and prjQuickAddActivity
|| 07/15/14 GWG 10.5.8.2  Changed the sort order of two rights for multi currency
|| 08/12/14 CRG 10.5.8.3  Added googleCalDAV Lab
|| 09/03/14 WDF 10.5.8.4  (225597) Added Custom Report (99000001)
|| 09/03/14 CRG 10.5.8.4  Removed googleCalDAV Lab
|| 09/23/14 MAS 10.5.8.4  Abelson & Taylor - added adminChangeBillingTitle right
|| 10/03/14 CRG 10.5.8.4  Added lab vPayment
|| 10/21/14 WDF 10.5.8.5  (231857) Added ''hideToDoNotes'' and ''hideDiaryNotes'' to tWidget.Settings where WidgetKey = 24 
|| 11/19/14 GAR 10.5.8.6  (236371) Added new security right.  Changed ''Edit Global Options'' to ''Allow Access to Global Options: System Options ''
||						  and added ''Allow Access to Global Options: Lists''.
|| 12/09/14 GHL 10.5.8.7  (229954) Added concentricChargeabilityRpt right for enhancement for Concentric 
|| 12/10/14 RLB 10.5.8.7  (239148) Removed Labs PO, Spec Sheet and Mass Billing
|| 01/09/15 GHL 10.5.8.8  (241893) Removed forecast lab, part of the general release now
|| 01/20/15 GHL 10.5.8.8  Added security right prjrecalclaborrates for Abelson Taylor
|| 01/26/15 GAR 10.5.8.8  (242601) Added jplChargeabilitySummary right for enhancement for JPL 
|| 01/26/15 GHL 10.5.8.8  Added prjChangeAnyoneCharges right to control the Anyone Allowed to Charge Time on projects for Abelson Taylor
|| 01/28/15 GHL 10.5.8.8  Added abelsonProjectResourceUtilization right to allow Abelson Taylor to use the HMI Project Resource Utilization rpt
|| 02/03/15 GAR 10.5.8.9  (244725) Changed Media Discrepancy Report to Media Details Report
|| 02/05/15 GWG 10.5.8.9  Move multi currency to labs
|| 02/09/15 GHL 10.5.8.9  Added right billingunwriteofftran to undo writeoffs for abelson taylor
|| 02/19/15 GHL 10.5.8.9  Added right prjViewTranAdjusted to view adjusted transactions for abelson Taylor
|| 03/05/15 GWG 10.5.9.0  Added Platinum review beta entry
|| 03/12/15 GHL 10.5.9.1  (241695) Added purch_viewbankinfo + purch_editbankinfo to control vendor''s bank info for Spark44 enh
|| 05/01/15 GWG 10.5.9.2  Removed a label from one of the rights.
|| 05/22/15 KMC 10.5.9.2  (257529) Added rights for view and editing of EIN Number
|| 09/17/15 GWG 10.5.9.6  Updated the WJ RSS Feed
|| 10/15/15 GHL 10.5.9.7  (271391) added right adminsetup_billing for a customization
|| 10/19/15 MCM 10.5.9.7  (273918) Updated description of two rights: "Allow Access to System Options" and "Allow Access to Lists"	
|| 11/14/15 GWG 10.5.9.8  Added Plat for Resource Managers lab
|| 12/02/15 MFT 10.5.9.8  Added platRedirectMobile lab
|| 12/03/15 MCM 10.5.9.8  (274460) Updated description for right 940700 (accteditanytime) by adding submission so it''s ''Edit transactions after submission/approval''
|| 02/09/16 GWG 10.6.0.1  Changed the label on edit billing info to edit accounting info for Mike.
|| 03/02/16 GWG 10.6.0.1  Removed platPO, folded under platPM
|| 03/30/16 GAR 10.6.0.2  Added status seeds for tTaskUserStatus table
|| 05/16/16 CRG 10.6.0.4  (295466) Added prjEditProjectNumber
|| 05/19/16 GAR 10.6.0.4  Removed unneeded statuses for tTaskUserStatus
|| 05/19/16 CRG 10.6.0.4  Removed duplicate platProjectRequest lab
|| 05/20/16 MAS 10.6.0.4  Added farmPostageAvailableReport
|| 05/26/16 CRG 10.6.0.4  (301321) Split Client Actual Hours and Dollars into two different rights
|| 06/06/16 RLB 10.6.0.5  (299542) Adding estimate approval notification
|| 06/27/16 RLB 10.6.0.5  (304632) Adding a right to see Plat project pm dashboard
|| 06/30/16 CRG 10.6.0.5  Added Platinum Resource Loading lab
|| 08/01/16 CRG 10.6.0.6  Removed Platinum Resource Loading lab
|| 08/25/16 GWG 10.0.6.7  Added a platinum specific section and rights for Today pages
|| 10/8/16  GWG 10.6.0.9  Added right for editing templates.
|| 11/16/16 MCM 10.6.1.0  Updated description for prjnotes and approveadd to say Addess instead of add 
|| 02/09/17 GWG 10.6.1.3  Remove lasalle bank
|| 05/16/17 WDF 10.6.1.6  (342677) Add ''View'' Right (20200) for Deliverables to the tRight table
|| 05/23/17 GHL 10.6.1.6  (345091) Added concentric client PL report
|| 05/30/17 GHL 10.6.1.6  (345091) Added concentric dept PL report
|| 06/09/17 RLB 10.6.1.7  Added right to use scheduled reports
|| 06/30/17 GWG 10.6.1.7  Add in the right for accounting today pages.
|| 07/20/17 GAR 10.6.1.8  (341612) Split the gl_post right out into 6 separate rights (gl_postvoucher, gl_postpayment, gl_postclientinvoice, gl_postreceipt, gl_postjournalentry, gl_postcreditcard)
|| 08/17/17 RLB 10.6.1.9  (356364) add barb group custom report right
|| 09/08/17 QMD 10.6.1.9  Add platImport screen lab
|| 09/15/17 GHL 10.6.2.0  (MN''s Todo) Rename ''Billing Worksheet'' to ''Billing Worksheet Report'' to differentiate from Electronic Billing Worksheets
|| 09/18/17 GHL 10.6.2.0  (MN''s Todo) Added ''Client'' to description for client right 501100 to differentiate from regular right
|| 10/05/17 RLB 10.6.2.1  Added right to only enter time against tasks where the predecessor is completed or has no pred/succ
|| 11/01/17 GAR 10.6.2.1  Added 2 rights for Platinum company notes
|| 11/8/17  GWG 10.6.2.2  Added lab for new creative today screen
|| 01/03/18 CRG 18.1.0    Added newSchedule lab
|| 02/20/18 WDF 18.3.0    (373099 ) Added ''NEWSPECSHEET'' to tNotification
|| 03/20/18 RLS 18.4.0    (392204) Changed DESCRIPTION verbage in tNotification for NotificationID TASKUPDATE
|| 04/04/18 GWG 18.4.0    Change Art Review to deliverable
|| 03/20/18 MAS 18.5.0    Added PlatMedia Lab
|| 04/10/18 RLS 18.5.0    (TODO DEV1784 - Round 2 Enhancement ) Added ''NEWOPPORTUNITY'' to tNotification
|| 04/12/18 MCM 18.5.0    (TODO 4430) Added right to import approved expense report
|| 04/18/18 GAR 18.5.0    Removed platReviews from tLab
|| 04/26/18 MAS 18.5.0    Removed PNC Bank from the Credit Card Connector list
|| 05/09/18 CRG 18.6.0    Added cross-project predecessor lab
|| 05/22/18  RLS 18.6.0.0 (402000) Change all labels that were ''timesheet to ''time sheet''. System-wide change
|| 05/25/18 MCM 18.6.0    (403146) Updated the description and hint for billing_expenserptapproveimported
|| 05/25/18  RLS 16.6.0   (403017) Change tTask Lookup descriptions to ''On or Before the Next X Days''
|| 06/07/18 CRG 18.7.0    Added officeBlockoutCalendars lab
|| 07/23/18 WDF 18.8.0    (411279) Modified Hint of right prjChangeAnyoneCharges to indicaate being visible/not visible rather than enabled/not enabled.
|| 10/12/18 AMP 18.9.2    (422151) Added a new Purchasing Right "View Vendor Invoices on Approval screen"
|| 10/17/18 GHL 18.9.2    (424497) Added rights to edit media orders after approval
|| 10/19/18 AMP 18.9.2    (424927) Added a new Purchasing Right "View Purchase Orders on Approvals"
|| 10/25/18 GHL 18.9.2    (423844) Added right questvouchersrpt to view custom vendor invoice report for Quest 
|| 11/7/18  GWG 18.9.3.0  (429573) Added specific rights to view each of the new dashboards and removed the dashboard lab/beta
|| 12/2/18  GWG 18.9.3.0  (429573) Remove rights for view todo dashboard.  based on view todo right.  Rename PM Dashboard right
|| 12/12/18 GWG 19.1.0    Fix the labels on the dashboard rights
|| 01/14/19 AMP 19.0.2.0  (438405) Added new Media rights "View Insertion Orders on Approvals" and "View Broadcast Orders on Approvals"
|| 01/24/19 RLS 19.0.2.0  (441481) Added adminsetup_changerequest
|| 02/08/19 GAR 19.0.3.0  (416773) Added tLab entry for globalFileSearch.
|| 02/13/19 RLB 19.0.3.0  Added client and user rights to tChange
|| 02/20/19 GWG 19.0.3.0  Move media out of beta
|| 03/13/19 GWG 19.0.4.0  Moving labs over to convertappseed
|| 04/30/19 CRG 19.0.5.0  Removed string numbers in hints
|| 05/20/19 GHL 19.0.6.0  (448693) Changed the description of view only AP transactions (removed on Approvals)
|| 05/24/19 AMP 19.0.6.0  (461647) Update for new graphs menus to say Graphs (instead of new dashboard)
|| 06/21/19 AMP 19.0.7.0  (461523) Changed wording on purch_usecreditcard right, and added new right (purch_viewcreditcard) for View Only on the credit card charge entry screens
|| 07/08/19 RLB 19.0.8.0  (441482) made some changes to CR''s rights wording
|| 07/16/19 GHL 19.0.8.0  (466585) Added billingenterlabornet for a customization for wongdoody to enter a net rate for OT in project billing
|| 09/18/19 GHL 19.1.0.0  (479811) Changed the wording of purch_editpo to Add and Edit Purchase Orders
|| 10/11/19 RLS 19.1.1.0  (462005) Added NEWCAMPAIGN to tNotifications
|| 11/21/19 GAR 19.1.2.0  (473697) Changed ''Projects where I am the account manager'' to ''Projects where I am the account manager or project manager'' on several notifications 
|| 12/16/19 RLB 20.0.1.0  (487336) added client right to access any project
|| 01/14/20 RLS 20.0.2.0  (494271) Moved the (Legacy) client rights into a new RightGroup named ClientLegacy
|| 01/16/20 CRG 20.0.2.0  (495703) Removed client_calendar from Legacy section
|| 01/30/20 GHL 20.0.2.0  (499146) Reordered the ''Contact Management'' or cm rights 
|| 02/28/20 GAR 20.0.4.0  (503817) Added a right for a client to delete their own project request
|| 03/06/20 AMP 20.0.4.0  (505412) Corrected BO/IO security rights descriptions
|| 03/06/20 AMP 20.0.4.0  (500075) Added a right for ''Edit Purchase Orders after Approval''
|| 04/03/20 AMP 20.0.5.0  (474467) Added a right under Billing to ''View Client Invoices''
|| 05/05/20 RLB 20.0.6.0  (494017) Added new overworked assignment
|| 07/27/20 RLB 20.0.8.0  (523358) removed beta in the descriptions on change requests
|| 07/31/20 GAR 20.0.9.0  (517761) Addded ''Projects where I am the account manager'' and ''Projects where I am the project manager'' to new campaigns and new projects notifications
|| 10/21/20 GAR 20.1.1.0  (534408) Removed PProject Change Requests lab
|| 10/22/20 RLS 20.1.1.1  (530775) Changed the verbiage in tNotification for NotificationID TASKUPDATE
|| 02/16/21 GAR 21.03.14  (546453) Changed the Chargeability Summary reports to Billable Summary.  
|| 04/07/21 RLS 21.0.5.0  (554335) Removed prjDashTeam. It wasn''t being used anywhere. Showing Teams is controlled by a system setting
|| 06/10/21 GHL 21.0.7.0  (561050) Changed the description for cm_editacctinfo to be more explicit
|| 06/22/21 AMP 21.07.18.0000 (561324) Modified the Description for ''Overdue Time Sheets'' Notification
|| 08/10/21 AMP 21.09.19.0000 (567102) Modified the description for ''Allow Access to Lists''
|| 08/18/21 RLB 21.09.19  (563856) Added ItemsToApprove To Notifications table
|| 08/23/21 AMP DEV2554   (498) - Added ''Changes in Project Settings'' to Email Notifications''
|| 09/02/21 GAR 21.10.17  (569710) Removed rights for prjDashSnapshot, dash_showsnapshot and dash_showprofit - using system settings for this
|| 09/27/21 AMP 22.01.16.0000 (569231) Added a new right called ''employee_project_time'' to allow access to the projects and time tab on the employee record
|| 09/30/21 GHL 21.11.14  (570696) Added deleteOpptyProject to delete oppty projects
|| 03/24/22 RLB 22.04.17  (592727) removed extra assignments on a notfication
|| 04/27/22 CRG 22.05.15  (574458) Added new right: adminsetup_security
|| 06/22/22 WDF 22.07.17  (602605) Moved prjEditProjectNumber from ''Platinum Specific Rights'' to ''Project Administration''
|| 06/24/22 WDF 22.07.17  (602792) Added group ''WMJ Desktop'' and moved various rights to it, moved other rights to different groups and 
||                                 changed the Description of some of the moved rights.
|| 06/30/22 RLS 22.07.24  (595958) Added new right: client_editconversations
|| 07/20/22 MCM 22.08.14  (593839) Added seed for new table tBankAccountType
|| 05/15/22 RLB 22.08.14 (598281) Added Employee notification for ToDoReminder
|| 09/13/22 RLB 22.10.16 (611729) added Employee notification for Campaign Over Budget
|| 12/05/22 RLS 23.01.15 (619626) added new right billingeditusersiapprove
|| 11/28/22 GAR 22.12.18 (615611) Added new right for RM Graphs menu dot
|| 02/07/23 RLB 23.03.19 (629182) Added Billing status notofication
|| 03/07/23 RLB 23.04.16 (630358) Added new right to edit Employee and Contact CF''s
|| 04/07/22 RLB 23.05.14 (629350) change right client_editconversations description to include change request conversations
|| 06/12/23 CRG 23.07.18 Added tTMLogService seeding
|| 06/21/23 MAS 23.07.16 Removed old media references, tMediaUnitType
|| 07/18/23 KMC 23.08.20 Added tHelpGuideLik
|| 11/09/23 CRG 23.12.17 (655963) Added new right: adminsetup_meetingrequest
|| 11/16/23 CRG 23.12.17 (644751) Changed the description of right: adminsetup_meetingrequest
|| 12/27/23 RLB 24.01.21 (658051) adding new right to add planning projects
|| 02/15/24 RLB 24.03.17 (663505) adding new right View Project Setup Billing Options
|| 04/03/24 RLB 24.05.19 (654860) created new right for new standard report Project Recap   tasks_Recap_Analysis
|| 05/30/24 GAR 24.07.14 (672150) Slightly change the names of the security rights so it''s easier to search for rights related to conversations (table in issue)
|| 06/05/24 MFT 24.07.00 (674224) Remove the " and Remove Items from Worksheets" verbiage from the billingremovefromsheet right, key 30902, and change ID to billingdeleteworksheet
|| 06/17/24 GAR 24.07.14 (672280) Added a new right - Transfer transactions to non-billable projects, changed other right to billable projects
|| 06/17/24 GAR 24.07.14 (670977) Added a new right - Approvers can View timesheets for people they approve
|| 07/01/24 MCM 24.08.x  (671239) Added new right - gl_approvejournalentry, to approve Journal Entries.  Only applies if have JEApprovalEnabled preference turned on
|| 07/02/24 GAR 24.08.18 (674308) Added a new right - Allows user to edit other people''s deliverable comments
|| 07/03/24 GAR 24.08.18 (674812) Added 2 new rights - Allows user to view custom fields on contacts and companies
|| 07/26/24 RLB 24.08.18 (653740) Added new right prjviewestimate to just view estimates
|| 08/27/24 CRG 24.09.15 (681708) Seeding tRTNActive table
|| 08/29/24 GAR 24.09.15 (681361) Added BillingManager as a contact option in UPDATESTATUS and UPDATEBILLINGSTATUS in user notifications 
|| 10/07/24 MCM 24.11.x  (676228) added a new right purch_approvevoucher to approve vendor invoices (aka voucher)
|| 01/21/25 GAR 25.02.x  (688217) Deleting the tWidget insert statements because the table definition changed.  We will add these back in once we have the new table set and widgets defined.
|| 02/17/25 AMP 25.03.16 (686463) Added new right - gl_view_journalentry, to view Journal Entries.
|| 05/28/25 RLB 25.06.15 (702747) Added new right - prjdeletespecs, to delete spec sheets.
|| 06/05/25 AMP 25.07.20 (697263) Added new rights - View Publications, View Stations
|| 07/10/25 GAR 25.08.17 (688217) Adding new seed scripts for the new project dashboard
|| 07/23/25 AMP 25.08.17 (697263) Added description to ''Edit Media Setup options'' to include Stations/Publications
|| 09/10/25 GAR 25.10.19 (710783) Adding new seed scripts for the new home dashboard
|| 10/1/25  GWG 25.10.19	      Removing the on off identity lines for widget defs (not needed).  also assigning a dash id
|| 01/12/25 RLB 26.02.15 (718213) Added new right to add or edit media plans
|| 02/10/26 CRG 26.04.19 (721964) Added new right adminsetup_automation
|| 04/09/26 GAR 26.05.17 (722428) Added new right purch_deletepo
|| 06/03/26 MCM 26.07.x  (730018) Added new right acct_view_scheduledreports
|| 06/10/26 AMP 26.07.19 (730512) Added new right - viewAPITokens
*/

/*
Script for generating level specific rights
Select ''INSERT tRightLevel(RightKey, CompanyKey, Level) Values ('' + CAST(RightKey as Varchar) + '',100,1) --'' + RightID from tRight 
*/

DELETE tRight



if @LoadBeta = 1
BEGIN

-- Media Rights
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500070, ''media_viewWorksheet'', ''View the Media Worksheet'', ''media'', ''admin'', 7, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500080, ''media_editWorksheet'', ''Edit the Media Worksheet'', ''media'', ''admin'', 8, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303305, ''media_printbuycal'', ''Media Print Buy Calendar Report'', ''reports'', ''admin'', 6040, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303306, ''media_printbuyblock'', ''Media Print Buy Block Report'', ''reports'', ''admin'', 6041, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303307, ''media_printbuygrid'', ''Media Print Buy Grid Report'', ''reports'', ''admin'', 6042, 1, '''')

END

-- change requests
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10201, ''adminsetup_changerequest'', ''---- Edit Project Change Requests'', ''admin'', ''admin'', 17, 1, ''Allows access to Admin > System Setup > Tracking > Define Project Change Requests.<br>Add/edit/delete project change request forms, set up of custom fields, create an approval process and give different security groups access to those change requests.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (970000, ''cr_viewchanges'', ''View Project Change Request Forms'', ''changes'', ''admin'', 1, 1, ''User can view change requests and linked spec sheets. This also allows the user to Cancel  Change Request, which will cancel an approval and change the change request status to Not Sent For Approval. This setting also allows the user to Add Attachments.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (970010, ''cr_addchanges'', ''Add New Project Change Request Forms to the system'', ''changes'', ''admin'', 2, 1, ''Allows user to create new change requests, only if they belong in the Selected Security Groups defined in the change request form at the system setup level.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (970020, ''cr_editchanges'', ''Edit Project Change Request Forms'', ''changes'', ''admin'', 3, 1, ''Allows user to make and Save changes to project change requests and linked spec sheets that have not been submitted.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (970030, ''cr_deletechanges'', ''Delete Project Change Request Forms'', ''changes'', ''admin'', 4, 1, ''[Delete] button is now present.'')

-- WMJ Desktop
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (111, ''menu_todayAdmin'', ''View Today Managers'', ''desktop'', ''admin'', 10, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (109, ''menu_todayPurchasing'', ''View Today Purchasing'', ''desktop'', ''admin'', 20, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (110, ''menu_todayAccounting'', ''View Today Accounting'', ''desktop'', ''admin'', 30, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (114, ''menu_todayBill'', ''View Today Billing'', ''desktop'', ''admin'', 40, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (115, ''menu_dashBill'', ''View the Billing Dashboard'', ''desktop'', ''admin'', 50, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100, ''menu_todayCreative'', ''View Today Creatives'', ''desktop'', ''admin'', 60, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (102, ''menu_todaySales'', ''View Today Sales'', ''desktop'', ''admin'', 70, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (103, ''menu_todayPM'', ''View Today PM'', ''desktop'', ''admin'', 80, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (104, ''prjViewPMDashboard'', ''View the PM Dashboard'', ''desktop'', ''admin'', 90, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (117, ''notes_view'', ''View Notes'', ''desktop'', ''admin'', 100, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (118, ''notes_edit'', ''Edit Company Notes'', ''desktop'', ''admin'', 110, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (119, ''menu_todayMedia'', ''View Today Media'', ''desktop'', ''admin'', 120, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (130, ''viewDashCreative'', ''View the Creative Graphs'', ''desktop'', ''admin'', 130, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (131, ''viewDashSales'', ''View the Sales Graphs'', ''desktop'', ''admin'', 140, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (132, ''viewDashPM'', ''View the PM Graphs'', ''desktop'', ''admin'', 150, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (133, ''viewDashPurchasing'', ''View the Purchasing Graphs'', ''desktop'', ''admin'', 160, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (134, ''viewDashBilling'', ''View the Billing Graphs'', ''desktop'', ''admin'', 170, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (135, ''viewDashAccounting'', ''View the Accounting Graphs'', ''desktop'', ''admin'', 180, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (136, ''viewDashMedia'', ''View the Media Graphs'', ''desktop'', ''admin'', 190, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (137, ''viewDashManager'', ''View the Manager''''s Graphs'', ''desktop'', ''admin'', 200, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (138, ''viewDashOwner'', ''View the Owner''''s Graphs'', ''desktop'', ''admin'', 210, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (139, ''viewDashRM'', ''View the RM Graphs'', ''desktop'', ''admin'', 155, 1, '''')



-- Platinum specific section  exec spConvertDBSeed
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (105, ''menu_todayRM'', ''View Today for Resource Managers'', ''platinum'', ''admin'', 8, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11605, ''viewLegacyFields'', ''View Legacy Fields'', ''admin'', ''admin'', 25, 1, ''This setting is used to determine if a user can view fields that have been identified as legacy.  If this setting is not enabled then fields that have been tagged as legacy, will not be visible to the user.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10100, ''adminsetup'', ''Maintain Setup Information'', ''admin'', ''admin'', 1, 1, ''This works with the first 15 options under this heading (security setting right preceded by ---- ); if you want to allow access in the following areas, you must also check this box.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10101, ''adminsetup_acctinfo'', ''---- Edit Account Information'', ''admin'', ''admin'', 2, 1, ''Allows access to Admin > System Setup > Account Information.<br>Address Information: Edit company information such as website, phone numbers, EIN and addresses.<br>Visual Appearance: Customize the culture, font for report options and application name.<br>Activation Status: Lets you view active and deactivated users.<br>Workamajig Labs: You can turn on/off the Workamajig Labs.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10117, ''adminsetup_security'', ''---- Allow Access to Security Settings'', ''admin'', ''admin'', 3, 1, ''Allows access to Admin > System Setup > System Options.<br>Security Settings: This is where you grant user rights for security groups, control password settings and control folder and file rights.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10102, ''adminsetup_globaloptions'', ''---- Allow Access to System Options'', ''admin'', ''admin'', 4, 1, ''Allows access to Admin > System Setup > System Options.<br>Transaction Preferences: Edit settings for Contact Management, Clients, Projects, Campaigns, Estimates, Time Sheets, Expense Reports, Deliverables, Purchase Orders, Media, Client and Vendor Invoices and Daily Emails.<br>Custom Menu: Create a company menu for each security group.<br>Connections: Edit your Email settings, File Storage settings, API, Single Sign on and Credit Cards.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10115, ''adminsetup_globaloptionslists'', ''---- Allow Access to Lists'', ''admin'', ''admin'', 5, 1, ''Resource Manager >Assignment Mgmt: Edit Assignment Statuses<br>Departments: Add/edit/delete departments for use in projects.<br>Offices: Add/edit/delete offices within the company.<br>Project Billing Status Codes: Add/edit/delete project billing status codes for your projects.<br>Project Status Codes: Add/edit/delete project status codes for your projects and set which statuses are active.<br>Project Templates: Setup project templates to be used to quickly create projects.<br>Project Types: Add/edit/delete the Project Types (i.e. Collateral, Events, Print, Web, etc.).<br>Report Groups: Add/edit/delete the name and display order of the Custom Report Groups (i.e. Time Analysis, Purchasing, Billing, Contact, & Sales Lead).<br>Request Reject Reasons: Set up your standard reasons for rejecting project requests.<br>Schedule Column Sets: Set up pre-defined sets of columns that can be used with the project schedule.<br>Scheduled Reports: Set up start date, end date, export type and recurrence options for scheduled reports.<br>Teams: Add/edit/delete teams for projects.<br>Timeline Segments: Add/edit/delete segment names and colors to show on the schedule and gantt view.<br>To Do Status: Add/edit/delete status codes for managing to dos.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10103, ''adminsetup_dashboard'', ''---- Edit Dashboards'', ''admin'', ''admin'', 6, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10104, ''adminsetup_GLSettings'', ''---- Edit GL Settings'', ''admin'', ''admin'', 7, 1, ''Allows access to Admin > System Setup  > GL Settings.<br>GL Tracking Options: Set up GL tracking Options, GL Accounts, Prebilled Purchase Orders and Media, Advance Sales and Purchasing Tracking, Multicurrency Tracking, Revenue Forecast Tracking and Legacy Integration.<br>GL Accounts: Add/edit/delete your general ledger accounts to track your finances.<br>GL Companies: Add/edit/delete GL companies.<br>Check Formats: Add/edit/delete check options, layouts, stub layouts and grid columns.<br>Postive Pay Layouts: Add/edit/delete header fields, detail fields and footer fields for positive pay layouts.<br>Corporate Profit and Loss Layout: Allows you to create custom layouts for financial reporting.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10105, ''adminsetup_CM'', ''---- Edit Contact Management options'', ''admin'', ''admin'', 8, 1, ''Allows access to Admin > System Setup > Contact Management.<br>Add/edit/delete Opportunity Stages, Opportunity Status and Opportunity Outcomes.<br>Company Types: Add/edit/delete the defined company types; default company types have been set up.<br>Meeting Types: Add/edit/delete the defined calendar event types, and what color it will show up as on the calendar.<br>Calendar Resources: Add/edit/delete the defined calendar resources, like conference room and projector.<br>Define Source: This is used to identify how the relationship with a Lead or a Company is initially formed. You can add/edit/delete your sources here.<br>Conversation Types: Add/edit/delete the defined conversation types and set display colors.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10106, ''adminsetup_timeoptions'', ''---- Edit Time options'', ''admin'', ''admin'', 9, 1, ''Allows access to Admin > System Setup > Billing Options > Time Tracking.<br>Services: Add/edit/delete the different types of services in the system, this includes the service code, description, active status and hourly rate.<br>Service Rate Sheets: This is where you can set up special rates for services and added/edit/delete those rate sheets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10107, ''adminsetup_media'', ''---- Edit Media Setup options'', ''admin'', ''admin'', 10, 1, '' Allows access to Admin > System Setup > Media.<br>Broadcast Items: Add/edit/delete the different broadcast items in the system.<br>Print Items: Add/edit/delete the different print item types in the system.<br>Markets: Add/edit/delete the Media Markets used to define regions for media buying.<br>Revision Reasons: Add/edit/ delete the reasons why media had to be revised.<br>Publication/Station Items: Add/edit/delete the different publication and station items in the system.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10108, ''adminsetup_specsheet'', ''---- Edit Spec Sheets'', ''admin'', ''admin'', 11, 1, ''Allow access to Admin > System Setup > Tracking > Define Spec Sheets.<br>Add/edit/delete project spec sheets, define the fields and customize the spec sheets. The default spec sheets in the system are Photography, Printing, and Publication Specs and they can be attached to projects throughout the system.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10109, ''adminsetup_projrequest'', ''---- Edit Project Requests'', ''admin'', ''admin'', 12, 1, ''Allows access to Admin > System Setup > Tracking > Define Project Requests.<br>Add/edit/delete project request forms, set up of custom fields, add spec sheets, create an approval process and give different security groups access to those requests.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10110, ''adminsetup_forms'', ''---- Edit Tracking Forms'', ''admin'', ''admin'', 13, 1, ''Allows access to Admin > System Setup > Tracking > Define Tracking Forms|, gives the right to add/edit/delete forms, including the right to define the options and fields associated with the form and give access to the forms.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10111, ''adminsetup_purchasing'', ''---- Edit Purchasing Options'', ''admin'', ''admin'', 14, 1, ''Allows access to Admin > System Setup > Purchasing.<br>Order Header Customization: Define the blocks of text that will appear at the top or bottom of POs, add/edit/delete PO header field groups and add/edit/delete purchase order types.<br>Order Line Customization: Add/edit/delete PO detail field groups.<br>Purchasing: Add/edit/delete expense report items, purchase items and item rate sheets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10112, ''adminsetup_da'', ''---- Edit Digital Assets Options'', ''admin'', ''admin'', 15, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10113, ''adminsetup_custfields'', ''---- Edit and Assign Custom Fields'', ''admin'', ''admin'', 16, 1, ''Allows access to Admin > System Setup > Custom Fields.<br>Custom Fields provides the ability to add customized input and reporting fields to key parts of the system. This setting allows access to setup company-wide custom fields that show up in the designated areas of your system for the following:<br>Employee Fields<br>Company Fields<br>Contact Fields<br>Project Fields<br>Campaign Fields<br>Retainer Fields<br>Conversation Fields<br>Opportunity Fields.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10114, ''adminsetup_glcompanyaccess'', ''---- Edit GL Company Access'', ''admin'', ''admin'', 17, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10116, ''adminsetup_billing'', ''---- Edit Billing options'', ''admin'', ''admin'', 18, 1, ''Allows access to Admin > System Setup > Billing Options > Billing Options.<br>Billing Items: Add/edit/delete the billing items in the system, set the default sales account, active status, etc.<br>Billing Groups: Add/edit/delete billing groups.<br>Sales Tax Rates:  Add/edit/delete the sales tax rates.<br>Payment Terms: Add/edit/delete the payment terms and corresponding days until an invoice is due.<br>Payment Methods: Add/edit/delete the accepted methods of payment for the company.<br>Write Off Reasons: Add/edit/delete the write off reasons.<br>Invoice Layouts: Add/edit/delete the invoice layouts. You can decide on how a particular invoice layout will print, where you set the margins, addresses to show, fonts, logos, etc.<br>Estimate Layouts: Add/edit/delete the estimate layout and determine how a particular estimate layout will print.<br>Credit Card Processing. the right to set up credit card processing.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10118, ''adminsetup_meetingrequest'', ''---- Edit Meeting Custom Fields'', ''admin'', ''admin'', 12, 1, ''Allows access to Meeting custom fields'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10200, ''admineditinout'', ''Edit Other Peoples In / Out Status'', ''admin'', ''admin'', 19, 1, ''Give access to change anyones status on the In/Out board (must have access to view and edit the in/out widget to see this right).'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10600, ''adminemployee'', ''Maintain Company Employees'', ''admin'', ''admin'', 20, 1, ''Allows access to Admin > Employees and the ability to Add New Employees and Delete Employees.  Can only see and edit Basic Info page and Notifications page.  Has access to the Actions: Reassign Assignments/ Assign to All Projects / Assign to All Active Projects / Assign to All Inactive Projects, but will not be able to reassign assignments unless you have those rights as well.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10610000, ''admin_edit_employee_contact_cf'', ''Edit Employee and Contact Custom Fields'', ''admin'', ''admin'', 21, 1, ''Allows access to Custom Field tab in Employees and Contacts. Must also have Maintain Company Employees checked to view this area.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10620, ''adminuserconvert'', ''Convert Contact to Employee or Employee to Contact'', ''admin'', ''admin'', 22, 1, ''Allows user to convert a Contact to an Employee or an Employee to a Contact.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10700, ''admineditlogin'', ''Edit Employee and Contact Login information'', ''admin'', ''admin'', 23, 1, ''Allows access to Security Controls/Login information tab in Employees and Contacts.  Must also have Maintain Company Employees checked to view this area.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10720, ''user_billing'', ''Edit Employee and Contact Accounting Information '', ''admin'', ''admin'', 24, 1, ''Allows access to Accounting tab in employees and Contacts. Must also have Maintain Company Employees checked to view this area.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10730, ''employee_project_time'', ''Edit Employee Projects and Time Information'', ''admin'', ''admin'', 25, 1, ''Allows access to Projects and Time tab on the Employee record. Must also have Maintain Company Employees checked to view this area.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10750, ''adminviewcostrate'', ''View labor net cost per hour in lookups and reports'', ''admin'', ''admin'', 26, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10800, ''adminedituserskills'', ''Maintain User Skill Levels'', ''admin'', ''admin'', 27, 1, ''Allows user access to view and edit in the Skill tab in employee records. Must also have Maintain Company Employees checked to view this area.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10805, ''admineditusercalendar'', ''Maintain Employee Calendar '', ''admin'', ''admin'', 28, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11200, ''reportsdesign'', ''Design custom reports'', ''admin'', ''admin'', 29, 1, ''Everyone > Reports (also need security rights in Reports). No Datasets available to create custom reports from when clicking on +New Custom Report.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11300, ''reportsrun'', ''Run custom reports'', ''admin'', ''admin'', 30, 1, ''Everyone > Reports. Access to Other Reports which is where custom reports reside.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11400, ''dataexchange'', ''Import and export data'', ''admin'', ''admin'', 31, 1, ''Admin > Import Data. This allows them to do any kind of data importing in the system.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11500, ''admineditlisting'', ''Edit Custom Listings'', ''admin'', ''admin'', 32, 1, ''Gives users the rights to Modify and Memorize (ex. on Project or Estimate listing screens).'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11601, ''adminViewLog'', ''View the System Log'', ''admin'', ''admin'', 33, 1, ''Admin > Today-Managers > System Log. This is the log of what has been approved, unapproved, posted, unposted or deleted in the system. Only if you selected Enable Transaction Logging in your Transaction Preferences.  You cannot view or open any of these items, but you can see what was done, by whom and when.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11602, ''adminActivateMyLabs'', ''Allow a person to enable labs just for themselves'', ''admin'', ''admin'', 34, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11603, ''adminDisplayNonProjectLogs'', ''View Non Project Log '', ''admin'', ''admin'', 35, 1, ''Allows a person to view non project related events on The Daily Feed.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (601000, ''desktopEditSetup'', ''Edit the company settings for the desktop'', ''admin'', ''admin'', 36, 1, ''Makes Company Settings available in Configure Desktop options allowing the user to create/edit/delete desktop views for any security group in the company. The security group must also have the right to change Their Desktop Layout or they will not be able to get to the Configure Desktop at all.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11606, ''adminChangeBillingTitle'', ''Edit Employee Billing Title'', ''admin'', ''admin'', 37, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (108, ''adminUserSettings'', ''Set System Settings'', ''admin'', ''admin'', 38, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (106, ''menu_reportCenter'', ''View the Report Center'', ''admin'', ''admin'', 39, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (116, ''adminsetup_scheduleReports'', ''Schedule Reports'', ''admin'', ''admin'', 40, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10210, ''adminsetup_automation'', ''Edit Automation'', ''admin'', ''admin'', 41, 1, ''Allows access to Admin > System Setup > Automation<br>Add/edit/delete automations.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (11700, ''viewAPITokens'', ''View API Tokens'', ''admin'', ''admin'', 42, 1, ''Allows users to access the API User Token and the API Company Token'')



INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (101, ''menu_myProjects'', ''View Projects App'', ''project'', ''admin'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90100, ''adminCreateProject'', ''Create New Projects'', ''project'', ''admin'', 10, 1, ''Allows access to project listings for those projects the user is assigned to and to create a New project in the system (but cannot see that new project unless they have other rights as well). User who created new project is automatically assigned to the project team.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90200, ''prjInfo'', ''Maintain Project Setup'', ''project'', ''admin'', 20, 1, ''Allows the user access to Project Setup > Project Settings (user access in these areas may be limited by other security settings).'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (903510, ''prjReopen'', ''Reopen Projects'', ''project'', ''admin'', 30, 1, ''Allows users to reopen Projects if they have this right on Projects > Setup > Project Settings > Accounting: they see a box next to Closed and they can close or open a project.  If it is not checked, they just see yes if it is closed, if it is not closed, there is a check box and they could close a project, then not have rights to re-open it. Must also have access to Maintain Project Setup.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90310, ''prjviewtasks'', ''View Task, Schedule Pages'', ''project'', ''admin'', 40, 1, ''Gives the user access to the Schedule tab in the project, but there are no options to add/edit or save.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90355, ''prjeditmastertaskdefs'', ''Edit Master Task defaults on task'', ''project'', ''admin'', 50, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90810, ''prjEditLocked'', ''Edit Projects in a Locked Status'', ''project'', ''admin'', 60, 1, ''There is a setting on a Project Status Codes that lets you put the project into a Locked Status. When a project is in this status you can not change the project status unless you have this right.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (107, ''prjEditProjectNumber'', ''Edit an existing Project Number'', ''project'', ''admin'', 65, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90315, ''prjviewbudget'', ''View Project Budget Page'', ''project'', ''admin'', 70, 1, ''Allows the user to view the Project Budget screen as well as view project budgets on the Campaign screen.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90320, ''prjedittasks'', ''Edit task information'', ''project'', ''admin'', 80, 1, ''User can edit tasks in the schedule and is granted access to all Detail tabs in the schedule screen (but not if schedule is locked and the user does not have the right  Override Scheduling Lock to Edit Projects in a Locked Status by Override).'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90850, ''prjUnlockLocked'', ''Override Scheduling Lock'', ''project'', ''admin'', 90, 1, ''Allows user to Unlock a schedule.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90335, ''prjeditestimaterates'', ''Edit Rates on Estimates'', ''project'', ''admin'', 100, 1, ''Must have Edit Estimate Information checked to view this.  Allows user to click on the pencil icon for Estimating Services/Edit Service Rates on new or unapproved estimates (this includes a persons rate if doing a task/person estimate), but it only effects that project.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90336, ''prjrecalcrates'', ''Update Estimate Rates from Project'', ''project'', ''admin'', 110, 1, ''Must have Edit Estimate Information checked to view this, and the right to Edit Rates on Estimates.  Allows user to update the Estimating Services/Edit Service Rates on a new or unapproved estimate, and to Set Standard Rates pulling from Service Rates setup at the system level. '')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90337, ''prjrecalclaborrates'', ''Recalculate Labor Rates on Project'', ''project'', ''admin'', 111, 1, ''This will update the rate on unbilled time entries on a project from rates and settings defined on the project.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90330, ''prjeditestimate'', ''Edit Estimate Information'', ''project'', ''admin'', 120, 1, ''Must have this checked to get to the above 2 rights.  When checked you can view Project Central > Estimates, add new estimates, set approver on a new estimate, make changes to hours on unapproved estimates only and add expenses on unapproved estimate only.  If someone else approved the estimate, they cannot unapprove it.  They see Edit Service Rates but this only allows them to limit services available to put on the estimate, not change the rate offered for the service on that project.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90338, ''prjviewestimate'', ''View Estimate Information'', ''project'', ''admin'', 112, 1, ''When checked a PDF will be created of the estimate'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (1190930, ''prjnotes'', ''Access Project Conversations'', ''project'', ''admin'', 130, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (1190931, ''prjnotesedit'', ''Edit own Project Conversations'', ''project'', ''admin'', 140, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90922, ''prjEditOthersDiary'', ''Edit other peoples Project Conversations'', ''project'', ''admin'', 150, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (903500, ''adminDeleteProject'', ''Delete a Project'', ''project'', ''admin'', 160, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (112, ''adminsetup_templates'', ''Edit Project Templates'', ''project'', ''admin'', 165, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90600, ''prjviewcreativebrief'', ''View the Creative Brief'', ''project'', ''admin'', 170, 1, ''On the project dashboard.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90350, ''prjeditcreativebrief'', ''Edit the Creative Brief'', ''project'', ''admin'', 180, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90700, ''prjviewspecs'', ''View the Project Specifications'', ''project'', ''admin'', 190, 1, ''View only access to any attached spec sheets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90360, ''prjeditspecs'', ''Edit the Specifications'', ''project'', ''admin'', 200, 1, ''Allows user to add/edit spec sheets and Copy spec sheets from another project, must have the right to View the Project Specifications.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90365, ''prjdeletespecs'', ''Delete a Specification'', ''project'', ''admin'', 205, 1, ''Allows user to delete spec sheets, must have the right to View the Project Specifications.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90370, ''prjMiscExpense'', ''Add and Edit Misc Expenses'', ''project'', ''admin'', 210, 1, ''Grants access for Project Details > Misc Costs.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90340, ''prjunappestimate'', ''Unapprove estimate or change order '', ''project'', ''admin'', 220, 1, ''User can unapproved an estimate that had already been approved by the designated Internal Approver.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20100, ''approveadd'', ''Edit/Add Deliverables'', ''project'', ''admin'', 230, 1, ''Allow access in Project Central > Deliverables. User can setup a new review, update existing reviews and recall reviews previously sent for approval.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20200, ''approveview'', ''View Deliverables'', ''project'', ''admin'', 225, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20300, ''approvedelete'', ''Delete Deliverables'', ''project'', ''admin'', 240, 1, ''Allows user to delete an existing deliverable, whether it has been reviewed or not.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20400, ''approveeditcomment'', ''Edit Other People''''s Deliverable Comments'', ''project'', ''admin'', 245, 1, ''Allows user to edit another user''''s deliverable comments.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90905, ''prjViewTran'', ''View Project Transactions'', ''project'', ''admin'', 250, 1, ''This only allows a view of the Project Transaction screen.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90906, ''prjViewTranAdjusted'', ''View Project Adjusted Transactions'', ''project'', ''admin'', 251, 1, ''This allows a view of the adjusted transactions on the Project Transaction screen. Adjustments include transfers, transactions edited after posting to WIP and writeoffs undone after posting out of WIP. Users who do not have this right, can only see the most current transactions, i.e. no original or reversed transactions.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90900, ''prjViewCampaign'', ''View Campaigns'', ''project'', ''admin'', 260, 1, ''User can view a Campaign Listing from Projects.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90800, ''prjEditCampaign'', ''Edit Campaigns'', ''project'', ''admin'', 270, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90901, ''prjEditTeam'', ''Edit the Project Team'', ''project'', ''admin'', 280, 1, ''User can add and delete team members from the Project Setup > Team tab.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90911, ''prjDashStatus'', ''View the current status on the project dashboard'', ''project'', ''admin'', 290, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90912, ''prjDashDescription'', ''View the project description on the project dashboard'', ''project'', ''admin'', 300, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90913, ''prjDashSetup'', ''View the setup information on the project dashboard'', ''project'', ''admin'', 310, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90914, ''prjDashBrief'', ''View the creative brief on the project dashboard'', ''project'', ''admin'', 320, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90915, ''prjDashSpecs'', ''View the spec sheets on the project dashboard'', ''project'', ''admin'', 330, 1, '''')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90917, ''prjDashSnapshot'', ''View the project snapshot on the project dashboard'', ''project'', ''admin'', 350, 1, ''Must also have the security right setting under Dashboard for View the Project Snapshot.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90918, ''prjAccessAny'', ''Access any project'', ''project'', ''admin'', 360, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90919, ''prjChargeAny'', ''Charge any project'', ''project'', ''admin'', 370, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90923, ''prjViewRevenueSource'', ''View Project Revenue Source'', ''project'', ''admin'', 400, 1, ''This setting controls where the system looks to get the GL Company and Office for labor revenue. It can either get the company/office from the Project or the Person. If you select the person and if you use multiple GL companies, then you need to have intercompany journal entry mappings set up.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90924, ''prjViewSetupAccounting'', ''View Project Setup Accounting'', ''project'', ''admin'', 410, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90925, ''prjDashCustomFields'', ''View the Project Custom Fields'', ''project'', ''admin'', 420, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90930, ''prjViewToDos'', ''View To Dos'', ''project'', ''admin'', 430, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90931, ''prjEditToDos'', ''Add/Edit To Dos'', ''project'', ''admin'', 440, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90932, ''prjDeleteToDos'', ''Delete To Dos'', ''project'', ''admin'', 450, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90933, ''prjViewOtherToDos'', ''View To Dos Not Assigned To You'', ''project'', ''admin'', 460, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90934, ''prjEditOtherToDos'', ''Edit To Dos Not Assigned To You'', ''project'', ''admin'', 470, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90935, ''prjQuickAddTask'', ''Use Quick Task Add without being able to edit the schedule'', ''project'', ''admin'', 480, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90936, ''prjQuickAddActivity'', ''Use Quick Activity Conversation Add without being able to edit the schedule'', ''project'', ''admin'', 481, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90937, ''prjChangeAnyoneCharges'', ''Change Anyone Allowed to Charge Time on project'', ''project'', ''admin'', 371, 1, ''If you have this right the checkbox ''''Anyone Allowed to Charge Time'''' will become visible on the Project Accounting screen allowing changes to it.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90938, ''adminCreatePlanningProject'', ''Create New Planning Projects'', ''project'', ''admin'', 482, 1, ''Allows access to project listings for those projects the user is assigned to and to create a New planning project in the system (but cannot see that new project unless they have other rights as well). User who created new planning project is automatically assigned to the project team.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90939, ''prjViewBillingOptions'', ''View Project Setup Billing Options'', ''project'', ''admin'', 483, 1, ''Allows access to project setup billing options.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30000, ''billingviewclientinvoice'', ''View Client Invoices'', ''billing'', ''admin'', 1, 1, ''Allows access in Billing to view the Client Invoices.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30101, ''billingviewinvoice'', ''View the Invoice List '', ''billing'', ''admin'', 2, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30100, ''billingeditinvoice'', ''Add and Edit Client Invoices and Credits'', ''billing'', ''admin'', 3, 1, ''This grants the right to bill projects. If it is not turned on, the security group will not see any options related to billing. Allows access to Billing > Client Invoices to view existing invoices and create new. Also allows user access to electronic Billing Worksheets to Generate, Reassign, Approve, and Create Invoices from the billing worksheet. User can also do Fixed Fee Billing and Mass Billing for Production, Media, and Retainers.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30200, ''billingpayments'', ''Enter Receipts'', ''billing'', ''admin'', 4, 0, ''Allows access to Receipts (this option also shows Deposit, but there is not actually access to that screen).'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30300, ''br_viewarreports'', ''-- View AR Reports --'', ''reports'', ''admin'', 4000, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30310, ''br_viewapreports'', ''-- View AP Reports --'', ''reports'', ''admin'', 5000, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30320, ''br_viewglfinancial'', ''-- View Company Financial Reports --'', ''reports'', ''admin'', 7000, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30330, ''br_viewmedia'', ''-- View Media Reports --'', ''reports'', ''admin'', 6000, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30700, ''billingdeposits'', ''Edit Deposit Slips'', ''billing'', ''admin'', 5, 0, ''Allows access to Deposits.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30800, ''billingcreditcard'', ''Edit and Charge Credit Cards'', ''billing'', ''admin'', 6, 0, ''Must also have System Setup in Time and Billing for Credit Card Processing in order to activate the Credit Card tab for receipts.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30900, ''billingretainers'', ''Edit Retainers'', ''billing'', ''admin'', 7, 1, ''Must have the right to View Retainers in order to setup and view details of how a Retainer is defined. This also allows access to the Status tab showing retainer history and performance.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30901, ''billingviewretainers'', ''View Retainers'', ''billing'', ''admin'', 8, 1, ''This only allows a view of the listing screen for Retainers.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30902, ''billingdeleteworksheet'', ''Delete Worksheets'', ''billing'', ''admin'', 9, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30903, ''billingedittran'', ''Edit Transactions on Projects'', ''billing'', ''admin'', 10, 1, ''Allows access to Billing > Time and Materials and The Project Transactions screen.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30904, ''billingaddtran'', ''Add Transactions to Worksheets'', ''billing'', ''admin'', 11, 1, ''Allows transactions to be added to a billing worksheets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30905, ''billingtransfertran'', ''Transfer Transactions to Billable Projects'', ''billing'', ''admin'', 12, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30906, ''billingwriteofftran'', ''Write Off Transactions'', ''billing'', ''admin'', 14, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30907, ''billingunwriteofftran'', ''Undo Write-off Transactions'', ''billing'', ''admin'', 15, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (30908, ''billingtransfertrannonbillable'', ''Transfer Transactions to Non Billable Projects'', ''billing'', ''admin'', 13, 1, '''')

-- Removed - issue #569710
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (40400, ''dash_showsnapshot'', ''View the Project Snapshot'', ''dashboard'', ''admin'', 1, 1, ''Must also have the Project Administration right to View the project snapshot on the project dashboard.'')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (40500, ''dash_showprofit'', ''View the Profit Snapshot'', ''dashboard'', ''admin'', 2, 1, ''Allows the user to view Project Profitability from the Project Dashboard. User must also have the right to Reports > Project Profitability, AND the Project Administration right to View the project snapshot on the project dashboard.'')


INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (50100, ''fileAccess'', ''Access the File Folders'', ''file'', ''admin'', 1, 1, ''Grants full access to Files managed through Project Central.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (50110, ''fileSearchAll'', ''Search in projects you are not assigned to'', ''file'', ''admin'', 2, 1, ''In order to view files in projects that this user is not assigned to, security rights must be granted to this group within the project where the file resides.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60100, ''purch_editpo'', ''Add and Edit Purchase Orders'', ''purch'', ''admin'', 2, 1, ''Allows access in Purchasing to add and edit Purchase Orders.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60101, ''purch_deletepo'', ''Delete Purchase Orders'', ''purch'', ''admin'', 3, 1, ''Allows access in Purchasing to delete Purchase Orders.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60200, ''purch_editpo_approved'', ''Edit Purchase Orders after Approval'', ''purch'', ''admin'', 4, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60300, ''purch_editvoucher'', ''Add and Edit Vendor Invoices'', ''purch'', ''admin'', 4, 1, ''Allows access in Purchasing to add and edit Vendor Invoices.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60301, ''purch_viewvoucher'', ''View Vendor Invoices'', ''purch'', ''admin'', 4, 1, ''Allows access in Purchasing to view the Vendor Invoices.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60302, ''purch_viewpo'', ''View Purchase Orders'', ''purch'', ''admin'', 4, 1, ''Allows access in Purchasing to view Purchase Orders.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60305, ''purch_approvevoucher'', ''Approve Vendor Invoices'', ''purch'', ''admin'', 4, 1, ''Allows access in Purchasing to approve Vendor Invoices.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60400, ''purch_usecreditcard'', ''Add and Edit credit card charge entry screens'', ''purch'', ''admin'', 5, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60401, ''purch_addothercreditcardcharge'', ''Add credit card charges for other employees'', ''purch'', ''admin'', 6, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60402, ''purch_editothercreditcardcharge'', ''Edit credit card charges of other employees'', ''purch'', ''admin'', 7, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60403, ''purch_approvecreditcardcharge'', ''Approve credit card charges'', ''purch'', ''admin'', 7, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60500, ''purch_usecreditcardconnect'', ''View and use the credit card connect screen'', ''purch'', ''admin'', 3, 1, ''Allows access to the Credit Card Connector screen.  From there you can download and apply credit card transactions.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (60501, ''purch_viewcreditcard'', ''View credit card charge entry screens'', ''purch'', ''admin'', 5, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61100, ''quote_edit'', ''Add and Edit Quotes'', ''purch'', ''admin'', 8, 1, ''Allows access to Purchasing > Quotes.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61200, ''quote_createpo'', ''Create PO''''s from Quotes'', ''purch'', ''admin'', 1, 1, ''Allows access to Purchasing > Quotes with access to the [Create PO] button in the Replies tab for Replies Completed. Must have the right to Add and Edit Quotes.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61300, ''purch_editpayment'', ''Add and Edit Payments'', ''purch'', ''admin'', 9, 0, ''Allows user access add and edit payments, to Select Invoices for Payment and to Print Checks.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61400, ''purch_viewiteminfo'', ''View Cost and Rate on Item Lookup '', ''purch'', ''admin'', 10, 1, ''Allows the user to see Unit Cost and Unit Rate setup for Purchase Items.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61500, ''purch_editsignatureoncheck'', ''Edit Electronic Signature on Checks'', ''purch'', ''admin'', 11, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61600, ''purch_printchecks'', ''Print Checks'', ''purch'', ''admin'', 12, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61700, ''purch_approvemyprojectvoucher'', ''Approve vendor invoices on your projects'', ''purch'', ''admin'', 13, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61800, ''purch_viewbankinfo'', ''View vendor bank information'', ''purch'', ''admin'', 14, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (61900, ''purch_editbankinfo'', ''Edit vendor bank information'', ''purch'', ''admin'', 15, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (70100, ''formuse'', ''Use forms'', ''form'', ''admin'', 1, 1, ''Allows access to Menu > Tracking forms for any tracking forms that their security group is assigned, but they cannot do anything else, unless they have the following rights; Add New Forms, View Forms or Delete Forms.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (70200, ''formadd'', ''Add new forms'', ''form'', ''admin'', 2, 1, ''Allows access to Menu > Tracking forms for any tracking forms that their security group is assigned to. The user can open a form > Add New and fill out that form. But once the form is saved, they will not be able to do anything else to it unless assigned to their self. The Assigned To field is required, if the user assigns it to someone other than themself, they will only have access as other security rights allow.'')
	
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (70300, ''formdelete'', ''Delete forms'', ''form'', ''admin'', 3, 1, ''Allows access to any tracking forms that the security group is assigned the right to Delete a form they created.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (70400, ''formviewall'', ''View forms not assigned to the user'', ''form'', ''admin'', 4, 1, ''Allows access to View any tracking forms that the security group is NOT assigned to. The user can re-open and Delete a form they created, but cannot Delete a form assigned to them that was authored by another user.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (70500, ''nonauthorformdelete'', ''Delete form if not author'', ''form'', ''admin'', 5, 1, ''If the user has the right to view forms not assigned to them, this allows the right to Delete a form they created, AND to re-open and Delete forms created by another user.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90300, ''prjviewprojectreports'', ''-- View Project Financial Reports --'', ''reports'', ''admin'', 2000, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100100, ''billingusetimesheet'', ''Use Time Sheets'', ''time'', ''admin'', 1, 1, ''Allows access to Time Sheets from main Menu dropdown.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100110, ''time_editratelevel'', ''Edit the rate level on the time sheet'', ''time'', ''admin'', 2, 1, ''Allows access to Time Sheets > Options > Show Rate Level > once that is checked, they can change their rate level from Level 1, to 2, 3, 4, 5, but cannot actually change the amount of those rates, that is an admin right.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100120, ''timeallservices'', ''Charge time to any service'', ''time'', ''admin'', 3, 1, ''This will make all services that are setup in the system available for the user to charge time against.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100130, ''timealltasks'', ''Charge time to tasks they are not assigned to'', ''time'', ''admin'', 4, 1, ''Allows the user to charge time to any tracking task whether assigned or not.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100950, ''timetotasksnocompletedpreds'', ''Charge time to tasks that do not have completed predecessors'', ''time'', ''admin'', 5, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90920, ''prjTimeCompletedTask'', ''Charge time to completed tasks'', ''time'', ''admin'', 6, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90921, ''prjExpenseCompletedTask'', ''Charge expense to completed tasks'', ''time'', ''admin'', 7, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100300, ''billingtimesheetrate'', ''View rates on the time sheet'', ''time'', ''admin'', 8, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100400, ''billingviewalltime'', ''View anyone''''s time sheet'', ''time'', ''admin'', 9, 1, ''Allows access to view other people''''s time sheets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100500, ''billinguseexpenses'', ''Use Expenses'', ''time'', ''admin'', 10, 1, ''The right to create and submit expense reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100700, ''billingviewallexpense'', ''View anyone''''s expense report'', ''time'', ''admin'', 11, 1, ''Right to view other peoples expense reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100800, ''billingeditanyone'', ''Edit Time Sheets and Expense Reports for anyone'', ''time'', ''admin'', 12, 1, ''Allows access to open, view and edit other peoples expense reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100801, ''billingeditusersiapprove'', ''Approvers can edit timesheets for people they approve'', ''time'', ''admin'', 13, 1, ''Allows users to edit timesheets for people under their approval.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100802, ''billingviewusersiapprove'', ''Approvers can view timesheets for people they approve'', ''time'', ''admin'', 14, 1, ''Allows users to view timesheets for people under their approval.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100900, ''billingtimesheetunapprove'', ''Unapprove the time sheets'', ''time'', ''admin'', 15, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (100905, ''billing_expenserptapproveimported'', ''Import Expense Reports as Approved'', ''time'', ''admin'', 16, 1, ''Allows user to import expense reports as approved when user does not have the ability to approve individual expense report.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (110300, ''traffic_viewschedule'', ''View Project Schedules'', ''traffic'', ''admin'', 1, 1, ''Allows access to Resource Manager > Traffic Calendar. Must also have Project Administration rights to View Task and Schedule pages.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (110900, ''traffic_viewstaff'', ''View Staff Scheduling and Loading'', ''traffic'', ''admin'', 2, 1, ''Allows access to Resource Manager > Staff Schedule. The Staff Schedule screen provides an overview of resource allocations.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (110950, ''traffic_viewassignment'', ''Traffic Assignment Review'', ''traffic'', ''admin'', 3, 1, ''Allows access to Project Manager > Today-PM > Views > Assignments. This provides a listing of assignments with filtering options and the ability to select and update Complete Dates for multiple assignments at once.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (110960, ''traffic_assignmentMgt'', ''Traffic Assignment Management Screen'', ''traffic'', ''admin'', 4, 1, '''')


INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200100, ''proj_projectsummary'', ''Project Budget Analysis'', ''reports'', ''admin'', 2010, 1, ''Access to the Project Budget Analysis, which allows the user to view project budget drilldowns in summary or detail (by Project, Task, or Item) against the actuals.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200101, ''proj_projectscoreboard'', ''Project Summary Scoreboard'', ''reports'', ''admin'', 2011, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200200, ''time_productivity'', ''Time Productivity Analysis'', ''reports'', ''admin'', 2020, 1, ''Show total billable and non-billable hours with multiple grouping options.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200300, ''proj_billingworksheet'', ''Billing Worksheet Report'', ''reports'', ''admin'', 2200, 1, ''Shows all unbilled transactions by project. When this is selected for Project Financial Reports, it is also avialable for run in the AR Report Center'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200400, ''proj_projectpo'', ''Project Purchase Order Listing'', ''reports'', ''admin'', 2300, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200500, ''time_billablesummary_hours'', ''Billable Summary - Hours'', ''reports'', ''admin'', 2100, 1, ''Shows chargeable, non-chargeable and total hours with labor budget comparison.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200600, ''time_billablesummary_dollars'', ''Billable Summary - Dollars'', ''reports'', ''admin'', 2120, 1, ''Shows chargeable, non-chargeable and total dollars with labor budget comparison.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (200700, ''proj_actualsbymonth'', ''Project Actuals by Month'', ''reports'', ''admin'', 2121, 1, ''Shows actuals per project with a 12-month view and the amount billed.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300000, ''rpt_trafficreports'', ''--  View Traffic Reports --'', ''reports'', ''admin'', 3000, 1, ''These settings are limited to access through the main Menu > Reports, and not through the Projects module'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300100, ''proj_projectstatus'', ''Project Status'', ''reports'', ''admin'', 3100, 1, ''This Summary report shows project status, estimated and actual hours.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300200, ''tasks_byUser'', ''Project Tasks by Person'', ''reports'', ''admin'', 3200, 1, ''Shows all tasks by assigned user.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300300, ''tasks_byUserDate'', ''Project Tasks by Person and Date'', ''reports'', ''admin'', 3300, 1, ''Shows all tasks by assigned user within a date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300400, ''tasks_byDate'', ''Project Tasks by Date'', ''reports'', ''admin'', 3400, 1, ''Shows all tasks by specified due date.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300500, ''tasks_setup'', ''Project Setup'', ''reports'', ''admin'', 3500, 1, ''Shows Schedule information for one or more projects.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300600, ''tasks_gantt'', ''Project Gantt Charts'', ''reports'', ''admin'', 3600, 1, ''Project Timeline shows Gantt Chart view of schedule for one or more projects.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (300655, ''tasks_Recap_Analysis'', ''Project Recap Analysis'', ''reports'', ''admin'', 3700, 1, ''This report is designed to highlight sections of the projects schedule where labor dollars and hours are concerned. Along with how long it took to complete each task.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303301, ''media_recap'', ''Media Recap'', ''reports'', ''admin'', 6010, 1, ''Shows media orders with net and gross amounts, grouped by month and by client.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303302, ''media_discrepancy'', ''Media Details Report'', ''reports'', ''admin'', 6020, 1, ''Shows media order variances from actual vendor invoice with multiple grouping options.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303303, ''media_mixanalysis'', ''Media Mix Analysis'', ''reports'', ''admin'', 6030, 1, ''Shows media types for the year by quarter with mix percentage, grouped by client.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303304, ''media_billing'', ''Media Billing Report'', ''reports'', ''admin'', 6031, 1, '''')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303305, ''media_printbuycal'', ''Media Print Buy Calendar Report'', ''reports'', ''admin'', 6040, 1, '''')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303306, ''media_printbuyblock'', ''Media Print Buy Block Report'', ''reports'', ''admin'', 6041, 1, '''')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (303307, ''media_printbuygrid'', ''Media Print Buy Grid Report'', ''reports'', ''admin'', 6042, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (400100, ''acct_ar_aging'', ''AR Account Aging'', ''reports'', ''admin'', 4010, 1, ''Shows all accounts receivable with open balances and aging.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (401000, ''usereports'', ''View the reports menu'', ''reports'', ''admin'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (401100, ''rptViewCMReports'', ''-- View Contact Management Reports --'', ''reports'', ''admin'', 1000, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (401200, ''rptCMBusDev'', ''Business Development Meeting'', ''reports'', ''admin'', 1001, 1, ''The business development report follows the WWP methodology. It shows a summary count of contacts at different levels to better understand trends. It also includes a summary of late stage opportunities as well as activities that need to get completed.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (401300, ''rptCMDownOpps'', ''Downgraded Opportunities'', ''reports'', ''admin'', 1002, 1, ''Shows opportunities that have been downgraded due to a number of different criteria such as a delay in close date, reduced forecast amounts and more.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500010, ''media_editio'', ''Edit Insertion Orders'', ''media'', ''admin'', 4, 1, ''Allows full access to Insertion Orders: Order Info, Address/Instructions, Order Line Items, Vendor and Client Invoices, and Linked Specifications. User can also Send Order Copies to Selected Contacts.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500011, ''media_editio_approved'', ''Edit Insertion Orders after Approval'', ''media'', ''admin'', 5, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500020, ''media_editbc'', ''Edit Broadcast Orders'', ''media'', ''admin'', 6, 1, ''Allows full access to Broadcast Orders: Order Info, Address/Instructions, Order Line Items, Traffic, Vendor and Client Invoices, and Linked Specifications. User can also Send Order Copies to Selected Contacts.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500021, ''media_editbc_approved'', ''Edit Broadcast Orders after Approval'', ''media'', ''admin'', 7, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500030, ''media_editestimate'', ''Edit Media Estimates'', ''media'', ''admin'', 2, 1, ''Allows user access to Media Estimates, where they can add and edit estimates and Update Orders.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500035, ''media_editplan'', ''Edit Media Plans'', ''media'', ''admin'', 3, 1, ''Allows user access to Media Plans, where they can add and edit plans.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500040, ''media_traffic'', ''View the Media Traffic Screen'', ''media'', ''admin'', 8, 1, ''User can access the Media Traffic screens for both Broadcast and Insertion Orders.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500050, ''media_viewio'', ''View Insertion Orders'', ''media'', ''admin'', 9, 1, ''Allows access in Media to view Insertion Orders.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500060, ''media_viewbo'', ''View Broadcast Orders'', ''media'', ''admin'', 10, 1, ''Allows access in Media to view Broadcast Orders.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500090, ''media_viewpubs'', ''View Publications'', ''media'', ''admin'', 11, 1, ''Allows access in Media to view Publications.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500095, ''media_viewstations'', ''View Stations'', ''media'', ''admin'', 12, 1, ''Allows access in Media to view Stations.'')


INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (40600, ''dash_editcompanynotes'', ''Edit the Company Wide Notes (CMP Only)'', ''legacy'', ''admin'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (40700, ''dash_editprojectnotes'', ''Edit the Project Notes (CMP Only)'', ''legacy'', ''admin'', 2, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (40800, ''dash_editcontactnotes'', ''Edit the Contact Notes (CMP Only) (in contact management)'', ''legacy'', ''admin'', 3, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (10500, ''admincontact'', ''View the Company Address Book (CM Only)'', ''legacy'', ''admin'', 4, 1, ''View the Company Address Book. Salesperson > Contacts and Companies. Can view contacts and companies owned by anyone in the company, but cannot make any changes.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930000, ''cm_editcontacts'', ''Edit contact information (CM Only)'', ''legacy'', ''admin'', 5, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930100, ''cm_viewothermanagers'', ''View Other Account Manager''''s Opportunities and Activity Conversations (CM Only)'', ''legacy'', ''admin'', 6, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930150, ''cm_dashboard'', ''View the contact management dashboard (CM Only)'', ''legacy'', ''admin'', 7, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930200, ''cm_viewleads'', ''View and Edit Opportunities (CM Only)'', ''legacy'', ''admin'', 8, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930400, ''cm_viewactivities'', ''View Contact Activity Conversations (CM Only)'', ''legacy'', ''admin'', 9, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930500, ''cm_allowdelete'', ''Delete contacts (CM Only)'', ''legacy'', ''admin'', 10, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930600, ''cm_showall'', ''See contacts they do not own (CM Only)'', ''legacy'', ''admin'', 11, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930700, ''cm_alldb'', ''See contacts in all databases (CM Only)'', ''legacy'', ''admin'', 12, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (120300, ''calviewcompany'', ''View Company Meetings (CM Only)'', ''legacy'', ''admin'', 13, 1, ''Allows access to Public Calendar company meetings/project meetings. Must also have the Security settings from calendar setup with the right to View.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20000000, ''br_viewlegacy'', ''-- View Legacy Reports --'', ''legacy'', ''admin'', 14, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20000001, ''legacy_proj_projectsummary'', ''Project Budget Summary (Legacy)'', ''legacy'', ''admin'', 15, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20000002, ''legacy_acct_projectprofit'', ''Project Profitability (Legacy)'', ''legacy'', ''admin'', 16, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20000003, ''legacy_acct_projectwip'', ''Project WIP Report (Legacy)'', ''legacy'', ''admin'', 17, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (20000004, ''legacy_acct_gl_pl_ytd'', ''Income Statement (Legacy)'', ''legacy'', ''admin'', 18, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (401301, ''rptCMLeadList'', ''Opportunity List (CMP Only)'', ''legacy'', ''admin'', 19, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (120100, ''calUseCalendar'', ''Access the calendar'', ''calendar'', ''admin'', 1, 1, ''Allows access to the enterprise calendar from the Menu dropdown.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (120200, ''caladdmeetings'', ''Add New Meetings'', ''calendar'', ''admin'', 2, 1, ''Gives the right to add and edit meetings, but only for those calendars where the Security setting has the right to Edit.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (120400, ''calBlockOutDays'', ''Mark Calendar Events to block out days on the schedule'', ''calendar'', ''admin'', 3, 1, ''Only for those calendars where the setup allows the right to Edit.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (120500, ''caleditglobalgroups'', ''Maintain Global Distribution Groups'', ''calendar'', ''admin'', 5, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (120600, ''foldersCalendar'', ''Add/Edit/Delete Public Calendars'', ''calendar'', ''admin'', 4, 1, ''Allows the user to create new public calendars, edit and delete calendars in the list of Public Calendars.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931600, ''useContacts'', ''Use Contacts'', ''cm'', ''admin'', 1, 1, ''This setting must be turned on for access to all other Contacts security settings and allows access to Salesperson > Contacts. Can only see folders assigned to themself, and the Contacts contained in those folders where this user is the Contact Owner, can also view options in Details windows for Contact,  Company, Opportunities, Projects, History and add New Activity. This setting also allows the user to open and Edit existing Contact records, make a selection of Contact and Change multiple contacts at once.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931601, ''viewOtherContacts'', ''View Contacts You Do Not Own'', ''cm'', ''admin'', 4, 1, ''Can see all Contacts, whether the Contact Owner or not.<br>This right determines whether or not a user can see Contacts whos Contact Owner is someone other than the user. If Folders are being used, then Folder security will be checked prior to checking record level security.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931602, ''editOtherContacts'', ''Edit Contacts You Do Not Own'', ''cm'', ''admin'', 5, 1, ''Allows the ability to open and Edit existing Contacts. View Contacts You Do Not Own must also be turned on.<br>This right determines whether or not a user can see Contacts whos Contact Owner is someone other than the user. If Folders are being used, then Folder security will be checked prior to checking record level security.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931603, ''addContacts'', ''Add New Contacts'', ''cm'', ''admin'', 2, 1, ''Allows user to Add individual Contact records, but not the ability to Import Contacts.<br>This right determines whether or not a user can create new Contacts for themselves or another user. If Folders are being used, then Folder security will be checked prior to checking record level security.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931604, ''deleteContacts'', ''Delete Public Contacts'', ''cm'', ''admin'', 3, 1, ''Allows the user to open and Delete Contacts, also gives access to the Remove Duplicate Contacts option (When given the right to View and Edit Contacts You Do Not Own).<br>This right determines whether or not a user can delete Contacts for which they are the Contact Owner and if the user has the Edit Contacts You Do Not Own right, they will be able to delete Contacts they do not own.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931605, ''moveFoldersContacts'', ''Move Public Contacts to Private Folders'', ''cm'', ''admin'', 6, 1, ''Allows the user to move a Contact record from a Public folder to their own Personal/Private folder that no other user will have access to.<br>The user must be have the right to edit that Public folder as well as edit that Contact record. Refer to the How to User Folders document for more information on setting, granting access, and deleting folders.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931606, ''foldersContacts'', ''Add/Edit/Delete Public Contact Folders'', ''cm'', ''admin'', 7, 1, ''This right determines whether or not a user can Add/Edit/Delete Public Folders for Contacts.  This right is only used if the Global Setting in the Transaction Preferences are checked for the Use Contact Folders.  If the user does not have the security rights to Add the Contact Folder, then they will not be able to edit or delete the folder regardless of this setting. Refer to the How to User Folders document for more information on setting, granting access, and deleting folders.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931607, ''mergeContacts'', ''Merge Contacts'', ''cm'', ''admin'', 8, 1, ''This right determines whether or not a user can Merge Contacts.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931608, ''viewContactCustomFields'', ''View Contact Custom Fields'', ''cm'', ''admin'', 9, 1, ''This right determines whether or not a user can view custom fields on a contact.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931700, ''useCompanies'', ''Use Companies'', ''cm'', ''admin'', 9, 1, ''This setting must be turned on for access to all other Companies security settings and allows access to Salesperson > Companies. Can only see folders assigned to themself, and the Companies contained in those folders where this user is the Company Owner, can also view Company Details windows for Company, Contact, Opportunities, Forms, History, (can add New Activity), Projects Estimates, Invoices, Receipts, Vendor Invoices and Payment. This setting also allows the user to open and Edit existing Company records, make a selection of Companies and Change multiple companies at once.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931701, ''viewOtherCompanies'', ''View Companies You Do Not Own'', ''cm'', ''admin'', 12, 1, ''Can see all Companies, whether the Company Owner or not.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931702, ''editOtherCompanies'', ''Edit Companies You Do Not Own'', ''cm'', ''admin'', 13, 1, ''Allows the ability to open and Edit existing Company Records. View Companies You Do Not Own must also be turned on. Edit limited to Details, Contacts and History.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931703, ''addCompanies'', ''Add new Companies'', ''cm'', ''admin'', 10, 1, ''Allows user to Add New Company records, but not the ability to Import Companies.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931704, ''deleteCompanies'', ''Delete Companies'', ''cm'', ''admin'', 11, 1, ''Allows the user to open and Delete Companies, also gives access to the Remove Duplicate Companies option (When given the right to View and Edit Companies You Do Not Own).'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931705, ''foldersCompanies'', ''Add/Edit/Delete Company Folders'', ''cm'', ''admin'', 14, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931706, ''cm_editacctinfo'', ''Edit Client and Vendor Accounting Information'', ''cm'', ''admin'', 16, 1, ''This allows access to the Client and Vendor Setup tabs in Company records.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931707, ''mergeCompanies'', ''Merge Companies'', ''cm'', ''admin'', 15, 1, ''This right determines whether or not a user can Merge Companies.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931708, ''viewEINNumber'', ''View Company EIN Number'', ''cm'', ''admin'', 41, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931709, ''editEINNumber'', ''Edit Company EIN Number'', ''cm'', ''admin'', 42, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931710, ''viewCompanyCustomFields'', ''View Company Custom Fields'', ''cm'', ''admin'', 16, 1, ''This right determines whether or not a user can view custom fields on a company.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931400, ''useLeads'', ''Use Lead'', ''cm'', ''admin'', 17, 1, ''This setting must be turned on for access to all other Leads security settings and allows access to Salesperson > Leads. Can only see folders assigned to themself, and the Leads contained in those folders where this user is the Lead Owner, can also view History and add New Activity. This setting also allows the user to open and Edit existing Lead records, make a selection of Leads and Change multiple leads at once.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931401, ''viewOtherLeads'', ''View Leads You Do Not Own'', ''cm'', ''admin'', 18, 1, ''Can see all Leads, whether the Lead Owner or not.<br>This right determines whether or not a user can see Leads whos Lead Owner is someone other than the user. If Folders are being used, then Folder security will be checked prior to checking record level security.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931402, ''editOtherLeads'', ''Edit Leads You Do Not Own'', ''cm'', ''admin'', 19, 1, ''Allows the ability to open and Edit existing Leads. View Leads You Do Not Own must also be turned on.<br>This right determines whether or not a user can edit or delete Leads whos Lead Owner is someone other than the user. If Folders are being used, then Folder security will be checked prior to checking record level security.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931403, ''addLeads'', ''Add Leads'', ''cm'', ''admin'', 20, 1, ''Allows user to Add individual Leads records, but not the ability to Import Leads.<br>This right determines whether or not a user can create new Leads for themselves or another user. If Folders are being used, then Folder security will be checked prior to checking record level security.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931404, ''deleteLeads'', ''Delete Leads'', ''cm'', ''admin'', 22, 1, ''Allows the user to open and Delete Leads, also gives access to the Remove Duplicate Leads option (When given the right to View and Edit Leads You do Not Own).<br>This right determines whether or not a user can delete Leads for which they are the Lead Owner and if the user has the Edit Leads You Do Not Own right, they will be able to delete Leads they do not own. If Folders are being used, then Folder security will be checked prior to checking record level security.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931405, ''foldersLeads'', ''Add/Edit/Delete Lead Folders'', ''cm'', ''admin'', 23, 1, ''This right determines whether or not a user can Add/Edit /Delete Public Folders for Leads.  This right is only used if the Global Setting in the Transaction Preferences are checked for the Use Lead Folders.  If the user does not have the security rights to Add the Lead Folder, then they will not be able to edit or delete the folder regardless of this setting.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931406, ''mergeLeads'', ''Merge Leads'', ''cm'', ''admin'', 21, 1, ''This right determines whether or not a user can Merge Leads.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931100, ''useOpp'', ''Use Opportunities'', ''cm'', ''admin'', 24, 1, ''This setting must be turned on for access to all other Opportunities security settings and allows access to Salesperson > Opportunities. Can only see folders assigned to themself, and the Opportunities contained in those folders where this user is the Opportunity Owner, can also view options in Details windows for Opportunity, Company, Contacts, History (can add a New Activity). This setting also allows the user to open and Edit existing Opportunities, make a selection of Opportunities and Change multiple opportunities at once.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931101, ''viewOtherOpp'', ''View Opportunities You Do Not Own'', ''cm'', ''admin'', 27, 1, ''Can see all Opportunities, whether the Owner or not.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931102, ''editOtherOpp'', ''Edit Opportunities You Do Not Own'', ''cm'', ''admin'', 28, 1, ''Allows the ability to open and Edit existing Opportunities.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931103, ''addOpp'', ''Add New Opportunities'', ''cm'', ''admin'', 25, 1, ''Allows user to Add New Opportunities, but not the ability to Import.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931104, ''deleteOpp'', ''Delete Opportunities'', ''cm'', ''admin'', 26, 1, ''Allows the user to open and Delete Opportunities (When given the right to View and Edit Companies You Do Not Own).'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931105, ''foldersOpp'', ''Add/Edit/Delete Opportunity Folders'', ''cm'', ''admin'', 29, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931106, ''deleteOpptyProject'', ''Delete Opportunity Projects'', ''cm'', ''admin'', 29, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931500, ''useActivities'', ''Use Activity Conversations'', ''cm'', ''admin'', 30, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931501, ''viewOtherActivities'', ''View Activity Conversations Not Assigned To You'', ''cm'', ''admin'', 33, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931507, ''editActivities'', ''Edit Activity Conversations'', ''cm'', ''admin'', 31, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931502, ''editOtherActivities'', ''Edit Activity Conversations Not Assigned To You'', ''cm'', ''admin'', 34, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931503, ''deleteActivities'', ''Delete Activity Conversations'', ''cm'', ''admin'', 32, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931504, ''foldersActivities'', ''Add/Edit/Delete Public Activity Conversation Folders'', ''cm'', ''admin'', 35, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931505, ''moveFoldersActivities'', ''Move Public Activity Conversations to Private Folders'', ''cm'', ''admin'', 36, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931506, ''activityAllwaysCheckOpp'', ''Always Check for Opportunities on Activity Conversations'', ''cm'', ''admin'', 37, 1, '''')


INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (931550, ''useMarketingLists'', ''Use Marketing Lists'', ''cm'', ''admin'', 38, 1, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930800, ''cm_viewclientlist'', ''View the client list'', ''cm'', ''admin'', 39, 1, ''Allows access to Menu > Billing > Clients to view the list of Clients.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (930900, ''cm_viewvendorlist'', ''View the vendor list'', ''cm'', ''admin'', 40, 1, ''Edit Accounting Information is required in order to view the Vendor Setup tab in the Company Record; this also makes Menu > Purchasing > Vendors available to view the list of Vendors.'')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940100, ''gl_glaccount'', ''Maintain GL Accounts'', ''acct'', ''admin'', 1, 1, ''Also need to System Administration  > Maintain Setup Information > Edit GL Settings. This allows complete access to System Setup > GL Accounts > GL Accounts, Control Accounts, GL Tracking Options, and Check Formats. This down allow access to the Accounting Module.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940200, ''gl_journalentry'', ''Enter Journal Entries'', ''acct'', ''admin'', 2, 0, ''Add/edit/delete Journal Entries. User can also view General Ledger Transactions.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940221, ''gl_view_journalentry'', ''View Journal Entries'', ''acct'', ''admin'', 5, 0, ''Allows the user to view Journal Entries. User can also view General Ledger Transactions.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940300, ''gl_budget'', ''Enter GL Budgets'', ''acct'', ''admin'', 3, 0, ''Allows the user to create and edit Financial Budgets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940321, ''gl_forecast'', ''Edit / View Revenue Forecasts'', ''acct'', ''admin'', 12, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940320, ''gl_view_forecast_others'', ''---- View Revenue Forecasts from other AEs'', ''acct'', ''admin'', 13, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940330, ''gl_currencyrates'', ''Maintain Currency Exchange Rates'', ''acct'', ''admin'', 13, 0, '''')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940400, ''gl_accountrecs'', ''Reconcile GL Accounts'', ''acct'', ''admin'', 7, 0, ''Allows full access to setup GL Account Reconciliation.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940445, ''gl_postvoucher'', ''Post Voucher to the General Ledger'', ''acct'', ''admin'', 9, 0, ''Allows user access to the Post Transactions screen, and to post Vouchers, and to run the Missing Transactions and Preposting reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940446, ''gl_postpayment'', ''Post Payment to the General Ledger'', ''acct'', ''admin'', 9, 0, ''Allows user access to the Post Transactions screen, and to post Payments, and to run the Missing Transactions and Preposting reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940447, ''gl_postclientinvoice'', ''Post Client Invoice to the General Ledger'', ''acct'', ''admin'', 9, 0, ''Allows user access to the Post Transactions screen, and to post Client Invoices, and to run the Missing Transactions and Preposting reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940448, ''gl_postreceipt'', ''Post Receipt to the General Ledger'', ''acct'', ''admin'', 9, 0, ''Allows user access to the Post Transactions screen, and to post Receipts, and to run the Missing Transactions and Preposting reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940449, ''gl_postjournalentry'', ''Post Journal Entry to the General Ledger'', ''acct'', ''admin'', 9, 0, ''Allows user access to the Post Transactions screen, and to post Journal Entries, and to run the Missing Transactions and Preposting reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940450, ''gl_postcreditcard'', ''Post Credit Card Transaction to the General Ledger'', ''acct'', ''admin'', 9, 0, ''Allows user access to the Post Transactions screen, and to post Credit Card Transactions, and to run the Missing Transactions and Preposting reports.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940455, ''gl_unpost'', ''Unpost Transaction to the General Ledger'', ''acct'', ''admin'', 10, 0, ''Allows user to the Unpost Transactions.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940460, ''gl_approvejournalentry'', ''Approve Journal Entries'', ''acct'', ''admin'', 11, 0, ''Allows user access to the approve Journal Entries.  Only applies if have preference turned on.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940500, ''gl_postwip'', ''Post WIP to GL'', ''acct'', ''admin'', 8, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940600, ''laborbud_edit'', ''Edit Labor Budgets'', ''acct'', ''admin'', 4, 1, ''Allow the user to create Labor Budgets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940610, ''laborbud_viewanyoffice'', ''---- Edit / View labor budgets for any office'', ''acct'', ''admin'', 5, 1, ''Access to labor budgets for staff assigned to any office.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940620, ''laborbud_viewanydept'', ''---- Edit / View labor budgets for any department'', ''acct'', ''admin'', 6, 1, ''Access to labor budgets for staff assigned to any department.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940630, ''chargesum_viewanyperson'', ''---- View any or all people on billable summary'', ''acct'', ''admin'', 7, 1, ''View Billable Summary in Hours and Dollars. You must have access to View the reports menu, -- View Project Financial Reports.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (940700, ''accteditanytime'', ''Edit transactions after submission/approval'', ''acct'', ''admin'', 11, 1, ''The right to unapprove and edit any transaction after approval.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950000, ''acct_ap_aging'', ''AP Account Aging'', ''reports'', ''admin'', 5010, 0, ''Shows all accounts payable aging with amount open and days old.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950001, ''acct_ap_listing'', ''AP Listing'', ''reports'', ''admin'', 5020, 1, ''Vendor Invoice Detail list shows all vendor invoice lines with expense account, project number and tasks.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950002, ''acct_ap_1099'', ''1099 Vendor Detail'', ''reports'', ''admin'', 5050, 1, ''Allows access to the following:<br>1099 (Misc/Form): prints 1099 (Misc/Int) Form matching the Federal form format.<br>1099 Vendor Detail: shows 1099 vendor detail information including a grand total for the report.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950003, ''acct_po_listing'', ''Purchase Order Listing'', ''reports'', ''admin'', 5060, 1, ''Shows order information grouped by vendors.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950004, ''acct_po_project'', ''Project PO Listing'', ''reports'', ''admin'', 5070, 1, ''Purchase Order By Projects shows order information grouped by vendors.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950005, ''acct_ap_checks'', ''Payment Listing'', ''reports'', ''admin'', 5080, 0, ''Check Listing shows all payment within a date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950006, ''acct_ar_invoicesummary'', ''Invoice Summary'', ''reports'', ''admin'', 4050, 1, ''Shows all invoices with totals, sales tax, gross labor and net expenses grouped by client.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950007, ''acct_ar_invoicelineitemsummary'', ''Invoice Line Item Summary'', ''reports'', ''admin'', 4060, 1, ''Shows all invoices with project number, subject, line total, gross labor and net expenses grouped by client.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950120, ''acct_projectprofit'', ''Project Profitability'', ''reports'', ''admin'', 7128, 0, ''The following reports are available when this is selected:<br>Project Profit and Loss (Detail View): shows profitability for a specific Project with breakdowns by GL Account and may include Overhead Allocation.<br>Project Profit and Loss (Multi View): shows profitability across multiple projects with ability to allocate overhead from the GL.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (400300, ''acct_projectwip'', ''Project WIP Analysis'', ''reports'', ''admin'', 2129, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950008, ''acct_gl_trailbal'', ''Trial Balance'', ''reports'', ''admin'', 7130, 0, ''Shows GL account balances with debits and credits.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950009, ''acct_gl_genledger'', ''General Ledger'', ''reports'', ''admin'', 7140, 0, ''Shows GL account activity by date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950010, ''acct_gl_genjournal'', ''General Journal'', ''reports'', ''admin'', 7150, 0, ''Shows journal entry transactions by date range.'')

INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950011, ''acct_gl_pl_ytd'', ''Income Statement Corporate'', ''reports'', ''admin'', 7160, 0, ''The following report is available when this is selected:<br>Corporate Profit and Loss: Shows income statement for the company and/or GL Company, Office, GL Class and Department level.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950050, ''acct_client_gl_pl_ytd'', ''Income Statement Client'', ''reports'', ''admin'', 7165, 0, ''The following reports are available when this is selected:<br>Client Profit and Loss (Detail View): shows profitability for a specific client with breakdowns by GL Account or Project Type.<br>Client Profit and Loss (Multi View): shows profitability across multiple clients with ability to allocate overhead from the GL.'')


INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950012, ''acct_gl_balsheet'', ''Balance Sheet'', ''reports'', ''admin'', 7170, 0, ''Shows assets, liabilities and equity balances as of a specified date.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950013, ''acct_ap_purchjournal'', ''Purchase Journal'', ''reports'', ''admin'', 5030, 0, ''Shows sub-ledger report of vendor invoices by date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950014, ''acct_ap_payjournal'', ''Cash Disbursements Journal'', ''reports'', ''admin'', 5040, 0, ''Shows sub-ledger report of payments by date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950015, ''acct_ar_salesjournal'', ''Sales Journal'', ''reports'', ''admin'', 4020, 1, ''Shows sales activity by client and posting date.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950016, ''acct_ar_cashjournal'', ''Cash Receipts Journal'', ''reports'', ''admin'', 4030, 1, ''Shows receipts received by client and posting date.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950020, ''acct_ar_statement'', ''Client Statements'', ''reports'', ''admin'', 4040, 1, ''Shows client transactions including amount billed, receipts, amount open and aging information.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950025, ''acct_inv_backup'', ''Invoice Backup'', ''reports'', ''admin'', 4045, 1, ''Shows the details of client invoices with actual labor, expenses and totals.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950030, ''acct_gl_excel'', ''Access Financials from Excel'', ''reports'', ''admin'', 7180, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950040, ''acct_ap_accruedorder'', ''AP Accrued Order Detail Report'', ''reports'', ''admin'', 5075, 0, ''Show all Orders with accrued balance as a result of Prebilling.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950045, ''acct_ap_exceptions'', ''AP Exceptions Report'', ''reports'', ''admin'', 5015, 1, ''Shows vendor invoices where there is a variance from the related PO amount.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950110, ''acct_salestaxanalysis'', ''Sales Tax Analysis Report'', ''reports'', ''admin'', 4070, 0, ''Shows taxable sales, tax amounts paid and collected, grouped by sales tax rate code.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950121, ''acct_projectrealization'', ''Project Hourly Realization Rate'', ''reports'', ''admin'', 2016, 1, ''Shows actual hourly rate earned on projects.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950130, ''acct_gl_statement_cashflow'', ''Statement of Cash Flows'', ''reports'', ''admin'', 7180, 0, ''Shows cash flow of company operating and investing activities by date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950135, ''acct_gl_cashprojection'', ''Cash Projection'', ''reports'', ''admin'', 7185, 0, ''Drill Down: Shows beginning and ending balances for AR, AP, Bank Accounts and projected balance for specified date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950136, ''acct_gl_uncleared'', ''Uncleared Transactions'', ''reports'', ''admin'', 7186, 0, ''Shows uncleared transactions for specified GL Account.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950137, ''rptOverheadAllocationDetail'', ''Overhead Allocation Details'', ''reports'', ''admin'', 7187, 0, ''Shows the transaction details that make up the overhead allocation total when running the Client P&L or Project P&L reports over the same date range.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (950140, ''acct_metrics'', ''Metrics Monitor'', ''reports'', ''admin'', 7190, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960000, ''pr_viewrequests'', ''View Project Requests'', ''requests'', ''admin'', 1, 1, ''User can view project requests and linked spec sheets. This also allows the user to Cancel Request, which will cancel an approval and change the request status to Not Sent For Approval. This setting also allows the user to Add Attachments.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960010, ''pr_addrequests'', ''Add New Requests to the system'', ''requests'', ''admin'', 2, 1, ''Allows user to create new project requests, only if they belong in the Selected Security Groups defined in the project request form at the system setup level.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960020, ''pr_editrequests'', ''Edit Existing Requests'', ''requests'', ''admin'', 3, 1, ''Allows user to make and Save changes to existing project requests and linked spec sheets.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960030, ''pr_deleterequests'', ''Delete Existing Requests'', ''requests'', ''admin'', 4, 1, ''[Delete] button is now present.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960040, ''pr_editapproval'', ''Edit the approval process'', ''requests'', ''admin'', 5, 1, ''[Approval Process] is now present in existing project requests allowing the user to add/edit/delete approval steps and change the order of defined approval steps.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960050, ''proj_projectassignments'', ''Assigned Tasks'', ''reports'', ''admin'', 3150, 1, ''Project Tasks. Shows all tasks by project.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960051, ''admin_employeehours'', ''Employee Actual Hours Report'', ''reports'', ''admin'', 2017, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960052, ''acct_gl_mc_realized'', ''Multicurrency Realized Gains and Losses'', ''reports'', ''admin'', 7191, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960053, ''acct_gl_mc_unrealized'', ''Multicurrency Unrealized Gains and Losses'', ''reports'', ''admin'', 7192, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (960054, ''acct_view_scheduledreports'', ''View Scheduled Transactions'', ''acct'', ''admin'', 7193, 1, '''')




INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90000001, ''cbeditbatch'', ''Edit Charge Back Batches'', ''billing'', ''ChargeCodes'', 1, 0, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (90000002, ''billingenterlabornet'', ''Enter Net Rate in Project Time and Material Billing'', ''billing'', ''billlabornet'', 1, 1, ''This right allows users to bill at a net cost different than the one on time entries on the Time and Material project billing for things like overtime.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (91000000, ''muddAMRpt'', ''AGI By Account Manager Report'', ''reports'', ''mudd'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (91000001, ''muddSMRpt'', ''AGI By Sales Manager'', ''reports'', ''mudd'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (91000002, ''muddAMClientRpt'', ''AGI By Account Manager or Client'', ''reports'', ''mudd'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (92000000, ''partnersnapierMonthyActualHours'', ''Retainer Monthly Actual Hours'', ''reports'', ''partnersnapier'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (92000001, ''partnersnapierMonthyActualHrsBudget'', ''Retainer Monthly Actual Hours with Budget'', ''reports'', ''partnersnapier'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (92000002, ''partnersnapierSalesJournal'', ''Custom Sales Journal'', ''reports'', ''partnersnapier'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (93000001, ''cbreSBRpt'', ''Custom Split Billing Invoice'', ''reports'', ''cbre'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (94000001, ''pyramidLaborRpt'', ''Custom Project Labor Analysis'', ''reports'', ''pyramid'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (95000001, ''hmiProjectResourceUtilization'', ''Custom Project Resource Utilization'', ''reports'', ''hmi'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (95000002, ''abelsonProjectResourceUtilization'', ''Custom Project Resource Utilization'', ''reports'', ''abelson'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (96000001, ''bgbBillableHours'', ''Project Billable Hours Summary'', ''reports'', ''bgb'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (97000001, ''bgbProjectReconciliationSummary'', ''Project Reconciliation Summary'', ''reports'', ''bgb'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (98000000, ''boyScoutExport'', ''Project Data Export'', ''reports'', ''boyscouts'', 999, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99000001, ''brittonTrafficRpt'', ''Custom Time Detail Data'', ''reports'', ''britton'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99100001, ''concentricChargeabilityRpt'', ''Custom Utilization Report'', ''reports'', ''concentric'', 1, 1, '''')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99100002, ''concentricClientPLRpt'', ''Custom Client PL Report'', ''reports'', ''concentric'', 1, 1, '''')
--INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99100003, ''concentricDeptPLRpt'', ''Custom Dept PL Report'', ''reports'', ''concentric'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99200001, ''jplChargeabilitySummary'', ''Custom Chargeability Summary'', ''reports'', ''jplcharge'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99300001, ''farmPostageAvailableReport'', ''Custom Postage Available Report'', ''reports'', ''farmPostage'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99400001, ''barbGroupCustomization'', ''Custom Barbarian Group Report'', ''reports'', ''barbGroup'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (99500001, ''questvouchersrpt'', ''Custom Quest Vendor Invoice Report'', ''reports'', ''questvouchersrpt'', 1, 1, '''')





INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500110, ''client_prjAccessAny'', ''Access all projects for client'', ''client'', ''client'', 1, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500100, ''client_calendar'', ''View the calendar'', ''client'', ''client'', 3, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500200, ''client_approvals'', ''View the approvals page (Legacy)'', ''clientLegacy'', ''client'', 4, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500300, ''client_schedule'', ''View the project schedule (Legacy)'', ''clientLegacy'', ''client'', 5, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500400, ''client_hours'', ''View hours on project budget (Legacy)'', ''clientLegacy'', ''client'', 9, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500500, ''client_budget'', ''View project budget page (Legacy)'', ''clientLegacy'', ''client'', 7, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500550, ''client_viewbudget'', ''View the project budget (Legacy)'', ''clientLegacy'', ''client'', 8, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500600, ''client_budgetdetail'', ''Drill down on budget transactions details (Legacy)'', ''clientLegacy'', ''client'', 10, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500650, ''client_budgetactuals'', ''View actuals on a project budget (Legacy)'', ''clientLegacy'', ''client'', 11, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500651, ''client_budgetactual_dollars'', ''View actual dollars on a project budget (Legacy)'', ''clientLegacy'', ''client'', 12, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500652, ''client_budgetactual_hours'', ''View actual hours on a project budget (Legacy)'', ''clientLegacy'', ''client'', 13, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500700, ''client_invoices'', ''View current invoices (Legacy)'', ''clientLegacy'', ''client'', 14, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500750, ''client_invoicespast'', ''View closed invoices (Legacy)'', ''clientLegacy'', ''client'', 15, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500775, ''client_invoicesassigned'', ''View Invoices for assigned projects (Legacy)'', ''clientLegacy'', ''client'', 16, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (500800, ''client_originalschedule'', ''View the original schedule (Legacy)'', ''clientLegacy'', ''client'', 6, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501100, ''client_prview'', ''Client can view Project Requests'', ''client'', ''client'', 17, 1, ''User can view project requests and linked spec sheets. This also allows the user to Cancel Request, which will cancel an approval and change the request status to Not Sent For Approval. This setting also allows the user to Add Attachment(s).'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501200, ''client_pradd'', ''Add New Project Requests'', ''client'', ''client'', 18, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501401, ''client_prdeleteown'', ''Delete Project Requests'', ''client'', ''client'', 19, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501300, ''client_predit'', ''Edit Project Requests from their company'', ''client'', ''client'', 20, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501400, ''client_prdelete'', ''Can delete requests from their company'', ''client'', ''client'', 21, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501450, ''client_praddnewspec'', ''Can add and delete spec sheets on project requests'', ''client'', ''client'', 27, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501500, ''client_dafiles'', ''Can View Digital Asset Files (Legacy)'', ''clientLegacy'', ''client'', 22, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501550, ''client_dafilesupload'', ''Can Upload Digital Asset Files (Legacy)'', ''clientLegacy'', ''client'', 23, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501600, ''client_projectlist'', ''View the list of assigned projects (Legacy)'', ''clientLegacy'', ''client'', 2, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501700, ''client_notes'', ''Add to the Project Diary (Legacy)'', ''clientLegacy'', ''client'', 24, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501710, ''client_editNotes'', ''Edit Diary Notes (Legacy)'', ''clientLegacy'', ''client'', 25, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501800, ''client_myinfo'', ''Change MyInfo data and password (Legacy)'', ''clientLegacy'', ''client'', 26, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501801, ''client_assignments'', ''View Assigned Tasks (Legacy)'', ''clientLegacy'', ''client'', 28, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501810, ''client_daviewprior'', ''Can view prior digital art reviews (Legacy)'', ''clientLegacy'', ''client'', 29, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501820, ''client_viewinvoicecompany'', ''View Invoices for Company (Legacy)'', ''clientLegacy'', ''client'', 30, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501830, ''client_viewinvoiceparentcompany'', ''View Invoices for Parent Company (Legacy)'', ''clientLegacy'', ''client'', 31, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501835, ''client_viewinvoicechildcompany'', ''View Invoices for Child Company (Legacy)'', ''clientLegacy'', ''client'', 32, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501840, ''client_projectdescription'', ''View the Project Description'', ''client'', ''client'', 33, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501850, ''client_projectteam'', ''View the Project Team (Legacy)'', ''clientLegacy'', ''client'', 34, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501860, ''client_creativebrief'', ''View the Project Creative Brief (Legacy)'', ''clientLegacy'', ''client'', 35, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501870, ''client_projectspecs'', ''View the Project Specifications (Legacy)'', ''clientLegacy'', ''client'', 36, 1, ''View only access to any attached spec sheet.'')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501880, ''client_editprojectspecs'', ''Edit the Project Specifications'', ''client'', ''client'', 37, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501890, ''client_viewprojectmisccost'', ''View the Project Misc Cost (Legacy)'', ''clientLegacy'', ''client'', 38, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501895, ''client_editconversations'', ''Use Project Request and Change Request Conversations'', ''client'', ''client'', 39, 1, '''')

if @LoadBeta = 1
BEGIN
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501900, ''client_crview'', ''Client Can View Project Change Request Forms'', ''client'', ''client'', 38, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501910, ''client_cradd'', ''Add New Project Change Request Forms'', ''client'', ''client'', 39, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501920, ''client_credit'', ''Edit Project Change Request Forms For Their Company'', ''client'', ''client'', 40, 1, '''')
INSERT tRight(RightKey, RightID, Description, RightGroup, SetGroup, DisplayOrder, CPM, Hint) Values (501930, ''client_crdelete'', ''Can Delete Project Change Request Forms For Their Company'', ''client'', ''client'', 41, 1, '''')
END


-- 688217 (GAR) - Deleting the tWidget insert statements because the table definition changed.  We will add these back in once we have the new table set and widgets defined.
--DELETE tWidget Where CompanyKey is null

--INSERT tWidget(WidgetKey, CompanyKey, DisplayName, Description, WidgetType, WidgetGroup, SourceFile, Icon, Settings, UserEdit, HasSettings, Height, Width, CanResize, LastModified) Values (1, NULL, ''RSS Reader'', ''RSS Reader'', ''main'', 0, ''OtherRSSReader.swf'', ''widgetOther'', ''<settings><Title>RSS READER</Title><rssUrl>http://www.groupamajig.com/forum/feed.php</rssUrl></settings>'', 1, 1, 400, 400, 1, GETDATE())

-- 688217 (GAR) - Adding the new widget definitions here for the new project dashboards.
DELETE tWidgetDef
DELETE tWidgetEntity
DELETE tWidgetEntityAssigned


INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (1, NULL, N''OppByStage'', N''By Stage'', NULL, NULL, 0, 0, 1, 1, 1, N''HTML2'', N''loadOppByStage'', N''!System.session.salesDashboard.OppByStage'', N''dashboards.widgets.sales.oppByStage'', N''OppByStage'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (2, NULL, N''OppByWWP'', N''By WWP Level'', NULL, NULL, 0, 0, 1, 1, 1, N''HTML2'', N''loadOppByWWP'', N''!System.session.salesDashboard.OppByWWP'', N''dashboards.widgets.sales.oppByWWP'', N''OppByWWP'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (3, NULL, N''FavoriteUsers'', N''Twitter Feeds'', NULL, NULL, 0, 0, 1, 1, 1, N''HTML2'', N''loadFavoriteUsers'', N''!System.session.salesDashboard.OppTwitter'', N''dashboards.widgets.sales.twitter'', N''Twitter'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (4, NULL, N''FavoriteOpps'', N''Favorite Opportunities'', NULL, NULL, 0, 0, 1, 1, 1, N''HTML2'', N''loadFavoriteOpps'', N''!System.session.salesDashboard.Weighted'', N''dashboards.widgets.sales.favoriteOpps'', N''FavoriteOpps'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (5, NULL, N''NeglectedOpps'', N''Neglected Opportunities'', NULL, NULL, 0, 0, 1, 1, 1, N''HTML2'', N''loadNeglectedOpps'', N''!System.session.salesDashboard.NeglectedOpps'', N''dashboards.widgets.sales.neglectedOpps'', N''NeglectedOpps'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (6, NULL, N''SalesTarget'', N''Sales Target'', NULL, NULL, 0, 0, 1, 1, 1, N''HTML2'', N''loadSalesTarget'', N''!System.session.salesDashboard.SalesTarget'', N''dashboards.widgets.sales.salesTarget'', N''SalesTarget'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (7, NULL, N''ProjectChangeRequests'', N''Change Requests'', N''View a list of the current change requests on a project. You must have the right "View Project Change Request Forms" to see any request forms in this widget.'', NULL, 2, 3, 3, 3, 1, N''HTML2'', N''loadProjectChangeRequests'', NULL, N''dashboards.widgets.projects.projectChangeRequests'', N''ProjectChangeRequests'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (8, NULL, N''ProjectContactInfo'', N''Contact Info'', N''This shows information about the primary contact on the project as well as the project manager and billing manager.'', NULL, 0, 4, 2, 2, 1, N''HTML2'', N''loadProjectContactInfo'', NULL, N''dashboards.widgets.projects.projectContactInfo'', N''ProjectContactInfo'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class])
VALUES (9, NULL, N''ProjectCustomFields'', N''Custom Fields'', N''This shows the values of the custom fields on the project. You must have right to Maintain Project Setup in order to edit these values.'', NULL, 8, 3, 3, 3, 1, N''HTML2'', N''loadProjectCustomFields'', NULL, N''dashboards.widgets.projects.projectCustomFields'', N''ProjectCustomFields'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (10, NULL, N''ProjectDailyFeed'', N''Daily Feed'', N''Shows a list of all the current actions on a project. There are options to limit what kind of actions show up in the list.'', NULL, 2, 0, 3, 3, 1, N''HTML2'', N''loadProjectDailyFeed'', NULL, N''dashboards.widgets.projects.projectDailyFeed'', N''ProjectDailyFeed'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (11, NULL, N''ProjectDeliverables'', N''Deliverables'', N''Shows a list of all the deliverables added to the project. You must have the right View Deliverables in order to see any contents in this widget.'', NULL, 8, 0, 3, 3, 1, N''HTML2'', N''loadProjectDeliverables'', NULL, N''dashboards.widgets.projects.projectDeliverables'', N''ProjectDeliverables'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (12, NULL, N''ProjectDetails'', N''Project Details'', N''This shows the current status and other high level settings for a project. '', NULL, 0, 2, 2, 2, 1, N''HTML2'', N''loadProjectDetails'', NULL, N''dashboards.widgets.projects.projectDetails'', N''ProjectDetails'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (13, NULL, N''ProjectMenu'', N''Menu'', N''This shows the main jump menu for a project so that you can access all the different areas on a project. '', NULL, 0, 6, 2, 3, 1, N''HTML2'', N''loadProjectMenu'', NULL, N''dashboards.widgets.projects.projectMenu'', N''ProjectMenu'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (14, NULL, N''ProjectProfitability'', N''Project Profitability'', N''This widget shows a summary of the profitability of a project. These numbers are based on values posted to the general ledger. This is more sensitive information, so be careful which security groups you allow to see this widget.'', NULL, 0, 1, 5, 5, 1, N''HTML2'', N''loadProjectProfitability'', NULL, N''dashboards.widgets.projects.projectProfitability'', N''ProjectProfitability'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (15, NULL, N''ProjectRecentConversations'', N''Recent Conversations'', N''Shows a list of all the conversations that have been going on in the system. You must have the right to Access Project Conversations to see any details in this widget.'', NULL, 5, 3, 3, 3, 1, N''HTML2'', NULL, N''!System.session.salesDashboard.OppTwitter'', N''dashboards.widgets.projects.projectRecentConversations'', N''ProjectRecentConversations'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (16, NULL, N''ProjectSetup'', N''Setup'', N''This widget shows jump links to the different areas of project setup such as Schedule, Estimates, Project Setup and the Team.'', NULL, 0, 0, 2, 2, 1, N''HTML2'', N''loadProjectSetup'', NULL, N''dashboards.widgets.projects.projectSetup'', N''ProjectSetup'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (17, NULL, N''ProjectSnapshot'', N''Project Snapshot'', N''This widget shows a summary of transactions and budget of a project. These numbers are based on activity in the system and does not necessarily correspond to the ledger. This is more sensitive information, so be careful which security groups you allow to see this widget.'', NULL, 0, 4, 3, 4, 1, N''HTML2'', N''loadProjectSnapshot'', NULL, N''dashboards.widgets.projects.projectSnapshot'', N''ProjectSnapshot'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (18, NULL, N''ProjectSpecSheets'', N''Spec Sheets'', N''This widget shows a list of all of the spec sheets currently on the project. You need to have the right to View the Project Specifications to see any details in this widget.'', NULL, 5, 0, 3, 3, 1, N''HTML2'', N''loadProjectSpecSheets'', NULL, N''dashboards.widgets.projects.projectSpecSheets'', N''ProjectSpecSheets'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (19, NULL, N''ProjectTeam'', N''Team'', N''This widget shows a list of all the current team members, their contact information as well as the services that they have been assigned to handle on this project.'', NULL, 2, 6, 3, 3, 1, N''HTML2'', N''loadProjectTeam'', NULL, N''dashboards.widgets.projects.projectTeam'', N''ProjectTeam'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (20, NULL, N''DailyFeed'', N''Daily Feed'', N''Shows a list of all the current actions on a project. There are options to limit what kind of actions show up in the list.'', NULL, 1, 1, 3, 3, 1, N''HTML2'', N''loadDailyFeed'', NULL, N''dashboards.widgets.today.dailyFeed'', N''DailyFeed'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (21, NULL, N''Conversations'', N''Conversations'', N''Shows a list of recent converations.'', NULL, 1, 1, 3, 3, 1, N''HTML2'', N''loadConversations'', NULL, N''dashboards.widgets.today.conversations'', N''Conversations'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (22, NULL, N''NeglectedOpportunities'', N''Neglected Opportunities'', N''Shows a list of neglected opportunities.'', NULL, 1, 1, 3, 2, 1, N''HTML2'', N''loadNeglectedOpportunities'', NULL, N''dashboards.widgets.today.neglectedOpportunities'', N''NeglectedOpportunities'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (23, NULL, N''FavoriteOpportunities'', N''Favorite Opportunities'', N''Shows a list of favorite opportunities.'', NULL, 1, 1, 3, 3, 1, N''HTML2'', N''loadFavoriteOpportunities'', NULL, N''dashboards.widgets.today.favoriteOpportunities'', N''FavoriteOpportunities'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (24, NULL, N''TwitterFeeds'', N''Twitter Feeds'', N''Shows a list of twitter feeds from your favorite contacts.'', NULL, 1, 1, 3, 2, 1, N''HTML2'', N''loadTwitterFeeds'', NULL, N''dashboards.widgets.today.twitterFeeds'', N''TwitterFeeds'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (25, NULL, N''ProjectOpenItems'', N''Project Open Items'', N''Shows your open items for projects.'', NULL, 1, 1, 3, 3, 1, N''HTML2'', N''loadProjectOpenItems'', NULL, N''dashboards.widgets.today.projectOpenItems'', N''ProjectOpenItems'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (26, NULL, N''ProjectItemsNeedingAttention'', N''Project Items Needing Attention'', N''Shows all of your items needing attention for projects.'', NULL, 1, 1, 3, 3, 1, N''HTML2'', N''loadProjectItemsNeedingAttention'', NULL, N''dashboards.widgets.today.projectItemsNeedingAttention'', N''ProjectItemsNeedingAttention'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (27, NULL, N''BillingWorksheets'', N''Billing Worksheets'', N''Shows all billing worksheets.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadBillingWorksheets'', NULL, N''dashboards.widgets.today.billingWorksheets'', N''BillingWorksheets'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (28, NULL, N''BillingToBillAsOf'', N''Billing To Bill As Of'', N''Shows items to bill as of a selected date.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadBillingToBillAsOf'', NULL, N''dashboards.widgets.today.billingToBillAsOf'', N''BillingToBillAsOf'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (29, NULL, N''BillingInvoices'', N''Billing Invoices'', N''Shows all invoices.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadBillingInvoices'', NULL, N''dashboards.widgets.today.billingInvoices'', N''BillingInvoices'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (30, NULL, N''PurchasingOpenItems'', N''Purchasing Open Items'', N''Shows open items for purchasing.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadPurchasingOpenItems'', NULL, N''dashboards.widgets.today.purchasingOpenItems'', N''PurchasingOpenItems'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (31, NULL, N''PurchasingIncomingCharges'', N''Purchasing Incoming Charges'', N''Shows incoming charges for purchasing.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadPurchasingIncomingCharges'', NULL, N''dashboards.widgets.today.purchasingIncomingCharges'', N''PurchasingIncomingCharges'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (32, NULL, N''PurchasingInvoices'', N''Purchasing Invoices'', N''Shows invoices for purchasing.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadPurchasingInvoices'', NULL, N''dashboards.widgets.today.purchasingInvoices'', N''PurchasingInvoices'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (33, NULL, N''PurchasingToPayAsOf'', N''Purchasing To Pay As Of'', N''Shows to pay as of items for purchasing.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadPurchasingToPayAsOf'', NULL, N''dashboards.widgets.today.purchasingToPayAsOf'', N''PurchasingToPayAsOf'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (34, NULL, N''PurchasingPayments'', N''Purchasing Payments'', N''Shows payment items for purchasing.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadPurchasingPayments'', NULL, N''dashboards.widgets.today.purchasingPayments'', N''PurchasingPayments'')

--INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
--VALUES (35, NULL, N''MediaOpenItems'', N''Media Open Items'', N''Shows open items for media.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadMediaOpenItems'', NULL, N''dashboards.widgets.today.mediaOpenItems'', N''MediaOpenItems'')

--INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
--VALUES (36, NULL, N''MediaOrdersNeedingAttention'', N''Media Orders Needing Attention'', N''Shows any media orders needing attention.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadMediaOrdersNeedingAttention'', NULL, N''dashboards.widgets.today.mediaOrdersNeedingAttention'', N''MediaOrdersNeedingAttention'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (37, NULL, N''AccountingItemsNeedingAttention'', N''Accounting Items Needing Attention'', N''Shows items needing attention for accounting.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadAccountingItemsNeedingAttention'', NULL, N''dashboards.widgets.today.accountingItemsNeedingAttention'', N''AccountingItemsNeedingAttention'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (38, NULL, N''AccountingAccountBalances'', N''Accounting Account Balances'', N''Shows your account balances.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadAccountingAccountBalances'', NULL, N''dashboards.widgets.today.accountingAccountBalances'', N''AccountingAccountBalances'')

--INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
--VALUES (39, NULL, N''AccountingFinancialReports'', N''Accounting Financial Reports'', N''Shows financial reports for accounting.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadAccountingFinancialReports'', NULL, N''dashboards.widgets.today.accountingFinancialReports'', N''AccountingFinancialReports'')

INSERT [dbo].[tWidgetDef] ([WidgetDefKey], [CompanyKey], [WidgetID], [Name], [Description], [TabName], [XPos], [YPos], [Width], [Height], [Local], [DisplayClass], [LoadFunction], [Disabled], [WidgetLocation], [Class]) 
VALUES (40, NULL, N''Schedule'', N''Schedule'', N''Shows your upcoming schedule.'', NULL, 1, 1, 2, 4, 1, N''HTML2'', N''loadSchedule'', NULL, N''dashboards.widgets.today.schedule'', N''Schedule'')

Update tWidgetDef Set DashID = ''Project'' Where WidgetDefKey < 20

Update tWidgetDef Set DashID = ''Today'' Where WidgetDefKey >= 20

SET IDENTITY_INSERT [dbo].[tWidgetEntity] ON 
INSERT [dbo].[tWidgetEntity] ([WidgetEntityKey], [Entity], [EntityDescription]) 
VALUES (1, N''ProjectSingle'', N''This is the dashboard for a single project.'')
INSERT [dbo].[tWidgetEntity] ([WidgetEntityKey], [Entity], [EntityDescription]) 
VALUES (2, N''Sales'', N''This is the sales dashboard.'')
INSERT [dbo].[tWidgetEntity] ([WidgetEntityKey], [Entity], [EntityDescription]) 
VALUES (3, N''Home'', N''These widgets are for the main home dashboard.'')
SET IDENTITY_INSERT [dbo].[tWidgetEntity] OFF

SET IDENTITY_INSERT [dbo].[tWidgetEntityAssigned] ON 
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (1, 2, 1)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (2, 2, 2)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (3, 2, 3)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (4, 2, 4)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (5, 2, 5)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (6, 2, 6)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (7, 1, 7)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (8, 1, 8)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (9, 1, 9)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (10, 1, 10)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (11, 1, 11)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (12, 1, 12)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (13, 1, 13)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (14, 1, 14)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (15, 1, 15)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (16, 1, 16)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (17, 1, 17)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (18, 1, 18)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (19, 1, 19)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (20, 3, 20)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (21, 3, 21)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (22, 3, 22)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (23, 3, 23)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (24, 3, 24)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (25, 3, 25)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (26, 3, 26)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (27, 3, 27)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (28, 3, 28)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (29, 3, 29)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (30, 3, 30)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (31, 3, 31)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (32, 3, 32)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (33, 3, 33)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (34, 3, 34)
--INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
--VALUES (35, 3, 35)
--INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
--VALUES (36, 3, 36)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (37, 3, 37)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (38, 3, 38)
--INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
--VALUES (39, 3, 39)
INSERT [dbo].[tWidgetEntityAssigned] ([WidgetEntityAssignedKey], [WidgetEntityKey], [WidgetDefKey]) 
VALUES (40, 3, 40)
SET IDENTITY_INSERT [dbo].[tWidgetEntityAssigned] OFF

-- (688217)

DELETE tString
DELETE tStringGroup

INSERT tStringGroup(StringGroupKey, StringGroupName, DisplayOrder) Values (2, ''Projects'', 2)
INSERT tStringGroup(StringGroupKey, StringGroupName, DisplayOrder) Values (6, ''Publication Dates'', 6)
INSERT tStringGroup(StringGroupKey, StringGroupName, DisplayOrder) Values (7, ''Broadcast Dates'', 7)
INSERT tStringGroup(StringGroupKey, StringGroupName, DisplayOrder) Values (8, ''General'', 1)
INSERT tStringGroup(StringGroupKey, StringGroupName, DisplayOrder) Values (9, ''Digital Art Review Fields'', 8)

INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''KeyUser1'', 2, ''Key Person 1'', NULL, NULL, 2, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''KeyUser2'', 2, ''Key Person 2'', NULL, NULL, 3, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''KeyUser3'', 2, ''Key Person 3'', NULL, NULL, 4, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''KeyUser4'', 2, ''Key Person 4'', NULL, NULL, 5, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''KeyUser5'', 2, ''Key Person 5'', NULL, NULL, 6, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''KeyUser6'', 2, ''Key Person 6'', NULL, NULL, 7, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaPrint1'', 6, ''User Defined 1'', ''Order Close'', NULL, 1, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaPrint2'', 6, ''User Defined 2'', ''Material Close'', NULL, 2, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaPrint3'', 6, ''User Defined 3'', NULL, NULL, 3, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaPrint4'', 6, ''User Defined 4'', NULL, NULL, 4, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaPrint5'', 6, ''User Defined 5'', NULL, NULL, 5, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaPrint6'', 6, ''User Defined 6'', NULL, NULL, 6, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaBroadcast1'', 7, ''User Defined 1'', NULL, NULL, 1, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaBroadcast2'', 7, ''User Defined 2'', NULL, NULL, 2, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaBroadcast3'', 7, ''User Defined 3'', NULL, NULL, 3, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaBroadcast4'', 7, ''User Defined 4'', NULL, NULL, 4, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaBroadcast5'', 7, ''User Defined 5'', NULL, NULL, 5, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''MediaBroadcast6'', 7, ''User Defined 6'', NULL, NULL, 6, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''Client'', 8, ''Client'', ''Client'', ''Clients'', 1, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''DARApprovalOption1'', 9, ''Approval Status Option 1'', ''Approved As Is'', NULL, 1, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''DARApprovalOption2'', 9, ''Approval Status Option 2'', ''Approved With Comments'', NULL, 2, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''DARApprovalOption3'', 9, ''Approval Status Option 3'', ''See Comments and Resubmit'', NULL, 3, 0, NULL)
INSERT tString(StringID, StringGroupKey, DisplayName, StringSingular, StringPlural, DisplayOrder, AllowDD, DefaultDD) Values (''DARApprovalOption4'', 9, ''Approval Status Option 4'', ''Rejected'', NULL, 4, 0, NULL)

DELETE tNotification

INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''ODTIME'', ''Overdue Time Sheets'', 1, 2, ''This will notify you on a daily or weekly basis of any time sheets that should have been submitted, but have not yet been sent out.'', 1, NULL, ''1*All People|2*People where I approve their time|3*People I supervise'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''NOHOURS'', ''Missing Time'', 1, 1, ''This will send you a daily email of all people who did not enter their hours the prior day'', 2, ''For'', ''1*All People|2*People where I approve their time|3*People I supervise'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''TASKUPDATE'', ''Task Completed Notification'', 2, 2, ''This will immediately send you an email whenever a task is completed.'', 2, ''For'', ''1*All Projects I am Assigned to|2*Projects where I am the account manager or project manager|3*Only Projects in my office'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''NEWPROJECT'', ''New Projects'', 2, 1, ''This will immediately send you an email when a project is added to the system'', 1, ''for'', ''1*All Projects|2*Projects where I am the project manager|3*Projects where I am the account manager'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''NEWSPECSHEET'', ''New Spec Sheet'', 2, 2, ''This will immediately send you an email when a spec sheet is added to any project you are assigned to'', 3, ''AnyOf'', NULL, NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''NEWVENDOR'', ''New Vendors'', 2, 4, ''This will immediately send you an email when a vendor is added to the system'', 1, NULL, NULL, NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''NEWCLIENT'', ''New Clients'', 2, 5, ''This will immediately send you an email when a client is added to the system'', 1, NULL, NULL, NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''UPDATESTATUS'', ''Changes in Project Status'', 2, 3, ''This will immediately notify you when the production status code changes on a project'', 2, ''for'', ''1*All Projects I am Assigned to|2*Projects where I am the account manager, project manager or billing manager|3*Only Projects in my office|4*All Projects'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''OVERBUDGET'', ''Overbudget Projects'', 1, 1, ''This will send you an email on a daily basis of all overbudget (in terms of total dollars) projects. This will only work on projects with an approved budget.'', 2, ''For'', ''1*My Projects|2*Projects where I am the account manager or project manager|3*Projects in my office|4*All Projects'', ''-30*Projects within 30% of Budget|-20*Projects within 20% of Budget|-10*Projects within 10% of Budget|-5*Projects within 5% of Budget|0*All Projects at budget|5*Projects 5 % over budget|10*Projects 10 % over budget|20*Projects 20 % over budget'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''OVERBUDGETTASK'', ''Overbudget Tasks'', 1, 2, ''This will send you an email on a daily basis of all overbudget (in terms of total dollars) tasks. This will only work on projects with an approved budget.'', 2, ''For'', ''1*My Projects|2*Projects where I am the account manager or project manager|3*Projects in my office|4*All Projects'', ''-30*Tasks within 30% of Budget|-20*Tasks within 20% of Budget|-10*Tasks within 10% of Budget|-5*Tasks within 5% of Budget|0*All Tasks at budget|5*Tasks 5 % over budget|10*Tasks 10 % over budget|20*Tasks 20 % over budget'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''OVERBUDGETSERVICE'', ''Overbudget by Service'', 1, 3, ''This will send you an email on a daily basis of all overbudget (in terms of total dollars) services. This will only work on projects with an approved budget.'', 2, ''For'', ''1*My Projects|2*Projects where I am the account manager or project manager|3*Projects in my office|4*All Projects'', ''-30*Services within 30% of Budget|-20*Services within 20% of Budget|-10*Services within 10% of Budget|-5*Services within 5% of Budget|0*All Services at budget|5*Services 5 % over budget|10*Services 10 % over budget|20*Services 20 % over budget'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''OVERBUDGETITEM'', ''Overbudget by Item'', 1, 4, ''This will send you an email on a daily basis of all overbudget (in terms of total dollars) items. This will only work on projects with an approved budget.'', 2, ''For'', ''1*My Projects|2*Projects where I am the account manager or project manager|3*Projects in my office'', ''-30*Items within 30% of Budget|-20*Items within 20% of Budget|-10*Items within 10% of Budget|-5*Items within 5% of Budget|0*All Items at budget|5*Items 5 % over budget|10*Items 10 % over budget|20*Items 20 % over budget'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''OVERWORKED'', ''Overworked Assignments'', 1, 5, ''This will send you an email on a daily basis of all overworked (in terms of actual hours have exceed allocated) assignments. This will only work on active, not completed projects with allocated hours on them.'', 4, ''For'', ''1*My Projects|2*Projects where I am the account manager or project manager|3*Projects in my office|4*All Projects'', ''-30*Tasks within 30% of task allocation|-20*Tasks within 20% of task allocation|-10*Tasks within 10% of task allocation|-5*Tasks within 5% of task allocation|0*All Tasks at task allocation|5*Tasks 5 % over task allocation|10*Tasks 10 % over task allocation|20*Tasks 20 % over task allocation'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''ODBILLING'', ''Overdue Billing Worksheets'', 1, 6, ''This will notify you on a daily basis of any billing worksheets that should have been approved, but have not yet been approved.'', 2, ''For'', ''1*My Billing Worksheets|2*All Billing Worksheets'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''ODESTIMATE'', ''Overdue Project Estimates'', 1, 7, ''This will notify you on a daily basis of any estimates that should have been approved, but have not yet been approved.'', 2, ''For'', ''1*My Estimates|2*All Estimates'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''TASKREMINDER'', ''Task Reminders'', 1, 8, ''This will notify you when tasks you are assigned to are about to be due. This email goes out once a day'', 2, ''For'', ''1*My Assigned Tasks on Active Projects|2*All Tasks on Active Projects I am assigned to|3*All Tasks on Active Projects I am the Account Manager or Project Manager'', ''0*Due On or Before Today|3*Due On or Before the Next 3 days|7*Due On or Before the Next 7 days|14*Due On or Before the Next 14 Days'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''DELIVERABLE'', ''Daily Deliverable Status'', 1, 9, ''This will send you a daily status email of all deliverables that have been sent for review and have approaching due dates'', 2, ''For'', ''1*All Deliverables I own on Active Projects|2*All Deliverables on Active Projects I am assigned to|3*All Deliverables on Active Projects I am the Account Manager or Project Manager'', ''0*Due On or Before Today|2*Due in the next 2 days|3*Due in the next 3 days|5*Due in the next 5 days'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''ESTIMATEAPPROVE'', ''Estimate Approval'', 2, 6, ''This will immediately notify you when the estimate has been approved'', 2, ''for'', ''1*All Projects|2*My Projects (where you are on the team)|3*Only Projects in my office'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''NEWOPPORTUNITY'', ''New Opportunities'', 2, 7, ''This will immediately send you an email when an opportunity is added to the system'', 1, NULL, NULL, NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''NEWCAMPAIGN'', ''New Campaigns'', 2, 8, ''This will immediately send you an email when an campaign is added to the system'', 1, ''for'', ''1*All Campaigns|2*Campaigns where I am the project manager|3*Campaigns where I am the account manager'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''ITEMSTOAPPROVE'', ''Items To Approve'', 2, 9, ''This will notify you on a daily basis of any items to approve in the notification bell'', 1, NULL, NULL, NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''UPDATEPROJECTSETTING'', ''Changes in Project Settings'', 2, 1, ''This will immediately send you an email when a project setting is changed in the system'', 1, ''for'', ''1*All Projects|2*Projects where I am the project manager|3*Projects where I am the account manager'', NULL)
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''TODOREMINDER'', ''To Do Reminders'', 1, 10, ''This will notify you when a to do you are assigned to is about to be due. This email goes out once a day'', 2, ''For'', NULL , ''0*Due On or Before Today|3*Due On or Before the Next 3 days|7*Due On or Before the Next 7 days|14*Due On or Before the Next 14 Days'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''OVERBUDGETCAMPAIGN'', ''Overbudget Campaign'', 1, 11, ''This will send you an email on a daily basis of all overbudget (in terms of total dollars) campaigns. This will only work on campaigns with an approved budget.'', 2, ''For'', ''1*My Campaigns|2*Campaigns where I am the account manager or project manager|3*All Campaigns'', ''-30*Campaigns within 30% of Budget|-20*Campaigns within 20% of Budget|-10*Campaigns within 10% of Budget|-5*Campaigns within 5% of Budget|0*All Campaigns at budget|5*Campaigns 5 % over budget|10*Campaigns 10 % over budget|20*Campaigns 20 % over budget'')
INSERT tNotification(NotificationID, NotificationName, DisplayGroup, DisplayOrder, Description, ValueType, ValueLabel, ValueDropDown, ValueDropDown2) Values (''UPDATEBILLINGSTATUS'', ''Changes in Project Billing Status'', 2, 12, ''This will immediately notify you when the production billing status code changes on a project'', 2, ''for'', ''1*All Projects I am Assigned to|2*Projects where I am the account manager, project manager or billing manager|3*Only Projects in my office|4*All Projects'', NULL)


-- tMobileMenu
DELETE tMobileMenu
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (1,  1, 1,'''', ''Projects'', ''projects.aspx?m=searchPage'', ''projectSearchList'', ''menuProjects'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (2,  2, 1,'''', ''My Tasks'', ''tasks.aspx?m=searchPage'', ''taskSearchList'', ''menuMyTasks'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (3,  3, 1,''calUseCalendar'', ''Calendar'', ''calendar.aspx?m=mainUI'', ''mainCalendar'', ''menuCalendar'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (6,  4, 1, ''useCompanies'', ''Companies'', ''clients.aspx?m=searchPage'', ''clientSearchList'', ''menuCompanies'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (7,  5, 1,''useContacts'', ''Contacts'', ''contacts.aspx?m=searchPage'', ''contactSearchList'', ''menuContacts'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (8,  6, 1,''useActivities'', ''Activities'', ''activities.aspx?m=searchPage'', ''activitySearchList'', ''menuActivities'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (4,  7, 1,''billingusetimesheet'', ''Time sheets'', ''timeentry.aspx?m=searchPage'', ''timeSheetSearchList'', ''menuTimesheets'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (5,  8, 1,'''', ''Approvals'', ''approvals.aspx?m=searchPage'', ''approvalList'', ''menuApprovals'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (9,  9, 1,''useOpp'', ''Opportunities'', ''opportunities.aspx?m=searchPage'', ''opportunitySearchList'', ''menuOpportunities'')
--INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) Values (10,  10, 1,'''', ''Project Requests'', ''projectRequests.aspx?m=searchPage'', ''projectRequestSearch'', ''menuProjectRequests'')
INSERT tMobileMenu (MobileMenuKey, DefaultDisplayOrder, DefaultSelection, RightID, Label, DataURL, PageID, Class) VALUES (11, 11, 1, ''billinguseexpenses'', ''Expense Reports'', ''expenseReports.aspx?m=searchPage'', ''expenseReportSearchList'', ''menuExpenseReports'')

/*
Delete tMobileSearchCondition Where MobileSearchKey in (Select MobileSearchKey from tMobileSearch Where UserKey is NULL)
Delete tMobileSearch Where UserKey is NULL

set identity_insert tMobileSearch on
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (1, NULL, ''Project'', NULL, ''Due In the Next Two Weeks'', ''Project Due Date'', ''ASC'', ''Client ID and Name'', 1, 3, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (2, NULL, ''Project'', NULL, ''Active Projects By Client'', ''Project Number'', ''ASC'', ''Client ID and Name'', 2, 1, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (3, NULL, ''Project'', NULL, ''Active Projects By Status'', ''Project Number'', ''ASC'', ''Project Status'', 3, 2, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (4, NULL, ''Contact'', NULL, ''My Contacts'', ''LastName'', ''ASC'', ''None'', 1, 4, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (5, NULL, ''Contact'', NULL, ''Contacts with an Activity in the next Week'', ''Next Activity Date'', ''ASC'', NULL, 2, 5, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (6, NULL, ''Contact'', NULL, ''All Active Contacts'', ''Contact First Name'', ''ASC'', NULL, 3, 6, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (7, NULL, ''MyTasks'', NULL, ''Due In The Next 7 Days'', ''Task Plan Completion Date'', ''ASC'', ''Priority'', 1, 6, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (8, NULL, ''MyTasks'', NULL, ''By Priority'', ''Task Plan Completion Date'', ''ASC'', ''Priority'', 2, 7, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (9, NULL, ''Opportunity'', NULL, ''My Opportunities'', ''Forecasted Close Date'', ''ASC'', ''Stage Name'', 1, 8, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (10, NULL, ''Opportunity'', NULL, ''Opportunities By Stage'', ''Forecasted Close Date'', ''ASC'', ''Stage Name'', 2, 9, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (11, NULL, ''Opportunity'', NULL, ''Opportunities By Status'', ''Forecasted Close Date'', ''ASC'', ''Status'', 3, 10, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (13, NULL, ''Activity'', NULL, ''Due By Today'', ''Activity Date'', ''ASC'', ''Activity Priority'', 2, 12, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (14, NULL, ''Activity'', NULL, ''All Activities'', ''Activity Date'', ''ASC'', NULL, 3, 13, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (15, NULL, ''TimeSheet'', NULL, ''All Open'', ''Start Date'', ''DESC'', ''Approval Status'', 1, 14, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (16, NULL, ''TimeSheet'', NULL, ''All Completed'', ''Start Date'', ''DESC'', ''Name'', 2, 15, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (17, NULL, ''TimeSheet'', NULL, ''My Open Time Sheets'', ''Start Date'', ''DESC'', ''Approval Status'', 3, 16, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (18, NULL, ''TimeSheet'', NULL, ''My Completed Time Sheets'', ''Start Date'', ''DESC'', NULL, 4, 17, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (19, NULL, ''ProjectRequest'', NULL, ''Open Requests'', ''Date Added'', ''DESC'', ''Client ID and Name'', 1, 18, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (20, NULL, ''ProjectRequest'', NULL, ''All Requests'', ''Date Added'', ''DESC'', ''Client ID and Name'', 2, 19, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (21, NULL, ''Company'', NULL, ''My Companies'', ''Company Name'', ''ASC'', NULL, 1, 20, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (22, NULL, ''Company'', NULL, ''Clients'', ''Company Name'', ''ASC'', NULL, 2, 21, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (23, NULL, ''Company'', NULL, ''Vendors'', ''Vendor ID'', ''ASC'', NULL, 3, 22, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (24, NULL, ''Company'', NULL, ''All Companies'', ''Company Name'', ''ASC'', NULL, 23, NULL, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (12, NULL, ''Activity'', NULL, ''My Activities'', ''Activity Date'', ''DESC'', ''Assigned To'', 1, 11, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (25, NULL, ''ExpenseReport'', NULL, ''All Open'', ''Start Date'', ''DESC'', ''Full Name'', 1, 24, 1, 0, '''')
INSERT tMobileSearch(MobileSearchKey, CompanyKey, ListID, UserKey, SearchName, SortField, SortDirection, GroupField, DisplayOrder, StdSearchKey, StandardSearch, Deleted) Values (26, NULL, ''ExpenseReport'', NULL, ''My Expense Reports'', ''Start Date'', ''DESC'', NULL, 1, 25, 1, 0, '''')
set identity_insert tMobileSearch off


set identity_insert tMobileSearchCondition on
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (1, 1, ''Project Due Date'', ''Is On or Before 2 Weeks From Today'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (2, 2, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (3, 3, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (4, 4, ''Contact Owner'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (5, 5, ''Next Activity Date'', ''Is On or Before A Week From Today'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (6, 6, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (7, 7, ''Assigned Staff'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (8, 7, ''Percentage Complete'', ''Less Than'', ''100'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (9, 7, ''Task Plan Completion Date'', ''Is On or Before A Week From Today'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (10, 7, ''Active Project'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (11, 8, ''Percentage Complete'', ''Less Than'', ''100'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (12, 8, ''Predecessors Completed'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (13, 8, ''Active Project'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (14, 9, ''Opportunity Owner Name'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (15, 9, ''Actual Close Date'', ''Is Blank'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (16, 10, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (17, 11, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (18, 12, ''Assigned To'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (19, 12, ''Activity Date Completed'', ''Is Blank'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (20, 13, ''Assigned To'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (21, 13, ''Activity Date'', ''Is On or Before Today'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (22, 15, ''Edit Status'', ''Equal To'', ''Open'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (23, 16, ''Approval Status'', ''Equal To'', ''Approved'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (24, 17, ''Name'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (25, 17, ''Edit Status'', ''Equal To'', ''Open'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (26, 18, ''Name'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (27, 18, ''Approval Status'', ''Equal To'', ''Approved'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (28, 19, ''Request Status'', ''Not Equal To'', ''Completed'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (29, 21, ''Account Manager Full Name'', ''Equal to My Name'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (30, 21, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (31, 22, ''Client ID'', ''Is Not Blank'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (32, 22, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (33, 23, ''Vendor ID'', ''Is Not Blank'', NULL, NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (34, 23, ''Active'', ''Equal To'', ''YES'', NULL)
INSERT tMobileSearchCondition(MobileSearchConditionKey, MobileSearchKey, FieldName, Condition, Value1, Value2) Values (35, 26, ''Full Name'', ''Equal to My Name'', NULL, NULL)
set identity_insert tMobileSearchCondition off

*/

delete tFinancialInstitution
INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(1, ''American Express (credit card)'',''3101'',''AMEX'',''https://online.americanexpress.com/myca/ofxdl/desktop/desktopDownload.do?request_type=nl_ofxdownload'')

--INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(4, ''Bank of America'',''5959'',''HAN'',''https://eftx.bankofamerica.com/eftxweb/access.ofx'')

--INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(5, ''Capital One Bank'',''1001'',''Hibernia'',''https://onlinebanking.capitalone.com/ofx/process.ofx'')
--INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(6, ''Chase (credit card)'',''10898'',''B1'',''https://ofx.chase.com'')
INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(7, ''Citi Bank (credit card)'',''24909'',''Citigroup'',''https://www.accountonline.com/cards/svc/citiofxmanager.do'')
--INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(7, ''Citi Bank (credit card)'',''24909'',''Citigroup'',''https://secureofx2.bankhost.com/citi/cgi-forte/ofx_rt?servicename=ofx_rt&pagename=ofx'')
--INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(8, ''Discover Card (credit card)'',''7101'',''Discover Financial Services'',''https://ofx.discovercard.com/'')
--INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(9, ''LaSalle Bank'',''1101'',''LaSalleBankMidwest'',''https://www.oasis.cfree.com/1101.ofxgp'')
INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(10, ''National City'',''5860'',''NATIONAL CITY'',''https://ofx.nationalcity.com/ofx/OFXConsumer.aspx'')
--INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(11, ''PNC Bank'',''4501'',''ISC'',''https://www.oasis.cfree.com/test.ofxgp'')
INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(12, ''Wachovia'',''4309'',''Wachovia'',''https://pfmpw.wachovia.com/cgi-forte/fortecgi?servicename=ofx&pagename=PFM'')
INSERT tFinancialInstitution(FinancialInstitutionKey, FIName, FIID, FIOrg, FIUrl) Values(13, ''Union Bank of California'',''2901'',''Union Bank of California'',''https://www.oasis.cfree.com/2901.ofxgp'')

-- Run this on PAAdmin if more currencies are added
delete tCurrency

Insert tCurrency (CurrencyID, Description) Values(''AED'', ''Arab Emirates Dirham'')
Insert tCurrency (CurrencyID, Description) Values(''ARS'', ''Argentine Peso'')
Insert tCurrency (CurrencyID, Description) Values(''AUD'', ''Australian Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''AWG'', ''Aruban Florin'')
Insert tCurrency (CurrencyID, Description) Values(''BAM'', ''Convertible Mark'')
Insert tCurrency (CurrencyID, Description) Values(''BBD'', ''Barbadian Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''BDT'', ''Bangladeshi Taka'')
Insert tCurrency (CurrencyID, Description) Values(''BGN'', ''Bulgarian Lev'')
Insert tCurrency (CurrencyID, Description) Values(''BHD'', ''Bahraini Dinar'')
Insert tCurrency (CurrencyID, Description) Values(''BMD'', ''Bermudian Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''BOB'', ''Bolivian Boliviano'')
Insert tCurrency (CurrencyID, Description) Values(''BRL'', ''Brazilian Real'')
Insert tCurrency (CurrencyID, Description) Values(''BSD'', ''Bahamian Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''CAD'', ''Canadian Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''CHF'', ''Swiss Franc'')
Insert tCurrency (CurrencyID, Description) Values(''CLP'', ''Chilean Peso'')
Insert tCurrency (CurrencyID, Description) Values(''CNY'', ''Chinese Yuan'')
Insert tCurrency (CurrencyID, Description) Values(''COP'', ''Colombian Peso'')
Insert tCurrency (CurrencyID, Description) Values(''CZK'', ''Czech Koruna'')
Insert tCurrency (CurrencyID, Description) Values(''DKK'', ''Danish Krone'')
Insert tCurrency (CurrencyID, Description) Values(''EGP'', ''Egyptian Pound'')
Insert tCurrency (CurrencyID, Description) Values(''EUR'', ''Euro'')
Insert tCurrency (CurrencyID, Description) Values(''FJD'', ''Fijian Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''GBP'', ''British Pound Sterling'')
Insert tCurrency (CurrencyID, Description) Values(''GHS'', ''Ghana Cedi'')
Insert tCurrency (CurrencyID, Description) Values(''GMD'', ''Gambian Dalasi'')
Insert tCurrency (CurrencyID, Description) Values(''GTQ'', ''Guatemalan Quetzal'')
Insert tCurrency (CurrencyID, Description) Values(''HKD'', ''Hong Kong Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''HRK'', ''Croatian Kuna'')
Insert tCurrency (CurrencyID, Description) Values(''HUF'', ''Hungarian Forint'')
Insert tCurrency (CurrencyID, Description) Values(''IDR'', ''Indonesian Rupiah'')
Insert tCurrency (CurrencyID, Description) Values(''ILS'', ''Israeli Sheqel'')
Insert tCurrency (CurrencyID, Description) Values(''INR'', ''Indian Rupee'')
Insert tCurrency (CurrencyID, Description) Values(''ISK'', ''Icelandic Krona'')
Insert tCurrency (CurrencyID, Description) Values(''JMD'', ''Jamaican Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''JOD'', ''Jordanian Dinar'')
Insert tCurrency (CurrencyID, Description) Values(''JPY'', ''Japanese Yen'')
Insert tCurrency (CurrencyID, Description) Values(''KES'', ''Kenyan Shilling'')
Insert tCurrency (CurrencyID, Description) Values(''KHR'', ''Cambodian Riel'')
Insert tCurrency (CurrencyID, Description) Values(''KRW'', ''South Korean Won'')
Insert tCurrency (CurrencyID, Description) Values(''KWD'', ''Kuwaiti Dinar'')
Insert tCurrency (CurrencyID, Description) Values(''LAK'', ''Lao Kip'')
Insert tCurrency (CurrencyID, Description) Values(''LBP'', ''Lebanese Pound'')
Insert tCurrency (CurrencyID, Description) Values(''LKR'', ''Sri Lankan Rupee'')
Insert tCurrency (CurrencyID, Description) Values(''LTL'', ''Lithuanian Litas'')
Insert tCurrency (CurrencyID, Description) Values(''LVL'', ''Latvian Lats'')
Insert tCurrency (CurrencyID, Description) Values(''MAD'', ''Moroccan Dirham'')
Insert tCurrency (CurrencyID, Description) Values(''MDL'', ''Moldovan Leu'')
Insert tCurrency (CurrencyID, Description) Values(''MGA'', ''Malagasy Ariary'')
Insert tCurrency (CurrencyID, Description) Values(''MKD'', ''Macedonian Denar'')
Insert tCurrency (CurrencyID, Description) Values(''MUR'', ''Mauritian Rupee'')
Insert tCurrency (CurrencyID, Description) Values(''MVR'', ''Maldivian Rufiyaa'')
Insert tCurrency (CurrencyID, Description) Values(''MXN'', ''Mexican Peso'')
Insert tCurrency (CurrencyID, Description) Values(''MYR'', ''Malaysian Ringgit'')
Insert tCurrency (CurrencyID, Description) Values(''NAD'', ''Namibian Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''NGN'', ''Nigerian Naira'')
Insert tCurrency (CurrencyID, Description) Values(''NOK'', ''Norwegian Krone'')
Insert tCurrency (CurrencyID, Description) Values(''NPR'', ''Nepalese Rupee'')
Insert tCurrency (CurrencyID, Description) Values(''NZD'', ''New Zealand Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''OMR'', ''Omani Rial'')
Insert tCurrency (CurrencyID, Description) Values(''PAB'', ''Panamanian Balboa'')
Insert tCurrency (CurrencyID, Description) Values(''PEN'', ''Peruvian Sol'')
Insert tCurrency (CurrencyID, Description) Values(''PHP'', ''Philippine Peso'')
Insert tCurrency (CurrencyID, Description) Values(''PKR'', ''Pakistani Rupee'')
Insert tCurrency (CurrencyID, Description) Values(''PLN'', ''Polish Zloty'')
Insert tCurrency (CurrencyID, Description) Values(''PYG'', ''Paraguayan Guaraní'')
Insert tCurrency (CurrencyID, Description) Values(''QAR'', ''Qatari Riyal'')
Insert tCurrency (CurrencyID, Description) Values(''RON'', ''Romanian Leu'')
Insert tCurrency (CurrencyID, Description) Values(''RSD'', ''Serbian Dinar'')
Insert tCurrency (CurrencyID, Description) Values(''RUB'', ''Russian Rouble'')
Insert tCurrency (CurrencyID, Description) Values(''SAR'', ''Saudi Riyal'')
Insert tCurrency (CurrencyID, Description) Values(''SCR'', ''Seychellois Rupee'')
Insert tCurrency (CurrencyID, Description) Values(''SEK'', ''Swedish Krona'')
Insert tCurrency (CurrencyID, Description) Values(''SGD'', ''Singapore Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''SYP'', ''Syrian Pound'')
Insert tCurrency (CurrencyID, Description) Values(''THB'', ''Thai Baht'')
Insert tCurrency (CurrencyID, Description) Values(''TND'', ''Tunisian Dinar'')
Insert tCurrency (CurrencyID, Description) Values(''TRY'', ''Turkish Lira'')
Insert tCurrency (CurrencyID, Description) Values(''TWD'', ''Taiwanese Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''UAH'', ''Ukraine Hryvnia'')
Insert tCurrency (CurrencyID, Description) Values(''UGX'', ''Ugandan Shilling'')
Insert tCurrency (CurrencyID, Description) Values(''UYU'', ''Uruguayan Peso'')
Insert tCurrency (CurrencyID, Description) Values(''USD'', ''US Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''VEF'', ''Venezuelan Bolívar'')
Insert tCurrency (CurrencyID, Description) Values(''VND'', ''Vietnamese Dong'')
Insert tCurrency (CurrencyID, Description) Values(''XAF'', ''Central African Franc'')
Insert tCurrency (CurrencyID, Description) Values(''XCD'', ''East Caribbean Dollar'')
Insert tCurrency (CurrencyID, Description) Values(''XOF'', ''West African Franc'')
Insert tCurrency (CurrencyID, Description) Values(''XPF'', ''CFP Franc'')
Insert tCurrency (CurrencyID, Description) Values(''ZAR'', ''South African Rand'')

delete tTaskUserStatus Where TaskUserStatusKey < 1000
set identity_insert tTaskUserStatus on
Insert tTaskUserStatus (TaskUserStatusKey, EntityKey, Entity, StatusName, IsDefault, DisplayOrder, DefaultPercentComp) Values (1, NULL, NULL, ''Work to be Done'', 1, 1, 0)
Insert tTaskUserStatus (TaskUserStatusKey, EntityKey, Entity, StatusName, IsDefault, DisplayOrder, DefaultPercentComp) Values (2, NULL, NULL, ''Do This Today'', 0, 2, 0)
Insert tTaskUserStatus (TaskUserStatusKey, EntityKey, Entity, StatusName, IsDefault, DisplayOrder, DefaultPercentComp) Values (3, NULL, NULL, ''Completed'', 0, 3, 100)
set identity_insert tTaskUserStatus off

delete from tBankAccountType

set identity_insert dbo.tBankAccountType ON
Insert tBankAccountType (BankAccountTypeKey, BankAccountType) VALUES (1, ''Checking'')
Insert tBankAccountType (BankAccountTypeKey, BankAccountType) VALUES (2, ''Saving'')
set identity_insert dbo.tBankAccountType OFF

--Save off any current services that are logging
SELECT	TMServiceKey
INTO	#TMLogActive
FROM	tTMLogService (nolock)
WHERE	LogActive = 1

--Seed the TM services
DELETE	tTMLogService

INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(1, ''Calendar'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(2, ''CheckWebsite'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(3, ''SendNotifications'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(4, ''DeleteWebFiles'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(5, ''ScheduleUpdate'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(6, ''Import'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(7, ''ReadEmails'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(8, ''ReverseJournalEntries'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(9, ''EmailMarketing'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(10, ''GoogleSync'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(11, ''DailyTasks'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(12, ''ArcManager'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(14, ''ApiWebHooks'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(15, ''ProjectRollup'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(16, ''SMTP'')
INSERT	tTMLogService (TMServiceKey, ServiceName) VALUES(17, ''ProcessBase64Attachments'')

--Turn logging back on for any that were logging when the seed script ran
UPDATE	tTMLogService
SET		LogActive = 1
FROM	tTMLogService
INNER JOIN #TMLogActive tmp ON tTMLogService.TMServiceKey = tmp.TMServiceKey

IF NOT EXISTS 
		(SELECT NULL
		FROM	tRTNActive (nolock))
	INSERT	tRTNActive (Active) VALUES (1)

--Seed the help guide links
TRUNCATE TABLE tHelpGuideLink

INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.dashboard.dash'', ''Project dashboard [in-depth guide] – Workamajig'', ''Gain an in-depth understanding of project dashboards and learn how to customize yours for maximum benefit.'', ''https://support.workamajig.com/hc/en-us/articles/360022821011-Project-dashboard-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.dashboard.dash'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.schedule.edit2'', ''Project schedule overview [in-depth guide] – Workamajig'', ''Discover how to schedule your projects and understand how to use the more advanced features for your benefit.'', ''https://support.workamajig.com/hc/en-us/articles/360022860831-Project-schedule-overview-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.schedule.edit2'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.diary.thread'', ''Project conversation [in-depth guide] – Workamajig'', ''Enhance collaboration by learning how to easily create, reply to, view, and subscribe others to the conversations. Also learn how to choose which conversations will be visible to the client.'', ''https://support.workamajig.com/hc/en-us/articles/4409614779924-Project-conversation-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.diary.thread'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''today.creative'', ''Creatives > Today creatives page [guide] – Workamajig'', ''Easily and efficiently keep track of tasks with this basic guide for creative users.'', ''https://support.workamajig.com/hc/en-us/articles/360022619492-Creatives-Today-creatives-page-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=today.creative'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.files.list'', ''Project files [in-depth guide] – Workamajig'', ''Make the most of your Project files with this guide manage, navigate, and send files for review.'', ''https://support.workamajig.com/hc/en-us/articles/360022647752-Project-files-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.files.list'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''user.timeEntry.edit'', ''Everyone > Time sheet page [guide] – Workamajig'', ''Learn how to work your timer, submit hours and get time sheets approved.'', ''https://support.workamajig.com/hc/en-us/articles/360022808811-Everyone-Time-sheet-page-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=user.timeEntry.edit'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.setup.edit'', ''Project Manager > Projects page [guide] – Workamajig'', ''Easily set up projects with templates and pre-populated forms.'', ''https://support.workamajig.com/hc/en-us/articles/360022855111-New-project-in-depth-guide-#h_773936660461549305604323?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.setup.edit'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''user.editTime'', ''Everyone > Time sheet page [guide] – Workamajig'', ''Understanding the multiple places available for users to enter time, depending on your needs & preferences.'', ''https://support.workamajig.com/hc/en-us/articles/360022808811-Everyone-Time-sheet-page-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=user.editTime'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.deliverables.rounds.review'', ''Deliverables overview [in-depth guide] – Workamajig'', ''Your in-depth guide to project deliverables - setting them up, using advanced features, and sending for review.'', ''https://support.workamajig.com/hc/en-us/articles/360022648112-Deliverables-overview-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.deliverables.rounds.review'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.production.dash'', ''Project Manager > Projects page [guide] – Workamajig'', ''Project manager? Learn to navigate new projects, view financial status, project schedules, and more.'', ''https://support.workamajig.com/hc/en-us/articles/360022820951-Project-Manager-Projects-page-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.production.dash'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''purchasing.vouchers.edit'', ''Purchasing > Vendor Invoices [in-depth guide] - Workamajig'', ''Create vendor invoices with ease with this in-depth guide on how to create, edit, and schedule them.'', ''https://support.workamajig.com/hc/en-us/articles/360022665812-Vendor-invoices-overview-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=purchasing.vouchers.edit'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''billing.invoices.edit'', ''Billing > Indepth Guides for Billing - Workamajig'', ''Manually create and edit client invoices with this in-depth guide.'', ''https://support.workamajig.com/hc/en-us/articles/360033507972-Client-invoices-overview-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=billing.invoices.edit'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.diary.reply'', ''Project conversation [in-depth guide] – Workamajig'', ''Navigate project conversations with confidence - get familiar with how to use them in this guide.'', ''https://support.workamajig.com/hc/en-us/articles/4409614779924-Project-conversation-in-depth-guide-#h_01FM5EQ2MZ8YX295K16HJ431S9?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.diary.reply'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.diary.add'', ''Project conversation [in-depth guide] – Workamajig'', ''Navigate project conversations with confidence - get familiar with how to use them in this guide.'', ''https://support.workamajig.com/hc/en-us/articles/4409614779924-Project-conversation-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.diary.thread'')
INSERT tHelpGuideLink (PageAID, Title, Description, Link) VALUES (''projects.diary.dash'', ''Project conversation [in-depth guide] – Workamajig'', ''Enhance collaboration by learning how to easily create, reply to, view, and subscribe others to the conversations. Also learn how to choose which conversations will be visible to the client.'', ''https://support.workamajig.com/hc/en-us/articles/4409614779924-Project-conversation-in-depth-guide-?utm_source=app&utm_medium=click&utm_campaign=in-app-support&utm_page=projects.diary.thread'')
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptLayoutCopy]'
GO
IF OBJECT_ID(N'[dbo].[sptLayoutCopy]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptLayoutCopy]
	@LayoutKey int
AS

/*
|| When      Who Rel      What
|| 04/20/10  CRG 10.5.2.2 Created to make a copy of a layout
|| 10/28/10  GHL 10.5.3.7 Added Task Show Transactions field
|| 01/27/16  MFT 10.6.0.0 Added PrintAtBottom
|| 03/04/16  MFT 10.6.0.1 (292144) Added EstLineFormat
|| 06/05/26  GAR 26.07.19 (712815) Added @URL for hyperlink controls
*/

	DECLARE	@NewLayoutKey int,
			@LayoutReportKey int,
			@NewLayoutReportKey int,
			@Entity varchar(50)
			
	SELECT	@Entity = Entity
	FROM	tLayout (nolock)
	WHERE	LayoutKey = @LayoutKey
	
	INSERT	tLayout
			(CompanyKey,
			LayoutName,
			Entity,
			Active,
			TaskDetailOption,
			TaskShowTransactions,
			EstLineFormat)
	SELECT	CompanyKey,
			''Copy of '' + ISNULL(LayoutName, ''''),
			Entity,
			Active,
			TaskDetailOption,
			TaskShowTransactions,
			EstLineFormat
	FROM	tLayout (nolock)
	WHERE	LayoutKey = @LayoutKey
	
	SELECT	@NewLayoutKey = @@IDENTITY
	
	IF @Entity = ''billing''
	BEGIN
		INSERT	tLayoutBilling
				(LayoutKey,
				Entity,
				EntityKey,
				ParentEntity,
				ParentEntityKey,
				DisplayOption,
				DisplayOrder,
				LayoutOrder,
				LayoutLevel)
		SELECT	@NewLayoutKey,
				Entity,
				EntityKey,
				ParentEntity,
				ParentEntityKey,
				DisplayOption,
				DisplayOrder,
				LayoutOrder,
				LayoutLevel
		FROM	tLayoutBilling (nolock)
		WHERE	LayoutKey = @LayoutKey
	END
	
	SELECT	@LayoutReportKey = 0
	
	WHILE(1=1)
	BEGIN
		SELECT	@LayoutReportKey = MIN(LayoutReportKey)
		FROM	tLayoutReport (nolock)
		WHERE	LayoutKey = @LayoutKey
		AND		LayoutReportKey > @LayoutReportKey
		
		IF @LayoutReportKey IS NULL
			BREAK
		
		INSERT	tLayoutReport
				(LayoutKey,
				Entity,
				PaperType,
				PaperWidth,
				PaperHeight,
				PaperOrientation,
				MarginTop,
				MarginBottom,
				MarginLeft,
				MarginRight,
				Watermark,
				WatermarkSizeMode,
				WatermarkAlignment)
		SELECT	@NewLayoutKey,
				Entity,
				PaperType,
				PaperWidth,
				PaperHeight,
				PaperOrientation,
				MarginTop,
				MarginBottom,
				MarginLeft,
				MarginRight,
				Watermark,
				WatermarkSizeMode,
				WatermarkAlignment
		FROM	tLayoutReport (nolock)
		WHERE	LayoutReportKey = @LayoutReportKey
	
		SELECT	@NewLayoutReportKey = @@IDENTITY
	
		INSERT	tLayoutSection
				(LayoutReportKey,
				ElementID,
				ParentID,
				ReportTag,
				Type,
				Name,
				BackColor,
				BorderColor,
				BorderStyle,
				BorderLeft,
				BorderRight,
				BorderTop,
				BorderBottom,
				BorderThickness,
				Shadow,
				X,
				Y,
				Height,
				Width,
				CanGrow,
				CanShrink,
				PrintAtBottom)
		SELECT	@NewLayoutReportKey,
				ElementID,
				ParentID,
				ReportTag,
				Type,
				Name,
				BackColor,
				BorderColor,
				BorderStyle,
				BorderLeft,
				BorderRight,
				BorderTop,
				BorderBottom,
				BorderThickness,
				Shadow,
				X,
				Y,
				Height,
				Width,
				CanGrow,
				CanShrink,
				PrintAtBottom
		FROM	tLayoutSection (nolock)
		WHERE	LayoutReportKey = @LayoutReportKey
				
		INSERT	tLayoutItems
				(LayoutReportKey,
				ElementID,
				ParentID,
				ReportTag,
				Type,
				Name,
				BackColor,
				BorderColor,
				BorderStyle,
				BorderLeft,
				BorderRight,
				BorderTop,
				BorderBottom,
				BorderThickness,
				Shadow,
				X,
				Y,
				Height,
				Width,
				Text,
				FontFamily,
				FontSize,
				FontItalic,
				FontBold,
				FontUnderline,
				TextAlign,
				LineColor,
				LineStyle,
				LineWeight,
				X1,
				Y1,
				X2,
				Y2,
				CornerRadius,
				ShapeType,
				ImageAlignment,
				ImageMode,
				DataField,
				ConfigData,
				ForeColor,
				ImageData,
				CanGrow,
				CanShrink,
				WordWrap,
				DataType,
				DecimalPlaces,
				ShowCurrencySymbol,
				URL)
		SELECT	@NewLayoutReportKey,
				ElementID,
				ParentID,
				ReportTag,
				Type,
				Name,
				BackColor,
				BorderColor,
				BorderStyle,
				BorderLeft,
				BorderRight,
				BorderTop,
				BorderBottom,
				BorderThickness,
				Shadow,
				X,
				Y,
				Height,
				Width,
				Text,
				FontFamily,
				FontSize,
				FontItalic,
				FontBold,
				FontUnderline,
				TextAlign,
				LineColor,
				LineStyle,
				LineWeight,
				X1,
				Y1,
				X2,
				Y2,
				CornerRadius,
				ShapeType,
				ImageAlignment,
				ImageMode,
				DataField,
				ConfigData,
				ForeColor,
				ImageData,
				CanGrow,
				CanShrink,
				WordWrap,
				DataType,
				DecimalPlaces,
				ShowCurrencySymbol,
				URL
		FROM	tLayoutItems (nolock)
		WHERE	LayoutReportKey = @LayoutReportKey
		
	END

	RETURN @NewLayoutKey
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptLayoutProjectItemRollup]'
GO
IF OBJECT_ID(N'[dbo].[sptLayoutProjectItemRollup]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptLayoutProjectItemRollup]
	(
	@CompanyKey int
	,@Entity varchar(50) -- ''tCampaign'', ''tCampaignNoSegment'', ''tCampaignSegment'', ''tProject'', etc...
	,@EntityKey int
	,@LayoutKey int
	)
AS
	SET NOCOUNT ON
	
/*
|| When      Who Rel      What
|| 01/07/10  GHL 10.5.1.? Creation for campaign layouts
||                        Returns:
||                        Billing Item 1, Item 1, rollup values
||                        Billing Item 1, Item 2, rollup values
||                        Billing Item 2, Item 3, rollup values
||                        Billing Item 2, Item 4, rollup values
|| 01/14/10  CRG 10.5.1.7 Modified to use customized billing item names for the entity
|| 01/26/10  GHL 10.5.1.7 Added @Entity,@EntityKey as part of the results to be used in grids for drill downs
|| 4/21/10   GHL 10.5.2.2 Added additional columns for campaign estimates 
|| 10/7/10   RLB 10.5.3.6 (89933)Added Sales Tax   AmountBilled - AmountBilledNoTax
|| 10/7/10   RLB 10.5.3.7 Added Total Gross Unbilled Fixed Fee
|| 11/15/10  GHL 10.5.3.8 (93504) During testing for 93504, found out that TotalGross was incorrect due to the fact that
||                        OpenOrderGross used to be calculated for unbilled po, but now includes them
||                        so use OpenOrderGrossUnbilled = tProjectItemRollup.OpenOrderUnbilled 
|| 01/04/13  WDF 10.5.6.3 Added DepartmentName
|| 01/07/13  GHL 10.5.6.3 Added nolock hints
|| 02/18/13 GHL 10.5.6.5 (168695) Added Allocated hours
|| 03/06/13 GHL 10.566   (167702) Added Total Gross After WriteOff
|| 06/27/13 MFT 10.569   (177496) Corrected HoursBilledRemaining calc
|| 10/08/13 GHL 10.573    Using now PTotalCost to support multi currency
|| 10/31/13 GHL 10.573    When LayoutKey = 0, manufacture a unique WorkTypeDisplayOrder for sorts on grids
||                       (because of some sorting issues on the project budget screen by BI and Item, 
||                        Phoenix Marketing, project OAPI1001)
||                       (193975) Added PurchasedQty and Budgeted Quantities
|| 11/15/13 GHL 10.573   (196880) Corrected typo with the WorkTypeDisplayOrder when LayoutKey > 0
|| 03/09/15 GHL 10.590   Added values for ItemID for ServiceKey = 0 for Abelson Taylor
||                       Could happen now if estimate is by title only
|| 05/26/16 GHL 10.604   (295137) Added write off data for enhancement for AT
|| 01/10/17 GHL 10.612  (326322) Recalculating now Costs Gross After WO w/o Orders as:
||                       Total Cost Gross - Expense WO instead of Inside Costs Gross + Voucher Gross - Expense WO
||                      Added Open Orders Unbilled to Costs Gross After WO w Orders for consistency with other budgets
|| 04/14/17 GHL 10.615  (340960) Added pulling of HoursWriteOff from tProjectItemRollup at the top 
|| 10/26/17 RLS 10.621   Added RemainingAllocatedHours
|| 08/04/21 MCM 21.090  (566562) Added CurrentTotalBudgetNoTax
|| 08/27/21 MCM 21.090  (566456) Added HoursUnbilled 
|| 11/22/21 MCM 21.12x  (578053) Added LaborHoursWriteOff
|| 07/22/22 RLS 22.08x  (606282) Changes ItemName to nvarchar
|| 01/29/25 RLB 25.03.16 (688067) adding new fields CurrentBudgetExpenseQuantity and ActualQuantity for Project item for project budget bash 
|| 08/18/25 RLB 25.10.19 (707695) adding new field RemainingAllocatedHoursP temp table will need this field
|| 04/13/25 RLB 26.05.17 (726310) added missing fields FutureLaborGrossRemaining, FutureAllocatedGross, AllocatedGross, FutureAllocatedHours. They are on other tabs but not this one
|| 06/29/26 MCM 26.07.x  (731430) Updated logic of ToBillRemaining and ToBillRemainingP to subtract AmountBilledNoTax
*/

	create table #projects(ProjectKey int null)

	-- other data, non summarized in tProjectRollup...
	create table #project_other(Entity varchar(50) null, EntityKey int null, AllocatedHours decimal(24,4) null, FutureAllocatedHours decimal(24,4) null, AllocatedGross money null, FutureAllocatedGross money null, projectKey int NULL, )
	
	-- Project Item Rollup table	
	create table #roll (
	    Entity varchar(50) NULL, -- tItem, tService
		EntityKey int NULL,      -- ItemKey, ServiceKey
		ItemID varchar(50),      -- ItemID or ServiceCode
		ItemName nvarchar(200),   -- ItemName or Description
		DepartmentName varchar(200) NULL,
		WorkTypeKey int,
		WorkTypeID varchar(100),
		WorkTypeName varchar(200),		
		WorkTypeDisplayOrder int, -- WorkType display order

		-- these fields are in tProjectItemRollup
		Hours decimal(24, 4) NULL ,
		HoursApproved decimal(24, 4) NULL ,
		HoursBilled decimal(24, 4) NULL ,
		HoursInvoiced decimal(24, 4) NULL ,
		HoursWriteOff decimal(24,4) null,
		HoursAfterWriteOff decimal(24,4) null,
		HoursUnbilled decimal(24, 4) NULL,
		LaborNet money NULL ,
		LaborNetApproved money NULL ,
		LaborGross money NULL ,
		LaborGrossApproved money NULL ,
		LaborUnbilled money NULL ,
		LaborBilled money NULL ,
		LaborInvoiced money NULL ,
		LaborWriteOff money NULL ,
		LaborHoursWriteOff money NULL ,
		LaborGrossAfterWriteOff money NULL ,
		MiscCostNet money NULL ,
		MiscCostGross money NULL ,
		MiscCostUnbilled money NULL ,
		MiscCostWriteOff money NULL ,
		MiscCostBilled money NULL ,
		MiscCostInvoiced money NULL ,
		ExpReceiptNet money NULL ,
		ExpReceiptNetApproved money NULL ,
		ExpReceiptGross money NULL ,
		ExpReceiptGrossApproved money NULL ,
		ExpReceiptUnbilled money NULL ,
		ExpReceiptWriteOff money NULL ,
		ExpReceiptBilled money NULL ,
		ExpReceiptInvoiced money NULL ,
		VoucherNet money NULL ,
		VoucherNetApproved money NULL ,
		VoucherGross money NULL ,
		VoucherGrossApproved money NULL ,
		VoucherOutsideCostsGross money NULL ,
		VoucherOutsideCostsGrossApproved money NULL ,
		VoucherUnbilled money NULL ,
		VoucherWriteOff money NULL ,
		VoucherBilled money NULL ,
		VoucherInvoiced money NULL ,
		OpenOrdersNet money NULL ,
		OpenOrderNetApproved money NULL ,
		OpenOrderGross money NULL ,
		OpenOrderGrossApproved money NULL ,
		OpenOrderUnbilled money NULL ,
		OrderPrebilled money NULL ,
		AmountBilled money NULL ,
		AmountBilledNoTax money NULL ,
		AdvanceBilled money NULL ,
		AdvanceBilledOpen money NULL,

		AllocatedHours decimal(24,4) null,
		FutureAllocatedHours decimal(24,4) null,
		AllocatedGross money null,
		FutureAllocatedGross money null,
		FutureLaborGrossRemaining money null,

		SalesTax money NULL,
		TotalGrossUnbilledFixedFee money NULL,
		EstQty decimal(24,4) NULL,
		EstNet money NULL,
		EstGross money NULL,
		EstCOQty decimal(24,4) NULL,
		EstCONet money NULL,
		EstCOGross money NULL,
		
		-- Actuals fields...Cloned from spRptBudgetAnalysis
		OutsideCostsNet money null
		,InsideCostsNet money null
		
		,OpenOrdersGrossUnbilled money null
		,OutsideCostsGrossUnbilled money null
		,InsideCostsGrossUnbilled money null
		
		,OutsideCostsGross money null
		,InsideCostsGross money null
		
		,ExpenseWriteOff money null		
		,ExpenseBilled money null		
		,ExpenseInvoiced money null	
		
		,ActualQuantity decimal(24,4)
				
		-- Budget fields...Cloned from spRptBudgetAnalysis
		,CurrentBudgetHours decimal(24,4) null
		,CurrentBudgetQty decimal(24,4) null
		,CurrentBudgetLaborNet money null
		,CurrentBudgetLaborGross money null
		,CurrentBudgetExpenseNet money null
		,CurrentBudgetExpenseGross money null
		,CurrentBudgetContingency money null
		,CurrentTotalBudget money null
		,CurrentTotalBudgetCont money null
		,CurrentTotalBudgetWithTax money null		-- not calc''ed, but added for rendering on the grid (was blank)
		,CurrentTotalBudgetContWithTax money null
		,CurrentTotalBudgetNoTax money null
		,CurrentBudgetExpenseQuantity decimal(24,4)

		,COBudgetHours decimal(24,4) null
		,COBudgetQty decimal(24,4) null
		,COBudgetLaborNet money null
		,COBudgetLaborGross money null
		,COBudgetExpenseNet money null
		,COBudgetExpenseGross money null
		,COBudgetContingency money null
		,COTotalBudget money null
		,COTotalBudgetCont money null
		,COTotalBudgetWithTax money null
		,COTotalBudgetContWithTax money null

		,OriginalBudgetHours decimal(24,4) null
		,OriginalBudgetQty decimal(24,4) null
		,OriginalBudgetLaborNet money null
		,OriginalBudgetLaborGross money null
		,OriginalBudgetExpenseNet money null
		,OriginalBudgetExpenseGross money null
		,OriginalBudgetContingency money null
		,OriginalTotalBudget money null
		,OriginalTotalBudgetCont money null
		,OriginalTotalBudgetWithTax money null
		,OriginalTotalBudgetContWithTax money null
		
		-- Campaign Budget fields
		,C_CurrentBudgetHours decimal(24,4) null
		,C_CurrentBudgetLaborNet money null
		,C_CurrentBudgetLaborGross money null
		,C_CurrentBudgetExpenseNet money null
		,C_CurrentBudgetExpenseGross money null
		,C_CurrentBudgetContingency money null
		,C_CurrentTotalBudget money null
		,C_CurrentTotalBudgetWithTax money null
		,C_CurrentTotalBudgetCont money null
		,C_CurrentTotalBudgetContWithTax money null

		,C_COBudgetHours decimal(24,4) null
		,C_COBudgetLaborNet money null
		,C_COBudgetLaborGross money null
		,C_COBudgetExpenseNet money null
		,C_COBudgetExpenseGross money null
		,C_COBudgetContingency money null
		,C_COTotalBudget money null
		,C_COTotalBudgetWithTax money null
		,C_COTotalBudgetCont money null
		,C_COTotalBudgetContWithTax money null

		,C_OriginalBudgetHours decimal(24,4) null
		,C_OriginalBudgetLaborNet money null
		,C_OriginalBudgetLaborGross money null
		,C_OriginalBudgetExpenseNet money null
		,C_OriginalBudgetExpenseGross money null
		,C_OriginalBudgetContingency money null
		,C_OriginalTotalBudget money null
		,C_OriginalTotalBudgetWithTax money null
		,C_OriginalTotalBudgetCont money null
		,C_OriginalTotalBudgetContWithTax money null

		-- Totals...Cloned from spRptBudgetAnalysis
		,TotalCostsNet money null				-- InsideCostsNet + OutsideCostsNet
		,TotalCostsGrossUnbilled money null		-- InsideCostsGrossUnbilled + OutsideCostsGrossUnbilled
		,TotalCostsGross money null				-- InsideCostsGross + OutsideCostsGross

		,TotalNet money null					-- InsideCostsNet + OutsideCostsNet + OpenOrdersNet + LaborNet
		,TotalGrossUnbilled money null			-- InsideCostsGrossUnbilled + OutsideCostsGrossUnbilled + OpenOrdersGrossUnbilled + LaborGrossUnbilled
		,TotalGross money null					-- InsideCostsGross + OutsideCostsGross + OpenOrdersGrossUnbilled + LaborGross
		,TotalGrossAfterWriteOff money null     -- TotalGross - LaborWriteOff - ExpenseWriteOff
		,TotalCostsGrossAfterWriteOff  money null -- TotalCostsGross + Open Orders Unbilled - ExpenseWriteOff
		,TotalCostsGrossAfterWriteOffNoOrder  money null -- TotalCostsGross  - ExpenseWriteOff  

		-- Variance calcs...Cloned from spRptBudgetAnalysis
		,HoursBilledRemaining decimal(24,4) null
		,HoursBilledRemainingP decimal(24,4) null
		,HoursRemaining decimal(24,4) null
		,HoursRemainingP decimal(24,4) null
		,LaborNetRemaining money null
		,LaborNetRemainingP decimal(24,4) null
		,LaborGrossRemaining money null
		,LaborGrossRemainingP decimal(24,4) null

		,HoursAfterWriteOffRemaining decimal(24,4) null
		,HoursAfterWriteOffRemainingP decimal(24,4) null
		,RemainingAllocatedHours decimal(24,4) null
		,RemainingAllocatedHoursP decimal(24,4) null
		,LaborGrossAfterWriteOffRemaining money null
		,LaborGrossAfterWriteOffRemainingP decimal(24,4) null
		,CostsGrossAfterWriteOffRemaining money null
		,CostsGrossAfterWriteOffRemainingP decimal(24,4) null
		,CostsGrossAfterWriteOffNoOrderRemaining  money null
		,CostsGrossAfterWriteOffNoOrderRemainingP decimal(24,4) null

		,CostsNetRemaining money null
		,CostsNetRemainingP decimal(24,4) null
		,CostsGrossRemaining money null
		,CostsGrossRemainingP decimal(24,4) null

		,ToBillRemaining money null
		,ToBillRemainingP decimal(24,4) null
		,GrossRemaining money null
		,GrossRemainingP decimal(24,4) null
				
		-- New fields added, not part of the project rollup table		
		,BilledDifference money null
		,PurchasedQty decimal(24,4) NULL -- MiscCost and VI only
	
	) 

	declare @CampaignKey int
	
	select @LayoutKey = isnull(@LayoutKey, 0)
	
	if not exists (select 1 from tLayout (nolock) where LayoutKey = @LayoutKey)
		select @LayoutKey = 0
	
	if @Entity = ''tProject''
	begin
		insert #projects (ProjectKey) values (@EntityKey)

		select @CampaignKey = CampaignKey
		from   tProject (nolock)
		where  ProjectKey = @EntityKey
	end
	else if @Entity = ''tCampaignSegment''
	begin
		insert #projects (ProjectKey) 
		select ProjectKey from tProject (nolock) 
		where CompanyKey = @CompanyKey 
		and CampaignSegmentKey = @EntityKey
	
		-- needed for index in tCampaignEstByItem
		select @CampaignKey = CampaignKey
		from   tCampaignSegment (nolock)
		where  CampaignSegmentKey = @EntityKey
	end
	else if @Entity = ''tCampaign''
	begin
		insert #projects (ProjectKey) 
		select ProjectKey from tProject (nolock) 
		where CompanyKey = @CompanyKey 
		and CampaignKey = @EntityKey

		select @CampaignKey = @EntityKey
	end
	else if @Entity = ''tCampaignNoSegment''
	begin
		insert #projects (ProjectKey) 
		select ProjectKey from tProject (nolock) 
		where CompanyKey = @CompanyKey 
		and CampaignKey = @EntityKey
		and isnull(CampaignSegmentKey, 0) = 0
		
		select @CampaignKey = @EntityKey
	end
	
	insert #roll (
	    Entity, 
		EntityKey,
		ItemID, 
		ItemName,
		WorkTypeKey,
		WorkTypeID,
		WorkTypeName,	
		WorkTypeDisplayOrder,	
		Hours,
		HoursApproved,
		HoursBilled,
		HoursInvoiced,
		HoursWriteOff,
		HoursUnbilled,
		LaborNet,
		LaborNetApproved,
		LaborGross,
		LaborGrossApproved ,
		LaborUnbilled ,
		LaborBilled ,
		LaborInvoiced ,
		LaborWriteOff,
		LaborHoursWriteOff,
		MiscCostNet,
		MiscCostGross,
		MiscCostUnbilled,
		MiscCostWriteOff,
		MiscCostBilled,
		MiscCostInvoiced,
		ExpReceiptNet,
		ExpReceiptNetApproved,
		ExpReceiptGross,
		ExpReceiptGrossApproved,
		ExpReceiptUnbilled,
		ExpReceiptWriteOff,
		ExpReceiptBilled,
		ExpReceiptInvoiced,
		VoucherNet,
		VoucherNetApproved,
		VoucherGross,
		VoucherGrossApproved,
		VoucherOutsideCostsGross,
		VoucherOutsideCostsGrossApproved,
		VoucherUnbilled,
		VoucherWriteOff,
		VoucherBilled,
		VoucherInvoiced,
		OpenOrdersNet,
		OpenOrderNetApproved,
		OpenOrderGross,
		OpenOrderGrossApproved,
		OpenOrderUnbilled,
		OrderPrebilled,
		AmountBilled,
		AmountBilledNoTax,
		AdvanceBilled,
		AdvanceBilledOpen,
		EstQty,
		EstNet,
		EstGross,
		EstCOQty,
		EstCONet,
		EstCOGross)
   select Entity, 
		EntityKey,
		case when Entity = ''tItem'' then ''[No Item ID]'' else ''[No Service Code]'' end, --ItemID, 
		case when Entity = ''tItem'' then ''[No Item]'' else ''[No Service]'' end, --ItemName,
		0,    --WorkTypeKey,
		''[No Billing Item ID]'', --WorkTypeID,
		''[No Billing Item]'', --WorkTypeName,
		0,    --WorkTypeDisplayOrder		
		sum(Hours),
		sum(HoursApproved),
		sum(HoursBilled),
		sum(HoursInvoiced),
		sum(HoursWriteOff),
		sum(HoursUnbilled),
		sum(LaborNet),
		sum(LaborNetApproved),
		sum(LaborGross),
		sum(LaborGrossApproved),
		sum(LaborUnbilled),
		sum(LaborBilled),
		sum(LaborInvoiced),
		sum(LaborWriteOff),
		sum(HoursWriteOff),  --LaborHoursWriteOff
		sum(MiscCostNet),
		sum(MiscCostGross),
		sum(MiscCostUnbilled),
		sum(MiscCostWriteOff),
		sum(MiscCostBilled),
		sum(MiscCostInvoiced),
		sum(ExpReceiptNet),
		sum(ExpReceiptNetApproved),
		sum(ExpReceiptGross),
		sum(ExpReceiptGrossApproved),
		sum(ExpReceiptUnbilled),
		sum(ExpReceiptWriteOff),
		sum(ExpReceiptBilled),
		sum(ExpReceiptInvoiced),
		sum(VoucherNet),
		sum(VoucherNetApproved),
		sum(VoucherGross),
		sum(VoucherGrossApproved),
		sum(VoucherOutsideCostsGross),
		sum(VoucherOutsideCostsGrossApproved),
		sum(VoucherUnbilled),
		sum(VoucherWriteOff),
		sum(VoucherBilled),
		sum(VoucherInvoiced),
		sum(OpenOrderNet),
		sum(OpenOrderNetApproved),
		sum(OpenOrderGross),
		sum(OpenOrderGrossApproved),
		sum(OpenOrderUnbilled),
		sum(OrderPrebilled),
		sum(BilledAmount),
		sum(BilledAmountNoTax),
		sum(AdvanceBilled),
		sum(AdvanceBilledOpen),
		sum(EstQty),
		sum(EstNet),
		sum(EstGross),
		sum(EstCOQty),
		sum(EstCONet),
		sum(EstCOGross)
	from tProjectItemRollup roll (nolock)
	inner join #projects b on roll.ProjectKey = b.ProjectKey
	group by Entity, EntityKey
	
	-- now add the items on the campaign estimates
	-- they may likely not be in tProjectItemRollup 

	if @Entity = ''tCampaign''
	insert #roll (
	    Entity, 
		EntityKey,
		WorkTypeKey,
		WorkTypeDisplayOrder)
	select distinct ''tItem'', cebi.EntityKey, 0,0
	from   tCampaignEstByItem cebi (nolock)
	where  cebi.CampaignKey = @CampaignKey
	and    cebi.Entity = ''tItem''
	and    cebi.EntityKey not in (select EntityKey from #roll where Entity = ''tItem'')
			
	if @Entity = ''tCampaignSegment''
	insert #roll (
	    Entity, 
		EntityKey,
		WorkTypeKey,
		WorkTypeDisplayOrder)
	select distinct ''tItem'', cebi.EntityKey, 0,0
	from   tCampaignEstByItem cebi (nolock)
	where  cebi.CampaignKey = @CampaignKey
	and    cebi.CampaignSegmentKey = @EntityKey
	and    cebi.Entity = ''tItem''
	and    cebi.EntityKey not in (select EntityKey from #roll where Entity = ''tItem'')

	if @Entity = ''tCampaign''	
	insert #roll (
	    Entity, 
		EntityKey,
		WorkTypeKey,
		WorkTypeDisplayOrder)
	select distinct ''tService'', cebi.EntityKey, 0,0
	from   tCampaignEstByItem cebi (nolock)
	where  cebi.CampaignKey = @CampaignKey
	and    cebi.Entity = ''tService''
	and    cebi.EntityKey not in (select EntityKey from #roll where Entity = ''tService'')
	
	if @Entity = ''tCampaignSegment''	
	insert #roll (
	    Entity, 
		EntityKey,
		WorkTypeKey,
		WorkTypeDisplayOrder)
	select distinct ''tService'', cebi.EntityKey, 0,0
	from   tCampaignEstByItem cebi (nolock)
	where  cebi.CampaignKey = @CampaignKey
	and    cebi.CampaignSegmentKey = @EntityKey
	and    cebi.Entity = ''tService''
	and    cebi.EntityKey not in (select EntityKey from #roll where Entity = ''tService'')


	----- adding future data
	declare @Today smalldatetime
	SELECT @Today = CONVERT(SMALLDATETIME, (CONVERT(VARCHAR(10), GETDATE(), 101)), 101)

	insert #project_other (Entity, EntityKey, AllocatedHours, AllocatedGross)
	select ''tService'', isnull(tu.ServiceKey, 0), sum(tu.Hours), SUM(tu.Hours * tu.AHourlyRate)
	from   tTaskUser tu (nolock)
	inner join tTask t (nolock) on tu.TaskKey = t.TaskKey
	inner join #projects p (nolock) on t.ProjectKey = p.ProjectKey
	group by isnull(tu.ServiceKey, 0)

	UPDATE #project_other
			SET    #project_other.FutureAllocatedHours = ISNULL((
				select SUM(tu.Hours) 
				from   vTaskUserHour tu (nolock)
				inner join #projects p (nolock) on tu.ProjectKey = p.ProjectKey
				where tu.BucketStart > DATEADD(week, -1, @Today) 
				and   isnull(tu.ServiceKey, 0) = isnull(#project_other.EntityKey, 0) -- must join with the service key in EntityKey
				), 0)

	UPDATE #project_other
			SET    #project_other.FutureAllocatedGross = ISNULL((
				select SUM(tu.Hours * tu.AHourlyRate)
				from   vTaskUserHour tu (nolock)
				inner join #projects p (nolock) on tu.ProjectKey = p.ProjectKey
				where tu.BucketStart > DATEADD(week, -1, @Today) 
				and   isnull(tu.ServiceKey, 0) = isnull(#project_other.EntityKey, 0) -- must join with the service key in EntityKey
				), 0)
	


	insert #roll (
	    Entity, 
		EntityKey,
		WorkTypeKey,
		WorkTypeDisplayOrder
		)
	select ''tService'', b.EntityKey, 0,0
	from   #project_other b
	where  b.Entity = ''tService''
	and    b.EntityKey not in (select EntityKey from #roll where Entity = ''tService'')

	update #roll
	set    #roll.AllocatedHours = b.AllocatedHours,
		   #roll.AllocatedGross = b.AllocatedGross,
		   #roll.FutureAllocatedHours = b.FutureAllocatedHours,
		   #roll.FutureAllocatedGross = b.FutureAllocatedGross
	from   #project_other b
	where  #roll.Entity = b.Entity
	and    #roll.EntityKey = b.EntityKey

	-- now updates actuals like in Budget Analysis and budget fields 
	update #roll
	set    #roll.OutsideCostsNet = #roll.VoucherNet
	      ,#roll.InsideCostsNet = #roll.MiscCostNet + #roll.ExpReceiptNet
	      ,#roll.OpenOrdersGrossUnbilled = #roll.OpenOrderUnbilled -- used to be calculated unbilled, so use new field OpenOrderUnbilled 
	      ,#roll.OutsideCostsGrossUnbilled = #roll.VoucherUnbilled
	      ,#roll.InsideCostsGrossUnbilled = #roll.MiscCostUnbilled + #roll.ExpReceiptUnbilled
	      ,#roll.OutsideCostsGross = #roll.OrderPrebilled + #roll.VoucherOutsideCostsGross -- + roll.OpenOrderGross (34827)
		  ,#roll.InsideCostsGross = #roll.MiscCostGross + #roll.ExpReceiptGross
		  ,#roll.ExpenseWriteOff = #roll.MiscCostWriteOff + #roll.ExpReceiptWriteOff + #roll.VoucherWriteOff
		  ,#roll.ExpenseBilled = #roll.MiscCostBilled + #roll.ExpReceiptBilled + #roll.VoucherBilled + #roll.OrderPrebilled
		  ,#roll.ExpenseInvoiced = #roll.MiscCostInvoiced + #roll.ExpReceiptInvoiced + #roll.VoucherInvoiced + #roll.OrderPrebilled

	      ,#roll.CurrentBudgetHours = case when Entity = ''tService'' then EstQty + EstCOQty else 0 end
		  ,#roll.CurrentBudgetQty = case when Entity = ''tItem'' then EstQty + EstCOQty else 0 end
		  ,#roll.CurrentBudgetLaborNet = case when Entity = ''tService'' then EstNet + EstCONet else 0 end
		  ,#roll.CurrentBudgetLaborGross = case when Entity = ''tService'' then EstGross + EstCOGross else 0 end
		  ,#roll.CurrentBudgetExpenseNet = case when Entity = ''tItem'' then EstNet + EstCONet else 0 end
		  ,#roll.CurrentBudgetExpenseGross = case when Entity = ''tItem'' then EstGross + EstCOGross else 0 end
		  ,#roll.CurrentBudgetContingency = 0
		  ,#roll.CurrentTotalBudget = EstGross + EstCOGross
		  ,#roll.CurrentTotalBudgetCont = EstGross + EstCOGross
		  ,#roll.CurrentTotalBudgetNoTax = EstGross + EstCOGross
		  ,#roll.CurrentBudgetExpenseQuantity = case when Entity = ''tItem'' then EstQty + EstCOQty else 0 end

		  ,#roll.COBudgetHours = case when Entity = ''tService'' then EstCOQty else 0 end
		  ,#roll.COBudgetQty = case when Entity = ''tItem'' then EstCOQty else 0 end
		  ,#roll.COBudgetLaborNet = case when Entity = ''tService'' then EstCONet else 0 end
		  ,#roll.COBudgetLaborGross = case when Entity = ''tService'' then EstCOGross else 0 end
		  ,#roll.COBudgetExpenseNet = case when Entity = ''tItem'' then EstCONet else 0 end
		  ,#roll.COBudgetExpenseGross = case when Entity = ''tItem'' then EstCOGross else 0 end
		  ,#roll.COBudgetContingency= 0
		  ,#roll.COTotalBudget = EstCOGross 
		  ,#roll.COTotalBudgetCont = EstCOGross

		  ,#roll.OriginalBudgetHours = case when Entity = ''tService'' then EstQty else 0 end
		  ,#roll.OriginalBudgetQty = case when Entity = ''tItem'' then EstQty else 0 end
		  ,#roll.OriginalBudgetLaborNet = case when Entity = ''tService'' then EstNet else 0 end
		  ,#roll.OriginalBudgetLaborGross = case when Entity = ''tService'' then EstGross else 0 end
		  ,#roll.OriginalBudgetExpenseNet = case when Entity = ''tItem'' then EstNet else 0 end
		  ,#roll.OriginalBudgetExpenseGross = case when Entity = ''tItem'' then EstGross else 0 end
		  ,#roll.OriginalBudgetContingency = 0
		  ,#roll.OriginalTotalBudget = EstGross 
		  ,#roll.OriginalTotalBudgetCont = EstGross
	      
	    -- now update the campaign budget fields (from estimates on campaigns)  

	    if @Entity = ''tCampaignSegment''
		begin
			update #roll
			set    #roll.C_CurrentBudgetHours = case when #roll.Entity = ''tService'' then cebi.Qty + cebi.COQty else 0 end	
			      ,#roll.C_CurrentBudgetLaborNet = case when #roll.Entity = ''tService'' then cebi.Net + cebi.CONet else 0 end
		          ,#roll.C_CurrentBudgetLaborGross = case when #roll.Entity = ''tService'' then cebi.Gross + cebi.COGross else 0 end
		          ,#roll.C_CurrentBudgetExpenseNet = case when #roll.Entity = ''tItem'' then cebi.Net + cebi.CONet else 0 end
		          ,#roll.C_CurrentBudgetExpenseGross = case when #roll.Entity = ''tItem'' then cebi.Gross + cebi.COGross else 0 end
		          ,#roll.C_CurrentBudgetContingency = 0
		          ,#roll.C_CurrentTotalBudget = cebi.Gross + cebi.COGross
		          ,#roll.C_CurrentTotalBudgetCont = cebi.Gross + cebi.COGross

				  ,#roll.C_COBudgetHours = case when #roll.Entity = ''tService'' then cebi.COQty else 0 end
				  ,#roll.C_COBudgetLaborNet = case when #roll.Entity = ''tService'' then cebi.CONet else 0 end
				  ,#roll.C_COBudgetLaborGross = case when #roll.Entity = ''tService'' then cebi.COGross else 0 end
				  ,#roll.C_COBudgetExpenseNet = case when #roll.Entity = ''tItem'' then cebi.CONet else 0 end
				  ,#roll.C_COBudgetExpenseGross = case when #roll.Entity = ''tItem'' then cebi.COGross else 0 end
				  ,#roll.C_COBudgetContingency= 0
				  ,#roll.C_COTotalBudget = cebi.COGross 
				  ,#roll.C_COTotalBudgetCont = cebi.COGross

				  ,#roll.C_OriginalBudgetHours = case when #roll.Entity = ''tService'' then cebi.Qty else 0 end
				  ,#roll.C_OriginalBudgetLaborNet = case when #roll.Entity = ''tService'' then cebi.Net else 0 end
				  ,#roll.C_OriginalBudgetLaborGross = case when #roll.Entity = ''tService'' then cebi.Gross else 0 end
				  ,#roll.C_OriginalBudgetExpenseNet = case when #roll.Entity = ''tItem'' then cebi.Net else 0 end
				  ,#roll.C_OriginalBudgetExpenseGross = case when #roll.Entity = ''tItem'' then cebi.Gross else 0 end
				  ,#roll.C_OriginalBudgetContingency = 0
				  ,#roll.C_OriginalTotalBudget = cebi.Gross 
				  ,#roll.C_OriginalTotalBudgetCont = cebi.Gross
		  
			from   tCampaignEstByItem cebi (nolock)
			where  cebi.CampaignSegmentKey = @EntityKey
			and    cebi.CampaignKey = @CampaignKey
			and    cebi.Entity = #roll.Entity COLLATE DATABASE_DEFAULT
			and    cebi.EntityKey = #roll.EntityKey
			
		end
		
		if @Entity = ''tCampaign''
		begin
			update #roll
			set    #roll.C_CurrentBudgetHours = case when #roll.Entity = ''tService'' then cebi.Qty + cebi.COQty else 0 end	
			      ,#roll.C_CurrentBudgetLaborNet = case when #roll.Entity = ''tService'' then cebi.Net + cebi.CONet else 0 end
		          ,#roll.C_CurrentBudgetLaborGross = case when #roll.Entity = ''tService'' then cebi.Gross + cebi.COGross else 0 end
		          ,#roll.C_CurrentBudgetExpenseNet = case when #roll.Entity = ''tItem'' then cebi.Net + cebi.CONet else 0 end
		          ,#roll.C_CurrentBudgetExpenseGross = case when #roll.Entity = ''tItem'' then cebi.Gross + cebi.COGross else 0 end
		          ,#roll.C_CurrentBudgetContingency = 0
		          ,#roll.C_CurrentTotalBudget = cebi.Gross + cebi.COGross
		          ,#roll.C_CurrentTotalBudgetCont = cebi.Gross + cebi.COGross

				  ,#roll.C_COBudgetHours = case when #roll.Entity = ''tService'' then cebi.COQty else 0 end
				  ,#roll.C_COBudgetLaborNet = case when #roll.Entity = ''tService'' then cebi.CONet else 0 end
				  ,#roll.C_COBudgetLaborGross = case when #roll.Entity = ''tService'' then cebi.COGross else 0 end
				  ,#roll.C_COBudgetExpenseNet = case when #roll.Entity = ''tItem'' then cebi.CONet else 0 end
				  ,#roll.C_COBudgetExpenseGross = case when #roll.Entity = ''tItem'' then cebi.COGross else 0 end
				  ,#roll.C_COBudgetContingency= 0
				  ,#roll.C_COTotalBudget = cebi.COGross 
				  ,#roll.C_COTotalBudgetCont = cebi.COGross

				  ,#roll.C_OriginalBudgetHours = case when #roll.Entity = ''tService'' then cebi.Qty else 0 end
				  ,#roll.C_OriginalBudgetLaborNet = case when #roll.Entity = ''tService'' then cebi.Net else 0 end
				  ,#roll.C_OriginalBudgetLaborGross = case when #roll.Entity = ''tService'' then cebi.Gross else 0 end
				  ,#roll.C_OriginalBudgetExpenseNet = case when #roll.Entity = ''tItem'' then cebi.Net else 0 end
				  ,#roll.C_OriginalBudgetExpenseGross = case when #roll.Entity = ''tItem'' then cebi.Gross else 0 end
				  ,#roll.C_OriginalBudgetContingency = 0
				  ,#roll.C_OriginalTotalBudget = cebi.Gross 
				  ,#roll.C_OriginalTotalBudgetCont = cebi.Gross
		  
			from   
					(select CampaignKey, Entity, EntityKey
					, Sum(Qty) As Qty, Sum(Net) As Net, Sum(Gross) As Gross
					, Sum(COQty) As COQty, Sum(CONet) As CONet, Sum(COGross) As COGross
					 from   tCampaignEstByItem  (nolock)
					 where CampaignKey = @EntityKey
					 group by CampaignKey, Entity, EntityKey) as cebi  
			where  cebi.Entity = #roll.Entity COLLATE DATABASE_DEFAULT
			and    cebi.EntityKey = #roll.EntityKey
			
		end
		
		UPDATE #roll
		SET #roll.BilledDifference = ISNULL((SELECT SUM(Round(t.BilledHours * t.BilledRate, 2) -
														Round(t.ActualHours * t.ActualRate, 2) 
		                                                ) 
								FROM tTime t (NOLOCK) 
								WHERE t.ProjectKey in (select ProjectKey from #projects)
								AND   #roll.Entity = ''tService''
								AND   ISNULL(t.ServiceKey, 0) = #roll.EntityKey
								AND  t.InvoiceLineKey > 0  
								), 0) 
								+
								ISNULL((
								SELECT SUM(mc.AmountBilled - mc.BillableCost) 
								FROM tMiscCost mc (NOLOCK)
								WHERE mc.ProjectKey in (select ProjectKey from #projects)
								AND   #roll.Entity = ''tItem''
								AND   ISNULL(mc.ItemKey, 0) = #roll.EntityKey
								AND   mc.InvoiceLineKey > 0
								), 0)
								+
								ISNULL((
								SELECT SUM(er.AmountBilled - er.BillableCost) 
								FROM tExpenseReceipt er (NOLOCK)
								WHERE er.ProjectKey in (select ProjectKey from #projects)
								AND   #roll.Entity = ''tItem''
								AND   ISNULL(er.ItemKey, 0) = #roll.EntityKey
								AND   er.VoucherDetailKey IS NULL 
								AND   er.InvoiceLineKey > 0
								), 0)
								+
								ISNULL((
								SELECT SUM(vd.AmountBilled - vd.BillableCost) 
								FROM tVoucherDetail vd (NOLOCK)
									INNER JOIN tVoucher v (NOLOCK) ON vd.VoucherKey = v.VoucherKey
								WHERE vd.ProjectKey in (select ProjectKey from #projects)
								AND   #roll.Entity = ''tItem''
								AND   ISNULL(vd.ItemKey, 0) = #roll.EntityKey
								AND   vd.InvoiceLineKey > 0
								), 0)
								+
								ISNULL((
								SELECT SUM(pod.AmountBilled - 
										CASE po.BillAt 
											WHEN 0 THEN ISNULL(pod.BillableCost, 0)
											WHEN 1 THEN ISNULL(pod.PTotalCost,0)
											WHEN 2 THEN ISNULL(pod.BillableCost,0) - ISNULL(pod.PTotalCost,0) 
											END) -- BillableCost 
								FROM tPurchaseOrderDetail pod (NOLOCK)
									INNER JOIN tPurchaseOrder po (NOLOCK) ON pod.PurchaseOrderKey = po.PurchaseOrderKey
								WHERE po.CompanyKey = @CompanyKey  
								AND  pod.ProjectKey in (select ProjectKey from #projects)
								AND   #roll.Entity = ''tItem''
								AND   ISNULL(pod.ItemKey, 0) = #roll.EntityKey
								AND pod.InvoiceLineKey > 0
								), 0)
	
	-- just for the project budget screen 			 
	if @Entity = ''tProject''
	begin
		 update #roll
		set    #roll.PurchasedQty = ISNULL((
			select sum(mc.Quantity) from tMiscCost mc (nolock)
			where  mc.ProjectKey = @EntityKey -- use index by Project
			and    mc.ItemKey = #roll.EntityKey and #roll.Entity = ''tItem'' 
		),0)

		 update #roll
		set    #roll.PurchasedQty = ISNULL(#roll.PurchasedQty, 0) + ISNULL((
			select sum(vd.Quantity) from tVoucherDetail vd (nolock)
			where  vd.ProjectKey = @EntityKey -- use index by Project
			and    vd.ItemKey = #roll.EntityKey and #roll.Entity = ''tItem'' 
		),0)

		 update #roll
		set    #roll.ActualQuantity = ISNULL((
			select sum(mc.Quantity) from tMiscCost mc (nolock)
			where  mc.ProjectKey = @EntityKey -- use index by Project
			and    mc.ItemKey = #roll.EntityKey and #roll.Entity = ''tItem'' 
		),0)

		 update #roll
		set    #roll.ActualQuantity = ISNULL(#roll.ActualQuantity, 0) + ISNULL((
			select sum(er.ActualQty) from tExpenseReceipt er (nolock)
			where  er.ProjectKey = @EntityKey -- use index by Project
			and    er.ItemKey = #roll.EntityKey and #roll.Entity = ''tItem'' 
		),0)

		 update #roll
		set    #roll.ActualQuantity = ISNULL(#roll.ActualQuantity, 0) + ISNULL((
			select sum(vd.Quantity) from tVoucherDetail vd (nolock)
			where  vd.ProjectKey = @EntityKey -- use index by Project
			and    vd.ItemKey = #roll.EntityKey and #roll.Entity = ''tItem'' 
		),0)


	end

	-- Final Calculations
	UPDATE #roll
	SET    OutsideCostsNet				= ISNULL(OutsideCostsNet, 0) -- + ISNULL(OpenOrdersNet, 0)  -- 10/15/2008
		   ,OutsideCostsGrossUnbilled	= ISNULL(OutsideCostsGrossUnbilled,0) -- + ISNULL(OpenOrdersGrossUnbilled, 0) -- 10/15/2008	
	
	UPDATE #roll
    SET    TotalCostsNet			= ISNULL(InsideCostsNet, 0) + ISNULL(OutsideCostsNet, 0)  
          ,TotalCostsGrossUnbilled	= ISNULL(InsideCostsGrossUnbilled,0) + ISNULL(OutsideCostsGrossUnbilled, 0)
          ,TotalCostsGross			= ISNULL(InsideCostsGross, 0) + ISNULL(OutsideCostsGross, 0)	
		  
		  -- These 2 added 10/15/2008
		  ,TotalNet					= ISNULL(LaborNet, 0) + ISNULL(InsideCostsNet, 0) + ISNULL(OutsideCostsNet, 0)
		                              + ISNULL(OpenOrdersNet, 0) 
		  ,TotalGrossUnbilled		= ISNULL(LaborUnbilled, 0) + ISNULL(InsideCostsGrossUnbilled, 0) + ISNULL(OutsideCostsGrossUnbilled, 0)
		                              + ISNULL(OpenOrdersGrossUnbilled, 0) 
	
		  ,TotalGross				= ISNULL(LaborGross, 0) + ISNULL(InsideCostsGross, 0) + ISNULL(OutsideCostsGross, 0)
		                              + ISNULL(OpenOrdersGrossUnbilled, 0) -- Added 10/15/2008
		  ,SalesTax					= ISNULL(AmountBilled,0) - ISNULL(AmountBilledNoTax, 0)
		  
	UPDATE #roll
    SET  TotalGrossUnbilledFixedFee = ISNULL(TotalGross,0) - ISNULL(AmountBilledNoTax, 0)
	
	--select 	LaborGross , InsideCostsGross, + OutsideCostsGross, OpenOrdersGrossUnbilled from #roll
	
	-- WriteOff stuff for Abelson Taylor
	UPDATE #roll
	SET   TotalGrossAfterWriteOff	= ISNULL(TotalGross,0) - ISNULL(LaborWriteOff, 0) - ISNULL(ExpenseWriteOff, 0) 
		 ,HoursAfterWriteOff		= ISNULL(Hours, 0) - ISNULL(HoursWriteOff , 0)
		 ,LaborGrossAfterWriteOff	= ISNULL(LaborGross, 0) - ISNULL(LaborWriteOff , 0)
		 ,TotalCostsGrossAfterWriteOff			= ISNULL(TotalCostsGross, 0) + ISNULL(OpenOrdersGrossUnbilled, 0) - ISNULL(ExpenseWriteOff, 0)
		 ,TotalCostsGrossAfterWriteOffNoOrder	= ISNULL(TotalCostsGross, 0) - ISNULL(ExpenseWriteOff, 0)
		 	
	-- mainly for better rendering on grid
	update #roll 
	    set Hours = isnull(Hours , 0),
		HoursApproved  = isnull(HoursApproved , 0),
		HoursBilled  = isnull(HoursBilled , 0),
		HoursInvoiced  = isnull(HoursInvoiced , 0),
		HoursWriteOff  = isnull(HoursWriteOff , 0),
		HoursUnbilled  = isnull(HoursUnbilled , 0),
		LaborNet  = isnull( LaborNet, 0),
		LaborNetApproved  = isnull(LaborNetApproved , 0),
		LaborGross  = isnull(LaborGross , 0),
		LaborGrossApproved  = isnull(LaborGrossApproved , 0),
		LaborUnbilled  = isnull(LaborUnbilled , 0),
		LaborBilled  = isnull(LaborBilled , 0),
		LaborInvoiced  = isnull(LaborInvoiced , 0),
		LaborWriteOff = isnull(LaborWriteOff , 0),
		LaborHoursWriteOff = isnull(LaborHoursWriteOff , 0),
		MiscCostNet = isnull(MiscCostNet , 0),
		MiscCostGross  = isnull(MiscCostGross , 0),
		MiscCostUnbilled  = isnull(MiscCostUnbilled , 0),
		MiscCostWriteOff = isnull(MiscCostWriteOff , 0),
		MiscCostBilled = isnull(MiscCostBilled , 0),
		MiscCostInvoiced = isnull(MiscCostInvoiced , 0),
		ExpReceiptNet = isnull(ExpReceiptNet , 0),
		ExpReceiptNetApproved = isnull(ExpReceiptNetApproved , 0),
		ExpReceiptGross = isnull(ExpReceiptGross , 0),
		ExpReceiptGrossApproved = isnull(ExpReceiptGrossApproved , 0),
		ExpReceiptUnbilled = isnull(ExpReceiptUnbilled , 0),
		ExpReceiptWriteOff = isnull(ExpReceiptWriteOff , 0),
		ExpReceiptBilled = isnull(ExpReceiptBilled , 0),
		ExpReceiptInvoiced = isnull(ExpReceiptInvoiced , 0),
		VoucherNet = isnull(VoucherNet , 0),
		VoucherNetApproved = isnull(VoucherNetApproved , 0),
		VoucherGross  = isnull(VoucherGross , 0),
		VoucherGrossApproved = isnull(VoucherGrossApproved , 0),
		VoucherOutsideCostsGross = isnull(VoucherOutsideCostsGross , 0),
		VoucherOutsideCostsGrossApproved = isnull(VoucherOutsideCostsGrossApproved , 0),
		VoucherUnbilled = isnull(VoucherUnbilled , 0),
		VoucherWriteOff = isnull(VoucherWriteOff , 0),
		VoucherBilled = isnull(VoucherBilled , 0),
		VoucherInvoiced = isnull(VoucherInvoiced , 0),
		OpenOrdersNet = isnull(OpenOrdersNet , 0),
		OpenOrderNetApproved = isnull(OpenOrderNetApproved , 0),
		OpenOrderGross = isnull(OpenOrderGross , 0),
		OpenOrderGrossApproved = isnull(OpenOrderGrossApproved , 0),
		OrderPrebilled = isnull( OrderPrebilled, 0),
		AmountBilled = isnull(AmountBilled , 0),
		AmountBilledNoTax  = isnull(AmountBilledNoTax , 0),
		AdvanceBilled  = isnull(AdvanceBilled , 0),
		AdvanceBilledOpen = isnull(AdvanceBilledOpen , 0),

		AllocatedHours = isnull(AllocatedHours , 0),
		AllocatedGross = isnull(AllocatedGross , 0),
		FutureAllocatedHours = isnull(FutureAllocatedHours , 0),
		FutureAllocatedGross = isnull(FutureAllocatedGross , 0),

		EstQty = isnull(EstQty , 0),
		EstNet = isnull(EstNet , 0),
		EstGross = isnull(EstGross , 0),
		EstCOQty  = isnull(EstCOQty , 0),
		EstCONet = isnull( EstCONet, 0),
		EstCOGross  = isnull(EstCOGross , 0),
		
		-- Actuals fields...Cloned from spRptBudgetAnalysis
		OutsideCostsNet = isnull(OutsideCostsNet , 0)
		,InsideCostsNet = isnull( InsideCostsNet, 0)
		
		,OpenOrdersGrossUnbilled  = isnull(OpenOrdersGrossUnbilled , 0)
		,OutsideCostsGrossUnbilled  = isnull(OutsideCostsGrossUnbilled , 0)
		,InsideCostsGrossUnbilled  = isnull(InsideCostsGrossUnbilled , 0)
		
		,OutsideCostsGross = isnull(OutsideCostsGross , 0)
		,InsideCostsGross = isnull(InsideCostsGross , 0)
		
		,ExpenseWriteOff = isnull(ExpenseWriteOff , 0)
		,ExpenseBilled = isnull(ExpenseBilled , 0)	
		,ExpenseInvoiced = isnull(ExpenseInvoiced , 0)	
				
		-- Budget fields...Cloned from spRptBudgetAnalysis
		,CurrentBudgetHours = isnull(CurrentBudgetHours , 0)
		,CurrentBudgetQty = isnull(CurrentBudgetQty , 0)
		,CurrentBudgetLaborNet = isnull(CurrentBudgetLaborNet , 0)
		,CurrentBudgetLaborGross = isnull(CurrentBudgetLaborGross , 0)
		,CurrentBudgetExpenseNet = isnull(CurrentBudgetExpenseNet , 0)
		,CurrentBudgetExpenseGross = isnull(CurrentBudgetExpenseGross , 0)
		,CurrentBudgetContingency = isnull(CurrentBudgetContingency , 0)
		,CurrentTotalBudget = isnull(CurrentTotalBudget , 0)
		,CurrentTotalBudgetCont = isnull(CurrentTotalBudgetCont , 0)
		,CurrentTotalBudgetWithTax  = isnull(CurrentTotalBudgetWithTax , 0)		-- not calc''ed, but added for rendering on the grid (was blank)
		,CurrentTotalBudgetContWithTax = isnull(CurrentTotalBudgetContWithTax , 0)
		,CurrentTotalBudgetNoTax = isnull(CurrentTotalBudgetNoTax , 0)

		,COBudgetHours  = isnull(COBudgetHours , 0)
		,COBudgetQty  = isnull(COBudgetQty , 0)
		,COBudgetLaborNet  = isnull(COBudgetLaborNet , 0)
		,COBudgetLaborGross = isnull(COBudgetLaborGross , 0)
		,COBudgetExpenseNet = isnull(COBudgetExpenseNet , 0)
		,COBudgetExpenseGross = isnull(COBudgetExpenseGross , 0)
		,COBudgetContingency = isnull(COBudgetContingency , 0)
		,COTotalBudget  = isnull(COTotalBudget , 0)
		,COTotalBudgetCont  = isnull(COTotalBudgetCont , 0)
		,COTotalBudgetWithTax  = isnull(COTotalBudgetWithTax , 0)
		,COTotalBudgetContWithTax  = isnull(COTotalBudgetContWithTax , 0)

		,OriginalBudgetHours  = isnull( OriginalBudgetHours, 0)
		,OriginalBudgetQty  = isnull( OriginalBudgetQty, 0)
		,OriginalBudgetLaborNet  = isnull( OriginalBudgetLaborNet, 0)
		,OriginalBudgetLaborGross  = isnull(OriginalBudgetLaborGross , 0)
		,OriginalBudgetExpenseNet  = isnull(OriginalBudgetExpenseNet , 0)
		,OriginalBudgetExpenseGross  = isnull(OriginalBudgetExpenseGross , 0)
		,OriginalBudgetContingency  = isnull( OriginalBudgetContingency, 0)
		,OriginalTotalBudget  = isnull(OriginalTotalBudget , 0)
		,OriginalTotalBudgetCont = isnull(OriginalTotalBudgetCont , 0)
		,OriginalTotalBudgetWithTax = isnull(OriginalTotalBudgetWithTax , 0)
		,OriginalTotalBudgetContWithTax  = isnull(OriginalTotalBudgetContWithTax , 0)
		
		-- Campaign Budget fields
		,C_CurrentBudgetHours = isnull(C_CurrentBudgetHours , 0)
		,C_CurrentBudgetLaborNet = isnull(C_CurrentBudgetLaborNet , 0)
		,C_CurrentBudgetLaborGross = isnull(C_CurrentBudgetLaborGross , 0)
		,C_CurrentBudgetExpenseNet = isnull(C_CurrentBudgetExpenseNet , 0)
		,C_CurrentBudgetExpenseGross  = isnull(C_CurrentBudgetExpenseGross , 0)
		,C_CurrentBudgetContingency  = isnull(C_CurrentBudgetContingency , 0)
		,C_CurrentTotalBudget  = isnull(C_CurrentTotalBudget , 0)
		,C_CurrentTotalBudgetWithTax  = isnull(C_CurrentTotalBudgetWithTax , 0)
		,C_CurrentTotalBudgetCont  = isnull(C_CurrentTotalBudgetCont , 0)
		,C_CurrentTotalBudgetContWithTax  = isnull(C_CurrentTotalBudgetContWithTax , 0)

		,C_COBudgetHours = isnull(C_COBudgetHours , 0)
		,C_COBudgetLaborNet  = isnull(C_COBudgetLaborNet , 0)
		,C_COBudgetLaborGross  = isnull(C_COBudgetLaborGross , 0)
		,C_COBudgetExpenseNet  = isnull(C_COBudgetExpenseNet , 0)
		,C_COBudgetExpenseGross  = isnull(C_COBudgetExpenseGross , 0)
		,C_COBudgetContingency  = isnull(C_COBudgetContingency , 0)
		,C_COTotalBudget = isnull(C_COTotalBudget , 0)
		,C_COTotalBudgetWithTax  = isnull(C_COTotalBudgetWithTax , 0)
		,C_COTotalBudgetCont  = isnull(C_COTotalBudgetCont , 0)
		,C_COTotalBudgetContWithTax  = isnull(C_COTotalBudgetContWithTax , 0)

		,C_OriginalBudgetHours  = isnull(C_OriginalBudgetHours , 0)
		,C_OriginalBudgetLaborNet  = isnull(C_OriginalBudgetLaborNet , 0)
		,C_OriginalBudgetLaborGross  = isnull(C_OriginalBudgetLaborGross , 0)
		,C_OriginalBudgetExpenseNet  = isnull(C_OriginalBudgetExpenseNet , 0)
		,C_OriginalBudgetExpenseGross  = isnull(C_OriginalBudgetExpenseGross , 0)
		,C_OriginalBudgetContingency  = isnull(C_OriginalBudgetContingency , 0)
		,C_OriginalTotalBudget  = isnull(C_OriginalTotalBudget , 0)
		,C_OriginalTotalBudgetWithTax  = isnull(C_OriginalTotalBudgetWithTax , 0)
		,C_OriginalTotalBudgetCont  = isnull(C_OriginalTotalBudgetCont , 0)
		,C_OriginalTotalBudgetContWithTax = isnull(C_OriginalTotalBudgetContWithTax , 0)

		-- Totals...Cloned from spRptBudgetAnalysis
		,TotalCostsNet  = isnull(TotalCostsNet , 0)				-- InsideCostsNet + OutsideCostsNet
		,TotalCostsGrossUnbilled  = isnull(TotalCostsGrossUnbilled , 0)		-- InsideCostsGrossUnbilled + OutsideCostsGrossUnbilled
		,TotalCostsGross  = isnull(TotalCostsGross , 0)				-- InsideCostsGross + OutsideCostsGross

		,TotalNet  = isnull(TotalNet , 0)					-- InsideCostsNet + OutsideCostsNet + OpenOrdersNet + LaborNet
		,TotalGrossUnbilled  = isnull(TotalGrossUnbilled , 0)			-- InsideCostsGrossUnbilled + OutsideCostsGrossUnbilled + OpenOrdersGrossUnbilled + LaborGrossUnbilled
		,TotalGross  = isnull(TotalGross , 0)					-- InsideCostsGross + OutsideCostsGross + OpenOrdersGrossUnbilled + LaborGross
		,SalesTax = ISNULL(SalesTax, 0)
		,TotalGrossUnbilledFixedFee = ISNULL(TotalGrossUnbilledFixedFee, 0)
		-- Variance calcs...Cloned from spRptBudgetAnalysis
		,HoursBilledRemaining  = isnull(HoursBilledRemaining , 0)
		,HoursBilledRemainingP  = isnull(HoursBilledRemainingP , 0)
		,HoursRemaining  = isnull(HoursRemaining , 0)
		,HoursRemainingP  = isnull(HoursRemainingP , 0)
		,LaborNetRemaining  = isnull(LaborNetRemaining , 0)
		,LaborNetRemainingP  = isnull(LaborNetRemainingP , 0)
		,LaborGrossRemaining  = isnull(LaborGrossRemaining , 0)
		,LaborGrossRemainingP  = isnull(LaborGrossRemainingP , 0)

		,CostsNetRemaining = isnull(CostsNetRemaining , 0)
		,CostsNetRemainingP  = isnull(CostsNetRemainingP , 0)
		,CostsGrossRemaining  = isnull(CostsGrossRemaining , 0)
		,CostsGrossRemainingP  = isnull(CostsGrossRemainingP , 0)

		,ToBillRemaining  = isnull(ToBillRemaining , 0)
		,ToBillRemainingP  = isnull(ToBillRemainingP , 0)
		,GrossRemaining  = isnull(GrossRemaining , 0)
		,GrossRemainingP  = isnull(GrossRemainingP , 0)
				
		-- BilledDifference		
		,BilledDifference  = isnull(BilledDifference , 0)
			
		,PurchasedQty = isnull(PurchasedQty , 0)

	UPDATE #roll
	SET    HoursBilledRemaining	= CurrentBudgetHours - HoursBilled
		   ,HoursRemaining		= CurrentBudgetHours - Hours 
     	   ,LaborNetRemaining	= CurrentBudgetLaborNet - LaborNet 
		   ,LaborGrossRemaining	= CurrentBudgetLaborGross - LaborGross
		   ,CostsNetRemaining	= CurrentBudgetExpenseNet - TotalCostsNet 
		   ,CostsGrossRemaining	= CurrentBudgetExpenseGross - TotalCostsGross 
		   ,ToBillRemaining		= CurrentTotalBudget - AmountBilledNoTax
		   ,GrossRemaining		= CurrentTotalBudget - TotalGross
		 
			-- Write off stuff for Abelson Taylor
			,HoursAfterWriteOffRemaining		= CurrentBudgetHours - HoursAfterWriteOff 
			,RemainingAllocatedHours = AllocatedHours - Hours
			,LaborGrossAfterWriteOffRemaining	= CurrentBudgetLaborGross - LaborGrossAfterWriteOff
			,CostsGrossAfterWriteOffRemaining	= CurrentBudgetExpenseGross - TotalCostsGrossAfterWriteOff 
		    ,CostsGrossAfterWriteOffNoOrderRemaining	= CurrentBudgetExpenseGross - TotalCostsGrossAfterWriteOffNoOrder 
			,FutureLaborGrossRemaining		= FutureAllocatedGross  - LaborGross
		    ,HoursAfterWriteOffRemainingP				= CASE WHEN CurrentBudgetHours = 0		THEN 0 ELSE 100 * (CurrentBudgetHours - HoursAfterWriteOff)/CurrentBudgetHours END
		    ,LaborGrossAfterWriteOffRemainingP			= CASE WHEN CurrentBudgetLaborGross = 0	THEN 0 ELSE 100 * (CurrentBudgetLaborGross - LaborGrossAfterWriteOff)/CurrentBudgetLaborGross END
		    ,CostsGrossAfterWriteOffRemainingP			= CASE WHEN CurrentBudgetExpenseGross = 0 THEN 0 ELSE 100 * (CurrentBudgetExpenseGross - TotalCostsGrossAfterWriteOff)/CurrentBudgetExpenseGross END
		    ,CostsGrossAfterWriteOffNoOrderRemainingP	= CASE WHEN CurrentBudgetExpenseGross = 0 THEN 0 ELSE 100 * (CurrentBudgetExpenseGross - TotalCostsGrossAfterWriteOffNoOrder)/CurrentBudgetExpenseGross END
		  
			-- If numerator is zero, I take 0% arbitrarilly	
		   ,HoursBilledRemainingP	= CASE WHEN CurrentBudgetHours = 0				THEN 0 ELSE 100 * (CurrentBudgetHours - HoursBilled) /CurrentBudgetHours END
		   ,HoursRemainingP			= CASE WHEN CurrentBudgetHours = 0		THEN 0 ELSE 100 * (CurrentBudgetHours - Hours)/CurrentBudgetHours END
		   ,LaborNetRemainingP		= CASE WHEN CurrentBudgetLaborNet = 0	THEN 0 ELSE 100 * (CurrentBudgetLaborNet - LaborNet)/CurrentBudgetLaborNet END
	       ,LaborGrossRemainingP	= CASE WHEN CurrentBudgetLaborGross = 0	THEN 0 ELSE 100 * (CurrentBudgetLaborGross - LaborGross)/CurrentBudgetLaborGross END
		   ,CostsNetRemainingP		= CASE WHEN CurrentBudgetExpenseNet = 0	THEN 0 ELSE 100 * (CurrentBudgetExpenseNet - TotalCostsNet)/CurrentBudgetExpenseNet END
		   ,CostsGrossRemainingP	= CASE WHEN CurrentBudgetExpenseGross = 0 THEN 0 ELSE 100 * (CurrentBudgetExpenseGross - TotalCostsGross)/CurrentBudgetExpenseGross END
		   ,ToBillRemainingP		= CASE WHEN CurrentTotalBudget = 0		THEN 0 ELSE 100 * (CurrentTotalBudget - AmountBilledNoTax)/CurrentTotalBudget END
		   ,GrossRemainingP			= CASE WHEN CurrentTotalBudget = 0		THEN 0 ELSE 100 * (CurrentTotalBudget - TotalGross)/CurrentTotalBudget END
		   ,RemainingAllocatedHoursP = CASE WHEN AllocatedHours = 0		THEN 0 ELSE 100 * (AllocatedHours - Hours)/AllocatedHours END

	update #roll
    set    #roll.ItemID = ''No Item ID''
          ,#roll.ItemName = ''No Item''
    where  #roll.Entity = ''tItem''
    and    #roll.EntityKey = 0

	update #roll
    set    #roll.ItemID = ''No Service Code''
          ,#roll.ItemName = ''No Service''
    where  #roll.Entity = ''tService''
    and    #roll.EntityKey = 0
      
	update #roll
    set    #roll.ItemID = i.ItemID
          ,#roll.ItemName = i.ItemName
          ,#roll.WorkTypeKey = isnull(i.WorkTypeKey, 0)
    from   tItem i (nolock)
    where  #roll.Entity = ''tItem''
    and    #roll.EntityKey = i.ItemKey
     
	update #roll
    set    #roll.ItemID = s.ServiceCode
          ,#roll.ItemName = s.Description
          ,#roll.WorkTypeKey = isnull(s.WorkTypeKey, 0)
    from   tService s (nolock)
    where  #roll.Entity = ''tService''
    and    #roll.EntityKey = s.ServiceKey

	update #roll
	set    WorkTypeID = ''[No Billing Item ID]''
		   ,WorkTypeName = ''[No Billing Item]''
		   ,WorkTypeKey = isnull(WorkTypeKey, 0)
	where  isnull(WorkTypeKey, 0) = 0

	if @LayoutKey = 0
	begin
		-- problem here because display order in tWorkType not unique or missing
		create table #sorted (SortKey int identity(1,1), Entity varchar(50) null, EntityKey int null)
	
		-- no layout, rely on WT display order then Item Name
		update #roll
		set    #roll.WorkTypeID = wt.WorkTypeID
			  ,#roll.WorkTypeName = wt.WorkTypeName
			  ,#roll.WorkTypeDisplayOrder = wt.DisplayOrder
		from   tWorkType wt (nolock)
		where  #roll.WorkTypeKey = wt.WorkTypeKey 

		-- Now update entity specific WorkTypeNames
		UPDATE	#roll
		SET		#roll.WorkTypeName = cust.Subject
		FROM	tWorkTypeCustom cust (nolock)
		WHERE	#roll.WorkTypeKey = cust.WorkTypeKey
		AND		cust.Entity = @Entity
		AND		cust.EntityKey = @EntityKey

		insert  #sorted (Entity, EntityKey)
		select  Entity, EntityKey
		from    #roll
		order   by isnull(WorkTypeDisplayOrder,0), WorkTypeName, ItemName

		update  #roll
		set     #roll.WorkTypeDisplayOrder = #sorted.SortKey
		from    #sorted
		where   #roll.Entity = #sorted.Entity collate database_default
		and     #roll.EntityKey = #sorted.EntityKey

	end
	else
	begin
		-- the items have been reorganized on the layout 
		update #roll
		set    #roll.WorkTypeKey = 0
	
		-- get WT key only when parent entity is tWorkType	
		update #roll
		set    #roll.WorkTypeKey = lb.ParentEntityKey
		from   tLayoutBilling lb (nolock)
		where  lb.LayoutKey = @LayoutKey
		and    #roll.Entity = lb.Entity COLLATE DATABASE_DEFAULT
		and    #roll.EntityKey = lb.EntityKey     				
	    and    lb.ParentEntity = ''tWorkType''
	

		update #roll
		set    #roll.WorkTypeID = wt.WorkTypeID
			  ,#roll.WorkTypeName = wt.WorkTypeName
		from   tWorkType wt (nolock)
		where  #roll.WorkTypeKey = wt.WorkTypeKey 
		
		-- Now update entity specific WorkTypeNames
		UPDATE	#roll
		SET		#roll.WorkTypeName = cust.Subject
		FROM	tWorkTypeCustom cust (nolock)
		WHERE	#roll.WorkTypeKey = cust.WorkTypeKey
		AND		cust.Entity = @Entity
		AND		cust.EntityKey = @EntityKey

		-- but always get the Layout Order
		update #roll
		set    #roll.WorkTypeDisplayOrder = lb.LayoutOrder
		from   tLayoutBilling lb (nolock)
		where  lb.LayoutKey = @LayoutKey
		and    #roll.Entity = lb.Entity COLLATE DATABASE_DEFAULT
		and    #roll.EntityKey = lb.EntityKey     				

	end

	-- redo this because we modified WTKey
	update #roll
	set    WorkTypeID = ''[No Billing Item ID]''
		   ,WorkTypeName = ''[No Billing Item]''
		   ,WorkTypeKey = isnull(WorkTypeKey, 0)
	where  isnull(WorkTypeKey, 0) = 0

	-- Set the DepartmentName for tItem
	Update #roll 
	   set #roll.DepartmentName = d.DepartmentName
	from  tItem i (nolock)
	LEFT JOIN tDepartment d (nolock) ON i.DepartmentKey = d.DepartmentKey
	Where #roll.Entity = ''tItem''
	and   #roll.EntityKey = i.ItemKey

	-- Set the DepartmentName for tService
	Update #roll 
	   set #roll.DepartmentName = d.DepartmentName
	from  tService s (nolock)
	LEFT JOIN tDepartment d (nolock) ON s.DepartmentKey = d.DepartmentKey
	Where #roll.Entity = ''tService''
	and   #roll.EntityKey = s.ServiceKey


	select @Entity as GroupEntity -- how we grouped the projects
	       ,@EntityKey as GroupEntityKey
	       ,* 
	from #roll 
	order by WorkTypeDisplayOrder, WorkTypeID, ItemName

			     	
	RETURN 1
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptRequestDefInsert]'
GO
IF OBJECT_ID(N'[dbo].[sptRequestDefInsert]', 'P') IS NOT NULL
EXEC sp_executesql N'

ALTER PROCEDURE [dbo].[sptRequestDefInsert]
	@CompanyKey int,
	@UserKey int,
	@RequestName varchar(200),
	@FieldSetKey int,
	@RequestPrefix varchar(20),
	@ProjectDescription text,
	@Description varchar(500),
	@NextRequestNum int,
	@DisplayProjectFields tinyint,
	@DisplayClientProjNbr tinyint,
	@RequireProjectName tinyint,
	@RequireProjectDescription tinyint,
	@RequesterToProjectTeam tinyint,
	@Active tinyint,
	@MinDays smallint,
	@DisplayCampaign tinyint,
	@SendConfirmation tinyint,
	@ConfirmationMessage varchar(500),
	@PrintSpecOnSepPages tinyint,
	@TemplateProjectNumber varchar(100),
	@UseDefaultNameAndEmail tinyint,
	@ApproveEmailSubject varchar(300),
	@RejectEmailSubject varchar(300),
	@SendForApprovalEmailSubject varchar(300) = null,
	@DisplayDivisionProduct tinyint = 0,
	@RequireAttachments tinyint = 0,
	@ClientEmailSubject varchar(300) = null,
	@SelectSpecAddList tinyint = 0,
	@HideDueDate tinyint = 0,
	@IncludesDeliverables tinyint = 0,
	@DeliverableTypeList tinyint = 0,
	@NotifyUsersWhenSentForReview tinyint = 1,
	@EmailOnProjectCreate tinyint = 0,
	@CancelEmailSubject varchar(300) = null,
	@SendIndividualApprovedEmails tinyint = 1,
	@oIdentity INT OUTPUT
AS --Encrypt

 /*
  || When     Who Rel       What
  || 11/10/10 RLB 10.5.3.8  (91299) Fields added for enhancement
  || 1/21/10 RLB 10.5.4.0   (99967) Fields added for enhancement
  || 12/19/11 CRG 10.5.5.1  (128766) Added MinDays
  || 05/29/12 QMD 10.5.5.6  (143615) Added DisplayCampaign
  || 07/17/12 MFT 10.5.5.8  (105753) Added SendConfirmation & ConfirmationMessage
  || 08/27/12 KMC 10.5.5.9  (151486) Added PrintSpecOnSeparatePages option
  || 10/29/12 KMC 10.5.6.1  (157441) Added TemplateProjectNumber option
  || 03/25/15 WDF 10.5.9.0  (250961) Added @UserKey, CreatedByKey, CreatedByDate, UpdatedByKey
  || 06/03/15 WDF 10.5.9.3  (244161) Added @DisplayClientProjNbr
  || 07/02/15 GAR 10.5.9.4  (258520) Added @UseDefaultNameAndEmail
  || 10/28/15 WDF 10.5.9.7  (271728) Added @RequireProjectDescription
  || 08/04/16 GAR 10.6.0.6  (303018) Added ApproveEmailSubject and RejectEmailSubject
  || 11/07/17 RLB 10.6.2.2  (337565) Added SendForApprovalEmailSubject i believe the other 2 options exist above
  || 01/29/18 GHL 18.2.0.0  (380560) Added parameter @DisplayDivisionProduct for enhancement for Platimun only
  || 03/06/18 RLB 18.4.0.0  (384138) Added Require Attachments for enhancement Plat only
  || 03/08/18 RLB 18.4.0.0  (384138) Added ClientEmailSubject
  || 08/01/19 RLB 19.0.9.0  (463954) Added option to have a select list of specs on the add
  || 10/16/19 GAR 19.1.1.0  (460115) Added HideDueDate
  || 10/22/19 GWG 19.1.1.0  Include option to show deliverables
  || 07/07/20 RLB 20.0.8.0  (516586) Added option to have a select list of Deliverable Types on the add
  || 03/17/22 RLB 22.04.17  (588307) Added option to send notifications to notifiers when sent for out review defaulted to yes 
  || 04/12/22 CRG 22.05.15  (587804) Added @EmailOnProjectCreate
  || 08/26/22 RLB 22.09.18  (610285) moving projectnumber up to varchar100
  || 04/09/25 RLB 25.05.18  (695728) Added @CancelEmailSubject
  || 05/04/26 RLB 26.06.14  (721431) Added @SendIndividualApprovedEmails option
 */

	INSERT tRequestDef
		(
		CompanyKey,
		RequestName,
		FieldSetKey,
		RequestPrefix,
		Description,
		NextRequestNum,
		ProjectDescription,
		DisplayProjectFields,
		DisplayClientProjNbr,
		RequireProjectName,
		RequireProjectDescription,
		RequesterToProjectTeam,
		Active,
		UseDefaultNameAndEmail,
		MinDays,
		DisplayCampaign,
		SendConfirmation,
		ConfirmationMessage,
		PrintSpecOnSeparatePages,
		TemplateProjectNumber,
		CreatedByKey,
		CreatedByDate,
		UpdatedByKey,
		ApproveEmailSubject,
		RejectEmailSubject,
		SendForApprovalEmailSubject,
		DisplayDivisionProduct,
		RequireAttachments,
		ClientEmailSubject,
		SelectSpecAddList,
		HideDueDate,
		IncludesDeliverables,
		DeliverableTypeList,
		NotifyUsersWhenSentForReview,
		EmailOnProjectCreate,
		CancelEmailSubject,
		SendIndividualApprovedEmails
		)

	VALUES
		(
		@CompanyKey,
		@RequestName,
		@FieldSetKey,
		@RequestPrefix,
		@Description,
		@NextRequestNum,
		@ProjectDescription,
		@DisplayProjectFields,
		@DisplayClientProjNbr,
		@RequireProjectName,
		@RequireProjectDescription,
		@RequesterToProjectTeam,
		@Active,
		@UseDefaultNameAndEmail,
		@MinDays,
		@DisplayCampaign,
		@SendConfirmation,
		@ConfirmationMessage,
		@PrintSpecOnSepPages,
		@TemplateProjectNumber,
		@UserKey,
		GETUTCDATE(),
		@UserKey,
		@ApproveEmailSubject,
		@RejectEmailSubject,
		@SendForApprovalEmailSubject,
		isnull(@DisplayDivisionProduct, 0),
		isnull(@RequireAttachments, 0),
		@ClientEmailSubject,
		@SelectSpecAddList,
		@HideDueDate,
		@IncludesDeliverables,
		@DeliverableTypeList,
		@NotifyUsersWhenSentForReview,
		@EmailOnProjectCreate,
		@CancelEmailSubject,
		@SendIndividualApprovedEmails
		)
	
	SELECT @oIdentity = @@IDENTITY

	RETURN 1


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spScheduleValidateRecurring]'
GO
IF OBJECT_ID(N'[dbo].[spScheduleValidateRecurring]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROC [dbo].[spScheduleValidateRecurring]
	@ProjectKey int
AS
/*
|| When      Who Rel      What
|| 12/29/25  CRG 26.02.15 Created
|| 02/04/26  CRG 25.03.15 (720854) Now setting the predcessors complete flag
|| 07/01/26  CRG 26.07.19 (732019) Now updating the SummaryTaskKey to match the parent
*/

	--This SP removes excess recurring records if they exceed the MaxRecurring count, and if their parent task has been deleted,
	--It also pushes down perc comp on any past occurrences to their assignments

	IF NOT EXISTS(
			SELECT	NULL
			FROM	vTaskRecurringActive
			WHERE	ProjectKey = @ProjectKey)
		RETURN

	SELECT	*
	INTO	#RecurringTasks
	FROM	vTaskRecurringActive
	WHERE	ProjectKey = @ProjectKey

	SELECT	*
	INTO	#Active
	FROM	#RecurringTasks
	WHERE	RecurringActive = 1

	SELECT DISTINCT RecurringParentKey, 0 AS TaskExists, 0 AS BudgetTaskKey
	INTO	#ParentKeys
	FROM	#RecurringTasks

	UPDATE	#ParentKeys
	SET		TaskExists = 1,
			BudgetTaskKey = t.BudgetTaskKey
	FROM	tTask t
	INNER JOIN #ParentKeys pk ON t.TaskKey = pk.RecurringParentKey

	CREATE TABLE #ToDelete (TaskKey int NULL)

	--Delete orphaned occurrences where their parent key has been deleted
	INSERT	#ToDelete
	SELECT	rt.TaskKey
	FROM	#RecurringTasks rt
	INNER JOIN #ParentKeys pk ON rt.RecurringParentKey = pk.RecurringParentKey
	WHERE	pk.TaskExists <> 1

	--Delete occurrences where their RecurringOrder is greater than the Max of the current active occurrence
	INSERT	#ToDelete
	SELECT	rt.TaskKey
	FROM	#RecurringTasks rt
	INNER JOIN #Active a ON rt.RecurringParentKey = a.RecurringParentKey
	WHERE	rt.RecurringOrder > a.RecurringMax

	SELECT DISTINCT TaskKey
	INTO	#DeleteKeys
	FROM	#ToDelete

	DECLARE	@TaskKey int
	SELECT	@TaskKey = 0

	WHILE(1=1)
	BEGIN
		SELECT	@TaskKey = MIN(TaskKey)
		FROM	#DeleteKeys
		WHERE	TaskKey > @TaskKey

		IF @TaskKey IS NULL
			BREAK

		EXEC sptTaskDelete @TaskKey
	END
	
	UPDATE	tTask
	SET		PercComp = 100,
			ActComplete = ISNULL(t.ActComplete, dbo.fFormatDateNoTime(GETDATE()))
	FROM	#RecurringTasks rt
	INNER JOIN tTask t ON rt.TaskKey = t.TaskKey
	INNER JOIN #Active a ON rt.RecurringParentKey = a.RecurringParentKey
	WHERE	rt.RecurringOrder < a.RecurringOrder
	AND		(t.PercComp < 100 OR t.ActComplete IS NULL)

	UPDATE	tTaskUser
	SET		PercComp = 100,
			ActComplete = ISNULL(tu.ActComplete, rt.ActComplete)
	FROM	#RecurringTasks rt
	INNER JOIN tTaskUser tu ON rt.TaskKey = tu.TaskKey
	INNER JOIN #Active a ON rt.RecurringParentKey = a.RecurringParentKey
	WHERE	rt.RecurringOrder < a.RecurringOrder
	AND		(tu.PercComp < 100 OR tu.ActComplete IS NULL)

	UPDATE	tTask
	SET		PercComp = 0,
			ActComplete = NULL
	FROM	#RecurringTasks rt
	INNER JOIN tTask t ON rt.TaskKey = t.TaskKey
	INNER JOIN #Active a ON rt.RecurringParentKey = a.RecurringParentKey
	WHERE	rt.RecurringOrder > a.RecurringOrder

	UPDATE	tTaskUser
	SET		PercComp = 0,
			ActComplete = NULL
	FROM	#RecurringTasks rt
	INNER JOIN tTaskUser tu ON rt.TaskKey = tu.TaskKey
	INNER JOIN #Active a ON rt.RecurringParentKey = a.RecurringParentKey
	WHERE	rt.RecurringOrder > a.RecurringOrder
	
	SELECT	COUNT(*) AS RecurringMax, RecurringParentKey
	INTO	#MaxCount
	FROM	vTaskRecurringActive
	WHERE	ProjectKey = @ProjectKey
	GROUP BY RecurringParentKey

	--Make sure that the Max is correct
	UPDATE	tTask
	SET		RecurringMax = mc.RecurringMax
	FROM	#MaxCount mc
	INNER JOIN tTask t ON t.RecurringParentKey = mc.RecurringParentKey

	--Make sure that the BudgetTaskKey points to itself, if TrackBudget = 1
	UPDATE	tTask
	SET		BudgetTaskKey = t.TaskKey
	FROM	#RecurringTasks rt
	INNER JOIN tTask t ON rt.TaskKey = t.TaskKey
	INNER JOIN #Active a ON rt.RecurringParentKey = a.RecurringParentKey
	WHERE	rt.RecurringOrder >= a.RecurringOrder --Only update active and later
	AND		t.TrackBudget = 1

	--Get the parent''s settings, so we can update its children below
	SELECT DISTINCT	t.TaskKey, t.TaskID, t.ProjectOrder, t.DisplayOrder, t.SummaryTaskKey
	INTO	#ParentSettings
	FROM	#RecurringTasks rt
	INNER JOIN tTask t ON rt.RecurringParentKey = t.TaskKey

	--Update the recurring children to match the same settings as the parent
	UPDATE	tTask
	SET		TaskID = ps.TaskID,
			ProjectOrder = ps.ProjectOrder,
			DisplayOrder = ps.DisplayOrder,
			SummaryTaskKey = ps.SummaryTaskKey
	FROM	#ParentSettings ps
	INNER JOIN tTask t ON t.RecurringParentKey = ps.TaskKey
	WHERE	t.TaskKey <> ps.TaskKey --Don''t update the parent itself

	--Update the predecessors complete flag
	UPDATE	tTask
	SET		PredecessorsComplete = 
				CASE
					WHEN t.RecurringOrder <= a.RecurringOrder THEN 1 --If it''s prior to or includes the current active occurrence
					ELSE 0
				END
	FROM	#RecurringTasks rt
	INNER JOIN tTask t ON rt.TaskKey = t.TaskKey
	INNER JOIN #Active a ON rt.RecurringParentKey = a.RecurringParentKey

	--Update the date on the TaskName
	UPDATE	tTask
	SET		TaskName = 
				CASE WHEN CHARINDEX(''[['', t.TaskName) > 1 THEN SUBSTRING(ISNULL(t.TaskName, ''''), 0, CHARINDEX(''[['', t.TaskName) - 1)
				ELSE t.TaskName
			END
	FROM	#RecurringTasks rt
	INNER JOIN tTask t ON rt.TaskKey = t.TaskKey

	UPDATE	tTask
	SET		TaskName = ISNULL(t.TaskName, '''') + '' [['' + SUBSTRING(DATENAME(MONTH, t.PlanStart), 1, 3) + ''-'' + CAST(DAY(t.PlanStart) AS varchar) + '']]''
	FROM	#RecurringTasks rt
	INNER JOIN tTask t ON rt.TaskKey = t.TaskKey'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAISearchContacts]'
GO
IF OBJECT_ID(N'[dbo].[spApiAISearchContacts]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spApiAISearchContacts]
(
    @CompanyKey     int,
    @UserKey        int,
    @SearchTerm     nvarchar(500),
    @CanViewOthers  bit = 0         -- 1 = admin or viewOtherContacts right; 0 = own contacts only
)
AS --Encrypt

/*
|| When      Who Rel        What
|| --        --  --         Created - contact search (set-based GL company filter)
|| 05/25/26  AI  26.05.25   Added standard #errors / warnings scaffold; required-field validation.
||                          Result-set shape now: [warnings, contacts] - handler updated to match.
|| 05/28/26  AI  26.05.28   Added #errors / warnings; required-field validation. Result-set shape now [warnings, contacts].
|| 06/24/26  AI  26.06.24   Added @CanViewOthers; restricts to OwnerKey = @UserKey when 0.
*/

set nocount on

    select * into #errors from tAPIErrorTemplate where 1 = 2

    declare @RestrictToGLCompany int

    if @SearchTerm is null or LTRIM(RTRIM(@SearchTerm)) = ''''
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''REQUIRED_FIELD'', ''searchTerm is required.'', ''searchTerm'')

        select errorType, errorCode, errorMessage, fieldName from #errors order by errorType desc, fieldName
        drop table #errors
        return -100
    end

    select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0)
    from   tPreference (nolock) where CompanyKey = @CompanyKey

    -- Result set 1: warnings (consistent shape, even when empty)
    select errorType, errorCode, errorMessage, fieldName from #errors where errorType = ''warning''

    -- Result set 2: contacts
    select
        v.UserKey       as contactKey,
        v.UserFullName  as fullName,
        v.Email         as email,
        v.UserName      as contactName,
        v.Phone1        as phone,
        v.Cell          as mobile,
        v.Title         as title,
        v.CompanyName   as companyName,
        v.Address1      as address1,
        v.Address2      as address2,
        v.City          as city,
        v.State         as state,
        v.PostalCode    as postalCode,
        v.Country       as country
    from   vUserName v (nolock)
    where  v.OwnerCompanyKey = @CompanyKey
      and  v.Active          = 1
      and  (
              v.UserFullName  like ''%'' + @SearchTerm + ''%''
           or v.Email         like ''%'' + @SearchTerm + ''%''
           or v.UserName      like ''%'' + @SearchTerm + ''%''
           or v.CompanyName   like ''%'' + @SearchTerm + ''%''
           )
      and  (@CanViewOthers = 1 or v.OwnerKey = @UserKey)
      and  (@RestrictToGLCompany = 0
            or v.GLCompanyKey in (select GLCompanyKey from tUserGLCompanyAccess (nolock) where UserKey = @UserKey))
    order by v.UserFullName

    drop table #errors
    return 0

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskUserUpdateRecurringTasks]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskUserUpdateRecurringTasks]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROC [dbo].[sptTaskUserUpdateRecurringTasks]
	@ProjectKey int
AS
/*
|| When      Who Rel      What
|| 12/22/25  CRG 26.02.15 Created
|| 06/01/26  RLS 26.07.19 (729817) Protect against @TaskUserStatusKey being 0 (needs to be NULL for Default Status)
*/

	SELECT	TaskKey, RecurringOrder
	INTO	#ActiveRecurring
	FROM	vTaskRecurringActive
	WHERE	ProjectKey = @ProjectKey
	AND		RecurringActive = 1
	AND		ISNULL(ModifiedOccurrence, 0) = 0

	SELECT	tu.TaskKey, tu.TaskUserKey, tu.UserKey, tu.ServiceKey, tu.Hours, tu.TaskUserStatusKey
	INTO	#RecurringAssignments
	FROM	tTaskUser tu (nolock)
	INNER JOIN #ActiveRecurring t ON tu.TaskKey = t.TaskKey

	SELECT	0 AS TaskKey, RecurringOrder  --Can''t just say "TaskKey" because it creates an Identity column in the Temp Table
	INTO	#FutureTasks
	FROM	tTask (nolock)
	WHERE	1 = 2

	SELECT	0 AS TaskUserKey, TaskKey
	INTO	#ExistingAssignments
	FROM	tTaskUser (nolock)
	WHERE	1 = 2

	--Just re-use TaskUser records, so we don''t burn through them, since these records have not been edited by a user yet anyway
	DECLARE	@TaskKey int,
			@RecurringParentKey int,
			@RecurringOrder int,
			@TaskUserKey int,
			@UpdateTaskKey int,
			@UpdateRecurringOrder int,
			@UpdateTaskUserKey int,
			@NewCount int,
			@ExistingCount int,
			@UserKey int,
			@ServiceKey int,
			@Hours decimal(24, 4),
			@TaskUserStatusKey int,
			@OrigUserKey int,
			@OrigServiceKey int,
			@OrigHours decimal(24, 4),
			@RecalcRequired tinyint

	SELECT	@TaskKey = 0

	WHILE(1=1)
	BEGIN
		--Loop through each active recurring task
		SELECT	@TaskKey = MIN(TaskKey)
		FROM	#ActiveRecurring
		WHERE	TaskKey > @TaskKey

		IF @TaskKey IS NULL
			BREAK

		SELECT	@TaskUserKey = 0,
				@RecurringParentKey = RecurringParentKey,
				@RecurringOrder = RecurringOrder
		FROM	tTask (nolock)
		WHERE	TaskKey = @TaskKey

		--Fill the table with all of the future occurrences of this recurring task
		DELETE	#FutureTasks

		INSERT	#FutureTasks
				(TaskKey, RecurringOrder)
		SELECT	TaskKey, RecurringOrder
		FROM	tTask (nolock)
		WHERE	RecurringParentKey = @RecurringParentKey --Tasks with the same recurring parent
		AND		RecurringOrder > @RecurringOrder --Tasks beyond the current active one

		--Fill the table with all of the recurring task assignments for future tasks (beyond the current active one)
		DELETE	#ExistingAssignments

		INSERT	#ExistingAssignments
				(TaskUserKey, TaskKey)
		SELECT	tu.TaskUserKey, tu.TaskKey
		FROM	tTaskUser tu (nolock)
		INNER JOIN #FutureTasks ft (nolock) ON tu.TaskKey = ft.TaskKey

		SELECT	@UpdateRecurringOrder = 0

		WHILE(1=1)
		BEGIN
			SELECT	@UpdateRecurringOrder = MIN(RecurringOrder)
			FROM	#FutureTasks
			WHERE	RecurringOrder > @UpdateRecurringOrder

			IF @UpdateRecurringOrder IS NULL
				BREAK

			SELECT	@UpdateTaskKey = MIN(TaskKey) --Min because there will be multiple assignments with the same TaskKey and RecurringOrder
			FROM	#FutureTasks
			WHERE	RecurringOrder = @UpdateRecurringOrder

			--Count of assignments on the existing recurring task that''s about to be updated
			SELECT	@ExistingCount = COUNT(*)
			FROM	#ExistingAssignments (nolock)
			WHERE	TaskKey = @UpdateTaskKey

			SELECT	@TaskUserKey = 0,
					@NewCount = 0,
					@UpdateTaskUserKey = 0

			WHILE(1=1)
			BEGIN
				SELECT	@TaskUserKey = MIN(TaskUserKey)
				FROM	#RecurringAssignments
				WHERE	TaskKey = @TaskKey
				AND		TaskUserKey > @TaskUserKey

				IF @TaskUserKey IS NULL
					BREAK

				SELECT	@UserKey = UserKey,
						@ServiceKey = ServiceKey,
						@Hours = Hours,
						@TaskUserStatusKey = TaskUserStatusKey
				FROM	#RecurringAssignments
				WHERE	TaskUserKey = @TaskUserKey

				IF @TaskUserStatusKey = 0
					SELECT @TaskUserStatusKey = NULL

				SELECT	@NewCount = @NewCount + 1

				SELECT	@UpdateTaskUserKey = MIN(TaskUserKey)
				FROM	#ExistingAssignments
				WHERE	TaskKey = @UpdateTaskKey
				AND		TaskUserKey > @UpdateTaskUserKey

				IF @UpdateTaskUserKey IS NULL
					INSERT	tTaskUser
							(TaskKey, UserKey, ServiceKey, Hours, TaskUserStatusKey, RecalcRequired)
					VALUES	(@UpdateTaskKey, @UserKey, @ServiceKey, @Hours, @TaskUserStatusKey, 1)
				ELSE
				BEGIN
					SELECT	@OrigUserKey = UserKey,
							@OrigServiceKey = ServiceKey,
							@OrigHours = Hours
					FROM	tTaskUser (nolock)
					WHERE	TaskUserKey = @UpdateTaskUserKey

					IF ISNULL(@OrigUserKey, 0) <> ISNULL(@UserKey, 0)
							OR ISNULL(@OrigServiceKey, 0) <> ISNULL(@ServiceKey, 0)
							OR ISNULL(@OrigHours, 0) <> ISNULL(@Hours, 0)
						SELECT	@RecalcRequired = 1
					ELSE
						SELECT	@RecalcRequired = 0

					UPDATE	tTaskUser
					SET		UserKey = @UserKey,
							ServiceKey = @ServiceKey,
							Hours = @Hours,
							TaskUserStatusKey = @TaskUserStatusKey,
							RecalcRequired = @RecalcRequired
					FROM	tTaskUser
					WHERE	TaskUserKey = @UpdateTaskUserKey
				END
			END

			IF @NewCount < @ExistingCount
				DELETE	tTaskUser
				WHERE	TaskKey = @UpdateTaskKey
				AND		TaskUserKey > @UpdateTaskUserKey
		END
	END'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptRequestDefUpdate]'
GO
IF OBJECT_ID(N'[dbo].[sptRequestDefUpdate]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptRequestDefUpdate]
	@RequestDefKey int,
	@UserKey int,
	@CompanyKey int,
	@RequestName varchar(200),
	@ProjectDescription text,
	@FieldSetKey int,
	@RequestPrefix varchar(20),
	@Description varchar(500),
	@NextRequestNum int,
	@DisplayProjectFields tinyint,
	@DisplayClientProjNbr tinyint,
	@RequireProjectName tinyint,
	@RequireProjectDescription tinyint,
	@RequesterToProjectTeam tinyint,
	@Active tinyint,
	@MinDays smallint,
	@DisplayCampaign tinyint,
	@SendConfirmation tinyint,
	@ConfirmationMessage varchar(500),
	@PrintSpecOnSeparatePages int,
	@TemplateProjectNumber varchar(100),
	@UseDefaultNameAndEmail tinyint,
	@ApproveEmailSubject varchar(300),
	@RejectEmailSubject varchar(300),
	@SendForApprovalEmailSubject varchar(300) = null,
	@DisplayDivisionProduct tinyint = null,
	@RequireAttachments tinyint = null,
	@ClientEmailSubject varchar(300) = null,
	@SelectSpecAddList tinyint = null,
	@HideDueDate tinyint = 0,
	@IncludesDeliverables tinyint = 0,
	@DeliverableTypeList tinyint = 0,
	@NotifyUsersWhenSentForReview tinyint = 1,
	@EmailOnProjectCreate tinyint = 0,
	@RestrictAfterApproval tinyint = 0,
	@CancelEmailSubject varchar(300) = null,
	@SendIndividualApprovedEmails tinyint = 1

AS --Encrypt

 /*
  || When     Who Rel       What
  || 11/10/10 RLB 10.5.3.8  (91299) Fields added for enhancement
  || 1/21/10  RLB 10.5.4.0  (99967) Fields added for enhancement
  || 12/19/11 CRG 10.5.5.1  (128766) Added MinDays
  || 05/29/12 QMD 10.5.5.6  (143615) Added DisplayCampaign
  || 07/17/12 MFT 10.5.5.8  (105753) Added SendConfirmation & ConfirmationMessage
  || 08/27/12 KMC 10.5.5.9  (151486) Added PrintSpecOnSeparatePages option
  || 10/29/12 KMC 10.5.6.1  (157441) Added TemplateProjectNumber option
  || 03/25/15 WDF 10.5.9.0  (250961) Added @UserKey, UpdatedByKey
  || 06/03/15 WDF 10.5.9.3  (244161) Added @DisplayClientProjNbr
  || 07/02/15 GAR 10.5.9.4  (258520) Added @UseDefaultNameAndEmail
  || 10/28/15 WDF 10.5.9.7  (271728) Added @RequireProjectDescription
  || 08/04/16 GAR 10.6.0.6  (303018) Added ApproveEmailSubject and RejectEmailSubject
  || 11/09/17 RLB 10.6.2.2  (337565) Added SendForApprovalEmailSubject i believe the other 2 options exist above
  || 01/29/18 GHL 18.2.0.0  (380560) Added parameter @DisplayDivisionProduct for enhancement for Platimun only
  ||                         this controls the display of divisions and products on project requests
  || 03/06/18 RLB 18.4.0.0  (384138) Added Require Attachments for enhancement Plat only
  || 03/08/18 RLB 18.4.0.0  (384138) Added ClientEmailSubject
  || 07/31/19 RLB 19.0.9.0  (463954) Added option to have a select list of specs on the add
  || 10/16/19 GAR 19.1.1.0  (460115) Added HideDueDate
  || 10/22/19 GWG 19.1.1.0  Include option to show deliverables
  || 07/07/20 RLB 20.0.8.0  (516586) Added option to have a select list of Deliverable Types
  || 03/17/22 RLB 22.04.17  (588307) Added option to send notifications to notifiers when sent for out review defaulted to yes 
  || 04/12/22 CRG 22.05.15  (587804) Added @EmailOnProjectCreate
  || 07/25/22 RLB 22.08.14  (604397) added option from kohls restrict after approval
  || 08/26/22 RLB 22.09.18  (610285) moving projectnumber up to varchar100
  || 04/09/25 RLB 25.05.18  (695728) Added @CancelEmailSubject
  || 05/04/26 RLB 26.06.14  (721431) Added @SendIndividualApprovedEmails option
*/

	-- since this is for Platinum only, read DisplayDivisionProduct first
	if @DisplayDivisionProduct is null
		select @DisplayDivisionProduct = DisplayDivisionProduct
		from   tRequestDef (nolock) where RequestDefKey = @RequestDefKey
	if @RequireAttachments is null
		select @RequireAttachments = RequireAttachments
		from   tRequestDef (nolock) where RequestDefKey = @RequestDefKey

	UPDATE
		tRequestDef
	SET
		CompanyKey = @CompanyKey,
		RequestName = @RequestName,
		FieldSetKey = @FieldSetKey,
		RequestPrefix = @RequestPrefix,
		Description = @Description,
		NextRequestNum = @NextRequestNum,
		ProjectDescription = @ProjectDescription,
		DisplayProjectFields = @DisplayProjectFields,
		DisplayClientProjNbr = @DisplayClientProjNbr,
		RequireProjectName = @RequireProjectName, 
		RequireProjectDescription = @RequireProjectDescription,
		RequesterToProjectTeam = @RequesterToProjectTeam,
		Active = @Active,
		UseDefaultNameAndEmail = @UseDefaultNameAndEmail,
		MinDays = @MinDays,
		DisplayCampaign = @DisplayCampaign,
		SendConfirmation = @SendConfirmation,
		ConfirmationMessage = @ConfirmationMessage,
		PrintSpecOnSeparatePages = @PrintSpecOnSeparatePages,
		TemplateProjectNumber = @TemplateProjectNumber,
		UpdatedByKey = @UserKey,
		ApproveEmailSubject = @ApproveEmailSubject,
		RejectEmailSubject = @RejectEmailSubject,
		SendForApprovalEmailSubject = @SendForApprovalEmailSubject,
		DisplayDivisionProduct = @DisplayDivisionProduct,
		RequireAttachments = @RequireAttachments,
		ClientEmailSubject  = @ClientEmailSubject,
		SelectSpecAddList = @SelectSpecAddList,
		HideDueDate = @HideDueDate,
		IncludesDeliverables = @IncludesDeliverables,
		DeliverableTypeList = @DeliverableTypeList,
		NotifyUsersWhenSentForReview = @NotifyUsersWhenSentForReview,
		EmailOnProjectCreate = @EmailOnProjectCreate,
		RestrictAfterApproval = @RestrictAfterApproval,
		CancelEmailSubject = @CancelEmailSubject,
		SendIndividualApprovedEmails = @SendIndividualApprovedEmails
	WHERE
		RequestDefKey = @RequestDefKey 

	RETURN 1

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spScheduleFlashSaveWMJ]'
GO
IF OBJECT_ID(N'[dbo].[spScheduleFlashSaveWMJ]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spScheduleFlashSaveWMJ]
	(
	@ProjectKey int,
	@ProjectStatusKey int,
	@StartDate smalldatetime,
	@CompleteDate smalldatetime,
	@ScheduleDirection smallint,
	@DetailedNotes varchar(4000),
	@WorkMon tinyint,
	@WorkTue tinyint,
	@WorkWed tinyint,
	@WorkThur tinyint,
	@WorkFri tinyint,
	@WorkSat tinyint,
	@WorkSun tinyint,
	@Duration int,
	@PercComp int,
	@AutoIDTask tinyint,
	@SimpleSchedule tinyint,
	@UserKey int = NULL,
	@Platinum tinyint = 0,
	@ValidatePreds tinyint = 1,
	@tasksFromTemplate tinyint = 0	
	)

AS -- Encrypt

  /*
  || When     Who Rel   What
  || 10/19/06 GHL 8.4   Added tTaskUser Rollup logic 
  || 11/27/06 GHL 8.4   Added update of tProject.Active 
  || 12/20/06 GHL 8.4   Added verification logic for predecessors similar to tasks
  || 12/21/06 GHL 8.4   Added logic to prevent duplicates in tAssignment
  || 01/03/07 GHL 8.4   Added patch to cleanup SummaryTaskKey = TaskKey situation
  || 01/03/07 GHL 8.4   Added protection against null PercComp
  || 01/22/07 GHL 8.4   Added logic for completed time and user
  || 02/09/07 GHL 8.4   Adding now user in tAssignment if missing there but is in tTaskUser
  ||                    Bug 8250 at Media Logic
  || 04/13/07 GHL 8.4   Added update of tProject.TaskStatus     
  || 05/18/07 RTC 8.5   (8314) Added custom field handling       
  || 09/06/07 GHL 8.435 Added patch for incorrect MoneyTask flag         
  || 05/09/08 RTC 8.5.1 Added logic for Task User Assignments to handle insert and updates, instead of delete all and re-insert      
  || 08/02/08 GWG 10.006 Added UserKey to the update tTaskUser to handle reasigning tasks. 
  || 09/03/08 GHL 10.008 (30569, 33987) Added/Fixed patch to update the BudgetTaskKey when missing
  || 09/29/08 GHL 10.009 (35379) Added patch to fix problem with TaskType = Tracking with existing subtasks
  ||                     i.e. should be TaskType = Summary  
  || 10/07/08 GHL 10.010 (36176) Added patch for incorrect MoneyTask flag (when TrackBudget = 1 and MoneyTask = 0)
  || 6/8/09   CRG 10.5.0.0 Added ServiceKey, Subject, Description, Comments to be updated from the #tTaskUser table
  || 09/14/09 RLB 10.5.1.0 Added DetailedNotes, Saving Next step comments on the project Schedule Project Setup area
  || 01/04/10 GHL 10.516 Added check of tran transfer status (task deletion)
  || 01/08/10 GHL 10.516 Added check of tran WIP status (task deletion) 
  || 01/11/10 GHL 10.516 (71304) Removed check of time DetailTaskKey (task deletion)
  || 01/21/10 GHL 10.517 (72908) Reviewed the deletion of transferred trans at the bottom of sp
  ||                     to increase perfo
  || 3/2/10   CRG 10.5.1.9 Added @AutoIDTask and @SimpleSchedule
  || 3/11/10  CRG 10.5.1.9 Added code to make sure that any tasks where ShowOnCalendar = 1 have the date part of EventStart/End matching the PlanStart/Complete dates
  || 04/14/10 GHL 10.521 (78802) Checking now amounts and rates on approved estimates
  ||                      if 0, we can delete the tasks
  || 7/12/10  CRG 10.5.3.2 Added ShowOnTimeline and TaskColor
  || 7/14/10  GWG 10.5.3.2 Added the rollup of names and allocated hours
  || 7/27/10  CRG 10.5.3.3 Now copying over Activities if the new Task was dragged onto the Schedule screen.
  ||                       Added optional UserKey parameter for use by the Activity copy SP.
  || 10/19/10 CRG 10.5.3.7 Removed ShowOnTimeline and TaskColor. Added TimelineSegmentKey.
  || 12/30/10 GHL 10.5.3.9 (87237) When checking if the tasks are in tEstimateTask before deleting them
  ||                       check if the estimate is for the project, because this could be for an opportunity
  ||                       If this for an opportunity, it is OK to delete because the task structure 
  ||                       is temporary stored in tEstimateTaskTemp
  || 2/11/11  RLB 10.5.4.1 (101827) changed error code on Task Predecessors to help locate where an error is coming from
  || 3/8/11   CRG 10.5.4.2 Now calling spScheduleSaveReassignToDo to reassign To Do items
  || 3/23/11  RLB 10.5.4.2 (106451) only pull tasks with PercComp < 100 when setting project task status
  || 4/19/11  GHL 10.5.4.3 (109241) Added recalc of estimates data when deleting tasks on estimates
  || 8/03/11  GHL 10.5.4.6 (118043) Removed an error when trying to delete a predecessor relationship which is already deleted 
  || 11/4/11  GHL 10.5.4.9 (125561) Instead of deleting tEstimateTaskExpense recs, set TaskKey = null when deleting tasks
  || 12/15/11 GWG 10.5.5.1 Added handling of defaults for subscribing and deliverable review and notify
  || 03/12/12 GHL 10.5.5.3 (136576) Modified the queries setting BudgetTaskKey (i.e I set them even if BTK <> 0)
  ||                       cause we keep on getting corrupted tasks at CenterLine
  || 03/21/12 GWG 10.554  Modified the call to copy activities so it will also copy project level todo''s
  || 05/15/12 GHL 10.556  Modified the insertion of tTaskUser so that we can have duplicate (TaskKey,UserKey,ServiceKey)
  || 10/30/12 RLB 10.5.6.1 Kohls enhancement for Constraint Day of the Week 
  || 10/30/12 RLB 10.5.6.2 Kohls enhancement for Exclude From Status
  || 06/20/13 RLB 10.5.6.9 Added for Enhancement (172776) 
  || 10/28/13 WDF 10.5.7.3 Added Logging of Task deletes
  || 03/06/14 RLB 10.5.7.8 (196273) Adding AllowAllocatedHours for enhancement
  || 04/13/17 GHL 10.615 (340912) Added deletion of estimate labor titles
  || 04/24/17 RLB 10.6.1.5 Added InWeeks on Preds for Kolhs change
  || 04/02/18 CRG 18.4.0   Added @Platinum parm to update platinum specific columns
  || 04/03/18 CRG 18.4.0   Added delete of tTaskUserHour when tTaskUser records are deleted
  || 04/20/18 GWG 18.5    Added sp call to set assignment hourly rates.
  || 05/03/18 RLB 18.5.0.0 Added some protection on plan complete getting time on it and plan start
  || 06/14/18 GWG 18.6.0.0 Don''t update tProject if you are coming from plat
  || 06/21/18 CRG 18.7.0.0 Added requirement in validation of predecessors that the PredecessorKey be a valid Task before it returns an error related to it
  || 06/29/18 CRG 18.7.0.0 Added TCProjectStatusKey
  || 07/09/18 CRG 18.8.0.0 Added validation of predecessor keys before save
  || 08/31/18 CRG 18.9.0.0 Added PercAssigned to the insert of tTaskUser
  || 09/28/18 CRG 18.9.1.0 Added logic to mark tasks for deletion when they have invalid SummaryTaskKeys
  || 09/28/18 RLB 18.9.1.0 Add update to project Task Status
  || 10/01/18 CRG 18.9.1.0 Removed error return if task marked for deletion is not already in the DB. We''ll just let it try to delete, and then continue on since it doesn''t hurt anything.
  || 10/26/18 CRG 18.9.2.0 (427769) Removed error return if tasks are no longer in schedule on DB. We''ll just let it try to save and then continue on.
  || 12/17/18 CRG 19.0.1.0  Added optional @ValidatePreds parameter
  || 06/21/19 RLS 19.0.7.0 (465965) Added @TasksFromTemplate parameter and operations on #tProjectUserServices
  || 06/24/19 CRG 19.0.7.0 (467392) Preventing duplicate predecessors
  || 07/18/19 GAR 19.0.8.0 (454300) Only copy todos if the preference is not turned off
  || 09/25/19 RLS 19.1.0.0 (480937) Changed the where clause in DELETE tProjectUserServices to: AND #tAssignment.Action = 3 instead of  #tAssignment.Action in (1,3)
  || 09/07/21 CRG 21.09.18 (569967) Now only updating PercComp, ActStart, and ActComplete if they''ve changed since the screen was loaded
  || 09/23/21 CRG 21.09.18 (572146) Cleaned up the NULL checking for OrigActStart and OrigActComplete
  || 10/08/21 CRG 21.11.14 (573148) Added fix to ensure that any copied tasks with negative SummaryTaskKeys are removed from the DB
  || 10/28/21 AMP xx.xx.xx (DEV2506-502) Added a flag to hide the task on the deliverable board 
  || 06/22/22 CRG 22.07.17 (604204) Moved the Copy To Do logic outside of the transaction
  || 08/26/22 RLB 22.09.18 (610285) moving projectnumber up to varchar100
  || 09/23/22 GAR 22.10.16 (DEV2605) Added AvalaraTaxCodeKey
  || 03/21/22 CRG 23.04.16 (622919) Added NoTimeEntry for Deborah Wood customization
  || 03/24/23 CRG 23.04.16 (635797) Now deleting task sub-tables when cleaning up tasks at the end with negative SummaryTaskKeys
  || 04/25/23 RLB 23.05.14 (623383) Added new col ADescriptionLastModified update
  || 05/08/23 CRG 23.06.18 (604775) Changed Priority to TaskPriorityKey
  || 10/04/23 CRG 23.11.19 (647340) Added MustFinishOnPredComplete
  || 06/23/25 CRG 25.07.20 (703934) Added DISTINCT to query of tProjectUserServices to ensure it''s unique 
  || 07/02/25 CRG 25.08.17 (705248) Performance improvements for large schedules
  || 08/22/25 CRG 25.10.19 (709445) Added ability to only update ProjectOrder, DisplayOrder, and TaskID to improve efficiency
  || 09/10/25 CRG 25.10.19 (710574) Now returning whether or not this project is a cross project pred, so it can be added to the queue later
  || 12/17/25 CRG 26.02.15 (548907) Added recurring task fields
  || 12/22/25 CRG 26.02.15 Added call to sptTaskUserUpdateRecurringTasks
  || 02/26/26 RLS 26.04.19 (721929) Added TaskUserStatusKey to tTaskUser insert and update sections
  || 05/13/26 RLS 26.05.17 (728544) Added zero/NULL check for TaskUserStatusKey
  || 05/13/26 CRG 26.06.14 (724211) Added new recurring frequency options
  || 
  */

	SET NOCOUNT ON
	 
    /* 
    Assume that the following tables have been populated
    #tTask
    #tTaskPredecessor
    #tTaskUser
    #tAssignment
    Also
    
    CREATE TABLE #NewKeys(Entity VARCHAR(50) NULL, OldKey INT NULL, NewKey INT NULL)
    
    Validation of temp tables ex #tTask

	Action = 1 Insert, 2 Update, 3 Delete, 4 Cannot Delete, 99 Update ProjectOrder, DisplayOrder, TaskID only
	
    #tTask.TaskKey  | #tTask.Action | Currently in DB
    ------------------------------------------------
        x		           2                x
        y                  2                y
        w                  2       
        -1                 1
        -2                 1
        u                  3                u
        v                  3
                                            z
        
        -1 and -2 will be inserted
        x and y can be updated
        u can be deleted
        
        w cannot be updated = ABORT
        z was not sent from flash = ABORT
        v cannot be deleted = ABORT 
	
	*/
	
	-- Tasks
	-- will capture case z 
	
	/* Assume created in VB
	CREATE TABLE #CopyToDos
		(FromTaskKey int NULL, 
		NewTaskKey int NULL)
	*/

	--FOR DEBUGGING ONLY!!!!
	DECLARE	@saveTiming tinyint,
			@debugTimeStamp datetime,
			@timingMsg nvarchar(max)
	SELECT	@saveTiming = 0, --SET TO 0 FOR PRODUCTION!!!!
			@debugTimeStamp = GETDATE(),
			@timingMsg = ''''

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tTime (NOLOCK)  
	WHERE	#tTask.TaskKey = tTime.TaskKey
	AND     tTime.TransferToKey is null -- not transferred
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tTime (NOLOCK)  
	WHERE	#tTask.TaskKey = tTime.TaskKey
	AND     tTime.TransferToKey is not null -- transferred
	AND     tTime.WIPPostingInKey > 0      -- WIP
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tExpenseReceipt (NOLOCK)  
	WHERE	#tTask.TaskKey = tExpenseReceipt.TaskKey
	AND     tExpenseReceipt.TransferToKey is null -- not transferred
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tExpenseReceipt (NOLOCK)  
	WHERE	#tTask.TaskKey = tExpenseReceipt.TaskKey
	AND     tExpenseReceipt.TransferToKey is not null -- transferred
	AND     tExpenseReceipt.WIPPostingInKey > 0       -- in wip
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tPurchaseOrderDetail (NOLOCK)  
	WHERE	#tTask.TaskKey = tPurchaseOrderDetail.TaskKey
	AND     tPurchaseOrderDetail.TransferToKey is null -- not transferred
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tVoucherDetail (NOLOCK)  
	WHERE	#tTask.TaskKey = tVoucherDetail.TaskKey 
	AND     tVoucherDetail.TransferToKey is null	-- not transferred
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tVoucherDetail (NOLOCK)  
	WHERE	#tTask.TaskKey = tVoucherDetail.TaskKey 
	AND     tVoucherDetail.TransferToKey is not null -- transferred
	AND     tVoucherDetail.WIPPostingInKey > 0 -- in wip
	AND     #tTask.Action = 3
	
	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tMiscCost (NOLOCK)  
	WHERE	#tTask.TaskKey = tMiscCost.TaskKey
	AND     tMiscCost.TransferToKey is null -- not transferred
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tMiscCost (NOLOCK)  
	WHERE	#tTask.TaskKey = tMiscCost.TaskKey
	AND     tMiscCost.TransferToKey is not null -- transferred
	AND     tMiscCost.WIPPostingInKey > 0      -- in wip
	AND     #tTask.Action = 3

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tInvoiceLine (NOLOCK)  
	WHERE	#tTask.TaskKey = tInvoiceLine.TaskKey
	AND     #tTask.Action = 3

	-- Cannot delete if on an approved estimate
	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tEstimateTask et (NOLOCK)
		  ,tEstimate e (NOLOCK)  
	WHERE	#tTask.TaskKey = et.TaskKey
	AND     et.EstimateKey = e.EstimateKey
	AND    ISNULL(et.EstLabor, 0) + ISNULL(et.EstExpenses, 0) <> 0
	AND     ((isnull(e.ExternalApprover, 0) > 0 and  e.ExternalStatus = 4) 
			Or (isnull(e.ExternalApprover, 0) = 0 and  e.InternalStatus = 4))  
	AND     #tTask.Action = 3
	AND     e.ProjectKey = @ProjectKey -- could be a tLead estimate, OK to delete

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tEstimateTaskLabor etl (NOLOCK)
		   ,tEstimate e (NOLOCK)  
	WHERE	#tTask.TaskKey = etl.TaskKey
	AND     etl.EstimateKey = e.EstimateKey
	AND     etl.Rate <> 0
	AND     ((isnull(e.ExternalApprover, 0) > 0 and  e.ExternalStatus = 4) 
			Or (isnull(e.ExternalApprover, 0) = 0 and  e.InternalStatus = 4))  
	AND     #tTask.Action = 3
	AND     e.ProjectKey = @ProjectKey -- could be a tLead estimate, OK to delete

	UPDATE	#tTask
	SET		#tTask.Action = 4
	FROM	tEstimateTaskExpense ete (NOLOCK)
		   ,tEstimate e (NOLOCK)  
	WHERE	#tTask.TaskKey = ete.TaskKey
	AND     ete.EstimateKey = e.EstimateKey
	AND     ((isnull(e.ExternalApprover, 0) > 0 and e.ExternalStatus = 4) 
			Or (isnull(e.ExternalApprover, 0) = 0 and  e.InternalStatus = 4)) 
	AND     #tTask.Action = 3
	AND     e.ProjectKey = @ProjectKey -- could be a tLead estimate, OK to delete
				
	-- Abort if we cannot delete
	IF EXISTS (SELECT 1 FROM #tTask Where Action = 4)
		RETURN -3

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''A: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	--Remove Tasks that point to invalid SummaryTaskKeys
	--If we are saving using the new DM process then @ValidatePreds will not be 1. 
	--This will prevent us from validating parents here, as not all tasks are in the temp table anymore
	IF @ValidatePreds = 1
		UPDATE	#tTask
		SET		Action = 3
		WHERE	SummaryTaskKey > 0
		AND		SummaryTaskKey NOT IN (SELECT TaskKey FROM #tTask)
	                          
	DECLARE @TaskKey INT
	       ,@NewTaskKey INT
	       ,@Error INT
		   ,@Rowcount INT
	       ,@Active INT
		   ,@FromTaskKey int
	       ,@RecalcEstimate int
		   ,@RequireTasks int
		   ,@CopyToDos tinyint

	SELECT @Active = IsActive
	FROM tProjectStatus (NOLOCK) 
	WHERE ProjectStatusKey = @ProjectStatusKey

	select	@RequireTasks = pref.RequireTasks
		,@CopyToDos = ISNULL(CopyToDos, 1)
	from tPreference pref (nolock)
	inner join tProject p (nolock) on p.CompanyKey = pref.CompanyKey 
	where p.ProjectKey = @ProjectKey 

	--Make sure the TaskKey and PredecessorKey are still valid tasks (especially with cross-project preds) to 
	--avoid foreign key constraint errors

	--ValidKeys values:
	-- 1: Valid TaskKey
	-- 2: Valid TaskKey & PredecessorKey
	UPDATE	#tTaskPredecessor
	SET		ValidKeys = 1 --Valid TaskKey
	FROM	tTask t (nolock)
	WHERE	#tTaskPredecessor.TaskKey = t.TaskKey
	AND		#tTaskPredecessor.Action IN (1, 2) --Inserts and Updates only

	UPDATE	#tTaskPredecessor
	SET		ValidKeys = 2 --Valid PredecessorKey
	FROM	tTask t (nolock)
	WHERE	#tTaskPredecessor.TaskKey = t.TaskKey
	AND		#tTaskPredecessor.Action IN (1, 2) --Inserts and Updates only
	AND		#tTaskPredecessor.ValidKeys = 1 --Only check if the TaskKey was already validated

	DELETE	#tTaskPredecessor
	WHERE	ValidKeys <> 2 --If the TaskKey & PredecessorKey are not both valid, remove the predecessor from the temp table
	AND		Action IN (1, 2)

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''B: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	/*
	 * tTask Inserts
	 */

	BEGIN TRAN

	SELECT	*
	INTO	#InsertedTasks
	FROM	#NewKeys
	WHERE	1=2

	INSERT	tTask
			(
			ProjectKey,
			TaskID,
			TaskName,
			Description,
			TaskType,
			SummaryTaskKey,
			BudgetTaskKey,
			HourlyRate,
			Markup,
			IOCommission,
			BCCommission,
			ShowDescOnEst,
			ServiceKey,
			Taxable,
			Taxable2,
			WorkTypeKey,
			BaseStart,
			BaseComplete,
			PlanStart,
			PlanComplete,
			PlanDuration,
			ActStart,
			ActComplete,
			PercComp,
			TaskConstraint,
			Comments,
			ScheduleTask,
			TrackBudget,
			MoneyTask,
			HideFromClient,
			AllowAnyone,
			MasterTaskKey,
			ConstraintDate,
			WorkAnyDay,
			PercCompSeparate,
			ProjectOrder,
			DisplayOrder,
			TaskLevel,
			TaskAssignmentTypeKey,
			TaskPriorityKey,
			ShowOnCalendar,
			EventStart,
			EventEnd,
			TimeZoneIndex,
			DueBy,
			ReviewedByTraffic,
			ReviewedByDate,
			ReviewedByKey,
			PredecessorsComplete,
			TaskStatus,
			ScheduleNote,
			CompletedByDate,
			CompletedByKey,
			TimelineSegmentKey,
			ConstraintDayOfTheWeek,
			ExcludeFromStatus,
			TimelineSegmentDisplayName,
			AllowAllocatedHours,
			TCProjectStatusKey,
			HideFromDeliverable,
			MustFinishOnPredComplete,
			InsertTempKey,
			RecurringFreq,
			RecurringMax,
			RecurringParentKey,
			RecurringOrder,
			OrigRecurringStart,
			ModifiedOccurrence,
			RecurringSetPos,
			RecurringWeekday
			)
	OUTPUT ''tTask'', INSERTED.InsertTempKey, INSERTED.TaskKey
	INTO	#InsertedTasks
	SELECT	ProjectKey,
			TaskID,
			TaskName,
			Description,
			TaskType,
			SummaryTaskKey,
			BudgetTaskKey,
			HourlyRate,
			Markup,
			IOCommission,
			BCCommission,
			ShowDescOnEst,
			ServiceKey,
			Taxable,
			Taxable2,
			WorkTypeKey,
			BaseStart,
			BaseComplete,
			dbo.fFormatDateNoTime(PlanStart),
			dbo.fFormatDateNoTime(PlanComplete),
			PlanDuration,
			ActStart,
			ActComplete,
			ISNULL(PercComp, 0),
			TaskConstraint,
			Comments,
			ScheduleTask,
			TrackBudget,
			MoneyTask,
			HideFromClient,
			AllowAnyone,
			MasterTaskKey,
			ConstraintDate,
			WorkAnyDay,
			PercCompSeparate,
			ProjectOrder,
			DisplayOrder,
			TaskLevel,
			TaskAssignmentTypeKey,
			TaskPriorityKey,
			ShowOnCalendar,
			EventStart,
			EventEnd,
			TimeZoneIndex,
			DueBy,
			ReviewedByTraffic,
			ReviewedByDate,
			ReviewedByKey,
			PredecessorsComplete,
			TaskStatus,
			ScheduleNote,
			CompletedByDate,
			CompletedByKey,
			TimelineSegmentKey,
			ConstraintDayOfTheWeek,
			ExcludeFromStatus,
			TimelineSegmentDisplayName,
			AllowAllocatedHours,
			TCProjectStatusKey,
			HideFromDeliverable,
			MustFinishOnPredComplete,
			TaskKey,
			RecurringFreq,
			RecurringMax,
			RecurringParentKey,
			ISNULL(RecurringOrder, 1),
			OrigRecurringStart,
			ModifiedOccurrence,
			RecurringSetPos,
			RecurringWeekday
	FROM	#tTask
	WHERE	Action = 1 --Insert

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''C: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
		
	UPDATE	#tTask 
	SET		NewTaskKey = it.NewKey
	FROM	#InsertedTasks it
	WHERE	#tTask.TaskKey = it.OldKey

	IF @CopyToDos = 1
		INSERT	#CopyToDos 
				(FromTaskKey, NewTaskKey)
		SELECT	t.FromTaskKey, it.NewKey
		FROM	#tTask t
		INNER JOIN #InsertedTasks it ON t.TaskKey = it.OldKey
		WHERE	ISNULL(t.FromTaskKey, 0) > 0
		        		       
	/*
	 * tTask Updates
	 */
	
	UPDATE  tTask
	SET tTask.TaskID = #tTask.TaskID,
			tTask.TaskName = #tTask.TaskName,
			tTask.Description = #tTask.Description,
			tTask.TaskType = #tTask.TaskType,
			tTask.SummaryTaskKey = #tTask.SummaryTaskKey,
			tTask.BudgetTaskKey = #tTask.BudgetTaskKey,
			tTask.HourlyRate = #tTask.HourlyRate,
			tTask.Markup = #tTask.Markup,
			tTask.IOCommission = #tTask.IOCommission,
			tTask.BCCommission = #tTask.BCCommission,
			tTask.ShowDescOnEst = #tTask.ShowDescOnEst,
			tTask.ServiceKey = #tTask.ServiceKey,
			tTask.Taxable = #tTask.Taxable,
			tTask.Taxable2 = #tTask.Taxable2,
			tTask.WorkTypeKey = #tTask.WorkTypeKey,
			tTask.BaseStart = #tTask.BaseStart,
			tTask.BaseComplete = #tTask.BaseComplete,
			tTask.PlanStart = dbo.fFormatDateNoTime(#tTask.PlanStart),
			tTask.PlanComplete = dbo.fFormatDateNoTime(#tTask.PlanComplete), 
			tTask.PlanDuration = #tTask.PlanDuration,
			--tTask.ActStart = #tTask.ActStart,
			--tTask.ActComplete = #tTask.ActComplete,
			--tTask.PercComp = ISNULL(#tTask.PercComp, 0),
			tTask.TaskConstraint = #tTask.TaskConstraint,
			tTask.Comments = #tTask.Comments,
			tTask.ScheduleTask = #tTask.ScheduleTask,
			tTask.TrackBudget = #tTask.TrackBudget ,
			tTask.MoneyTask = #tTask.MoneyTask,
			tTask.HideFromClient = #tTask.HideFromClient,
			tTask.AllowAnyone = #tTask.AllowAnyone,
			tTask.MasterTaskKey = #tTask.MasterTaskKey,
			tTask.ConstraintDate = #tTask.ConstraintDate,
			tTask.WorkAnyDay = #tTask.WorkAnyDay,
			tTask.PercCompSeparate = #tTask.PercCompSeparate,
			tTask.ProjectOrder = #tTask.ProjectOrder,
			tTask.DisplayOrder = #tTask.DisplayOrder,
			tTask.TaskLevel = #tTask.TaskLevel,
			tTask.TaskAssignmentTypeKey = #tTask.TaskAssignmentTypeKey,
			tTask.TaskPriorityKey = #tTask.TaskPriorityKey,
			tTask.ShowOnCalendar = #tTask.ShowOnCalendar,
			tTask.EventStart = #tTask.EventStart,
			tTask.EventEnd = #tTask.EventEnd,
			tTask.TimeZoneIndex = #tTask.TimeZoneIndex,
			tTask.DueBy = #tTask.DueBy,
			tTask.ReviewedByTraffic = #tTask.ReviewedByTraffic,
			tTask.ReviewedByDate = #tTask.ReviewedByDate,
			tTask.ReviewedByKey = #tTask.ReviewedByKey,
			tTask.PredecessorsComplete = #tTask.PredecessorsComplete,
			tTask.TaskStatus = #tTask.TaskStatus,
			tTask.ScheduleNote = #tTask.ScheduleNote,
			tTask.CompletedByDate = #tTask.CompletedByDate,
			tTask.CompletedByKey = #tTask.CompletedByKey,
			tTask.TimelineSegmentKey = ISNULL(#tTask.TimelineSegmentKey, tTask.TimelineSegmentKey), --Temp table could be null from CMP90, then keep existing value
			tTask.ConstraintDayOfTheWeek = #tTask.ConstraintDayOfTheWeek,
			tTask.ExcludeFromStatus = #tTask.ExcludeFromStatus,
			tTask.TimelineSegmentDisplayName = #tTask.TimelineSegmentDisplayName,
			tTask.AllowAllocatedHours = #tTask.AllowAllocatedHours,
			tTask.TCProjectStatusKey = 
				CASE 
					WHEN #tTask.TCProjectStatusKey = -1 THEN tTask.TCProjectStatusKey --If the value in the temp table is -1, then keep the existing value
					ELSE #tTask.TCProjectStatusKey
				END,
		    tTask.HideFromDeliverable = #tTask.HideFromDeliverable,
			tTask.AvalaraTaxCodeKey = #tTask.AvalaraTaxCodeKey,
			tTask.NoTimeEntry = #tTask.NoTimeEntry,
			tTask.MustFinishOnPredComplete = #tTask.MustFinishOnPredComplete,
			tTask.RecurringFreq = #tTask.RecurringFreq,
			tTask.RecurringMax = #tTask.RecurringMax,
			tTask.RecurringParentKey = #tTask.RecurringParentKey,
			tTask.RecurringOrder = ISNULL(#tTask.RecurringOrder, 1),
			tTask.OrigRecurringStart = #tTask.OrigRecurringStart,
			tTask.ModifiedOccurrence = #tTask.ModifiedOccurrence,
			tTask.RecurringSetPos = #tTask.RecurringSetPos,
			tTask.RecurringWeekday = #tTask.RecurringWeekday
	FROM    #tTask
	WHERE   tTask.TaskKey = #tTask.TaskKey
	AND     tTask.ProjectKey = @ProjectKey
	AND     #tTask.Action = 2
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''D: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	UPDATE	tTask
	SET		tTask.ProjectOrder = #tTask.ProjectOrder,
			tTask.DisplayOrder = #tTask.DisplayOrder,
			tTask.TaskID = #tTask.TaskID
	FROM    #tTask
	WHERE   tTask.TaskKey = #tTask.TaskKey
	AND     tTask.ProjectKey = @ProjectKey
	AND     #tTask.Action = 99 --Only update ProjectOrder, DisplayOrder, TaskID

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''D2: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	UPDATE	tTask
	SET		tTask.PercComp = ISNULL(#tTask.PercComp, 0)
	FROM    #tTask
	WHERE   tTask.TaskKey = #tTask.TaskKey
	AND     tTask.ProjectKey = @ProjectKey
	AND     #tTask.Action = 2
	AND		((ISNULL(#tTask.PercComp, 0) <> ISNULL(#tTask.OrigPercComp, 0)) OR @Platinum <> 1)

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	UPDATE	tTask
	SET		tTask.ActStart = #tTask.ActStart
	FROM    #tTask
	WHERE   tTask.TaskKey = #tTask.TaskKey
	AND     tTask.ProjectKey = @ProjectKey
	AND     #tTask.Action = 2
	AND		((#tTask.ActStart IS NULL AND #tTask.OrigActStart IS NOT NULL)
			OR (#tTask.ActStart IS NOT NULL AND #tTask.OrigActStart IS NULL)
			OR (#tTask.ActStart <> #tTask.OrigActStart)
			OR (@Platinum <> 1))

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	UPDATE	tTask
	SET		tTask.ActComplete = #tTask.ActComplete
	FROM    #tTask
	WHERE   tTask.TaskKey = #tTask.TaskKey
	AND     tTask.ProjectKey = @ProjectKey
	AND     #tTask.Action = 2
	AND		((#tTask.ActComplete IS NULL AND #tTask.OrigActComplete IS NOT NULL)
			OR (#tTask.ActComplete IS NOT NULL AND #tTask.OrigActComplete IS NULL)
			OR (#tTask.ActComplete <> #tTask.OrigActComplete)
			OR (@Platinum <> 1))

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

					
	-- Now update the summary and budget tasks			
	UPDATE tTask
	SET    tTask.SummaryTaskKey = #tTask.NewTaskKey
	FROM   #tTask
	WHERE  tTask.SummaryTaskKey = #tTask.TaskKey
	AND    tTask.ProjectKey = @ProjectKey
	AND    tTask.SummaryTaskKey < 0
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	UPDATE tTask
	SET    tTask.BudgetTaskKey = #tTask.NewTaskKey
	FROM   #tTask
	WHERE  tTask.BudgetTaskKey = #tTask.TaskKey
	AND    tTask.ProjectKey = @ProjectKey
	AND    tTask.BudgetTaskKey < 0
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''E: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
	
	-- Also save new keys in #tTaskPredecessor 
	UPDATE #tTaskPredecessor
	SET    #tTaskPredecessor.TaskKey = #tTask.NewTaskKey
	FROM   #tTask
	WHERE  #tTaskPredecessor.TaskKey = #tTask.TaskKey
	AND #tTaskPredecessor.TaskKey < 0
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	UPDATE #tTaskPredecessor
	SET    #tTaskPredecessor.PredecessorKey = #tTask.NewTaskKey
	FROM   #tTask
	WHERE  #tTaskPredecessor.PredecessorKey = #tTask.TaskKey
	AND    #tTaskPredecessor.PredecessorKey < 0
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	-- Save new keys in #tTaskUser 
	UPDATE #tTaskUser
	SET    #tTaskUser.TaskKey = #tTask.NewTaskKey
	FROM   #tTask
	WHERE  #tTaskUser.TaskKey = #tTask.TaskKey
	AND    #tTaskUser.TaskKey < 0
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	/*
	 * tTask Deletes
	 */

	--Add Recurring children to be deleted
	INSERT	#tTask (TaskKey, Action)
	SELECT	t.TaskKey, 3
	FROM	tTask t (nolock)
	INNER JOIN #tTask tmp ON t.RecurringParentKey = tmp.TaskKey AND t.TaskKey <> tmp.TaskKey
	WHERE	tmp.Action = 3
	
	DELETE	tTaskUserHour
	FROM	tTaskUserHour tuh
	INNER JOIN tTaskUser tu ON tuh.TaskUserKey = tu.TaskUserKey
	INNER JOIN #tTask t ON tu.TaskKey = t.TaskKey
	WHERE	t.Action = 3

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
		 
	-- Same order than in sptTaskDelete for deadlocks
	-- However we updated tTask first!!!! The order is different
	delete tTaskUser
	from   #tTask 
	where  tTaskUser.TaskKey = #tTask.TaskKey
	and    #tTask.Action = 3
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	-- We should update the tasks on tTaskPredecessor before deleting
	UPDATE  tTaskPredecessor
	SET		tTaskPredecessor.TaskKey = #tTaskPredecessor.TaskKey
			,tTaskPredecessor.PredecessorKey = #tTaskPredecessor.PredecessorKey
			,tTaskPredecessor.Lag = #tTaskPredecessor.Lag
			,tTaskPredecessor.InWeeks = #tTaskPredecessor.InWeeks
	FROM    #tTaskPredecessor  		
	WHERE   tTaskPredecessor.TaskPredecessorKey = #tTaskPredecessor.TaskPredecessorKey  		
	AND		Action = 2
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	delete tTaskPredecessor
	from   #tTask 
	where  tTaskPredecessor.TaskKey = #tTask.TaskKey
	and    #tTask.Action = 3
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	delete tTaskPredecessor
	from   #tTask 
	where  tTaskPredecessor.PredecessorKey = #tTask.TaskKey
	and    #tTask.Action = 3

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''F: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
			
	if isnull(@RequireTasks, 0) = 1
	begin
		-- tasks are required on expenses
		delete tEstimateTaskExpense
		from   #tTask 
		where  tEstimateTaskExpense.TaskKey = #tTask.TaskKey
		and    #tTask.Action = 3
	
		select @Error = @@ERROR, @Rowcount = @@ROWCOUNT

		If @Rowcount > 0
			select @RecalcEstimate = 1

		IF @Error <> 0
		BEGIN
			ROLLBACK TRAN
			RETURN -99
		END
	end
	else
	begin
		-- tasks are not required on expenses
		update tEstimateTaskExpense
		set    tEstimateTaskExpense.TaskKey = null
		from   #tTask 
		where  tEstimateTaskExpense.TaskKey = #tTask.TaskKey
		and    #tTask.Action = 3

		IF @@ERROR <> 0
		BEGIN
			ROLLBACK TRAN
			RETURN -99
		END
	end

	delete tEstimateTaskLabor
	from   #tTask 
	where  tEstimateTaskLabor.TaskKey = #tTask.TaskKey
	and    #tTask.Action = 3
	
	select @Error = @@ERROR, @Rowcount = @@ROWCOUNT

	If @Rowcount > 0
		select @RecalcEstimate = 1

	IF @Error <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	delete tEstimateTaskLaborTitle
	from   #tTask 
	where  tEstimateTaskLaborTitle.TaskKey = #tTask.TaskKey
	and    #tTask.Action = 3
		
	delete tEstimateTaskLaborLevel
	from   #tTask 
	where  tEstimateTaskLaborLevel.TaskKey = #tTask.TaskKey
	and    #tTask.Action = 3

	delete tEstimateTaskAssignmentLabor
	from   #tTask 
	where  tEstimateTaskAssignmentLabor.TaskKey = #tTask.TaskKey
	and    #tTask.Action = 3
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
	
	delete tEstimateTask
	from   #tTask 
	where  tEstimateTask.TaskKey = #tTask.TaskKey
	and    #tTask.Action = 3
	
	select @Error = @@ERROR, @Rowcount = @@ROWCOUNT

	If @Rowcount > 0
		select @RecalcEstimate = 1

	IF @Error <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''G: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	-- Log Tasks being deleted from the Schedule
	DECLARE @CompanyKey int, @ProjectNumber VARCHAR(100), @Now as datetime, @Comments varchar(4000), @ActionBy nvarchar(500)

	SELECT @ProjectNumber = ProjectNumber, @CompanyKey = CompanyKey from tProject (nolock) where ProjectKey = @ProjectKey
	SELECT @Now = GETUTCDATE()
	
	IF ISNULL(@UserKey,0) > 0
		SELECT @ActionBy = UserName FROM vUserName WHERE UserKey = @UserKey

	INSERT	tActionLog
			(
			Entity,
			EntityKey,
			CompanyKey,
			ProjectKey,
			Action,
			ActionDate,
			ActionBy,
			Comments,
			Reference,
			SourceCompanyID,
			UserKey
			)
	SELECT	''Project'', 
			tmp.TaskKey, 
			@CompanyKey, 
			@ProjectKey, 
			''Task Deleted'',
			@Now,
			@ActionBy,
			''Task '' + ISNULL(t.TaskID, '''') + '' - '' + ISNULL(t.TaskName, '''') + '' was deleted'',
			@ProjectNumber,
			NULL,
			@UserKey
	FROM	#tTask tmp
	INNER JOIN tTask t (nolock) ON tmp.TaskKey = t.TaskKey
	WHERE	Action = 3 --Delete
	

	-- Delete the tasks			
	DELETE tTask 
	FROM   #tTask
	WHERE  tTask.TaskKey = #tTask.TaskKey
	AND    tTask.ProjectKey = @ProjectKey
	AND    #tTask.Action = 3
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''H: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	
	/*
	 * tTaskUser 
	 */

	DELETE	tTaskUserHour
	FROM	tTaskUserHour tuh
	INNER JOIN #tTaskUser tu ON tuh.TaskUserKey = tu.TaskUserKey
	WHERE	tu.Action = 3

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END
		
	DELETE  tTaskUser
	FROM    #tTaskUser  		
	WHERE   tTaskUser.TaskUserKey = #tTaskUser.TaskUserKey  		
	AND     Action = 3

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''I: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()


	--Call SP to reassign ToDo items	
	EXEC spScheduleSaveReassignToDo

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''J: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	--If this is not a Platinum save, populate the Platinum specific field values in the temp table with the existing values so that
	--they''re not lost when Flash saves.
	IF @Platinum <> 1
		UPDATE	#tTaskUser
		SET		#tTaskUser.APlanStart = tTaskUser.APlanStart,
				#tTaskUser.APlanComplete = tTaskUser.APlanComplete,
				#tTaskUser.ADescription = tTaskUser.ADescription,
				#tTaskUser.ManualAdjustment = ISNULL(tTaskUser.ManualAdjustment, 0),
				#tTaskUser.PercAssigned = tTaskUser.PercAssigned
		FROM	tTaskUser
		WHERE	tTaskUser.TaskUserKey = #tTaskUser.TaskUserKey		
		AND		Action = 2

	-- (728544) Treat 0 as NULL (unassigned) so the default TaskUserStatus can be applied.
	UPDATE  #tTaskUser
	SET     TaskUserStatusKey = NULL
	WHERE   ISNULL(TaskUserStatusKey, 0) = 0

	UPDATE tTaskUser
	SET		tTaskUser.UserKey = #tTaskUser.UserKey,
			tTaskUser.Hours = #tTaskUser.Hours,
			--tTaskUser.PercComp = #tTaskUser.PercComp,
			--tTaskUser.ActStart = #tTaskUser.ActStart,
			--tTaskUser.ActComplete = #tTaskUser.ActComplete,
			tTaskUser.ReviewedByTraffic = #tTaskUser.ReviewedByTraffic,
			tTaskUser.ReviewedByDate = #tTaskUser.ReviewedByDate,
			tTaskUser.ReviewedByKey = #tTaskUser.ReviewedByKey,
			tTaskUser.CompletedByDate = #tTaskUser.CompletedByDate,
			tTaskUser.CompletedByKey = #tTaskUser.CompletedByKey,
			tTaskUser.ServiceKey = #tTaskUser.ServiceKey,
			tTaskUser.Subject = #tTaskUser.Subject,
			tTaskUser.Description = #tTaskUser.Description,
			tTaskUser.Comments = #tTaskUser.Comments,
			tTaskUser.DeliverableKey = #tTaskUser.DeliverableKey,
			tTaskUser.APlanStart = #tTaskUser.APlanStart,
			tTaskUser.APlanComplete = #tTaskUser.APlanComplete,
			tTaskUser.ADescription = #tTaskUser.ADescription,
			tTaskUser.ManualAdjustment = ISNULL(#tTaskUser.ManualAdjustment, 0),
			tTaskUser.PercAssigned = #tTaskUser.PercAssigned,
			tTaskUser.TaskUserStatusKey = #tTaskUser.TaskUserStatusKey
	FROM	#tTaskUser
	WHERE	tTaskUser.TaskUserKey = #tTaskUser.TaskUserKey		
	AND		Action = 2
	
	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	UPDATE	tTaskUser
	SET		tTaskUser.PercComp = ISNULL(#tTaskUser.PercComp, 0)
	FROM    #tTaskUser
	WHERE   tTaskUser.TaskUserKey = #tTaskUser.TaskUserKey
	AND     #tTaskUser.Action = 2
	AND		((ISNULL(#tTaskUser.PercComp, 0) <> ISNULL(#tTaskUser.OrigPercComp, 0)) OR @Platinum <> 1)

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	UPDATE	tTaskUser
	SET		tTaskUser.ActStart = #tTaskUser.ActStart
	FROM    #tTaskUser
	WHERE   tTaskUser.TaskUserKey = #tTaskUser.TaskUserKey
	AND     #tTaskUser.Action = 2
	AND		((#tTaskUser.ActStart IS NULL AND #tTaskUser.OrigActStart IS NOT NULL)
			OR (#tTaskUser.ActStart IS NOT NULL AND #tTaskUser.OrigActStart IS NULL)
			OR (#tTaskUser.ActStart <> #tTaskUser.OrigActStart)
			OR (@Platinum <> 1))

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	UPDATE	tTaskUser
	SET		tTaskUser.ActComplete = #tTaskUser.ActComplete
	FROM    #tTaskUser
	WHERE   tTaskUser.TaskUserKey = #tTaskUser.TaskUserKey
	AND     #tTaskUser.Action = 2
	AND		((#tTaskUser.ActComplete IS NULL AND #tTaskUser.OrigActComplete IS NOT NULL)
			OR (#tTaskUser.ActComplete IS NOT NULL AND #tTaskUser.OrigActComplete IS NULL)
			OR (#tTaskUser.ActComplete <> #tTaskUser.OrigActComplete)
			OR (@Platinum <> 1))

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END	
	
	UPDATE	tTaskUser
	SET		tTaskUser.ADescriptionLastModified = GETUTCDATE()
	FROM    #tTaskUser
	WHERE   tTaskUser.TaskUserKey = #tTaskUser.TaskUserKey
	AND     #tTaskUser.Action = 2
	AND		ISNULL(#tTaskUser.ADescription, '''') <> ISNULL(#tTaskUser.OrigADescription, '''')

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END		

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''K: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	INSERT tTaskUser
			(
			UserKey,
			TaskKey,
			Hours,
			PercComp,
			ActStart,
			ActComplete,
			ReviewedByTraffic,
			ReviewedByDate,
			ReviewedByKey,
			CompletedByDate,
			CompletedByKey,
			ServiceKey,
			Subject,
			Description,
			Comments,
			DeliverableKey,
			APlanStart,
			APlanComplete,
			ADescription,
			ADescriptionLastModified,
			ManualAdjustment,
			PercAssigned,
			TaskUserStatusKey,
			InsertTempKey
			)
	OUTPUT ''tTaskUser'', INSERTED.InsertTempKey, INSERTED.TaskUserKey
	INTO	#InsertedTasks
	SELECT
			UserKey,
			TaskKey,
			Hours,
			PercComp,
			ActStart,
			ActComplete,
			ReviewedByTraffic,
			ReviewedByDate,
			ReviewedByKey,
			CompletedByDate,
			CompletedByKey,
			ServiceKey,
			Subject,
			Description,
			Comments,
			DeliverableKey,
			APlanStart,
			APlanComplete,
			ADescription,
			GETUTCDATE(),
			ISNULL(ManualAdjustment, 0),
			PercAssigned,
			TaskUserStatusKey,
			TaskUserKey
	FROM	#tTaskUser
	WHERE	TaskUserKey <= 0
	AND		Action = 1

	INSERT	#NewKeys
	SELECT	*
	FROM	#InsertedTasks

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''L: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	/*
	 * tTaskPredecessor 
	 */		

	DELETE  tTaskPredecessor
	FROM    #tTaskPredecessor  		
	WHERE   tTaskPredecessor.TaskPredecessorKey = #tTaskPredecessor.TaskPredecessorKey  		
	AND     Action = 3

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @ValidatePreds = 1
	BEGIN
		DELETE  tTaskPredecessor
			FROM tTask (NOLOCK)
		WHERE   tTaskPredecessor.TaskKey = tTask.TaskKey
		AND     tTask.ProjectKey = @ProjectKey
		AND     tTaskPredecessor.TaskPredecessorKey NOT IN (SELECT TaskPredecessorKey FROM #tTaskPredecessor)

		IF @@ERROR <> 0
		BEGIN
			ROLLBACK TRAN
			RETURN -99
		END
	END

	--Prevent duplicate inserts
	DELETE	#tTaskPredecessor
	FROM	tTaskPredecessor
	WHERE	#tTaskPredecessor.TaskKey = tTaskPredecessor.TaskKey
	AND		#tTaskPredecessor.PredecessorKey = tTaskPredecessor.PredecessorKey
	AND		#tTaskPredecessor.Action = 1
	
	INSERT  tTaskPredecessor (TaskKey, PredecessorKey, Type, Lag, InWeeks)
	SELECT  #tTaskPredecessor.TaskKey
			,#tTaskPredecessor.PredecessorKey
			,#tTaskPredecessor.Type
			,#tTaskPredecessor.Lag
			,#tTaskPredecessor.InWeeks
	FROM    #tTaskPredecessor  		
	WHERE   Action = 1

	IF @@ERROR <> 0
	BEGIN
		ROLLBACK TRAN
		RETURN -99
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''M: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	-- For returns to Flash
	INSERT #NewKeys (Entity, OldKey, NewKey)
	SELECT ''tTaskPredecessor'', TaskPredecessorKey, NULL
	FROM   #tTaskPredecessor
	WHERE  Action = 1
	
	UPDATE #NewKeys
	SET    #NewKeys.NewKey = b.TaskPredecessorKey 
	FROM   #tTaskPredecessor a
	       ,tTaskPredecessor b (NOLOCK)  
	WHERE  a.TaskPredecessorKey = #NewKeys.OldKey
	AND    a.TaskKey = b.TaskKey
	AND    a.PredecessorKey = b.PredecessorKey
	AND    #NewKeys.Entity = ''tTaskPredecessor''
	
	COMMIT TRAN

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''N: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

		 
	-- fix for issues where project status
	UPDATE tProject 
	SET TaskStatus = ISNULL((SELECT MAX(tTask.TaskStatus) 
	FROM tTask (NOLOCK) 
	WHERE tTask.ProjectKey = tProject.ProjectKey
	AND tTask.PercComp < 100
	AND tTask.ScheduleTask = 1
	AND tTask.TaskType = 2), 1)
	WHERE tProject.ProjectKey = @ProjectKey

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''O: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
				
	/*
	 * tAssignment
	 * Did not put any SQL Transaction since the original code does not have any 
	 */		

	 --Inserts and Deletes only, do not process Updates
	IF @tasksFromTemplate = 0
	BEGIN	
		DELETE tProjectUserServices
		FROM   #tAssignment
		WHERE  tProjectUserServices.ProjectKey = @ProjectKey
		AND    tProjectUserServices.UserKey = #tAssignment.UserKey
		AND    #tAssignment.Action = 3
	END
	ELSE 
	BEGIN
		DELETE tProjectUserServices
		FROM   #tProjectUserServices
		WHERE  tProjectUserServices.ProjectKey = @ProjectKey
		AND    tProjectUserServices.UserKey = #tProjectUserServices.UserKey
		AND	   #tProjectUserServices.ServiceKey <> 0
	END
			
	-- Deletes
	DELETE tAssignment
	FROM   #tAssignment
	WHERE  tAssignment.ProjectKey = @ProjectKey 
	AND    tAssignment.UserKey = #tAssignment.UserKey
	AND    #tAssignment.Action = 3	

	-- Before inserting, check if already there
	UPDATE #tAssignment
	SET    #tAssignment.Action = 4 -- do not process later
	FROM   tAssignment (NOLOCK)
	WHERE  tAssignment.ProjectKey = @ProjectKey 
	AND    tAssignment.UserKey = #tAssignment.UserKey 
	
	INSERT tAssignment(ProjectKey,UserKey, HourlyRate, SubscribeDiary, SubscribeToDo, DeliverableReviewer, DeliverableNotify)
	SELECT DISTINCT @ProjectKey, u.UserKey, ISNULL(u.HourlyRate, 0), ISNULL(u.SubscribeDiary, 0), ISNULL(u.SubscribeToDo, 0), ISNULL(u.DeliverableReviewer, 0), ISNULL(u.DeliverableNotify, 0)
	FROM   #tAssignment
	INNER JOIN tUser u (nolock) on #tAssignment.UserKey = u.UserKey
	WHERE  #tAssignment.Action = 1

	-- protection against duplicates
	DELETE tAssignment
	WHERE  tAssignment.ProjectKey = @ProjectKey
	AND    tAssignment.AssignmentKey > (SELECT MIN(a2.AssignmentKey) FROM tAssignment a2 (NOLOCK)
							WHERE  a2.ProjectKey = @ProjectKey
							AND    a2.UserKey = tAssignment.UserKey)
		
	-- protection against missing users (Bug 8250)
	-- not sure why, but it happened at Media Logic
	INSERT tAssignment (ProjectKey, UserKey, HourlyRate, SubscribeDiary, SubscribeToDo, DeliverableReviewer, DeliverableNotify)
	SELECT DISTINCT @ProjectKey, tu.UserKey, u.HourlyRate, ISNULL(u.SubscribeDiary, 0), ISNULL(u.SubscribeToDo, 0), ISNULL(u.DeliverableReviewer, 0), ISNULL(u.DeliverableNotify, 0)
	FROM   tTaskUser tu (NOLOCK)
		INNER JOIN tTask t (NOLOCK) ON tu.TaskKey = t.TaskKey
		INNER JOIN tUser u (NOLOCK) ON tu.UserKey = u.UserKey
	WHERE t.ProjectKey = @ProjectKey
	AND   tu.UserKey NOT IN (SELECT UserKey FROM tAssignment (NOLOCK) WHERE ProjectKey = @ProjectKey)

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''P: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
			
	-- For returns to Flash
	INSERT #NewKeys (Entity, OldKey, NewKey)
	SELECT ''tAssignment'', AssignmentKey, AssignmentKey
	FROM   #tAssignment
	WHERE  Action = 1
	
	UPDATE #NewKeys
	SET    #NewKeys.NewKey = b.AssignmentKey 
	FROM   #tAssignment a
	       ,tAssignment b (NOLOCK)  
	WHERE  a.AssignmentKey = #NewKeys.OldKey
	AND    b.ProjectKey = @ProjectKey
	AND    a.UserKey = b.UserKey
	AND    #NewKeys.Entity = ''tAssignment''
	
	IF @tasksFromTemplate = 0
	BEGIN
		Insert tProjectUserServices (ProjectKey, UserKey, ServiceKey)
		Select @ProjectKey, u.UserKey, u.DefaultServiceKey
		from   tUser u (nolock)
		 ,#tAssignment b
		Where  b.UserKey = u.UserKey
		And    b.Action = 1
		And    u.DefaultServiceKey IS NOT NULL
	END
	ELSE
	BEGIN
		Insert tProjectUserServices (ProjectKey, UserKey, ServiceKey)
		Select Distinct @ProjectKey, UserKey, ServiceKey
		from   #tProjectUserServices 
		WHERE  ProjectKey = @ProjectKey
		AND	   ServiceKey <> 0
	END

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''Q: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
	
	-- SummaryTaskKey
	UPDATE tTask SET SummaryTaskKey = 0 WHERE ProjectKey = @ProjectKey AND TaskKey = SummaryTaskKey 	

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''R: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	--Fix to ensure that tasks that were copied on the screen and not linked properly are deleted
	DELETE	tTaskUserHour
	FROM	tTaskUserHour tuh
	INNER JOIN tTaskUser tu ON tuh.TaskUserKey = tu.TaskUserKey
	INNER JOIN tTask t ON tu.TaskKey = t.TaskKey
	WHERE	t.ProjectKey = @ProjectKey
	AND		t.SummaryTaskKey < 0

	DELETE	tTaskUser
	FROM	tTaskUser tu
	INNER JOIN tTask t ON tu.TaskKey = t.TaskKey
	WHERE	t.ProjectKey = @ProjectKey
	AND		t.SummaryTaskKey < 0

	DELETE	tTaskPredecessor
	FROM	tTaskPredecessor pred
	INNER JOIN tTask t ON pred.TaskKey = t.TaskKey
	WHERE	t.ProjectKey = @ProjectKey
	AND		t.SummaryTaskKey < 0

	DELETE	tTaskPredecessor
	FROM	tTaskPredecessor pred
	INNER JOIN tTask t ON pred.PredecessorKey = t.TaskKey
	WHERE	t.ProjectKey = @ProjectKey
	AND		t.SummaryTaskKey < 0
	
	DELETE	tTask
	WHERE	ProjectKey = @ProjectKey
	AND		SummaryTaskKey < 0
	-- -------------------------------------------

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''S: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	-- MoneyTask
	
	-- Fix MoneyTask at the level we track budget
	UPDATE tTask
	SET    tTask.MoneyTask = 1
	WHERE  tTask.ProjectKey = @ProjectKey
	AND    tTask.MoneyTask = 0
	AND    tTask.TrackBudget = 1
	
	-- Fix MoneyTask one level higher than the level where we track budget
	UPDATE tTask
	SET    tTask.MoneyTask = 1
	FROM   tTask (NOLOCK)
		   ,tTask track (NOLOCK) 
	WHERE  tTask.ProjectKey = @ProjectKey
	AND    tTask.ProjectKey = track.ProjectKey 
	AND    tTask.TaskKey = track.SummaryTaskKey 
	AND    track.TrackBudget = 1
	AND    tTask.MoneyTask = 0

	-- BudgetTaskKey
	update tTask
	set    tTask.BudgetTaskKey = tTask.SummaryTaskKey
	from   tTask (NOLOCK)
		  ,tTask summary (NOLOCK)
	where  tTask.SummaryTaskKey = summary.TaskKey
	--and    ISNULL(tTask.BudgetTaskKey, 0) = 0  -- for (136576)
	and    summary.TrackBudget = 1
	and    tTask.TrackBudget = 0
	and    tTask.ProjectKey = @ProjectKey
	and    summary.ProjectKey = @ProjectKey
	
	update tTask
	set    tTask.BudgetTaskKey = summary.SummaryTaskKey
	from   tTask (NOLOCK)
		  ,tTask summary (NOLOCK)
		  ,tTask summary2 (NOLOCK)
	where  tTask.SummaryTaskKey = summary.TaskKey
	and    summary.SummaryTaskKey = summary2.TaskKey
	--and    ISNULL(tTask.BudgetTaskKey, 0) = 0 -- for (136576)
	and    summary2.TrackBudget = 1
	and    tTask.TrackBudget = 0
	and    tTask.ProjectKey = @ProjectKey
	and    summary.ProjectKey = @ProjectKey
	and    summary2.ProjectKey = @ProjectKey

	update tTask
	set    tTask.BudgetTaskKey = tTask.TaskKey
	where  tTask.TrackBudget = 1
	and    ISNULL(tTask.BudgetTaskKey, 0) = 0
	and    tTask.ProjectKey = @ProjectKey

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''T: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	-- patch for TaskType
	update tTask
	set    tTask.TaskType = 1 -- summary
	where  tTask.ProjectKey = @ProjectKey
	and    tTask.TaskType = 2 -- tracking
	and    exists (select 1 from tTask t2 (nolock) 
					where t2.ProjectKey = @ProjectKey
					and   t2.SummaryTaskKey = tTask.TaskKey)  
	
	--Make sure that the date parts of EventStart/End match the dates in PlanStart and PlanComplete
	UPDATE	tTask
	SET		EventStart = dbo.fSyncDate(EventStart, PlanStart),
			EventEnd = dbo.fSyncDate(EventEnd, PlanComplete)
	WHERE	ProjectKey = @ProjectKey
	AND		ShowOnCalendar = 1	
	
	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''U: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	   
	-- Re rollup assigned names, allocations
	exec sptProjectRollupSchedule @ProjectKey, @PercComp, @Duration

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''W: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
	
	-- GHL: I placed this outside of the SQL transaction because it takes too long
	-- and this concerns only transferred transactions
	if exists (select 1 from #tTask where TaskKey > 0 and Action = 3)
	begin
		-- At this time, we have established at the top of the sp that all tTime records have been
		-- 1) Transferred
		-- 2) And not in WIP
		-- we can safely delete tTime records without testing TransferToKey
		
		-- Same logic for other transactions
		
		delete tTime
		from   #tTask 
		where  tTime.ProjectKey = @ProjectKey -- Limit to ProjectKey
		and    tTime.TaskKey = #tTask.TaskKey 
		--and    tTime.TransferToKey is not null -- Avoid a costly RID lookup to read TransferToKey
		and    #tTask.Action = 3 -- delete action
		and    #tTask.TaskKey > 0
		
		create table #time(TimeKey uniqueidentifier null)
		
		insert #time (TimeKey)
		select TimeKey
		from   tTime (nolock)
		      ,#tTask 
		where  tTime.ProjectKey = @ProjectKey
		and    tTime.DetailTaskKey = #tTask.TaskKey
		and    #tTask.Action = 3 -- delete action
		and    #tTask.TaskKey > 0
 
		if (select count(*) from #time) > 0
		begin		 
			update tTime
			set    tTime.DetailTaskKey = null
			from   #time
			where  tTime.TimeKey = #time.TimeKey
		end
		
		
		delete tExpenseReceipt
		from   #tTask 
		where  tExpenseReceipt.ProjectKey = @ProjectKey
		and    tExpenseReceipt.TaskKey = #tTask.TaskKey
		--and    tExpenseReceipt.TransferToKey is not null -- was transferred
		and    #tTask.Action = 3 -- delete action
		and    #tTask.TaskKey > 0
		
		
		delete tVoucherDetail
		from   #tTask 
		where  tVoucherDetail.ProjectKey = @ProjectKey
		and    tVoucherDetail.TaskKey = #tTask.TaskKey
		--and    tVoucherDetail.TransferToKey is not null -- was transferred
		and    #tTask.Action = 3 -- delete action
		and    #tTask.TaskKey > 0
		
		delete tPurchaseOrderDetail
		from   #tTask 
		where  tPurchaseOrderDetail.ProjectKey = @ProjectKey
		and    tPurchaseOrderDetail.TaskKey = #tTask.TaskKey
		--and    tPurchaseOrderDetail.TransferToKey is not null -- was transferred
		and    #tTask.Action = 3 -- delete action
		and    #tTask.TaskKey > 0
		
		delete tMiscCost
		from   #tTask 
		where  tMiscCost.ProjectKey = @ProjectKey
		and    tMiscCost.TaskKey = #tTask.TaskKey
		--and    tMiscCost.TransferToKey is not null -- was transferred
		and    #tTask.Action = 3 -- delete action
		and    #tTask.TaskKey > 0
		
	end

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''X: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	declare @EstimateKey int, @ApprovedQty int, @SalesTax1Amount money, @SalesTax2Amount money
	if isnull(@RecalcEstimate, 0) > 0
	begin
		select @EstimateKey = 0

		while (1=1)
		begin
			select @EstimateKey = min(EstimateKey)
			from   tEstimate (nolock)
			where  ProjectKey = @ProjectKey
			and    EstimateKey > @EstimateKey
			-- And not approved
			AND    NOT  ((isnull(ExternalApprover, 0) > 0 and  ExternalStatus = 4) 
						Or (isnull(ExternalApprover, 0) = 0 and  InternalStatus = 4))  

			if @EstimateKey is null
				break

			Select @ApprovedQty = ApprovedQty from tEstimate (nolock) where EstimateKey = @EstimateKey
			Exec sptEstimateRecalcSalesTax @EstimateKey, @ApprovedQty, @SalesTax1Amount OUTPUT, @SalesTax2Amount OUTPUT
			Update tEstimate set SalesTaxAmount = @SalesTax1Amount, SalesTax2Amount = @SalesTax2Amount where EstimateKey = @EstimateKey

			exec sptEstimateTaskRollupDetail @EstimateKey

		end

	end

	IF @saveTiming = 1
		SELECT	@timingMsg = @timingMsg + ''Y: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

	-- Sets hourly rates on assignment records where possible
	Exec sptProjectRollupSetAssignmentRates @ProjectKey

	IF @saveTiming = 1
	BEGIN
		SELECT	@timingMsg = @timingMsg + ''Z: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
	END

	--Update the task assignments for future recurring tasks
	EXEC sptTaskUserUpdateRecurringTasks @ProjectKey

	IF @saveTiming = 1
	BEGIN
		SELECT	@timingMsg = @timingMsg + ''AA: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()
	END

	EXEC spScheduleValidateRecurring @ProjectKey

	IF @saveTiming = 1
	BEGIN
		SELECT	@timingMsg = @timingMsg + ''AB: '' + CAST(DATEDIFF(MILLISECOND, @debugTimeStamp, GETDATE()) as varchar)+ ''; '',
				@debugTimeStamp = GETDATE()

		UPDATE	tProject
		SET		StatusNotes = @timingMsg
		WHERE	ProjectKey = @ProjectKey
	END

	IF EXISTS(SELECT NULL
			FROM	vTaskPredecessorCrossProject
			WHERE	PredProjectKey = @ProjectKey
			AND		CrossProject = 1)
		RETURN 2 --This is a cross project pred
			  						 			
	RETURN 1 --Not a cross project pred


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptRetainerGetAmount]'
GO
IF OBJECT_ID(N'[dbo].[sptRetainerGetAmount]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptRetainerGetAmount]
	(
		@RetainerKey INT
	    ,@InvoiceDate DATETIME
	    ,@RetainerAmount MONEY OUTPUT
	)
AS --Encrypt

  /*
  || When     Who Rel   What
  || 08/15/08 GHL 10.006 And GWG and RB. Corrected @NumberOfPeriodsBilled       
  || 09/15/08 GHL 10.008 (34396) Number of periods billed was incorrect 
  ||                     when users enter fixed fee manually
  || 10/02/08 GHL 10.010 (36622) Basing now decision to bill retainer upon LastBillingDate only 
  ||                     and not the number of invoices per period since Hawse Design keeps on
  ||                     entering fixed fee invoices for the current period
  || 
  ||                     tRetainer.LastBillingDate is set by:
  ||                     1) mass billing: spMassBillingBillRetainer --> spProcessWIPWorksheetRetainer
  ||                     2) billing WS:   spBillingInvoiceBill	    --> spBillingInvoiceRetainer  
  ||                     OR on the retainer detail 
  || 01/02/09 GHL 10.015 (43190) In the case of Yearly frequency, consider LastBillingDate + 1 year
  ||                     instead of LastBillingDate + 1 year then January 1st for that year
  || 08/28/09 GHL 10.5   (60241) Return now -1 when not the time to bill, we allow now for 0 amount
  || 01/22/10 GHL 10.517 (69011) Using now the stored procedure return to determine whether it is
  ||                      time to bill or not since we can now have retainer amounts <0, =0, >0
  ||                      1 -- Can Bill
  ||                      0 -- Cannot Bill
  || 10/06/11 GHL 10.549 (122952) when StartDate = 10/13/2010, EndDate should be 10/13/2011 not 10/1/2011
  ||                     Removed change of 10/13/2011 to 10/1/2011
  || 12/04/17 GHL 10.622  Limit #Periods to 1000 to prevent overflows
  || 03/13/18 GHL 18.4.0 (390830) After 10 years of operation, the logic for NumberOfPeriodsBilled is back
  ||                      Spawn/Nerland has a retainer start date 10/26/17 and # of periods = 4
  ||                      They are able to bill 5 invoices using billing worksheets, invoice dates are
  ||                      10/31/17, 11/20/17, 12/15/17, 1/17/18, 2/22/18
  ||                      The problem is that the first billing should have been on 11/20/17. A possible fix
  ||                      is to calculate the NumberOfPeriodsBilled from invoices linked to billing worksheets
  || 05/08/18 GHL 18.6.0  (400364) When calculating NumberOfPeriodsBilled, make sure that BillFrom = 1  No Transactions
  ||                       if BillFrom = 2 Use Transactions, that means extra expenses/labor
  || 03/13/19 GHL 19.4.0  (436087) Added support for weekly retainer
  || 09/13/19 GHL 19.1.0  (478241) For monthly retainers, they should not show up until they are due
  ||                       Ex: LastBillingDate = 8/15/19, show retainers if date >= 9/15/19 (not date >= 9/1/19)  
  || 10/02/19 GHL 19.1.0  (481941) When calculating NumberOfPeriodsBilled, filter out lines with projects
  ||                       The retainer amount is entered on a line without project. If there is a project, that was entered 
  ||                       manually by the users.
  || 02/22/22 GHL 22.3.0  (585318) Added frequency = twice a year
  || 05/12/22 MFT 22.6.0  (598581) bringing NumberOfPeriodsBilled into alignment with sptRetainerSnapshot and the Retainer edit screen
  || 06/03/22 GHL 22.6.0  (601725) For NumberOfPeriodsBilled put back the i.BillingKey > 0 and ProjectKey > 0
  ||                       because this is changing the way users doing mass billing do business (vs BWS people)
  ||                       and there should not be a project on the line if this is a true retainer billing line
  ||                       The thing that I keep from 598581 is that we should not be taking duplicate invoices
  || 04/02/26 MFT 26.5.0  (665301) Set monthly billing retainer bill date based on the day of the StartDate, not the LastBilledDate
  */
  

	SET NOCOUNT ON
	
	DECLARE @kCAN_BILL INT SELECT @kCAN_BILL = 1
	DECLARE @kCANNOT_BILL INT SELECT @kCANNOT_BILL = 0
	
	DECLARE @CompanyKey INT
			,@NumberOfPeriods INT		-- If 0 means infinite
			,@NumberOfPeriodsBilled INT
			,@Frequency SMALLINT		-- 1: monthly, 2: quaterly, 3: yearly, 4:weekly
			,@LastBillingDate DATETIME
			,@StartDate DATETIME
			,@NextBillingDate DATETIME
			,@NextEndBillingDate DATETIME
			,@EndDate DATETIME -- This will be the final billing date + 1 day. We will abort if @InvoiceDate >= @EndDate
			,@BillDay tinyint
			
		SELECT @CompanyKey = CompanyKey
			   ,@NumberOfPeriods = NumberOfPeriods
			   ,@RetainerAmount = AmountPerPeriod
			   ,@Frequency = Frequency
			   ,@LastBillingDate = LastBillingDate
			   ,@StartDate = StartDate
			   ,@BillDay = DAY(StartDate)
		FROM   tRetainer (NOLOCK) 
		WHERE  RetainerKey = @RetainerKey
			
		-- Abort if the invoice date is before the start	
		IF @InvoiceDate < @StartDate
		begin
			--select 1 as debug
			RETURN @kCANNOT_BILL
		end

		-- Calculate the end date, if number of periods > 0 (number of periods = 0, we allow invoice)
		IF @NumberOfPeriods > 0
		BEGIN
			-- datetime are limited to 12/31/9999
			if @NumberOfPeriods >= 1000
					select @NumberOfPeriods = 1000

			IF @Frequency = 1
			BEGIN
				SELECT @EndDate = DATEADD(m, @NumberOfPeriods, @StartDate) 
				--SELECT @EndDate = CAST(DATEPART(m, @EndDate) AS VARCHAR(2)) + ''/1/''+CAST(DATEPART(yy, @EndDate) AS VARCHAR(4))  
			END
			
			IF @Frequency = 2
			BEGIN
			    SELECT @EndDate = DATEADD(m, 3 * @NumberOfPeriods, @StartDate) -- Add 3 months * # of periods
				SELECT @EndDate = CAST(DATEPART(m, @EndDate) AS VARCHAR(2)) + ''/1/''+CAST(DATEPART(yy, @EndDate) AS VARCHAR(4))  
				
			END
			
			IF @Frequency = 3
			BEGIN
				SELECT @EndDate = DATEADD(yy, @NumberOfPeriods, @StartDate) -- Add 1 year * # of periods
				SELECT @EndDate =  ''1/1/''+CAST(DATEPART(yy, @EndDate) AS VARCHAR(4))  
			END
			
			IF @Frequency = 4
			BEGIN
				SELECT @EndDate = DATEADD(wk, @NumberOfPeriods, @StartDate) 
			END
			
			-- Twice a year =  6 months
			IF @Frequency = 5
			BEGIN
			    SELECT @EndDate = DATEADD(m, 6 * @NumberOfPeriods, @StartDate) -- Add 3 months * # of periods
				SELECT @EndDate = CAST(DATEPART(m, @EndDate) AS VARCHAR(2)) + ''/1/''+CAST(DATEPART(yy, @EndDate) AS VARCHAR(4))  
				
			END

			-- Abort, if the invoice date is after or ON the end date of the last period	
			IF @InvoiceDate >= @EndDate
			begin
				--select 2 as debug
				RETURN @kCANNOT_BILL
			end

			/*
			-- fix for 390830
			SELECT @NumberOfPeriodsBilled = COUNT(il.InvoiceLineKey)
			FROM tInvoiceLine il (NOLOCK)
			INNER JOIN tInvoice i (NOLOCK) ON il.InvoiceKey = i.InvoiceKey
			WHERE il.RetainerKey = @RetainerKey -- there is an index on Retainer
			AND   isnull(il.ProjectKey, 0) = 0 -- the retainer amount should not have a project. If there is a project, that has been entered manually by user
			AND   il.BillFrom = 1  -- must have a invoice line that does NOT use transactions -- fix for 400364
			AND   i.BillingKey > 0 -- must be linked to a EBWS
			*/
			
			--598581, 579419; counting Invoices, not lines; not requiring a BWS; allowing a Project; not allowing AB
			SELECT @NumberOfPeriodsBilled = COUNT(*)
			FROM
				tInvoice i (nolock)
				INNER JOIN (
					SELECT InvoiceKey, RetainerKey
					FROM tInvoiceLine (nolock)
					WHERE	BillFrom = 1 AND RetainerKey = @RetainerKey
					-- put back line below for issue 601725
					AND   isnull(ProjectKey, 0) = 0 -- the retainer amount should not have a project. If there is a project, that has been entered manually by user
					GROUP BY InvoiceKey, RetainerKey
				) il ON i.InvoiceKey = il.InvoiceKey
			WHERE i.AdvanceBill = 0
			AND   i.BillingKey > 0 -- must be linked to a EBWS ... put back for issue 601725

			--select @NumberOfPeriodsBilled as NumberOfPeriodsBilled, @NumberOfPeriods as NumberOfPeriods-
			IF @NumberOfPeriodsBilled > @NumberOfPeriods
			begin
				--select 3 as debug
				RETURN @kCANNOT_BILL
			end
		END

		IF @LastBillingDate IS NOT NULL
		BEGIN
			IF @Frequency = 1
			BEGIN
				SELECT @NextBillingDate = LTRIM(STR(MONTH(@InvoiceDate))) + ''/'' + LTRIM(STR(@BillDay)) + ''/'' + LTRIM(STR(YEAR(@InvoiceDate)))
				IF @LastBillingDate >= @NextBillingDate
					BEGIN
						RETURN @kCANNOT_BILL
					END

				SELECT @NextEndBillingDate = DATEADD(m, 1,@NextBillingDate)
				SELECT @NextEndBillingDate = DATEADD(d, -1,@NextEndBillingDate)
			END
			IF @Frequency = 2
			BEGIN
				-- Add a quarter or 3 months
				SELECT @NextBillingDate = DATEADD(m, 3, @LastBillingDate)
				-- Any invoice date after or on the first of the MONTH will be fine
				SELECT @NextBillingDate = CAST(DATEPART(m, @NextBillingDate) AS VARCHAR(2)) + ''/1/''+CAST(DATEPART(yy, @NextBillingDate) AS VARCHAR(4))  
				SELECT @NextEndBillingDate = DATEADD(m, 3,@NextBillingDate)
				SELECT @NextEndBillingDate = DATEADD(d, -1,@NextEndBillingDate)
			END
			IF @Frequency = 3
			BEGIN
				-- Add a year
				SELECT @NextBillingDate = DATEADD(yy, 1, @LastBillingDate)
				-- Any invoice date after or on the first of the YEAR  will be fine
				--SELECT @NextBillingDate = ''1/1/''+CAST(DATEPART(yy, @NextBillingDate) AS VARCHAR(4))  
				SELECT @NextEndBillingDate = ''12/31/''+CAST(DATEPART(yy, @NextBillingDate) AS VARCHAR(4))  
			
			END
			
			IF @Frequency = 4
			BEGIN
				-- Add a week
				SELECT @NextBillingDate = DATEADD(wk, 1, @LastBillingDate) 
			END

			IF @Frequency = 5
			BEGIN
				-- Add a 1/2 year or 6 months
				SELECT @NextBillingDate = DATEADD(m, 6, @LastBillingDate)
				-- Any invoice date after or on the first of the MONTH will be fine
				SELECT @NextBillingDate = CAST(DATEPART(m, @NextBillingDate) AS VARCHAR(2)) + ''/1/''+CAST(DATEPART(yy, @NextBillingDate) AS VARCHAR(4))  
				SELECT @NextEndBillingDate = DATEADD(m, 6,@NextBillingDate)
				SELECT @NextEndBillingDate = DATEADD(d, -1,@NextEndBillingDate)
			END

			-- Do not create if not in range
			IF @InvoiceDate < @NextBillingDate
			begin
				--select 4 as debug
				RETURN @kCANNOT_BILL 
			end
		END	
		
		RETURN @kCAN_BILL'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptUserApiGet]'
GO
IF OBJECT_ID(N'[dbo].[sptUserApiGet]', 'P') IS NOT NULL
EXEC sp_executesql N'
/*
  || When     Who Rel			What
  || 12/03/14 QMD 10.5.8.7		Created to get the API user
  || 01/28/16 QMD 10.6.0.0		User token must be on an active user
  || 11/09/20 MCM 20.1.2.0		(535068) Added OwnerCompanyKey so can create AuthToken
  || 03/16/22 QMD 22.03.20	    (591634) Allow contractors to use the API as long as they have a clientvendorlogin of 0
  || 06/12/26 GAR 26.07.19      (730742) Adding a user level permission, EnableAPIMCPUse, to allow a user to use the API or MCP
*/
ALTER PROCEDURE [dbo].[sptUserApiGet] 
	@APIAccessToken AS VARCHAR(MAX),
	@PublicUserToken AS VARCHAR(MAX)
AS

	SELECT	up.PrivateUserToken, u.UserKey, ISNULL(u.OwnerCompanyKey, u.CompanyKey) AS CompanyKey, u.OwnerCompanyKey, u.EnableAPIMCPUse
	FROM	tUserPreference up (NOLOCK) 
				INNER JOIN tUser u (NOLOCK) ON u.UserKey = up.UserKey
				INNER JOIN tPreference p (NOLOCK) ON ISNULL(u.OwnerCompanyKey, u.CompanyKey) = p.CompanyKey
	WHERE	up.PublicUserToken = @PublicUserToken
			AND p.APIAccessToken = @APIAccessToken
			AND u.Active = 1
			AND u.ClientVendorLogin = 0

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[vListing_MediaTrafficIO]'
GO
IF OBJECT_ID(N'[dbo].[vListing_MediaTrafficIO]', 'V') IS NOT NULL
EXEC sp_executesql N'








ALTER View [dbo].[vListing_MediaTrafficIO]
AS

  /*
  || When     Who Rel   What
  || 09/25/06 RTC 8.35  Changed inner join to outer from PO to Project.  POs linking through media
  ||                    estimates were not shown.
  || 10/16/06 WES 8.356 Added Client Name and ID fields
  || 09/13/07 GHL 8.436 Fixed Client Name and ID fields
  || 10/10/07 CRG 8.5   Added Class, GLCompany, Office, and Department
  || 01/21/10 RLB 10517 (72879) Added POLine Custom fields
  || 12/12/11 RLB 10551 (119167) Added Line Comments
  || 04/25/12 GHL 10555 Added GLCompanyKey for map/restrict
  || 03/22/13 WDF 10566 (172559) Added Transferred Out
  || 01/20/14 GHL 10576 Added Order Description
  || 11/07/14 WDF 10586 (234091) Added Special and Traffic Instructions
  || 01/27/15 WDF 10588 (Abelson Taylor) Added Division and Product
  || 02/18/15 GHL 10588 (246235) Rolled back 243930. Greg, did you mean media worksheets instead of media estimates? 
  || 02/07/20 GHL 20.030 (500841) Added Materials Sent Date (was on vListing_InsertionOrder by mistake)
  || 09/02/20 RLB 20.100 (523772) making anything using user name common format
  || 01/26/23 AMP 23.03.19 (628305) Added Media Plan ID and Media Plan Name
  || 02/06/25 AMP 25.02.16 (688666) Added Order Type, Order Line Field
  || 02/02/26 RLB 26.03.15 (718217) Added Media Plan Full Name
  || 04/23/26 MCM 26.05.x  (725435) Added InteractiveAdUnitName as Ad Size
  || 06/30/26 MCM 26.07.x  (730399) updated name of InteractiveAdUnitName to be Ad Unit
 */

Select
     po.PurchaseOrderKey
	,pod.PurchaseOrderDetailKey
    ,po.CompanyKey
    ,po.GLCompanyKey
    ,po.CustomFieldKey
	,pod.CustomFieldKey as POLineCustomFieldKey
	,po.POKind
    ,c.CompanyKey as VendorKey
    ,po.PurchaseOrderNumber AS [Order Number]
    ,c.VendorID AS [Vendor ID]
    ,c.CompanyName AS [Vendor Name]
    ,c.VendorID + '' - '' + c.CompanyName AS [Vendor Full Name]
    ,po.Contact AS [Vendor Contact]
    ,po.Address1 AS [Address 1]
    ,po.Address2 AS [Address 2]
    ,po.Address3 AS [Address 3]
    ,po.City AS [Address City]
    ,po.State AS [Address State]
    ,po.PostalCode AS [Address Postal Code]
    ,po.Country AS [Address Country]
    ,po.DateCreated AS [Date Created]
    ,po.PODate AS [Order Date]
    ,po.OrderedBy AS [Ordered By]
    ,po.Revision AS [Revision Number]
    ,po.ApprovedDate AS [Approved Date]
    ,Case When po.Closed = 1 then ''Closed'' else 
		case po.Status 
			when 1 then ''Not Sent For Approval''
			when 2 then ''Sent for Approval''
			when 3 then ''Rejected''
			when 4 then ''Open Approved'' end 
		end as [Status]
    ,case po.Closed when 1 then ''YES'' else ''NO'' end as [Closed]
	,case po.Printed when 1 then ''YES'' else ''NO'' end as [Printed]
	,LTRIM(RTRIM(ISNULL(u.FirstName + '' '','''')  + ISNULL(u.LastName,''''))) AS [Selected Approver]
	,p.ProjectNumber as [Project Number]
	,p.ProjectName as [Project Name]
	,p.ProjectNumber + '' - '' + p.ProjectName as [Project Full Name]
	,me.EstimateID as [Media Estimate ID]
	,me.EstimateName as [Media Estimate Name]
	,me.EstimateID + '' - '' + me.EstimateName as [Media Estimate Full Name]
	,cm.StationID as [Publication ID]
	,cm.Name as [Publication Name]
	,cm.StationID + '' - '' + cm.Name as [Publication Full Name]
	,pod.LineNumber AS [Line Number]
	,pod.ShortDescription AS [Caption]
	,pod.DetailOrderDate as [Insertion Date]
    ,pod.LongDescription AS [Line Long Description]
    ,pod.LongDescription AS [Line Comments]
    ,pod.TotalCost AS [Net]
    ,pod.AppliedCost AS [Applied Invoices]
	,pod.TotalCost - ISNULL(pod.AppliedCost, 0) AS [Open Amount]
    ,pod.Markup as [Commission]
	,pod.BillableCost AS [Gross]
	,pod.UserDate1 as [User Defined Date 1]
	,pod.UserDate2 as [User Defined Date 2]
	,pod.UserDate3 as [User Defined Date 3]
	,pod.UserDate4 as [User Defined Date 4]
	,pod.UserDate5 as [User Defined Date 5]
	,pod.UserDate6 as [User Defined Date 6]
	,pod.MaterialsSentDate as [Materials Sent Date]
	,pod.InteractiveAdUnitName AS [Ad Unit]

	,Case When pod.TransferToKey IS NULL Then ''NO'' else ''YES'' end as [Transferred Out]
	,i.ItemID as [Item ID]
	,i.ItemName as [Item Name]
	,mm.MarketID as [Market ID]  
    ,mm.MarketName as [Market Name]
	,case when isnull(pref.IOClientLink, 1) = 1 then pc.CompanyName else mc.CompanyName end as [Client Name] 
	,case when isnull(pref.IOClientLink, 1) = 1 then pc.CustomerID else mc.CustomerID end as [Client ID] 
	,glc.GLCompanyID as [Company ID]
	,glc.GLCompanyName as [Company Name]
	,cl.ClassID as [Class ID]
	,cl.ClassName as [Class Name]
	,o.OfficeID as [Office ID]
	,o.OfficeName as [Office Name]
	,d.DepartmentName as Department
	,po.[Description] as [Order Description] 
	,po.SpecialInstructions as [Special Instructions]
	,po.DeliveryInstructions as [Traffic Instructions]
	,cd.DivisionID as [Client Division ID]
    ,cd.DivisionName as [Client Division]
    ,cp.ProductID as [Client Product ID]
    ,cp.ProductName as [Client Product]
    ,mp.PlanID as [Media Plan ID]
	,mp.PlanName as [Media Plan Name]
	,mp.PlanID + '' - '' + mp.PlanName as [Media Plan Full Name]
	,pot.PurchaseOrderTypeName AS [Order Type]	
	,fs.FieldSetName as [Order Line Field]

FROM 
	tPurchaseOrder po (nolock)
	INNER JOIN tPurchaseOrderDetail pod (nolock) on po.PurchaseOrderKey = pod.PurchaseOrderKey
	INNER JOIN tPreference pref (nolock) on po.CompanyKey = pref.CompanyKey	
    INNER JOIN tCompany c (nolock) ON po.VendorKey = c.CompanyKey 
	left outer join tProject p (nolock) on po.ProjectKey = p.ProjectKey
	left outer join tProject pline (nolock) on pod.ProjectKey = pline.ProjectKey
	left outer join tItem i (nolock) on pod.ItemKey = i.ItemKey
	left outer join tCompanyMedia cm (nolock) on po.CompanyMediaKey = cm.CompanyMediaKey
	left outer join tMediaMarket mm (nolock) on cm.MediaMarketKey = mm.MediaMarketKey
	left outer join tUser u (nolock) on po.ApprovedByKey = u.UserKey
	left outer join tMediaEstimate me (nolock) on po.MediaEstimateKey = me.MediaEstimateKey
	left outer join tCompany pc (nolock) on pline.ClientKey = pc.CompanyKey
	left outer join tCompany mc (nolock) on me.ClientKey = mc.CompanyKey
	left outer join tClass cl (nolock) on pod.ClassKey = cl.ClassKey
	left outer join tGLCompany glc (nolock) on po.GLCompanyKey = glc.GLCompanyKey
	left outer join tOffice o (nolock) on pod.OfficeKey = o.OfficeKey
	left outer join tDepartment d (nolock) on pod.DepartmentKey = d.DepartmentKey
	left outer join tClientDivision cd (nolock) on p.ClientDivisionKey = cd.ClientDivisionKey
    left outer join tClientProduct  cp (nolock) on p.ClientProductKey  = cp.ClientProductKey
	left outer join tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey	=  pod.PurchaseOrderDetailKey			 
	left outer join tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey
	left outer join tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey
	left outer join tPurchaseOrderType pot (nolock) on po.PurchaseOrderTypeKey = pot.PurchaseOrderTypeKey
	left outer join tObjectFieldSet ofs (nolock) on pod.CustomFieldKey = ofs.ObjectFieldSetKey
	left outer join tFieldSet fs (nolock) on fs.FieldSetKey = ofs.FieldSetKey
Where po.POKind = 1 -- and isnull(po.MediaEstimateKey, 0) = 0
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spScheduleGetTasks]'
GO
IF OBJECT_ID(N'[dbo].[spScheduleGetTasks]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spScheduleGetTasks]
	(
		@ProjectKey INT
	)
AS -- Encrypt

  /*
  || When     Who Rel      What
  || 11/22/06 GHL 8.4      Removed restriction on ScheduleTask 
  || 11/09/12 RLB 10561    Added 2 fields for Kohls changes
  || 10/11/23 CRG 23.11.19 (647340) Added MustFinishOnPredComplete
  || 01/13/26 CRG 26.02.15 (548907) Added recurring task fields
  || 06/02/26 CRG 26.07.19 (729772) Removing the time portion from ActStart, ActComplete
  */

	SET NOCOUNT ON

	SELECT	TaskType	-- 1 Summary, 2 Tracking
			,TaskKey
			,SummaryTaskKey
			,CAST(TaskName AS VARCHAR(500)) AS TaskName
			,TaskID
			,TaskConstraint
			,ConstraintDate
			,PlanDuration AS Duration
			,dbo.fFormatDateNoTime(ActStart) AS ActStart
			,dbo.fFormatDateNoTime(ActComplete) AS ActComplete
			,PlanStart
			,PlanComplete
			,PercComp
			,PercCompSeparate
			,PredecessorsComplete
			,WorkAnyDay
			,EventStart
			,EventEnd
			,(SELECT COUNT(*) FROM tTask t2 (NOLOCK) 
				WHERE t2.ProjectKey = @ProjectKey
				AND   t2.SummaryTaskKey = tTask.TaskKey) AS SubtaskCount
			,ScheduleTask
			,MoneyTask
			,TrackBudget
			,ProjectOrder
			,DisplayOrder
			,TaskLevel
			,BudgetTaskKey
			,ConstraintDayOfTheWeek
			,ExcludeFromStatus
			,MustFinishOnPredComplete
			,RecurringFreq
			,RecurringParentKey
			,RecurringOrder
			,RecurringMax
	FROM	tTask (NOLOCK)
	WHERE	ProjectKey = @ProjectKey
	
	RETURN 1
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptRequestDefGetByPrefix]'
GO
IF OBJECT_ID(N'[dbo].[sptRequestDefGetByPrefix]', 'P') IS NOT NULL
EXEC sp_executesql N' ALTER PROCEDURE [dbo].[sptRequestDefGetByPrefix]  
 @CompanyKey int,  
 @RequestPrefix varchar (50)  
  
AS --Encrypt  
 /*  
  || When     Who Rel         What  
  || 01/26/18 MCM 18.02.00.0  Creating for Request Import  
  || 06/18/26 QMD 26.06.14.0  (731067) Added Active = 1 AND Order By DESC
 */  
  
SELECT	*  
FROM	tRequestDef (NOLOCK)   
WHERE	CompanyKey = @CompanyKey 
		AND RequestPrefix = @RequestPrefix  
		AND Active = 1
ORDER BY LastModified DESC

 RETURN 1  
  '
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptPlaidAccountUpdate]'
GO
IF OBJECT_ID(N'[dbo].[sptPlaidAccountUpdate]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptPlaidAccountUpdate]
 @PlaidItemKey INT,
 @Name VARCHAR(50),
 @PlaidAccountID VARCHAR(100),
 @Mask VARCHAR(50),
 @SubType VARCHAR(50),
 @Type VARCHAR(50)

AS --Encrypt

/*
|| When     Who Rel			What
|| 10/01/18	MAS 18.9.2		Created
|| 10/11/21	MAS 21.11.14	Fix a bug where we were mistakenly updated a sub account mask.
|| 06/02/26	MAS 26.07.19	(715260) Set ParentAccount=1 on INSERT so updateSubAccounts can find parent accounts immediately
||							without needing a sub-account to have been created first (chicken-and-egg bug).
*/

DECLARE @PlaidAccountKey AS INT

IF Exists (SELECT 1 FROM tPlaidAccount (nolock) WHERE PlaidItemKey = @PlaidItemKey AND PlaidAccountID = @PlaidAccountID)
	BEGIN
		UPDATE tPlaidAccount SET Name = @Name, Mask = @Mask, SubType = @SubType, Type = @Type
		WHERE PlaidItemKey = @PlaidItemKey
		AND  PlaidAccountID = @PlaidAccountID
		AND ParentAccount = 1
	END
ELSE
	BEGIN   
		INSERT INTO tPlaidAccount (PlaidItemKey, Name, PlaidAccountID, Mask, SubType, Type, ParentAccount) VALUES (@PlaidItemKey, @Name, @PlaidAccountID, @Mask, @SubType, @Type, 1)

		SELECT @PlaidAccountKey = @@IDENTITY 
	END

RETURN @PlaidAccountKey'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptMediaPlanDetailUpdateAPIWorker]'
GO
IF OBJECT_ID(N'[dbo].[sptMediaPlanDetailUpdateAPIWorker]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER procedure [dbo].[sptMediaPlanDetailUpdateAPIWorker]    
 (    
	@CompanyKey INT,
	@MediaPlanKey INT,
	@PlanID VARCHAR(50), 
	@Timestamp INT
 )    
AS    
--Encrypt    
    
  /*    
  || When     Who	Rel			What    
  || 08/04/22 QMD	22.09.17	(609307) Created for media plans.  Took the procs Gil did and made it set based.
  || 08/19/22 QMD	22.09.17	(609307) Fix issue for new media plans
  || 06/21/23 MAS	23.07.16	Removed Old Media tables
  || 09/10/23 MAS	23.10.16	(646370) Added TimeStamp
  || 01/22/24 MAS	24.01.21	(661977) Added StationID to the "Update worker table with the newly created MediaPlanVendorKey" update
  || 06/22/24 MAS	24.06.16	(669638) Added sptMediaPlanDetailDelete
  || 09/27/24 MAS	24.10.20	(683656) Ensure that when setting the MediaPlanVendorKey, the ItemKey is also considered to account for scenarios where a vendor has multiple items. 
								Previously, only one vendor was included when creating mediaPlanDetail lines, even though tMediaPlanVendor records 
								were correctly created for all items associated with that vendor.
  || 11/12/24 MAS	24.11.17	(684125) Fixed the sort order when determining the LineNumbers
  || 09/04/25 MAS	25.09.21	(708512) Added error messages when deleting MediaPlanDetail line
  || 10/07/25 MAS	25.11.??	(712850) Added error messages when an existing SpotLinkID is sent over attached to a different Order
  || 10/09/25 MAS	25.09.21	Added @InitialMediaPlanKey to eliminate possible PRIMARY KEY violations on tMediaPlanDetailWorker
  || 12/01/25 MAS	26.12.14	(717669) Retain the original LineNumber when creating MediaPlanDetailHistory records & Only create MediaPlanDetailHistory records when something changes
  || 04/23/25 MAS	26.04.19	(727087) Restored sptMediaPlanDetailUpdateAPIWorker to use the legacy -69 placeholder for new media plan worker rows
  || 04/30/26 MAS	26.04.19	(727514) Restored full history creation for API updates; removed unused @InitialMediaPlanKey
  || 07/08/26 MAS	26.07.19	(732561) Keep API save atomic on bad lines: fixed NULL ErrMsg concat (a valid vendor + invalid item left ErrMsg NULL),
								and added an early RETURN -5 before any writes so every invalid line is reported instead of a raw NULL MediaPlanVendorKey insert error.
  */

  /*    
  The structure for tMediaPlan/tMediaPlanVendor/tMediaPlanDetail has 3 levels    
  But the API only has 2 levels, so this stored proc for the API will create the intermediate level    
  tMediaPlanVendor and call the regular sptMediaPlanDetailUpdate    
  */    

    
  -- since the API now updates records based on the ID, rather than on the keys    
  -- it could happen that the keys do not belong to the same plan    

  	PRINT ''--------------------------''
	PRINT '' Starting ''
	PRINT ''--------------------------''
	PRINT ''''
	PRINT GETDATE()	

	/* *******************************************************************************
		If new Media Orders need to update the mediaplankey 
		-69 is used for new orders along with the mediaplanid
	   ******************************************************************************* */
	IF NOT EXISTS (	
					SELECT	1
					FROM	tMediaPlanDetailWorker mpw (NOLOCK)
					WHERE	mpw.CompanyKey = @CompanyKey 
							AND mpw.MediaPlanKey = @MediaPlanKey
							AND mpw.Timestamp = @Timestamp
				   )
		BEGIN
			UPDATE	mpw
			SET		mpw.MediaPlanKey = @MediaPlanKey
			FROM	tMediaPlanDetailWorker mpw (NOLOCK)
			WHERE	mpw.CompanyKey = @CompanyKey
					AND mpw.MediaPlanID = @PlanID
					AND mpw.MediaPlanKey = -69
		END 

	/* *******************************************************************************
		A SpotLinkID can ONLY ever be associated with one OrderLinkID
	   ******************************************************************************* */
	IF EXISTS (    
			SELECT	1
			FROM	tMediaPlanDetailWorker mpw (NOLOCK)
					INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.SpotLinkID = mpd.SpotLinkID  
			WHERE	mpw.CompanyKey = @CompanyKey
					AND mpw.Timestamp = @Timestamp							
					AND mpw.OrderLinkID <> mpd.OrderLinkID
			)
			RETURN -3 


	/* *******************************************************************************
		Update MediaPlanDetailKey
	   ******************************************************************************* */

	UPDATE	mpw
	SET		mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey   
	--SELECT	mpd.MediaPlanDetailKey, *
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlan mp (NOLOCK) ON mpw.MediaPlanKey = mp.MediaPlanKey
				INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mp.MediaPlanKey = mpv.MediaPlanKey    
				INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpv.MediaPlanVendorKey = mpd.MediaPlanVendorKey    
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND mpw.MediaPlanDetailKey <= -1000
			--AND mp.MediaPlanKey = @MediaPlanKey  
			AND  upper(rtrim(ltrim(mpd.SpotLinkID))) = upper(rtrim(ltrim(mpw.SpotLinkID)))    

  
  
/* *******************************************************************************
	Update ItemID
   ******************************************************************************* */
   	
	PRINT ''--------------------------''
	PRINT ''Update Item''
	PRINT ''--------------------------''
	PRINT ''''

	UPDATE	mpw
	SET		mpw.ItemKey = i.ItemKey
	--SELECT	mpw.ItemKey, mpw.MediaPlanDetailKey, i.ItemKey
	FROM	tMediaPlanDetailWorker mpw (NOLOCK) INNER JOIN tItem i (NOLOCK) ON mpw.ItemID = i.ItemID AND i.CompanyKey = @CompanyKey
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND i.ItemType = CASE WHEN -1 >= 0 THEN -1 ELSE i.ItemType END
		
	UPDATE	mpw
	SET		mpw.ItemKey = i.ItemKey
	--SELECT	mpw.ItemKey, mpw.MediaPlanDetailKey, i.ItemKey
	FROM	tMediaPlanDetailWorker mpw (NOLOCK) INNER JOIN tItem i (NOLOCK) ON mpw.ItemID = i.ItemID AND i.CompanyKey = @CompanyKey
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND i.ItemName = mpw.ItemID
			AND i.ItemType = CASE WHEN -1 >= 0 THEN -1 ELSE i.ItemType END
			AND ISNULL(mpw.ItemKey,0) = 0

/* *******************************************************************************
	Check for invalid PO types
	Mark invalid
   ******************************************************************************* */
	UPDATE	mpw
	SET		mpw.ErrMsg = ''Invalid item, items can only be 1 (Print) or 2 (Broadcast)''
	-- SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK) INNER JOIN tItem i (NOLOCK) ON mpw.ItemKey = i.ItemKey
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND i.ItemType NOT IN (1,2)


/* *******************************************************************************
	Get Vendor - sptCompanyMediaGet
   ******************************************************************************* */
	
	PRINT ''--------------------------''
	PRINT '' Get and Set Vendor''
	PRINT ''--------------------------''
	PRINT ''''

	--------------------------------------
	-- PART 1/2 No Vendor in Worker Table
	--------------------------------------

	UPDATE	mpw
	SET		mpw.VendorID = c.VendorID, mpw.VendorKey = cm.VendorKey
	-- SELECT	*
	FROM 	tMediaPlanDetailWorker mpw (NOLOCK)
			INNER JOIN tCompanyMedia cm (nolock) ON mpw.StationKey = cm.CompanyMediaKey
			INNER JOIN tCompany c (nolock) ON cm.VendorKey = c.CompanyKey 
			--LEFT JOIN tUser u (nolock) on cm.VendorContactKey = u.UserKey
			--LEFT JOIN tUser u2 (nolock) on c.PrimaryContact = u2.UserKey
			--LEFT JOIN tMediaMarket mm (nolock) ON cm.MediaMarketKey = mm.MediaMarketKey 	
			--LEFT JOIN tItem i (nolock) on cm.ItemKey = i.ItemKey
			--LEFT JOIN tSalesTax st (nolock) on cm.SalesTaxKey = st.SalesTaxKey
			--LEFT JOIN tSalesTax st2 (nolock) on cm.SalesTax2Key = st2.SalesTaxKey

	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND mpw.VendorID IS NULL

	--------------------------------------
	-- PART 2/2 Worker table Has Vendor - sptCompanyValidVendor
	--------------------------------------

	-- Changed the rule to only update active vendors
	-- All inactive vendors will be marked with an error

	UPDATE	mpw
	SET		mpw.VendorKey = c.CompanyKey
	-- SELECT	c.CompanyKey, *
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tCompany c (NOLOCK) ON mpw.CompanyKey = c.OwnerCompanyKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND mpw.VendorID = c.VendorID
			AND c.Vendor = 1
			AND mpw.VendorID IS NOT NULL
			AND mpw.VendorKey IS NULL
			AND c.Active = 1

	UPDATE	mpw
	SET		mpw.ErrMsg = ''Inactive vendor''
	--  SELECT	c.CompanyKey, *
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tCompany c (NOLOCK) ON mpw.CompanyKey = c.OwnerCompanyKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND mpw.VendorID = c.VendorID
			AND c.Vendor = 1
			AND c.Active = 0

		

	IF EXISTS (    
				SELECT	1
				FROM	tMediaPlanDetailWorker mpw (NOLOCK)
							INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
							INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey    
							INNER JOIN tMediaPlan mp (NOLOCK) ON mpv.MediaPlanKey = mp.MediaPlanKey    
				WHERE	mpw.CompanyKey = @CompanyKey
						AND mpw.MediaPlanKey = @MediaPlanKey
						AND mpw.Timestamp = @Timestamp
						AND mpw.MediaPlanDetailKey > 0
						AND mpw.MediaPlanKey <> mp.MediaPlanKey
				)
				RETURN -1


/* *******************************************************************************
	Get StationKey - sptCompanyMediaValidID
   ******************************************************************************* */
   	
	PRINT ''--------------------------''
	PRINT ''Get Station ''
	PRINT ''--------------------------''
	PRINT ''''

	UPDATE	mpw
	SET		mpw.StationKey = cm.CompanyMediaKey
	-- SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tCompanyMedia cm (NOLOCK) ON mpw.VendorKey = cm.VendorKey
				INNER JOIN tItem i (NOLOCK) ON mpw.ItemKey = i.ItemKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND cm.MediaKind = i.ItemType
			AND mpw.StationID = cm.StationID
			AND mpw.VendorID IS NULL

	UPDATE	mpw
	SET		mpw.StationKey = cm.CompanyMediaKey
	-- SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tCompanyMedia cm (NOLOCK) ON mpw.VendorKey = cm.VendorKey
				INNER JOIN tCompany c (NOLOCK) ON c.CompanyKey = cm.VendorKey
				INNER JOIN tItem i (NOLOCK) ON mpw.ItemKey = i.ItemKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND cm.MediaKind = i.ItemType
			AND c.VendorID = mpw.VendorID
			AND mpw.StationID = cm.StationID
			AND mpw.VendorID IS NOT NULL

/* *******************************************************************************
	Update MediaPlanVendorKey where is null or less than equal to 0 - sptMediaPlanDetailUpdateAPI
   ******************************************************************************* */
	UPDATE	mpw
	SET		mpw.MediaPlanVendorKey = mpv.MediaPlanVendorKey
	-- SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)

			-- Ensure that when setting the MediaPlanVendorKey, the ItemKey is also considered to account for scenarios where a vendor has multiple items. 
			-- Previously, only one vendor was included when creating mediaPlanDetail lines, even though tMediaPlanVendor records were correctly created for all items associated with that vendor.
			INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mpw.MediaPlanKey = mpv.MediaPlanKey AND mpw.ItemKey = mpv.ItemKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.MediaPlanVendorKey,0) <=0	
		
			AND ISNULL(mpw.VendorKey,0) = ISNULL(mpv.VendorKey,0)
			AND ISNULL(mpw.ItemKey,0) = ISNULL(mpv.ItemKey,0)
			AND ISNULL(mpw.StationKey,0) = ISNULL(mpv.StationKey,0)
		
			AND ISNULL(mpw.VendorID,'''') = ISNULL(mpv.VendorID,'''')
			AND ISNULL(mpw.ItemID,'''') = ISNULL(mpv.ItemLinkID,'''')
			AND ISNULL(mpw.StationID,'''') = ISNULL(mpv.StationID,'''')
  
  
 /* *******************************************************************************
	Update tMediaPlanVendor - sptMediaPlanVendorUpdate
   ******************************************************************************* */
	
	PRINT ''--------------------------''
	PRINT ''Update tMediaPlanVendor''
	PRINT ''--------------------------''
	PRINT ''''
	--------------------------------------
	-- validate the item
	--------------------------------------
	--IF EXISTS (
	--			SELECT	1
	--			FROM	tMediaPlanDetailWorker mpw (NOLOCK)
	--						INNER JOIN tItem i (NOLOCK) ON mpw.ItemKey = i.ItemKey AND i.ItemType NOT IN (1,2)
	--			WHERE	mpw.CompanyKey = @CompanyKey
	--					AND mpw.MediaPlanKey = @MediaPlanKey
	--					AND ISNULL(mpw.ItemKey,0) > 0 -- API call may have no item 
	--		  )
	--		  RETURN -1 


	--------------------------------------
	-- on an update, and PODs have been created we really need an item
	--------------------------------------	
	IF EXISTS (
				SELECT	1
				FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				WHERE	mpw.CompanyKey = @CompanyKey
						AND mpw.MediaPlanKey = @MediaPlanKey
						AND mpw.Timestamp = @Timestamp
						AND MediaPlanVendorKey > 0 						
						AND ISNULL(ItemKey, 0) = 0
						AND EXISTS (
									SELECT	1 
									FROM	tMediaPlanDetail mpd (NOLOCK)
											INNER JOIN tPurchaseOrderDetail pod (NOLOCK) ON pod.MediaPlanDetailKey = mpd.MediaPlanDetailKey
									WHERE	mpd.MediaPlanVendorKey = mpw.MediaPlanVendorKey
									)
			  )
			  RETURN -1

	--------------------------------------
	-- on an update, and PODs have been created we really need an item
	--------------------------------------		
	UPDATE	mpw
	SET		mpw.ItemType = i.ItemType
	--SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tItem i (NOLOCK) ON mpw.ItemKey = i.ItemKey 
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.ItemKey,0) > 0
		
	--------------------------------------
	-- on an update, and PODs have been created we really need an item
	--------------------------------------	
	UPDATE	mpw
	SET		mpw.MediaKind = i.MediaKind
	-- SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tCompanyMedia i (NOLOCK) ON mpw.StationKey = i.CompanyMediaKey
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.StationKey,0) > 0

	--------------------------------------
	-- on an update, and PODs have been created we really need an item
	--------------------------------------	
	IF EXISTS (
				SELECT	1
				FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				WHERE	mpw.CompanyKey = @CompanyKey 
						AND mpw.MediaPlanKey = @MediaPlanKey
						AND mpw.Timestamp = @Timestamp
						AND	ISNULL(mpw.ItemKey,0) > 0
						AND ISNULL(mpw.StationKey,0) > 0
						AND ISNULL(mpw.ItemType,0) <> ISNULL(mpw.MediaKind,0)
			  )
			  RETURN -2

	--------------------------------------
	-- Error Checks 
	--------------------------------------	

	PRINT ''--------------------------''
	PRINT ''Error Checks''
	PRINT ''--------------------------''
	PRINT ''''

	-- is there a composite key? do we check uniqueness of MediaPlanKey/VendorKey/StationKey/ItemKey?
	-- Compose the message in one pass.  Previously these were three separate UPDATEs where the 2nd/3rd
	-- concatenated onto ErrMsg (ErrMsg + ''...''); when ErrMsg started NULL (e.g. a valid vendor but an
	-- invalid item) the concat produced NULL, so the line was left with NO message and fell through to
	-- a NULL MediaPlanVendorKey insert.  ISNULL() around ErrMsg keeps every failing line flagged.
	-- The vendor clause is skipped when a message is already present so an ''Inactive vendor'' line
	-- keeps its more specific message instead of being overwritten with the generic ''Invalid Vendor.''.
	UPDATE	mpw
	SET		ErrMsg = ISNULL(mpw.ErrMsg, '''')
					+ CASE WHEN ISNULL(mpw.VendorKey, 0) = 0 AND ISNULL(mpw.ErrMsg, '''') = '''' THEN ''Invalid Vendor. '' ELSE '''' END
					+ CASE WHEN ISNULL(mpw.ItemKey, 0) = 0 THEN ''Invalid Item. '' ELSE '''' END
					+ CASE WHEN ISNULL(mpw.StationKey, 0) = 0 THEN ''Invalid Station/Publication. '' ELSE '''' END
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND (	ISNULL(mpw.VendorKey, 0) = 0
				OR	ISNULL(mpw.ItemKey, 0) = 0
				OR	ISNULL(mpw.StationKey, 0) = 0 )

	--------------------------------------
	-- Atomic validation gate
	--
	-- If ANY line has an unresolved vendor, item, or station key, stop here
	-- BEFORE writing to tMediaPlanVendor/tMediaPlanDetail.  An unresolved key is
	-- exactly what leaves MediaPlanVendorKey NULL and blew up the detail insert
	-- with a raw "Cannot insert NULL into MediaPlanVendorKey" SQL error.
	-- Returning before any write keeps the whole batch atomic (nothing saves)
	-- and lets the caller harvest every bad line''s ErrMsg (set just above) so
	-- all offending lines are reported at once instead of one SQL exception.
	--------------------------------------
	IF EXISTS (
				SELECT	1
				FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				WHERE	mpw.CompanyKey = @CompanyKey
						AND mpw.MediaPlanKey = @MediaPlanKey
						AND mpw.Timestamp = @Timestamp
						AND (	ISNULL(mpw.VendorKey, 0) = 0
							OR	ISNULL(mpw.ItemKey, 0) = 0
							OR	ISNULL(mpw.StationKey, 0) = 0 )
			  )
			  RETURN -5


   	--------------------------------------
	-- Update tMediaPlanVendor
	--
	-- complete the update before the insert
	-- so that we can then update the mediaplanvendorkeys
	--------------------------------------	
	
	PRINT ''--------------------------''
	PRINT ''Insert tMediaPlanDetail''
	PRINT ''--------------------------''
	PRINT ''''

	UPDATE	mpv
	SET		MediaPlanKey	= mpw.MediaPlanKey
			,VendorID		= mpw.VendorID
			,VendorKey		= mpw.VendorKey
			,StationID		= mpw.StationID
			,StationKey		= mpw.StationKey
			,ItemLinkID		= mpw.ItemID
			,ItemKey		= mpw.ItemKey
			,ErrMsg			= mpw.ErrMsg
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mpw.MediaPlanVendorKey = mpv.MediaPlanVendorKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.MediaPlanVendorKey,0) > 0

   	--------------------------------------
	-- Insert into MediaPlanVendor
	--------------------------------------	
	
	PRINT ''--------------------------''
	PRINT ''Insert tMediaPlanVendor''
	PRINT ''--------------------------''
	PRINT ''''

	INSERT INTO tMediaPlanVendor
			([MediaPlanKey]
			,[VendorID]
			,[VendorKey]
			,[StationID]
			,[StationKey]
			,[ItemLinkID]
			,[ItemKey]
			,[ErrMsg])
	SELECT  DISTINCT 
			mpw.MediaPlanKey
			,mpw.VendorID
			,mpw.VendorKey 
			,mpw.StationID 
			,mpw.StationKey
			,mpw.ItemID
			,mpw.ItemKey
			,mpw.ErrMsg
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(MediaPlanVendorKey,0) <= 0

	
 	--------------------------------------
	-- Update worker table with the newly
	-- created MediaPlanVendorKey
	--------------------------------------		
	--Q-DO -- Figure a way to update the identity in the worker table.   Might be able to join on the vendorID  to get the key and update the mediaplanvendorkey in the worker table.

	UPDATE	mpw 
	SET		mpw.MediaPlanVendorKey = mpv.MediaPlanVendorKey
	-- SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mpv.MediaPlanKey = mpw.MediaPlanKey 
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.MediaPlanVendorKey,0) <= 0
			AND mpw.VendorID = mpv.VendorID
			AND mpw.StationID = mpv.StationID
			AND mpw.ItemKey = mpv.ItemKey
 

 /* *******************************************************************************
	Update tMediaPlanDetail - sptMediaPlanDetailUpdate
   ******************************************************************************* */    
	--------------------------------------
	-- POKind - Update the itemtype/pokind
	--------------------------------------	 
	PRINT ''--------------------------''
	PRINT ''POKind''
	PRINT ''--------------------------''
	PRINT ''''

	UPDATE	mpw
	SET		mpw.ItemType = i.ItemType
	--SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mpw.MediaPlanVendorKey = mpv.MediaPlanVendorKey
				INNER JOIN tMediaPlan mp (NOLOCK) ON mpv.MediaPlanKey = mp.MediaPlanKey
				INNER JOIN tItem i (NOLOCK) ON mpv.ItemKey = i.ItemKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			

	--------------------------------------
	-- The SpotLinkID is a cross reference to the external system
	--------------------------------------	 
	
	PRINT ''--------------------------''
	PRINT ''SpotLinkID''
	PRINT ''--------------------------''
	PRINT ''''

	IF EXISTS (
				SELECT	1
				FROM	tMediaPlanDetailWorker mpw (NOLOCK)
							INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
							INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey
							INNER JOIN tMediaPlan mp (NOLOCK) ON mpv.MediaPlanKey = mp.MediaPlanKey
				WHERE	mpw.CompanyKey = @CompanyKey
						AND mpw.MediaPlanKey = @MediaPlanKey
						AND mpw.Timestamp = @Timestamp
						AND mp.CompanyKey = @CompanyKey
						AND mpd.MediaPlanDetailKey <> ISNULL(mpw.MediaPlanDetailKey, 0)
						AND mpd.SpotLinkID = mpw.SpotLinkID
			  )
			  RETURN -4


	PRINT ''--------------------------''
	PRINT '' Set Start and End dates''
	PRINT ''--------------------------''
	PRINT ''''

	--------------------------------------
	-- Set null startdate
	--------------------------------------	
	UPDATE	mpw
	SET		StartDate = [dbo].[fFormatDateNoTime](getdate())
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND mpw.StartDate IS NULL

	--------------------------------------
	-- Set null enddate
	--------------------------------------	
	UPDATE	mpw
	SET		EndDate = [dbo].[fFormatDateNoTime](getdate())
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND mpw.EndDate IS NULL
			AND mpw.ItemType = 2  -- this is POKind


	--------------------------------------
	-- Set line number
	--------------------------------------	

	PRINT ''--------------------------''
	PRINT '' Set Line Numbers''
	PRINT ''--------------------------''
	PRINT ''''

	DECLARE @NextNumber INT 

	SELECT	@NextNumber = ISNULL(MAX(mpd.LineNumber),0)
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanVendorKey = mpd.MediaPlanVendorKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp

	UPDATE	mp
	SET		mp.LineNumber = m.Row
	--SELECT	m.Row, *
	FROM	(
			SELECT	ROW_NUMBER() OVER(ORDER BY ISNULL(mpw.LineNumber,1) ASC) + @NextNumber AS Row, mpw.CompanyKey, mpw.MediaPlanKey, mpw.MediaPlanDetailKey	
			FROM	tMediaPlanDetailWorker mpw (NOLOCK)
			WHERE	mpw.CompanyKey = @CompanyKey 
					AND mpw.MediaPlanKey = @MediaPlanKey
					AND mpw.Timestamp = @Timestamp
			) m, tMediaPlanDetailWorker mp
	WHERE	mp.CompanyKey = @CompanyKey
			AND mp.MediaPlanKey = @MediaPlanKey
			AND mp.MediaPlanDetailKey = m.MediaPlanDetailKey
					
	
	--------------------------------------
	-- Update tMediaPlanDetail
	--------------------------------------	

	PRINT ''--------------------------''
	PRINT ''Update tMediaPlanDetail''
	PRINT ''--------------------------''
	PRINT ''''

	-- if an order was created, do not change the Order Link ID		
	UPDATE	mpw
	SET		mpw.OrderLinkID = mpd.OrderLinkID
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
				INNER JOIN tPurchaseOrderDetail pod (NOLOCK) ON mpd.MediaPlanDetailKey = pod.MediaPlanDetailKey
	WHERE	mpw.CompanyKey = @CompanyKey 
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp


	-- create temp table for account call below
	SELECT	mpw.CompanyKey, mpw.MediaPlanKey, mpw.MediaPlanDetailKey, ROW_NUMBER() OVER(ORDER BY ISNULL(mpw.LineNumber,1) DESC) AS RowNumber
	INTO	#MediaPlanDetailUpdateAccounting
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.MediaPlanDetailKey,0) > 0
			AND ISNULL(mpw.Deleted, 0 ) = 0

	UPDATE	tMediaPlanDetail
	SET		MediaPlanVendorKey	= mpw.MediaPlanVendorKey
			,SpotLinkID			= mpw.SpotLinkID
			,StartDate			= mpw.StartDate
			,EndDate			= mpw.EndDate
			,[Description]		= mpw.[Description]
			,OrderDays			= mpw.OrderDays
			,OrderTime			= mpw.OrderTime
			,OrderLength		= mpw.OrderLength
			,Date1				= mpw.Date1
			,Date2				= mpw.Date2
			,Quantity			= mpw.Quantity
			,Cost				= mpw.Cost
			,UnitCost			= mpw.UnitCost
			,Markup				= mpw.Markup
			,Gross				= mpw.Gross
			,AmountToBill		= mpw.AmountToBill
			,DateModified		= GETUTCDATE()
			,[Status]			= mpw.[Status]
			,OrderLinkID		= mpw.OrderLinkID
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.MediaPlanDetailKey,0) > 0
	

	--------------------------------------
	-- Insert tMediaPlanDetail
	--------------------------------------

	PRINT ''--------------------------''
	PRINT ''Insert tMediaPlanDetail''
	PRINT ''--------------------------''
	PRINT ''''	

	INSERT INTO dbo.tMediaPlanDetail
			(MediaPlanVendorKey
			,SpotLinkID
			,LineNumber
			,StartDate
			,EndDate
			,[Description]
			,OrderDays
			,OrderTime
			,OrderLength
			,Date1
			,Date2
			,Quantity
			,Cost
			,UnitCost
			,Markup
			,Gross
			,AmountToBill
			,DateAdded
			,DateModified
			,PurchaseOrderDetailKey
			,Status
			,OrderLinkID
			)
	SELECT	mpw.MediaPlanVendorKey
			,mpw.SpotLinkID
			,mpw.LineNumber
			,mpw.StartDate
			,mpw.EndDate
			,mpw.[Description]
			,mpw.OrderDays
			,mpw.OrderTime
			,mpw.OrderLength
			,mpw.Date1
			,mpw.Date2
			,mpw.Quantity
			,mpw.Cost
			,mpw.UnitCost
			,mpw.Markup
			,mpw.Gross
			,mpw.AmountToBill
			,GETUTCDATE()	--DateAdded
			,GETUTCDATE()	--DateModified
			,NULL			--PurchaseOrderDetailKey
			,mpw.Status
			,mpw.OrderLinkID
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				--INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.MediaPlanDetailKey,0) <= 0


	--------------------------------------
	-- Update the media plan detail keys 
	-- in the worker table after the insert
	-- link based on mediaplankey, vendorkey 
	-- and spotlinkid - wasn''t in original code
	-- added after walk through with mas.
	--------------------------------------	

	UPDATE	mpw
	SET		mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
	-- SELECT	*
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlan mp (NOLOCK) ON mpw.MediaPlanKey = mp.MediaPlanKey
				INNER JOIN tMediaPlanVendor mpv (NOLOCK) ON mpv.MediaPlanKey = mp.MediaPlanKey
				INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey
	WHERE 	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			AND ISNULL(mpw.MediaPlanDetailKey,0) <= 0
			AND mpd.SpotLinkID = mpw.SpotLinkID
			AND mpv.VendorKey = mpw.VendorKey


 /* *******************************************************************************
	Update tMediaPlanDetailHistory
    ******************************************************************************* */    

	PRINT ''--------------------------''
	PRINT ''Update tMediaPlanDetailHistory''
	PRINT ''--------------------------''
	PRINT ''''

	INSERT INTO dbo.tMediaPlanDetailHistory
			(MediaPlanDetailKey
			,MediaPlanVendorKey
			,SpotLinkID
			,LineNumber
			,StartDate
			,EndDate
			,Description
			,OrderDays
			,OrderTime
			,OrderLength
			,Date1
			,Date2
			,Quantity
			,Cost
			,UnitCost
			,Markup
			,Gross
			,AmountToBill
			,DateAdded
			,Status
			,OrderLinkID
			)
	SELECT	mpw.MediaPlanDetailKey
			,mpw.MediaPlanVendorKey
			,mpw.SpotLinkID
			,mpd.LineNumber -- The LineNumber should never change for an Existing line.  ISNULL(MAX(mpd.LineNumber),0) 
			,mpw.StartDate
			,mpw.EndDate
			,mpw.[Description]
			,mpw.OrderDays
			,mpw.OrderTime
			,mpw.OrderLength
			,mpw.Date1
			,mpw.Date2	
			,mpw.Quantity
			,mpw.Cost
			,mpw.UnitCost
			,mpw.Markup
			,mpw.Gross
			,mpw.AmountToBill
			,GETUTCDATE()
			,mpw.[Status]
			,mpw.OrderLinkID
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				INNER JOIN tMediaPlanDetail mpd (NOLOCK) ON mpw.MediaPlanDetailKey = mpd.MediaPlanDetailKey
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.Timestamp = @Timestamp
			--AND ISNULL(mpw.MediaPlanDetailKey,0) <= 0

	--------------------------------------
	-- Update Accounting
	--------------------------------------	

	PRINT GETDATE()	
	PRINT ''--------------------------''
	PRINT ''Update Accounting''
	PRINT ''--------------------------''

	IF EXISTS (SELECT 1 FROM #MediaPlanDetailUpdateAccounting)
	BEGIN

		DECLARE @MediaPlanDetailKey INT
		DECLARE @Count BIGINT 
		DECLARE @RunningCounter BIGINT 

		SET @Count = 0 
		SET @RunningCounter = 1

		-- get a count of total rows to process 
		SELECT @Count = MAX(RowNumber) FROM #MediaPlanDetailUpdateAccounting
 
		WHILE @RunningCounter <= @Count
		BEGIN
			PRINT @RunningCounter
			PRINT GETDATE()

			SELECT	@MediaPlanDetailKey = MediaPlanDetailKey
			FROM	#MediaPlanDetailUpdateAccounting
			WHERE	RowNumber = @RunningCounter
	
			EXEC sptMediaPlanDetailUpdateAccounting @MediaPlanDetailKey
    
			SET @RunningCounter = @RunningCounter + 1 
 
		END
	END 

	PRINT GETDATE()	
	PRINT ''--------------------------''
	PRINT ''Deleting Deleted Detail lines ''
	PRINT ''--------------------------''

	IF EXISTS (SELECT 1 FROM	tMediaPlanDetailWorker mpw (NOLOCK)
						WHERE	mpw.CompanyKey = @CompanyKey 
						AND		mpw.MediaPlanKey = @MediaPlanKey
						AND		mpw.Timestamp = @Timestamp
						AND		ISNULL(mpw.Deleted, 0) = 1)
	BEGIN
		DECLARE @CurrentMediaPlanDetailKey INT = -1

		WHILE 1=1
			BEGIN
				SELECT @CurrentMediaPlanDetailKey = MIN(MediaPlanDetailKey) 
				FROM	tMediaPlanDetailWorker mpw (NOLOCK)
				WHERE	mpw.CompanyKey = @CompanyKey 
				AND		mpw.MediaPlanKey = @MediaPlanKey
				AND		mpw.Timestamp = @Timestamp
				AND		ISNULL(mpw.Deleted, 0) = 1
				AND		MediaPlanDetailKey > @CurrentMediaPlanDetailKey
	
				IF @CurrentMediaPlanDetailKey IS NULL
					BREAK
			
				DECLARE @ReturnValue INT
				EXEC @ReturnValue = sptMediaPlanDetailDelete @CurrentMediaPlanDetailKey
    
				 IF @ReturnValue = -2
					BEGIN
						UPDATE tMediaPlanDetail 
						SET ErrMsgOrder = ''Cannot delete the line because it is linked to a Voucher Detail Line.'' 
						WHERE MediaPlanDetailKey = @CurrentMediaPlanDetailKey
					END
					ELSE IF @ReturnValue = -1
					BEGIN					
						UPDATE tMediaPlanDetail 
						SET ErrMsgOrder = ''Cannot delete the line due to an unspecified purchase order detail error.'' 
						WHERE MediaPlanDetailKey = @CurrentMediaPlanDetailKey
					END
			END
	END

	PRINT GETDATE()	
	PRINT ''--------------------------''
	PRINT ''Project Rollup''
	PRINT ''--------------------------''
	DECLARE @ProjectKey INT

	SELECT	@ProjectKey = ProjectKey
	FROM	tMediaPlan (NOLOCK)
	WHERE	MediaPlanKey = @MediaPlanKey

	 if @ProjectKey > 0  
	begin
		print ''Starting rollup''
		exec sptProjectRollupUpdate @ProjectKey, 5, 1, 1, 1, 1  
		print ''Rollup Done''
	end 


RETURN 1

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskUserAssign]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskUserAssign]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptTaskUserAssign]
	(
	@TaskKey int,
	@TaskUserKey int,
	@UserKey int,
	@TaskUserStatusKey int = NULL,
	@UseNewUserDefaultService tinyint = 0
	)
AS

/*
|| When      Who Rel      What
|| 07/31/14   QMD 10.5.8.2 Changed User.Today.MyTasks to today.creative.myTasks
|| 09/08/15   MCM 10.5.9.6 (268464) Updated logic for TaskUserKey is null
|| 04/26/16   GAR 10.6.0.3 Update TaskUserStatusKey if it is passed in
|| 03/25/25   RLB 25.04.20 (688773) pass in if using a customization to use user default service
|| 06/01/26   RLS 26.07.19 (729817) Protect against @TaskUserStatusKey being 0 (needs to be NULL for Default Status)
*/

Declare @ProjectKey int, @CompanyKey int, @TaskType int, @ServiceKey int, @Hours decimal(24,4)

IF @TaskUserStatusKey = 0
    SELECT @TaskUserStatusKey = NULL
Select @ProjectKey = ProjectKey, @TaskType = TaskType from tTask (nolock) Where TaskKey = @TaskKey
Select @ServiceKey = DefaultServiceKey, @CompanyKey = ISNULL(OwnerCompanyKey, CompanyKey) From tUser (nolock) Where UserKey = @UserKey

if @TaskType = 1
	return 1
	
	
if @TaskUserKey is not null
BEGIN
	if @UseNewUserDefaultService = 1
		Update tTaskUser 
		Set UserKey = @UserKey, 
			ServiceKey = ISNULL(@ServiceKey, ServiceKey),
			TaskUserStatusKey = @TaskUserStatusKey
		Where TaskUserKey = @TaskUserKey
	else
		Update tTaskUser 
		Set UserKey = @UserKey, 
			ServiceKey = ISNULL(ServiceKey, @ServiceKey),
			TaskUserStatusKey = @TaskUserStatusKey
		Where TaskUserKey = @TaskUserKey
END
ELSE
BEGIN
	Insert tTaskUser(TaskKey, UserKey, ServiceKey, Hours, TaskUserStatusKey)
	Values(@TaskKey, @UserKey, @ServiceKey, 0, @TaskUserStatusKey)
	Select @TaskUserKey = @@Identity
	
END

exec sptAppFavoriteInsert @CompanyKey, @UserKey, ''today.creative.myTasks'', @TaskUserKey
exec sptAssignmentInsertFromTask @ProjectKey, @UserKey

RETURN @TaskUserKey

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spProjectLoadTasks]'
GO
IF OBJECT_ID(N'[dbo].[spProjectLoadTasks]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[spProjectLoadTasks]
	(
	@ProjectKey int
	)
AS

/*
|| When       Who Rel      What
|| 05/11/10   CRG 10.5.2.2 Added IconID to the select list
|| 01/10/11   CRG 10.5.4.0 Added ProjectNumber, ProjectName, TaskColor
|| 03/20/11   GWG 10.5.4.2 Added Open To Do Count
|| 03/10/14   RLB 10.5.7.8 (196273) 
|| 07/07/15   RLB 10.5.9.4 Added Work Type ID and Name for plat
|| 07/30/15   RLB 10.5.9.4 Added a few items i had missed
|| 02/04/16   RLB 10.6.0.0 Added Fields for updating task in Plat
|| 02/16/16   CRG 10.6.0.1 Added TotalEstHours
|| 02/09/17   RLB 10.6.1.3 Added for enhancement 328679
|| 02/20/17   RLB 10.6.1.3 Added field for customization
|| 08/10/18   CRG 18.8.0.0 Added OrigPercComp so that we can track changed tasks in the schedule
|| 09/27/18   CRG 18.9.1.1 Now removing tasks with bad SummaryTaskKeys from the table prior to loading
|| 10/01/19   CRG 19.1.0.0 (480550) Now overriding a NULL SegmentColor with ProjectColor
|| 09/07/21   CRG 21.09.18 (569967) Added OrigActStart and OrigActComplete
|| 09/23/22   GAR 22.10.16 (DEV2605) Added AvalaraTaxCodeKey
|| 11/09/22   GAR 22.12.18 (618114) Added Conversation Count
|| 05/08/23   CRG 23.06.18 (604775) Changed Priority to TaskPriorityKey
|| 11/27/24   RLS 25.01.19 (685516) Added AllocatedHoursGross, SumRate and CurrentBudgetLaborGross
|| 12/17/25   CRG 26.02.15 (548907) Added FreqName and filtering out all but the current active recurring task
|| 04/15/26   GAR 26.05.17 (726555) Added DeliverableCount
|| 04/27/26   GAR 26.05.17 (727081) Added BudgetRemainingHours
|| 05/13/26   CRG 26.06.14 (724211) Added new recurring frequency options
*/

--Validate the SummaryTaskKeys
SELECT	TaskKey, SummaryTaskKey, RecurringFreq
INTO	#Keys
FROM	tTask (nolock)
WHERE	ProjectKey = @ProjectKey

IF EXISTS(
		SELECT	NULL
		FROM	#Keys
		WHERE	ISNULL(RecurringFreq, 0) > 0)
	DELETE	#Keys
	FROM	vTaskRecurringActive v
	INNER JOIN #Keys k ON v.TaskKey = k.TaskKey
	WHERE	ISNULL(v.RecurringFreq, 0) > 0
	AND		v.RecurringActive <> 1

SELECT	TaskKey
INTO	#BadKeys
FROM	#Keys
WHERE	SummaryTaskKey > 0
AND		SummaryTaskKey NOT IN (SELECT TaskKey FROM #Keys)

IF EXISTS (SELECT 1 FROM #BadKeys)
BEGIN
	DECLARE	@TaskKey int
	SELECT @TaskKey = -1

	WHILE(1=1)
	BEGIN
		SELECT	@TaskKey = MIN(TaskKey)
		FROM	#BadKeys
		WHERE	TaskKey > @TaskKey

		IF @TaskKey IS NULL
			BREAK

		EXEC sptTaskDelete @TaskKey
	END
END

select t.*
			,t.PercComp as OrigPercComp
			,t.ActStart as OrigActStart
			,t.ActComplete as OrigActComplete
			,t.EstHours as EstimateHours
			,t2.TaskName as SummaryTaskName
			,CASE WHEN t.TaskType = 2 THEN ''edit'' 
				  WHEN t.TaskType = 1 THEN 
										case when t.AllowAllocatedHours = 1 then ''edit''
										else '''' end
			 ELSE '''' END AS IconID
			,(select count(*) from tForm f (nolock) 
			   Where f.TaskKey = t.TaskKey 
			   and	f.DateClosed IS NULL) as FormCount
			,ISNULL((Select Sum(ActualHours) from tTime ti (nolock) 
				   Where ti.ProjectKey = t.ProjectKey 
				   And ti.TaskKey = t.TaskKey), 0) as ActualHours
			,ISNULL((Select Sum(Hours) from tTaskUser tau (nolock) 
					   Where tau.TaskKey = t.TaskKey), 0) as AllocatedHours
			,(select count(*) from tAttachment (nolock)
			   Where AssociatedEntity = ''Task'' AND
			   EntityKey = t.TaskKey) as AttachmentCount
			,(SELECT COUNT(*) FROM tActivity a (nolock) INNER JOIN tActivityLink al (nolock) ON a.ActivityKey = al.ActivityKey WHERE al.Entity = ''tTask'' AND al.EntityKey = t.TaskKey AND a.Completed = 0) AS OpenActivities
			,ISNULL((Select Count(*) from tActivity (nolock) Where ActivityEntity = ''ToDo'' and TaskKey = t.TaskKey and Completed = 0), 0) as ToDoCount
			, (SELECT COUNT(*) FROM tActivity a (nolock) WHERE a.TaskKey = t.TaskKey AND Completed = 0 AND a.ActivityEntity = ''ToDo'' AND ParentActivityKey = 0) AS OpenToDos
			,ISNULL(c.CompanyName, ''No Client'') AS CompanyName
			,p.ClientKey
			,ProjectNumber + '' - '' + ProjectName AS Project
			,p.ProjectNumber
			,p.ProjectName
			,p.CompanyKey
			,p.StartDate as ProjectStartDate
			,p.CompleteDate as ProjectCompleteDate
			,p.PercComp as ProjectPercComp
			,p.ProjectStatusKey
			,ps.ProjectStatus
			,ps.ProjectStatusID
			,pbs.ProjectBillingStatusKey
			,pbs.ProjectBillingStatus
			,pbs.ProjectBillingStatusID
			,ISNULL(u.UserName, ''No Account Manager'') AS UserName
			,u.UserKey as AccountManager
			,ISNULL(pt.ProjectTypeName, ''No Project Type'') AS ProjectTypeName
			,pt.ProjectTypeKey			
			,ISNULL(ca.CampaignName, ''No Campaign'') AS CampaignName
			,ca.CampaignKey
			,ISNULL(CAST(ts.SegmentColor as varchar), p.ProjectColor) AS TaskColor
			,ts.SegmentName
			,ISNULL(cps.SegmentName, ''No Campaign Segment'') AS CampaignSegmentName
			,cps.CampaignSegmentKey
			,wt.WorkTypeName
			,wt.WorkTypeID
			 ,CASE 
					WHEN ISNULL(t.TaskConstraint,0) = 0 THEN 
						CASE 
							WHEN p.ScheduleDirection = 1 THEN ''As Soon As Possible'' 
							ELSE ''As Late As Possible''
						END
					WHEN ISNULL(t.TaskConstraint,0) = 1 THEN ''Must Start On'' 
					WHEN ISNULL(t.TaskConstraint,0) = 2 THEN ''Must Finish On'' 
					WHEN ISNULL(t.TaskConstraint,0) = 3 THEN ''Finish No Earlier Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 4 THEN ''Finish No Later Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 5 THEN ''Start No Earlier Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 6 THEN ''Start No Later Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 7 THEN ''Duration Of Project''
					ELSE ''Client''
			  END AS ConstraintName
			,tp.PriorityName
			,CASE 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 0 THEN ''Any Day''
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 1 THEN ''Sunday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 2 THEN ''Monday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 3 THEN ''Tuesday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 4 THEN ''Wednesday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 5 THEN ''Thursday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 6 THEN ''Friday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 7 THEN ''Saturday'' 
					ELSE ''Any Day''
			  END AS ConstraintDayOfTheWeekName
			 ,CASE
				WHEN ISNULL(t.MoneyTask, 0) = 1 THEN ISNULL(t.ApprovedCOHours, 0) + ISNULL(t.EstHours, 0)
				ELSE 0
			  END AS TotalEstHours
			  ,ISNULL(tcps.ProjectStatus, '''') as TCProjectStatus
			  ,ISNULL(tcps.ProjectStatusID, '''') as TCProjectStatusID
			  , 0 as LagCustomizationSet
			  ,a.AvalaraTaxCode
			  ,ISNULL((Select count(*) from tActivity a (nolock) inner join tActivityLink al (nolock) on a.ActivityKey = al.ActivityKey  Where al.Entity = ''tTask'' and al.EntityKey = t.TaskKey and a.ParentActivityKey = 0 and a.ActivityEntity = ''Diary''), 0) as ConversationCount
			  ,ISNULL(p.EstLabor, 0)
			  ,ISNULL(tu.GrossAmount, 0) as AllocatedHoursGross
			  ,t.EstLabor + t.ApprovedCOLabor as CurrentBudgetLaborGross
			  ,CASE
				WHEN ISNULL(t.RecurringFreq, 0) = 0 THEN ''None''
				WHEN ISNULL(t.RecurringFreq, 0) = 1 THEN ''Weekly''
				WHEN ISNULL(t.RecurringFreq, 0) = 2 THEN ''Monthly (Date)''
				WHEN ISNULL(t.RecurringFreq, 0) = 3 THEN ''Monthly (Relative)''
				WHEN ISNULL(t.RecurringFreq, 0) = 4 THEN ''Quarterly''
			   END AS FreqName
			   ,(Select COUNT(*) from tReviewDeliverable (NOLOCK) Where ProjectKey = p.ProjectKey and TaskKey = tmp.TaskKey and tReviewDeliverable.Completed = 0) as DeliverableCount
			   ,(ISNULL(t.EstHours, 0) +  ISNULL(t.ApprovedCOHours, 0)) - (ISNULL((Select Sum(ActualHours) from tTime ti (nolock) Where ti.ProjectKey = t.ProjectKey And ti.TaskKey = t.TaskKey), 0)) as BudgetRemainingHours
   from #Keys tmp
   inner join tTask t (nolock) on tmp.TaskKey = t.TaskKey
   inner join tProject p (nolock) on t.ProjectKey = p.ProjectKey
   LEFT JOIN (
		SELECT SUM(GrossAmount) AS GrossAmount, TaskKey
		FROM (
			SELECT AHourlyRate * Hours AS GrossAmount, ttu.TaskKey
			FROM tTaskUser ttu (nolock) 
			INNER JOIN tTask tt (nolock) ON ttu.TaskKey = tt.TaskKey
			WHERE ProjectKey = @ProjectKey
		) tus
		GROUP BY TaskKey
	) tu ON t.TaskKey = tu.TaskKey
   left join tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
   left join tProjectStatus tcps (nolock) on t.TCProjectStatusKey = tcps.ProjectStatusKey
   left join tTimelineSegment ts (nolock) ON t.TimelineSegmentKey = ts.TimelineSegmentKey
   left join tProjectBillingStatus pbs (nolock) on p.ProjectBillingStatusKey = pbs.ProjectBillingStatusKey
   left join tTask t2 (nolock) ON t.SummaryTaskKey = t2.TaskKey
   left join tCompany c (nolock) ON p.ClientKey = c.CompanyKey
   left join vUserName u  (nolock) ON p.AccountManager = u.UserKey
   left join tProjectType pt (nolock) ON p.ProjectTypeKey = pt.ProjectTypeKey
   left join tCampaign ca (nolock) ON p.CampaignKey = ca.CampaignKey
   left join tCampaignSegment cps (nolock) ON p.CampaignSegmentKey = cps.CampaignSegmentKey
   left join tWorkType wt (nolock) on t.WorkTypeKey = wt.WorkTypeKey
   left join tAvalaraTaxCode a (nolock) on t.AvalaraTaxCodeKey = a.AvalaraTaxCodeKey
   left join tTaskPriority tp (nolock) on t.TaskPriorityKey = tp.TaskPriorityKey
  order by t.ProjectOrder

  '
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskUserStatusDelete]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskUserStatusDelete]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptTaskUserStatusDelete]
	@TaskUserStatusKey int
	,@NewTaskUserStatusKey int
	,@Entity varchar(50) = ''User''
	,@EntityKey int

AS
/*
|| When       Who Rel      What
|| 03/22/16   GAR 10.6.0.2 Added for deleting task user statuses
|| 06/01/26   RLS 26.07.19 (729817) Protect against @NewTaskUserStatusKey being 0 (needs to be NULL for Default Status)
*/
	DECLARE @IsDefault AS TINYINT

	IF @NewTaskUserStatusKey = 0
		SELECT @NewTaskUserStatusKey = NULL

	SET @IsDefault = (SELECT IsDefault FROM tTaskUserStatus WHERE TaskUserStatusKey = @TaskUserStatusKey)	

	DELETE
	FROM
		tTaskUserStatus
	WHERE
		TaskUserStatusKey = @TaskUserStatusKey 

--update display order
	UPDATE tTaskUserStatus 
	Set DisplayOrder = NewDisplayOrder
	FROM ( SELECT DisplayOrder,  ROW_NUMBER() OVER (Order by DisplayOrder) as NewDisplayOrder FROM tTaskUserStatus WHERE Entity = @Entity AND EntityKey = @EntityKey) tTaskUserStatus
	
	IF @IsDefault = 1
	BEGIN
		UPDATE tTaskUserStatus
		SET IsDefault = 1
		WHERE TaskUserStatusKey = @NewTaskUserStatusKey
	END
	
	UPDATE tTaskUser
	SET TaskUserStatusKey = @NewTaskUserStatusKey
	WHERE TaskUserStatusKey = @TaskUserStatusKey'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptActivityCopyFromTask]'
GO
IF OBJECT_ID(N'[dbo].[sptActivityCopyFromTask]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptActivityCopyFromTask]
	@CopyProjectKey int,
	@CopyFromTaskKey int,
	@NewProjectKey int,
	@NewTaskKey int,
	@UserKey int,
	@OnlyIfNewTaskHasNoToDos tinyint = 0
AS

/*
|| When      Who Rel      What
|| 07/12/10  CRG 10.5.3.2 Created to copy activities from one task to another
|| 08/15/10  GWG 10.5.3.3 Put in a check so that the from task has to be from a template project.
|| 03/21/12  GWG 10.554   Modified the call to copy activities so it will also copy project level todo''s
|| 11/04/14  GAR 10.585   (234258) Allow To Dos to be copied over whether they are copying from a project or a template.
||						  Before only To Dos that were being copied from a template were being copied.
|| 05/28/15  RLB 10.5.9.2 (258052) update the new activity with the old ones display order
|| 12/12/16  RLB 10.6.1.1 Do not add To do''s from any deliverable onto the project
|| 05/3/18   GWG 18.5.0   Filter out comments on todos
|| 06/24/22  GWG 22.6.1   (590887) Copying over the status of the todo
|| 09/27/23  RLB 23.10.15 (650872) Fix hole where to do status was complete but was not setting new to do completed
|| 02/04/25  RLS 25.03.16 (691960) Removed @ActivityDate from three places: (1) the DECLARE statement (2) the assignment/SELECT FROM tActivity (3) replaced it with NULL in the call to sptActivityUpdate
|| 07/30/25  AMP 25.08.17 (705266) Reviewed - No trigger change needed at this time - The process will work quick enough it''ll be covered through the Insert trigger. 
|| 05/27/26  CRG 26.07.19 (729099) Added optional parm to only copy to new task if it doesn''t already have To Dos.
*/

	

	DECLARE	@ActivityKey int,
			@NewActivityKey int,
			@CompanyKey int,
			@Private tinyint,
			@Type varchar(50),
			@Priority varchar(20),
			@Subject varchar(2000),
			@ContactCompanyKey int,
			@ContactKey int,
			@UserLeadKey int,
			@LeadKey int,
			@TaskKey int,
			@CMFolderKey int,
			@StandardActivityKey int,
			@ActivityTypeKey int,
			@AssignedUserKey int,
			@OriginatorUserKey int,
			@VisibleToClient tinyint,
			@Outcome smallint,
			@StartTime smalldatetime,
			@EndTime smalldatetime,
			@ReminderMinutes int

	if @CopyProjectKey = 0
		SELECT  @CopyProjectKey = ProjectKey from tTask (nolock) Where TaskKey = @CopyFromTaskKey
	
	-- (234258) Allow To Dos to be copied over even when they are not being copied over from a template.
	IF NOT EXISTS(Select 1 from tProject (nolock) Where ProjectKey = @CopyProjectKey) --and Template = 1)
		RETURN 1

	IF @NewTaskKey = 0
		SELECT @NewTaskKey = NULL

	IF @OnlyIfNewTaskHasNoToDos = 1 AND @NewTaskKey > 0
		IF EXISTS
				(SELECT NULL
				FROM	tActivity (nolock)
				WHERE	ISNULL(TaskKey, 0) = @NewTaskKey
				AND		ActivityEntity = ''ToDo'')
			RETURN 1

	SELECT	@ActivityKey = 0

	WHILE(1=1)
	BEGIN
		SELECT	@ActivityKey = MIN(ActivityKey)
		FROM	tActivity (nolock)
		WHERE	ProjectKey = @CopyProjectKey
		AND		ISNULL(TaskKey, 0) = @CopyFromTaskKey
		AND		ActivityEntity = ''ToDo''
		AND		ActivityKey > @ActivityKey
		AND     ISNULL(ReviewDeliverableKey, 0) = 0
		AND		ParentActivityKey = 0

		IF @ActivityKey IS NULL
			BREAK

		SELECT	@CompanyKey = CompanyKey,
				@UserKey = ISNULL(@UserKey, UpdatedByKey),
				@Private = Private,
				@Type = Type,
				@Priority = Priority,
				@Subject = Subject,
				@ContactCompanyKey = ContactCompanyKey,
				@ContactKey = ContactKey,
				@UserLeadKey = UserLeadKey,
				@LeadKey = LeadKey,
				@CMFolderKey = CMFolderKey,
				@StandardActivityKey = StandardActivityKey,
				@ActivityTypeKey = ActivityTypeKey,
				@AssignedUserKey = AssignedUserKey,
				@OriginatorUserKey = OriginatorUserKey,
				@VisibleToClient = VisibleToClient,
				@Outcome = Outcome,
				@StartTime = StartTime,
				@EndTime = EndTime,
				@ReminderMinutes = ReminderMinutes
		FROM	tActivity (nolock)
		WHERE	ActivityKey = @ActivityKey

		EXEC @NewActivityKey = sptActivityUpdate
				0,
				@CompanyKey,
				@UserKey,
				0, --ParentActivityKey
				0, --RootActivityKey
				@Private,
				@Type,
				@Priority,
				@Subject,
				@ContactCompanyKey,
				@ContactKey,
				@UserLeadKey,
				@LeadKey,
				@NewProjectKey,
				@NewTaskKey,
				@CMFolderKey,
				@StandardActivityKey,
				@ActivityTypeKey,
				@AssignedUserKey,
				@OriginatorUserKey,
				@VisibleToClient,
				@Outcome,
				NULL, --ActivityDate,
				@StartTime,
				@EndTime,
				@ReminderMinutes,
				0, --Completed
				NULL, --DateCompleted
				NULL, --Notes will be updated in the next statement because they''re text and can''t be stored in a local variable
				''ToDo''  --Force these over to a todo

		UPDATE	tActivity
		SET		tActivity.Notes = old.Notes,
				tActivity.DisplayOrder = old.DisplayOrder,
				tActivity.ActivityStatusKey = old.ActivityStatusKey
		FROM	tActivity (nolock), 
				tActivity old (nolock)
		WHERE	old.ActivityKey = @ActivityKey
		AND		tActivity.ActivityKey = @NewActivityKey

		UPDATE tActivity    
	    SET  tActivity.Completed = 1,    
			tActivity.DateCompleted = getutcdate()
	    FROM tActivity (NOLOCK),     
			tActivity old (NOLOCK),
			tActivityStatus ats (nolock)  
	    WHERE old.ActivityKey = @ActivityKey 	 
		 AND  tActivity.ActivityKey = @NewActivityKey  
		 AND old.ActivityStatusKey = ats.ActivityStatusKey
		 and  ats.IsCompleted = 1

		IF NOT EXISTS(
				SELECT	NULL
				FROM	tActivityLink al (nolock)
				WHERE	ActivityKey = @NewActivityKey
				AND		Entity = ''tProject''
				AND		EntityKey = @NewProjectKey)
			INSERT	tActivityLink
					(ActivityKey,
					Entity,
					EntityKey)
			VALUES	(@NewActivityKey,
					''tProject'',
					@NewProjectKey)

		IF @NewTaskKey IS NOT NULL
		BEGIN
			IF NOT EXISTS(
					SELECT	NULL
					FROM	tActivityLink al (nolock)
					WHERE	ActivityKey = @NewActivityKey
					AND		Entity = ''tTask''
					AND		EntityKey = @NewTaskKey)
				INSERT	tActivityLink
						(ActivityKey,
						Entity,
						EntityKey)
				VALUES	(@NewActivityKey,
						''tTask'',
						@NewTaskKey)
		END

		INSERT	tActivityEmail
				(ActivityKey,
				UserKey,
				UserLeadKey)
		SELECT	@NewActivityKey,
				UserKey,
				UserLeadKey
		FROM	tActivityEmail (nolock)
		WHERE	ActivityKey = @ActivityKey

	END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskUserStatusUpdate]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskUserStatusUpdate]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptTaskUserStatusUpdate]
(
    @TaskUserStatusKey int,
    @EntityKey int,
    @Entity varchar(50) = ''user'',
    @StatusName varchar(200),
    @IsDefault tinyint,
    @DisplayOrder int,
	@DefaultPercentComp int,
	@StatusColor varchar(30),
	@UpdatedFromKey int = 0
)

as
/*
|| When     Who Rel       What
|| 03/22/16 GAR 10.6.0.2  Added for updating task user statuses
|| 02/17/23 RLB 23.03.19  Added Status Color
|| 06/01/26 RLS 26.07.19  (729817) Protect against @UpdatedFromKey being 0 (needs to be NULL for Default Status)
||
*/

IF @UpdatedFromKey = 0
	SELECT @UpdatedFromKey = NULL

if (@IsDefault = 1)
	BEGIN
		UPDATE tTaskUserStatus SET IsDefault = 0 WHERE Entity = @Entity AND EntityKey = @EntityKey
	END

if ISNULL(@TaskUserStatusKey, 0) > 0
BEGIN
	UPDATE tTaskUserStatus
	   SET 
			StatusName = @StatusName,
			IsDefault = @IsDefault,
			DisplayOrder = @DisplayOrder,
			DefaultPercentComp = @DefaultPercentComp ,
			CompanyTaskUserStatusKey = @UpdatedFromKey,
			StatusColor = @StatusColor
	 WHERE TaskUserStatusKey = @TaskUserStatusKey
	 
	 --update display order
	UPDATE tTaskUserStatus 
	Set DisplayOrder = NewDisplayOrder
	FROM ( SELECT DisplayOrder,  ROW_NUMBER() OVER (Order by DisplayOrder) as NewDisplayOrder FROM tTaskUserStatus WHERE Entity = @Entity AND EntityKey = @EntityKey) tTaskUserStatus

END
ELSE
BEGIN
	INSERT INTO tTaskUserStatus
           (EntityKey
           ,Entity
           ,StatusName
           ,IsDefault
           ,DisplayOrder
           ,DefaultPercentComp
		   ,StatusColor
           ,CompanyTaskUserStatusKey)
     VALUES
           (@EntityKey
           ,@Entity
           ,@StatusName
           ,@IsDefault
           ,@DisplayOrder
           ,@DefaultPercentComp
		   ,@StatusColor
           ,@UpdatedFromKey)

	Select @TaskUserStatusKey = @@IDENTITY
	
	UPDATE tTaskUser
	SET TaskUserStatusKey = @TaskUserStatusKey
	FROM tTaskUser (NOLOCK)
		WHERE TaskUserStatusKey = @UpdatedFromKey

END

return @TaskUserStatusKey'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptReviewCommentGet]'
GO
IF OBJECT_ID(N'[dbo].[sptReviewCommentGet]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptReviewCommentGet]
 @ReviewDeliverableKey INT,
 @ReviewRoundKey INT,
 @UserKey INT,
 @AllowClientToViewAllComments tinyint = 0
 
AS --Encrypt

  /*
  || When		Who Rel			What
  || 01/01/12	RJE 10.5.x.x	Created for new ArtReview
  || 01/10/12   GWG 10.5.5.5    Added code to find the round in a number of ways
  || 02/15/12   QMD 10.5.5.5    Added logic to restrict attachments to external steps for client logins
  || 4/17/12    CRG 10.5.5.5    Returning the Project''s OfficeKey in case the office is using a different WebDAV server
  ||                            Added Src to the File and Attachment queries so that we can add the WebDAV URL in VB prior to sending it to the JS
  ||                            Added FileID to the Attachment query
  || 3/13/13    GWG 10.5.6.6    If there is no active step, getting the last step as we allow comments at any time now
  || 07/15/13	QMD 10.5.6.9    Fixed the approval step status description to match the code
  || 07/16/13	QMD 10.5.7.0    Changed Rejected status description to Changes Needed
  || 07/19/13	QMD 10.5.7.0    Added #ReviewKeys to limit the review markup get when clientlogin = 1
  || 09/06/13	QMD 10.5.7.1    Added Distinct to insert of review keys to eliminate duplicates
  || 02/27/14	QMD 10.5.7.7    Added Distinct to the clientvendorlogin
  || 05/28/14	QMD 10.5.8.0    Added ApprovalStepKey, MaxNumberOfRounds
  || 06/13/14	QMD 10.5.8.1    Added Approveral Select
  || 06/17/15   GAR 10.5.9.3	(259974) If logged in user is ClientVendorLogin then only grab parent comments (with any children) from either
  ||							that user or another user that is a ClientVendorLogin.  Before this change it was grabbing all comments
  ||							for a round where a comment from a ClientVendorLogin existed.
  || 10/22/15   RLB 10.5.9.8    Change made for campaign deliverables
  || 04/03/16   RJE 10.6.0.2    Change made to show user approved status
  || 04/07/16   GWG 10.6.0.3    Modified which rounds show for a user. If no routing, they can see even if they are not the active user or have seen it before.
  || 04/27/16   RJE 10.6.0.3    Add PageCount field for ReviewFile to support legacy comment
  || 06/30/16	QMD 10.6.0.5	added PasswordProtected
  || 08/08/16   GAR 10.6.0.7    DueDate should come from tApprovalStepUser
  || 10/17/16   CRG 10.6.0.9    Added TaskID and TaskName
  || 11/30/16   RLB 10.6.1.0    Change Decision to first check WithChanges so it can be either approved or approved with changes and few other changes
  || 01/25/16   CRG 10.6.1.2    Added sorting to approvers
  || 03/03/17   CRG 10.6.1.3    (335405) Added deliverable OwnerKey
  || 03/22/17   CRG 10.6.1.4    (338021) Added FileID to the file list query
  || 06/21/17   CRG 10.6.1.7    (351192) Added @AllowClientToViewAllComments to allow client logins to view all comments
  || 05/14/18   RLB 18.6.0.0    Added fields to comments for a To Do change
  || 10/01/18   RLB 18.9.1.0    (416614) Added client key 
  || 10/02/18   RLB 18.9.1.0    (416614) Added pulling of comment email to list from tMention
  || 08/26/19   RLB 19.0.7.0    (456099) pull all of the projects rounds for compare
  || 09/24/19   WDF 19.1.0.0    (480446) Added ''Order By rr.ReviewRoundKey'' to (456099) 
  || 10/02/19   GAR 19.1.0.0    (480953) Added ReviewDeliverableKey in the rounds table (last table) - same spot as 456099
  || 12/19/19   GAR 20.0.1.0    (492220) Added Owner Name for use in the round review screen 
  || 04/13/20   RLS 20.0.5.0    (509272) Added d.TaskKey
  || 06/03/20   GAR 20.0.7.0    (516648) Allow a ClientLogin to view all attachments on comments if AllowClientToViewAllComments is turned on
  || 06/10/20   RLB 20.0.7.0    (517015) For Compare pulls any rounds on that project that the client is on and there DateActive is not null
  || 12/02/20   GAR 20.1.2.0    (538759) Made a fix for client logins that can see their own comments, but not attachments in that comment
  || 01/15/20   RLB 21.01.24    (542787) Fixed round list showing rounds it should not
  || 01/04/22   RLS 22.01.23    (582003) Changed the --Get Approvers who approved section to join on vUserName to prevent null FullName
  || 03/18/24   RLB 24.04.14    (667109) Added review comment owner email to default them on replies
  || 06/09/26   RLS 26.07.19    (730013) Fixed DateDue ISNULL fallback to use step DueDate (aps.DueDate) instead of round sent date (r.DateSent)
  */
  -- Get the round info object
  
declare @RequestedRoundKey int, @PrivateCanView tinyint, @CanApprove tinyint, @ClientLogin tinyint, @ProjectKey int

if @ReviewRoundKey is null
BEGIN
	-- Just passed a deliverablekey, so find the round to show by the last completed review (non cancelled)
	Select @ReviewRoundKey = LastCompletedRoundKey
	From tReviewDeliverable (nolock) 
	Where ReviewDeliverableKey = @ReviewDeliverableKey

	if @ReviewRoundKey is null
		Select @ReviewRoundKey = Max(ReviewRoundKey)
		From tReviewRound (nolock) 
		Where ReviewDeliverableKey = @ReviewDeliverableKey
END

-- See if the user is a client login
if @UserKey = 0
	Select @ClientLogin = 1
else
	Select @ClientLogin = ISNULL(ClientVendorLogin, 0) from tUser Where UserKey = @UserKey


 -- Need to figure out which deliverable we are on
if @ReviewDeliverableKey is null
	Select @ReviewDeliverableKey = ReviewDeliverableKey from tReviewRound (nolock) Where ReviewRoundKey = @ReviewRoundKey

Select @ProjectKey = ProjectKey from tReviewDeliverable (nolock) Where ReviewDeliverableKey = @ReviewDeliverableKey

-- Is this person listed as an approver anywhere on this deliverable. If not and a login is required, then not allowed to view
if exists(Select 1 from tApprovalStepUser asu (nolock)
		inner join tApprovalStep tas (nolock) on asu.ApprovalStepKey = tas.ApprovalStepKey
		Where asu.AssignedUserKey = @UserKey and tas.Entity = ''tReviewRound'' and EntityKey in (Select ReviewRoundKey from tReviewRound (nolock) Where ReviewDeliverableKey = @ReviewDeliverableKey))
	Select @PrivateCanView = 1
Else
	Select @PrivateCanView = 0

-- See if the person viewing the review is the active approver
if exists(Select 1 From tApprovalStep aps (nolock)
			INNER JOIN tApprovalStepUser asu (nolock) on aps.ApprovalStepKey = asu.ApprovalStepKey
			Where aps.EntityKey = @ReviewRoundKey and aps.Entity = ''tReviewRound'' and ActiveStep = 1 and asu.AssignedUserKey = @UserKey and asu.ActiveUser = 1)
	SELECT @CanApprove = 1
ELSE
	SELECT @CanApprove = 0

Declare @ApprovalStepKey int

Select @ApprovalStepKey = ApprovalStepKey from tApprovalStep (nolock) Where Entity = ''tReviewRound'' and EntityKey = @ReviewRoundKey and ActiveStep = 1
if @ApprovalStepKey is null
	Select @ApprovalStepKey = Max(ApprovalStepKey) from tApprovalStep (nolock) Where Entity = ''tReviewRound'' and EntityKey = @ReviewRoundKey


if @ProjectKey > 0
BEGIN
	SELECT	r.*, p.ProjectKey, p.ProjectName, p.ProjectNumber, p.ClientKey, p.OfficeKey,
			ISNULL(p.ProjectNumber,'''') + '' - '' + ISNULL(p.ProjectName,'''')AS ProjectFormattedName,
			d.DeliverableName,
			CASE r.Status
				WHEN 1 THEN ''New''
				WHEN 2 THEN ''Submitted''
				WHEN 3 THEN ''Completed''
				WHEN 4 THEN ''Cancelled''
				ELSE ''Invalid Status ... Check SP''
			END AS StatusDescription,
			ISNULL(aps.Instructions, '''') AS Instructions,
			ISNULL(aps.ApprovalStepKey, 0) as CurrentStepKey,
			ISNULL(aps.LoginRequired, 1) as LoginRequired,
			@PrivateCanView as PrivateCanView,
			@CanApprove as CanApprove,
			@ClientLogin AS ClientLogin,
			CASE WHEN r.Status = 4 THEN 0 ELSE 1 END AS CanComment,
			aps.ApprovalStepKey,
			ISNULL(d.MaxNumberOfRounds,0) AS MaxNumberOfRounds,
            CASE asu.WithChanges
				WHEN 1 then case asu.Action when 1 then ''Approved With Changes'' when 2 then ''Changes Needed'' else '''' end
				ELSE case asu.Action when 1 then ''Approved'' when 2 then ''Changes Needed'' else '''' end
			END AS Decision,
			ISNULL(asu.DueDate, aps.DueDate) AS DateDue,
			t.TaskID,
			t.TaskName,
			d.TaskKey as ExistingTaskKey,
			d.OwnerKey,
			o.UserName AS OwnerName
	FROM tReviewRound r (NOLOCK) 
	INNER JOIN tReviewDeliverable d (NOLOCK) ON d.ReviewDeliverableKey = r.ReviewDeliverableKey
	INNER JOIN tProject p (NOLOCK) ON p.ProjectKey = d.ProjectKey
	LEFT OUTER JOIN tApprovalStep aps (NOLOCK) on r.ReviewRoundKey= aps.EntityKey and aps.Entity = ''tReviewRound'' and ApprovalStepKey = @ApprovalStepKey
	LEFT OUTER JOIN tApprovalStepUser asu (NOLOCK) on @UserKey = asu.AssignedUserKey AND @ApprovalStepKey = asu.ApprovalStepKey
	LEFT OUTER JOIN tTask t (NOLOCK) ON r.TaskKey = t.TaskKey
	LEFT OUTER JOIN vUserName o (NOLOCK) ON d.OwnerKey = o.UserKey
	WHERE		ReviewRoundKey = @ReviewRoundKey
END
ELSE
BEGIN
	SELECT	r.*, d.ProjectKey, c.CampaignKey, c.CampaignName, c.CampaignID,c.ClientKey, null as OfficeKey,
			ISNULL(c.CampaignID,'''') + '' - '' + ISNULL(c.CampaignName,'''')AS CampaignFormattedName,
			d.DeliverableName,
			CASE r.Status
				WHEN 1 THEN ''New''
				WHEN 2 THEN ''Submitted''
				WHEN 3 THEN ''Completed''
				WHEN 4 THEN ''Cancelled''
				ELSE ''Invalid Status ... Check SP''
			END AS StatusDescription,
			ISNULL(aps.Instructions, '''') AS Instructions,
			ISNULL(aps.ApprovalStepKey, 0) as CurrentStepKey,
			ISNULL(aps.LoginRequired, 1) as LoginRequired,
			@PrivateCanView as PrivateCanView,
			@CanApprove as CanApprove,
			@ClientLogin AS ClientLogin,
			CASE WHEN r.Status = 4 THEN 0 ELSE 1 END AS CanComment,
			aps.ApprovalStepKey,
			ISNULL(d.MaxNumberOfRounds,0) AS MaxNumberOfRounds,
			CASE asu.WithChanges
				WHEN 1 then case asu.Action when 1 then ''Approved With Changes'' when 2 then ''Changes Needed'' else '''' end
				ELSE case asu.Action when 1 then ''Approved'' when 2 then ''Changes Needed'' else '''' end
			END AS Decision,
			ISNULL(asu.DueDate, aps.DueDate) AS DateDue,
			t.TaskID,
			t.TaskName,
			d.TaskKey as ExistingTaskKey,
			d.OwnerKey,
			o.UserName AS OwnerName
	FROM tReviewRound r (NOLOCK) 
	INNER JOIN tReviewDeliverable d (NOLOCK) ON d.ReviewDeliverableKey = r.ReviewDeliverableKey
	INNER JOIN tCampaign c (NOLOCK) ON c.CampaignKey = d.ProjectKey * -1
	LEFT OUTER JOIN tApprovalStep aps (NOLOCK) on r.ReviewRoundKey= aps.EntityKey and aps.Entity = ''tReviewRound'' and ApprovalStepKey = @ApprovalStepKey
	LEFT OUTER JOIN tApprovalStepUser asu (NOLOCK) on @UserKey = asu.AssignedUserKey AND @ApprovalStepKey = asu.ApprovalStepKey
	LEFT OUTER JOIN tTask t (NOLOCK) ON r.TaskKey = t.TaskKey
	LEFT OUTER JOIN vUserName o (NOLOCK) ON d.OwnerKey = o.UserKey
	WHERE		ReviewRoundKey = @ReviewRoundKey

END

IF Object_Id(''tempdb..#ReviewCommentKeys'') IS NOT NULL  
  DROP TABLE #ReviewCommentKeys  

CREATE TABLE #ReviewCommentKeys(	
	[ReviewCommentKey] [int] NULL )
  
-- Get all comments for this round/step
IF @ClientLogin = 1 AND @AllowClientToViewAllComments = 0
	INSERT INTO #ReviewCommentKeys
	SELECT	DISTINCT rc.ParentCommentKey
	FROM	tReviewComment rc (NOLOCK) 
			LEFT OUTER JOIN tUser u (NOLOCK) on rc.UserKey = u.UserKey	
	WHERE	rc.ReviewRoundKey = @ReviewRoundKey
			AND	(u.UserKey is null OR u.ClientVendorLogin = 1 OR u.UserKey = @UserKey)
ELSE
	INSERT INTO #ReviewCommentKeys
	SELECT	DISTINCT rc.ReviewCommentKey
	FROM	tReviewComment rc (NOLOCK) 
	WHERE	rc.ReviewRoundKey = @ReviewRoundKey

SELECT	rc.*,
	 CASE asu.WithChanges
		WHEN 1 then case asu.Action when 1 then ''Approved With Changes'' when 2 then ''Changes Needed'' else '''' end
		ELSE case asu.Action when 1 then ''Approved'' when 2 then ''Changes Needed'' else '''' end
	END AS Status,
	act.ActivityStatusKey,
	ats.StatusName as ActivityStatusName,
	rco.Email as ReviewCommentOwnerEmail
	
FROM		tReviewComment rc (NOLOCK) 
	LEFT OUTER JOIN tApprovalStepUser asu (NOLOCK) on rc.UserKey = asu.AssignedUserKey AND rc.ApprovalStepKey = asu.ApprovalStepKey
	LEFT OUTER JOIN tActivity act (NOLOCK) on rc.ActivityKey = act.ActivityKey
	LEFT OUTER JOIN tActivityStatus ats (NOLOCK) on act.ActivityStatusKey = ats.ActivityStatusKey
	INNER JOIN #ReviewCommentKeys rk (NOLOCK) ON rc.ParentCommentKey = rk.ReviewCommentKey
	LEFT OUTER JOIN vUserName rco (NOLOCK) ON rc.UserKey = rco.UserKey
ORDER BY  rc.ParentCommentKey ASC, rc.ReviewCommentKey ASC
  
-- Get all markup for this round/step
SELECT	rm.*
FROM	tReviewCommentMarkup rm (NOLOCK) 
		INNER JOIN tReviewComment rc (NOLOCK) ON rm.ReviewCommentKey = rc.ReviewCommentKey
			OR rc.ParentCommentKey = rm.ReviewCommentKey
		INNER JOIN #ReviewCommentKeys rk (NOLOCK) ON rc.ReviewCommentKey = rk.ReviewCommentKey
			

-- Get the list of files for downloading
SELECT FilePath, IsURL, '''' AS Src, ReviewRoundFileKey, PageCount, PasswordProtected, FileID 
FROM tReviewRoundFile (NOLOCK)
WHERE ReviewRoundKey = @ReviewRoundKey
ORDER BY DisplayOrder

-- Get the Other Rounds for this deliverable
if @ClientLogin = 1
BEGIN
	SELECT	rc.ReviewCommentKey, a.AttachmentKey, FileName, Path, FileID, CASE WHEN CHARINDEX(''.'',REVERSE(FileName)) > 1 THEN LOWER( RIGHT(FileName, CHARINDEX(''.'',REVERSE(FileName))-1)) ELSE '''' END AS FileType, '''' AS Src
	FROM	tAttachment a (NOLOCK) 
				inner join tReviewComment rc (NOLOCK) on a.EntityKey = rc.ReviewCommentKey and a.AssociatedEntity = ''tReviewComment''
				inner join tApprovalStep tas (NOLOCK) on tas.Entity = ''tReviewRound'' and tas.ApprovalStepKey = rc.ApprovalStepKey
				inner join #ReviewCommentKeys rk (NOLOCK) ON rc.ParentCommentKey = rk.ReviewCommentKey
	WHERE	rc.ReviewRoundKey = @ReviewRoundKey 
				--516648 - GAR - Allow a ClientLogin to view all attachments on comments if AllowClientToViewAllComments is turned on
				and (tas.Internal = 0 OR @AllowClientToViewAllComments = 1 OR a.AddedBy = @UserKey)

	Select Distinct rr.ReviewRoundKey, Status, RoundName, Case When CancelledDate is null then 0 else 1 end as Cancelled, Case When rr.ReviewRoundKey = @ReviewRoundKey then 1 else 0 end as SelectedRound
	From tReviewRound rr (nolock)
	inner join tApprovalStep aps (nolock) on rr.ReviewRoundKey= aps.EntityKey and aps.Entity = ''tReviewRound''
	inner join tApprovalStepUser asu (nolock) on aps.ApprovalStepKey = asu.ApprovalStepKey
	Where ReviewDeliverableKey = @ReviewDeliverableKey and asu.AssignedUserKey = @UserKey and (aps.EnableRouting = 0 OR asu.CompletedUser = 1 OR asu.ActiveUser = 1)

	Order By ReviewRoundKey

	Select rd.ReviewDeliverableKey, rd.DeliverableName, ISNULL(rr.RoundName, ''Round 1'') as RoundName
	From tReviewDeliverable rd (nolock) 
	inner join tReviewRound rr (nolock) on rd.LastCompletedRoundKey = rr.ReviewRoundKey
	Where rd.ProjectKey = @ProjectKey
	and rd.ReviewDeliverableKey in (Select Distinct ReviewDeliverableKey from tReviewRound rr (nolock)
										inner join tApprovalStep a (nolock) on rr.ReviewRoundKey = a.EntityKey AND a.Entity = ''tReviewRound''
										inner join tApprovalStepUser asu (NOLOCK) on asu.ApprovalStepKey = a.ApprovalStepKey
										Where asu.AssignedUserKey = @UserKey and (a.EnableRouting = 0 OR asu.CompletedUser = 1 OR asu.ActiveUser = 1))
	Order By DeliverableName

END
ELSE
BEGIN
	SELECT ReviewCommentKey, a.AttachmentKey, FileName, Path, FileID, CASE WHEN CHARINDEX(''.'',REVERSE(FileName)) > 1 THEN LOWER( RIGHT(FileName, CHARINDEX(''.'',REVERSE(FileName))-1)) ELSE '''' END AS FileType, '''' AS Src
	From tAttachment a (nolock) 
	inner join tReviewComment rc (nolock) on a.EntityKey = rc.ReviewCommentKey and a.AssociatedEntity = ''tReviewComment''
	Where rc.ReviewRoundKey = @ReviewRoundKey

	Select rr.ReviewRoundKey, Status, RoundName, Case When CancelledDate is null then 0 else 1 end as Cancelled, Case When rr.ReviewRoundKey = @ReviewRoundKey then 1 else 0 end as SelectedRound
	From tReviewRound rr (nolock)
	Where ReviewDeliverableKey = @ReviewDeliverableKey
	Order By ReviewRoundKey


	Select rd.ReviewDeliverableKey, rd.DeliverableName, ISNULL(rr.RoundName, ''Round 1'') as RoundName
	From tReviewDeliverable rd (nolock) 
	left outer join tReviewRound rr (nolock) on rd.LastCompletedRoundKey = rr.ReviewRoundKey
	Where rd.ProjectKey = @ProjectKey and rd.ReviewDeliverableKey in (Select Distinct revD.ReviewDeliverableKey from tReviewRound rev (nolock)
																			inner join tReviewDeliverable revD on revD.ReviewDeliverableKey = rev.ReviewDeliverableKey
																			Where revD.ProjectKey = @ProjectKey)
	Order By DeliverableName
END


--Get Approvers who approved
SELECT	u.UserName AS FullName,
		CASE asu.WithChanges
		WHEN 1 then case asu.Action when 1 then ''Approved With Changes'' when 2 then ''Changes Needed'' else '''' end
		ELSE case asu.Action when 1 then ''Approved'' when 2 then ''Changes Needed'' else '''' end
		END AS Status
FROM	tApprovalStepUser asu (NOLOCK) INNER JOIN vUserName u (NOLOCK) ON asu.AssignedUserKey = u.UserKey
WHERE	ApprovalStepKey = @ApprovalStepKey
ORDER BY DisplayOrder

-- Get all review comments email to list
		SELECT mt.EntityKey as ReviewCommentKey, mt.TargetKey as UserKey, un.UserFullName as UserName, un.Email
		FROM		tMention mt(NOLOCK) 
		INNER JOIN #ReviewCommentKeys rk (NOLOCK) ON mt.EntityKey = rk.ReviewCommentKey AND mt.Entity = ''tReviewComment''
		LEFT OUTER JOIN vUserName  un (NOLOCK) ON mt.TargetKey = un.UserKey and mt.TargetType = ''User''

--456099 get all rounds for the project to compare
if @ClientLogin = 1
	if @ProjectKey > 0
		Select Distinct rr.ReviewRoundKey, Status, RoundName, Case When CancelledDate is null then 0 else 1 end as Cancelled, Case When rr.ReviewRoundKey = @ReviewRoundKey then 1 else 0 end as SelectedRound, Case When rr.ReviewDeliverableKey = @ReviewDeliverableKey then 1 else 0 end as SelectedDeliverable, rr.ReviewDeliverableKey
		From tReviewRound rr (nolock)
		inner join tApprovalStep aps (nolock) on rr.ReviewRoundKey= aps.EntityKey and aps.Entity = ''tReviewRound''
		inner join tApprovalStepUser asu (nolock) on aps.ApprovalStepKey = asu.ApprovalStepKey
		inner join tReviewDeliverable rd (nolock) on rr.ReviewDeliverableKey = rd.ReviewDeliverableKey
		Where rr.ReviewDeliverableKey in (Select Distinct revD.ReviewDeliverableKey from tReviewRound rev (nolock)
										  inner join tReviewDeliverable revD on revD.ReviewDeliverableKey = rev.ReviewDeliverableKey
										  Where revD.ProjectKey = @ProjectKey) 
		and asu.AssignedUserKey = @UserKey and asu.DateActivated IS NOT NULL 
		Order By rr.ReviewRoundKey
	else
		Select Distinct rr.ReviewRoundKey, Status, RoundName, Case When CancelledDate is null then 0 else 1 end as Cancelled, Case When rr.ReviewRoundKey = @ReviewRoundKey then 1 else 0 end as SelectedRound, 1 as SelectedDeliverable, rr.ReviewDeliverableKey
		From tReviewRound rr (nolock)
		inner join tApprovalStep aps (nolock) on rr.ReviewRoundKey= aps.EntityKey and aps.Entity = ''tReviewRound''
		inner join tApprovalStepUser asu (nolock) on aps.ApprovalStepKey = asu.ApprovalStepKey
		Where ReviewDeliverableKey = @ReviewDeliverableKey and asu.AssignedUserKey = @UserKey and asu.DateActivated IS NOT NULL 
		Order By rr.ReviewRoundKey
else
if @ProjectKey > 0
	Select rr.ReviewRoundKey, Status, rd.DeliverableName + '' - '' + rr.RoundName as RoundName, Case When CancelledDate is null then 0 else 1 end as Cancelled, Case When rr.ReviewRoundKey = @ReviewRoundKey then 1 else 0 end as SelectedRound, Case When rr.ReviewDeliverableKey = @ReviewDeliverableKey then 1 else 0 end as SelectedDeliverable, rr.ReviewDeliverableKey
	From tReviewRound rr (nolock)
	inner join tReviewDeliverable rd (nolock) on rr.ReviewDeliverableKey = rd.ReviewDeliverableKey
	Where rr.ReviewDeliverableKey in (Select Distinct revD.ReviewDeliverableKey from tReviewRound rev (nolock)
																			inner join tReviewDeliverable revD on revD.ReviewDeliverableKey = rev.ReviewDeliverableKey
																			Where revD.ProjectKey = @ProjectKey)
	Order By rr.ReviewRoundKey
else
	Select rr.ReviewRoundKey, Status, RoundName, Case When CancelledDate is null then 0 else 1 end as Cancelled, Case When rr.ReviewRoundKey = @ReviewRoundKey then 1 else 0 end as SelectedRound, 1 as SelectedDeliverable, rr.ReviewDeliverableKey
	From tReviewRound rr (nolock)
	Where ReviewDeliverableKey = @ReviewDeliverableKey
	Order By rr.ReviewRoundKey
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptUserGet]'
GO
IF OBJECT_ID(N'[dbo].[sptUserGet]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptUserGet]
  @UserKey int = 0,
  @UserID nvarchar(100) = NULL
AS --Encrypt

/*
  || When     Who Rel   What
  || 10/04/06 WES 8.35  Added ISNULL(u.AddressKey, c.DefaultAddressKey)
  || 7/17/07  CRG 8.5   (9833) Added UserName.
  || 06/23/08 GHL 10.500 Changed inner join with tCompany c to left outer join for contacts
  ||                    since u.CompanyKey is nullable now
  || 08/01/08 GWG 10.5  Added hooks to the folder
  || 06/18/09 QMD 10.5  Added join to tUserPreference to get Email info
  || 08/25/09 MFT 10.508 Added get by UserID logic
  || 02/09/11 RLB 10.542 (100772)Added vendor sales tax defaults
  || 04/14/11 GWG 10.543 Added default service
  || 08/31/11 GHL 10.547 Added ExpenseApprover name
  || 09/04/12 RLB 10.560 Added ServiceCode
  || 09/19/12 GHL 10.560 (154716) Added credit card approver name 
  || 12/15/13 GWG 10.575 Added Timezone to default over to the company
  || 04/23/14 QMD 10.579 Added UserToken
  || 05/22/14 CRG 10.580 Added DefaultCalendarName
  || 12/03/14 QMD 10.586 Changed UserToken to PublicUserToken
  || 02/10/15 GHL 10.589 Added billing title info for Abelson Taylor
  || 09/15/15 GWG 10.596 Added GL Company
  || 06/06/16 CRG 10.604 Added join to tCompany on OwnerCompanyKey for the TimeZone 
  ||                     (if a client user doesn''t have a TimeZone, and their Company doesn''t have a TimeZone, use the Owner Company''s TimeZone)
  || 12/09/16 GAR 10.611 Added security level for use in SecurityGroup lookup
  || 04/12/17 RLB 10.615 since files will blow an error if there is no timezone. if we do not find one i default EST
  || 04/17/17 GAR 10.615 (341152) Add office key, office ID, and office name for defaulting in new projects
  || 04/25/17 GWG 10.615 Added UserTimeZoneIndex to properly default through the levels of timezone.
  || 06/14/17 GAR 10.617 (349653) Added reminder type and backup approver for user settings.
  || 01/22/18 GWG 18.2.0 Added change desktop
  || 03/22/18 GHL 18.4.0 Removed OfficeKey because it is already part of tUser
  ||                     Added ClassName to set on lookups in Plat 
  || 04/05/18 GWG 18.5.0 Added Culture waterfall. User > Office > Preferences  (fixed to be userculture and office culture)
  || 04/30/18 GAR 18.5.0 (398155) Grab security group name for logging.
  || 05/03/18 GHL 18.5.0 (386867) Added department name to default it on expense receipts
  || 06/25/18 GHL 18.7.0 (407650) Added TimeApproverBackupApprover, this is the BackupApprover on the time approver user
  ||                     not the BackupApprover on the user
  || 7/26/19  RLS 19.0.8 (471116) Added cascading ActionID and ActionName
  || 12/06/19 RLB 20.0.1 (491317) changed action name to max because planning project is not getting displayed
  || 02/27/20 CRG 20.0.3.0 (503419) Added NULLIF to TimeZone column to handle if a user''s time zone is blanked out in the UI and a 0 is saved.
  || 05/15/20 KMC 20.0.7.0 Added GoogleCalendarAuthToken from tUserPreference for changes to Google OAuth
  || 08/01/20 MAS 20.0.8.0 Added APIAccessToken 
  || 08/25/21 WDF 21.0.9.0 (569419) Added UserFullName
  || 09/13/22 AMP 22.10.16 (612089) Removed u.* to eliminate the Encrypted Password from being returned
  || 04/07/23 CRG 23.05.14 (630097) Added TwoFactorAuth and TwoFactorSendPref 
  || 02/26/24 MCM 24.03.17 (664040) Made userID parameter a nvarchar
  || 12/18/20 RLB 25.01.19 (688771) added new fields SubscribeDiaryPA and SubscribeToDoPA
  || 2/1/25   GWG 25.02.16  Added in Theme calls
  || 05/20/25 CRG 25.06.15 (699112) Added SuspendAdmin
  || 10/10/25 KMC 25.11.16 (698233) Removed tUserPreference EmailMailBox, EmailUserID, and EmailPassword
  || 03/27/26 RLB 26.04.19 (720867) Added PrintCulture for printing
  || 06/12/26 GAR 26.07.19 (730742) Adding a user level permission, EnableAPIMCPUse, to allow a user to use the API or MCP
*/

 IF @UserKey = 0
 	BEGIN
		SELECT @UserKey = UserKey
		FROM tUser (nolock)
		WHERE UserID = @UserID
 	END

	SELECT
	 u.UserKey
	,u.CompanyKey
    ,u.FirstName
    ,u.MiddleName
    ,u.LastName
    ,u.Salutation
    ,u.DepartmentKey
    ,u.Phone1
    ,u.Phone2
    ,u.Cell
    ,u.Fax
    ,u.Pager
    ,u.Title
    ,u.Email
    ,u.SecurityGroupKey
    ,u.Administrator
    ,u.UserID    
    ,u.SystemID
    ,u.OwnerCompanyKey
    ,u.LastLogin
    ,u.ContactMethod
    ,u.Active
    ,u.AutoAssign
    ,u.NoUnassign
    ,u.HourlyRate
    ,u.HourlyCost
    ,u.TimeApprover
    ,u.ExpenseApprover
    ,u.POLimit
    ,u.BCLimit
    ,u.IOLimit
    ,u.VendorKey
    ,u.ClassKey
    ,u.CustomFieldKey
    ,u.InOutStatus
    ,u.InOutNotes
    ,u.UserDefined1
    ,u.UserDefined2
    ,u.UserDefined3
    ,u.UserDefined4
    ,u.UserDefined5
    ,u.UserDefined6
    ,u.UserDefined7
    ,u.UserDefined8
    ,u.UserDefined9
    ,u.UserDefined10
    ,u.OfficeKey
    ,u.RateLevel
    ,u.TrafficNotification
    ,u.ClientVendorLogin
    ,u.DateAdded
    ,u.DateUpdated
    ,u.TimeZoneIndex
    ,u.NumberOfAttempts
    ,u.Locked
    ,u.LastPwdChange
    ,u.Supervisor
    ,u.DefaultReminderTime
    ,u.LinkID
    ,u.AddressKey
    ,u.DefaultServiceKey
    ,u.SystemMessage
    ,u.GLCompanyKey
    ,u.MonthlyCost
    ,u.LastModified
    ,u.OwnerKey
    ,u.CMFolderKey
    ,u.DoNotCall
    ,u.DoNotEmail
    ,u.DoNotMail
    ,u.DoNotFax
    ,u.AddedByKey
    ,u.UpdatedByKey
    ,u.HomeAddressKey
    ,u.OtherAddressKey
    ,u.ClientDivisionKey
    ,u.ClientProductKey
    ,u.Department
    ,u.UserRole
    ,u.ReportsToKey
    ,u.Assistant
    ,u.AssistantPhone
    ,u.AssistantEmail
    ,u.Birthday
    ,u.SpouseName
    ,u.Children
    ,u.Anniversary
    ,u.Hobbies
    ,u.Comments
    ,u.UserCompanyName
    ,u.LastActivityKey
    ,u.NextActivityKey
    ,u.DefaultCMFolderKey
    ,u.WWPCurrentLevel
    ,u.DefaultCalendarColor
    ,u.DateConverted
    ,u.DefaultContactCMFolderKey
    ,u.SyncMLDirection
    ,u.CalendarReminder
    ,u.DateLeadCreated
    ,u.QuickMeeting
    ,u.LinkedCompanyAddressKey
    ,u.MarketingMessage
    ,u.SubscribeDiary
    ,u.SubscribeToDo
	,u.SubscribeDiaryPA
    ,u.SubscribeToDoPA
    ,u.DeliverableReviewer
    ,u.DeliverableNotify
    ,u.RightLevel
    ,u.Contractor
    ,u.RequireUserTimeDetails
    ,u.CreditCardApprover
    ,u.BackupApprover
    ,u.DateHired
    ,u.ExternalMarketingKey
    ,u.LanguageID
    ,u.ForcePwdChangeOnNextLogin
    ,u.Uid
    ,u.OriginalVCard
    ,u.GoogleAuthToken
    ,u.GoogleAuthTokenExpires
    ,u.GoogleRefreshToken
    ,u.GoogleRefreshTokenExpires
    ,u.TitleKey
    ,u.InvoiceEmails
    ,u.TwitterID
    ,u.LinkedInURL
    ,u.Signature
    ,u.DefaultActionID
    ,u.SignatureFont
    ,u.LoggedOut
    ,u.RequestToken
    ,u.UserDesktopImage
    ,u.UserCulture
    ,u.SSOAutoUpdateOff
    ,u.SupervisorKey
    ,u.SubscribeFileUpload
    ,u.SlackMemberID
    ,u.SSOAuthenticationOff
    ,u.VendorCost
    ,u.OvertimeCost
    ,u.OvertimeVendorCost,
	ISNULL(u.FirstName, '''') + '' '' + ISNULL(u.LastName, '''') AS UserName,
	CASE
		WHEN u.FirstName IS NULL AND u.LastName IS NULL THEN NULL
		ELSE
		CASE 
			WHEN u.MiddleName IS NULL THEN LTRIM(RTRIM(ISNULL(u.FirstName,'''') + '' '' + ISNULL(u.LastName,''''))) 
			ELSE LTRIM(RTRIM(ISNULL(u.FirstName,'''') + '' '' + SUBSTRING(u.MiddleName, 1, 1) + '' '' + ISNULL(u.LastName,''''))) 
		END 
	END AS UserFullName,			
	v.VendorID,
	v.CompanyName as VendorName,
	cl.ClassID,
	cl.ClassName,
	c.CustomerID as ClientID,
	c.CompanyName,
	c.CustomLogo,
	v.VendorSalesTaxKey,
	v.VendorSalesTax2Key,
	st.SalesTaxID,
	st.SalesTaxName,
	st.TaxRate,
	st.PiggyBackTax,
	st2.SalesTaxID as SaleTax2ID,
	st2.SalesTaxName as SaleTax2Name,
	st2.TaxRate as TaxRate2,
	st2.PiggyBackTax as PiggyBackTax2,
	ad.AddressName,
	ad.Address1,
	ad.Address2,
	ad.Address3,
	ad.City,
	ad.State,
	ad.Country,
	ad.PostalCode,
	c.Phone,
	f.UserKey as FolderUserKey,
	s.ServiceKey,
	s.Description as ServiceDescription,
	s.ServiceCode,
	ISNULL(uea.FirstName, '''') + '' '' + ISNULL(uea.LastName, '''') AS ExpenseApproverName,
	ISNULL(ucca.FirstName, '''') + '' '' + ISNULL(ucca.LastName, '''') AS CreditCardApproverName,
	ISNULL(uba.FirstName, '''') + '' '' + ISNULL(uba.LastName, '''') AS BackupApproverName,
	ISNULL(ISNULL(ISNULL(NULLIF(u.TimeZoneIndex, 0), c.TimeZoneIndex), oc.TimeZoneIndex), 35) as TimeZone,
	ISNULL(u.UserCulture, ISNULL(o.OfficeCulture, p.Culture)) as Culture,
	ISNULL(o.OfficeCulture, p.Culture) as PrintCulture,
	up.PublicUserToken,
	p.APIAccessToken,
	cal.FolderName AS DefaultCalendarName,
	t.TitleID,
	t.TitleName,
	ISNULL(u.DefaultActionID, ISNULL(sg.DefaultActionID,''today.creative'')) as ActionID,
	ISNULL((Select Max(Label) from tAppMenu (nolock) Where Entity = ''System'' and ActionID = ISNULL(u.DefaultActionID, sg.DefaultActionID)), ''Today - Creative'') as ActionName,
	gl.GLCompanyID,
	gl.GLCompanyName,
	sg.SecurityLevel,
	sg.ChangeDesktop,
	o.OfficeID,
	o.OfficeName,
	CASE 
		WHEN ISNULL(u.CalendarReminder,0) = 0 THEN ''Both Email and Popup'' 
		WHEN ISNULL(u.CalendarReminder,0) = 1 THEN ''Email Only'' 
		WHEN ISNULL(u.CalendarReminder,0) = 2 THEN ''Popup Only'' 
		WHEN ISNULL(u.CalendarReminder,0) = 3 THEN ''None'' 
		ELSE ''Both Email and Popup''
	END AS ReminderType,
	sg.GroupName,
	d.DepartmentName,
	uta.BackupApprover as TimeApproverBackupApprover,
	ISNULL(up.GoogleCalendarAuthToken, u.GoogleAuthToken) AS GoogleCalendarAuthToken,
	p.TwoFactorAuth,
	u.TwoFactorSendPref,
	ISNULL(u.Theme, 0) as Theme,
	Case ISNULL(u.Theme, 0) When 1 then ''Next Era'' when 2 then ''Next Era Dark'' when 3 then ''Moody Blues'' when 4 then ''Workamajig Classic'' end as ThemeName,
	u.SuspendAdmin,
	u.EnableAPIMCPUse
	FROM	tUser u (nolock)
			left outer join tCompany c (NOLOCK) on u.CompanyKey = c.CompanyKey
			left outer join tCompany oc (nolock) ON u.OwnerCompanyKey = oc.CompanyKey
			left outer join tCompany v (NOLOCK) on u.VendorKey = v.CompanyKey
			left outer join tClass cl (NOLOCK) on u.ClassKey = cl.ClassKey
			left outer join tAddress ad (nolock) on ISNULL(u.AddressKey, c.DefaultAddressKey) = ad.AddressKey
			left outer join tCMFolder f (nolock) on u.CMFolderKey = f.CMFolderKey
			left outer join tUserPreference up (nolock) on u.UserKey = up.UserKey
			left outer join tSalesTax st (nolock) on v.VendorSalesTaxKey = st.SalesTaxKey
			Left outer join tSalesTax st2 (nolock) on v.VendorSalesTax2Key = st2.SalesTaxKey
			left outer join tService s (nolock) on u.DefaultServiceKey = s.ServiceKey
			left outer join tUser uea (nolock) on u.ExpenseApprover = uea.UserKey
			left outer join tUser ucca (nolock) on u.CreditCardApprover = ucca.UserKey
			left outer join tUser uba (nolock) on u.BackupApprover = uba.UserKey
			left outer join tUser uta (nolock) on u.TimeApprover = uta.UserKey  -- this is to get to the backup of the time approver
			left outer join tPreference p (nolock) on ISNULL(u.OwnerCompanyKey, u.CompanyKey) = p.CompanyKey
			left outer join tCMFolder cal (nolock) ON u.DefaultCMFolderKey = cal.CMFolderKey
			left outer join tTitle t (nolock) on u.TitleKey = t.TitleKey
			left outer join tGLCompany gl (nolock) on u.GLCompanyKey = gl.GLCompanyKey
			left outer join tSecurityGroup sg (nolock) on u.SecurityGroupKey = sg.SecurityGroupKey
			left outer join tOffice o (nolock) on u.OfficeKey = o.OfficeKey
			LEFT OUTER JOIN tDepartment d (NOLOCK) ON u.DepartmentKey = d.DepartmentKey
	WHERE	u.UserKey = @UserKey

 RETURN 1


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spConvertDB1892]'
GO
IF OBJECT_ID(N'[dbo].[spConvertDB1892]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER procedure [dbo].[spConvertDB1892]
as

-- GHL: added checks in case we run this several times

-- seed the 2 new rights to edit IO and BO after approval - issue 424497
if not exists (select 1 from tRightAssigned (nolock) where RightKey = 500011)
insert tRightAssigned (EntityType, EntityKey, RightKey)
select EntityType, EntityKey, 500011 --''media_editio_approved
from tRightAssigned where RightKey = 500010 -- ''media_editio
and EntityKey >0

-- issue 424497
if not exists (select 1 from tRightAssigned (nolock) where RightKey = 500021)
insert tRightAssigned (EntityType, EntityKey, RightKey)
select EntityType, EntityKey, 500021 --''media_editbc_approved
from tRightAssigned where RightKey = 500020 -- ''media_editbc
and EntityKey >0


-- seed the right for a new quest report for issue 423844
if not exists (select 1 from tRightAssigned (nolock) where RightKey = 99500001)
insert tRightAssigned (EntityType, EntityKey, RightKey)
select ra.EntityType, ra.EntityKey, 99500001 --''questvouchersrpt
from tRightAssigned ra
inner join tSecurityGroup sg (nolock) on ra.EntityKey = sg.SecurityGroupKey
inner join tCompany c (nolock) on sg.CompanyKey = c.CompanyKey
where ra.RightKey = 950001 -- ''acct_ap_listing
and  c.CompanyKey = 5 -- Quest on App22
and  c.CompanyName like ''Quest%'' -- to filter out other company 5 on other servers


-- seed the new right to View VI on approval
if not exists (select 1 from tRightAssigned (nolock) where RightKey = 60301)
insert tRightAssigned (EntityType, EntityKey, RightKey)
select EntityType, EntityKey, 60301 --''purch_viewvoucher
from tRightAssigned where RightKey = 60300 -- ''purch_editvoucher
and EntityKey > 0

-- for issue 427056, seed that field to 1 for Ackerman
update tPreference
set    tPreference.KeepEstimateRates = 1
from   tCompany c (nolock)
where  tPreference.CompanyKey = c.CompanyKey
and    c.CompanyName like ''Ackerman McQueen%''

-- for Issue 424927,seed the new right to View PO on approval
if not exists(select 1 from tRightAssigned (nolock) where  RightKey = 60302)
insert tRightAssigned (EntityType, EntityKey, RightKey)
select EntityType, EntityKey, 60302 --''purch_viewpo
from tRightAssigned where RightKey = 60100 -- ''purch_editpo
and EntityKey > 0




Declare @CompanyKey int, @UserKey int 
Select @CompanyKey = -1
While 1=1
BEGIN
	Select @CompanyKey = MIN(CompanyKey) from tCompany (NOLOCK) Where OwnerCompanyKey is null and Locked = 0 and CompanyKey > @CompanyKey
		if @CompanyKey is null
			break



	if not exists(Select 1 from tReport Where CompanyKey = @CompanyKey and ReportType = 3)
	BEGIN
		Select @UserKey = MIN(UserKey) from tUser Where CompanyKey = @CompanyKey and Administrator = 1 and Active = 1 and UserID is not null

	
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''Time by Person'',''Time by Person'',2,''AdminDash'',''Show hours for people on active projects'',0,5,6,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="User Name" Key="PK48910" groupBy="3" columnHeading="User Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48911" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" values="1" calcAfter="0" name="Client Name" promptText="Client Name Equal To" Key="-1"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="1" values="1" calcAfter="0" name="Project Number" promptText="Project Number Equal To" Key="-2"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="2" values="1" calcAfter="0" name="Account Manager" promptText="Account Manager Equal To" Key="-3"></condition><condition calculated="0" dataType="String" andOr="and" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="YES" dataTypeLabel="Text" prompt="0" batch="3" values="1" calcAfter="0" name="Active Project" Key="-4"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Between" condition="3" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="4" values="2" calcAfter="0" name="Date Worked" promptText="Date Worked Between" Key="-5"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  13,''Opportunities by Stage'',''Opportunities by Stage'',0,''AdminDash'',NULL,0,0,6,5,''Bar'',''Stages'',''Sales'',12,20000,10000,''<fields><field dataType="string" name="Lead Stage" Key="PK49868" groupBy="3" columnHeading="Lead Stage"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Forecasted Sale Amount" Key="PK49869" groupBy="6" columnHeading="Forecasted Sale Amount"></field><field dataType="string" groupBy="3" name="Opportunity Owner Name" columnHeading="Opportunity Owner Name"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="YES" dataTypeLabel="Text" prompt="0" batch="0" values="1" calcAfter="0" name="Lead Status Active" Key="-6"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  36,''Amount Adv Billed'',''Amount Adv Billed'',1,''AdminDash'',NULL,6,0,6,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK49623" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Advance Billed" Key="PK49624" groupBy="6" columnHeading="Amount Advance Billed"></field></fields>'',''<conditions><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="-1" inputType="text" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Amount Advance Billed] Greater Than" leftParenthesis="" values="1" name="[Amount Advance Billed]" rightParenthesis=""></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''My Non-Billable Time'',''My Non-Billable Time'',0,''CreativeDash'',NULL,4,0,4,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK52600" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Non Billable Hours" Key="PK52601" groupBy="6" columnHeading="Actual Non Billable Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''My Hours By Service - YTD'',''My Hours By Service - YTD'',1,''CreativeDash'',NULL,0,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK49812" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49834" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="2"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''Invoice Aging'',''Invoice Aging'',2,''BillingDash'',NULL,0,0,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Due Date Aging" Key="PK49746" groupBy="3" columnHeading="Due Date Aging"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK49747" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Open" promptText="Amount Open Not Equal To" Key="-1"></condition><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Equal To" condition="1" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="1" values="1" calcAfter="0" name="Account Manager" promptText="Account Manager Equal To" Key="-2"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''Amount Open'',''Amount Open'',2,''BillingDash'',NULL,4,0,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK50647" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Open" Key="PK50648" groupBy="6" columnHeading="Amount Open"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Open" promptText="Amount Open Not Equal To" Key="-3"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''Revenue YTD'',''Revenue YTD'',2,''BillingDash'',NULL,0,10,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK51547" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK51548" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-4"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''Revenue MTD'',''Revenue MTD'',2,''BillingDash'',NULL,0,5,4,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK52628" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK52629" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Month To Date" andOr="and" condition="19" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Invoice Date" promptText="Invoice Date Month To Date" values="0" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''AM Revenue MTD'',''AM Revenue MTD'',2,''BillingDash'',NULL,4,5,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK48662" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK48663" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Month To Date" andOr="or" condition="19" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="1" andOrLabel="OR" calcAfter="0" name="Invoice Date" promptText="Invoice Date Month To Date" values="0" Key="1"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Between" condition="3" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" values="2" calcAfter="0" name="Invoice Date" promptText="Invoice Date Between" Key="-1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''AM Revenue YTD'',''AM Revenue YTD'',2,''BillingDash'',NULL,4,10,4,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK54554" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK54555" groupBy="6" columnHeading="Amount Total"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-7"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''Billing By Month'',''Billing By Month'',1,''BillingDash'',NULL,0,15,8,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Invoice Month" Key="PK1759" groupBy="3" columnHeading="Invoice Month"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK1760" groupBy="6" columnHeading="Amount Total"></field><field dataType="string" groupBy="3" name="Account Manager" columnHeading="Account Manager"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Total" promptText="Amount Total Not Equal To" Key="-1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Service'',''YTD Hours By Service'',1,''PMnDash'',NULL,0,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK51546" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK51547" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Client'',''YTD Hours By Client'',1,''PMnDash'',NULL,0,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK52509" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK52531" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''YTD Hours By Account Manager'',''YTD Hours By Account Manager'',1,''PMnDash'',NULL,5,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK48845" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48846" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  23,''Tasks Due Today By Person'',''Tasks Due Today By Person'',1,''PMnDash'',NULL,5,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Plan Completion Date" Key="PK1567292" groupBy="3" columnHeading="Plan Completion Date"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Total Allocated Hours" Key="PK1567293" groupBy="6" columnHeading="Total Allocated Hours"></field><field dataType="string" groupBy="3" name="Assigned People" columnHeading="Assigned People"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Blank" condition="24" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Actual Completion Date" promptText="Actual Completion Date Blank" Key="-1"></condition><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Today" condition="21" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="3" values="0" calcAfter="0" name="Plan Completion Date" promptText="Plan Completion Date Today" Key="-2"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''My Billable Time'',''My Billable Time'',0,''CreativeDash'',NULL,0,0,4,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK53436" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Billable Hours" Key="PK53437" groupBy="6" columnHeading="Actual Billable Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Is Me" values="0" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''My Billable Status - YTD'',''My Billable Status - YTD'',4,''CreativeDash'',''This report shows total hours worked this year by person. It breaks out their billable and non billable time.'',5,4,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK49620" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49621" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Billing Status" columnHeading="Billing Status"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="text" parameter1="" dataTypeLabel="Date" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" values="0" Key="2"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''Time Detail Data'',''Time Detail Data'',1,''PMnDash'',NULL,0,8,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="User Name" Key="PK50644" groupBy="3" columnHeading="User Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Billable Hours" Key="PK50645" groupBy="6" columnHeading="Actual Billable Hours"></field><field dataType="string" groupBy="3" name="Service Description" columnHeading="Service Description"></field></fields>'',''<conditions></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  37,''Project Completion Percentage'',''Project Completion Percentage'',1,''RMDash'',NULL,0,3,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Project Name" Key="PK1507516" groupBy="3" columnHeading="Project Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Percentage Complete" Key="PK1507517" groupBy="4" columnHeading="Percentage Complete"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="2018-06-26T00:00:00" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="2018-05-01T00:00:00" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Last Task Due Date" promptText="Last Task Due Date Between" values="2" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  62,''Allocated Hours by Assigned User'',''Allocated Hours by Assigned User'',1,''RMDash'',NULL,0,0,5,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Assigned User" Key="PK54646" groupBy="3" columnHeading="Assigned User"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Allocated Hours" Key="PK54647" groupBy="6" columnHeading="Allocated Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="Int32" parameter2="" conditionName="Less Than" andOr="and" condition="6" inputType="number" parameter1="100" dataTypeLabel="Number" prompt="0" batch="0" step="1" andOrLabel="AND" calcAfter="0" name="Percentage Complete" promptText="Percentage Complete Less Than" values="1" Key="1"></condition><condition calculated="1" dataType="string" parameter2="" conditionName="Does Not Contain" andOr="and" condition="14" Key="2" inputType="text" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Assigned User] Does Not Contain" leftParenthesis="" values="1" name="[Assigned User]" rightParenthesis=""></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''Actual Hours Worked'',''Actual Hours Worked'',1,''RMDash'',NULL,5,0,4,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Service Description" Key="PK1509353" groupBy="3" columnHeading="Service Description"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK1509354" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".0001" andOrLabel="AND" calcAfter="0" name="Actual Hours Worked" promptText="Actual Hours Worked Greater Than" values="1" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''Time Per Week YTD'',''Time Per Week YTD'',1,''CreativeDash'',NULL,0,8,12,3,''Line'','''','''',12,0,0,''<fields><field dataType="string" name="Date Worked Week Formatted" Key="PK1787" groupBy="3" columnHeading="Date Worked Week Formatted"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK1788" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Billing Status" columnHeading="Billing Status"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="User Name" promptText="User Name Is Me" values="0" Key="1"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="or" condition="20" inputType="date" parameter1="" dataTypeLabel="Date" prompt="0" batch="1" step="1" andOrLabel="OR" calcAfter="0" name="Date Worked" promptText="Date Worked Year To Date" leftParenthesis="(" values="0" Key="2"></condition><condition calculated="0" dataType="Date" parameter2="" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="" dataTypeLabel="Date" prompt="1" batch="2" andOrLabel="AND" calcAfter="0" name="Date Worked" promptText="Date Worked Between" values="2" Key="3" rightParenthesis=")"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  8,''Open Invoices By Vendor'',''Open Invoices By Vendor'',1,''PurchasingDash'',NULL,6,0,6,4,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Vendor Name" Key="PK55385" groupBy="3" columnHeading="Vendor Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Invoice Amount Open" Key="PK55386" groupBy="6" columnHeading="Invoice Amount Open"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".0001" andOrLabel="AND" calcAfter="0" name="Invoice Amount Open" promptText="Invoice Amount Open Greater Than" values="1" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  7,''Open Orders by Client'',''Open Orders by Client'',1,''PurchasingDash'',NULL,0,0,6,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK1508571" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Line Total Amount Billable" Key="PK1508572" groupBy="6" columnHeading="Line Total Amount Billable"></field></fields>'',''<conditions><condition calculated="0" dataType="String" conditionName="Equal To" andOr="and" condition="1" inputType="lookup.General" parameter1="Open Approved" dataTypeLabel="Text" datasource="_vl886" batch="0" andOrLabel="AND" calcAfter="0" prompt="0" name="Status" values="1" Key="1"></condition><condition calculated="0" dataType="Decimal" parameter2="" conditionName="Greater Than" andOr="and" condition="5" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="1" step=".0001" andOrLabel="AND" calcAfter="0" name="Remaining PO Amount" promptText="Remaining PO Amount Greater Than" values="1" Key="2"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  61,''Open Quotes By Vendor'',''Open Quotes By Vendor'',1,''PurchasingDash'',NULL,0,4,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Vendor Name" Key="PK1509536" groupBy="3" columnHeading="Vendor Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Quote Number" Key="PK1509537" groupBy="6" columnHeading="Quote Number"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Not Equal To" andOr="and" condition="2" inputType="lookup.General" parameter1="Closed" dataTypeLabel="Text" datasource="_vl886" batch="0" andOrLabel="AND" calcAfter="0" prompt="0" name="Status" promptText="Status Not Equal To" values="1" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''Client Invoice Level Data'',''Client Invoice Level Data'',4,''AccountingDash'',NULL,0,0,5,6,''Bar'',''Account Manager'',''Invoiced Amount'',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK1575662" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Billed" Key="PK1575663" groupBy="6" columnHeading="Amount Billed"></field><field dataType="string" groupBy="3" name="Client Name" columnHeading="Client Name"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="06/27/2018" conditionName="Between" andOr="and" condition="3" inputType="date" parameter1="01/01/2017" dataTypeLabel="Date" prompt="0" batch="2" andOrLabel="AND" calcAfter="0" name="Invoice Date" promptText="Invoice Date Between" values="2" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1004,''Client Invoice Level Data'',''Client Invoice Level Data'',1,''AccountingDash'',NULL,5,0,6,6,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Project Number" Key="PK1573989" groupBy="3" columnHeading="Project Number"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Total" Key="PK1574011" groupBy="6" columnHeading="Amount Total"></field><field dataType="string" groupBy="3" name="Account Manager" columnHeading="Account Manager"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Year To Date" condition="20" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="Invoice Date" promptText="Invoice Date Year To Date" Key="-7"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  24,''Tasks Due Date With Allocated Hours'',''Tasks Due Date With Allocated Hours'',1,''RMDash'',NULL,0,6,12,3,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Plan Completion Date" Key="PK1569924" groupBy="3" columnHeading="Plan Completion Date"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Allocated Hours" Key="PK1569925" groupBy="6" columnHeading="Allocated Hours"></field><field dataType="string" groupBy="3" name="Client Name" columnHeading="Client Name"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" andOr="and" parameter2="" conditionName="Blank" condition="24" andOrLabel="AND" inputType="text" parameter1="" dataTypeLabel="Text" prompt="0" batch="2" values="0" calcAfter="0" name="Actual Completion Date" promptText="Actual Completion Date Blank" Key="-2"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  13,''Forcasted Closed Amount By Account Manager - YTD'',''Forcasted Closed Amount By Account Manager - YTD'',1,''SalesDash'',NULL,0,0,5,4,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Manager" Key="PK50832" groupBy="3" columnHeading="Account Manager"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Forecasted Sale Amount" Key="PK50833" groupBy="6" columnHeading="Forecasted Sale Amount"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Year To Date" andOr="and" condition="20" inputType="text" parameter1="" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Forecasted Close Date" promptText="Forecasted Close Date Year To Date" values="0" Key="1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  16,''GL Transaction Detail Data'',''GL Transaction Detail Data'',1,''OwnerDash'',NULL,0,0,7,5,''Bar'','''','''',12,0,0,''<fields><field dataType="string" name="Account Type" Key="PK48633" groupBy="3" columnHeading="Account Type"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Transaction Amount" Key="PK48634" groupBy="6" columnHeading="Transaction Amount"></field></fields>'',''<conditions><condition calculated="1" dataType="number" parameter2="" conditionName="Not Equal To" andOr="and" condition="2" Key="-1" inputType="text" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Transaction Amount] Not Equal To" leftParenthesis="" values="1" name="[Transaction Amount]" rightParenthesis=""></condition></conditions>'')

		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  41,''Order Detail Accrual Data'',''Order Detail Accrual Data'',1,''MediaDash'',NULL,0,0,6,5,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Client Name" Key="PK49716" groupBy="3" columnHeading="Client Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Amount Accrued" Key="PK49717" groupBy="6" columnHeading="Amount Accrued"></field></fields>'',''<conditions><condition calculated="0" dataType="Decimal" andOr="and" parameter2="" conditionName="Not Equal To" condition="2" andOrLabel="AND" inputType="text" parameter1="0" dataTypeLabel="Text" prompt="0" batch="0" step=".0001" values="1" calcAfter="0" name="Amount Accrued" promptText="Amount Accrued Not Equal To" Key="-1"></condition></conditions>'')

		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  36,''Hours Items/Services'',''Hours Items/Services'',1,''CreativeDash'',''Sherry'',0,11,12,3,''Pie'','''','''',12,0,0,''<fields><field dataType="string" name="Item Name" Key="PK1513197" groupBy="3" columnHeading="Item Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours" Key="PK1513198" groupBy="6" columnHeading="Actual Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="Date" parameter2="" conditionName="Is On Or After" andOr="and" condition="17" inputType="date" parameter1="" dataTypeLabel="Date" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="Project Start Date" promptText="Project Start Date Is On Or After" values="1" Key="1"></condition></conditions>'')

		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  30,''Time Entered On Time by User'',''Time Entered On Time by User'',1,''AdminDash'',''Test'',0,9,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="User Full Name" Key="PK48658" groupBy="3" columnHeading="User Full Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48659" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Time Entered On Time" columnHeading="Time Entered On Time"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Any Of" andOr="and" condition="26" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Any Of" values="1" Key="1"></condition><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="2" inputType="number" parameter1="0" dataTypeLabel="Number" prompt="0" batch="0" step=".01" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Actual Hours Worked] Greater Than" leftParenthesis="" values="1" name="[Actual Hours Worked]" rightParenthesis=""></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  30,''Time Enterted on Time Global View'',''Time Enterted on Time Global View'',1,''AdminDash'',''NULL'',0,0,5,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Entered On Time" Key="PK52475" groupBy="3" columnHeading="Time Entered On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK52476" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  30,''Time Sheet Submitted on Time by User'',''Time Sheet Submitted on Time by User'',1,''AdminDash'',''NULL'',0,12,12,3,''Bar'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="User Full Name" Key="PK48843" groupBy="3" columnHeading="User Full Name"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK48844" groupBy="6" columnHeading="Actual Hours Worked"></field><field dataType="string" groupBy="3" name="Time Sheet Submitted On Time" columnHeading="Time Sheet Submitted On Time"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Any Of" andOr="and" condition="26" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="1" batch="0" andOrLabel="AND" calcAfter="0" name="User Full Name" promptText="User Full Name Any Of" values="1" Key="1"></condition><condition calculated="1" dataType="number" parameter2="" conditionName="Greater Than" andOr="and" condition="5" Key="2" inputType="number" parameter1="40" dataTypeLabel="Number" prompt="0" batch="0" step=".01" andOrLabel="AND" calcAfter="1" newItem="0" promptText="[Actual Hours Worked] Greater Than" leftParenthesis="" values="1" name="[Actual Hours Worked]" rightParenthesis=""></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1,''Time Entered On Time'',''Time Entered On Time'',1,''CreativeDash'',''NULL'',0,14,4,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Entered On Time" Key="PK49592" groupBy="3" columnHeading="Time Entered On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Actual Hours Worked" Key="PK49593" groupBy="6" columnHeading="Actual Hours Worked"></field></fields>'',''<conditions><condition calculated="0" dataType="String" andOr="and" parameter2="" conditionName="Is Me" condition="29" andOrLabel="AND" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" values="0" calcAfter="0" name="User Name" promptText="User Name Is Me" Key="-1"></condition></conditions>'')
		Insert tReport(CompanyKey, UserKey, ReportType, ViewKey, Name, ReportHeading1, ReportHeading1Align, ReportID, Description, XPos, YPos, Width, Height, DisplayType, XAxisLabel, YAxisLabel, MaxItemCount, DataTargetUpper, DataTargetLower, FieldDefinition, ConditionDefinition)
		VALUES (@CompanyKey, @UserKey, 3,  1014,''Timesheet Submitted on Time'',''Timesheet Submitted on Time'',1,''CreativeDash'',''NULL'',4,14,5,5,''Pie'',''NULL'',''NULL'',12,0,0,''<fields><field dataType="string" name="Time Sheet Submitted On Time" Key="PK50677" groupBy="3" columnHeading="Time Sheet Submitted On Time"></field><field dataType="decimal" sortOrder="1" sortDirection="2" name="Total Hours" Key="PK50678" groupBy="6" columnHeading="Total Hours"></field></fields>'',''<conditions><condition calculated="0" dataType="String" parameter2="" conditionName="Is Me" andOr="and" condition="29" inputType="lookup.User" parameter1="" dataTypeLabel="Text" prompt="0" batch="0" andOrLabel="AND" calcAfter="0" name="Name" promptText="Name Is Me" values="0" Key="1"></condition></conditions>'')



		Insert tRptSecurityGroup(ReportKey, SecurityGroupKey) 
		Select ReportKey, sg.SecurityGroupKey
		From tReport r (NOLOCK)
		inner join tSecurityGroup sg (NOLOCK) on r.CompanyKey = sg.CompanyKey
		Where r.CompanyKey = @CompanyKey and r.ReportType = 3

		Update tReport Set
		Private = 1, Orientation = 0, GroupBy = 1, ShowConditions = 0, LockedColumns = 0, Deleted = 0, AutoRun = 1, ApplicationVersion = 2, RunCnt = 0,  LastModified = GETUTCDATE(),  DateAdded = GETUTCDATE(),  DateModified = GETUTCDATE(), AddedBy = @UserKey, ModifiedBy = @UserKey
		Where CompanyKey = @CompanyKey and ReportType = 3

	END

END





'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAIGetCorporatePL]'
GO
IF OBJECT_ID(N'[dbo].[spApiAIGetCorporatePL]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER Procedure [dbo].[spApiAIGetCorporatePL]
(
    @CompanyKey            int,
    @UserKey               int,
    @StartDate             datetime,                       -- required: period start
    @EndDate               datetime,                       -- required: period end
    @PriorStartDate        datetime    = null,             -- optional: prior-period start (drives comparison)
    @PriorEndDate          datetime    = null,             -- optional: prior-period end
    @GLCompanyIDs          varchar(max) = null,            -- comma/pipe list of tGLCompany.GLCompanyID
    @OfficeIDs             varchar(max) = null,            -- comma/pipe list of tOffice.OfficeID
    @ClassIDs              varchar(max) = null,            -- comma/pipe list of tClass.ClassID
    @DepartmentNames       varchar(max) = null,            -- comma/pipe list of tDepartment.DepartmentName  (no ID column)
    @AccrualBasis          bit         = 1,                -- 1 = accrual (default), 0 = cash basis
    @CashBasisLegacy       bit         = 0,                -- cash-basis variant (engine-specific)
    @RunInGLCHomeCurrency  bit         = 0                 -- 1 = report in GLCompany home currency (single-company filter only)
)
as --Encrypt

/*
|| When      Who Rel        What
|| 05/24/26  AI  26.05.24   Created — API-friendly wrapper around spRptCorpPLAccrual / spRptCorpPLCash.
||                          Returns 3 result sets: warnings, meta, lines.
||                          All filters accept string IDs (or names for departments); resolved internally.
||                          Computes synthetic subtotal rows: Gross Profit, Net Operating Income, Net Income.
|| 07/07/26  MCM 26.07.x    (732349) Updated case for the raw.Minor gorup for Expenses and OtherIncome 
*/

set nocount on

    declare @SecurityGroupKey    int
    declare @IsAdministrator     bit
    declare @RestrictToGLCompany tinyint
    declare @MultiCurrency       tinyint
    declare @HomeCurrencyID      varchar(10)
    declare @EffectiveCurrencyID varchar(10)
    declare @CanRunPL            bit
    declare @ErrorCount          int
    declare @ResolvedGLCount     int
    declare @SingleGLCompanyKey  int
    declare @GLCHomeCurrencyID   varchar(10)

    -- ------------------------------------------------------------------
    -- 1. Errors / warnings staging
    -- ------------------------------------------------------------------
    select * into #errors from tAPIErrorTemplate where 1 = 2

    -- ------------------------------------------------------------------
    -- 2. Validate required inputs
    -- ------------------------------------------------------------------
    if @StartDate is null or @EndDate is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''REQUIRED_FIELD'', ''startDate and endDate are required.'', ''startDate'')
    end
    else if @EndDate < @StartDate
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''INVALID_VALUE'', ''endDate must be on or after startDate.'', ''endDate'')
    end

    if (@PriorStartDate is null and @PriorEndDate is not null)
        or (@PriorStartDate is not null and @PriorEndDate is null)
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''INVALID_VALUE'', ''priorStartDate and priorEndDate must be supplied together.'', ''priorStartDate'')
    end
    else if @PriorStartDate is not null and @PriorEndDate < @PriorStartDate
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''INVALID_VALUE'', ''priorEndDate must be on or after priorStartDate.'', ''priorEndDate'')
    end

    -- ------------------------------------------------------------------
    -- 3. Load user + security context
    -- ------------------------------------------------------------------
    select @SecurityGroupKey = SecurityGroupKey,
           @IsAdministrator  = Administrator
    from tUser (nolock)
    where UserKey    = @UserKey
      and CompanyKey = @CompanyKey

    if @SecurityGroupKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''User not found or invalid UserKey.'', ''general'')

        select errorType, errorCode, errorMessage, fieldName
        from #errors
        order by errorType desc, fieldName

        drop table #errors
        return -101
    end

    -- ------------------------------------------------------------------
    -- 4. Right check: acct_gl_pl_ytd (admin bypass)
    -- ------------------------------------------------------------------
    set @CanRunPL = 0
    if @IsAdministrator = 1
        set @CanRunPL = 1
    else if exists (
        select 1
        from tRight r (nolock)
        inner join tRightAssigned ra (nolock) on r.RightKey = ra.RightKey
        where ra.EntityType = ''Security Group''
          and ra.EntityKey  = @SecurityGroupKey
          and r.RightID     = ''acct_gl_pl_ytd''
    )
        set @CanRunPL = 1

    if @CanRunPL = 0
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''ACCESS_DENIED'', ''User does not have permission to run the Corporate P&L (acct_gl_pl_ytd).'', ''general'')

        select errorType, errorCode, errorMessage, fieldName
        from #errors
        order by errorType desc, fieldName

        drop table #errors
        return -103
    end

    -- ------------------------------------------------------------------
    -- 5. Bail on validation errors
    -- ------------------------------------------------------------------
    select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
    if @ErrorCount > 0
    begin
        select errorType, errorCode, errorMessage, fieldName
        from #errors
        order by errorType desc, fieldName

        drop table #errors
        return -102
    end

    -- ------------------------------------------------------------------
    -- 6. Preferences
    -- ------------------------------------------------------------------
    select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0),
           @MultiCurrency       = ISNULL(MultiCurrency, 0),
           @HomeCurrencyID      = CurrencyID
    from tPreference (nolock)
    where CompanyKey = @CompanyKey

    set @RestrictToGLCompany = ISNULL(@RestrictToGLCompany, 0)
    set @MultiCurrency       = ISNULL(@MultiCurrency, 0)
    set @EffectiveCurrencyID = @HomeCurrencyID

    -- ------------------------------------------------------------------
    -- 7. Build the four engine temp tables. Empty = "all".
    -- ------------------------------------------------------------------
    create table #GLCompanyKeys  (GLCompanyKey  int null)
    create table #OfficeKeys     (OfficeKey     int null)
    create table #ClassKeys      (ClassKey      int null)
    create table #DepartmentKeys (DepartmentKey int null)

    -- Required by spRptBalanceSheetRevaluation (called inside spRptCorpPLAccrual
    -- when MultiCurrency = 1). Engine will populate from exchange table if empty.
    create table #revaluerate (
        CurrencyID    varchar(10)   null,
        PreviousRate  decimal(24,7) null,
        CurrentRate   decimal(24,7) null
    )

    -- GL Companies
    if @GLCompanyIDs is not null and LTRIM(RTRIM(@GLCompanyIDs)) <> ''''
    begin
        set @GLCompanyIDs = replace(@GLCompanyIDs, ''|'', '','')

        insert into #GLCompanyKeys (GLCompanyKey)
        select gc.GLCompanyKey
        from tGLCompany gc (nolock)
        inner join dbo.fSplitVals(@GLCompanyIDs, '','') s
            on UPPER(LTRIM(RTRIM(gc.GLCompanyID))) = UPPER(LTRIM(RTRIM(s.value)))
        where gc.CompanyKey = @CompanyKey

        if not exists (select 1 from #GLCompanyKeys)
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''warning'', ''NOT_FOUND'', ''No GL companies matched the supplied glCompanyIDs.'', ''glCompanyIDs'')
    end

    -- Offices
    if @OfficeIDs is not null and LTRIM(RTRIM(@OfficeIDs)) <> ''''
    begin
        set @OfficeIDs = replace(@OfficeIDs, ''|'', '','')

        insert into #OfficeKeys (OfficeKey)
        select o.OfficeKey
        from tOffice o (nolock)
        inner join dbo.fSplitVals(@OfficeIDs, '','') s
            on UPPER(LTRIM(RTRIM(o.OfficeID))) = UPPER(LTRIM(RTRIM(s.value)))
        where o.CompanyKey = @CompanyKey

        if not exists (select 1 from #OfficeKeys)
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''warning'', ''NOT_FOUND'', ''No offices matched the supplied officeIDs.'', ''officeIDs'')
    end

    -- Classes
    if @ClassIDs is not null and LTRIM(RTRIM(@ClassIDs)) <> ''''
    begin
        set @ClassIDs = replace(@ClassIDs, ''|'', '','')

        insert into #ClassKeys (ClassKey)
        select c.ClassKey
        from tClass c (nolock)
        inner join dbo.fSplitVals(@ClassIDs, '','') s
            on UPPER(LTRIM(RTRIM(c.ClassID))) = UPPER(LTRIM(RTRIM(s.value)))
        where c.CompanyKey = @CompanyKey

        if not exists (select 1 from #ClassKeys)
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''warning'', ''NOT_FOUND'', ''No GL classes matched the supplied classIDs.'', ''classIDs'')
    end

    -- Departments (resolved by name; tDepartment has no ID column)
    if @DepartmentNames is not null and LTRIM(RTRIM(@DepartmentNames)) <> ''''
    begin
        set @DepartmentNames = replace(@DepartmentNames, ''|'', '','')

        insert into #DepartmentKeys (DepartmentKey)
        select d.DepartmentKey
        from tDepartment d (nolock)
        inner join dbo.fSplitVals(@DepartmentNames, '','') s
            on UPPER(LTRIM(RTRIM(d.DepartmentName))) = UPPER(LTRIM(RTRIM(s.value)))
        where d.CompanyKey = @CompanyKey

        if not exists (select 1 from #DepartmentKeys)
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''warning'', ''NOT_FOUND'', ''No departments matched the supplied departmentNames.'', ''departmentNames'')
    end

    -- ------------------------------------------------------------------
    -- 8. Validate @RunInGLCHomeCurrency request
    --    Engine only supports it for exactly one GLCompany whose home
    --    currency differs from the main co''s home currency.
    -- ------------------------------------------------------------------
    if @RunInGLCHomeCurrency = 1
    begin
        select @ResolvedGLCount = COUNT(*),
               @SingleGLCompanyKey = MAX(GLCompanyKey)
        from #GLCompanyKeys

        if @ResolvedGLCount <> 1
        begin
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''warning'', ''INVALID_VALUE'',
                    ''runInGLCHomeCurrency requires exactly one glCompanyID. Falling back to main home currency.'',
                    ''runInGLCHomeCurrency'')
            set @RunInGLCHomeCurrency = 0
        end
        else
        begin
            select @GLCHomeCurrencyID = CurrencyID
            from tGLCompany (nolock)
            where GLCompanyKey = @SingleGLCompanyKey

            if @GLCHomeCurrencyID is null or @GLCHomeCurrencyID = @HomeCurrencyID
            begin
                insert into #errors (errorType, errorCode, errorMessage, fieldName)
                values (''warning'', ''INVALID_VALUE'',
                        ''The chosen GL company does not have a distinct home currency. Reporting in main home currency.'',
                        ''runInGLCHomeCurrency'')
                set @RunInGLCHomeCurrency = 0
            end
            else
                set @EffectiveCurrencyID = @GLCHomeCurrencyID
        end
    end

    -- ------------------------------------------------------------------
    -- 9. Pull current-period totals into #PLRaw
    -- ------------------------------------------------------------------
    create table #PLRaw (
        GLAccountKey      int          null,
        ParentAccountKey  int          null,
        DisplayOrder      int          null,
        DisplayLevel      int          null,
        Rollup            tinyint      null,
        EBITDAAccount     tinyint      null,
        MinorGroup        int          null,
        Amount            decimal(20,4) null
    )

    if @AccrualBasis = 1
    begin
        insert into #PLRaw (GLAccountKey, ParentAccountKey, DisplayOrder, DisplayLevel, Rollup, EBITDAAccount, MinorGroup, Amount)
        exec spRptCorpPLAccrual
             @CompanyKey           = @CompanyKey,
             @StartDate            = @StartDate,
             @EndDate              = @EndDate,
             @UserKey              = @UserKey,
             @TranCountOnly        = 0,
             @RunInGLCHomeCurrency = @RunInGLCHomeCurrency
    end
    else
    begin
        insert into #PLRaw (GLAccountKey, ParentAccountKey, DisplayOrder, DisplayLevel, Rollup, EBITDAAccount, MinorGroup, Amount)
        exec spRptCorpPLCash
             @CompanyKey      = @CompanyKey,
             @StartDate       = @StartDate,
             @EndDate         = @EndDate,
             @UserKey         = @UserKey,
             @TranCountOnly   = 0,
             @CashBasisLegacy = @CashBasisLegacy
    end

    -- ------------------------------------------------------------------
    -- 10. Optional prior-period pull (for delta display)
    -- ------------------------------------------------------------------
    create table #PLPrior (
        GLAccountKey int          null,
        Amount       decimal(20,4) null
    )

    if @PriorStartDate is not null
    begin
        declare @TmpPrior table (
            GLAccountKey      int,
            ParentAccountKey  int,
            DisplayOrder      int,
            DisplayLevel      int,
            Rollup            tinyint,
            EBITDAAccount     tinyint,
            MinorGroup        int,
            Amount            decimal(20,4)
        )

        if @AccrualBasis = 1
        begin
            insert into @TmpPrior (GLAccountKey, ParentAccountKey, DisplayOrder, DisplayLevel, Rollup, EBITDAAccount, MinorGroup, Amount)
            exec spRptCorpPLAccrual
                 @CompanyKey           = @CompanyKey,
                 @StartDate            = @PriorStartDate,
                 @EndDate              = @PriorEndDate,
                 @UserKey              = @UserKey,
                 @TranCountOnly        = 0,
                 @RunInGLCHomeCurrency = @RunInGLCHomeCurrency
        end
        else
        begin
            insert into @TmpPrior (GLAccountKey, ParentAccountKey, DisplayOrder, DisplayLevel, Rollup, EBITDAAccount, MinorGroup, Amount)
            exec spRptCorpPLCash
                 @CompanyKey      = @CompanyKey,
                 @StartDate       = @PriorStartDate,
                 @EndDate         = @PriorEndDate,
                 @UserKey         = @UserKey,
                 @TranCountOnly   = 0,
                 @CashBasisLegacy = @CashBasisLegacy
        end

        insert into #PLPrior (GLAccountKey, Amount)
        select GLAccountKey, Amount
        from @TmpPrior
    end

    -- ------------------------------------------------------------------
    -- 11. Build the decorated line set (account info + amount + prior)
    -- ------------------------------------------------------------------
    create table #Lines (
        ord                int,
        accountKey         int            null,
        accountNumber      varchar(100)   null,
        accountName        nvarchar(200)  null,
        accountType        varchar(20)    null,
        section            varchar(20)    null,
        parentAccountKey   int            null,
        level              int            null,
        displayOrder       int            null,
        isRollup           bit            null,
        isEBITDA           bit            null,
        amount             decimal(20,4)  null,
        priorPeriodAmount  decimal(20,4)  null
    )

    insert into #Lines
        (ord, accountKey, accountNumber, accountName, accountType, section,
         parentAccountKey, level, displayOrder, isRollup, isEBITDA, amount, priorPeriodAmount)
    select
        -- Order: MinorGroup × 1000 leaves room to splice subtotal rows in step 12
        (raw.MinorGroup * 1000) + raw.DisplayOrder                        as ord,
        case when raw.GLAccountKey < 0 then null else raw.GLAccountKey end as accountKey,
        gl.AccountNumber                                                  as accountNumber,
        case
            when raw.GLAccountKey = -1 then ''Bank Revaluation''
            when raw.GLAccountKey = -2 then ''Unrealized Currency Gains''
            else gl.AccountName
        end                                                               as accountName,
        case raw.MinorGroup
            when 1 then ''Income''
            when 2 then ''COGS''
            when 3 then ''Expense''
            when 4 then ''OtherIncome''
            when 5 then ''OtherExpense''
        end                                                               as accountType,
        case raw.MinorGroup
            when 1 then ''Income''
            when 2 then ''COGS''
            when 3 then ''Expense''
            when 4 then ''OtherIncome''
            when 5 then ''OtherExpense''
        end                                                               as section,
        ISNULL(raw.ParentAccountKey, 0)                                   as parentAccountKey,
        ISNULL(raw.DisplayLevel, 0)                                       as [level],
        raw.DisplayOrder                                                  as displayOrder,
        cast(ISNULL(raw.Rollup, 0)        as bit)                         as isRollup,
        cast(ISNULL(raw.EBITDAAccount, 0) as bit)                         as isEBITDA,
        ROUND(ISNULL(raw.Amount, 0), 2)                                   as amount,
        ROUND(prior.Amount, 2)                                            as priorPeriodAmount
    from #PLRaw raw
    left join tGLAccount gl (nolock) on raw.GLAccountKey = gl.GLAccountKey
                                    and gl.CompanyKey   = @CompanyKey
    left join #PLPrior  prior        on raw.GLAccountKey = prior.GLAccountKey

    -- ------------------------------------------------------------------
    -- 12. Synthetic subtotal rows: Gross Profit, Net Operating Income, Net Income
    --     Sign convention: income/COGS/expense already returned positive by
    --     the engine; signs below reflect the natural P&L roll-up.
    -- ------------------------------------------------------------------
    declare @Income       decimal(20,4),
            @COGS         decimal(20,4),
            @OtherIncome  decimal(20,4),
            @Expense      decimal(20,4),
            @OtherExpense decimal(20,4),
            @PriorIncome       decimal(20,4),
            @PriorCOGS         decimal(20,4),
            @PriorOtherIncome  decimal(20,4),
            @PriorExpense      decimal(20,4),
            @PriorOtherExpense decimal(20,4)

    -- Section totals = sum of LEAF rows only (parent rows are already rolled up
    -- and would double-count if added).
    select
        @Income       = SUM(case when section = ''Income''       and isRollup = 0 then amount else 0 end),
        @COGS         = SUM(case when section = ''COGS''         and isRollup = 0 then amount else 0 end),
        @OtherIncome  = SUM(case when section = ''OtherIncome''  and isRollup = 0 then amount else 0 end),
        @Expense      = SUM(case when section = ''Expense''      and isRollup = 0 then amount else 0 end),
        @OtherExpense = SUM(case when section = ''OtherExpense'' and isRollup = 0 then amount else 0 end),
        @PriorIncome       = SUM(case when section = ''Income''       and isRollup = 0 then ISNULL(priorPeriodAmount, 0) else 0 end),
        @PriorCOGS         = SUM(case when section = ''COGS''         and isRollup = 0 then ISNULL(priorPeriodAmount, 0) else 0 end),
        @PriorOtherIncome  = SUM(case when section = ''OtherIncome''  and isRollup = 0 then ISNULL(priorPeriodAmount, 0) else 0 end),
        @PriorExpense      = SUM(case when section = ''Expense''      and isRollup = 0 then ISNULL(priorPeriodAmount, 0) else 0 end),
        @PriorOtherExpense = SUM(case when section = ''OtherExpense'' and isRollup = 0 then ISNULL(priorPeriodAmount, 0) else 0 end)
    from #Lines

    -- Insert subtotals between sections.  ord values are chosen to fall between
    -- MinorGroup boundaries so the final ORDER BY interleaves them correctly.
    insert into #Lines
        (ord, accountKey, accountNumber, accountName, accountType, section,
         parentAccountKey, level, displayOrder, isRollup, isEBITDA, amount, priorPeriodAmount)
    values
        (2500, null, null, ''Gross Profit'',          ''Subtotal'', ''GrossProfit'',  0, 0, 0, 1, 0,
            ISNULL(@Income, 0)      - ISNULL(@COGS, 0),
            case when @PriorStartDate is null then null else ISNULL(@PriorIncome, 0) - ISNULL(@PriorCOGS, 0) end),
        (4500, null, null, ''Net Operating Income'', ''Subtotal'', ''NetOperating'', 0, 0, 0, 1, 0,
            ISNULL(@Income, 0) + ISNULL(@OtherIncome, 0) - ISNULL(@COGS, 0) - ISNULL(@Expense, 0),
            case when @PriorStartDate is null then null else
                 ISNULL(@PriorIncome, 0) + ISNULL(@PriorOtherIncome, 0) - ISNULL(@PriorCOGS, 0) - ISNULL(@PriorExpense, 0) end),
        (5500, null, null, ''Net Income'',            ''Subtotal'', ''NetIncome'',    0, 0, 0, 1, 0,
            ISNULL(@Income, 0) + ISNULL(@OtherIncome, 0) - ISNULL(@COGS, 0) - ISNULL(@Expense, 0) - ISNULL(@OtherExpense, 0),
            case when @PriorStartDate is null then null else
                 ISNULL(@PriorIncome, 0) + ISNULL(@PriorOtherIncome, 0) - ISNULL(@PriorCOGS, 0) - ISNULL(@PriorExpense, 0) - ISNULL(@PriorOtherExpense, 0) end)

    -- ------------------------------------------------------------------
    -- 13. Result set 1: warnings
    -- ------------------------------------------------------------------
    select errorType    as errorType,
           errorCode    as errorCode,
           errorMessage as errorMessage,
           fieldName    as fieldName
    from #errors
    where errorType = ''warning''

    -- ------------------------------------------------------------------
    -- 14. Result set 2: meta (single row)
    -- ------------------------------------------------------------------
    select
        convert(varchar(19), getutcdate(), 126) + ''Z''                     as asOf,
        @CompanyKey                                                       as companyKey,
        ISNULL(@EffectiveCurrencyID, '''')                                  as currency,
        convert(varchar(10), @StartDate,      23)                         as windowStart,
        convert(varchar(10), @EndDate,        23)                         as windowEnd,
        convert(varchar(10), @PriorStartDate, 23)                         as comparisonWindowStart,
        convert(varchar(10), @PriorEndDate,   23)                         as comparisonWindowEnd,
        case when @AccrualBasis = 1 then ''accrual'' else ''cash'' end        as basis,
        cast(@RunInGLCHomeCurrency as bit)                                as isGLCHomeCurrency,
        (select COUNT(*) from #Lines)                                     as [rowCount],
        cast(0 as bit)                                                    as truncated,
        cast(null as int)                                                 as nextCursor

    -- ------------------------------------------------------------------
    -- 15. Result set 3: lines (full GL tree + subtotals, ordered)
    -- ------------------------------------------------------------------
    select
        accountKey         as accountKey,
        accountNumber      as accountNumber,
        accountName        as accountName,
        accountType        as accountType,
        section            as section,
        parentAccountKey   as parentAccountKey,
        level              as [level],
        displayOrder       as displayOrder,
        isRollup           as isRollup,
        isEBITDA           as isEBITDA,
        amount             as amount,
        priorPeriodAmount  as priorPeriodAmount
    from #Lines
    order by ord

    -- ------------------------------------------------------------------
    drop table #Lines
    drop table #PLPrior
    drop table #PLRaw
    drop table #DepartmentKeys
    drop table #ClassKeys
    drop table #OfficeKeys
    drop table #GLCompanyKeys
    drop table #revaluerate
    drop table #errors

    return 0
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spRpt1099Form]'
GO
IF OBJECT_ID(N'[dbo].[spRpt1099Form]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spRpt1099Form]
(
	@CompanyKey int,
	@MinAmount money,
	@StartDate smalldatetime,
	@EndDate smalldatetime,
	@Form smallint,						-- 1: Misc, 2: Int, 3: NEC
	@VendorKey int,						-- 0 All, > 0 valid vendor
	@GLCompanyKey INT = -1,		-- -1 All, 0 Blank or NULL, >0 valid GLCompany
	@UserKey int = NULL,
	@1099Summary int = NULL,  --Summarize 1099 data for 1096 form
	@IncludeCCPayments int = NULL, --CC Payments get reported on 1099-K by CC company
	@ShowLast4DigitsEIN int = NULL--Option to hide all but the last four digits of EIN/SSN on the report
)

AS --Encrypt

/*
|| When     Who Rel      What
|| 12/7/06  CRG 8.4      Added the @VendorKey parameter.
|| 01/29/08 GHL 8.503    (20078 + 20133) Sort by VendorID. Take >= @MinAmount 
|| 10/27/08 GHL 10.011   (34982) Added GLCompanyKey param for 1099 reporting
|| 03/17/09 MFT 10.021   (40077) Added Exclude1099
|| 11/4/09  CRG 10.5.1.3 (67238) Added DBA
|| 1/28/10  CRG 10.5.1.7 (72919) Now including the Exclude1099 calculation in the HAVING clause
|| 11/4/10  RLB 10.5.3.7 Changes made for the added 1096 report
|| 11/28/11 MFT 10.5.5.0 For electronic file format: added GLCompanyKey to output
|| 01/11/12 RLB 10.5.5.2 (131060) Changes made because GLCompany can be null or 0
|| 04/13/12 GHL 10.555  Added UserKey for UserGLCompanyAccess
|| 05/11/12 GHL 10.556 (142929) Added 1099 logic for credit cards
|| 01/09/14 GHL 10.576 (202119) Credit cards are payments
|| 03/04/14 GHL 10.578 Added conversion to home currency
|| 03/24/14 RLB 10.578 (203504) Added Exclude1099 on CC to the voucher cc calculation
|| 01/29/15 MFT 10.588 (244173) Restriced Credit Card payments to BoughtFromKey = @VendorKey so CC data will respect @VendorKey param
|| 09/30/15 MFT 10.596 (245426) Added the FATCAFilingRequirement field
|| 01/27/17 MFT 10.612 (330149) Return DBA only if UseDBAForPayment is selected
|| 11/27/18 MFT 18.9.3 (432767) Added "dba/" prefix to DBA field per IRS example
|| 09/25/20 MFT 20.110 (528335) Changed @Form enum (removed 4), added @1099Summary instead of @FormOriginal
|| 10/15/20 MFT 20.110 (506409) Removed CC payments by default
|| 01/26/20 MFT 21.010 (545666) Put in override to use Vendor''s PaymentAddressKey over DefaultAddressKey
|| 06/23/21 MFT 21.060 (538227) Added options to exclude VCard & ACH Payments
|| 09/28/23 MCM 23.010 (628804) Added #PaymentTypes so we can search by paymentTypes
|| 11/29/23 RLB 23.120 (653809) use new UseDBAForPayment1099
|| 12/11/23 MFT 24.010 (657806) Add recipient Email and IDType to support CSV submission
|| 01/19/24 MFT 24.010 (662488) Changed IDType to text values
|| 04/29/24 AMP 26.05.17 (720478) Added option to show only last 4 digits of EIN/SSN
|| 05/15/26 AMP 26.05.17 (720174) Added option to use company main address instead of pay to address
*/

-- CREATE TABLE #PaymentTypes (PaymentType int NULL)
Declare @HasPaymentTypes int
SET @HasPaymentTypes = 0
SELECT @HasPaymentTypes = Count(*)  From #PaymentTypes

Declare @RestrictToGLCompany int

Select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0)
	from tUser u (nolock)
	inner join tPreference p (nolock) on p.CompanyKey = ISNULL(u.OwnerCompanyKey, u.CompanyKey)
	Where u.UserKey = @UserKey

select @RestrictToGLCompany = isnull(@RestrictToGLCompany, 0)

-- Step 1: get the payments by GLCompany/Vendor
create table #tmpPayment 
	(
	PaymentKey int
	,GLCompanyKey int null
	,VendorKey int null
	,PaymentAmount money null
	,Exclude1099 money null
	,ExchangeRate decimal(24, 7) null
	,GPFlag int null
	,PaymentType varchar(25) null
	)

-- Pass 1: Get the payments againt regular vouchers

insert #tmpPayment (PaymentKey, GLCompanyKey, VendorKey, PaymentAmount, Exclude1099, ExchangeRate, GPFlag, PaymentType)
SELECT
	p.PaymentKey
	,isnull(p.GLCompanyKey, 0)
	,p.VendorKey
	,p.PaymentAmount
	,(ISNULL((
		SELECT SUM(ISNULL(Exclude1099, 0)) FROM tPaymentDetail pd (nolock) WHERE pd.PaymentKey = p.PaymentKey
	),0))
	,p.ExchangeRate
	,0
	,''Payment''
FROM
	tPayment p (nolock)
	INNER JOIN tCompany c (nolock) ON p.VendorKey = c.CompanyKey
WHERE 
	p.PaymentDate >= @StartDate 
	AND p.PaymentDate <= @EndDate 
	AND c.Type1099 = @Form
	AND p.CompanyKey = @CompanyKey
	AND (p.VendorKey = @VendorKey OR @VendorKey = 0)
	AND (
			@HasPaymentTypes = 0
			OR
			ISNULL(p.PaymentType, 1) in (SELECT PaymentType from #PaymentTypes)
		)
	AND     (-- case when @GLCompanyKey = ALL
				(@GLCompanyKey = -1 AND 
					(
					@RestrictToGLCompany = 0 OR 
					(@RestrictToGLCompany = 1 AND p.GLCompanyKey IN (SELECT GLCompanyKey FROM tUserGLCompanyAccess (NOLOCK) WHERE UserKey = @UserKey) )
					)
				)
			--case when @GLCompanyKey = X or Blank(0)
			 OR (@GLCompanyKey != -1 AND ISNULL(p.GLCompanyKey, 0) = @GLCompanyKey)
			)

-- Now remove the payments against credit cards
-- there is a special process by payment detail line for credit cards
update #tmpPayment
set    #tmpPayment.GPFlag = 1
from   tPayment p (nolock)
inner  join tPaymentDetail pd (nolock) on p.PaymentKey = pd.PaymentKey
inner  join tVoucher v (nolock) on pd.VoucherKey = v.VoucherKey
where  #tmpPayment.PaymentKey = p.PaymentKey
and    isnull(v.CreditCard, 0) = 1 

delete #tmpPayment where GPFlag = 1


-- Pass 2: add the payments against credit cards if specifially requested
IF @IncludeCCPayments = 1
	insert #tmpPayment (PaymentKey, GLCompanyKey, VendorKey, PaymentAmount, Exclude1099, ExchangeRate, PaymentType)
	select ccc.VoucherKey, 
		ccc.GLCompanyKey, 
		ccc.BoughtFromKey, 
		ccc.VoucherTotal,
		(
			(
					 (select ISNULL(sum (Exclude1099), 0) from tVoucherDetail vod (nolock) where vod.VoucherKey = ccc.VoucherKey) 
					 + 
					 (select ISNULL(sum (Exclude1099), 0) from tVoucherCC vcc (nolock) where vcc.VoucherCCKey = ccc.VoucherKey)
			)
		 ),
		ccc.ExchangeRate, 
		''Credit Card''
	from   tVoucher ccc (nolock)
	INNER JOIN tCompany c (nolock) ON ccc.BoughtFromKey = c.CompanyKey
	where isnull(ccc.CreditCard, 0) = 1
		AND ccc.InvoiceDate >= @StartDate 
		AND ccc.InvoiceDate <= @EndDate 
		AND c.Type1099 = @Form
		AND ccc.CompanyKey = @CompanyKey
		AND (ccc.BoughtFromKey = @VendorKey OR @VendorKey = 0)
		AND     (-- case when @GLCompanyKey = ALL
					(@GLCompanyKey = -1 AND 
						(
						@RestrictToGLCompany = 0 OR 
						(@RestrictToGLCompany = 1 AND ccc.GLCompanyKey IN (SELECT GLCompanyKey FROM tUserGLCompanyAccess (NOLOCK) WHERE UserKey = @UserKey) )
						)
					)
				--case when @GLCompanyKey = X or Blank(0)
				 OR (@GLCompanyKey != -1 AND ISNULL(ccc.GLCompanyKey, 0) = @GLCompanyKey)
				)

update #tmpPayment 
	set PaymentAmount = isnull(PaymentAmount, 0) 
		, Exclude1099 = isnull(Exclude1099, 0)
		, ExchangeRate = isnull(ExchangeRate, 1)

update #tmpPayment
set PaymentAmount = round(PaymentAmount * ExchangeRate, 2)
   ,Exclude1099 = round(Exclude1099 * ExchangeRate, 2)

-- Step 2: get the data to display

	IF @1099Summary = 1 --Form 1096 (Summary of 1099 payments)
		BEGIN
			Select 
				SUM(PaymentAmount) as FormTotal
				,COUNT(DISTINCT VendorKey) as FormCount
				,@Form as FormType
			FROM (
					SELECT
						c.CompanyKey
						,c.CompanyName
						,c.VendorID
						,p.VendorKey
						,SUM(PaymentAmount - Exclude1099) AS PaymentAmount
						,ISNULL(p.GLCompanyKey, 0) AS GLCompanyKey
					FROM
						#tmpPayment p (nolock)
						INNER JOIN tCompany c (nolock) ON p.VendorKey = c.CompanyKey
					GROUP BY
						 c.CompanyKey
						,c.CompanyName
						,c.VendorID
						,p.VendorKey
						,ISNULL(p.GLCompanyKey, 0) 
					HAVING
						SUM(PaymentAmount - Exclude1099) >= @MinAmount
				) as FormData
		END

	ELSE
		SELECT
			 c.CompanyKey
			,c.CompanyName
			,c.VendorID
			,c.Type1099
			,CASE Type1099 WHEN 3 THEN ''SSN'' ELSE ''EIN'' END AS IDType			
			,CASE @ShowLast4DigitsEIN WHEN 1 THEN ''*****'' + RIGHT(EINNumber, 4) ELSE EINNumber END AS EINNumber			
			,c.Box1099
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address1 ELSE ad.Address1 END AS Address1	
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address2 ELSE ad.Address2 END AS Address2
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address3 ELSE ad.Address3 END AS Address3
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.City ELSE ad.City END AS City
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.State ELSE ad.State END AS State
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.PostalCode ELSE ad.PostalCode END AS PostalCode
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Country ELSE ad.Country END AS Country			
			,c.Phone
			,u.Email
			,SUM(PaymentAmount -Exclude1099) AS PaymentAmount
			,CASE UseDBAForPayment1099 WHEN 1 THEN ''dba/ '' + ISNULL(c.DBA, '''') ELSE '''' END AS DBA
			,ISNULL(p.GLCompanyKey, 0) AS GLCompanyKey
			,FATCAFilingRequirement
		FROM 
			#tmpPayment p (nolock)
			INNER JOIN tCompany c (nolock) ON p.VendorKey = c.CompanyKey	
			LEFT JOIN tAddress ad (nolock) ON CASE ISNULL(c.PaymentAddressKey, 0) WHEN 0 THEN c.DefaultAddressKey ELSE c.PaymentAddressKey END = ad.AddressKey
			LEFT JOIN tAddress d (nolock) ON c.DefaultAddressKey = d.AddressKey
			LEFT JOIN tUser u (nolock) ON c.PrimaryContact = u.UserKey
		GROUP BY
			 c.CompanyKey
			,c.CompanyName
			,c.VendorID
			,c.Type1099
			,CASE Type1099 WHEN 3 THEN 2 ELSE 1 END			
			,CASE @ShowLast4DigitsEIN WHEN 1 THEN ''*****'' + RIGHT(EINNumber, 4) ELSE EINNumber END
			,c.StateEINNumber
			,c.Box1099			
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address1 ELSE ad.Address1 END
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address2 ELSE ad.Address2 END
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Address3 ELSE ad.Address3 END
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.City ELSE ad.City END
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.State ELSE ad.State END
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.PostalCode ELSE ad.PostalCode END
			,CASE ISNULL(c.UseAltAddress,0) WHEN 0 THEN d.Country ELSE ad.Country END
			,c.Phone
			,u.Email
			,CASE UseDBAForPayment1099 WHEN 1 THEN ''dba/ '' + ISNULL(c.DBA, '''') ELSE '''' END
			,ISNULL(p.GLCompanyKey, 0)
			,FATCAFilingRequirement
		HAVING
			SUM(PaymentAmount - Exclude1099) >= @MinAmount
		ORDER BY
			VendorID'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[vReport_GLTransaction]'
GO
IF OBJECT_ID(N'[dbo].[vReport_GLTransaction]', 'V') IS NOT NULL
EXEC sp_executesql N'




ALTER VIEW [dbo].[vReport_GLTransaction]
AS

/*
|| When      Who Rel     What
|| 10/11/07  CRG 8.5     Added GLCompany, Office, Department
|| 11/06/07  CRG 8.5     (12822) Added Account Type
|| 10/20/08  GWG 10.0.11 Added Client Division and product through the project
|| 2/10/09   GWG 10.018  Added the date it was posted to the ledger
|| 4/8/09    GWG 10.022  Added Overhead to the fields
|| 04/14/10  RLB 10.521  (40466)Added Company Type 
|| 04/24/12  GHL 10.555  Added GLCompanyKey for map/restrict
|| 10/29/12  CRG 10.5.6.1 (156391) Added ProjectKey
|| 07/19/13  WDF 10.5.7.0 (176497) Added VoucherID
|| 03/07/14  GHL 10.578   Added Currency
|| 09/28/14  GWG 10.5.8.4 Modified where Transaction Date comes from
|| 01/27/15  WDF 10.5.8.8 (Abelson Taylor) Added Division and Product ID
|| 08/27/15  WDF 10.5.9.5 (267963) Added HCredit and HDebit
|| 01/05/16  KMC 10.5.9.9 (283457) Added Sales Person
|| 01/19/16  WDF 10.6.0.0 (285750) Prefixed 0 in front of Single Digit Month of [Posting Month Name]
|| 04/02/16  GWG 10.6.0.2 (293630) Added the project budget.
|| 02/28/17  WDF 10.6.1.3 (334530) Added BoughtFrom.
|| 07/05/17  GWG 10.6.1.7 Adding account types
|| 07/06/17  GHL 10.6.1.7 (345091) Added HC Transaction Amount, Overhead/No Client to help with Concentric custom report
|| 05/9/17   GWG 18.5.0   Adding campaign name
|| 07/19/19  AMP 19.0.8.0 (468042) Added Active, Parent Account Name, and Parent Account Number 
|| 03/03/20  AMP 20.0.3.0 (504119) Added Client State from the main address set on the client record
|| 03/27/20  MCM 20.0.4.0 (508230) Added Source Venodor is 1099 and Source Vendor 1099 Box
|| 05/01/20  AMP 20.0.5.0 (513291) Parent Issue (504119) - Added Client City from the main address set on the client record
|| 05/08/20  RLS 20.0.6.0 (514507) Added Project Manager
|| 09/02/20  RLB 20.1.0.0 (523772) making anything using user name common format
|| 11/20/20  MFT 20.1.2.0 (537837) Add NEC to Type1099 enums and updated box definitions
|| 02/22/21  AMP 21.03.14.0000 (530406) Added Company Type for vendor transactions
|| 08/31/21  AMP 21.10.17.0000 (568871) Added yes/no for EBITDA Account
|| 08/02/22  GAR 22.09.18 (607525) Added Source Vendor Name
|| 08/24/22  GAR 22.09.18 (609934) Added Parent Client ID and Parent Client Name
|| 02/16/23  AMP 23.03.19 (630382) Paid Customization for Fingerpaint - Added columns [Added By] and [Posted By] 
|| 03/13/23  RLB 23.04.16 (629165) Adding Office Color and Department Color
|| 05/10/23  AMP 23.06.18 (633609) Added Project Type
|| 08/11/23  RLB 23.09.17 (648008) added project type color
|| 11/08/23  RLB 23.12.17 (655622) Added Posting Month and Year
|| 08/07/24  MCM 24.09.x  (674904) Updated the Bought From to include Credit Card Charges
|| 08/19/24  AMP 24.09.15 (675480) Added GL Company Amount, GL Company Debit Amount and GL Company Credit
|| 10/15/24  MCM 24.11.x  (685593) Updated the link on the account manager to come from the client instead of the project
|| 10/25/24  MCM 24.11.x  (685593) Missunderstood the issue.  Only change to client if project account manager doesn''t exist
|| 11/04/25  RLB 25.12.14 (714635) added Project Budget Expenses and Project Budget Labor.
|| 03/09/26  GAR 26.04.19 (723570) Added Reconciliation Date 
|| 07/01/26  RLB 26.08.16 (731314) Added Project Budget Expenses Net
*/

SELECT
	t.CompanyKey
	,t.GLCompanyKey
	,t.Entity as [Source Transaction Type]
	,Cast(Cast(DatePart(mm,t.TransactionDate) as varchar) + ''/'' + Cast(DatePart(dd,t.TransactionDate) as varchar) + ''/'' + Cast(DatePart(yyyy,t.TransactionDate) as varchar) as datetime) as [Date Posted]
	--,t.TransactionDate as [Transaction Date] changed per Mike''s request
	,CASE t.Entity
		WHEN ''VOUCHER'' THEN (Select InvoiceDate from tVoucher (nolock) Where VoucherKey = t.EntityKey)
		WHEN ''CREDITCARD'' THEN (Select InvoiceDate from tVoucher (nolock) Where VoucherKey = t.EntityKey)
		WHEN ''PAYMENT'' THEN (Select PaymentDate from tPayment (nolock) Where PaymentKey = t.EntityKey)
		WHEN ''INVOICE'' THEN (Select InvoiceDate from tInvoice (nolock) Where InvoiceKey = t.EntityKey)
		WHEN ''RECEIPT'' THEN (Select CheckDate from tCheck (nolock) Where CheckKey = t.EntityKey)
		WHEN ''GENJRNL'' THEN (Select PostingDate from tJournalEntry (nolock) Where JournalEntryKey = t.EntityKey)
		WHEN ''WIP'' THEN (Select PostingDate from tWIPPosting (nolock) Where WIPPostingKey = t.EntityKey)
		END as [Transaction Date]
	,t.DateCreated as [Date Posted to Ledger]	
	,t.Reference as [Transaction Reference]
	,gl.AccountNumber as [GL Account Number]
	,gl.AccountName as [GL Account Name]
	,gl.AccountNumber + '' - '' + gl.AccountName as [GL Account Name Full]
	,t.Debit as [Debit Amount]
	,t.Credit as [Credit Amount]
	,t.HDebit as [HC Debit Amount]
	,t.HCredit as [HC Credit Amount]
	,Case 
		When gl.AccountType in (10, 11, 12, 13, 14, 50, 51, 52) Then t.Debit - t.Credit
		ELSE t.Credit - t.Debit END as [Transaction Amount]
	,Case 
		When gl.AccountType in (10, 11, 12, 13, 14, 50, 51, 52) Then HDebit - HCredit
		ELSE HCredit - HDebit END as [HC Transaction Amount]
	,t.Memo as [Transaction Memo]
	,cl.ClassID as [Class ID]
	,cl.ClassName as [Class Name]
	,cl.ClassID + '' - '' + cl.ClassName as [Class Name Full]
	,CAST(DATEPART(Year, t.TransactionDate) AS VARCHAR(4)) + '' ''+ RIGHT(''0'' + CAST(DATEPART(Month, t.TransactionDate) AS VARCHAR(2)), 2) + '' '' + DATENAME(Month, t.TransactionDate) AS  [Posting Month and Year]
	,t.PostMonth as [Posting Month]
	,CASE LEN(t.PostMonth)
	    WHEN 1 then ''0'' + Cast(t.PostMonth as varchar) + '' - '' + DATENAME(mm, t.TransactionDate)
	    ELSE Cast(t.PostMonth as varchar) + '' - '' + DATENAME(mm, t.TransactionDate) 
     END  as [Posting Month Name]
	,t.PostYear as [Posting Year]
	,Case When t.Cleared = 1 then ''YES'' else ''NO'' end as [Transaction Cleared]
	,Case When t.Overhead = 1 then ''YES'' else ''NO'' end as [Overhead Transaction]
	,Case When t.Overhead = 1 Or t.ClientKey is null  then ''YES'' else ''NO'' end as [Overhead/No Client]
	
	,Case When gl.PayrollExpense = 1 then ''YES'' else ''NO'' end as [Payroll Account]
	,Case When gl.FacilityExpense = 1 then ''YES'' else ''NO'' end as [Facility Expense]
	,Case When gl.LaborIncome = 1 then ''YES'' else ''NO'' end as [Fee Income Account]
    ,Case When gl.EBITDAAccount = 1 then ''YES'' else ''NO'' end as [EBITDA Account]

	,case ISNULL(c.Vendor,0) When 0 then c.CompanyName else '''' end as [Source Company Name]
	,c.CustomerID as [Source Customer ID]
	,CASE ISNULL(c.Type1099, 0)
		WHEN 0 THEN ''None''
		WHEN 1 THEN ''MISC''
		WHEN 2 THEN ''INT''
		WHEN 3 THEN ''NEC''
	 END as [Source Vendor is 1099]
	,CASE c.Type1099 
		WHEN 1 THEN
			CASE c.Box1099 
				WHEN ''01'' Then ''01 - Rents''
				WHEN ''02'' Then ''02 - Royalties''
				WHEN ''03'' Then ''03 - Other Income''
				WHEN ''05'' Then ''05 - Fishing Boat Proceeds''
				WHEN ''06'' Then ''06 - Medical and Health Care Payments''
				WHEN ''08'' Then ''08 - Substitute Payments in Lieu of Dividends and Interest''
				WHEN ''09'' Then ''09 - Crop Insurance Proceeds''
				WHEN ''10'' Then ''10 - Gross Proceeds Paid to Attorney''
				WHEN ''13'' Then ''13 - Excess Golden Parachute Payments''
				WHEN ''14'' Then ''14 - Nonqualified Deferred Compensation''
			END
		WHEN 2 THEN
			CASE c.Box1099 
				WHEN ''01'' Then ''01 - Interest Income''
				WHEN ''02'' Then ''02 - Early Withdrawl Penalty''
				WHEN ''03'' Then ''03 - Interest on U.S. Saving Bonds and Treasury Obligations''
				WHEN ''05'' Then ''05 - Investment Expenses''
				WHEN ''06'' Then ''06 - Foreign Tax Paid''
			END
		WHEN 3 THEN
			CASE c.Box1099
				WHEN ''01'' Then ''01 - Non Employee Compensation''
			END
	 END AS [Source Vendor 1099 Box]
	,client.CompanyName as [Client Name]
	,client.CustomerID as [Client ID]
	,a.State as [Client State]
	,a.City as [Client City]
	,c.VendorID as [Source Vendor ID]
	,case ISNULL(c.Vendor,0) When 1 then c.CompanyName else '''' end as [Source Vendor Name]
	,ct.CompanyTypeName as [Company Type]
	,p.ProjectNumber as [Project Number]
	,p.ProjectName as [Project Name]
	,p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense as [Project Budget]
	,p.EstLabor + p.ApprovedCOLabor AS [Project Budget Labor] 
	,p.EstExpenses + p.ApprovedCOExpense AS [Project Budget Expenses]
	,p.BudgetExpenses + p.ApprovedCOBudgetExp as [Project Budget Expenses Net] 
	,Case p.NonBillable When 1 then ''YES'' else ''NO'' end as [Non Billable Project]
	,glc.GLCompanyID as [Company ID]
	,glc.GLCompanyName as [Company Name]
	,o.OfficeID as [Office ID]
	,o.OfficeName as [Office Name]
	,o.OfficeColor as [Office Color]
	,d.DepartmentName as Department
	,d.DepartmentColor as [Department Color]
	,LTRIM(RTRIM(ISNULL(am.FirstName + '' '',cam.FirstName + '' '')  + ISNULL(am.LastName,cam.LastName))) AS [Account Manager]
	,CASE gl.AccountType
		WHEN 10 THEN ''Bank''
		WHEN 11 THEN ''Accounts Receivable''
		WHEN 12 THEN ''Current Asset''
		WHEN 13 THEN ''Fixed Asset''
		WHEN 14 THEN ''Other Asset''
		WHEN 20 THEN ''Accounts Payable''
		WHEN 21 THEN ''Current Liability''
		WHEN 22 THEN ''Long Term Liability''
		WHEN 23 THEN ''Credit Card''
		WHEN 30 THEN ''Equity - Does Not Close''
		WHEN 31 THEN ''Equity - Closes''
		WHEN 32 THEN ''Retained Earnings''
		WHEN 40 THEN ''Income''
		WHEN 41 THEN ''Other Income''
		WHEN 50 THEN ''Cost of Goods Sold''
		WHEN 51 THEN ''Expense''
		WHEN 52 THEN ''Other Expense''
	END AS [Account Type]
	,cd.DivisionName as [Client Division]
	,cd.DivisionID as [Client Division ID]
	,cp.ProductName as [Client Product]
	,cp.ProductID as [Client Product ID]
	,p.ProjectKey
	,v.VoucherID as [Unique Auto Number]
	,v2.BoughtFrom as [Bought From]
	,t.CurrencyID as [Currency]
	,LTRIM(RTRIM(ISNULL(sp1.FirstName + '' '','''')  + ISNULL(sp1.LastName,''''))) AS [Client Sales Person]
	,gl.Description as [GL Account Description]
	,ca.CampaignID as [Campaign ID]
	,ca.CampaignName as [Campaign Name]
	,CASE gl.Active WHEN 1 THEN ''YES'' ELSE ''NO'' END as [Active]
	,gl2.AccountName as [Parent Account Name]
	,gl2.AccountNumber as [Parent Account Number]
	,pm.UserName as [Project Manager]	
	,vct.CompanyTypeName as [Vendor Company Type]
	,pc.CustomerID as [Parent Client ID]
	,pc.CompanyName as [Parent Client Name]	
	,CASE t.Entity
		WHEN ''VOUCHER'' THEN
			vName.UserFullName
		WHEN ''GENJRNL'' THEN
			jeName.UserFullName
		WHEN ''INVOICE'' THEN
			iName.UserFullName
		WHEN ''RECEIPT'' THEN
			chName.UserFullName
		WHEN ''PAYMENT'' THEN
			pName.UserFullName
		WHEN ''CREDITCARD'' THEN
			ccName.UserFullName			
		WHEN ''WIP'' THEN
			wipName.UserFullName
	   END AS [Added By] 
	  ,postedName.UserFullName AS [Posted By]
   	  ,pt.ProjectTypeName as [Project Type]
	  ,pt.ProjectTypeColor as [Project Type Color]
      ,vt.GLCAmount as [GL Company Amount]
	  ,vt.GLCCredit	as [GL Company Credit Amount]
	  ,vt.GLCDebit  as [GL Company Debit Amount]
	  ,ar.EndDate as Reconciliation
from tTransaction t (nolock)
	left outer join tClass cl (nolock) on t.ClassKey = cl.ClassKey
	inner join tGLAccount gl (nolock) on t.GLAccountKey = gl.GLAccountKey
	left outer join tGLAccount gl2 (nolock) on gl.ParentAccountKey = gl2.GLAccountKey 
	left outer join tCompany c (nolock) on t.SourceCompanyKey = c.CompanyKey
	left outer join tCompany client (nolock) on t.ClientKey = client.CompanyKey
	left outer join tCompany pc (nolock) on client.ParentCompanyKey = pc.CompanyKey
	left outer join tProject p (nolock) on t.ProjectKey = p.ProjectKey
	left outer join tProjectRollup proll (nolock) on p.ProjectKey = proll.ProjectKey
	left outer join tUser am (nolock) on p.AccountManager = am.UserKey
	left outer join tUser cam (nolock) on client.AccountManagerKey = cam.UserKey
	left outer join tClientProduct cp (nolock) on p.ClientProductKey = cp.ClientProductKey
	left outer join tClientDivision cd (nolock) on p.ClientDivisionKey = cd.ClientDivisionKey
	left outer join tGLCompany glc (nolock) on t.GLCompanyKey = glc.GLCompanyKey
	left outer join tOffice o (nolock) on t.OfficeKey = o.OfficeKey
	left outer join tDepartment d (nolock) on t.DepartmentKey = d.DepartmentKey
	left outer join tCompanyType ct (nolock) on client.CompanyTypeKey = ct.CompanyTypeKey 
	left outer join tCompanyType vct (nolock) on c.CompanyTypeKey = vct.CompanyTypeKey 	
	left outer join tUser sp1 (nolock) on client.SalesPersonKey = sp1.UserKey
	left outer join tCampaign ca (nolock) on p.CampaignKey = ca.CampaignKey
	left outer join tAddress a (nolock) on client.DefaultAddressKey = a.AddressKey
	left outer join vUserName pm (nolock) on p.ProjectManager = pm.UserKey	
	left outer join tVoucher v (nolock) on (t.EntityKey = v.VoucherKey AND t.Entity = ''VOUCHER'' and v.CreditCard = 0) 
	left outer join vUserName vName (nolock) on v.CreatedByKey = vName.UserKey
    left outer join tJournalEntry je (nolock) on (t.EntityKey = je.JournalEntryKey AND t.Entity = ''GENJRNL'')
	left outer join vUserName jeName (nolock) on je.EnteredBy = jeName.UserKey 
    left outer join tInvoice i (nolock) on (t.EntityKey = i.InvoiceKey AND t.Entity = ''INVOICE'')
	left outer join vUserName iName (nolock) on i.CreatedByKey = iName.UserKey
    left outer join tCheck ch (nolock) on (t.EntityKey = ch.CheckKey AND t.Entity = ''RECEIPT'')
	left outer join vUserName chName (nolock) on ch.CreatedByKey = chName.UserKey
	left outer join tPayment pay (nolock) on (t.EntityKey = pay.PaymentKey AND t.Entity = ''PAYMENT'')
	left outer join vUserName pName (nolock) on pay.CreatedByKey = pName.UserKey
	left outer join tVoucher v2 (nolock) on (t.EntityKey = v2.VoucherKey AND t.Entity = ''CREDITCARD'' and v2.CreditCard = 1)
	left outer join vUserName ccName (nolock) on v2.CreatedByKey = ccName.UserKey
	left outer join tWIPPosting w (nolock) on (t.EntityKey = w.WIPPostingKey AND t.Entity = ''WIP'')
	left outer join vUserName wipName (nolock) on w.CreatedByKey = wipName.UserKey
	left outer join vUserName postedName (nolock) on t.PostedByKey = postedName.UserKey
	left outer join tProjectType pt (nolock) on pt.ProjectTypeKey = p.ProjectTypeKey
	left outer join vTransaction vt (nolock) on t.TransactionKey = vt.TransactionKey
	left outer join tGLAccountRecDetail ard (nolock) on t.TransactionKey = ard.TransactionKey
	left outer join tGLAccountRec ar (nolock) on ard.GLAccountRecKey = ar.GLAccountRecKey
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptPurchaseOrderDetailDeleteSpot]'
GO
IF OBJECT_ID(N'[dbo].[sptPurchaseOrderDetailDeleteSpot]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptPurchaseOrderDetailDeleteSpot]

	@PurchaseOrderDetailKey int

AS --Encrypt

  /*
  || When     Who Rel      What
  || 11/06/19 GHL 19.120   (487108) Added rollups. We are now using the sp in platinum
  || 02/25/20 MFT 20.030   (503225) Fixed check for billed (on tVoucherDetail) to PurchaseOrderDetailKey instead of PurchaseOrderkey (any line billed)
  || 07/08/26 MAS 26.07.19 (732506) Re-point tMediaPlanDetail.PurchaseOrderDetailKey at the latest surviving POD after
  ||                       deleting a POD (falling back to NULL when none remain), instead of nulling it before the delete.
  ||                       Deleting a media plan revision line was blanking the media plan buys grid Order column even
  ||                       though the original order line still existed.
  */

DECLARE @CurrentStatus int
DECLARE @Revision int
DECLARE @PurchaseOrderKey int
declare @LineNumber int 
declare @FlightStartDate smalldatetime
declare @DetailOrderDate smalldatetime
declare @InvoiceLineKey int
declare @ProjectKey int
declare @MediaPlanDetailKey int

	SELECT @PurchaseOrderKey = pod.PurchaseOrderKey 
	      ,@LineNumber = pod.LineNumber
	      ,@FlightStartDate = po.FlightStartDate
	      ,@DetailOrderDate = pod.DetailOrderDate
	      ,@InvoiceLineKey = pod.InvoiceLineKey
		  ,@ProjectKey = pod.ProjectKey
		  ,@MediaPlanDetailKey = pod.MediaPlanDetailKey
	FROM tPurchaseOrderDetail pod (NOLOCK) inner join tPurchaseOrder po (nolock) on pod.PurchaseOrderKey = po.PurchaseOrderKey
	WHERE pod.PurchaseOrderDetailKey = @PurchaseOrderDetailKey
	
		
	IF EXISTS (
		SELECT 1
		FROM tVoucherDetail vd (nolock)
		WHERE vd.PurchaseOrderDetailKey = @PurchaseOrderDetailKey
	)
	RETURN -1
	
	IF EXISTS (SELECT 1
	           FROM		tPurchaseOrder po (NOLOCK)
	           WHERE  po.PurchaseOrderKey = @PurchaseOrderKey
	           AND    (po.Closed = 1))
		RETURN -2

	-- may have to check AllowChangesAfterClientInvoice later
	if isnull(@InvoiceLineKey,0) > 0
		RETURN -3

	UPDATE tEstimateTaskExpense
	SET    PurchaseOrderDetailKey = NULL
	WHERE  PurchaseOrderDetailKey = @PurchaseOrderDetailKey 
	
	-- do not delete detail line if it''s got an InvoiceLineKey.  It will have an Accrued Cost and cannot be deleted
	if isnull(@InvoiceLineKey,0) > 0
	    update tPurchaseOrderDetail
		   set Quantity = 0
			  ,UserDate1 = null
			  ,UserDate2 = null
			  ,UserDate3 = null
			  ,UserDate4 = null
			  ,UserDate5 = null
			  ,UserDate6 = null
			  ,BillableCost = 0
			  ,TotalCost = 0
		where PurchaseOrderDetailKey = @PurchaseOrderDetailKey 
	else
		delete from tPurchaseOrderDetail
	     where PurchaseOrderDetailKey = @PurchaseOrderDetailKey

	-- If this POD came from a media plan, re-point the media plan detail at its latest surviving POD
	-- (or NULL when none remain) so the media plan buys grid does not show a blank Order column.
	if isnull(@MediaPlanDetailKey, 0) > 0
		update tMediaPlanDetail
		set    PurchaseOrderDetailKey = (select max(pod.PurchaseOrderDetailKey)
		                                   from tPurchaseOrderDetail pod (nolock)
		                                  where pod.MediaPlanDetailKey = @MediaPlanDetailKey
		                                    and pod.PurchaseOrderKey = @PurchaseOrderKey)
		where  MediaPlanDetailKey = @MediaPlanDetailKey

	if not exists(select 1 from tPurchaseOrderDetail (nolock) where PurchaseOrderKey = @PurchaseOrderKey and LineNumber = @LineNumber)
		UPDATE tPurchaseOrderDetail
		SET    LineNumber = LineNumber - 1
		WHERE
			PurchaseOrderKey = @PurchaseOrderKey 
		AND 
			LineNumber > @LineNumber
		
	exec sptPurchaseOrderRollupAmounts @PurchaseOrderKey

	UPDATE tPurchaseOrder
	SET   DateUpdated = CAST( CAST(MONTH(GETDATE()) as varchar) + ''/'' + CAST(DAY(GETDATE()) as varchar) + ''/'' + CAST(YEAR(GETDATE()) as varchar) as smalldatetime)
	WHERE  PurchaseOrderKey = @PurchaseOrderKey
		
	exec sptPurchaseOrderDetailUpdateApprover @PurchaseOrderKey
	
	if @ProjectKey > 0
	EXEC sptProjectRollupUpdate @ProjectKey, 5, 1, 1, 1, 1 



	RETURN 1
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAIProjectGetSummary]'
GO
IF OBJECT_ID(N'[dbo].[spApiAIProjectGetSummary]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spApiAIProjectGetSummary]
(
    @CompanyKey     int,
    @UserKey        int,
    @ProjectNumber  varchar(50)  = null,
    @ClientID       varchar(50)  = null,
    @ProjectType    varchar(100) = null,
    @ProjectStatus  varchar(50)  = null,
    @Filter         varchar(50)  = null    -- ''over_budget'' | ''behind_schedule'' | ''near_overbudget''
)
AS --Encrypt

/*
|| When      Who Rel        What
|| 03/10/26  QMD 26.03.15   Created for AI project summary tool
|| 03/10/26  QMD 26.03.15   Switched from @ProjectKey to @ProjectNumber; lookup now done inside proc
|| 03/10/26  QMD 26.03.15   Added @ClientID, @ProjectType, @ProjectStatus for list queries
|| 03/10/26  QMD 26.03.15   Added key lookups for ClientID, ProjectType, ProjectStatus (name or id)
|| 03/10/26  QMD 26.03.15   Added @Filter for over_budget / behind_schedule / near_overbudget
|| 05/25/26  AI  26.05.25   Added #errors standard error logging and user-validity check.
||                          When @ProjectNumber identifies a single project, access is gated through
||                          spCheckAccess (tProject). List mode (no @ProjectNumber) keeps the set-based
||                          GL company + assignment filter - calling spCheckAccess per row would be N
||                          proc calls.
|| 05/28/26  AI  26.05.28   Added #errors / warnings; spCheckAccess (tProject) for single-project mode. Result-set shape now [warnings, projects].
|| 06/18/26  GAR 26.07.19   (730520) Added custom field key so we can get custom fields on the front end.
*/

set nocount on

    select * into #errors from tAPIErrorTemplate where 1 = 2

    declare @ProjectKey          int = null
    declare @ClientKey           int = null
    declare @ProjectTypeKey      int = null
    declare @ProjectStatusKey    int = null
    declare @RestrictToGLCompany int
    declare @CheckAssignment     int
    declare @SecurityGroupKey    int
    declare @AccessOK            int
    declare @ErrorCount          int

    -- ------------------------------------------------------------------
    -- 1. Validate user
    -- ------------------------------------------------------------------
    select @SecurityGroupKey = SecurityGroupKey
    from   tUser (nolock)
    where  UserKey    = @UserKey
      and  CompanyKey = @CompanyKey

    if @SecurityGroupKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''User not found or invalid UserKey.'', ''general'')

        select errorType, errorCode, errorMessage, fieldName
        from   #errors order by errorType desc, fieldName

        drop table #errors
        return -101
    end

    select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0)
    from   tPreference (nolock) where CompanyKey = @CompanyKey

    -- ------------------------------------------------------------------
    -- 2. Resolve string filters
    -- ------------------------------------------------------------------
    if @ProjectNumber is not null
        select @ProjectKey = ProjectKey
        from   tProject (nolock)
        where  CompanyKey    = @CompanyKey
          and  ProjectNumber = @ProjectNumber

    if @ClientID is not null
        select @ClientKey = CompanyKey
        from   tCompany (nolock)
        where  OwnerCompanyKey = @CompanyKey
          and  (CustomerID = @ClientID or CompanyName = @ClientID)

    if @ProjectType is not null
        select @ProjectTypeKey = ProjectTypeKey
        from   tProjectType (nolock)
        where  CompanyKey      = @CompanyKey
          and  ProjectTypeName = @ProjectType

    if @ProjectStatus is not null
        select @ProjectStatusKey = ProjectStatusKey
        from   tProjectStatus (nolock)
        where  CompanyKey = @CompanyKey
          and  (ProjectStatusID = @ProjectStatus or ProjectStatus = @ProjectStatus)

    -- ------------------------------------------------------------------
    -- 3. Single-project mode: when @ProjectNumber was supplied, hard-gate
    --    access via spCheckAccess. This gives a clean -103 instead of a
    --    silently-empty result when the user can''t see the project.
    -- ------------------------------------------------------------------
    if @ProjectNumber is not null and LTRIM(RTRIM(@ProjectNumber)) <> ''''
    begin
        if @ProjectKey is null
        begin
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''error'', ''NOT_FOUND'', ''Project not found for projectNumber: '' + @ProjectNumber, ''projectNumber'')

            select errorType, errorCode, errorMessage, fieldName
            from   #errors order by errorType desc, fieldName

            drop table #errors
            return -101
        end

        exec @AccessOK = spCheckAccess @UserKey, @CompanyKey, ''tProject'', @ProjectKey

        if @AccessOK <> 1
        begin
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''error'', ''ACCESS_DENIED'', ''User does not have access to this project.'', ''projectNumber'')

            select errorType, errorCode, errorMessage, fieldName
            from   #errors order by errorType desc, fieldName

            drop table #errors
            return -103
        end
    end

    -- ------------------------------------------------------------------
    -- 4. Build #projectKeys: candidates that satisfy the filter set
    -- ------------------------------------------------------------------
    create table #projectKeys (ProjectKey int not null)

    if @Filter = ''over_budget''
    begin
        insert into #projectKeys (ProjectKey)
        select pr.ProjectKey
        from   tProject pr (nolock)
        left outer join tProjectRollup roll (nolock) on pr.ProjectKey = roll.ProjectKey
        where  pr.CompanyKey = @CompanyKey
          and  pr.Closed     = 0
          and  (@ProjectKey       is null or pr.ProjectKey       = @ProjectKey)
          and  (@ClientKey        is null or pr.ClientKey        = @ClientKey)
          and  (@ProjectTypeKey   is null or pr.ProjectTypeKey   = @ProjectTypeKey)
          and  (@ProjectStatusKey is null or pr.ProjectStatusKey = @ProjectStatusKey)
          and  (ISNULL(roll.LaborGross, 0)
                  + ISNULL(roll.MiscCostGross, 0)
                  + ISNULL(roll.ExpReceiptGross, 0)
                  + ISNULL(roll.VoucherOutsideCostsGross, 0))
              > (ISNULL(pr.EstLabor, 0) + ISNULL(pr.ApprovedCOLabor, 0)
                  + ISNULL(pr.EstExpenses, 0) + ISNULL(pr.ApprovedCOExpense, 0))
    end
    else if @Filter = ''behind_schedule''
    begin
        insert into #projectKeys (ProjectKey)
        select distinct pr.ProjectKey
        from   tProject pr (nolock)
        inner join tTask t (nolock) on pr.ProjectKey = t.ProjectKey
        where  pr.CompanyKey   = @CompanyKey
          and  pr.Closed       = 0
          and  t.ActComplete   is not null
          and  t.PlanComplete  < GETUTCDATE()
          and  (@ProjectKey       is null or pr.ProjectKey       = @ProjectKey)
          and  (@ClientKey        is null or pr.ClientKey        = @ClientKey)
          and  (@ProjectTypeKey   is null or pr.ProjectTypeKey   = @ProjectTypeKey)
          and  (@ProjectStatusKey is null or pr.ProjectStatusKey = @ProjectStatusKey)
    end
    else if @Filter = ''near_overbudget''
    begin
        insert into #projectKeys (ProjectKey)
        select pr.ProjectKey
        from   tProject pr (nolock)
        left outer join tProjectRollup roll (nolock) on pr.ProjectKey = roll.ProjectKey
        where  pr.CompanyKey = @CompanyKey
          and  pr.Closed     = 0
          and  (@ProjectKey       is null or pr.ProjectKey       = @ProjectKey)
          and  (@ClientKey        is null or pr.ClientKey        = @ClientKey)
          and  (@ProjectTypeKey   is null or pr.ProjectTypeKey   = @ProjectTypeKey)
          and  (@ProjectStatusKey is null or pr.ProjectStatusKey = @ProjectStatusKey)
          and  (ISNULL(pr.EstLabor, 0) + ISNULL(pr.ApprovedCOLabor, 0)
                  + ISNULL(pr.EstExpenses, 0) + ISNULL(pr.ApprovedCOExpense, 0)) > 0
          and  (ISNULL(roll.BilledAmount, 0)
                  - (ISNULL(roll.LaborNet, 0) + ISNULL(roll.MiscCostNet, 0)
                      + ISNULL(roll.ExpReceiptNet, 0) + ISNULL(roll.VoucherNet, 0)))
              / (ISNULL(pr.EstLabor, 0) + ISNULL(pr.ApprovedCOLabor, 0)
                  + ISNULL(pr.EstExpenses, 0) + ISNULL(pr.ApprovedCOExpense, 0)) < 0.10
    end
    else
    begin
        insert into #projectKeys (ProjectKey)
        select pr.ProjectKey
        from   tProject pr (nolock)
        where  pr.CompanyKey = @CompanyKey
          and  pr.Closed     = 0
          and  (@ProjectKey       is null or pr.ProjectKey       = @ProjectKey)
          and  (@ClientKey        is null or pr.ClientKey        = @ClientKey)
          and  (@ProjectTypeKey   is null or pr.ProjectTypeKey   = @ProjectTypeKey)
          and  (@ProjectStatusKey is null or pr.ProjectStatusKey = @ProjectStatusKey)
    end

    -- ------------------------------------------------------------------
    -- 5. List-mode set-based GL company + assignment filter
    --    (Single-project mode already passed spCheckAccess above.)
    -- ------------------------------------------------------------------
    if @ProjectKey is null
    begin
        if @RestrictToGLCompany = 1
            delete pk
            from   #projectKeys pk
            inner join tProject pr (nolock) on pk.ProjectKey = pr.ProjectKey
            where  pr.GLCompanyKey not in (
                       select GLCompanyKey from tUserGLCompanyAccess (nolock) where UserKey = @UserKey
                   )

        set @CheckAssignment = 1
        if exists (
            select 1 from tRight r (nolock)
            inner join tRightAssigned ra (nolock) on r.RightKey = ra.RightKey
            where  ra.EntityType = ''Security Group''
              and  ra.EntityKey  = @SecurityGroupKey
              and  r.RightID     = ''prjAccessAny''
        )
            set @CheckAssignment = 0

        if @CheckAssignment = 1
            delete from #projectKeys
            where  ProjectKey not in (select ProjectKey from tAssignment where UserKey = @UserKey)
    end

    -- ------------------------------------------------------------------
    -- 6. Warnings (consistent shape)
    -- ------------------------------------------------------------------
    select errorType, errorCode, errorMessage, fieldName
    from   #errors where errorType = ''warning''

    -- ------------------------------------------------------------------
    -- 7. Project summary
    -- ------------------------------------------------------------------
    select
         pr.ProjectNumber                                                  as ProjectNumber
        ,ISNULL(pr.ProjectName, '''')                                        as ProjectName
        ,pr.ProjectNumber + '' '' + ISNULL(pr.ProjectName, '''')               as ProjectFullName
        ,ISNULL(pr.Description, '''')                                        as Description
        ,ISNULL(cl.CompanyName, '''')                                        as ClientName
        ,ISNULL(am.FirstName, '''') + '' '' + ISNULL(am.LastName, '''')          as AccountManager
        ,ISNULL(pm.FirstName, '''') + '' '' + ISNULL(pm.LastName, '''')          as ProjectManager
        ,ISNULL(bcu.FirstName, '''') + '' '' + ISNULL(bcu.LastName, '''')        as BillingContact
        ,ISNULL(ps.ProjectStatus, '''')                                      as ProjectStatus
        ,ISNULL(ps.ProjectStatusID, '''')                                    as ProjectStatusID
        ,ISNULL(pbs.ProjectBillingStatus, '''')                              as BillingStatus
        ,ISNULL(pr.StatusNotes, '''')                                        as StatusNotes
        ,ISNULL(pr.Closed, 0)                                              as Closed
        ,ISNULL(pr.NonBillable, 0)                                         as NonBillable
        ,case
            when ISNULL(pr.BillingMethod, 0) = 1 then ''Time and Materials''
            when ISNULL(pr.BillingMethod, 0) = 2 then ''Fixed Fee''
            when ISNULL(pr.BillingMethod, 0) = 3 then ''Retainer''
            else ''Time and Materials''
         end                                                                as BillingMethod
        ,ISNULL(pr.StartDate, '''')                                          as StartDate
        ,case when YEAR(pr.CompleteDate) <= 1900 then null else pr.CompleteDate end as DueDate
        ,ISNULL(pr.EstHours, 0) + ISNULL(pr.ApprovedCOHours, 0)            as BudgetHours
        ,ISNULL(pr.EstLabor, 0) + ISNULL(pr.ApprovedCOLabor, 0)            as BudgetLaborGross
        ,ISNULL(pr.EstExpenses, 0) + ISNULL(pr.ApprovedCOExpense, 0)       as BudgetExpenseGross
        ,ISNULL(pr.EstLabor, 0) + ISNULL(pr.ApprovedCOLabor, 0)
           + ISNULL(pr.EstExpenses, 0) + ISNULL(pr.ApprovedCOExpense, 0)   as BudgetTotal
        ,ISNULL(roll.Hours, 0)                                             as ActualHours
        ,ISNULL(roll.LaborGross, 0)                                        as ActualLaborGross
        ,ISNULL(roll.LaborNet, 0)                                          as ActualLaborCost
        ,ISNULL(roll.MiscCostGross, 0)
           + ISNULL(roll.ExpReceiptGross, 0)
           + ISNULL(roll.VoucherOutsideCostsGross, 0)                       as ActualExpenseGross
        ,ISNULL(roll.MiscCostNet, 0)
           + ISNULL(roll.ExpReceiptNet, 0)
           + ISNULL(roll.VoucherNet, 0)                                     as ActualExpenseCost
        ,ISNULL(roll.LaborGross, 0)
           + ISNULL(roll.MiscCostGross, 0)
           + ISNULL(roll.ExpReceiptGross, 0)
           + ISNULL(roll.VoucherOutsideCostsGross, 0)                       as ActualTotalGross
        ,ISNULL(roll.LaborNet, 0)
           + ISNULL(roll.MiscCostNet, 0)
           + ISNULL(roll.ExpReceiptNet, 0)
           + ISNULL(roll.VoucherNet, 0)                                     as ActualTotalCost
        ,ISNULL(roll.BilledAmount, 0)                                      as AmountBilled
        ,ISNULL(roll.LaborUnbilled, 0)
           + ISNULL(roll.MiscCostUnbilled, 0)
           + ISNULL(roll.ExpReceiptUnbilled, 0)
           + ISNULL(roll.VoucherUnbilled, 0)                                as UnbilledTotal
        ,ISNULL(roll.BilledAmount, 0)
           - (ISNULL(roll.LaborNet, 0)
                + ISNULL(roll.MiscCostNet, 0)
                + ISNULL(roll.ExpReceiptNet, 0)
                + ISNULL(roll.VoucherNet, 0))                               as Margin
        ,(ISNULL(pr.EstLabor, 0) + ISNULL(pr.ApprovedCOLabor, 0)
            + ISNULL(pr.EstExpenses, 0) + ISNULL(pr.ApprovedCOExpense, 0))
            - (ISNULL(roll.LaborGross, 0)
                + ISNULL(roll.MiscCostGross, 0)
                + ISNULL(roll.ExpReceiptGross, 0)
                + ISNULL(roll.VoucherOutsideCostsGross, 0))                 as BudgetRemaining
        ,pr.CustomFieldKey                                                 as CustomFieldKey
    from   tProject pr (nolock)
    inner join #projectKeys pk on pr.ProjectKey = pk.ProjectKey
    left outer join tProjectStatus ps (nolock)
        on pr.ProjectStatusKey = ps.ProjectStatusKey
    left outer join tProjectBillingStatus pbs (nolock)
        on pr.ProjectBillingStatusKey = pbs.ProjectBillingStatusKey
    left outer join tCompany cl (nolock)
        on pr.ClientKey = cl.CompanyKey
    left outer join tProjectType pt (nolock)
        on pr.ProjectTypeKey = pt.ProjectTypeKey
    left outer join tUser am (nolock)
        on pr.AccountManager = am.UserKey
    left outer join tUser pm (nolock)
        on pr.ProjectManager = pm.UserKey
    left outer join tUser bcu (nolock)
        on pr.BillingContact = bcu.UserKey
    left outer join tProjectRollup roll (nolock)
        on pr.ProjectKey = roll.ProjectKey

    drop table #projectKeys
    drop table #errors

    return 0

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskUserReassignWMJ]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskUserReassignWMJ]', 'P') IS NOT NULL
EXEC sp_executesql N'


ALTER PROCEDURE [dbo].[sptTaskUserReassignWMJ]
	(
		@OldTaskUserKey INT,
		@NewUserKey INT,
		@RemoveFromProject INT,
		@AddToTask tinyint = 0,
		@NewTaskHours decimal(24,4),
		@UseTaskUserService tinyint = 0,
		@UseNewUserDefaultService tinyint = 0

	)
AS --Encrypt

  /*
  || When     Who Rel      What
  || 03/28/11 GHL 10.543   (107252) Creation to handle reassign of services 
  ||                       Just change UserKey on task user key 
  || 6/2/11   CRG 10.5.4.5 Added @AddToTask to allow user to be added without removing the existing user.
  ||                       Also added @NewTaskHours to pass in the hours from the reassign screen and set it for the new tTaskUser record.
  || 10/25/13 RLB 10.5.7.3 (192183) If 0 NewUserKey is passed in and there is a service on the olduserkey then just remove the user but keep the service
  || 04/19/16 GAR 10.6.0.3 When reassigning a task, set TaskUserStatusKey to NULL to prevent issues displaying status
  || 05/10/16 RLB 10.6.0.4 When adding to a task use the service on the task if there is one. if not use default user service
  || 05/24/16 GAR 10.6.0.4 Override change from 4/19/16 - Need to try and match up task user statuses to the new user.
  || 06/17/16 GAR 10.6.0.5 Add code to not override TaskUserStatusKey if there are no overrides for the security groups.
  || 11/09/20 RLB 20.1.2.0 (524218) Added handoff code should only apply if reassigned has actual hours entered
  || 09/29/21 CRG 21.10.17 (572736) Now preventing a task assignment from getting the user cleared if it also doesn''t have a service on it.
  || 11/08/21 RLB 21.12.19 (575829) Added check for new trans pref 
  || 06/22/23 CRG 23.07.18 (619667) Added optional @UseTaskUserService. This is for a Ruffalo customization. 
  ||                                If 1, then it will use the tTaskUser service when defaulting on the team tab  
  || 11/10/23 CRG 23.12.17 (655613) Now defaulting the PercComp to 0 instead of NULL when adding new assignments
  || 03/03/25 RLB 25.04.20 (688773) for customization to set default user service over the old service
  || 03/24/25 RLB 25.04.20 (688773) for customization only check tran pref default service in list when customization is not used
  || 06/01/26 RLS 26.07.19 (729817) Protect against @NewTaskUserStatusKey being 0 (needs to be NULL for Default Status)
  */

	SET NOCOUNT ON

	if isnull(@OldTaskUserKey, 0) = 0
		return 0

	DECLARE @ProjectKey INT
			,@TaskKey INT
			,@OldUserKey int
			,@OldUserServiceKey int
			,@NewServiceKey int
			,@PercCompSeparate tinyint
			,@DefaultServiceKey int
			,@RetVal int
			,@OldTaskUserStatusKey int
			,@OldActualHours decimal(24, 4)
			,@OldHours decimal(24, 4)
			,@NewHours decimal(24, 4)
			,@OldActStart smalldatetime
			,@OldActComplete smalldatetime
			,@OldPercComp int 
			,@DisplayAssignedServicesOnly tinyint
			,@CurrentCompanyKey int
			,@DefaultAssignmentServiceKey int
			
	select @OldUserKey = UserKey
	      ,@TaskKey = TaskKey
		  ,@OldUserServiceKey = ServiceKey
		  ,@OldTaskUserStatusKey = TaskUserStatusKey
		  ,@OldHours = ISNULL(Hours, 0)
		  ,@OldActStart = ActStart
		  ,@OldActComplete = ActComplete
		  ,@OldPercComp = PercComp
		  ,@DefaultAssignmentServiceKey = 
			CASE @UseTaskUserService
				WHEN 1 THEN ServiceKey
				ELSE NULL
			END
	from tTaskUser (nolock) 
	where TaskUserKey = @OldTaskUserKey

	-- added for issue 575829 if they have a trans pref only make change if new user has service in tUserService
	IF ISNULL(@OldUserKey, 0) > 0 
		SELECT @CurrentCompanyKey = CompanyKey from tUser (nolock) where UserKey = @OldUserKey

	IF ISNULL(@CurrentCompanyKey, 0) = 0 and ISNULL(@NewUserKey, 0) > 0
	    SELECT @CurrentCompanyKey = CompanyKey from tUser (nolock) where UserKey = @NewUserKey

	IF ISNULL(@CurrentCompanyKey, 0) = 0
		SELECT @DisplayAssignedServicesOnly = 0
	ELSE
		SELECT @DisplayAssignedServicesOnly = ISNULL(DisplayAssignedServicesOnly, 0) from tPreference (nolock) where CompanyKey = @CurrentCompanyKey


	-- check to see if there are actual hours on here for hand off change
	SELECT @OldActualHours = ISNULL(SUM(t.ActualHours), 0)
		FROM	tTime t (nolock)
		INNER JOIN tTaskUser tu (nolock) ON t.UserKey = tu.UserKey AND ISNULL(t.DetailTaskKey, t.TaskKey) = tu.TaskKey
		WHERE	tu.TaskUserKey = @OldTaskUserKey
		AND		t.ServiceKey = @OldUserServiceKey
	-- for hand off change
	IF @OldActualHours > 0
	begin
		SELECT @NewHours = @OldHours - @OldActualHours
		if @NewHours < 0
			SELECT @NewHours = 0

	end
	else 
		SELECT @NewHours = 0

	select @OldUserKey = isnull(@OldUserKey, 0)
	select @OldUserServiceKey = isnull(@OldUserServiceKey, 0)
	select @UseNewUserDefaultService = isnull(@UseNewUserDefaultService, 0)

	-- if there is an old service and a new user and they have the trans pref do not add new user if they do not have service in tUserService
	if ISNULL(@OldUserServiceKey, 0) > 0 and ISNULL( @NewUserKey, 0) > 0 and @DisplayAssignedServicesOnly = 1 and @UseNewUserDefaultService = 0
	BEGIN
		IF NOT EXISTS(SELECT 1 FROM tUserService (NOLOCK) WHERE UserKey = @NewUserKey AND ServiceKey = @OldUserServiceKey) 
			return 0 
	END

	-- if the users are the same, abort
	if @OldUserKey = @NewUserKey
		return 0 
	-- if unassigned and the old user does not have a service set abort
	IF @NewUserKey = 0 AND @OldUserServiceKey = 0
		return 0

	SELECT	@ProjectKey = ProjectKey,
			@PercCompSeparate = ISNULL(PercCompSeparate, 0)
	FROM	tTask (NOLOCK)
	WHERE	TaskKey = @TaskKey

	IF @NewUserKey < 0
		SELECT @NewServiceKey = @NewUserKey * -1

	IF @AddToTask = 1
	BEGIN
	    IF @NewUserKey > 0
		begin
			if @OldUserServiceKey > 0 and @UseNewUserDefaultService = 0
				SELECT @DefaultServiceKey = @OldUserServiceKey
			else
				SELECT	@DefaultServiceKey = DefaultServiceKey 
				FROM	tUser (nolock) 
				WHERE	UserKey = @NewUserKey

			INSERT	tTaskUser	
					(TaskKey, 
					UserKey, 
					Hours, 
					ServiceKey,
					PercComp)
			SELECT	@TaskKey, 
					@NewUserKey, 
					@NewTaskHours,
					@DefaultServiceKey,
					0

			SELECT @RetVal = @@IDENTITY

			IF @PercCompSeparate = 1
				EXEC sptTaskUserRollup @TaskKey
		end
		ELSE
		begin
			INSERT	tTaskUser	
						(TaskKey, 
						UserKey, 
						Hours, 
						ServiceKey,
						PercComp)
				SELECT	@TaskKey, 
						null, 
						@NewTaskHours,
						@NewServiceKey,
						0

				SELECT @RetVal = @@IDENTITY
			IF @PercCompSeparate = 1
				EXEC sptTaskUserRollup @TaskKey
		end

	END
	ELSE
	BEGIN
	    IF @NewUserKey = 0
		BEGIN
			--If user is being cleared, make sure that it has a service key
			IF @OldUserServiceKey > 0 -- made some changes to handle 0 userkey which is unassign but keep if there is a service set on TaskUser
				update tTaskUser                          -- also made some changes to handle if a service was assigned instead of a user
				set UserKey = null
				where  TaskUserKey = @OldTaskUserKey
			ELSE
				RETURN 0
		END
		ELSE
			IF @NewUserKey < 0
				update tTaskUser
				set    UserKey = null,
					   ServiceKey = @NewServiceKey
				where  TaskUserKey = @OldTaskUserKey
			ELSE
			BEGIN
				-- Grab security group for the new user and the old user
				DECLARE @NewTaskUserStatusKey INT
				DECLARE @NewSecurityGroupKey INT, @OldSecurityGroupKey INT, @OldCompanyKey INT, @NewCompanyKey INT
				SELECT @NewSecurityGroupKey = ISNULL(SecurityGroupKey, 0), @NewCompanyKey = ISNULL(OwnerCompanyKey, CompanyKey) from tUser (nolock) Where UserKey = @NewUserKey
				SELECT @OldSecurityGroupKey = ISNULL(SecurityGroupKey, 0), @OldCompanyKey = ISNULL(OwnerCompanyKey, CompanyKey) from tUser (nolock) Where UserKey = @OldUserKey
				
				IF (@NewSecurityGroupKey = @OldSecurityGroupKey OR @OldTaskUserStatusKey IS NULL)
					SET @NewTaskUserStatusKey = @OldTaskUserStatusKey
				ELSE
				BEGIN
					DECLARE @OldEntity VARCHAR(50), @NewEntity VARCHAR(50), @OldStatusName VARCHAR(250), @NewStatusName VARCHAR(250)
					SELECT @OldEntity = Entity, @OldStatusName = LOWER(StatusName) FROM tTaskUserStatus (nolock) WHERE TaskUserStatusKey = @OldTaskUserStatusKey

					-- See if an entry exists for the new security group for this status
					BEGIN
						SELECT @NewTaskUserStatusKey = TaskUserStatusKey FROM tTaskUserStatus (nolock) WHERE Entity = ''securitygroup'' AND EntityKey = @NewSecurityGroupKey AND LOWER(StatusName) = @OldStatusName
						IF @NewTaskUserStatusKey IS NULL						
						BEGIN
							IF @OldCompanyKey = @NewCompanyKey AND @OldEntity = ''company''
							BEGIN
								SET @NewTaskUserStatusKey = @OldTaskUserStatusKey
							END						
						END
						IF @NewTaskUserStatusKey IS NULL						
						BEGIN
							SELECT @NewTaskUserStatusKey = CompanyTaskUserStatusKey FROM tTaskUserStatus (nolock) WHERE TaskUserStatusKey = @OldTaskUserStatusKey
						END
					END
				END

				IF @NewTaskUserStatusKey = 0
					SELECT @NewTaskUserStatusKey = NULL

				-- if actual hours then try to reduce current users hours to actual and add the new user with the remaining hours. if there are no remaining hours then just add user with 0 hours
				-- set the plan complete on old user as well
				if @OldActualHours > 0
					if @OldHours - @OldActualHours > 0
					begin
					-- if tracking seperate then we have to updated the task user actuals since we need to close assignment
						if @PercCompSeparate = 1 AND @OldPercComp < 100
						begin
							if @OldActStart is null AND @OldActComplete IS NULL												
								update tTaskUser
								SET Hours = @OldActualHours, RecalcRequired = 1, PercComp = 100, ActStart =  GETDATE(), ActComplete =  GETDATE()
								where  TaskUserKey = @OldTaskUserKey
							if @OldActStart IS NOT NULL and @OldActComplete IS NULL	
								update tTaskUser
								SET Hours = @OldActualHours, RecalcRequired = 1, PercComp = 100, ActComplete =  GETDATE()
								where  TaskUserKey = @OldTaskUserKey
						end
						else
							update tTaskUser
							SET Hours = @OldActualHours, RecalcRequired = 1
							where  TaskUserKey = @OldTaskUserKey
						-- now added the reassigned user with remaining hours
						if @OldUserServiceKey > 0 and @UseNewUserDefaultService = 0
							SELECT @DefaultServiceKey = @OldUserServiceKey
						else
							SELECT	@DefaultServiceKey = DefaultServiceKey 
							FROM	tUser (nolock) 
							WHERE	UserKey = @NewUserKey

						INSERT	tTaskUser	
								(TaskKey, 
								UserKey, 
								Hours, 
								ServiceKey,
								PercComp)
						SELECT	@TaskKey, 
								@NewUserKey, 
								@NewHours,
								@DefaultServiceKey,
								0

						SELECT @RetVal = @@IDENTITY

						IF @PercCompSeparate = 1
							EXEC sptTaskUserRollup @TaskKey
								
					end
					else
					begin
					-- if tracking seperate then we have to updated the task user actuals since we need to close assignment
						if @PercCompSeparate = 1 AND @OldPercComp < 100
						begin
							if  @OldActStart is null AND @OldActComplete IS NULL												
								update tTaskUser
								SET RecalcRequired = 1, PercComp = 100, ActStart =  GETUTCDATE(), ActComplete =  GETUTCDATE()
								where  TaskUserKey = @OldTaskUserKey
							if @OldActStart IS NOT NULL and @OldActComplete IS NULL	
								update tTaskUser
								SET RecalcRequired = 1, PercComp = 100, ActComplete =  GETUTCDATE()
								where  TaskUserKey = @OldTaskUserKey
						end
							-- now added the reassigned user with 0 hours since there are none left
						if @OldUserServiceKey > 0 and @UseNewUserDefaultService = 0
							SELECT @DefaultServiceKey = @OldUserServiceKey
						else
							SELECT	@DefaultServiceKey = DefaultServiceKey 
							FROM	tUser (nolock) 
							WHERE	UserKey = @NewUserKey

						INSERT	tTaskUser	
								(TaskKey, 
								UserKey, 
								Hours, 
								ServiceKey,
								PercComp)
						SELECT	@TaskKey, 
								@NewUserKey, 
								0,
								@DefaultServiceKey,
								0

						SELECT @RetVal = @@IDENTITY

						IF @PercCompSeparate = 1
							EXEC sptTaskUserRollup @TaskKey

					end
				else
					if  @UseNewUserDefaultService = 1
					begin
						SELECT	@DefaultServiceKey = DefaultServiceKey 
						FROM	tUser (nolock) 
						WHERE	UserKey = @NewUserKey

						update tTaskUser
						set UserKey = @NewUserKey,
							TaskUserStatusKey = @NewTaskUserStatusKey,
							ServiceKey = @DefaultServiceKey
						where  TaskUserKey = @OldTaskUserKey
					end
					else
					update tTaskUser
					set UserKey = @NewUserKey,
						TaskUserStatusKey = @NewTaskUserStatusKey
					where  TaskUserKey = @OldTaskUserKey
			END
	END	

	IF @NewUserKey > 0
		-- Assign new user to project, this sp will do it with proper hourly rate
		EXEC sptAssignmentInsertFromTask @ProjectKey, @NewUserKey, @DefaultAssignmentServiceKey

	-- Cleanup old user from project?
	DECLARE @NoUnassign INT
	SELECT @NoUnassign = 1

	IF isnull(@OldUserKey, 0) > 0
 	SELECT @NoUnassign = ISNULL(NoUnassign, 0) FROM tUser (NOLOCK) WHERE UserKey = @OldUserKey

	IF @RemoveFromProject = 1 AND @NoUnassign = 0 AND @OldUserKey > 0
	BEGIN

		IF (SELECT COUNT(*) 
			FROM tTaskUser tu (NOLOCK)
				INNER JOIN tTask t (NOLOCK) ON tu.TaskKey = t.TaskKey 
			WHERE tu.UserKey = @OldUserKey
			AND   t.ProjectKey = @ProjectKey)
			 = 0
		BEGIN
			DELETE tAssignment WHERE ProjectKey = @ProjectKey AND UserKey = @OldUserKey
			DELETE tProjectUserServices WHERE ProjectKey = @ProjectKey AND UserKey = @OldUserKey		 
		END
	END

	EXEC sptTaskRollupAssignedNames @TaskKey

	IF @AddToTask = 1
		RETURN @RetVal
	ELSE
	IF @OldActualHours > 0
		RETURN @RetVal
	ELSE
		RETURN 0
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAITimeGetEntries]'
GO
IF OBJECT_ID(N'[dbo].[spApiAITimeGetEntries]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spApiAITimeGetEntries]
(
    @CompanyKey    int,
    @UserKey       int,
    @StartDate     smalldatetime,
    @EndDate       smalldatetime,
    @TargetUserID  varchar(300) = null
)
AS --Encrypt

/*
|| When      Who Rel        What
|| 03/10/26  QMD 26.03.15   Created for AI time tool
|| 05/25/26  AI  26.05.25   Added #errors / warnings scaffold; result-set shape is now
||                          [warnings, timeEntries]. Caller is implicitly self-scoped (UserKey filter),
||                          so no record gate is needed.
|| 05/28/26  AI  26.05.28   Added #errors / warnings result-set scaffold.
|| 06/11/26  GAR 26.07.19   (730680) Added optional @TargetUserID to view another user''s time entries.
||                          Security: caller must be admin, have billingviewalltime right, or have
||                          billingviewusersiapprove right and be the target user''s TimeApprover
||                          or BackupApprover. Accepts first+last name, UserID, or email.
*/

set nocount on

    select * into #errors from tAPIErrorTemplate where 1 = 2

    declare @EffectiveUserKey   int       = @UserKey
    declare @IsAdministrator    bit
    declare @SecurityGroupKey   int
    declare @HasViewAll         bit       = 0
    declare @HasViewApproved    bit       = 0
    declare @IsApprover         bit       = 0

    -- ------------------------------------------------------------------
    -- 1. Validate dates
    -- ------------------------------------------------------------------
    if @StartDate is null or @EndDate is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''REQUIRED_FIELD'', ''startDate and endDate are required.'', ''startDate'')

        select errorType, errorCode, errorMessage, fieldName from #errors order by errorType desc, fieldName
        drop table #errors
        return -100
    end

    -- ------------------------------------------------------------------
    -- 2. Resolve optional target user
    -- ------------------------------------------------------------------
    if @TargetUserID is not null and LTRIM(RTRIM(@TargetUserID)) <> ''''
    begin
        select @EffectiveUserKey = UserKey
        from   tUser (nolock)
        where  ISNULL(OwnerCompanyKey, CompanyKey) = @CompanyKey
          and  (   UserID         like ''%'' + @TargetUserID + ''%''
                or Email          like ''%'' + @TargetUserID + ''%''
                or FirstName + '' '' + LastName like ''%'' + @TargetUserID + ''%'' )

        if @EffectiveUserKey is null
        begin
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''error'', ''NOT_FOUND'', ''User not found for targetUserID: '' + @TargetUserID, ''targetUserID'')

            select errorType, errorCode, errorMessage, fieldName from #errors order by errorType desc, fieldName
            drop table #errors
            return -101
        end
    end

    -- ------------------------------------------------------------------
    -- 3. Security check when viewing another user''s time
    -- ------------------------------------------------------------------
    if @EffectiveUserKey <> @UserKey
    begin
        -- Load caller''s admin flag and security group
        select @IsAdministrator   = Administrator,
               @SecurityGroupKey  = SecurityGroupKey
        from   tUser (nolock)
        where  UserKey = @UserKey and CompanyKey = @CompanyKey

        if @IsAdministrator <> 1
        begin
            -- Check billingviewalltime
            if exists (
                select 1
                from   tRight r (nolock)
                inner join tRightAssigned ra (nolock) on ra.RightKey = r.RightKey
                where  ra.EntityType = ''Security Group''
                  and  ra.EntityKey  = @SecurityGroupKey
                  and  r.RightID     = ''billingviewalltime''
            )
                set @HasViewAll = 1

            if @HasViewAll <> 1
            begin
                -- Check billingviewusersiapprove
                if exists (
                    select 1
                    from   tRight r (nolock)
                    inner join tRightAssigned ra (nolock) on ra.RightKey = r.RightKey
                    where  ra.EntityType = ''Security Group''
                      and  ra.EntityKey  = @SecurityGroupKey
                      and  r.RightID     = ''billingviewusersiapprove''
                )
                    set @HasViewApproved = 1

                if @HasViewApproved = 1
                begin
                    -- Confirm caller is the target user''s TimeApprover or BackupApprover
                    if exists (
                        select 1 from tUser (nolock)
                        where  UserKey = @EffectiveUserKey
                          and  (TimeApprover = @UserKey or BackupApprover = @UserKey)
                    )
                        set @IsApprover = 1
                end

                if @HasViewApproved = 0 or @IsApprover = 0
                begin
                    insert into #errors (errorType, errorCode, errorMessage, fieldName)
                    values (''error'', ''ACCESS_DENIED'',
                            ''You do not have permission to view time entries for this user.'',
                            ''targetUserID'')

                    select errorType, errorCode, errorMessage, fieldName from #errors order by errorType desc, fieldName
                    drop table #errors
                    return -103
                end
            end
        end
    end

    -- ------------------------------------------------------------------
    -- 4. Result set 1: warnings
    -- ------------------------------------------------------------------
    select errorType, errorCode, errorMessage, fieldName from #errors where errorType = ''warning''

    -- ------------------------------------------------------------------
    -- 5. Result set 2: time entries
    -- ------------------------------------------------------------------
    select
         u.FirstName                                                             as firstName
        ,u.LastName                                                             as lastName
        ,CONVERT(varchar(10), t.WorkDate, 101)                                  as workDate
        ,case when t.StartTime is null then '''' else CONVERT(varchar(5), t.StartTime, 108) end as startTime
        ,case when t.EndTime   is null then '''' else CONVERT(varchar(5), t.EndTime,   108) end as endTime
        ,ISNULL(t.ActualHours, 0)                                               as actualHours
        ,ISNULL(t.ActualRate, 0)                                                as actualRate
        ,ROUND(ISNULL(t.ActualHours, 0) * ISNULL(t.ActualRate, 0), 2)           as actualAmount
        ,ISNULL(p.ProjectNumber, '''')                                            as projectNumber
        ,ISNULL(p.ProjectName, '''')                                              as projectName
        ,ISNULL(ta.TaskID, '''')                                                  as taskID
        ,ISNULL(ta.TaskName, '''')                                                as taskName
        ,ISNULL(s.ServiceCode, '''')                                              as serviceCode
        ,ISNULL(s.Description, '''')                                              as serviceName
        ,ISNULL(t.Comments, '''')                                                 as comments
        ,case ts.Status
            when 1 then ''Open''
            when 2 then ''Submitted''
            when 3 then ''Rejected''
            when 4 then ''Approved''
            else ''Open''
         end                                                                    as timesheetStatus
        ,t.TimeKey                                                              as timeKey
    from   tTime t (nolock)
    inner join tTimeSheet ts (nolock)    on ts.TimeSheetKey = t.TimeSheetKey
    inner join tUser u (nolock)          on u.UserKey       = t.UserKey
    left outer join tProject p (nolock)  on p.ProjectKey    = t.ProjectKey
    left outer join tTask ta (nolock)    on ta.TaskKey       = t.TaskKey
    left outer join tService s (nolock)  on s.ServiceKey     = t.ServiceKey
    where  t.CompanyKey   = @CompanyKey
      and  t.UserKey      = @EffectiveUserKey
      and  t.WorkDate    >= @StartDate
      and  t.WorkDate    <= @EndDate
      and  t.TransferToKey is null
    order by t.WorkDate, t.StartTime, t.TimeKey

    drop table #errors
    return 0

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptProjectStatusUpdate]'
GO
IF OBJECT_ID(N'[dbo].[sptProjectStatusUpdate]', 'P') IS NOT NULL
EXEC sp_executesql N'




ALTER PROCEDURE [dbo].[sptProjectStatusUpdate]
	@ProjectStatusKey int,
	@CompanyKey int,
	@ProjectStatusID nvarchar(30),
	@ProjectStatus nvarchar(200),
	@DisplayOrder int,
	@StatusCategory smallint,
	@IsActive tinyint,
	@Active tinyint,
	@TimeActive tinyint,
	@ExpenseActive tinyint,
	@Locked tinyint,
	@OnHold tinyint,
	@IncludeInForecast tinyint,
	@IsDefault tinyint = 0,
	@UpdateBaseline tinyint = 0,
	@ProjectStatusColor varchar(50) = null

AS --Encrypt
  /*
  || When     Who Rel      What
  || 08/26/09 MAS 10.5.0.8 Added insert logic
  || 9/5/12   CRG 10.5.6.0 Added IncludeInForecast
  || 7/11/18  RLS 18.8     (TODO 4515) Added @Active parameter.
  || 10/08/19 RLS 18.8     (457489) Added IsDefault
  || 05/11/21 RLS 21.0.6.0 (556492) Changed ProjectStatusID to nvarchar
  || 05/11/21 RLS 21.0.6.0 (556492) Changed ProjectStatus to nvarchar
  || 08/05/24 CRG 24.09.15 (673989) Added UpdateBaseline
  || 03/31/26 GAR 26.04.19 (723332) Added ProjectStatusColor
  || 06/23/26 KMC 26.06.14 (731261) Fixed default value for @ProjectStatusColor.  Was ...varchar(50) null, updated to varchar(50) = null
  */

 if (@IsDefault = 1) -- make them all zero first
	BEGIN
		UPDATE tProjectStatus SET IsDefault = 0 WHERE CompanyKey = @CompanyKey 
	END

If @ProjectStatusKey <= 0
	BEGIN
		INSERT tProjectStatus
		(
		CompanyKey,
		ProjectStatusID,
		ProjectStatus,
		DisplayOrder,
		StatusCategory,
		IsActive,
		Active,
		TimeActive,
		ExpenseActive,
		Locked,
		OnHold,
		IncludeInForecast,
		IsDefault,
		UpdateBaseline,
		ProjectStatusColor
		)

		VALUES
		(
		@CompanyKey,
		@ProjectStatusID,
		@ProjectStatus,
		@DisplayOrder,
		@StatusCategory,
		@IsActive,
		@Active,
		@TimeActive,
		@ExpenseActive,
		@Locked,
		@OnHold,
		@IncludeInForecast,
		@IsDefault,
		@UpdateBaseline,
		@ProjectStatusColor
		)
					
		RETURN @@IDENTITY
	END
ELSE
	BEGIN
		IF EXISTS(
			SELECT 1
			FROM tProjectStatus (NOLOCK) 
			WHERE 
				ProjectStatusID = @ProjectStatusID AND
				CompanyKey = @CompanyKey AND
				ProjectStatusKey <> @ProjectStatusKey
		)

		RETURN -1
		
		UPDATE
			tProjectStatus
		SET
			CompanyKey = @CompanyKey,
			ProjectStatusID = @ProjectStatusID,
			ProjectStatus = @ProjectStatus,
			DisplayOrder = @DisplayOrder,
			StatusCategory = @StatusCategory,
			IsActive = @IsActive,
			Active = @Active,
			TimeActive = @TimeActive,
			ExpenseActive = @ExpenseActive,
			Locked = @Locked,
			OnHold = @OnHold,
			IncludeInForecast = @IncludeInForecast,
			IsDefault = @IsDefault,
			UpdateBaseline = @UpdateBaseline,
			ProjectStatusColor = @ProjectStatusColor
		WHERE
			ProjectStatusKey = @ProjectStatusKey 
		
		UPDATE
			tProject
		SET
			Active = @IsActive
		WHERE
			ProjectStatusKey = @ProjectStatusKey

		RETURN @ProjectStatusKey
	END

RETURN 1


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptPurchaseOrderDetailDelete]'
GO
IF OBJECT_ID(N'[dbo].[sptPurchaseOrderDetailDelete]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptPurchaseOrderDetailDelete]

	@PurchaseOrderDetailKey int
	,@UserKey int = null


AS --Encrypt

 /*
  || When     Who Rel      What
  || 02/20/07 GHL 8.4      Added project rollup section
  || 07/30/07 BSH 8.4.3.3  (10744)Fix PurchaseOrderTotal on POs, was not calculated on deletion.
  || 03/04/09 RTC 10.0.2.0 (48281) Changed validation for applied invoice to check specific POD line
  ||                               having a vendor invoice applied not any POD on the same order
  || 07/06/11 GHL 8.546    (111482) Added deletion of tax records tPurchaseOrderDetailTax 
  || 06/11/14 GHL 10.581   Added UserKey parameter for media print revision log
  || 06/23/15 MCM 10.593   (260832) Adding check on line number to see if exists prior to updating
  || 05/10/16 GHL 10.604   Added deletion of tEstimateTaskExpenseOrder
  || 03/11/19 GHL 19.400   (449701) Do not delete if the detail is prebilled
  || 01/27/21 MAS 210214   Set tMediaPlanDetail.PurchaseOrderDetailKey to NULL
  || 06/21/23 MAS 23.07.16 Removed Old Media tables
  || 07/08/26 MAS 26.07.19 (732506) Re-point tMediaPlanDetail.PurchaseOrderDetailKey at the latest surviving POD after
  ||                       deleting a POD (falling back to NULL when none remain), instead of nulling it before the delete.
  ||                       Deleting a media plan revision line was blanking the media plan buys grid Order column even
  ||                       though the original order line still existed.
  */
 
DECLARE @CurrentStatus int
DECLARE @Revision int
DECLARE @PurchaseOrderKey int
declare @LineNumber int
declare @AdjustmentNumber int
declare @POKind smallint
declare @ProjectKey int
declare @CompanyKey int
declare @MediaWorksheetKey int
declare @Status int
declare @InvoiceLineKey int
declare @MediaPlanDetailKey int


	SELECT @PurchaseOrderKey = PurchaseOrderKey
	      ,@LineNumber = LineNumber
	      ,@AdjustmentNumber = isnull(AdjustmentNumber, 0) -- new field, protect from nulls
		  ,@ProjectKey = ProjectKey
		  ,@InvoiceLineKey = InvoiceLineKey
		  ,@MediaPlanDetailKey = MediaPlanDetailKey
	FROM tPurchaseOrderDetail (NOLOCK)
	WHERE PurchaseOrderDetailKey = @PurchaseOrderDetailKey

	-- if the detail is prebilled, do not delete
	if @InvoiceLineKey > 0
		return -3

	select @POKind = POKind
	      ,@CompanyKey = CompanyKey
	      ,@MediaWorksheetKey = MediaWorksheetKey
		  ,@Status = Status
		  ,@Revision = isnull(Revision, 0)
	  from tPurchaseOrder (nolock)
	 where PurchaseOrderKey = @PurchaseOrderKey	
	
	IF EXISTS (SELECT 1
			FROM   tVoucherDetail vd (NOLOCK)
			WHERE  PurchaseOrderDetailKey = @PurchaseOrderDetailKey)
		RETURN -1

	IF EXISTS (SELECT 1
	           FROM		tPurchaseOrder po (NOLOCK)
	           WHERE  po.PurchaseOrderKey = @PurchaseOrderKey
	           AND    (po.Closed = 1))
		RETURN -2

	if @POKind = 2
		UPDATE tEstimateTaskExpense
		SET    PurchaseOrderDetailKey = NULL
		WHERE  PurchaseOrderDetailKey in (select PurchaseOrderDetailKey
		                                    from tPurchaseOrderDetail (nolock)
		                                   where PurchaseOrderKey = @PurchaseOrderKey 
		                                     and LineNumber = @LineNumber
		                                     and isnull(AdjustmentNumber, 0) = @AdjustmentNumber)
	else
		UPDATE tEstimateTaskExpense
		SET    PurchaseOrderDetailKey = NULL
		WHERE  PurchaseOrderDetailKey = @PurchaseOrderDetailKey 
	
	DELETE tEstimateTaskExpenseOrder where PurchaseOrderDetailKey = @PurchaseOrderDetailKey

	-- (media plan detail link is re-pointed after the POD is deleted - see below)

    if @POKind = 2
    BEGIN
		DELETE
		FROM tPurchaseOrderDetail
		WHERE
			PurchaseOrderKey = @PurchaseOrderKey 
		AND 
			LineNumber = @LineNumber
		AND 
			isnull(AdjustmentNumber, 0) = @AdjustmentNumber

		-- We can only move everything up if there are none with same line number
		IF NOT EXISTS (SELECT 1 FROM	tPurchaseOrderDetail (NOLOCK)
								WHERE  	PurchaseOrderKey = @PurchaseOrderKey 
								AND		LineNumber = @LineNumber)

			UPDATE tPurchaseOrderDetail
			SET    LineNumber = LineNumber - 1
			WHERE
				PurchaseOrderKey = @PurchaseOrderKey 
			AND 
				LineNumber > @LineNumber
	END
	else
	BEGIN
		DELETE
		FROM tPurchaseOrderDetailTax
		WHERE
			PurchaseOrderDetailKey = @PurchaseOrderDetailKey
	
		DELETE
		FROM tPurchaseOrderDetail
		WHERE
			PurchaseOrderDetailKey = @PurchaseOrderDetailKey
	
		if @POKind = 0  OR @POKind = 1 -- if it is a Purchase Order (0) or an insertion order (1) 
			begin
				-- We can only move everything up if there are none with same line number
				IF NOT EXISTS (SELECT 1 FROM	tPurchaseOrderDetail (NOLOCK)
								WHERE  	PurchaseOrderKey = @PurchaseOrderKey 
								AND		LineNumber = @LineNumber)

					UPDATE tPurchaseOrderDetail
					SET    LineNumber = LineNumber - 1
					WHERE
						PurchaseOrderKey = @PurchaseOrderKey 
					AND 
						LineNumber > @LineNumber			
			end
		else
			UPDATE tPurchaseOrderDetail
			SET    LineNumber = LineNumber - 1
			WHERE
				PurchaseOrderKey = @PurchaseOrderKey 
			AND 
				LineNumber > @LineNumber
	END

	-- If this POD came from a media plan, re-point the media plan detail at its latest surviving POD
	-- (or NULL when none remain) so the media plan buys grid does not show a blank Order column.
	if isnull(@MediaPlanDetailKey, 0) > 0
		update tMediaPlanDetail
		set    PurchaseOrderDetailKey = (select max(pod.PurchaseOrderDetailKey)
		                                   from tPurchaseOrderDetail pod (nolock)
		                                  where pod.MediaPlanDetailKey = @MediaPlanDetailKey
		                                    and pod.PurchaseOrderKey = @PurchaseOrderKey)
		where  MediaPlanDetailKey = @MediaPlanDetailKey

	exec sptPurchaseOrderRollupAmounts @PurchaseOrderKey

	UPDATE tPurchaseOrder
	SET   DateUpdated = CAST( CAST(MONTH(GETDATE()) as varchar) + ''/'' + CAST(DAY(GETDATE()) as varchar) + ''/'' + CAST(YEAR(GETDATE()) as varchar) as smalldatetime)
	WHERE  PurchaseOrderKey = @PurchaseOrderKey
		
	exec sptPurchaseOrderDetailUpdateApprover @PurchaseOrderKey
	
	EXEC sptProjectRollupUpdate @ProjectKey, 5, 1, 1, 1, 1 

	RETURN 1





'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptLayoutCopyFrom]'
GO
IF OBJECT_ID(N'[dbo].[sptLayoutCopyFrom]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptLayoutCopyFrom]   
	@LayoutName varchar(500) = NULL,
	@CopyItemOptionsKey int,
	@CopyEstimateLayoutKey int,
	@CopyInvoiceLayoutKey int
AS
/*
|| When      Who Rel      What
|| 05/21/20  MFT 20.0.6.0 (486491) Created for Platinum Layout Designer
|| 06/06/23  AMP 23.06.18 (623473) Modified the copy options for estimate and invoice layouts
|| 06/05/26  GAR 26.07.19 (712815) Added @URL for hyperlink controls
*/
SET NOCOUNT ON

DECLARE
	@NewLayoutKey int = 0,
	@LayoutReportKey int = 0,
	@NewLayoutReportKey int = 0,
	@Entity varchar(50)

CREATE TABLE #tLayoutReport
		(LayoutReportKey   int   NOT NULL,
	     LayoutKey   int  NULL,
	     Entity   varchar (50) NULL,
	     PaperType   varchar (50) NULL,
	     PaperWidth   smallint  NULL,
	     PaperHeight   smallint  NULL,
	     PaperOrientation   varchar (50) NULL,
	     MarginTop   smallint  NULL,
	     MarginBottom   smallint  NULL,
	     MarginLeft   smallint  NULL,
	     MarginRight   smallint  NULL,
	     Watermark   image  NULL,
	     WatermarkSizeMode   varchar (50) NULL,
	     WatermarkAlignment   varchar (50) NULL,
	     FontFamily   nvarchar (50) NULL,
	     FontSize   tinyint  NULL)


CREATE TABLE #tLayout
		(LayoutKey int not null
		,CompanyKey int not null
		,LayoutName varchar(500) not null
		,Entity varchar(50) not null
		,Active tinyint null
		,TaskDetailOption smallint null
		,TaskShowTransactions tinyint null
		,EstLineFormat smallint null)


CREATE TABLE #tLayoutSection 
        (LayoutReportKey   int  NOT NULL,
		 ElementID   smallint  NOT NULL,
		 ParentID   smallint  NOT NULL,
		 ReportTag   varchar (50) NOT NULL,
		 Type   varchar (50) NOT NULL,
		 Name   varchar (100) NOT NULL,
		 BackColor   int  NULL,
		 BorderColor   int  NULL,
		 BorderStyle   varchar (50) NULL,
		 BorderLeft   tinyint  NULL,
		 BorderRight   tinyint  NULL,
		 BorderTop   tinyint  NULL,
		 BorderBottom   tinyint  NULL,
		 BorderThickness   smallint  NULL,
		 Shadow   tinyint  NULL,
		 X   int  NULL,
		 Y   int  NULL,
		 Height   int  NULL,
		 Width   int  NULL,
		 CanGrow   tinyint  NOT NULL,
		 CanShrink   tinyint  NOT NULL,
		 PrintAtBottom   tinyint  NULL,
		 KeepTogether   tinyint  NULL)

CREATE TABLE #tLayoutItems 
	   (LayoutReportKey   int  NOT NULL,
	     ElementID   smallint  NOT NULL,
		 ParentID   smallint  NOT NULL,
		 ReportTag   varchar (50) NOT NULL,
		 Type   varchar (50) NOT NULL,
		 Name   varchar (100) NOT NULL,
		 BackColor   int  NULL,
		 BorderColor   int  NULL,
		 BorderStyle   varchar (50) NULL,
		 BorderLeft   tinyint  NULL,
		 BorderRight   tinyint  NULL,
		 BorderTop   tinyint  NULL,
		 BorderBottom   tinyint  NULL,
		 BorderThickness   smallint  NULL,
		 Shadow   tinyint  NULL,
		 X   int  NULL,
		 Y   int  NULL,
		 Height   int  NULL,
		 Width   int  NULL,
		 Text   nvarchar (max) NULL,
		 FontFamily   varchar (50) NULL,
		 FontSize   smallint  NULL,
		 FontItalic   tinyint  NULL,
		 FontBold   tinyint  NULL,
		 FontUnderline   tinyint  NULL,
		 TextAlign   varchar (50) NULL,
		 LineColor   int  NULL,
		 LineStyle   varchar (50) NULL,
		 LineWeight   tinyint  NULL,
		 X1   int  NULL,
		 Y1   int  NULL,
		 X2   int  NULL,
		 Y2   int  NULL,
		 CornerRadius   smallint  NULL,
		 ShapeType   varchar (50) NULL,
		 ImageAlignment   varchar (50) NULL,
		 ImageMode   varchar (50) NULL,
		 ConfigData   text  NULL,
		 DataField   varchar (200) NULL,
		 ForeColor   int  NULL,
		 ImageData   image  NULL,
		 CanGrow   tinyint  NULL,
		 CanShrink   tinyint  NULL,
		 WordWrap   tinyint  NULL,
		 DataType   varchar (50) NULL,
		 DecimalPlaces   smallint  NULL,
		 ShowCurrencySymbol   tinyint  NULL,
		 SuppressZeroRow   tinyint  NULL,
		 URL   nvarchar (512) NULL)

DECLARE @LayoutReportKeys table (LayoutReportKey int, NewLayoutReportKey int, Entity varchar(50))

SELECT @Entity = Entity
FROM tLayout (nolock)
WHERE LayoutKey = @CopyItemOptionsKey

--If you are copying the item options
IF @Entity = ''billing'' AND @CopyItemOptionsKey > 0
BEGIN	
	Insert #tLayout
	(LayoutKey,CompanyKey,LayoutName,Entity,Active,TaskDetailOption,TaskShowTransactions,EstLineFormat )
	SELECT  LayoutKey,CompanyKey,LayoutName,Entity,Active,TaskDetailOption,TaskShowTransactions,EstLineFormat
	FROM tLayout (nolock)
	WHERE LayoutKey = @CopyItemOptionsKey

	ALTER TABLE #tLayout
	DROP COLUMN LayoutKey 

	UPDATE #tLayout
	SET LayoutName = ISNULL(@LayoutName, ''Copy of '' + ISNULL(LayoutName, ''''))

	INSERT INTO tLayout
	SELECT *
	FROM #tLayout
	SELECT @NewLayoutKey = SCOPE_IDENTITY()

	SELECT *
	INTO #tLayoutBilling
	FROM tLayoutBilling (nolock)
	WHERE LayoutKey = @CopyItemOptionsKey
		
	UPDATE #tLayoutBilling
	SET LayoutKey = @NewLayoutKey
			
	INSERT INTO tLayoutBilling
	SELECT *
	FROM #tLayoutBilling
		
	DROP TABLE #tLayoutBilling
	
	INSERT #tLayoutReport (LayoutReportKey,LayoutKey,Entity,PaperType,PaperWidth,PaperHeight,PaperOrientation,MarginTop,MarginBottom,MarginLeft,MarginRight,Watermark,WatermarkSizeMode,WatermarkAlignment,FontFamily,FontSize)
	SELECT LayoutReportKey,@NewLayoutKey,Entity,PaperType,PaperWidth,PaperHeight,PaperOrientation,MarginTop,MarginBottom,MarginLeft,MarginRight,Watermark,WatermarkSizeMode,WatermarkAlignment,FontFamily,FontSize
	FROM tLayoutReport (nolock)
	WHERE LayoutKey = @CopyItemOptionsKey 
	AND   Entity = ''billing''

	INSERT INTO @LayoutReportKeys (LayoutReportKey,Entity)
	SELECT LayoutReportKey,Entity
	FROM #tLayoutReport

	UPDATE #tLayoutReport
	SET LayoutKey = @NewLayoutKey	
END

--If you are copying only an estimate layout
IF @CopyEstimateLayoutKey > 0 
BEGIN
    DELETE #tLayout
    DELETE #tLayoutReport

	IF @NewLayoutKey = 0 
	BEGIN		
		Insert #tLayout
				(LayoutKey,CompanyKey,LayoutName,Entity,Active,TaskDetailOption,TaskShowTransactions,EstLineFormat )
		SELECT LayoutKey,CompanyKey,LayoutName,Entity,Active,TaskDetailOption,TaskShowTransactions,EstLineFormat
		FROM tLayout (nolock)
		WHERE LayoutKey = @CopyEstimateLayoutKey

		ALTER TABLE #tLayout
		DROP COLUMN LayoutKey 

		UPDATE #tLayout
		SET LayoutName = ISNULL(@LayoutName, ''Copy of '' + ISNULL(LayoutName, ''''))

		INSERT INTO tLayout
		SELECT *
		FROM #tLayout

		SELECT @NewLayoutKey = SCOPE_IDENTITY()
	END
	
	INSERT #tLayoutReport
	(LayoutReportKey,LayoutKey,Entity,PaperType,PaperWidth,PaperHeight,PaperOrientation,MarginTop,MarginBottom,MarginLeft,MarginRight,Watermark,WatermarkSizeMode,WatermarkAlignment,FontFamily,FontSize)
	SELECT  LayoutReportKey,@NewLayoutKey,Entity,PaperType,PaperWidth,PaperHeight,PaperOrientation,MarginTop,MarginBottom,MarginLeft,MarginRight,Watermark,WatermarkSizeMode,WatermarkAlignment,FontFamily,FontSize
	FROM tLayoutReport (nolock)
	WHERE
		LayoutKey = @CopyEstimateLayoutKey AND
		Entity = ''estimate''
   
   DELETE @LayoutReportKeys

	INSERT INTO @LayoutReportKeys (
		LayoutReportKey,
		Entity
	)
	SELECT
		LayoutReportKey,
		Entity
	FROM #tLayoutReport

	UPDATE #tLayoutReport
	SET LayoutKey = @NewLayoutKey

	WHILE(1=1)
		BEGIN
			SELECT TOP 1 @LayoutReportKey = lrk.LayoutReportKey
			FROM
				#tLayoutReport lr
				INNER JOIN @LayoutReportKeys lrk ON lr.Entity = lrk.Entity
			ORDER BY lr.Entity
		
			IF @LayoutReportKey IS NULL 
				BREAK

			INSERT INTO tLayoutReport
			SELECT TOP 1 
			       lr.LayoutKey,
		           lr.Entity,
		           lr.PaperType,
			       lr.PaperWidth,
			       lr.PaperHeight,
			       lr.PaperOrientation,
			       lr.MarginTop,
			       lr.MarginBottom,
			       lr.MarginLeft,
			       lr.MarginRight,
			       lr.Watermark,
			       lr.WatermarkSizeMode,
			       lr.WatermarkAlignment,
			       lr.FontFamily,
			       lr.FontSize
			FROM
				#tLayoutReport lr
				INNER JOIN @LayoutReportKeys lrk ON lr.Entity = lrk.Entity
			WHERE lrk.LayoutReportKey = @LayoutReportKey
		
			SELECT @NewLayoutReportKey = SCOPE_IDENTITY()
	   
			UPDATE @LayoutReportKeys
			SET NewLayoutReportKey = @NewLayoutReportKey
			WHERE LayoutReportKey = @LayoutReportKey
			
			DELETE #tLayoutReport
			FROM
				#tLayoutReport lr
				INNER JOIN @LayoutReportKeys lrk ON lr.Entity = lrk.Entity
			WHERE lrk.LayoutReportKey = @LayoutReportKey

			SELECT @LayoutReportKey = NULL
		END

	INSERT #tLayoutSection (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		                    BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		                    Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether)
	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		   BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		   Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether
	FROM tLayoutSection (nolock)
	WHERE LayoutReportKey IN (SELECT LayoutReportKey
		                      FROM @LayoutReportKeys)

	UPDATE #tLayoutSection
	SET LayoutReportKey = lrk.NewLayoutReportKey
	FROM
		#tLayoutSection ls
		INNER JOIN @LayoutReportKeys lrk ON ls.LayoutReportKey = lrk.LayoutReportKey
		
	INSERT #tLayoutItems (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
						  BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
						  FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
						  ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
						  WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL)

	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
		   BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
		   FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
		   ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
		   WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL
	FROM tLayoutItems (nolock)
	WHERE LayoutReportKey IN (SELECT LayoutReportKey
							  FROM @LayoutReportKeys)

	UPDATE #tLayoutItems
	SET LayoutReportKey = lrk.NewLayoutReportKey
	FROM
		#tLayoutItems li
		INNER JOIN @LayoutReportKeys lrk ON li.LayoutReportKey = lrk.LayoutReportKey


	INSERT INTO tLayoutSection (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		                        BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		                        Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether)
	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		   BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		   Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether
    FROM #tLayoutSection

	INSERT INTO tLayoutItems (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
						  BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
						  FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
						  ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
						  WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL)
	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
	       BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
           FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
           ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
           WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL
	FROM #tLayoutItems
END

--If you are copying only an invoice layout
IF @CopyInvoiceLayoutKey > 0 
BEGIN
	DELETE #tLayout
	DELETE #tLayoutReport

	IF @NewLayoutKey = 0 
	BEGIN
		INSERT #tLayout	(LayoutKey,CompanyKey,LayoutName,Entity,Active,TaskDetailOption,TaskShowTransactions,EstLineFormat )
		SELECT LayoutKey,CompanyKey,LayoutName,Entity,Active,TaskDetailOption,TaskShowTransactions,EstLineFormat
		FROM   tLayout (nolock)
		WHERE  LayoutKey = @CopyInvoiceLayoutKey

		ALTER TABLE #tLayout
		DROP COLUMN LayoutKey 

		UPDATE #tLayout
		SET LayoutName = ISNULL(@LayoutName, ''Copy of '' + ISNULL(LayoutName, ''''))

		INSERT INTO tLayout
		SELECT *
		FROM #tLayout
		SELECT @NewLayoutKey = SCOPE_IDENTITY()
	END
	
	INSERT #tLayoutReport (LayoutReportKey,LayoutKey,Entity,PaperType,PaperWidth,PaperHeight,PaperOrientation,MarginTop,MarginBottom,MarginLeft,MarginRight,Watermark,WatermarkSizeMode,WatermarkAlignment,FontFamily,FontSize)
	SELECT LayoutReportKey,@NewLayoutKey,Entity,PaperType,PaperWidth,PaperHeight,PaperOrientation,MarginTop,MarginBottom,MarginLeft,MarginRight,Watermark,WatermarkSizeMode,WatermarkAlignment,FontFamily,FontSize
	FROM tLayoutReport (nolock)
	WHERE
		LayoutKey = @CopyInvoiceLayoutKey AND
		Entity = ''invoice''

	DELETE @LayoutReportKeys

	INSERT INTO @LayoutReportKeys (
		LayoutReportKey,
		Entity
	)
	SELECT
		LayoutReportKey,
		Entity
	FROM #tLayoutReport
	
	ALTER TABLE #tLayoutReport
	DROP COLUMN LayoutReportKey

	UPDATE #tLayoutReport
	SET LayoutKey = @NewLayoutKey

	WHILE(1=1)
		BEGIN
			SELECT TOP 1 @LayoutReportKey = lrk.LayoutReportKey
			FROM
				#tLayoutReport lr
				INNER JOIN @LayoutReportKeys lrk ON lr.Entity = lrk.Entity
			ORDER BY lr.Entity
		
			IF @LayoutReportKey IS NULL 
				BREAK

			INSERT INTO tLayoutReport			
			SELECT TOP 1 
			       lr.LayoutKey,
		           lr.Entity,
		           lr.PaperType,
			       lr.PaperWidth,
			       lr.PaperHeight,
			       lr.PaperOrientation,
			       lr.MarginTop,
			       lr.MarginBottom,
			       lr.MarginLeft,
			       lr.MarginRight,
			       lr.Watermark,
			       lr.WatermarkSizeMode,
			       lr.WatermarkAlignment,
			       lr.FontFamily,
			       lr.FontSize
			FROM
				#tLayoutReport lr
				INNER JOIN @LayoutReportKeys lrk ON lr.Entity = lrk.Entity
			WHERE lrk.LayoutReportKey = @LayoutReportKey

			SELECT @NewLayoutReportKey = SCOPE_IDENTITY()
			
			UPDATE @LayoutReportKeys
			SET NewLayoutReportKey = @NewLayoutReportKey
			WHERE LayoutReportKey = @LayoutReportKey

			DELETE #tLayoutReport
			FROM
				#tLayoutReport lr
				INNER JOIN @LayoutReportKeys lrk ON lr.Entity = lrk.Entity
			WHERE lrk.LayoutReportKey = @LayoutReportKey

			SELECT @LayoutReportKey = NULL
		END

		DELETE #tLayoutSection

	INSERT #tLayoutSection (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		                    BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		                    Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether)
	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		   BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		   Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether
	FROM tLayoutSection (nolock)
	WHERE LayoutReportKey IN (SELECT LayoutReportKey
							  FROM @LayoutReportKeys)
							 
	UPDATE #tLayoutSection
	SET LayoutReportKey = lrk.NewLayoutReportKey
	FROM
		#tLayoutSection ls
		INNER JOIN @LayoutReportKeys lrk ON ls.LayoutReportKey = lrk.LayoutReportKey
	
	DELETE #tLayoutItems
	
	INSERT #tLayoutItems (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
						  BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
						  FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
						  ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
						  WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL)

	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
	       BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
           FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
           ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
           WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL
	FROM tLayoutItems (nolock)
	WHERE LayoutReportKey IN (SELECT LayoutReportKey
							  FROM @LayoutReportKeys)

	UPDATE #tLayoutItems
	SET LayoutReportKey = lrk.NewLayoutReportKey  
	FROM
		#tLayoutItems li
		INNER JOIN @LayoutReportKeys lrk ON li.LayoutReportKey = lrk.LayoutReportKey

	INSERT INTO tLayoutSection (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		                        BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		                        Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether)
	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,   
		   BorderColor,BorderStyle,BorderLeft,BorderRight,BorderTop,BorderBottom,BorderThickness, 
		   Shadow,X,Y,Height,Width,CanGrow,CanShrink,PrintAtBottom,KeepTogether
    FROM #tLayoutSection

	INSERT INTO tLayoutItems (LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
						  BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
						  FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
						  ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
						  WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL)
	SELECT LayoutReportKey,ElementID,ParentID,ReportTag,Type,Name,BackColor,BorderColor,BorderStyle,BorderLeft,
	       BorderRight,BorderTop,BorderBottom,BorderThickness,Shadow,X,Y,Height,Width,Text,FontFamily,FontSize,
           FontItalic,FontBold,FontUnderline,TextAlign,LineColor,LineStyle,LineWeight,X1,Y1,X2,Y2,CornerRadius,
           ShapeType,ImageAlignment,ImageMode,ConfigData,DataField,ForeColor,ImageData,CanGrow,CanShrink,
           WordWrap,DataType,DecimalPlaces,ShowCurrencySymbol,SuppressZeroRow,URL
	FROM #tLayoutItems


END

DROP TABLE #tLayoutItems
DROP TABLE #tLayoutSection
DROP TABLE #tLayoutReport
DROP TABLE #tLayout

RETURN @NewLayoutKey
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptApprovalStepGetDelAllDetails]'
GO
IF OBJECT_ID(N'[dbo].[sptApprovalStepGetDelAllDetails]', 'P') IS NOT NULL
EXEC sp_executesql N'

ALTER PROCEDURE [dbo].[sptApprovalStepGetDelAllDetails]
@ApprovalStepKey int,
@Entity varchar(200) = ''tReviewRound''

AS --Encrypt

/*
|| When     Who		Rel			What
|| 04/20/17 RLB     10.6.1.5    Created to get all the information i need at any time
|| 11/23/20 RLB     20.1.2.0    (523390) Added Project Request Entity and added counts to them all for rounds with no approvers
|| 11/17/21 RLB     21.12.19    (523390) updated to handle PR and always pass back an EntityFullName in cases or an error will be thrown
|| 11/10/22 RLB     22.12.18    (618093) Added fields to send nofity when last user complete round
|| 12/22/22 RLS     23.01.15    (625513) Added Check for Campaign
|| 05/04/26 RLB     26.06.14    (721431) Pull new project request def option SendIndividualApprovedEmails
*/


if @Entity = ''tReviewRound''
BEGIN
	--First see if this is a campaign:
	DECLARE @ProjectKey INT

	SELECT  @ProjectKey = ISNULL(rd.ProjectKey , 0)
		FROM tReviewDeliverable rd 
		inner join tReviewRound rr on rd.ReviewDeliverableKey = rr.ReviewDeliverableKey
		inner join tApprovalStep aps on rr.ReviewRoundKey = aps.EntityKey
		WHERE ApprovalStepKey = @ApprovalStepKey

	IF @ProjectKey > 0 -- Continue as usual. Not a campaign
	BEGIN

		SELECT aps.*, rr.ReviewRoundKey, rr.ReviewDeliverableKey, rd.ProjectKey, rr.RoundName, p.ProjectName, p.ProjectNumber
				,(SELECT COUNT(*) FROM tApprovalStepUser (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as ApprovalUserCount
				,(SELECT COUNT(*) FROM tApprovalStepNotify (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as NotifyUserCount
				, (Select ISNULL(DeliverableName, '''') from tReviewDeliverable  (NOLOCK) where ReviewDeliverableKey = rr.ReviewDeliverableKey) as EntityFullName
			FROM tApprovalStep aps (nolock)
			inner join tReviewRound rr (NOLOCK) on aps.EntityKey = rr.ReviewRoundKey
			inner join tReviewDeliverable rd (NOLOCK) on rr.ReviewDeliverableKey = rd.ReviewDeliverableKey
			inner join tProject p (NOLOCK) on rd.ProjectKey = p.ProjectKey
			WHERE
			ApprovalStepKey = @ApprovalStepKey
	END
	ELSE IF @ProjectKey < 0 -- Negative ProjectKey indicates a Campaign
	BEGIN
		-- Get the campaign data to use as Project data:
		DECLARE @CampaignID nvarchar(50), @CampaignName nvarchar(200)

		SELECT @CampaignID = CampaignID,
			   @CampaignName = CampaignName
		FROM tCampaign
		WHERE CampaignKey = abs(@ProjectKey)

		-- Data to return
		SELECT aps.*, rr.ReviewRoundKey, rr.ReviewDeliverableKey, 
			@ProjectKey AS ProjectKey, -- will be the negative CampaignKey
			rr.RoundName, 
			@CampaignName AS ProjectName,
			@CampaignID AS ProjectNumber
			,(SELECT COUNT(*) FROM tApprovalStepUser (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as ApprovalUserCount
			,(SELECT COUNT(*) FROM tApprovalStepNotify (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as NotifyUserCount
			, (Select ISNULL(DeliverableName, '''') from tReviewDeliverable  (NOLOCK) where ReviewDeliverableKey = rr.ReviewDeliverableKey) as EntityFullName
			FROM tApprovalStep aps (nolock)
			inner join tReviewRound rr (NOLOCK) on aps.EntityKey = rr.ReviewRoundKey
			inner join tReviewDeliverable rd (NOLOCK) on rr.ReviewDeliverableKey = rd.ReviewDeliverableKey
			WHERE
			ApprovalStepKey = @ApprovalStepKey
	END --if @ProjectKey > 0
END -- if @Entity = ''tReviewRound''

if @Entity = ''tChange''
BEGIN
	SELECT aps.*, cg.ChangeKey
	, cg.Entity as ChangeEntity
	, cg.EntityKey as ChangeEntityKey
	,CASE cg.Entity
				WHEN ''Project'' then (SELECT tProject.ProjectNumber + ''-'' + tProject.ProjectName FROM tProject (nolock) where ProjectKey = cg.EntityKey)
				ELSE (SELECT tCampaign.CampaignID + ''-'' + tCampaign.CampaignName FROM tCampaign (nolock) where CampaignKey = cg.EntityKey)
			END as EntityFullName
	,CASE cg.Entity
				WHEN ''Project'' then (SELECT tProject.ProjectNumber FROM tProject (nolock) where ProjectKey = cg.EntityKey)
				ELSE (SELECT tCampaign.CampaignID FROM tCampaign (nolock) where CampaignKey = cg.EntityKey)
			END as EntityNumber
	,CASE cg.Entity
				WHEN ''Project'' then (SELECT tProject.ProjectName FROM tProject (nolock) where ProjectKey = cg.EntityKey)
				ELSE (SELECT tCampaign.CampaignName FROM tCampaign (nolock) where CampaignKey = cg.EntityKey)
			END as EntityName
	,(SELECT COUNT(*) FROM tApprovalStepUser (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as ApprovalUserCount
	,(SELECT COUNT(*) FROM tApprovalStepNotify (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as NotifyUserCount
	FROM tApprovalStep aps (nolock)
	inner join tChange cg (NOLOCK) on aps.EntityKey = cg.ChangeKey
	WHERE
	ApprovalStepKey = @ApprovalStepKey

END

if @Entity = ''ProjectRequest''
BEGIN
	SELECT aps.*, rq.RequestKey
	, rq.RequestID
	, rq.RequestDefKey
	,rqd.RequestName
	,ISNULL(rqd.SendIndividualApprovedEmails, 1) as SendIndividualApprovedEmails
	, rq.Subject as EntityFullName
	,(SELECT COUNT(*) FROM tApprovalStepUser (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as ApprovalUserCount
	,(SELECT COUNT(*) FROM tApprovalStepNotify (NOLOCK) where ApprovalStepKey = @ApprovalStepKey) as NotifyUserCount
	FROM tApprovalStep aps (nolock)
	inner join tRequest rq (NOLOCK) on aps.EntityKey = rq.RequestKey
	left outer join tRequestDef rqd (NOLOCK) on rq.RequestDefKey = rqd.RequestDefKey
	WHERE
	ApprovalStepKey = @ApprovalStepKey

END


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spMassBillingGetMedia]'
GO
IF OBJECT_ID(N'[dbo].[spMassBillingGetMedia]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spMassBillingGetMedia]
 @UserKey int,  
 @IO tinyint,  
 @IOBeginDate datetime,  
 @IOEndDate datetime,  
 @BC tinyint,  
 @BCBeginDate datetime,  
 @BCEndDate datetime,  
 @Invoice tinyint,  
 @InvoiceBeginDate datetime,  
 @InvoiceEndDate datetime,  
 @ClientKey int,  
 @ClientDivisionKey int,  
 @ClientProductKey int,  
 @CampaignKey int,  
 @MediaMarketKey int,  
 @PurchaseOrderNumber varchar(30),  
 @TaskID nvarchar(30),  
 @GLCompanyKey int = -1,  -- -1: All, 0: None, or valid record   
 @OfficeKey int = -1,   -- -1: All, 0: None, or valid record  
 @OpenOrdersOnlyOnInvoices int = 0,  
 @ProjectKey int = null,  
 @MediaEstimateKey int = null,  
 @AccountManager int = null,  
 @UseInvoicePostingDate tinyint = 0, -- 0 Invoice Date, 1 Posting Date, 2 Order Date  
 -- added for new media screens  
 @Interactive tinyint = 0,  
 @InteractiveBeginDate datetime = null,  
 @InteractiveEndDate datetime = null,  
 @MediaWorksheetKey int = null,  
 @CompanyMediaKey int = null,  
 @OpenOrdersOnly int = 1,  
 @ParentClientKey int = null, 
 @MediaPlanKey int = null,  
 @IncludeOverheadClients tinyint = 1,
 @CountOnly tinyint = 0
  
AS --Encrypt  
  
/*  
|| When     Who Rel     What  
|| 07/16/07 RTC 8.4.3.2 (#9930) Use Flight Start Date instead of Flight End Date to determine what is included in the search results.  
|| 10/18/07 GHL 8.438   (14701) Removed restrictions on vouchers with po closed  
|| 12/20/07 GHL 8.5     (17723) Added restrictions on vouchers with po closed because another customer complained  
||                       Using now a parameter to determine this  
|| 01/24/08 GHL 8.502   (19677) Nerland. Changed Project on invoices from pod.ProjectKey to v.ProjectKey       
|| 07/03/08 GHL 8.515   (29754) Push. Having problems because a broadcast order has 2 spots, one qty = 1, one qty =-1  
||                       causing invoice amount on the line = 0. In that case, delete records where group unbilled amount = 0     
|| 09/16/08 GHL 10.009  (33073) a-b-c. Allowing now 0 summary unbilled amount because cost must be applied to client   
|| 10/06/08 GHL 10.010  (35266) Timeout errors. Removed join with tTask. Added po.CompanyKey to where clause  
||                      Added client key to where clause.  
|| 03/10/11 GHL 10.452  (84790) Added filters by Project and Media Estimate  
|| 06/23/11 GHL 10.545  (60333) Added extra fields so that the sp can be used for the media billing report  
|| 09/01/11 GHL 10.547  (120201) Do not include vendor invoice lines which have been written off   
|| 12/27/11 GHL 10.551  (129332) Do not remove recs if UnbilledAmount = 0   
|| 04/10/12 GHL 10.555  Added logic for UserGLCompanyAccess  
|| 10/30/12 KMC 10.561  (152562) Added the TaskID logic back in and added the grouping option by TaskID in the client  
|| 10/31/12 KMC 10.561  (152563) Added the Hide Details option, which included adding columns to the #tMediaMassBilling  
||                      table to be shown in the summary report  
|| 11/2/12  KMC 10.561  (152562 & 152563) Updated SP after review with Chris and Gil.  Moved the JOIN to tTask out of the  
||                      primary INSERT/SELECT and updated the temp table afterwards.  Also appended the TaskName to the   
||                      TaskID.  
|| 01/04/13 WDF 10.563  (159100) Added AccountManager  
|| 01/07/13 GHL 10.563  (159100) Added Nolock hint  
|| 05/01/13 GHL 10.567  (176580) Added Adjustment #, Invoice Number, Invoice Line Number to help with media report  
|| 08/26/13 RLB 10.571  (185716) add filter for account manager for report  
|| 10/04/13 GHL 10.573  Added support for multi currency  
|| 10/24/13 MFT 10.573  Added @UseInvoicePostingDate and CASE logic  
|| 03/17/14 RLB 10.587  (198748) Added logic on case for Related Order Date  
|| 04/23/14 GHL 10.579  Added support for media worksheets  
|| 05/14/14 GHL 10.579  Fixed query used for invoices and IO  
|| 06/05/14 GHL 10.581  Added Media Worksheet Name  
|| 09/04/14 GHL 10.584  (228260) Added param @OpenOrdersOnly for new media screen  
||                      Must be able to bill closed orders  
|| 09/17/14 GHL 10.584 (217847) Added param @ParentClientKey for enhancement  
|| 10/31/14 GHL 10.585  Added SalesTaxAmount to support Pass Through Taxes PTT (from Publication to client invoice)  
||                      Requested by SM to identity publications with PTT and bill one line per publication  
|| 02/12/15 PLC 10.589  Added logic to limit the zero billable invoices because mk good are added to the purchaseorder  
|| 07/22/16 GHL 10.606 Do not take projects which have an open worksheet (ToDo DEV1746-Mass Billing)  
|| 08/22/16 WDF 10.607  (311021) Added MarketName  
|| 08/25/16 GHL 10.607  Added word of caution when summarizing data  
|| 12/20/17 GHL 18.100  (377939) Added stripping of times  
|| 04/18/19 GHL 19.500  (447171) Added currency ID  
|| 10/14/19 GHL 19.110  (483843) Increase size of OrderProgram from 30 to 150  
|| 04/14/20 MCM 20.050  (471784) Added Overhead client so can filter it out  
|| 07/13/21 RLS 21.0.8.0 (564254) Changed @TaskID to nvarchar(30)  
|| 01/21/22 GHL 22.0.2.0 (584962) Added the ability to bill unapplied VIs (using tItem.ItemType = 1, 2 instead of POKind)  
|| 06/09/22 GHL 22.0.7.0 (602660) Take credit card charges, add a ParentKey for the drill down (Voucher or Credit Card Charge)    
|| 07/18/22 MCM 22.0.8.0 (606204) Updated the group by for the estimateName to be isnull(estimateName, '''') when inserting into #tMediaMassBilling  
|| 02/02/23 AMP 23.03.19 (628305) Added Media Plan ID and Media Plan Name     
|| 06/21/23 MAS 23.07.16 Removed old media references, tMediaWorksheet  
|| 11/17/23 QMD 23.11.19 (657618) Performance Initiative 
|| 12/20/23 QMD 24.01.21  (657618) Performance Initiative - switched to using tCache
|| 01/09/24 QMD 24.01.21  (657618) Performance Initiative - fixed datatype
|| 01/16/25 MFT 25.01.00 (670641) Removed pod lines included in a Retainer
|| 01/16/25 RLB 26.02.15 (718215) Add Media Plan option
|| 02/18/26 MCM 26.03.15 (722379) Fix issue with the Estimate Name
|| 06/23/26 MFT 26.07.15 (730939) Removed MediaPlanKey/PlanName from #tMediaMassBilling summary grouping
*/

/*  
 create table #tMediaMassBilling (  
        ClientKey           int,  
        CustomerID varchar(75),  
        ProjectKey int null,  
        AccountManager varchar(201) null,  
        ProjectName varchar(200) null,  
        MediaEstimateKey int null,  
        EstimateName varchar(200) null,  
		MediaPlanKey int null,  
        PlanName varchar(200) null,  
        UnbilledAmount money null,  
        SalesTaxAmount money null,  
        DetailOrderDate datetime null,  
        DetailOrderEndDate datetime null,  
        OrderProgram varchar(150) null,  
        Quantity decimal(24,4) null,  
        TotalCost money null,  
        MediaWorksheetKey int null,  
        MarketName varchar(200) null,   
        WorksheetID varchar(50) null,   
        WorksheetName varchar(1000) null,  
  CurrencyID varchar(10) null,  
        ParentKey int null,                   
        PlanID varchar(50) null,   
        PlanName varchar(300) null   
  )  
   
  
 create table #tMediaMassBillingDetail (  
  GLCompanyKey  int null,  
  OfficeKey   int null,  
     ClientKey           int null,  
        CustomerID          varchar(75) null,  
        Entity              varchar(10) null,  
  EntityKey           int null,  
        EntityDate          datetime null,  
        EntityNumber        varchar(50) null,  
  ProjectKey   int null,  
  ProjectName   varchar(200) null,  
  MediaEstimateKey int null,  
  EstimateName  varchar(200) null,  
  ClientDivisionKey   int  null,  
  ClientProductKey    int null,  
  CampaignKey         int null,  
        MediaMarketKey      int null,  
        PurchaseOrderNumber varchar(30) null,  
        TaskID              varchar(60) null,  
        DetailOrderDate     datetime null,  
        DetailOrderEndDate  datetime null,  
  MediaID             varchar(50) null,  
  OrderProgram        varchar(150) null,  
  OrderTime           varchar(50) null,  
  Quantity            decimal(24,4) null,  
  UnitCost            money null,  
  TotalCost           money null,  
  UnbilledAmount      money null,  
  SalesTaxAmount      money null,  
  
  -- added so that the stored proc can be used in new report Media Billing  
  LineNumber          int null,  
  CompanyMediaKey  int null,  
  VendorKey   int null,  
  StationName   varchar(255) null,  
  TransactionMonth VARCHAR(20) NULL,  
  TransactionMonthNumeric INT NULL,  
  TransactionType     varchar(50) null,  
  CompanyName         varchar(255) null, -- will hold the Client Name  
  AccountManager      varchar(255) null,  
  
  -- Added to help out with media   
  AdjustmentNumber    int null,  
  LineAdjustment      varchar(50) null, -- will hold PO LineNumber + PO AdjustmentNumber  
  InvoiceLineNumber   int null,  
  InvoiceNumber       varchar(50) null,  
  InvoiceDetails      varchar(100) null, -- will hold InvoiceNumber + InvoiceLineNumber  
  
  -- Added for new media screens  
  MediaWorksheetKey int null,  
  WorksheetID varchar(50) null,  
  WorksheetName varchar(1000) null,  
  CurrencyID varchar(10) null,  
  
   -- Added for the drill down, the parent key will be the VoucherKey or the PurchaseOrderKey  
        ParentKey int null,  
  
  PlanID varchar(50) null, "          PlanName varchar(300) null "  
  )  
*/  
  
declare @CompanyKey int  
declare @IOClientLink tinyint  
declare @BCClientLink tinyint  
declare @CurrencyID varchar(10)  

DECLARE @MediaUnbilledAmount money


IF @CountOnly = 1  
	BEGIN
		SELECT	@MediaUnbilledAmount = ProcessAmount
		FROM	tCache (NOLOCK)
		WHERE	Entity = ''tUser''
				AND EntityKey = @UserKey
				AND ProcessID = ''today.billing.mediaUnbilledAmount''
				AND Expiration > GETDATE()

		IF @MediaUnbilledAmount IS NOT NULL
			RETURN ISNULL(@MediaUnbilledAmount , 0)   			
	END 
    
 truncate table #tMediaMassBilling  
 truncate table #tMediaMassBillingDetail  
   
 if @IOEndDate is null  
  select @IOEndDate = ''01/01/2050''  
 if @BCEndDate is null  
  select @BCEndDate = ''01/01/2050''  
 if @InteractiveEndDate is null  
  select @InteractiveEndDate = ''01/01/2050''  
 if @InvoiceEndDate is null  
  select @InvoiceEndDate = ''01/01/2050''  
    
 -- strip times  
 select @IOBeginDate = convert(datetime,  convert(varchar(10), @IOBeginDate, 101), 101)  
 select @IOEndDate = convert(datetime,  convert(varchar(10), @IOEndDate, 101), 101)  
  
 select @BCBeginDate = convert(datetime,  convert(varchar(10), @BCBeginDate, 101), 101)  
 select @BCEndDate = convert(datetime,  convert(varchar(10), @BCEndDate, 101), 101)  
  
 select @InteractiveBeginDate = convert(datetime,  convert(varchar(10), @InteractiveBeginDate, 101), 101)  
 select @InteractiveEndDate = convert(datetime,  convert(varchar(10), @InteractiveEndDate, 101), 101)  
  
 select @InvoiceBeginDate = convert(datetime,  convert(varchar(10), @InvoiceBeginDate, 101), 101)  
 select @InvoiceEndDate = convert(datetime,  convert(varchar(10), @InvoiceEndDate, 101), 101)  
  
 -- get company key  
 select @CompanyKey = isnull(OwnerCompanyKey,CompanyKey)  
   from tUser (nolock)  
  where UserKey = @UserKey     
   
 -- get client link settings, default to ''through project''  
 select @IOClientLink = isnull(IOClientLink,1),  
           @BCClientLink = isnull(BCClientLink,1),  
     @CurrencyID = isnull(CurrencyID, '''')  
      from tPreference (nolock)  
     where CompanyKey = @CompanyKey  
  
Declare @RestrictToGLCompany int  
  
Select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0)  
 from tUser u (nolock)  
 inner join tPreference p (nolock) on p.CompanyKey = ISNULL(u.OwnerCompanyKey, u.CompanyKey)  
 Where u.UserKey = @UserKey  
  
select @RestrictToGLCompany = isnull(@RestrictToGLCompany, 0)  
  
  
 -- get all IOs for this company  
 if @IO = 1   
 BEGIN  
      insert #tMediaMassBillingDetail  
       (GLCompanyKey,  
       OfficeKey,  
       ClientKey,  
       CustomerID,  
       CompanyName, -- client  
             TransactionType,  
       Entity,  
             EntityKey,  
       EntityDate,  
       EntityNumber,  
       ProjectKey,  
             ProjectName,  
             MediaEstimateKey,  
             EstimateName,   
       ClientDivisionKey,  
       ClientProductKey,  
       CampaignKey,  
                MediaMarketKey,  
                MarketName,  
                PurchaseOrderNumber,  
                TaskID,  
                DetailOrderDate,  
                DetailOrderEndDate,  
                MediaID,  
                OrderProgram,  
                OrderTime,  
       Quantity,  
                UnitCost,  
                TotalCost,  
                   UnbilledAmount,  
                   LineNumber,  
       AdjustmentNumber,  
       CompanyMediaKey,  
             VendorKey,  
             StationName,  
                   TransactionMonth,  
                TransactionMonthNumeric,  
                AccountManager,  
       MediaWorksheetKey,  
       ParentKey,
	   MediaPlanKey,
       PlanID,  
       PlanName  
      )  
      select case when @IOClientLink = 1 then ISNULL(p.GLCompanyKey, 0) else ISNULL(e.GLCompanyKey, 0) end,  
       case when @IOClientLink = 1 then ISNULL(p.OfficeKey, 0) else ISNULL(e.OfficeKey, 0) end,   
       case when @IOClientLink = 1 then p.ClientKey else e.ClientKey end,  
             case when @IOClientLink = 1 then c.CustomerID else clm.CustomerID end,  
             case when @IOClientLink = 1 then c.CompanyName else clm.CompanyName end,  
             ''Insertion Order'',  
       ''IO'',  
       pod.PurchaseOrderDetailKey,  
       pod.DetailOrderDate,  
             po.PurchaseOrderNumber,  
             p.ProjectKey,  
       isnull(p.ProjectNumber+'' - '','''') + isnull(left(p.ProjectName, 25),''''),  
             e.MediaEstimateKey,  
       isnull(e.EstimateID+'' - '','''') + isnull(left(e.EstimateName, 25),''''),   
       p.ClientDivisionKey,  
       p.ClientProductKey,  
                case when @IOClientLink = 1 then p.CampaignKey else e.CampaignKey end,  
                m.MediaMarketKey,  
                mm.MarketName,  
       po.PurchaseOrderNumber,  
                '''',  
                pod.DetailOrderDate,  
                pod.DetailOrderEndDate,  
                m.StationID,  
                left(pod.ShortDescription,150),  
                pod.OrderTime,  
                pod.Quantity,  
                pod.UnitCost,  
                isnull(pod.PTotalCost,isnull(pod.TotalCost,0)),  
             isnull(case isnull(po.BillAt, 0)   
              when 0 then isnull(BillableCost,0)  
           when 1 then isnull(PTotalCost,isnull(TotalCost,0))  
           when 2 then isnull(BillableCost,0) - isnull(PTotalCost,isnull(TotalCost,0)) end ,0),  
       pod.LineNumber,  
       pod.AdjustmentNumber,  
       m.CompanyMediaKey,  
             po.VendorKey,  
             m.StationID + '' - '' + m.Name,  
                   datename(mm, pod.DetailOrderDate),  
                datepart(mm, pod.DetailOrderDate),  
                u.FirstName + '' '' + u.LastName,  
       po.MediaWorksheetKey,  
       po.PurchaseOrderKey,
	   mp.MediaPlanKey,
       mp.PlanID,  
       mp.PlanName  
        from tPurchaseOrderDetail pod (nolock)   
             inner join tPurchaseOrder po (nolock) on pod.PurchaseOrderKey = po.PurchaseOrderKey  
             left outer join tProject p (nolock) on pod.ProjectKey = p.ProjectKey  
             left outer join tUser u (nolock) on p.AccountManager = u.UserKey  
             left outer join tCompany c (nolock) on p.ClientKey = c.CompanyKey  
             left outer join tMediaEstimate e (nolock) on po.MediaEstimateKey = e.MediaEstimateKey
             left outer join tCompanyMedia m (nolock) on po.CompanyMediaKey = m.CompanyMediaKey  
             left outer join tMediaMarket mm (nolock) on m.MediaMarketKey = mm.MediaMarketKey  
       left outer join tCompany clm (nolock) on e.ClientKey = clm.CompanyKey        
       left outer join tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey =  pod.PurchaseOrderDetailKey      
       left outer join tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey  
                left outer join tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey     
					LEFT JOIN tItem i (nolock) ON pod.ItemKey = i.ItemKey
					LEFT JOIN (
						SELECT
							ri.EntityKey AS ItemKey,
							p.ProjectKey
						FROM
							tRetainerItems ri (nolock)
							INNER JOIN tRetainer r (nolock) ON ri.RetainerKey = r.RetainerKey
							INNER JOIN tProject p (nolock) ON ri.RetainerKey = p.RetainerKey
						WHERE
							ri.Entity = ''tItem'' AND
							r.IncludeExpense = 1 AND
							p.BillingMethod = 3
					) ri ON pod.ProjectKey = ri.ProjectKey AND pod.ItemKey = ri.ItemKey
				where
					po.CompanyKey = @CompanyKey
         and pod.InvoiceLineKey is null -- customer not yet billed  
         and isnull(pod.AppliedCost, 0) = 0  -- vendor has not invoiced  
      and (@IncludeOverheadClients = 1 OR ISNULL(c.Overhead, 0) = 0)  
         and po.Status = 4 -- PO approved  
         and po.POKind = 1  
					and ri.ItemKey IS NULL --Billed Item is not on a Retainer for this Project
            and (  
     (@IOClientLink = 1 and (@ClientKey is null or p.ClientKey = @ClientKey))  
     or  
     (@IOClientLink <> 1 and (@ClientKey is null or e.ClientKey = @ClientKey))  
     )  
     and (  
     (@IOClientLink = 1 and (@ParentClientKey is null or p.ClientKey = @ParentClientKey   
      or c.ParentCompanyKey =  @ParentClientKey ))  
     or  
     (@IOClientLink <> 1 and (@ParentClientKey is null or e.ClientKey = @ParentClientKey  
      or clm.ParentCompanyKey =  @ParentClientKey ))  
     )  
      and (@AccountManager is null or p.AccountManager = @AccountManager)  
      and (  
     (@IOClientLink = 1  and p.Closed = 0 and p.NonBillable = 0)  
     or  
     @IOClientLink <> 1  
     )  
            and isnull(pod.OnHold,0) = 0  
            and (@OpenOrdersOnly = 0 or isnull(pod.Closed,0) = 0)  
      and (@MediaWorksheetKey is null or po.MediaWorksheetKey = @MediaWorksheetKey)  
             AND NOT EXISTS (SELECT 1   
       FROM tBillingDetail bd (NOLOCK)  
        INNER JOIN tBilling b (NOLOCK) ON bd.BillingKey = b.BillingKey  
       WHERE b.CompanyKey = @CompanyKey  
       AND   b.Status < 5  
       AND   bd.EntityKey = pod.PurchaseOrderDetailKey    
       AND   bd.Entity = ''tPurchaseOrderDetail'')  
  
 END  
  
 -- get all BCs for this company  
    if @BC = 1  
    BEGIN  
      insert #tMediaMassBillingDetail  
       (GLCompanyKey,  
       OfficeKey,  
       ClientKey,  
       CustomerID,  
             CompanyName, -- client  
             TransactionType,  
       Entity,  
             EntityKey,  
       EntityDate,  
       EntityNumber,  
       ProjectKey,  
             ProjectName,  
             MediaEstimateKey,  
             EstimateName,  
       ClientDivisionKey,  
       ClientProductKey,  
       CampaignKey,  
                MediaMarketKey,  
                MarketName,  
                PurchaseOrderNumber,  
                TaskID,  
                DetailOrderDate,  
                DetailOrderEndDate,  
                MediaID,  
                OrderProgram,  
                OrderTime,  
                Quantity,  
                UnitCost,  
                TotalCost,  
             UnbilledAmount,  
                   LineNumber,  
       AdjustmentNumber,  
       CompanyMediaKey,  
             VendorKey,  
             StationName,  
                   TransactionMonth,  
                TransactionMonthNumeric,  
                AccountManager,  
       MediaWorksheetKey,  
       ParentKey, 
	   MediaPlanKey,
       PlanID,  
       PlanName  
       )  
      select case when @BCClientLink = 1 then ISNULL(p.GLCompanyKey, 0) else ISNULL(e.GLCompanyKey, 0) end,  
       case when @BCClientLink = 1 then ISNULL(p.OfficeKey, 0) else ISNULL(e.OfficeKey, 0) end,   
       case when @BCClientLink = 1 then p.ClientKey else e.ClientKey end,  
             case when @BCClientLink = 1 then c.CustomerID else clm.CustomerID end,  
             case when @BCClientLink = 1 then c.CompanyName else clm.CompanyName end,  
       ''Broadcast Order'',  
             ''BC'',  
             pod.PurchaseOrderDetailKey,  
                pod.DetailOrderDate,  
             po.PurchaseOrderNumber,  
             p.ProjectKey,  
       isnull(p.ProjectNumber+'' - '','''') + isnull(left(p.ProjectName, 25),''''),  
             e.MediaEstimateKey,  
       isnull(e.EstimateID+'' - '','''') + isnull(left(e.EstimateName, 25),''''),  
       p.ClientDivisionKey,  
       p.ClientProductKey,  
                case when @BCClientLink = 1 then p.CampaignKey else e.CampaignKey end,  
                m.MediaMarketKey,  
                mm.MarketName,  
                po.PurchaseOrderNumber,  
                '''',  
                pod.DetailOrderDate,  
                pod.DetailOrderEndDate,  
                m.StationID,  
                left(pod.ShortDescription,150),  
                pod.OrderTime,  
                pod.Quantity,  
                pod.UnitCost,  
                isnull(pod.PTotalCost,isnull(pod.TotalCost,0)),  
             isnull(case isnull(po.BillAt, 0)   
              when 0 then isnull(BillableCost,0)  
           when 1 then isnull(PTotalCost,isnull(TotalCost,0))  
           when 2 then isnull(BillableCost,0) - isnull(PTotalCost,isnull(TotalCost,0)) end ,0),  
             pod.LineNumber,  
       pod.AdjustmentNumber,  
       m.CompanyMediaKey,  
             po.VendorKey,  
             m.StationID + '' - '' + m.Name,  
                   datename(mm, pod.DetailOrderDate),  
                datepart(mm, pod.DetailOrderDate),  
                u.FirstName + '' '' + u.LastName,  
       po.MediaWorksheetKey,  
       po.PurchaseOrderKey, 
	   mp.MediaPlanKey,
       mp.PlanID,  
       mp.PlanName  
     from tPurchaseOrderDetail pod (nolock)   
             inner join tPurchaseOrder po (nolock) on pod.PurchaseOrderKey = po.PurchaseOrderKey  
             left outer join tProject p (nolock) on pod.ProjectKey = p.ProjectKey  
             left outer join tUser u (nolock) on p.AccountManager = u.UserKey  
       left outer join tCompany c (nolock) on p.ClientKey = c.CompanyKey  
             left outer join tMediaEstimate e (nolock) on po.MediaEstimateKey = e.MediaEstimateKey  
       left outer join tCompany clm (nolock) on e.ClientKey = clm.CompanyKey  
                left outer join tCompanyMedia m (nolock) on po.CompanyMediaKey = m.CompanyMediaKey  
                left outer join tMediaMarket mm (nolock) on m.MediaMarketKey = mm.MediaMarketKey  
       left outer join tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey =  pod.PurchaseOrderDetailKey      
       left outer join tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey  
                left outer join tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey
				LEFT JOIN tItem i (nolock) ON pod.ItemKey = i.ItemKey
				LEFT JOIN (
					SELECT
						ri.EntityKey AS ItemKey,
						p.ProjectKey
					FROM
						tRetainerItems ri (nolock)
						INNER JOIN tRetainer r (nolock) ON ri.RetainerKey = r.RetainerKey
						INNER JOIN tProject p (nolock) ON ri.RetainerKey = p.RetainerKey
					WHERE
						ri.Entity = ''tItem'' AND
						r.IncludeExpense = 1 AND
						p.BillingMethod = 3
				) ri ON pod.ProjectKey = ri.ProjectKey AND pod.ItemKey = ri.ItemKey     
       
       where po.CompanyKey = @CompanyKey   
      and pod.InvoiceLineKey is null -- customer not yet billed  
         and isnull(pod.AppliedCost, 0) = 0 -- vendor has not invoiced  
      and (@IncludeOverheadClients = 1 OR ISNULL(c.Overhead, 0) = 0)  
         and po.Status = 4 -- PO approved
		and ri.ItemKey IS NULL --Billed Item is not on a Retainer for this Project  
         and po.POKind = 2  
      and (  
     (@BCClientLink = 1 and (@ClientKey is null or p.ClientKey = @ClientKey))  
     or  
     (@BCClientLink <> 1 and (@ClientKey is null or e.ClientKey = @ClientKey))  
     )  
      and (  
     (@BCClientLink = 1 and (@ParentClientKey is null or p.ClientKey = @ParentClientKey   
      or c.ParentCompanyKey =  @ParentClientKey ))  
     or  
     (@BCClientLink <> 1 and (@ParentClientKey is null or e.ClientKey = @ParentClientKey  
      or clm.ParentCompanyKey =  @ParentClientKey ))  
     )  
      and (@AccountManager is null or p.AccountManager = @AccountManager)  
      and (  
     (@BCClientLink = 1  and p.Closed = 0 and p.NonBillable = 0)  
     or  
     @BCClientLink <> 1  
     )  
            and isnull(pod.OnHold,0) = 0  
            and (@OpenOrdersOnly = 0 or isnull(pod.Closed,0) = 0)  
      and (@MediaWorksheetKey is null or po.MediaWorksheetKey = @MediaWorksheetKey)  
            AND NOT EXISTS (SELECT 1   
       FROM tBillingDetail bd (NOLOCK)  
        INNER JOIN tBilling b (NOLOCK) ON bd.BillingKey = b.BillingKey  
       WHERE b.CompanyKey = @CompanyKey  
       AND   b.Status < 5  
       AND   bd.EntityKey = pod.PurchaseOrderDetailKey    
       AND   bd.Entity = ''tPurchaseOrderDetail'')  
   
 END  
  
 create table #pokind (POKind int null)  
 if @Interactive = 1   
  insert #pokind (POKind) values (4)  
  
 -- get all Interactive orders for this company (or other orders, just add to POKind)  
 if @Interactive = 1   
 BEGIN  
      insert #tMediaMassBillingDetail  
       (GLCompanyKey,  
       OfficeKey,  
       ClientKey,  
       CustomerID,  
       CompanyName, -- client  
             TransactionType,  
       Entity,  
             EntityKey,  
       EntityDate,  
       EntityNumber,  
       ProjectKey,  
             ProjectName,  
             MediaEstimateKey,  
             EstimateName,  
       ClientDivisionKey,  
       ClientProductKey,  
       CampaignKey,  
                MediaMarketKey,  
                MarketName,  
                PurchaseOrderNumber,  
       TaskID,  
                DetailOrderDate,  
                DetailOrderEndDate,  
                MediaID,  
                OrderProgram,  
                OrderTime,  
       Quantity,  
                UnitCost,  
                TotalCost,  
                   UnbilledAmount,  
                   LineNumber,  
       AdjustmentNumber,  
       CompanyMediaKey,  
             VendorKey,  
             StationName,  
                   TransactionMonth,  
                TransactionMonthNumeric,  
                AccountManager,  
       MediaWorksheetKey,  
       ParentKey, 
	   MediaPlanKey,
       PlanID,  
       PlanName  
      )  
      select ISNULL(p.GLCompanyKey, 0),  
       ISNULL(p.OfficeKey, 0),   
       p.ClientKey,  
             c.CustomerID,  
             c.CompanyName,  
       case po.POKind   
      when 4 then ''Interactive Order''  
      when 5 then ''OOH''  
      else ''Radio Order''  
       end,  
       case po.POKind   
      when 4 then ''Interactive''   
      when 5 then ''OOH''  
      else ''Radio''  
       end,  
       pod.PurchaseOrderDetailKey,  
       pod.DetailOrderDate,  
             po.PurchaseOrderNumber,  
             p.ProjectKey,  
       isnull(p.ProjectNumber+'' - '','''') + isnull(left(p.ProjectName, 25),''''),  
             e.MediaEstimateKey,  
       isnull(e.EstimateID+'' - '','''') + isnull(left(e.EstimateName, 25),''''),  
       p.ClientDivisionKey,  
       p.ClientProductKey,  
                p.CampaignKey,  
                m.MediaMarketKey,  
                mm.MarketName,  
       po.PurchaseOrderNumber,  
                '''',  
                pod.DetailOrderDate,  
                pod.DetailOrderEndDate,  
                m.StationID,  
                left(pod.ShortDescription,150),  
                pod.OrderTime,  
                pod.Quantity,  
                pod.UnitCost,  
                isnull(pod.PTotalCost,isnull(pod.TotalCost,0)),  
             isnull(case isnull(po.BillAt, 0)   
              when 0 then isnull(BillableCost,0)  
           when 1 then isnull(PTotalCost,isnull(TotalCost,0))  
           when 2 then isnull(BillableCost,0) - isnull(PTotalCost,isnull(TotalCost,0)) end ,0),  
       pod.LineNumber,  
       pod.AdjustmentNumber,  
       m.CompanyMediaKey,  
             po.VendorKey,  
             m.StationID + '' - '' + m.Name,  
                   datename(mm, pod.DetailOrderDate),  
                datepart(mm, pod.DetailOrderDate),  
                u.FirstName + '' '' + u.LastName,  
       po.MediaWorksheetKey,  
       po.PurchaseOrderKey, 
	   mp.MediaPlanKey,
       mp.PlanID,  
       mp.PlanName  
        from tPurchaseOrderDetail pod (nolock)   
             inner join tPurchaseOrder po (nolock) on pod.PurchaseOrderKey = po.PurchaseOrderKey  
             left outer join tProject p (nolock) on pod.ProjectKey = p.ProjectKey  
             left outer join tUser u (nolock) on p.AccountManager = u.UserKey  
             left outer join tCompany c (nolock) on p.ClientKey = c.CompanyKey  
             left outer join tMediaEstimate e (nolock) on po.MediaEstimateKey = e.MediaEstimateKey  
                left outer join tCompanyMedia m (nolock) on po.CompanyMediaKey = m.CompanyMediaKey  
                left outer join tMediaMarket mm (nolock) on m.MediaMarketKey = mm.MediaMarketKey  
       left outer join tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey =  pod.PurchaseOrderDetailKey      
       left outer join tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey  
                left outer join tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey
			LEFT JOIN tItem i (nolock) ON pod.ItemKey = i.ItemKey
			LEFT JOIN (
				SELECT
					ri.EntityKey AS ItemKey,
					p.ProjectKey
				FROM
					tRetainerItems ri (nolock)
					INNER JOIN tRetainer r (nolock) ON ri.RetainerKey = r.RetainerKey
					INNER JOIN tProject p (nolock) ON ri.RetainerKey = p.RetainerKey
				WHERE
					ri.Entity = ''tItem'' AND
					r.IncludeExpense = 1 AND
					p.BillingMethod = 3
			) ri ON pod.ProjectKey = ri.ProjectKey AND pod.ItemKey = ri.ItemKey     
       
       where po.CompanyKey = @CompanyKey  
         and pod.InvoiceLineKey is null -- customer not yet billed  
         and isnull(pod.AppliedCost, 0) = 0  -- vendor has not invoiced  
      and (@IncludeOverheadClients = 1 OR ISNULL(c.Overhead, 0) = 0)  
         and po.Status = 4 -- PO approved
			and ri.ItemKey IS NULL --Billed Item is not on a Retainer for this Project
         and po.POKind in (select POKind from #pokind) -- Interactive + we can add to it here  
            and (@ClientKey is null or p.ClientKey = @ClientKey)  
      and (@ParentClientKey is null or p.ClientKey = @ParentClientKey or c.ParentCompanyKey = @ParentClientKey)  
      and (@AccountManager is null or p.AccountManager = @AccountManager)  
      and p.Closed = 0  
      and p.NonBillable = 0  
            and isnull(pod.OnHold,0) = 0  
            and (@OpenOrdersOnly = 0 or isnull(pod.Closed,0) = 0)  
      and (@MediaWorksheetKey is null or po.MediaWorksheetKey = @MediaWorksheetKey)  
             AND NOT EXISTS (SELECT 1   
       FROM tBillingDetail bd (NOLOCK)  
        INNER JOIN tBilling b (NOLOCK) ON bd.BillingKey = b.BillingKey  
       WHERE b.CompanyKey = @CompanyKey  
       AND   b.Status < 5  
       AND   bd.EntityKey = pod.PurchaseOrderDetailKey    
       AND   bd.Entity = ''tPurchaseOrderDetail'')  
  
 END  
   
 -- get all IOs with vendor invoices for this company  
    if @Invoice = 1  
    BEGIN  
      insert #tMediaMassBillingDetail  
       (GLCompanyKey,  
       OfficeKey,  
       ClientKey,  
       CustomerID,  
             CompanyName, -- client  
             TransactionType,  
       Entity,  
             EntityKey,  
       EntityDate,  
       EntityNumber,  
       ProjectKey,  
             ProjectName,  
             MediaEstimateKey,  
             EstimateName,  
       ClientDivisionKey,  
       ClientProductKey,  
       CampaignKey,  
                MediaMarketKey,  
                MarketName,  
                PurchaseOrderNumber,  
                TaskID,  
                DetailOrderDate,  
                DetailOrderEndDate,  
                MediaID,  
                OrderProgram,  
                OrderTime,  
                Quantity,  
                UnitCost,  
                TotalCost,  
             UnbilledAmount,  
                   LineNumber,  
       AdjustmentNumber,  
       InvoiceLineNumber,  
       InvoiceNumber,  
       CompanyMediaKey,  
             VendorKey,  
             StationName,  
                   TransactionMonth,  
                TransactionMonthNumeric,  
                AccountManager,  
       MediaWorksheetKey,  
       ParentKey,  
	   MediaPlanKey,
       PlanID,  
       PlanName  
       )  
      select case when @IOClientLink = 1 then ISNULL(p.GLCompanyKey, 0) else ISNULL(e.GLCompanyKey, 0) end,  
       case when @IOClientLink = 1 then ISNULL(p.OfficeKey, 0) else ISNULL(e.OfficeKey, 0) end,   
                   case when @IOClientLink = 1 then p.ClientKey else e.ClientKey end,  
             case when @IOClientLink = 1 then c.CustomerID else clm.CustomerID end,  
             case when @IOClientLink = 1 then c.CompanyName else clm.CompanyName end,  
             ''Insertion Order'',  
             ''Invoice'',  
       vd.VoucherDetailKey,  
                CASE @UseInvoicePostingDate WHEN 1 THEN v.PostingDate WHEN 2 THEN pod.DetailOrderDate ELSE v.InvoiceDate END,  
             v.InvoiceNumber,  
             p.ProjectKey,  
       isnull(p.ProjectNumber+'' - '','''') + isnull(left(p.ProjectName, 25),''''),  
             e.MediaEstimateKey,  
       isnull(e.EstimateID+'' - '','''') + isnull(left(e.EstimateName, 25),''''),  
       p.ClientDivisionKey,  
       p.ClientProductKey,  
                case when @IOClientLink = 1 then p.CampaignKey else e.CampaignKey end,  
                m.MediaMarketKey,  
                mm.MarketName,  
                po.PurchaseOrderNumber,  
                '''',  
                pod.DetailOrderDate,  
                pod.DetailOrderEndDate,  
                m.StationID,  
                left(pod.ShortDescription,150),  
                pod.OrderTime,  
                vd.Quantity,  
                vd.UnitCost,  
                isnull(vd.PTotalCost,isnull(vd.TotalCost,0)),  
             isnull(vd.BillableCost,0),  
       pod.LineNumber,  
       pod.AdjustmentNumber,  
       vd.LineNumber,  
       v.InvoiceNumber,  
       m.CompanyMediaKey,  
             po.VendorKey,  
             m.StationID + '' - '' + m.Name,  
                   datename(mm, v.InvoiceDate),  
                datepart(mm, v.InvoiceDate),  
                u.FirstName + '' '' + u.LastName,  
       po.MediaWorksheetKey,  
       v.VoucherKey, 
	   mp.MediaPlanKey,
       mp.PlanID,  
       mp.PlanName  
        from tPurchaseOrderDetail pod (nolock)   
             inner join tPurchaseOrder po (nolock) on pod.PurchaseOrderKey = po.PurchaseOrderKey  
             inner join tVoucherDetail vd (nolock) on pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey  
             inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey  
             --inner join tProject p (nolock) on pod.ProjectKey = p.ProjectKey  
             left outer join tProject p (nolock) on vd.ProjectKey = p.ProjectKey  
       left outer join tUser u (nolock) on p.AccountManager = u.UserKey  
      left outer join tCompany c (nolock) on p.ClientKey = c.CompanyKey  
       left outer join tMediaEstimate e (nolock) on po.MediaEstimateKey = e.MediaEstimateKey  
             left outer join tCompany clm (nolock) on e.ClientKey = clm.CompanyKey  
       left outer join tCompanyMedia m (nolock) on po.CompanyMediaKey = m.CompanyMediaKey  
                left outer join tMediaMarket mm (nolock) on m.MediaMarketKey = mm.MediaMarketKey  
       left outer join tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey =  pod.PurchaseOrderDetailKey      
       left outer join tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey  
                left outer join tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey     
       
             --left outer join tTask t (nolock) on pod.TaskKey = t.TaskKey  
             --left outer join tTask t (nolock) on vd.TaskKey = t.TaskKey  
       where po.CompanyKey = @CompanyKey  
             and vd.InvoiceLineKey is null and isnull(vd.BillableCost,0) <> 0 -- customer not yet billed PC 2/12/15 added Billable cost to remove zeros from data set  
       and vd.WriteOff = 0  
       and (@IncludeOverheadClients = 1 OR ISNULL(c.Overhead, 0) = 0)  
             and v.Status = 4 -- Voucher approved  
             and po.POKind = 1  
          --and p.CompanyKey = @CompanyKey -- limit to the user''s company  
                and (  
     (@IOClientLink = 1 and (@ClientKey is null or p.ClientKey = @ClientKey))  
     or  
     (@IOClientLink <> 1 and (@ClientKey is null or e.ClientKey = @ClientKey))  
     )  
     and (  
     (@IOClientLink = 1 and (@ParentClientKey is null or p.ClientKey = @ParentClientKey   
      or c.ParentCompanyKey =  @ParentClientKey ))  
     or  
     (@IOClientLink <> 1 and (@ParentClientKey is null or e.ClientKey = @ParentClientKey  
      or clm.ParentCompanyKey =  @ParentClientKey ))  
     )  
       and (@AccountManager is null or p.AccountManager = @AccountManager)  
       and (  
     (@IOClientLink = 1  and p.Closed = 0 and p.NonBillable = 0)  
     or  
     @IOClientLink <> 1  
     )  
       and isnull(vd.OnHold,0) = 0  
                   and (@OpenOrdersOnlyOnInvoices = 0 or (@OpenOrdersOnlyOnInvoices = 1 and isnull(pod.Closed,0) = 0))   
       and (@MediaWorksheetKey is null or po.MediaWorksheetKey = @MediaWorksheetKey)  
       AND  NOT EXISTS (SELECT 1   
       FROM tBillingDetail bd (NOLOCK)  
        INNER JOIN tBilling b (NOLOCK) ON bd.BillingKey = b.BillingKey  
       WHERE b.CompanyKey = @CompanyKey  
       AND   b.Status < 5  
       AND   bd.EntityKey = vd.VoucherDetailKey    
       AND   bd.Entity = ''tVoucherDetail''  
       )  
  
 END  
  
 -- get all BCs with vendor invoices for this company  
    if @Invoice = 1  
    BEGIN  
      insert #tMediaMassBillingDetail  
       (GLCompanyKey,  
       OfficeKey,  
       ClientKey,  
       CustomerID,  
             CompanyName, -- client  
             TransactionType,  
       Entity,  
             EntityKey,  
       EntityDate,  
       EntityNumber,  
       ProjectKey,  
             ProjectName,  
             MediaEstimateKey,  
             EstimateName,  
       ClientDivisionKey,  
       ClientProductKey,  
       CampaignKey,  
                MediaMarketKey,  
                MarketName,  
                PurchaseOrderNumber,  
                TaskID,  
                DetailOrderDate,  
       DetailOrderEndDate,  
                MediaID,  
                OrderProgram,  
                OrderTime,  
                Quantity,  
                   UnitCost,  
                   TotalCost,  
             UnbilledAmount,  
                   LineNumber,  
       AdjustmentNumber,  
       InvoiceLineNumber,  
       InvoiceNumber,  
       CompanyMediaKey,  
             VendorKey,  
             StationName,  
                   TransactionMonth,  
                TransactionMonthNumeric,  
                AccountManager,  
       MediaWorksheetKey,  
       ParentKey,  
	   MediaPlanKey,
       PlanID,  
       PlanName  
       )  
      select case when @BCClientLink = 1 then ISNULL(p.GLCompanyKey, 0) else ISNULL(e.GLCompanyKey, 0) end,  
       case when @BCClientLink = 1 then ISNULL(p.OfficeKey, 0) else ISNULL(e.OfficeKey, 0) end,  
       case when @BCClientLink = 1 then p.ClientKey else e.ClientKey end,  
             case when @BCClientLink = 1 then c.CustomerID else clm.CustomerID end,  
             case when @BCClientLink = 1 then c.CompanyName else clm.CompanyName end,  
       ''Broadcast Order'',  
             ''Invoice'',  
             vd.VoucherDetailKey,  
                CASE @UseInvoicePostingDate WHEN 1 THEN v.PostingDate WHEN 2 THEN pod.DetailOrderDate ELSE v.InvoiceDate END,  
             v.InvoiceNumber,  
             p.ProjectKey,  
       isnull(p.ProjectNumber+'' - '','''') + isnull(left(p.ProjectName, 25),''''),  
             e.MediaEstimateKey,  
       isnull(e.EstimateID+'' - '','''') + isnull(left(e.EstimateName, 25),''''),  
       p.ClientDivisionKey,  
       p.ClientProductKey,  
                case when @BCClientLink = 1 then p.CampaignKey else e.CampaignKey end,  
                m.MediaMarketKey,  
                mm.MarketName,  
                po.PurchaseOrderNumber,  
                '''',  
                pod.DetailOrderDate,  
                pod.DetailOrderEndDate,  
                m.StationID,  
                left(pod.ShortDescription,150),  
                pod.OrderTime,  
                vd.Quantity,  
                vd.UnitCost,  
                isnull(vd.PTotalCost,isnull(vd.TotalCost,0)),  
       isnull(vd.BillableCost,0),  
       pod.LineNumber,  
       pod.AdjustmentNumber,  
       vd.LineNumber,  
       v.InvoiceNumber,  
       m.CompanyMediaKey,  
             po.VendorKey,  
             m.StationID + '' - '' + m.Name,  
                   datename(mm, v.InvoiceDate),  
                datepart(mm, v.InvoiceDate),  
                u.FirstName + '' '' + u.LastName,  
       po.MediaWorksheetKey,  
       v.VoucherKey, 
	   mp.MediaPlanKey,
       mp.PlanID,  
       mp.PlanName  
        from tPurchaseOrderDetail pod (nolock)   
             inner join tPurchaseOrder po (nolock) on pod.PurchaseOrderKey = po.PurchaseOrderKey  
             inner join tVoucherDetail vd (nolock) on pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey  
             inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey  
             --inner join tProject p (nolock) on pod.ProjectKey = p.ProjectKey  
             left outer join tProject p (nolock) on vd.ProjectKey = p.ProjectKey  
          left outer join tUser u (nolock) on p.AccountManager = u.UserKey  
             left outer join tCompany c (nolock) on p.ClientKey = c.CompanyKey  
             left outer join tMediaEstimate e (nolock) on po.MediaEstimateKey = e.MediaEstimateKey  
                left outer join tCompanyMedia m (nolock) on po.CompanyMediaKey = m.CompanyMediaKey  
                left outer join tMediaMarket mm (nolock) on m.MediaMarketKey = mm.MediaMarketKey  
                left outer join tCompany clm (nolock) on e.ClientKey = clm.CompanyKey  
       left outer join tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey =  pod.PurchaseOrderDetailKey      
       left outer join tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey  
                left outer join tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey     
       
               
       where po.CompanyKey = @CompanyKey  
      and vd.InvoiceLineKey is null and isnull(vd.BillableCost,0) <> 0  -- customer not yet billed  
         and vd.WriteOff = 0  
      and (@IncludeOverheadClients = 1 OR ISNULL(c.Overhead, 0) = 0)  
         and v.Status = 4 -- PO approved  
         and po.POKind = 2  
            and (  
     (@BCClientLink = 1 and (@ClientKey is null or p.ClientKey = @ClientKey))  
     or  
     (@BCClientLink <> 1 and (@ClientKey is null or e.ClientKey = @ClientKey))  
     )  
    and (  
     (@BCClientLink = 1 and (@ParentClientKey is null or p.ClientKey = @ParentClientKey   
      or c.ParentCompanyKey =  @ParentClientKey ))  
     or  
     (@BCClientLink <> 1 and (@ParentClientKey is null or e.ClientKey = @ParentClientKey  
      or clm.ParentCompanyKey =  @ParentClientKey ))  
     )  
      and (@AccountManager is null or p.AccountManager = @AccountManager)  
      and (  
     (@BCClientLink = 1  and p.Closed = 0 and p.NonBillable = 0)  
     or  
     @BCClientLink <> 1  
     )  
            and isnull(vd.OnHold,0) = 0  
            and (@OpenOrdersOnlyOnInvoices = 0 or (@OpenOrdersOnlyOnInvoices = 1 and isnull(pod.Closed,0) = 0))  
      and (@MediaWorksheetKey is null or po.MediaWorksheetKey = @MediaWorksheetKey)   
      AND  NOT EXISTS (SELECT 1   
       FROM tBillingDetail bd (NOLOCK)  
        INNER JOIN tBilling b (NOLOCK) ON bd.BillingKey = b.BillingKey  
       WHERE b.CompanyKey = @CompanyKey  
       AND   b.Status < 5  
       AND   bd.EntityKey = vd.VoucherDetailKey    
       AND   bd.Entity = ''tVoucherDetail''  
       )  
    
 END  
  
 -- get all vendor invoices with no orders for this company  
    if @Invoice = 1  
    BEGIN  
      insert #tMediaMassBillingDetail  
       (GLCompanyKey,  
       OfficeKey,  
       ClientKey,  
       CustomerID,  
             CompanyName, -- client  
             TransactionType,  
       Entity,  
             EntityKey,  
       EntityDate,  
       EntityNumber,  
       ProjectKey,  
             ProjectName,  
             MediaEstimateKey,  
             EstimateName,  
       ClientDivisionKey,  
       ClientProductKey,  
       CampaignKey,  
                MediaMarketKey,  
                MarketName,  
                PurchaseOrderNumber,  
                TaskID,  
                DetailOrderDate,  
       DetailOrderEndDate,  
                MediaID,  
                OrderProgram,  
                OrderTime,  
                Quantity,  
                   UnitCost,  
                   TotalCost,  
             UnbilledAmount,  
                   LineNumber,  
       AdjustmentNumber,  
       InvoiceLineNumber,  
       InvoiceNumber,  
       CompanyMediaKey,  
             VendorKey,  
             StationName,  
                   TransactionMonth,  
                TransactionMonthNumeric,  
                AccountManager,  
       MediaWorksheetKey,  
       ParentKey  
       )   
      select ISNULL(v.GLCompanyKey, 0) ,  
       ISNULL(v.OfficeKey, 0),  
       ISNULL(p.ClientKey,vd.ClientKey),  
             c.CustomerID ,  
             c.CompanyName,  
       ''No Order'',  
       case when isnull(v.CreditCard,0) = 0 then ''Invoice'' else ''Credit Card Charge'' end,  
             vd.VoucherDetailKey,  
                CASE @UseInvoicePostingDate WHEN 1 THEN v.PostingDate ELSE v.InvoiceDate END,  
             v.InvoiceNumber,  
             p.ProjectKey,  
       isnull(p.ProjectNumber+'' - '','''') + isnull(left(p.ProjectName, 25),''''),  
             null, --e.MediaEstimateKey,  
       null, --isnull(e.EstimateID+'' - '','''') + isnull(left(e.EstimateName, 25),''''),  
       p.ClientDivisionKey,  
       p.ClientProductKey,  
                p.CampaignKey,  
                null, -- m.MediaMarketKey,  
                null, -- mm.MarketName,  
                null, -- po.PurchaseOrderNumber,  
                '''',  
                null, -- pod.DetailOrderDate,  
                null, -- pod.DetailOrderEndDate,  
                null, -- m.StationID,  
                left(vd.ShortDescription,150),  
                null, -- pod.OrderTime,  
                vd.Quantity,  
                vd.UnitCost,  
                isnull(vd.PTotalCost,isnull(vd.TotalCost,0)),  
       isnull(vd.BillableCost,0),  
       null, -- pod.LineNumber,  
       null, -- pod.AdjustmentNumber,  
       vd.LineNumber,  
       v.InvoiceNumber,  
       null, -- m.CompanyMediaKey,  
             v.VendorKey,  
             null, -- m.StationID + '' - '' + m.Name,  
                   datename(mm, v.InvoiceDate),  
                datepart(mm, v.InvoiceDate),  
                u.FirstName + '' '' + u.LastName,  
       null, -- po.MediaWorksheetKey  
       v.VoucherKey  
        from tVoucherDetail vd (nolock)   
             inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey  
             left outer join tProject p (nolock) on vd.ProjectKey = p.ProjectKey  
          left outer join tUser u (nolock) on p.AccountManager = u.UserKey  
             left outer join tCompany c (nolock) on p.ClientKey = c.CompanyKey -- Client on the project  
       inner join tItem i (nolock) on i.ItemKey = vd.ItemKey  
       where v.CompanyKey = @CompanyKey  
      and vd.PurchaseOrderDetailKey is null   
      and vd.InvoiceLineKey is null and isnull(vd.BillableCost,0) <> 0  -- customer not yet billed  
         and vd.WriteOff = 0  
      and (@IncludeOverheadClients = 1 OR ISNULL(c.Overhead, 0) = 0)  
         and v.Status = 4 -- PO approved  
         and i.ItemType in (1,2) -- media  
      --and isnull(v.CreditCard,0) = 0  
  
            and (@ClientKey is null or p.ClientKey = @ClientKey)  
      and (@ParentClientKey is null or p.ClientKey = @ParentClientKey or c.ParentCompanyKey =  @ParentClientKey)  
      and (@AccountManager is null or p.AccountManager = @AccountManager)  
      and p.Closed = 0 and p.NonBillable = 0  
            and isnull(vd.OnHold,0) = 0  
        
      AND  NOT EXISTS (SELECT 1   
       FROM tBillingDetail bd (NOLOCK)  
        INNER JOIN tBilling b (NOLOCK) ON bd.BillingKey = b.BillingKey  
       WHERE b.CompanyKey = @CompanyKey  
       AND   b.Status < 5  
       AND   bd.EntityKey = vd.VoucherDetailKey    
       AND   bd.Entity = ''tVoucherDetail''  
       )  
      
 END  
  
  
 -- get all other orders with vendor invoices for this company  
    if @Invoice = 1  
    BEGIN  
      insert #tMediaMassBillingDetail  
       (GLCompanyKey,  
       OfficeKey,  
       ClientKey,  
       CustomerID,  
             CompanyName, -- client  
             TransactionType,  
       Entity,  
             EntityKey,  
       EntityDate,  
       EntityNumber,  
       ProjectKey,  
             ProjectName,  
             MediaEstimateKey,  
             EstimateName,  
       ClientDivisionKey,  
       ClientProductKey,  
       CampaignKey,  
                MediaMarketKey,  
                MarketName,  
                PurchaseOrderNumber,  
                TaskID,  
                DetailOrderDate,  
       DetailOrderEndDate,  
                MediaID,  
                OrderProgram,  
                OrderTime,  
                Quantity,  
                   UnitCost,  
                   TotalCost,  
             UnbilledAmount,  
                   LineNumber,  
       AdjustmentNumber,  
       InvoiceLineNumber,  
       InvoiceNumber,  
       CompanyMediaKey,  
             VendorKey,  
             StationName,  
                   TransactionMonth,  
                TransactionMonthNumeric,  
                AccountManager,  
       MediaWorksheetKey,  
       ParentKey, 
	   MediaPlanKey,
       PlanID,  
       PlanName  
       )  
      select ISNULL(p.GLCompanyKey, 0),  
       ISNULL(p.OfficeKey, 0),  
       p.ClientKey,  
             c.CustomerID,  
             c.CompanyName,  
       case po.POKind   
      when 4 then ''Interactive Order''  
      when 5 then ''Outdoor Order''  
      else ''Radio Order''  
       end,  
       ''Invoice'',  
             vd.VoucherDetailKey,  
                CASE @UseInvoicePostingDate WHEN 1 THEN v.PostingDate WHEN 2 THEN pod.DetailOrderDate ELSE v.InvoiceDate END,  
             v.InvoiceNumber,  
             p.ProjectKey,  
       isnull(p.ProjectNumber+'' - '','''') + isnull(left(p.ProjectName, 25),''''),  
             e.MediaEstimateKey,  
       isnull(e.EstimateID+'' - '','''') + isnull(left(e.EstimateName, 25),''''),  
       p.ClientDivisionKey,  
       p.ClientProductKey,  
                case when @BCClientLink = 1 then p.CampaignKey else e.CampaignKey end,  
                m.MediaMarketKey,  
                mm.MarketName,  
                po.PurchaseOrderNumber,  
                '''',  
                pod.DetailOrderDate,  
                pod.DetailOrderEndDate,  
                m.StationID,  
                left(pod.ShortDescription,150),  
                pod.OrderTime,  
                vd.Quantity,  
                vd.UnitCost,  
                isnull(vd.PTotalCost,isnull(vd.TotalCost,0)),  
       isnull(vd.BillableCost,0),  
       pod.LineNumber,  
       pod.AdjustmentNumber,  
       vd.LineNumber,  
       v.InvoiceNumber,  
       m.CompanyMediaKey,  
             po.VendorKey,  
             m.StationID + '' - '' + m.Name,  
                   datename(mm, v.InvoiceDate),  
                datepart(mm, v.InvoiceDate),  
                u.FirstName + '' '' + u.LastName,  
       po.MediaWorksheetKey,  
       v.VoucherKey,  
	   mp.MediaPlanKey,
       mp.PlanID,  
       mp.PlanName  
        from tPurchaseOrderDetail pod (nolock)   
             inner join tPurchaseOrder po (nolock) on pod.PurchaseOrderKey = po.PurchaseOrderKey  
             inner join tVoucherDetail vd (nolock) on pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey  
             inner join tVoucher v (nolock) on vd.VoucherKey = v.VoucherKey  
             --inner join tProject p (nolock) on pod.ProjectKey = p.ProjectKey  
             left outer join tProject p (nolock) on vd.ProjectKey = p.ProjectKey  
          left outer join tUser u (nolock) on p.AccountManager = u.UserKey  
             left outer join tCompany c (nolock) on p.ClientKey = c.CompanyKey  
             left outer join tMediaEstimate e (nolock) on po.MediaEstimateKey = e.MediaEstimateKey  
                left outer join tCompanyMedia m (nolock) on po.CompanyMediaKey = m.CompanyMediaKey  
                left outer join tMediaMarket mm (nolock) on m.MediaMarketKey = mm.MediaMarketKey  
       left outer join tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey =  pod.PurchaseOrderDetailKey      
       left outer join tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey  
                left outer join tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey     
       
               
       where po.CompanyKey = @CompanyKey  
      and vd.InvoiceLineKey is null  and isnull(vd.BillableCost,0) <> 0 -- customer not yet billed  
         and vd.WriteOff = 0  
      and (@IncludeOverheadClients = 1 OR ISNULL(c.Overhead, 0) = 0)  
         and v.Status = 4 -- PO approved  
         and po.POKind in (4,5,6) -- Interactive, Outdoor, Radio  
      and (@ClientKey is null or p.ClientKey = @ClientKey)  
      and (@ParentClientKey is null or p.ClientKey = @ParentClientKey or c.ParentCompanyKey = @ParentClientKey)  
            and (@AccountManager is null or p.AccountManager = @AccountManager)  
      --and p.Closed = 0  
      --and p.NonBillable = 0  
       and (  
     (@IOClientLink = 1  and p.Closed = 0 and p.NonBillable = 0)  
     or  
     @IOClientLink <> 1  
     )  
      and isnull(vd.OnHold,0) = 0  
             and (@OpenOrdersOnlyOnInvoices = 0 or (@OpenOrdersOnlyOnInvoices = 1 and isnull(pod.Closed,0) = 0))  
      and (@MediaWorksheetKey is null or po.MediaWorksheetKey = @MediaWorksheetKey)   
      AND  NOT EXISTS (SELECT 1   
       FROM tBillingDetail bd (NOLOCK)  
        INNER JOIN tBilling b (NOLOCK) ON bd.BillingKey = b.BillingKey  
       WHERE b.CompanyKey = @CompanyKey  
       AND   b.Status < 5  
       AND   bd.EntityKey = vd.VoucherDetailKey    
       AND   bd.Entity = ''tVoucherDetail''  
       )  
    
 END  
  
  
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.TaskID = isnull(t.TaskID + '' - '', '''') + isnull(left(t.TaskName, 30), '''')  
 from   tVoucherDetail vd (nolock)  
 inner join tTask t (nolock) on vd.TaskKey = t.TaskKey and vd.ProjectKey = t.ProjectKey   
 where  #tMediaMassBillingDetail.EntityKey = vd.VoucherDetailKey  
 and    #tMediaMassBillingDetail.Entity = ''Invoice''  
  
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.TaskID = isnull(t.TaskID + '' - '', '''') + isnull(left(t.TaskName, 30), '''')  
 from   tPurchaseOrderDetail pod (nolock)  
 inner join tTask t (nolock) on pod.TaskKey = t.TaskKey and pod.ProjectKey = t.ProjectKey  
 where  #tMediaMassBillingDetail.EntityKey = pod.PurchaseOrderDetailKey  
 and    #tMediaMassBillingDetail.Entity <> ''Invoice''  
  
 -- correct StationName if missing, and set it to vendor info, similar to Media Discrepancy report  
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.StationName = v.VendorID + '' - '' + v.CompanyName   
 from   tCompany v (nolock)  
 where  #tMediaMassBillingDetail.VendorKey = v.CompanyKey  
 and    #tMediaMassBillingDetail.StationName is null  
   
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.MediaID = v.VendorID    
 from   tCompany v (nolock)  
 where  #tMediaMassBillingDetail.VendorKey = v.CompanyKey  
 and    #tMediaMassBillingDetail.MediaID is null  
   
   
 -- format the LineAdjustment  
 -- Example: 1 or 1.1 or 2.4   
   update #tMediaMassBillingDetail  
 set    LineAdjustment = case when isnull(AdjustmentNumber, 0) = 0 then cast(LineNumber as varchar(50))  
                              else cast(LineNumber as varchar(50)) + ''.'' + cast(AdjustmentNumber as varchar(50))  
         end  
  
   -- format the InvoiceDetails   
   -- Example: Invoice 12345 Line 3   
   update #tMediaMassBillingDetail   
   set     InvoiceDetails = ''Invoice '' + InvoiceNumber + '' Line '' + cast(InvoiceLineNumber as varchar(100))  
   where   Entity = ''Invoice''  
  
 -- delete rows not matching criteria  
 if @IOBeginDate is not null  
  delete #tMediaMassBillingDetail  
         where Entity = ''IO''  
           and EntityDate < @IOBeginDate  
  
 if @IOEndDate is not null  
  delete #tMediaMassBillingDetail  
   where Entity = ''IO''  
           and EntityDate > @IOEndDate  
  
 if @BCBeginDate is not null  
  delete #tMediaMassBillingDetail  
         where Entity = ''BC''  
           and EntityDate < @BCBeginDate  
  
 if @BCEndDate is not null  
  delete #tMediaMassBillingDetail  
         where Entity = ''BC''  
           and EntityDate > @BCEndDate  
  
 if @InteractiveBeginDate is not null  
  delete #tMediaMassBillingDetail  
         where Entity = ''Interactive''  
           and EntityDate < @InteractiveBeginDate  
  
 if @InteractiveEndDate is not null  
  delete #tMediaMassBillingDetail  
         where Entity = ''Interactive''  
           and EntityDate > @InteractiveEndDate  
  
 if @InvoiceBeginDate is not null  
  delete #tMediaMassBillingDetail  
         where Entity = ''Invoice''  
           and EntityDate < @InvoiceBeginDate  
  
 if @InvoiceEndDate is not null  
  delete #tMediaMassBillingDetail  
         where Entity = ''Invoice''  
           and EntityDate > @InvoiceEndDate  
  
 if @ClientKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(ClientKey,0) <> @ClientKey  
  
 if @ClientDivisionKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(ClientDivisionKey,0) <> @ClientDivisionKey  
           
 if @ClientProductKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(ClientProductKey,0) <> @ClientProductKey  
                    
 if @CampaignKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(CampaignKey,0) <> @CampaignKey    
  
 if @ProjectKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(ProjectKey,0) <> @ProjectKey    
  
 if @MediaMarketKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(MediaMarketKey,0) <> @MediaMarketKey    
  
 if @MediaEstimateKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(MediaEstimateKey,0) <> @MediaEstimateKey    

if @MediaPlanKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(MediaPlanKey,0) <> @MediaPlanKey    
  
 if @PurchaseOrderNumber is not null  
  delete #tMediaMassBillingDetail  
         where isnull(PurchaseOrderNumber,'''') <> @PurchaseOrderNumber    
  
 if @TaskID is not null  
  delete #tMediaMassBillingDetail  
         where isnull(TaskID,'''') <> @TaskID    
  
 IF @GLCompanyKey >= 0  
  DELETE #tMediaMassBillingDetail WHERE GLCompanyKey <> @GLCompanyKey   
   
 IF @RestrictToGLCompany = 1  
  -- GLCompanyKey is never null, no need to take isnull  
  
  DELETE #tMediaMassBillingDetail   
  WHERE GLCompanyKey NOT IN (SELECT GLCompanyKey FROM tUserGLCompanyAccess (nolock) WHERE UserKey = @UserKey )  
    
 IF @OfficeKey >= 0  
  DELETE #tMediaMassBillingDetail WHERE OfficeKey <> @OfficeKey   
  
 -- publication  
 if @CompanyMediaKey is not null  
  delete #tMediaMassBillingDetail  
         where isnull(CompanyMediaKey,0) <> @CompanyMediaKey  
  
 -- removed for 129332  
    --delete #tMediaMassBillingDetail Where UnbilledAmount = 0  
  
 -- Do not take projects which have an open worksheet (ToDo DEV1746-Mass Billing)  
 DELETE #tMediaMassBillingDetail   
 FROM   tBilling b (nolock)  
 WHERE  #tMediaMassBillingDetail.ProjectKey = b.ProjectKey  
 and    b.Status < 5   
  
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.SalesTaxAmount = isnull(vd.SalesTaxAmount, 0)  
 from   tVoucherDetail vd (nolock)  
 where  #tMediaMassBillingDetail.EntityKey = vd.VoucherDetailKey  
 and    #tMediaMassBillingDetail.Entity = ''Invoice''  
  
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.SalesTaxAmount = isnull(pod.SalesTaxAmount, 0)  
 from   tPurchaseOrderDetail pod (nolock)  
 where  #tMediaMassBillingDetail.EntityKey = pod.PurchaseOrderDetailKey  
 and    #tMediaMassBillingDetail.Entity <> ''Invoice''  
  
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.CurrencyID = p.CurrencyID  
 from   tProject p (nolock)  
 where  #tMediaMassBillingDetail.ProjectKey = p.ProjectKey  
   
 update #tMediaMassBillingDetail  
 set    #tMediaMassBillingDetail.CurrencyID = @CurrencyID  
 where  #tMediaMassBillingDetail.CurrencyID is null  
   
 --select summary level data  
  
 -- Caution: The mass billing screen expects 1 row per ProjectKey/MediaEstimateKey/MediaWorksheetKey  (MediaWorksheetKey used only with the new media screens)  
 -- Do not add other fields which do not have a 1 to 1 relationship which project/estimate/media worksheet  
 -- If you add extra rows here for a project below for example, multiple client invoices for the project will be created causing the client to be overbilled  
   
    insert #tMediaMassBilling  
     (ClientKey,  
     CustomerID,  
     ProjectKey,  
     AccountManager,  
           ProjectName,  
           MediaEstimateKey,  
           EstimateName,  
     MediaWorksheetKey,  
     WorksheetID,  
     WorksheetName,  
  
           UnbilledAmount,  
           DetailOrderDate,  
           DetailOrderEndDate,  
           Quantity,  
           TotalCost,  
     SalesTaxAmount)  
    select ClientKey,  
     CustomerID,  
           ProjectKey,  
           Null,  
     ProjectName,  
           MediaEstimateKey,  
     isnull(EstimateName, ''''),
     isnull(MediaWorksheetKey,0),  
     WorksheetID,  
     WorksheetName,  
     SUM(UnbilledAmount),  
     MIN(DetailOrderDate),  
           MAX(DetailOrderEndDate),  
           SUM(Quantity),  
           SUM(TotalCost),  
     SUM(SalesTaxAmount)  
      from #tMediaMassBillingDetail  
  group by ClientKey,  
     CustomerID,  
        ProjectKey,  
        ProjectName,  
     MediaEstimateKey,  
           isnull(EstimateName, ''''), 
     isnull(MediaWorksheetKey,0),  
           WorksheetID,  
     WorksheetName  
  
  
 update #tMediaMassBillingDetail set ProjectName = ''No Project'' where isnull(ProjectName, '''') = ''''  
 update #tMediaMassBillingDetail set EstimateName = ''No Estimate'' where isnull(EstimateName, '''') = ''''  
 update #tMediaMassBillingDetail set MarketName = ''No Market'' where isnull(MarketName, '''') = ''''
 update #tMediaMassBillingDetail set PlanName = ''No Plan'' where isnull(PlanName, '''') = ''''  
  
 update #tMediaMassBilling  
 set    #tMediaMassBilling.AccountManager = u.FirstName + '' '' + u.LastName  
          ,#tMediaMassBilling.CurrencyID = p.CurrencyID  
 from   tProject p (nolock)  
 left   outer join tUser u (nolock) ON p.AccountManager = u.UserKey  
 where  #tMediaMassBilling.ProjectKey = p.ProjectKey  
 --and (@AccountManager is null or p.AccountManager = @AccountManager)  
  
 update #tMediaMassBilling  
 set    #tMediaMassBilling.CurrencyID = @CurrencyID  
 where  #tMediaMassBilling.CurrencyID is null  
   
  
--select * from #tMediaMassBilling  
  
DECLARE @timenow DATETIME;
SET @timenow = DATEADD(MINUTE, 60, GETDATE())

SELECT ISNULL(SUM(UnbilledAmount),0) FROM #tMediaMassBilling 
SELECT @MediaUnbilledAmount = ISNULL(SUM(UnbilledAmount),0) FROM #tMediaMassBilling 
  
IF EXISTS (SELECT TOP 1 EntityKey FROM tCache (NOLOCK) WHERE Entity = ''tUser'' AND EntityKey =  @UserKey AND ProcessID = ''today.billing.mediaUnbilledAmount'')
	UPDATE	tCache
	SET		ProcessAmount = ISNULL(@MediaUnbilledAmount,0), Expiration = REPLACE(@timenow, '':'' + FORMAT(DATEPART(MINUTE, @timenow),''00''), '':'' + LEFT(FORMAT(DATEPART(MINUTE, @timenow),''00''),1) + RIGHT(@UserKey, 1))
	WHERE	Entity = ''tUser''
			AND EntityKey = @UserKey
			AND ProcessID = ''today.billing.medaiUnbilledAmount''
ELSE
	INSERT INTO	tCache (Entity, EntityKey, ProcessID, ProcessAmount, Expiration)
	VALUES ( ''tUser'', @UserKey, ''today.billing.mediaUnbilledAmount'', ISNULL(@MediaUnbilledAmount,0), REPLACE(@timenow, '':'' + FORMAT(DATEPART(MINUTE, @timenow),''00''), '':'' + LEFT(FORMAT(DATEPART(MINUTE, @timenow),''00''),1) + RIGHT(@UserKey, 1)) )


 RETURN @MediaUnbilledAmount
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptUserCheckActive]'
GO
IF OBJECT_ID(N'[dbo].[sptUserCheckActive]', 'P') IS NOT NULL
EXEC sp_executesql N'

ALTER PROCEDURE [dbo].[sptUserCheckActive]
 @UserKey int

AS --Encrypt

/*
|| When		Who	Rel			What
|| 04/06/17	QMD	10.6.1.4	added loggedout column to select
|| 09/01/17	QMD	10.6.2.0	added RequestToken column to select
|| 09/28/17	QMD	10.6.2.0	added case for loggedout
|| 02/11/25 MAS 26.02.15	(714029) Added PwdDaysBetweenChanges override when using SSO 
|| 06/24/26 MAS 26.06.14    (730209) Override ForcePwdChangeOnNextLogin to 0 when using SSO
*/
 
SELECT 
      u.Active as uActive,
      u.LastPwdChange,
      u.LastLogin,
      ISNULL(u.ClientVendorLogin, 0) as ClientVendorLogin,
      c.Locked as cLocked,
      c.Active as cActive,

      CASE 
          WHEN LEN(ISNULL(p.SSOIPURL, '''')) > 0 THEN 0 -- Override when using SSO 
          ELSE p.PwdDaysBetweenChanges
      END as PwdDaysBetweenChanges,

      CASE
          WHEN LEN(ISNULL(p.SSOIPURL, '''')) > 0 THEN 0 -- Override when using SSO
          ELSE u.ForcePwdChangeOnNextLogin
      END as ForcePwdChangeOnNextLogin,
          
      ISNULL(u.OwnerCompanyKey, u.CompanyKey) as CompanyKey,
      u.LoggedOut, 
      CASE u.LoggedOut 
          WHEN 1 THEN NULL
          ELSE u.RequestToken
      END AS RequestToken,
      ISNULL(ISNULL(u.Theme, p.Theme), 1) as Theme

  FROM tUser u (nolock)
  INNER JOIN tCompany c (nolock) ON ISNULL(u.OwnerCompanyKey, u.CompanyKey) = c.CompanyKey
  INNER JOIN tPreference p (nolock) ON c.CompanyKey = p.CompanyKey

  WHERE u.UserKey = @UserKey

RETURN 1
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptCalendarScheduledReportUpdateNextScheduleDate]'
GO
IF OBJECT_ID(N'[dbo].[sptCalendarScheduledReportUpdateNextScheduleDate]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptCalendarScheduledReportUpdateNextScheduleDate]
	@CalendarKey int
AS --Encrypt

/*
|| When     Who Rel      What
|| 11/08/24 RLB 24.12.15 (684679) created to update NextScheduleDate on scheduled reports
|| 06/01/26 RLB 26.06.14 (729627) fix for monthly and yearly next date not set correctly for last week option
|| 06/26/26 RLB 26.07.19 (731685) another fix for monthly and yealy when last week is selected
|| 07/15/26 RLB 26.07.19 (732513) day was off by 1 because a day was not added after the start was calculated
*/

Declare @Frequency varchar(50)
	,@Interval int
	,@ByMonthDay int
	,@Su tinyint
	,@Mo tinyint
	,@Tu tinyint
	,@We tinyint
	,@Th tinyint
	,@Fr tinyint
	,@Sa tinyint
	,@BySetPos int
	,@ByMonth int
	,@NextDate smalldatetime
	,@NextNextDate smalldatetime
	,@EventStart smalldatetime
	,@CurrentDatePart int
	,@SelectedDatePart int
	,@addDays int


select @NextDate = NextScheduleDate
		,@Interval = Interval
		,@Frequency = Freq
		,@ByMonthDay = ByMonthDay
		,@Su = Su
		,@Mo = Mo
		,@Tu = Tu
		,@We = We
		,@Th = Th
		,@Fr = Fr
		,@Sa = Sa
		,@BySetPos = BySetPos
		,@ByMonth = ByMonth
		,@EventStart = EventStart
		,@SelectedDatePart = CASE
			WHEN Su = 1 then 1
			WHEN Mo = 1 then 2
			when Tu = 1 then 3
			when We = 1 then 4
			when Th = 1 then 5
			when Fr = 1 then 6
			when Sa = 1 then 7
			else 0
		end
	from tCalendar
	where CalendarKey = @CalendarKey

Select @NextNextDate = dbo.fFormatDateNoTime(GETDATE())    

if @Frequency = ''DAILY''
BEGIN
	if isnull(@Interval, 0) = 0 and @Mo = 1 and @Tu = 1 and @We = 1 and @Th = 1 and @Fr = 1
	begin
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
		Select @CurrentDatePart = DATEPART(dw,@NextNextDate)
		if @CurrentDatePart = 1
			Select @NextNextDate = dateadd(d, 2,@NextNextDate)
		else if @CurrentDatePart = 2
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
		else if @CurrentDatePart = 3
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
		else if @CurrentDatePart = 4
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
		else if @CurrentDatePart = 5
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
		else if @CurrentDatePart = 6
			Select @NextNextDate = dateadd(d, 4,@NextNextDate)
		else if @CurrentDatePart = 7
			Select @NextNextDate = dateadd(d, 3,@NextNextDate)
	end
	else
	begin
		Select @NextNextDate = dateadd(d, @Interval,@NextNextDate)
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	end
END

if @Frequency = ''WEEKLY''
BEGIN
	select @addDays = 7 * @Interval
	Select @NextNextDate = dateadd(d, @addDays,@NextNextDate)
	SELECT @CurrentDatePart = DATEPART(dw,@NextNextDate)
	IF @Su = 1 and @CurrentDatePart = 1
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	else if @Mo = 1 and @CurrentDatePart < 3
		if @CurrentDatePart = 1
			Select @NextNextDate = dateadd(d, 2,@NextNextDate)
		else	
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	else if @Tu = 1 and @CurrentDatePart < 4
		if @CurrentDatePart = 1
			Select @NextNextDate = dateadd(d, 3,@NextNextDate)
		else if @CurrentDatePart = 2
			Select @NextNextDate = dateadd(d, 2,@NextNextDate)
		else if @CurrentDatePart = 3
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	else if @We = 1 and @CurrentDatePart < 5
		if @CurrentDatePart = 1
			Select @NextNextDate = dateadd(d, 4,@NextNextDate)
		else if @CurrentDatePart = 2
			Select @NextNextDate = dateadd(d, 3,@NextNextDate)
		else if @CurrentDatePart = 3
			Select @NextNextDate = dateadd(d, 2,@NextNextDate)
		else if @CurrentDatePart = 4
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	else if @Th = 1 and @CurrentDatePart < 6
		if @CurrentDatePart = 1
			Select @NextNextDate = dateadd(d, 5,@NextNextDate)
		else if @CurrentDatePart = 2
			Select @NextNextDate = dateadd(d, 4,@NextNextDate)
		else if @CurrentDatePart = 3
			Select @NextNextDate = dateadd(d, 3,@NextNextDate)
		else if @CurrentDatePart = 4
			Select @NextNextDate = dateadd(d, 2,@NextNextDate)
		else if @CurrentDatePart = 5
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	else if @Fr = 1 and @CurrentDatePart < 7
		if @CurrentDatePart = 1
			Select @NextNextDate = dateadd(d, 6,@NextNextDate)
		else if @CurrentDatePart = 2
			Select @NextNextDate = dateadd(d, 5,@NextNextDate)
		else if @CurrentDatePart = 3
			Select @NextNextDate = dateadd(d, 4,@NextNextDate)
		else if @CurrentDatePart = 4
			Select @NextNextDate = dateadd(d, 3,@NextNextDate)
		else if @CurrentDatePart = 5
			Select @NextNextDate = dateadd(d, 2,@NextNextDate)
		else if @CurrentDatePart = 6
			Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	else if @Sa = 1 and @CurrentDatePart = 7
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	Select @NextNextDate = dateadd(d, 1,@NextNextDate)
END

if @Frequency = ''MONTHLY''
BEGIN
	IF @ByMonthDay > 0
	begin
		Select @NextNextDate = dateadd(m, @Interval,@NextNextDate)
		SELECT @NextNextDate = DATEFROMPARTS (DATEPART(YY,@NextNextDate), DATEPART(M,@NextNextDate), @ByMonthDay);
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	end
	else
	begin
		Select @NextNextDate = dateadd(m, @Interval,@NextNextDate)
		SELECT @NextNextDate = DATEFROMPARTS (DATEPART(YY,@NextNextDate), DATEPART(M,@NextNextDate), 1);
		SELECT @CurrentDatePart = DATEPART(dw,@NextNextDate)
		if @CurrentDatePart <= @SelectedDatePart
		begin
			select @addDays = @SelectedDatePart - @CurrentDatePart
			Select @NextNextDate = dateadd(d, @addDays,@NextNextDate)
		end
		else
		begin
			select @addDays = @SelectedDatePart - @CurrentDatePart
			Select @NextNextDate = dateadd(d, @addDays,@NextNextDate)
			Select @NextNextDate = dateadd(d, 7,@NextNextDate)
		end
		-- @NextNextDate is now the first occurrence of @SelectedDatePart in the target month
		if @BySetPos = -1
		begin
			-- find last occurrence: advance by weeks while still in same month
			while DATEPART(m, dateadd(d, 7, @NextNextDate)) = DATEPART(m, @NextNextDate)
				Select @NextNextDate = dateadd(d, 7, @NextNextDate)
		end
		else
		begin
			if @BySetPos = 1
				select @addDays = 0
			else
				select @addDays = 7 * (@BySetPos - 1)
			Select @NextNextDate = dateadd(d, @addDays, @NextNextDate)
		end
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	end
END

if @Frequency = ''YEARLY''
BEGIN
	IF @ByMonthDay > 0
	begin
		Select @NextNextDate = dateadd(YY, 1,@NextNextDate)
		SELECT @NextNextDate = DATEFROMPARTS (DATEPART(YY,@NextNextDate), @ByMonth, @ByMonthDay);
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	end
	else
	begin
		Select @NextNextDate = dateadd(YY, 1,@NextNextDate)
		SELECT @NextNextDate = DATEFROMPARTS (DATEPART(YY,@NextNextDate), @ByMonth, 1);
		SELECT @CurrentDatePart = DATEPART(dw,@NextNextDate)

		if @CurrentDatePart <= @SelectedDatePart
		begin
			select @addDays = @SelectedDatePart - @CurrentDatePart
			Select @NextNextDate = dateadd(d, @addDays,@NextNextDate)
		end
		else
		begin
			select @addDays = @SelectedDatePart - @CurrentDatePart
			Select @NextNextDate = dateadd(d, @addDays,@NextNextDate)
			Select @NextNextDate = dateadd(d, 7,@NextNextDate)
		end
		-- @NextNextDate is now the first occurrence of @SelectedDatePart in the target month
		if @BySetPos = -1
		begin
			-- find last occurrence: advance by weeks while still in same month
			while DATEPART(m, dateadd(d, 7, @NextNextDate)) = DATEPART(m, @NextNextDate)
				Select @NextNextDate = dateadd(d, 7, @NextNextDate)
		end
		else
		begin
			if @BySetPos = 1
				select @addDays = 0
			else
				select @addDays = 7 * (@BySetPos - 1)
			Select @NextNextDate = dateadd(d, @addDays, @NextNextDate)
		end
		Select @NextNextDate = dateadd(d, 1,@NextNextDate)
	end
END


-- apply the scheduled time from EventStart to the calculated next date
Select @NextNextDate = DATEADD(minute, DATEDIFF(minute, dbo.fFormatDateNoTime(@EventStart), @EventStart), @NextNextDate)

Select @NextDate = @NextNextDate

UPDATE
	tCalendar
SET

	NextScheduleDate = @NextDate	
WHERE
	CalendarKey = @CalendarKey 

	
	
	RETURN @CalendarKey 

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAIGetCalendarEvents]'
GO
IF OBJECT_ID(N'[dbo].[spApiAIGetCalendarEvents]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[spApiAIGetCalendarEvents]
(
	@CompanyKey int,
	@UserKey int,
	@StartDate datetime,
	@EndDate datetime,
	@UTCOffsetHours	int      = 0,
	@UserName varchar(200)   = NULL
)

as

/*
|| When      Who Rel        What
|| 05/01/26  GRR 26.05.xx   Created
|| 05/04/26  GRR 26.05.xx   Added user name to search on.
|| 05/15/26  GRR 26.05.xx   Fixed date range filter to use overlap check so events ending after midnight are returned.
|| 05/28/26  AI  26.05.28   Reviewed: only feature-right (admineditusercalendar) check; no record-level entity gate applies. Normalized to CREATE OR ALTER.
|| 06/18/26  GAR 26.07.xx   Also allow access when caller''s security group has CanView or CanAdd in tCMFolderSecurity for the target user''s calendar folder.
|| 06/29/26  GAR 26.07.xx   Initialize @IsAdministrator = 0 so a failed tUser lookup never silently bypasses the security check.
|| 06/29/26  GAR 26.07.xx   Per-folder security: admins/admineditusercalendar get all events; others get only events from folders
||                           they have explicit tCMFolderSecurity access to. Upfront check now only errors when caller has NO
||                           folder access at all rather than acting as an all-or-nothing gate.
*/

Declare @SecurityGroupKey int
Declare @IsAdministrator bit = 0
Declare @HasAdminRight bit = 0
Declare @TargetUserKey int

Select * into #errors From tAPIErrorTemplate Where 1 = 2

-- If a user name was provided, resolve it to a UserKey
If @UserName Is Not Null And LTRIM(RTRIM(@UserName)) <> ''''
Begin
	Select Top 1 @TargetUserKey = UserKey
	From tUser (nolock)
	Where CompanyKey = @CompanyKey
	And ISNULL(Active,0) = 1
	And (FirstName + '' '' + LastName LIKE ''%'' + @UserName + ''%''
			Or UserID Like ''%'' + @UserName + ''%''
			Or Email Like ''%'' + @UserName + ''%''
		)
	Order By UserKey

	If @TargetUserKey Is Null
	Begin
		Insert Into #errors (errorType, errorCode, errorMessage, fieldName)
		Values (''error'', ''NOT_FOUND'', ''User not found: '' + @UserName + ''.'', ''userName'')

		Select errorType, errorCode, errorMessage, fieldName From #errors Order By errorType Desc, fieldName
		Drop Table #errors
		Return -101
	End

	-- Security only applies when viewing a different user''s calendar
	If @TargetUserKey <> @UserKey
	Begin
		Select @SecurityGroupKey = SecurityGroupKey,
			@IsAdministrator = ISNULL(Administrator, 0)
		From tUser (nolock)
		Where UserKey = @UserKey
			And CompanyKey = @CompanyKey

		If @IsAdministrator = 0
		Begin
			-- Check for the broad ''admineditusercalendar'' feature right (grants access to all folders)
			If Exists (
				Select 1 From tRight r (nolock)
				Inner Join tRightAssigned ra (nolock) On r.RightKey = ra.RightKey
				Where ra.EntityType = ''SecurityGroup''
				And ra.EntityKey = @SecurityGroupKey
				And r.RightID = ''admineditusercalendar''
			)
				Set @HasAdminRight = 1

			-- Without the broad right, caller must have per-folder access to at least one of
			-- the target user''s calendar folders.  If none exist, return ACCESS_DENIED now
			-- so we give a meaningful error rather than silently returning zero rows.
			If @HasAdminRight = 0
			Begin
				If Not Exists (
					Select 1 From tCMFolder f (nolock)
					Inner Join tCMFolderSecurity fsec (nolock) On f.CMFolderKey = fsec.CMFolderKey
					Where f.UserKey = @TargetUserKey
					And f.Entity = ''tCalendar''
					And (fsec.CanView = 1 Or fsec.CanAdd = 1)
					And (   (fsec.Entity = ''tUser''          And fsec.EntityKey = @UserKey)
					     Or (fsec.Entity = ''tSecurityGroup'' And fsec.EntityKey = @SecurityGroupKey)
					    )
				)
				Begin
					Insert Into #errors (errorType, errorCode, errorMessage, fieldName)
					Values (''error'', ''ACCESS_DENIED'', ''You do not have permissions to view other users'''' calendar entries.'', ''userName'')

					Select errorType, errorCode, errorMessage, fieldName From #errors Order By errorType Desc, fieldName
					Drop Table #errors
					Return -103
				End
			End
		End
	End

End
Else
	Set @TargetUserKey = @UserKey

Drop Table #errors

-- First leg: non-recurring events and first occurrence of recurring events (stored in tCalendar)
Select cal.Subject, cal.Description, cal.Location, p.ProjectNumber, p.ProjectName, t.TaskID, u.FirstName + '' '' + u.LastName as ContactName, c.CompanyName,
	cal.Recurring, cal.RecurringCount, cal.RecurringEndDate, cal.RecurringSettings, cal.UID, cal.OriginalUID, cal.EventStart as EventStart, cal.EventEnd as EventEnd, cal.Pattern, cal.Su, cal.Mo, cal.Tu, cal.We, cal.Th, cal.Fr, cal.Sa,
	f.FolderName as FolderName
From tCalendar cal (nolock)
inner join tCalendarAttendee ca (nolock) on ca.CalendarKey = cal.CalendarKey
inner join tCMFolder f (nolock) on f.CMFolderKey = ca.CMFolderKey
left outer join tProject p (nolock) on p.ProjectKey = cal.ProjectKey
left outer join tTask t (nolock) on t.TaskKey = cal.TaskKey
left outer join tUser u (nolock) on u.UserKey = cal.ContactUserKey
left outer join tCompany c (nolock) on c.CompanyKey = cal.ContactCompanyKey

Where f.UserKey = @TargetUserKey
And cal.EventStart < DATEADD(day, 1, @EndDate)
And cal.EventEnd > @StartDate
And (
	@TargetUserKey = @UserKey		-- own calendar: no restriction
	Or @IsAdministrator = 1			-- system admin: no restriction
	Or @HasAdminRight = 1			-- admineditusercalendar right: no restriction
	Or Exists (						-- per-folder grant: only folders caller can see
		Select 1 From tCMFolderSecurity fsec (nolock)
		Where fsec.CMFolderKey = f.CMFolderKey
		And (fsec.CanView = 1 Or fsec.CanAdd = 1)
		And (   (fsec.Entity = ''tUser''          And fsec.EntityKey = @UserKey)
		     Or (fsec.Entity = ''tSecurityGroup'' And fsec.EntityKey = @SecurityGroupKey)
		    )
	)
)

Union All

-- Second leg: subsequent occurrences of recurring events (stored in tCalendarCache)
Select cal.Subject, cal.Description, cal.Location, p.ProjectNumber, p.ProjectName, t.TaskID, u.FirstName + '' '' + u.LastName as ContactName, c.CompanyName,
	cal.Recurring, cal.RecurringCount, cal.RecurringEndDate, cal.RecurringSettings, cal.UID, cal.OriginalUID, cal.EventStart as EventStart, cal.EventEnd as EventEnd, cal.Pattern, cal.Su, cal.Mo, cal.Tu, cal.We, cal.Th, cal.Fr, cal.Sa,
	f.FolderName as FolderName
From tCalendar cal (nolock)
inner join tCalendarCache cc (nolock) on cc.CalendarKey = cal.CalendarKey
inner join tCalendarAttendee ca (nolock) on ca.CalendarKey = cal.CalendarKey
inner join tCMFolder f (nolock) on f.CMFolderKey = ca.CMFolderKey
left outer join tProject p (nolock) on p.ProjectKey = cal.ProjectKey
left outer join tTask t (nolock) on t.TaskKey = cal.TaskKey
left outer join tUser u (nolock) on u.UserKey = cal.ContactUserKey
left outer join tCompany c (nolock) on c.CompanyKey = cal.ContactCompanyKey

Where f.UserKey = @TargetUserKey
And cc.EventStart < DATEADD(day, 1, @EndDate)
And cc.EventEnd > @StartDate
And (
	@TargetUserKey = @UserKey		-- own calendar: no restriction
	Or @IsAdministrator = 1			-- system admin: no restriction
	Or @HasAdminRight = 1			-- admineditusercalendar right: no restriction
	Or Exists (						-- per-folder grant: only folders caller can see
		Select 1 From tCMFolderSecurity fsec (nolock)
		Where fsec.CMFolderKey = f.CMFolderKey
		And (fsec.CanView = 1 Or fsec.CanAdd = 1)
		And (   (fsec.Entity = ''tUser''          And fsec.EntityKey = @UserKey)
		     Or (fsec.Entity = ''tSecurityGroup'' And fsec.EntityKey = @SecurityGroupKey)
		    )
	)
)


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[sptActivityGetSummary]'
GO
IF OBJECT_ID(N'[dbo].[sptActivityGetSummary]', 'P') IS NULL
EXEC sp_executesql N'
CREATE PROCEDURE [dbo].[sptActivityGetSummary]
	(
	@CompanyKey int,
	@EntityKey int
	)

AS --Encrypt

/*
|| When     Who Rel      What
|| 07/01/24	MAS 25.00.00 Created
*/

SELECT Notes
FROM tActivity (NOLOCK)
WHERE CompanyKey = @CompanyKey
AND RootActivityKey = @EntityKey
ORDER BY ActivityDate DESC'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[sptAttachmentValidatePermission]'
GO
IF OBJECT_ID(N'[dbo].[sptAttachmentValidatePermission]', 'P') IS NULL
EXEC sp_executesql N'CREATE    PROCEDURE [dbo].[sptAttachmentValidatePermission]
    (
        @CompanyKey         int,
        @UserKey            int,
        @AssociatedEntity   varchar(50),
        @EntityKey          int
    )
AS --Encrypt

/*
|| When      Who Rel        What
|| 05/12/26  GRR 26.05.xx   Created — generic permission check for tAttachment inserts.
||                          Dispatches per @AssociatedEntity. Each branch does
||                          its own existence + ownership + state + GL + right
||                          checks and emits a single result row the caller can act on.
||
|| Result row columns:
||   CanAttach     tinyint         1 = attach allowed, 0 = blocked
||   ErrorMessage  nvarchar    NULL on success, reason on failure
||   EntityExists  tinyint         1 if the row was found in this company
||   UserOwns      tinyint         1 if the user is the record''s owner (else they''re using an override right)
||   EntityState   varchar     Human-readable state of the entity (where applicable)
||
|| Adding a new entity:
||   1. Add a new ELSE IF @AssociatedEntity = ''YourEntity'' branch below
||   2. Apply checks: existence + CompanyKey, ownership/override, state, GL, right
||   3. Set @CanAttach=1 + clear @ErrorMessage on success
||   4. Document the entity in mcp-dev skill OPERATIONS.md
*/

    Declare @SecurityGroupKey       int
    Declare @IsAdministrator        tinyint
    Declare @RestrictToGLCompany    int

    Declare @CanAttach              tinyint             = 0
    Declare @ErrorMessage           nvarchar(500)   = NULL
    Declare @EntityExists           tinyint             = 0
    Declare @UserOwns               tinyint             = 0
    Declare @EntityState            nvarchar(50)    = NULL

    -- ============================================================================
    -- Load caller''s security context
    -- ============================================================================
    Select  @SecurityGroupKey = SecurityGroupKey,
            @IsAdministrator  = ISNULL(Administrator, 0)
      From  tUser (nolock)
     Where  UserKey = @UserKey
       And  CompanyKey = @CompanyKey

    If @SecurityGroupKey Is Null
    Begin
        Set @ErrorMessage = ''Calling user not found in this company.''
        Goto Done
    End

    Select  @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0)
      From  tPreference (nolock)
     Where  CompanyKey = @CompanyKey

    -- ============================================================================
    -- Dispatch on entity type
    -- ============================================================================

    If @AssociatedEntity = ''ExpenseReceipt''
    Begin
        Declare @EnvUserKey         int
        Declare @EnvStatus          smallint
        Declare @EnvGLCompanyKey    int

        Select  @EntityExists       = 1,
                @EnvUserKey         = ee.UserKey,
                @EnvStatus          = ee.Status,
                @EnvGLCompanyKey    = p.GLCompanyKey,
                @EntityState        = Case ee.Status
                                          When 1 Then ''Unsubmitted''
                                          When 2 Then ''Submitted''
                                          When 3 Then ''Rejected''
                                          When 4 Then ''Approved''
                                          Else        ''Unknown''
                                      End
          From  tExpenseReceipt  er (nolock)
    Inner Join  tExpenseEnvelope ee (nolock) On ee.ExpenseEnvelopeKey = er.ExpenseEnvelopeKey
    Left outer join tProject p (nolock) On p.ProjectKey = er.ProjectKey
         Where  er.ExpenseReceiptKey = @EntityKey
           And  ee.CompanyKey        = @CompanyKey

        If @EntityExists = 0
        Begin
            Set @ErrorMessage = ''Expense receipt not found in this company.''
            Goto Done
        End

        -- Ownership / override-right check
        If @EnvUserKey = @UserKey
        Begin
            Set @UserOwns = 1
        End
        Else If @IsAdministrator = 0
        Begin
            If Not Exists (
                Select  1
                  From  tRight r (nolock)
            Inner Join  tRightAssigned ra (nolock) On ra.RightKey = r.RightKey
                 Where  ra.EntityType = ''Security Group''
                   And  ra.EntityKey  = @SecurityGroupKey
                   And  r.RightID     = ''billingviewallexpense''
            )
            Begin
                Set @ErrorMessage = ''You do not have permission to modify another user''''s expense receipt.''
                Goto Done
            End

            -- GL company access (only enforced when company preference is set)
            If @RestrictToGLCompany = 1 And @EnvGLCompanyKey Is Not Null
            Begin
                If Not Exists (
                    Select  1
                      From  tUserGLCompanyAccess (nolock)
                     Where  UserKey      = @UserKey
                       And  GLCompanyKey = @EnvGLCompanyKey
                )
                Begin
                    Set @ErrorMessage = ''You do not have GL company access for this expense envelope.''
                    Goto Done
                End
            End
        End

        -- State check: only Unsubmitted (1) or Rejected (3) accept attachments
        If @EnvStatus Not In (1, 3)
        Begin
            Set @ErrorMessage = ''Cannot attach to a receipt whose envelope is '' + ISNULL(@EntityState, ''Unknown'') + ''. Only Unsubmitted or Rejected envelopes accept new attachments.''
            Goto Done
        End

        Set @CanAttach = 1
        Goto Done
    End

    -- ----------------------------------------------------------------------------
    Else If @AssociatedEntity = ''tVoucher'' Or @AssociatedEntity = ''Voucher''
    Begin
        Declare @VoucherCreatedBy   int
        Declare @VoucherStatus      smallint
        Declare @VoucherGLCompany   int
        Declare @VoucherPosted      tinyint
        Declare @VoucherCreditCard  tinyint

        Select  @EntityExists       = 1,
                @VoucherCreatedBy   = CreatedByKey,
                @VoucherStatus      = Status,
                @VoucherGLCompany   = GLCompanyKey,
                @VoucherPosted      = ISNULL(Posted, 0),
                @VoucherCreditCard  = ISNULL(CreditCard, 0),
                @EntityState        = Case Status
                                          When 1 Then ''Draft''
                                          When 2 Then ''Submitted''
                                          When 3 Then ''Rejected''
                                          When 4 Then ''Approved''
                                          Else        ''Unknown''
                                      End
          From  tVoucher (nolock)
         Where  VoucherKey = @EntityKey
           And  CompanyKey = @CompanyKey

        If @EntityExists = 0
        Begin
            Set @ErrorMessage = ''Voucher not found in this company.''
            Goto Done
        End

        -- Voucher edit right is the floor — needed even to touch your own voucher.
        -- (purch_editvoucher = "Add and Edit Vendor Invoices")
        If @IsAdministrator = 0
        Begin
            If Not Exists (
                Select  1
                  From  tRight r (nolock)
            Inner Join  tRightAssigned ra (nolock) On ra.RightKey = r.RightKey
                 Where  ra.EntityType = ''Security Group''
                   And  ra.EntityKey  = @SecurityGroupKey
                   And  r.RightID     = ''purch_editvoucher''
            )
            Begin
                Set @ErrorMessage = ''You do not have permission to edit vouchers (requires purch_editvoucher).''
                Goto Done
            End
        End

        -- Ownership check
        If @VoucherCreatedBy = @UserKey
        Begin
            Set @UserOwns = 1
        End
        -- For non-owners, purch_editvoucher (already verified above) is sufficient
        -- since voucher editing is gated at the right level, not per-record ownership.
        Else
        Begin
            Set @UserOwns = 0
        End

        -- GL company access
        If @IsAdministrator = 0 And @RestrictToGLCompany = 1 And @VoucherGLCompany Is Not Null
        Begin
            If Not Exists (
                Select  1
                  From  tUserGLCompanyAccess (nolock)
                 Where  UserKey      = @UserKey
                   And  GLCompanyKey = @VoucherGLCompany
            )
            Begin
                Set @ErrorMessage = ''You do not have GL company access for this voucher.''
                Goto Done
            End
        End

        -- State check: posted vouchers are audit-frozen, refuse new attachments.
        -- Allowed states: Draft (1), Submitted (2), Rejected (3). Approved/Posted (4) is locked.
        If @VoucherPosted = 1 Or @VoucherStatus = 4
        Begin
            Set @ErrorMessage = ''Cannot attach to a posted voucher.''
            Goto Done
        End

        Set @CanAttach = 1
        Goto Done
    End

    -- ----------------------------------------------------------------------------
    -- Unknown entity
    Else
    Begin
        Set @ErrorMessage = ''Attachments are not supported for entity type '''''' + ISNULL(@AssociatedEntity, ''(null)'') + ''''''. Supported types: ExpenseReceipt, Voucher.''
        Goto Done
    End

    Done:

    Select  ISNULL(@CanAttach, 0)   As CanAttach,
            @ErrorMessage           As ErrorMessage,
            ISNULL(@EntityExists, 0) As EntityExists,
            ISNULL(@UserOwns, 0)    As UserOwns,
            @EntityState            As EntityState
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAIGetScheduleDetails]'
GO
IF OBJECT_ID(N'[dbo].[spApiAIGetScheduleDetails]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spApiAIGetScheduleDetails]
(
    @CompanyKey     int,
    @UserKey        int,
    @ProjectNumber  varchar(300),
    @UserID         varchar(300) = null
)
AS --Encrypt

/*
|| When      Who Rel        What
|| --        --  --         Created - AI schedule details (project + tasks + assignments)
|| 05/25/26  AI  26.05.25   Added #errors standard error logging + spCheckAccess gate (tProject).
||                          Replaces the inline GL company + project-assignment check that returned
||                          empty rows on denial; now returns -103 with an explicit ACCESS_DENIED.
|| 05/28/26  AI  26.05.28   Full rewrite: #errors / warnings + spCheckAccess (tProject). Result-set shape now [warnings, project, tasks, assignments].
|| 06/11/26  GAR 26.07.19   (730680) Assignments result set now includes actHours (sum of tTime.ActualHours per user per task).
|| 06/18/26  GAR 26.07.19   (730520) Adding baseline start and baseline complete to the tasks
*/

set nocount on

    select * into #errors from tAPIErrorTemplate where 1 = 2

    declare @ProjectKey     int
    declare @FilterUserKey  int = null
    declare @AccessOK       int

    -- ------------------------------------------------------------------
    -- 1. Validate user
    -- ------------------------------------------------------------------
    if not exists (
        select 1 from tUser (nolock)
        where  UserKey = @UserKey and CompanyKey = @CompanyKey
    )
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''User not found or invalid UserKey.'', ''general'')

        select errorType, errorCode, errorMessage, fieldName
        from   #errors order by errorType desc, fieldName

        drop table #errors
        return -101
    end

    -- ------------------------------------------------------------------
    -- 2. Resolve project
    -- ------------------------------------------------------------------
    if @ProjectNumber is null or LTRIM(RTRIM(@ProjectNumber)) = ''''
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''REQUIRED_FIELD'', ''projectNumber is required.'', ''projectNumber'')

        select errorType, errorCode, errorMessage, fieldName
        from   #errors order by errorType desc, fieldName

        drop table #errors
        return -100
    end

    select @ProjectKey = ProjectKey
    from   tProject (nolock)
    where  CompanyKey    = @CompanyKey
      and  ProjectNumber = @ProjectNumber

    if @ProjectKey is null
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''NOT_FOUND'', ''Project not found for projectNumber: '' + @ProjectNumber, ''projectNumber'')

        select errorType, errorCode, errorMessage, fieldName
        from   #errors order by errorType desc, fieldName

        drop table #errors
        return -101
    end

    -- ------------------------------------------------------------------
    -- 3. Access gate (spCheckAccess: tProject)
    -- ------------------------------------------------------------------
    exec @AccessOK = spCheckAccess @UserKey, @CompanyKey, ''tProject'', @ProjectKey

    if @AccessOK <> 1
    begin
        insert into #errors (errorType, errorCode, errorMessage, fieldName)
        values (''error'', ''ACCESS_DENIED'', ''User does not have access to this project.'', ''projectNumber'')

        select errorType, errorCode, errorMessage, fieldName
        from   #errors order by errorType desc, fieldName

        drop table #errors
        return -103
    end

    -- ------------------------------------------------------------------
    -- 4. Optional @UserID filter (resolve to UserKey)
    -- ------------------------------------------------------------------
    if @UserID is not null and @UserID <> ''''
    begin
        select @FilterUserKey = UserKey
        from   tUser (nolock)
        where  ISNULL(OwnerCompanyKey, CompanyKey) = @CompanyKey
          and  (   UserID like ''%'' + @UserID + ''%''
                or Email + ''|'' + FirstName + '' '' + LastName like ''%'' + @UserID + ''%'' )

        if @FilterUserKey is null
            insert into #errors (errorType, errorCode, errorMessage, fieldName)
            values (''warning'', ''NOT_FOUND'',
                    ''User not found for userID: '' + @UserID + '' - returning unfiltered schedule.'',
                    ''userID'')
    end

    -- ------------------------------------------------------------------
    -- 5. Result set 1: warnings
    -- ------------------------------------------------------------------
    select errorType, errorCode, errorMessage, fieldName
    from   #errors where errorType = ''warning''

    -- ------------------------------------------------------------------
    -- 6. Result set 2: project header
    -- ------------------------------------------------------------------
    select
        p.ProjectNumber  as projectNumber,
        p.ProjectName    as projectName,
        p.Description    as description,
        p.StartDate      as planStart,
        p.CompleteDate   as planComplete,
        c.CustomerID     as clientID,
        c.CompanyName    as clientName
    from   tProject p (nolock)
    inner join tCompany c (nolock) on c.CompanyKey = p.ClientKey
    where  p.ProjectKey = @ProjectKey

    -- ------------------------------------------------------------------
    -- 7. Result set 3: tasks (with predecessors / successors as JSON)
    -- ------------------------------------------------------------------
    select
        t.TaskKey               as taskKey,
        t.TaskID                as taskID,
        t.TaskName              as taskName,
        t.Description           as description,
        t.PlanStart             as planStart,
        t.PlanComplete          as planComplete,
        t.ActStart              as actStart,
        t.ActComplete           as actComplete,
        t.BaseStart             as baseStart,
        t.BaseComplete          as baseComplete,
        t.EstHours              as estHours,
        t.TotalActualHours      as actHours,
        t.PercComp              as percentComplete,
        t.PredecessorsComplete  as predecessorsComplete,
        t.SummaryTaskKey        as parentTaskKey,
        t.ProjectOrder          as displayOrder,
        (
            select pt.TaskID as taskID,
                   pt.TaskName as task,
                   p.Lag  as lagDays,
                   p.Type as lagType
            from   tTaskPredecessor p (nolock)
            inner join tTask pt (nolock) on pt.TaskKey = p.PredecessorKey
            where  p.TaskKey = t.TaskKey
            for json path
        ) as predecessors,
        (
            select st.TaskID as taskID,
                   st.TaskName as task,
                   p.Lag  as lagDays,
                   p.Type as lagType
            from   tTaskPredecessor p (nolock)
            inner join tTask st (nolock) on st.TaskKey = p.PredecessorKey
            where  p.PredecessorKey = t.TaskKey
            for json path
        ) as successors
    from   tTask t (nolock)
    where  t.ProjectKey = @ProjectKey
      and  (@FilterUserKey is null or exists (
                select 1 from tTaskUser tu (nolock)
                where  tu.TaskKey = t.TaskKey and tu.UserKey = @FilterUserKey
            ))
    order by t.ProjectOrder

    -- ------------------------------------------------------------------
    -- 8. Result set 4: task assignments (with actual hours per user per task)
    -- ------------------------------------------------------------------
    ;with cteActuals as (
        select TaskKey, UserKey, SUM(ActualHours) as actHours
        from   tTime (nolock)
        where  ProjectKey = @ProjectKey
        group by TaskKey, UserKey
    )
    select
        t.TaskKey                                 as taskKey,
        s.ServiceCode                             as serviceCode,
        s.Description                             as service,
        u.FirstName                               as firstName,
        u.LastName                                as lastName,
        tu.Hours                                  as allocatedHours,
        ISNULL(a.actHours, 0)                     as actHours,
        ISNULL(tu.APlanStart, t.PlanStart)        as assignmentPlanStart,
        ISNULL(tu.APlanComplete, t.PlanComplete)  as assignmentPlanComplete,
        tu.PercComp                               as assignmentPercentComplete
    from   tTaskUser tu (nolock)
    inner join tTask t (nolock) on t.TaskKey = tu.TaskKey
    left outer join tUser u (nolock) on u.UserKey = tu.UserKey
    left outer join tService s (nolock) on s.ServiceKey = tu.ServiceKey
    left outer join cteActuals a on a.TaskKey = tu.TaskKey and a.UserKey = tu.UserKey
    where  t.ProjectKey = @ProjectKey
      and  (@FilterUserKey is null or tu.UserKey = @FilterUserKey)

    drop table #errors
    return 0


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[sptTaskGetNextRecurring]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskGetNextRecurring]', 'P') IS NULL
EXEC sp_executesql N'CREATE PROC [dbo].[sptTaskGetNextRecurring]
	@TaskKey int
AS
/*
|| When     Who Rel	      What
|| 05/26/26 CRG 26.07.19  Created 
*/

	DECLARE	@NextTaskKey int,
			@RecurringFreq smallint,
			@RecurringParentKey int,
			@RecurringOrder smallint
		
	SELECT	@RecurringFreq = RecurringFreq,
			@RecurringParentKey = RecurringParentKey,
			@RecurringOrder = RecurringOrder
	FROM	tTask (nolock)
	WHERE	TaskKey = @TaskKey
	
	--If the task is not recurring, return 0
	IF ISNULL(@RecurringFreq, 0) = 0
		RETURN 0

	SELECT	@NextTaskKey = TaskKey
	FROM	tTask (nolock)
	WHERE	RecurringParentKey = @RecurringParentKey
	AND		RecurringOrder = ISNULL(@RecurringOrder, 0) + 1

	RETURN ISNULL(@NextTaskKey, 0)'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[spConvertDB2607]'
GO
IF OBJECT_ID(N'[dbo].[spConvertDB2607]', 'P') IS NULL
EXEC sp_executesql N'CREATE PROC [dbo].[spConvertDB2607]
AS

--For issue 730018-MCM, adding a new right for users to view scheduled reports
INSERT INTO tRightAssigned (EntityType, EntityKey, RightKey)
SELECT EntityType, EntityKey, 960054
FROM tRightAssigned (nolock)
WHERE RightKey = 110
AND NOT EXISTS (SELECT * FROM tRightAssigned (nolock) WHERE RightKey = 960054)

--730742-GAR - We added a new setting in tUser called EnableAPIMCPUse and we need to turn it on here for all users that have a PublicAPIToken
UPDATE tUser
SET EnableAPIMCPUse = 1
WHERE UserKey IN 
	(SELECT UserKey FROM tUserPreference (nolock) WHERE LEN(ISNULL(PublicUserToken, '''')) > 0)

--For issue 730512-AMP, adding a new right for users to View API Tokens the default is turned ''ON''
DECLARE @RightKey int = 11700
INSERT INTO tRightAssigned (EntityType, EntityKey, RightKey)
SELECT DISTINCT
  ra.EntityType,
  ra.EntityKey,
  @RightKey
FROM tRightAssigned ra (nolock)
WHERE NOT EXISTS (
  SELECT *
  FROM tRightAssigned existing (nolock)
  WHERE
    existing.EntityType = ra.EntityType AND
    existing.EntityKey = ra.EntityKey AND
    existing.RightKey = @RightKey
)AND ra.EntityKey > 0

-- Seed default email templates and sections for all active, unlocked companies
DECLARE @SeedTemplates TABLE (
    SeedEmailTemplateKey int,
    EmailTemplateName     varchar(200),
    Description           varchar(200),
    Active                smallint
)

INSERT INTO @SeedTemplates (SeedEmailTemplateKey, EmailTemplateName, Description, Active) VALUES
(11, ''Project Summary'',        NULL, 1),
(12, ''Upcoming Meetings'',      NULL, 1),
(13, ''Task Status Overview'',   NULL, 1),
(14, ''Completed Assignments'',  NULL, 1),
(15, ''Overdue Assignments'',    NULL, 1),
(16, ''Deliverable Status'',     NULL, 1),
(17, ''Free Text'',              NULL, 1)

DECLARE @SeedSections TABLE (
    SeedEmailTemplateKey        int,
    EmailTemplateSectionDefKey  int,
    DisplayOrder                int,
    PromptText                  nvarchar(max),
    SectionName                 nvarchar(500)
)

INSERT INTO @SeedSections (SeedEmailTemplateKey, EmailTemplateSectionDefKey, DisplayOrder, PromptText, SectionName) VALUES
(11, 1, 0, NULL,                                                          ''Project Summary''),
(12, 2, 0, NULL,                                                          ''Upcoming Meetings''),
(13, 3, 0, NULL,                                                          ''Task Status Overview''),
(14, 4, 0, NULL,                                                          ''Completed Assignments''),
(15, 5, 0, NULL,                                                          ''Overdue Assignments''),
(16, 6, 0, NULL,                                                          ''Deliverable Status''),
(17, 7, 0, ''<span class="usr"><p>Add your text here!</p></span>'',         ''Free Text'')

DECLARE @CompanyKey             int
DECLARE @SeedTemplateKey        int
DECLARE @EmailTemplateName      varchar(200)
DECLARE @Description            varchar(200)
DECLARE @TemplateActive         smallint
DECLARE @NewEmailTemplateKey    int
DECLARE @SectionDefKey          int
DECLARE @DisplayOrder           int
DECLARE @PromptText             nvarchar(max)
DECLARE @SectionName            nvarchar(500)

SET @CompanyKey = 0

WHILE 1 = 1
BEGIN
    SELECT @CompanyKey = MIN(c.CompanyKey)
    FROM tCompany c (nolock)
    WHERE c.Active = 1 AND c.Locked = 0 AND c.CompanyKey > @CompanyKey
      AND NOT EXISTS (SELECT 1 FROM tEmailTemplate (nolock) WHERE CompanyKey = c.CompanyKey)

    IF @CompanyKey IS NULL BREAK

    SET @SeedTemplateKey = 0

    WHILE 1 = 1
    BEGIN
        SELECT @SeedTemplateKey = MIN(SeedEmailTemplateKey)
        FROM @SeedTemplates
        WHERE SeedEmailTemplateKey > @SeedTemplateKey

        IF @SeedTemplateKey IS NULL BREAK

        SELECT @EmailTemplateName = EmailTemplateName, @Description = Description, @TemplateActive = Active
        FROM @SeedTemplates
        WHERE SeedEmailTemplateKey = @SeedTemplateKey

        SET @NewEmailTemplateKey = 0
        EXEC @NewEmailTemplateKey = sptEmailTemplateUpdate
            @CompanyKey        = @CompanyKey,
            @EmailTemplateKey  = 0,
            @EmailTemplateName = @EmailTemplateName,
            @Description       = @Description,
            @Active            = @TemplateActive

        SET @SectionDefKey = 0

        WHILE 1 = 1
        BEGIN
            SELECT @SectionDefKey = MIN(EmailTemplateSectionDefKey)
            FROM @SeedSections
            WHERE SeedEmailTemplateKey = @SeedTemplateKey AND EmailTemplateSectionDefKey > @SectionDefKey

            IF @SectionDefKey IS NULL BREAK

            SELECT @DisplayOrder = DisplayOrder, @PromptText = PromptText, @SectionName = SectionName
            FROM @SeedSections
            WHERE SeedEmailTemplateKey = @SeedTemplateKey AND EmailTemplateSectionDefKey = @SectionDefKey

            EXEC sptEmailTemplateSectionUpdate
                @CompanyKey                 = @CompanyKey,
                @EmailTemplateKey           = @NewEmailTemplateKey,
                @EmailTemplateSectionKey    = 0,
                @EmailTemplateSectionDefKey = @SectionDefKey,
                @SectionName                = @SectionName,
                @PromptText                 = @PromptText,
                @DisplayOrder               = @DisplayOrder,
                @Active                     = 1
        END
    END
END

--731609-RLS - Graduating recurringTasks, automation, and emailtemplates labs to general release
DELETE tLab WHERE LabKey IN (126, 128, 130) -- These are removed in spConvertAppSeedLab but included here for completeness
DELETE tLabBeta WHERE LabKey IN (126, 128, 130)
DELETE tLabCompany WHERE LabKey IN (126, 128, 130)'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spApiAIAddTask]'
GO
IF OBJECT_ID(N'[dbo].[spApiAIAddTask]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spApiAIAddTask]
(
	@CompanyKey int,
	@UserKey int,
	@ProjectNumber varchar(100),
	@TaskID nvarchar(30) = null,
	@TaskName nvarchar(500),
	@Description nvarchar(max) = null,
	@ParentTaskID nvarchar(30) = null,
	@InsertBelowTaskID nvarchar(30) = null, -- Optional TaskID to specify where to insert new task under the parent (if not provided, will be added as last child of ParentTaskID)
	@PlanStart smalldatetime = null,
	@PlanComplete smalldatetime = null,
	@PlanDuration int = null,
	@EstHours decimal(24,4) = 0,
	@AssignedTo varchar(max) = null,
	@PredecessorTaskIDs varchar(max) = null,
	@Comments varchar(4000) = null,
	@TrackBudget tinyint = null
)

as --Encrypt

/*
|| When      Who Rel        What
|| 04/01/26  AI  26.05.17   Created - Add/Update tasks via API with assignments and predecessors
|| 04/22/26  CRG 26.05.17   Updated - Add InsertBelowTaskID parameter to specify where to insert new task under the parent
|| 05/18/26  CRG 26.05.17   Fixed the DisplayOrder and ParentTaskKeys so that the TaskID will be set correctly
|| 05/28/26  AI  26.05.28   spCheckAccess (tProject) replaces inline GL company + assignment checks.
|| 06/15/26  GAR 26.06.14   (730907) Fixed an issue with rights - Claude was using prjEdit and schedEdit and there is no such thing - switched to prjedittasks
|| 06/22/26  CRG 26.07.19   Added @TrackBudget parameter; wired into INSERT and UPDATE.
|| 06/22/26  CRG 26.05.19   Added TrackBudget validation and MoneyTask/BudgetTaskKey cascade logic.
*/

	declare @ProjectKey int
	declare @TaskKey int
	declare @ParentTaskKey int
	declare @InsertBelowTaskKey int
	declare @ServiceKey int
	declare @WorkTypeKey int
	declare @TaskExists tinyint
	declare @TaskStatus smallint
	declare @ErrorCount int
	declare @CheckParentKey int
	declare @ResetCheckResult int
	declare @CurrentTaskConstraint int

	-- Create temp table for error/warning messages
	select * into #errors from tAPIErrorTemplate where 1 = 2

	-- Validate required parameters
	if @TaskName is null or LTRIM(RTRIM(@TaskName)) = ''''
	begin
		insert into #errors (errorType, errorCode, errorMessage, fieldName)
		values (''error'', ''REQUIRED_FIELD'', ''TaskName is required.'', ''taskName'')
	end

	if @ProjectNumber is null or LTRIM(RTRIM(@ProjectNumber)) = ''''
	begin
		insert into #errors (errorType, errorCode, errorMessage, fieldName)
		values (''error'', ''REQUIRED_FIELD'', ''ProjectNumber is required.'', ''projectNumber'')
	end

	-- Return errors if validation failed
	select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
	if @ErrorCount > 0
	begin
		select errorType, errorCode, errorMessage, fieldName
		from #errors
		order by errorType desc, fieldName

		drop table #errors
		return -100
	end

	-- Get the project key for the requested project
	select @ProjectKey = ProjectKey
	from tProject (nolock)
	where CompanyKey = @CompanyKey
	and UPPER(ProjectNumber) = UPPER(@ProjectNumber)

	if @ProjectKey is null
	begin
		insert into #errors (errorType, errorCode, errorMessage, fieldName)
		values (''error'', ''NOT_FOUND'', ''Project not found for ProjectNumber: '' + @ProjectNumber, ''projectNumber'')
	end

	-- Security checks: Get user''s security group and administrator status
	declare @SecurityGroupKey int
	declare @IsAdministrator bit
	declare @RestrictToGLCompany tinyint
	declare @CheckAssignment tinyint
	declare @HasScheduleEditRight tinyint
	declare @ProjectGLCompanyKey int

	select @SecurityGroupKey = SecurityGroupKey,
		   @IsAdministrator = Administrator
	from tUser (nolock)
	where UserKey = @UserKey
	and CompanyKey = @CompanyKey

	-- Record-level access gate via spCheckAccess (tProject). Replaces the
	-- inline GL company + assignment checks. spCheckAccess handles admin
	-- bypass and the prjAccessAny / tAssignment fallback.
	if @ProjectKey is not null
	begin
		declare @AccessOK int
		exec @AccessOK = spCheckAccess @UserKey, @CompanyKey, ''tProject'', @ProjectKey
		if @AccessOK <> 1
			insert into #errors (errorType, errorCode, errorMessage, fieldName)
			values (''error'', ''ACCESS_DENIED'', ''User does not have access to this project.'', ''projectNumber'')
	end

	-- Administrators bypass the remaining feature-right checks
	if @IsAdministrator = 0 or @IsAdministrator is null
	begin

		-- Check if user has schedule edit rights
		set @HasScheduleEditRight = 0

		if exists (
			select 1
			from tRight r (nolock)
			inner join tRightAssigned ra (nolock) on r.RightKey = ra.RightKey
			where ra.EntityType = ''Security Group''
			and ra.EntityKey = @SecurityGroupKey
			and r.RightID in (''prjedittasks'')
		)
		begin
			set @HasScheduleEditRight = 1
		end

		if @HasScheduleEditRight = 0
		begin
			insert into #errors (errorType, errorCode, errorMessage, fieldName)
			values (''error'', ''ACCESS_DENIED'', ''User does not have permission to edit project schedules.'', ''general'')
		end
	end

	-- Return errors if security checks failed
	select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
	if @ErrorCount > 0
	begin
		select errorType, errorCode, errorMessage, fieldName
		from #errors
		order by errorType desc, fieldName

		drop table #errors
		return -103
	end

	-- Check if task already exists by TaskID
	set @TaskExists = 0
	if @TaskID is not null and @TaskID <> ''''
	begin
		select @TaskKey = TaskKey
		from tTask (nolock)
		where ProjectKey = @ProjectKey
		and UPPER(TaskID) = UPPER(@TaskID)

		if @TaskKey is not null
			set @TaskExists = 1
	end

	-- Find parent task key if ParentTaskID is provided
	if @ParentTaskID is not null and @ParentTaskID <> ''''
	begin
		select @ParentTaskKey = TaskKey
		from tTask (nolock)
		where ProjectKey = @ProjectKey
		and UPPER(TaskID) = UPPER(@ParentTaskID)

		if @ParentTaskKey is null
		begin
			insert into #errors (errorType, errorCode, errorMessage, fieldName)
			values (''error'', ''NOT_FOUND'', ''Parent task not found or not a summary task for ParentTaskID: '' + @ParentTaskID, ''parentTaskID'')
		end
	end

	-- Find insert below task key if ParentTaskID is provided
	if @InsertBelowTaskID is not null and @InsertBelowTaskID <> ''''
	begin
		select @InsertBelowTaskKey = TaskKey
		from tTask (nolock)
		where ProjectKey = @ProjectKey
		and UPPER(TaskID) = UPPER(@InsertBelowTaskID)

		if @InsertBelowTaskKey is null
		begin
			insert into #errors (errorType, errorCode, errorMessage, fieldName)
			values (''error'', ''NOT_FOUND'', ''Insert Below task not found'', ''insertBelowTaskID'')
		end

		if @ParentTaskKey is not null
		begin
			--Make sure the Insert Below Task is a child of the Parent Task
			if not exists(
					select 1
					from tTask (nolock)
					where TaskKey = @InsertBelowTaskKey
					and SummaryTaskKey = @ParentTaskKey)
			begin
				insert into #errors (errorType, errorCode, errorMessage, fieldName)
				values (''warning'', ''PREVIOUS_NOT_VALID'', ''Insert Below task not a child of the ParentTaskID: '' + @ParentTaskID, ''insertBelowTaskID'')

				set @InsertBelowTaskKey = null -- Ignore the Insert Below Task if it''s not a child of the Parent Task
			end
		end
		else
		begin
			--Set the Parent Task to the Summary Task of the Insert Below Task if Parent Task is not provided
			select @ParentTaskKey = SummaryTaskKey
			from tTask (nolock)
			where ProjectKey = @ProjectKey
			and TaskKey = @InsertBelowTaskKey
		end
	end

	-- Return errors if any lookups failed
	select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
	if @ErrorCount > 0
	begin
		select errorType, errorCode, errorMessage, fieldName
		from #errors
		order by errorType desc, fieldName

		drop table #errors
		return -101
	end

	-- Calculate plan dates if needed
	if @PlanStart is null
		set @PlanStart = GETDATE()

	if @PlanComplete is null
	begin
		if @PlanDuration is not null and @PlanDuration > 0
			set @PlanComplete = DATEADD(DAY, @PlanDuration + ((@PlanDuration + DATEPART(WEEKDAY, @PlanStart) - 1) / 5) * 2, @PlanStart)
		else
			set @PlanComplete = DATEADD(DAY, 1 + ((1 + DATEPART(WEEKDAY, @PlanStart) - 1) / 5) * 2, @PlanStart)
	end
	else
	begin
		if @PlanDuration is null
			set @PlanDuration = dbo.fDateDiffNoWeekend(@PlanStart, @PlanComplete)
	end

	if @PlanDuration is null
		set @PlanDuration = 0

	-- -----------------------------------------------------------------------
	-- TrackBudget validation
	-- -----------------------------------------------------------------------
	if @TrackBudget is not null
	begin
		-- Determine the effective parent key to begin ancestor traversal.
		-- For existing tasks: read the stored SummaryTaskKey (unless caller supplied a new parent).
		-- For new tasks: use @ParentTaskKey directly (null = top-level, no ancestors).
		if @TaskExists = 1
		begin
			select @CheckParentKey = NULLIF(SummaryTaskKey, 0) from tTask (nolock) where TaskKey = @TaskKey
			if @ParentTaskKey is not null
				set @CheckParentKey = @ParentTaskKey
		end
		else
			set @CheckParentKey = @ParentTaskKey

		if @TrackBudget = 1
		begin
			-- Check that no ancestor has TrackBudget = 1
			if @CheckParentKey is not null
			begin
				;with AncestorCTE as (
					select TaskKey, SummaryTaskKey, TrackBudget
					from tTask (nolock) where TaskKey = @CheckParentKey
					union all
					select t.TaskKey, t.SummaryTaskKey, t.TrackBudget
					from tTask t (nolock)
					inner join AncestorCTE a on t.TaskKey = a.SummaryTaskKey
					where a.SummaryTaskKey > 0
				)
				select @ErrorCount = COUNT(*) from AncestorCTE where TrackBudget = 1

				if @ErrorCount > 0
					insert into #errors (errorType, errorCode, errorMessage, fieldName)
					values (''error'', ''TRACK_BUDGET_CONFLICT'', ''TrackBudget cannot be set to 1 because a parent task is already tracking budget and expenses.'', ''trackBudget'')
			end

			-- For an existing task, check that no descendant has TrackBudget = 1.
			-- NOTE: CTE must be immediately followed by a DML statement; result is captured
			-- in @ErrorCount before branching with IF.
			if @TaskExists = 1
			begin
				;with DescendantCTE as (
					select TaskKey from tTask (nolock) where SummaryTaskKey = @TaskKey
					union all
					select t.TaskKey from tTask t (nolock)
					inner join DescendantCTE d on t.SummaryTaskKey = d.TaskKey
				)
				select @ErrorCount = COUNT(*)
				from tTask (nolock) t
				inner join DescendantCTE d on t.TaskKey = d.TaskKey
				where t.TrackBudget = 1

				if @ErrorCount > 0
					insert into #errors (errorType, errorCode, errorMessage, fieldName)
					values (''error'', ''TRACK_BUDGET_CONFLICT'', ''TrackBudget cannot be set to 1 because a child task is already tracking budget and expenses.'', ''trackBudget'')
			end
		end
		else if @TrackBudget = 0 and @TaskExists = 1
		begin
			-- New tasks with TrackBudget = 0 pass through; only existing tasks need the reset check.
			exec @ResetCheckResult = sptTaskCheckResetTrackBudget @TaskKey

			if @ResetCheckResult < 0
				insert into #errors (errorType, errorCode, errorMessage, fieldName)
				values (''error'', ''TRACK_BUDGET_HAS_TRANSACTIONS'', ''TrackBudget cannot be set to 0 because transactions are already tied to this task.'', ''trackBudget'')
			else if @ResetCheckResult > 0
			begin
				-- Even with no transaction block, Duration of Project constraint requires TrackBudget.
				select @CurrentTaskConstraint = TaskConstraint from tTask (nolock) where TaskKey = @TaskKey
				if @CurrentTaskConstraint = 7  -- Enum.ProjectScheduleConstraintTypes.DURATION_OF_PROJECT
					insert into #errors (errorType, errorCode, errorMessage, fieldName)
					values (''error'', ''TASK_CONSTRAINT'', ''TrackBudget cannot be set to 0 because the scheduling constraint requires tracking budget and expenses.'', ''trackBudget'')
			end
		end

		select @ErrorCount = COUNT(*) from #errors where errorType = ''error''
		if @ErrorCount > 0
		begin
			select errorType, errorCode, errorMessage, fieldName from #errors order by errorType desc, fieldName
			drop table #errors
			return -104
		end
	end

	-- Insert or Update the task
	if @TaskExists = 0
	begin
		-- Calculate display order for new task
		Update tTask Set TaskType = 1 Where TaskKey = @ParentTaskKey -- Ensure parent is marked as summary task

		declare @DisplayOrder int,
				@ProjectOrder int

		--print ''InsertBelowTaskKey: '' + ISNULL(CAST(@InsertBelowTaskKey as varchar), ''null'')

		if @InsertBelowTaskKey is not null
		begin
			--Get the display order of the task to insert below + 1 and increment
			--display order of all tasks below it
			select	@DisplayOrder = ISNULL(MAX(DisplayOrder), 0) + 1
			from	tTask (nolock)
			where	ProjectKey = @ProjectKey
			and		TaskKey = @InsertBelowTaskKey

			update  tTask
			set		DisplayOrder = DisplayOrder + 1
			where	ProjectKey = @ProjectKey
			and		SummaryTaskKey = @ParentTaskKey
			and		DisplayOrder >= @DisplayOrder
		end
		else
		begin
			select	@DisplayOrder = ISNULL(MAX(DisplayOrder), 0) + 1
			from	tTask (nolock)
			where	ProjectKey = @ProjectKey
			and		SummaryTaskKey = ISNULL(@ParentTaskKey, 0)
		end

		--print ''DisplayOrder: '' + ISNULL(CAST(@DisplayOrder as varchar), ''null'')

		--print ''ParentTaskKey: '' + ISNULL(CAST(@ParentTaskKey as varchar), ''null'')

		if @DisplayOrder = 1 --This will be inserted directly below the parent
			if @ParentTaskKey is not null
				select	@ProjectOrder = ISNULL(ProjectOrder, 0) + 1
				from	tTask (nolock)
				where	TaskKey = @ParentTaskKey
			else
				select	@ProjectOrder = ISNULL(MAX(ProjectOrder), 0) + 1
				from	tTask (nolock)
				where	ProjectKey = @ProjectKey
				and		ISNULL(SummaryTaskKey, 0) = 0
		else
			select	@ProjectOrder = ISNULL(MAX(ProjectOrder), 0) + 1
			from	tTask (nolock)
			where	ProjectKey = @ProjectKey
			and		SummaryTaskKey = ISNULL(@ParentTaskKey, 0)
			and		DisplayOrder = @DisplayOrder - 1

		--print ''ProjectOrder: '' + ISNULL(CAST(@ProjectOrder as varchar), ''null'')

		if isnull(@ProjectOrder, 0) = 0
			set @ProjectOrder = 1

		update	tTask
		set		ProjectOrder = ProjectOrder + 1
		where	ProjectKey = @ProjectKey
		and		ProjectOrder > @ProjectOrder

		-- Insert new task
		insert into tTask
		(
			ProjectKey,
			TaskID,
			TaskName,
			Description,
			TaskType,
			SummaryTaskKey,
			DisplayOrder,
			ProjectOrder,
			ServiceKey,
			WorkTypeKey,
			PlanStart,
			PlanComplete,
			PlanDuration,
			TaskStatus,
			Comments,
			ScheduleTask,
			MoneyTask,
			TaskConstraint,
			TrackBudget,
			DateUpdated
		)
		values
		(
			@ProjectKey,
			@TaskID,
			@TaskName,
			@Description,
			2,
			ISNULL(@ParentTaskKey, 0),
			@DisplayOrder,
			@ProjectOrder,
			@ServiceKey,
			@WorkTypeKey,
			@PlanStart,
			@PlanComplete,
			@PlanDuration,
			@TaskStatus,
			@Comments,
			1,
			1,
			0,
			@TrackBudget,
			GETUTCDATE()
		)

		set @TaskKey = SCOPE_IDENTITY()

		-- Reorder tasks in project
		exec sptTaskOrder @ProjectKey, 0, 0, 0
	end
	else
	begin
		-- Update existing task
		update tTask
		set TaskName = @TaskName,
			Description = ISNULL(@Description, Description),
			SummaryTaskKey = ISNULL(@ParentTaskKey, SummaryTaskKey),
			ServiceKey = ISNULL(@ServiceKey, ServiceKey),
			WorkTypeKey = ISNULL(@WorkTypeKey, WorkTypeKey),
			PlanStart = ISNULL(@PlanStart, PlanStart),
			PlanComplete = ISNULL(@PlanComplete, PlanComplete),
			PlanDuration = ISNULL(@PlanDuration, PlanDuration),
			Comments = ISNULL(@Comments, Comments),
			EstHours = ISNULL(@EstHours, EstHours),
			TrackBudget = ISNULL(@TrackBudget, TrackBudget),
			DateUpdated = GETUTCDATE()
		where TaskKey = @TaskKey
	end

	-- -----------------------------------------------------------------------
	-- TrackBudget cascades (MoneyTask and BudgetTaskKey)
	-- -----------------------------------------------------------------------
	if @TrackBudget = 1
	begin
		-- Set MoneyTask = 1 and BudgetTaskKey = self on the task
		update tTask set MoneyTask = 1, BudgetTaskKey = @TaskKey where TaskKey = @TaskKey

		-- Propagate MoneyTask = 1 up to all ancestors
		;with AncestorCTE as (
			select TaskKey, SummaryTaskKey
			from tTask (nolock)
			where TaskKey = (select NULLIF(SummaryTaskKey, 0) from tTask (nolock) where TaskKey = @TaskKey)
			union all
			select t.TaskKey, t.SummaryTaskKey from tTask t (nolock)
			inner join AncestorCTE a on t.TaskKey = a.SummaryTaskKey
			where a.SummaryTaskKey > 0
		)
		update tTask set MoneyTask = 1 from tTask t inner join AncestorCTE a on t.TaskKey = a.TaskKey

		-- Set BudgetTaskKey = @TaskKey down through all descendants
		;with DescendantCTE as (
			select TaskKey from tTask (nolock) where SummaryTaskKey = @TaskKey
			union all
			select t.TaskKey from tTask t (nolock)
			inner join DescendantCTE d on t.SummaryTaskKey = d.TaskKey
		)
		update tTask set BudgetTaskKey = @TaskKey from tTask t inner join DescendantCTE d on t.TaskKey = d.TaskKey
	end
	else if @TrackBudget = 0 and @TaskExists = 1
	begin
		-- Clear MoneyTask and BudgetTaskKey on the task itself
		update tTask set MoneyTask = 0, BudgetTaskKey = 0 where TaskKey = @TaskKey

		-- Propagate MoneyTask = 0 up to all ancestors
		;with AncestorCTE as (
			select TaskKey, SummaryTaskKey
			from tTask (nolock)
			where TaskKey = (select NULLIF(SummaryTaskKey, 0) from tTask (nolock) where TaskKey = @TaskKey)
			union all
			select t.TaskKey, t.SummaryTaskKey from tTask t (nolock)
			inner join AncestorCTE a on t.TaskKey = a.SummaryTaskKey
			where a.SummaryTaskKey > 0
		)
		update tTask set MoneyTask = 0 from tTask t inner join AncestorCTE a on t.TaskKey = a.TaskKey

		-- Clear BudgetTaskKey down through all descendants
		;with DescendantCTE as (
			select TaskKey from tTask (nolock) where SummaryTaskKey = @TaskKey
			union all
			select t.TaskKey from tTask t (nolock)
			inner join DescendantCTE d on t.SummaryTaskKey = d.TaskKey
		)
		update tTask set BudgetTaskKey = 0 from tTask t inner join DescendantCTE d on t.TaskKey = d.TaskKey
	end

	-- Create temp table to store user keys and service keys
	create table #users (UserKey int, DefaultServiceKey int)

	-- Process assignments if provided
	if @AssignedTo is not null and @AssignedTo <> ''''
	begin
		-- Split comma-separated values and look up users
		declare @UserIdentifier varchar(200)
		declare @Pos int
		declare @AssignedToCopy varchar(max)
		declare @FoundUserKey int
		declare @DefaultServiceKey int

		set @AssignedToCopy = @AssignedTo + '',''
		set @Pos = CHARINDEX('','', @AssignedToCopy)

		while @Pos > 0
		begin
			set @UserIdentifier = LTRIM(RTRIM(SUBSTRING(@AssignedToCopy, 1, @Pos - 1)))
			set @AssignedToCopy = SUBSTRING(@AssignedToCopy, @Pos + 1, LEN(@AssignedToCopy))
			set @Pos = CHARINDEX('','', @AssignedToCopy)

			if @UserIdentifier <> ''''
			begin
				-- Look up user by UserID or Name (partial match) and get DefaultServiceKey
				set @FoundUserKey = null
				set @DefaultServiceKey = null

				select top 1 @FoundUserKey = UserKey,
							 @DefaultServiceKey = DefaultServiceKey
				from tUser (nolock)
				where CompanyKey = @CompanyKey
				and (
					UPPER(UserID) = UPPER(@UserIdentifier)
					or UPPER(FirstName + '' '' + LastName) like ''%'' + UPPER(@UserIdentifier) + ''%''
					or UPPER(LastName + '', '' + FirstName) like ''%'' + UPPER(@UserIdentifier) + ''%''
				)

				if @FoundUserKey is not null
				begin
					insert into #users (UserKey, DefaultServiceKey)
					values (@FoundUserKey, @DefaultServiceKey)
				end
				else
				begin
					-- User not found - add warning
					insert into #errors (errorType, errorCode, errorMessage, fieldName)
					values (''warning'', ''USER_NOT_FOUND'', ''User not found: '' + @UserIdentifier, ''assignedTo'')
				end
			end
		end

		-- Add users to project assignment if not already assigned
		insert into tAssignment (ProjectKey, UserKey, SubscribeDiary, SubscribeToDo, DeliverableReviewer, DeliverableNotify, SubscribeFileUpload)
		select distinct @ProjectKey,
			   u.UserKey, SubscribeDiary, SubscribeToDo, DeliverableReviewer, DeliverableNotify, SubscribeFileUpload
		from #users u
			inner join tUser (nolock) on u.UserKey = tUser.UserKey
		where not exists (
			select 1
			from tAssignment a (nolock)
			where a.ProjectKey = @ProjectKey
			and a.UserKey = u.UserKey
		)

		declare @userCount int
		select	@userCount = count(*)
		from	#users

		-- Users can be duplicated on an assignment, so always insert them
		insert into tTaskUser(TaskKey, UserKey, ServiceKey, Hours)
		select @TaskKey, UserKey, DefaultServiceKey,
				case
					when @userCount > 0 then @EstHours / @userCount
					else 0
				end
		from #users
	end

	-- Process predecessor task IDs if provided
	if @PredecessorTaskIDs is not null and @PredecessorTaskIDs <> ''''
	begin
		-- Create temp table to store predecessor task keys
		create table #predecessors (PredecessorKey int)

		-- Split comma-separated task IDs and look up task keys
		declare @PredTaskID nvarchar(30)
		declare @PredKey int
		set @Pos = null

		declare @PredecessorsCopy varchar(2000)
		set @PredecessorsCopy = @PredecessorTaskIDs + '',''
		set @Pos = CHARINDEX('','', @PredecessorsCopy)

		while @Pos > 0
		begin
			set @PredTaskID = LTRIM(RTRIM(SUBSTRING(@PredecessorsCopy, 1, @Pos - 1)))
			set @PredecessorsCopy = SUBSTRING(@PredecessorsCopy, @Pos + 1, LEN(@PredecessorsCopy))
			set @Pos = CHARINDEX('','', @PredecessorsCopy)

			if @PredTaskID <> ''''
			begin
				-- Look up task key by TaskID in same project
				set @PredKey = null

				select @PredKey = TaskKey
				from tTask (nolock)
				where ProjectKey = @ProjectKey
				and UPPER(TaskID) = UPPER(@PredTaskID)

				if @PredKey is not null
				begin
					insert into #predecessors (PredecessorKey)
					values (@PredKey)
				end
				else
				begin
					-- Predecessor task not found - add warning
					insert into #errors (errorType, errorCode, errorMessage, fieldName)
					values (''warning'', ''TASK_NOT_FOUND'', ''Predecessor task not found: '' + @PredTaskID, ''predecessorTaskIDs'')
				end
			end
		end

		-- Delete existing predecessors for this task (we''ll re-add them)
		delete from tTaskPredecessor
		where TaskKey = @TaskKey

		-- Add predecessors to tTaskPredecessor
		insert into tTaskPredecessor (TaskKey, PredecessorKey, Type, Lag, InWeeks)
		select @TaskKey, p.PredecessorKey, ''FS'', 0, 0
		from #predecessors p
		where not exists (
			select 1
			from tTaskPredecessor tp (nolock)
			where tp.TaskKey = @TaskKey
			and tp.PredecessorKey = p.PredecessorKey
		)

		drop table #predecessors
	end

	declare @AutoTaskID tinyint
	Select @AutoTaskID = ISNULL(AutoIDTask, 1) from tProject Where ProjectKey = @ProjectKey

	exec sptTaskOrder @ProjectKey, 0, 0, 0, @AutoTaskID -- AutoIDTask = 1 to reset TaskIDs based on TaskKey to ensure uniqueness

	-- Check for any errors that should prevent success
	select @ErrorCount = COUNT(*) from #errors where errorType = ''error''

	if @ErrorCount > 0
	begin
		-- Return only errors
		select errorType, errorCode, errorMessage, fieldName
		from #errors
		where errorType = ''error''
		order by fieldName

		drop table #errors
		return -102
	end
	else
	begin
		declare	@UserEmail varchar(100),
				@Culture int

		select	@UserEmail = Email,
				@Culture = ISNULL(u.UserCulture, ISNULL(o.OfficeCulture, p.Culture))
		from	vUserName u
		left join tOffice o (nolock) on u.OfficeKey = o.OfficeKey
		left join tPreference p (nolock) on ISNULL(u.OwnerCompanyKey, u.CompanyKey) = p.CompanyKey
		where	u.UserKey = @UserKey

		-- Return success result with any warnings
		select @TaskKey as taskKey,
			   @TaskID as taskID,
			   @TaskName as taskName,
			   @ProjectKey as projectKey,
			   @ProjectNumber as projectNumber,
			   @UserEmail as userEmail,
			   @Culture as culture,
			   case when @TaskExists = 1 then ''updated'' else ''created'' end as action

		-- Return warnings if any exist
		if exists (select 1 from #errors where errorType = ''warning'')
		begin
			select errorType, errorCode, errorMessage, fieldName
			from #errors
			where errorType = ''warning''
			order by fieldName
		end

		-- Return the users who were assigned
		select	*
		from	#users

		drop table #users
		drop table #errors
		return 1
	end
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[sptInvoiceLineRollupTransactions]'
GO
IF OBJECT_ID(N'[dbo].[sptInvoiceLineRollupTransactions]', 'P') IS NULL
EXEC sp_executesql N'CREATE procedure [dbo].[sptInvoiceLineRollupTransactions] 
	(
	@InvoiceKey int
	)
as --Encrypt

/*
||When     Who Rel      What
||04/22/21 GHL 21.05.10 Created to fix discrepancies between underlying transactions and invoice lines 
||                      This can be used when users cannot do the posting to GL
||						NOTE:  This SP is not called from an code or other SPs.  It is used for troubleshooting and data cleanup
*/

declare @InvoiceLineKey int
declare @RecalcSalesTaxes int   
declare @RecalcLineSalesTaxes int 
declare @ValidateLine int
declare @TotalAmountBefore money
declare @TotalAmountAfter money
declare @DiscrepanciesFound int

select @RecalcSalesTaxes = 0     
select @RecalcLineSalesTaxes = 0
select @ValidateLine = 0
select @DiscrepanciesFound = 0

select @InvoiceLineKey = -1
while (1=1)
begin
	select @InvoiceLineKey = min(InvoiceLineKey)
	from  tInvoiceLine (nolock)
	where InvoiceKey = @InvoiceKey
	and   InvoiceLineKey > @InvoiceLineKey
	and   LineType = 2 -- detail
	and   BillFrom = 2 -- TM

	if @InvoiceLineKey is null
		break

	select @TotalAmountBefore = TotalAmount
	from   tInvoiceLine (nolock)
	where InvoiceLineKey = @InvoiceLineKey
	
	exec sptInvoiceLineUpdateTotals @InvoiceLineKey, @RecalcSalesTaxes, @RecalcLineSalesTaxes, @ValidateLine

	select @TotalAmountAfter = TotalAmount
	from   tInvoiceLine (nolock)
	where InvoiceLineKey = @InvoiceLineKey

	-- only recalc the taxes if necessary (i.e. if the total has changed)
	-- this will rollup to the header also
	if isnull(@TotalAmountBefore,0) <> isnull(@TotalAmountAfter,0)
	begin
		exec sptInvoiceRecalcLineAmounts @InvoiceKey, @InvoiceLineKey, 1
		select @DiscrepanciesFound = 1
	end
	  
end

-- now rollup to the projects
if @DiscrepanciesFound = 1
begin
	exec sptProjectRollupUpdateEntity ''tInvoice'', @InvoiceKey, 0, 0
end


return 1'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[sptMediaPlanDetailWorkerGetErrors]'
GO
IF OBJECT_ID(N'[dbo].[sptMediaPlanDetailWorkerGetErrors]', 'P') IS NULL
EXEC sp_executesql N'CREATE PROCEDURE [dbo].[sptMediaPlanDetailWorkerGetErrors]
	(
	@CompanyKey INT,
	@MediaPlanKey INT,
	@TimeStamp INT
	)
AS
--Encrypt

/*
|| When      Who  Rel			What
|| 07/08/26  MAS  26.07.19		(732561) Created.  Returns the per-line validation errors stamped on the worker table by
||								sptMediaPlanDetailUpdateAPIWorker so the API can report every bad line at once
||								when that proc returns -5 (keeps the media plan save atomic).
*/

	SELECT	mpw.SpotLinkID as spotLinkID
			,mpw.LineNumber as lineNumber
			,mpw.ItemID as itemID
			,mpw.VendorID as vendorID
			,mpw.StationID as stationID
			,LTRIM(RTRIM(mpw.ErrMsg)) as errMsg
	FROM	tMediaPlanDetailWorker mpw (NOLOCK)
	WHERE	mpw.CompanyKey = @CompanyKey
			AND mpw.MediaPlanKey = @MediaPlanKey
			AND mpw.[Timestamp] = @TimeStamp
			AND ISNULL(mpw.ErrMsg, '''') <> ''''
	ORDER BY mpw.LineNumber
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spConvertDB2101]'
GO
IF OBJECT_ID(N'[dbo].[spConvertDB2101]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER procedure  [dbo].[spConvertDB2101]
AS --Encrypt

--Add the customization for legacycalendarsync for companies that are using sync
CREATE TABLE #CalendarSyncCompanies (CompanyKey int null)

INSERT	#CalendarSyncCompanies
SELECT DISTINCT	c.CompanyKey
FROM	tCMFolder cm (nolock)
INNER JOIN tCompany c (nolock) ON cm.CompanyKey = c.CompanyKey
LEFT JOIN tUser u (nolock) ON cm.UserKey = u.UserKey and cm.Entity = ''tCalendar''
LEFT JOIN tUserPreference up (nolock) ON u.UserKey = up.UserKey
INNER JOIN tSyncFolder sf (nolock) on cm.GoogleSyncFolderKey = sf.SyncFolderKey
WHERE	ISNULL(u.Active, 1) = 1
AND		c.Active = 1
AND		ISNULL(c.Locked, 0) = 0
AND		(ISNULL(up.GoogleCalendarAuthToken, ISNULL(u.GoogleAuthToken, '''')) > '''' or ISNULL(sf.FolderID, '''') > '''')

INSERT	#CalendarSyncCompanies
SELECT	DISTINCT c.CompanyKey
FROM	tUser u (nolock)
INNER JOIN tCompany c (nolock) ON (u.CompanyKey = c.CompanyKey OR u.OwnerCompanyKey = c.CompanyKey)
INNER JOIN tUserPreference up (nolock) ON u.UserKey = up.UserKey
LEFT JOIN tCMFolder cm (nolock) ON u.UserKey = cm.UserKey AND cm.Entity = ''tCalendar'' 
WHERE	ISNULL(u.Active, 1) = 1
AND		c.Active = 1
AND		ISNULL(c.Locked, 0) = 0
AND		c.CompanyKey NOT IN (SELECT CompanyKey FROM #CalendarSyncCompanies)

UPDATE	tPreference
SET		Customizations =
			CASE
				WHEN ISNULL(Customizations, '''') <> '''' THEN ISNULL(Customizations, '''') + ''|legacycalendarsync''
				ELSE ''legacycalendarsync''
			END
WHERE	CompanyKey IN (SELECT CompanyKey FROM #CalendarSyncCompanies)
AND		Customizations NOT LIKE ''%legacycalendarsync%'' --So it only adds it once if this is run multiple times

--For 530937 - Set Pref where Lab currently in use
UPDATE tPreference
SET EnableInvoiceEstimateLayouts = 1
WHERE CompanyKey IN (
	SELECT CompanyKey
	FROM tLabCompany (nolock)
	WHERE LabKey IN (7, 106)
)


--for 538931

update tTransaction
set    tTransaction.Overhead = 1
from   tTransaction
	inner join tProject p (nolock) on tTransaction.ProjectKey = p.ProjectKey
where p.Opportunity = 1

return 1'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[vReport_OrderDetail]'
GO
IF OBJECT_ID(N'[dbo].[vReport_OrderDetail]', 'V') IS NOT NULL
EXEC sp_executesql N'






ALTER VIEW [dbo].[vReport_OrderDetail]
AS

/*
|| When     Who Rel		What
|| 07/20/18	MAS 18.8.0	(395210) Created. 
|| 03/13/23 RLB 23.04.16 (629165) Adding Office Color and department
|| 04/07/25 AMP 25.05.18 (697727) Added Media Plan ID and Media Plan Name
|| 12/01/25 RLS 26.01.18 (713662) Added [Materials Sent Date] and [Account Manager]
|| 01/15/25 RLB 26.02.15 (719253) Added Line Date which is a copy of Insertion Date for SQL scrubbing reasons
|| 01/16/25 RLB 26.02.15 (719243) Added Item Sales Account
|| 04/23/26 MCM 26.05.x  (725435) Added InteractiveAdUnitName as Ad Size
|| 06/30/26 MCM 26.07.x  (730399) updated name of InteractiveAdUnitName to be Ad Unit
*/

SELECT 
	 po.CompanyKey
	,po.GLCompanyKey
	,pod.CustomFieldKey
	,cl.CustomFieldKey as CustomFieldKey2
    ,po.PurchaseOrderNumber AS [Order Number]
    ,c.VendorID AS [Vendor ID]
    ,c.CompanyName AS [Vendor Name]
    ,c.VendorID + '' - '' + c.CompanyName AS [Vendor Full Name]
	,st.StationID as [Publication ID]
	,st.Name as [Publication Name]
	,st.StationID + '' - '' + st.Name as [Publication Full Name]
    ,po.Contact AS [Vendor Contact]
    ,po.Address1 AS [Address 1]
    ,po.Address2 AS [Address 2]
    ,po.Address3 AS [Address 3]
    ,po.City AS [Address City]
    ,po.State AS [Address State]
    ,po.PostalCode AS [Address Postal Code]
    ,po.Country AS [Address Country]
    ,po.DateCreated AS [Date Created]
    ,po.PODate AS [Order Date]
    ,po.OrderedBy AS [Ordered By]
    ,po.SpecialInstructions AS [Special Instructions]
    ,po.DeliveryInstructions AS [Traffic Instructions]
    ,po.Revision AS [Revision Number]
    ,po.ApprovedDate AS [Approved Date]
	,Case ISNULL(po.POKind, 0) 
		When 0 Then ''Purchase Order''
		When 1 Then ''Insertion Order''
		When 2 Then ''Broadcast Order''
	 End As [Order Type]
    ,Case When po.Closed = 1 then ''Closed'' else 
		case po.Status 
			when 1 then ''Not Sent For Approval''
			when 2 then ''Sent for Approval''
			when 3 then ''Rejected''
			when 4 then ''Open Approved'' end 
		end as [Status]
    ,case po.Closed when 1 then ''YES'' else ''NO'' end as [Closed]
    ,case po.Downloaded when 1 then ''YES'' else ''NO'' end as [Downloaded]
	,me.EstimateID as [Media Estimate ID]
	,me.EstimateName as [Media Estimate Name]
	,me.EstimateID + '' - '' + me.EstimateName as [Media Estimate Full Name]
    ,pod.LineNumber AS [Line Number]
    ,p.ProjectName AS [Project Name]
    ,p.ProjectNumber AS [Project Number]
    ,p.ProjectNumber + '' - '' + p.ProjectName AS [Project Full Name]
	,cp.CampaignName as [Campaign Name]
	,cp.CampaignID as [Campaign ID]
    ,t.TaskID AS [Task ID]
    ,t.TaskName AS [Task Name]
    ,t.TaskID + '' - '' + t.TaskName AS [Task Full Name]
    ,pod.ShortDescription AS [Caption]
    ,pod.LongDescription AS [Line Comments]
	,i.ItemID as [Item ID]
	,i.ItemName as [Item Name]
	,gla.AccountNumber + '' - '' + gla.AccountName as [Item Expense Account]
	,gla2.AccountNumber + '' - '' + gla2.AccountName as [Item Sales Account]
    ,pod.TotalCost AS [Net Amount]
	,ISNULL(pod.AccruedCost, 0) as [Line Accrued Cost]
	,pod.TotalCost - ISNULL(pod.AccruedCost, 0) as [Line Accrued Cost Difference]
	,pod.AdjustmentNumber as [Adjustment Number]
	,Case when pod.InvoiceLineKey > 0 then 0 else ISNULL(pod.AmountBilled, 0) - pod.BillableCost end as [Billed Difference]
    ,ISNULL((Select Sum(PrebillAmount) from tVoucherDetail (nolock) Where tVoucherDetail.PurchaseOrderDetailKey = pod.PurchaseOrderDetailKey), 0) as [Line Amount Unaccrued]
    ,ISNULL(pod.AccruedCost, 0) - ISNULL((Select Sum(PrebillAmount) from tVoucherDetail (nolock) Where tVoucherDetail.PurchaseOrderDetailKey = pod.PurchaseOrderDetailKey), 0) as [Line Amount Left To Unaccrue]
	,ISNULL(pod.AppliedCost, 0) AS [Applied Invoices]
	,ISNULL(pod.TotalCost, 0) - ISNULL(pod.AppliedCost, 0) AS [Open Amount]
	,case when pod.InvoiceLineKey > 0 then ISNULL(pod.AmountBilled, 0) else 0 end as [Amount Billed]
	,pod.DetailOrderDate as [Insertion Date]
	,pod.DetailOrderDate as [Line Date]
	,pod.Markup as [Markup Percent]
	,case when pod.InvoiceLineKey > 0 then ISNULL(pod.AmountBilled, 0) else 0 end 
	+ ISNULL((Select Sum(ISNULL(AmountBilled, 0)) from tVoucherDetail vd (nolock) Where pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey and vd.InvoiceLineKey > 0), 0) as [Total Billed]
	,case pod.Markup when 1 then ''YES'' else ''NO'' end as [Commission]
	,(Select Sum(ISNULL(AmountBilled, 0)) from tVoucherDetail vd (nolock) Where pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey and vd.InvoiceLineKey > 0) as [Amount Billed On Vendor Invoices]
    ,pod.BillableCost AS [Gross Amount]
	,pod.UserDate1 as [User Defined Date 1]
	,pod.UserDate2 as [User Defined Date 2]
	,pod.UserDate3 as [User Defined Date 3]
	,pod.UserDate4 as [User Defined Date 4]
	,pod.UserDate5 as [User Defined Date 5]
	,pod.UserDate6 as [User Defined Date 6]
	,pod.UserDate1 as [Space Close]
	,pod.UserDate2 as [Materials Due]
	,iv.InvoiceNumber as [Line Invoice Number]
	,iv.PostingDate as [Line Date Billed]
	,iv.InvoiceDate as [Invoice Date]
	,iv.InvoiceNumber as [Invoice Number]
	,iv.TotalNonTaxAmount as [Invoice Non Tax Total]
	,iv.SalesTaxAmount as [Invoice Sales Tax Total]
	,iv.InvoiceTotalAmount as [Invoice Total]
	,ISNULL(iv.InvoiceTotalAmount, 0) - ISNULL(iv.AmountReceived, 0) - ISNULL(iv.WriteoffAmount, 0) - ISNULL(iv.RetainerAmount, 0) as [Invoice Amount Open]
	,iv.HeaderComment as [Invoice Comment]

	,case pod.Closed when 1 then ''YES'' else ''NO'' end as [Line Closed]

	,CASE ISNULL(po.POKind, 0)
		WHEN 0 THEN cl.CompanyName
		WHEN 1 THEN
			CASE ISNULL(pref.IOClientLink, 1) -- 1 Project, 2 - Estimate
				WHEN 1 THEN cl.CompanyName
				ELSE cl2.CompanyName
			END  
		WHEN 2 THEN
			CASE ISNULL(pref.BCClientLink, 1)
				WHEN 1 THEN cl.CompanyName
				ELSE cl2.CompanyName
			END  			
	END as [Client Name]

    ,CASE ISNULL(po.POKind, 0)
		WHEN 0 THEN cl.CustomerID
		WHEN 1 THEN
			CASE ISNULL(pref.IOClientLink, 1) -- 1 Project, 2 - Estimate
				WHEN 1 THEN cl.CustomerID
				ELSE cl2.CustomerID
			END  
		WHEN 2 THEN
			CASE ISNULL(pref.BCClientLink, 1)
				WHEN 1 THEN cl.CustomerID
				ELSE cl2.CustomerID
			END  
	END as [Client ID]

	,CASE ISNULL(po.POKind, 0) -- UserFullName
			WHEN 0 THEN sales.UserFullName
		WHEN 1 THEN
			CASE ISNULL(pref.IOClientLink, 1) -- 1 Project, 2 - Estimate
				WHEN 1 THEN sales.UserFullName
				ELSE sales2.UserFullName
			END  
		WHEN 2 THEN
			CASE ISNULL(pref.BCClientLink, 1) 
				WHEN 1 THEN sales.UserFullName
				ELSE sales2.UserFullName
			END  
	END as [Sales Person]

	,mm.MarketID as [Market ID]
    ,mm.MarketName as [Market Name]
	,glc.GLCompanyID as [Company ID]
	,glc.GLCompanyName as [Company Name]
	,cla.ClassID as [Class ID]
	,cla.ClassName as [Class Name]
	,o.OfficeID as [Office ID]
	,o.OfficeName as [Office Name]
	,o.OfficeColor as [Office Color]
	,d.DepartmentName as Department
	,d.DepartmentColor as [Department Color]
	,Case When pod.TransferToKey IS NULL Then ''NO'' else ''YES'' end as [Transferred Out]
	,p.ProjectKey
	,po.[Description] as [Order Description]
	,po.CurrencyID as [Currency]
	,cd.DivisionID as [Client Division ID]
    ,cd.DivisionName as [Client Division]
    ,pc.ProductID as [Client Product ID]
    ,pc.ProductName as [Client Product]
	,mp2.PlanID  as [Media Plan ID]
	,mp2.PlanName as [Media Plan Name]
	,pod.MaterialsSentDate AS [Materials Sent Date]
	,pod.InteractiveAdUnitName AS [Ad Unit]
	,ISNULL(AMProj.UserFullName, AMClient.UserFullName) AS [Account Manager]
FROM 
	tPurchaseOrder po (nolock)
	INNER JOIN tPurchaseOrderDetail pod (nolock) ON po.PurchaseOrderKey = pod.PurchaseOrderKey
	INNER JOIN tPreference pref (nolock) ON po.CompanyKey = pref.CompanyKey
    INNER JOIN tCompany c (nolock) ON po.VendorKey = c.CompanyKey 
	LEFT OUTER JOIN tTask t (nolock) ON pod.TaskKey = t.TaskKey 
	LEFT OUTER JOIN tProject p (nolock) ON pod.ProjectKey = p.ProjectKey
	LEFT OUTER JOIN tCompany cl (nolock) on p.ClientKey = cl.CompanyKey
	LEFT OUTER JOIN tCompanyMedia st (nolock) on po.CompanyMediaKey = st.CompanyMediaKey
	LEFT OUTER JOIN tItem i (nolock) on pod.ItemKey = i.ItemKey
	Left OUTER JOIN tGLAccount gla (nolock) on i.ExpenseAccountKey = gla.GLAccountKey
	Left OUTER JOIN tGLAccount gla2 (nolock) on i.SalesAccountKey = gla2.GLAccountKey
	left outer join tMediaEstimate me (nolock) on po.MediaEstimateKey = me.MediaEstimateKey
	LEFT OUTER JOIN tCompany cl2 (nolock) on me.ClientKey = cl2.CompanyKey
	left outer join tCampaign cp (nolock) on p.CampaignKey = cp.CampaignKey
    left outer join tMediaMarket mm (nolock) on st.MediaMarketKey = mm.MediaMarketKey
	left outer join tClass cla (nolock) on pod.ClassKey = cla.ClassKey
	left outer join tGLCompany glc (nolock) on po.GLCompanyKey = glc.GLCompanyKey
	left outer join tOffice o (nolock) on pod.OfficeKey = o.OfficeKey
	left outer join tDepartment d (nolock) on pod.DepartmentKey = d.DepartmentKey
	left outer join tInvoiceLine il (nolock) on pod.InvoiceLineKey = il.InvoiceLineKey
	left outer join tInvoice iv (nolock) on il.InvoiceKey = iv.InvoiceKey
	left outer join tClientDivision cd (nolock) on p.ClientDivisionKey = cd.ClientDivisionKey
    left outer join tClientProduct  pc (nolock) on p.ClientProductKey  = pc.ClientProductKey
	left outer join vUserName sales (nolock) on cl.SalesPersonKey = sales.UserKey
	left outer join vUserName sales2 (nolock) on cl2.SalesPersonKey = sales2.UserKey
	left outer join 
				 (SELECT mp.PlanID, mp.PlanName, pod.PurchaseOrderKey
				  FROM
					  tPurchaseOrderDetail pod
					  INNER JOIN tMediaPlanDetail mpd (nolock) on mpd.PurchaseOrderDetailKey =  pod.PurchaseOrderDetailKey
					  INNER JOIN tMediaPlanVendor mpv (nolock) on mpd.MediaPlanVendorKey = mpv.MediaPlanVendorKey
				  	  INNER JOIN tMediaPlan mp (nolock) on mpv.MediaPlanKey = mp.MediaPlanKey						
				  GROUP BY mp.PlanID, mp.PlanName, pod.PurchaseOrderKey) AS mp2 on mp2.PurchaseOrderKey = pod.PurchaseOrderKey	  
left outer join vUserName AMProj (nolock) on p.AccountManager = AMProj.UserKey
left outer join vUserName AMClient (nolock) on cl.AccountManagerKey = AMClient.UserKey
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[spProjectLoadUserServices]'
GO
IF OBJECT_ID(N'[dbo].[spProjectLoadUserServices]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[spProjectLoadUserServices]
	@ProjectKey int,
	@ServiceKey int = NULL
AS --Encrypt

/*
|| When      Who Rel      What
|| 4/11/08   CRG 1.0.0.0  Created for use by the new ProjectManager
|| 11/05/12  MFT 10.562   Added tService join
|| 03/11/26  CRG 26.04.19 (721964) Added optional ServiceKey to filter on
*/

	SELECT
		us.*,
		s.ServiceCode,
		s.Description
	FROM
		tProjectUserServices us (nolock)
		INNER JOIN tService s (nolock) ON us.ServiceKey = s.ServiceKey
	WHERE	ProjectKey = @ProjectKey
	AND		(@ServiceKey IS NULL OR us.ServiceKey = @ServiceKey)'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptPurchaseOrderUpdate]'
GO
IF OBJECT_ID(N'[dbo].[sptPurchaseOrderUpdate]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptPurchaseOrderUpdate]
	@PurchaseOrderKey int,
	@POKind smallint,
	@PurchaseOrderTypeKey int = NULL,
	@CompanyKey int,
	@PurchaseOrderNumber varchar(30),
	@VendorKey int,
	@ProjectKey int,
	@TaskKey int,
	@ItemKey int,
	@ClassKey int,
	@Contact nvarchar(200),
	@PODate smalldatetime,
	@DueDate smalldatetime,
	@OrderedBy nvarchar(200),
	@Printed smallint,
	@PrintOption smallint,
	@Downloaded smallint,
	@CustomFieldKey int,
	@HeaderTextKey int,
	@FooterTextKey int,
	@ApprovedByKey int,
	@CreatedByKey int = NULL,
	@CompanyMediaKey int,
	@MediaEstimateKey int,
	@OrderDisplayMode smallint,
	@BillAt smallint,
	@SalesTaxKey int,
	@SalesTax2Key int,
	@FlightStartDate smalldatetime,
	@FlightEndDate smalldatetime,
	@FlightInterval tinyint,
	@PrintClientOnOrder tinyint,
	@PrintTraffic tinyint,
	@GLCompanyKey int,
	@CompanyAddressKey int,
	@SkipLineValidation tinyint = 0,
	@LastUpdateBy int = null,
	@Emailed tinyint = null,
	@MediaWorksheetKey int = null,
	@InternalID int = null,
	@MediaPrintSpaceKey int = null,
	@MediaPrintPositionKey int = null,
	@CompanyMediaPrintContractKey int = null,
	@MediaUnitTypeKey int = null,
	@CompanyMediaRateCardKey int = null,
	@MediaPrintSpaceID varchar(500) = null,
	@MediaMarketKey int = null,
	@MediaPrintPositionID varchar(500) = null,
	@CurrencyID varchar(10) = null,
	@ExchangeRate decimal(24,7) = 1,
	@PCurrencyID varchar(10) = null,
	@PExchangeRate decimal(24,7) = 1,
	@PlacementTag varchar(500) = null,
	@Description nvarchar(max) = null,
	@MediaAffiliateKey int = null,
	@MediaDayKey int = null,
	@MediaDayPartKey int = null,
	@MediaLen int = null,
	@BillingBase smallint = null,
	@BillingAdjPercent decimal(24, 4) = null,
	@BillingAdjBase smallint = null,
	@MediaCategoryKey int = null,
	@MediaWorksheetDemoKey int = null,
	@MaterialsSent tinyint = 0,
	@AllowDuplicatePONumber tinyint = 0

AS --Encrypt

/*
|| When     Who Rel      What
|| 04/13/07 BSH 8.4.5    DateUpdated needed to be updated.
|| 07/12/07 BSH 8.5      (9659)Update GLCompanyKey
|| 01/17/08 BSH 8.5      (18369)Validate that Project on line and header belong to same GLC
||							   and also the MediaEstimate for IOs and BCs.
|| 08/13/08 GHL 10.007   (32001) Calling now project rollup because changing things like BillAt
||                       affect the Open Order Gross on projects
|| 10/22/08 GHL 10.5     (37963) Added CompanyAddressKey param
|| 11/25/09 MFT 10.514	 Added insert logic
|| 10/14/10 MFT 10.536   Added @SkipLineValidation parameter to support document level saves
|| 11/0/11  RLB 10.500   (121862) Added for enhancement
|| 07/19/12 GHL 10.558   Added validation of GLCompany on media estimates 
|| 12/13/12 WDF 10.563   (162210) Added LastUpdateBy
|| 02/28/13 GHL 10.565   (167188) Prevent from changing BillAt if lines are prebilled or applied
|| 08/08/13 CRG 10.5.7.0 Added optional Emailed parameter
|| 08/30/13 CRG 10.5.7.1 Modified insert logic to handle a negative PurchaseOrderKey value passed in
|| 08/30/13 CRG 10.5.7.1 Added @MediaWorksheetKey and @InternalID
|| 09/05/13 CRG 10.5.7.2 Added @MediaPrintSpaceKey, @MediaPrintPositionKey, @CompanyMediaPrintContractKey, @MediaUnitTypeKey, @CompanyMediaRateCardKey
|| 09/16/13 CRG 10.5.7.2 Added @MediaPrintSpaceID
|| 09/30/13 CRG 10.5.7.3 Added @MediaMarketKey
|| 10/01/13 CRG 10.5.7.3 Now we''re not setting the PurchaseOrderNumber on the insert if it''s coming from the new Media Worksheet screen.
||                       We''ll set the PurchaseOrderNumber upon approval
|| 11/25/13 CRG 10.5.7.4 Added logic to make sure that the MediaPrintSpaceKey is set to NULL if free form text is passed in
|| 12/09/13 CRG 10.5.7.5 Added @MediaPrintPositionID
|| 12/16/13 GHL 10.5.7.5 Added currency info
|| 12/17/13 CRG 10.5.7.5 Added @PlacementTag
|| 01/17/14 GHL 10.5.7.6 (197214) Added @Description for enhancement + made @LastUpdateBy optional
|| 02/14/14 CRG 10.5.7.7 Added @MediaAffiliateKey, @MediaDayKey, @MediaDayPartKey, @MediaLen
|| 03/14/14 CRG 10.5.7.8 Added @BillingBase, @BillingAdjPercent, @BillingAdjBase
|| 03/28/14 CRG 10.5.7.8 Added @MediaCategoryKey
|| 04/09/14 CRG 10.5.7.9 Added @MediaWorksheetDemoKey
|| 04/16/14 GHL 10.5.7.9 Modified section that restore null values from old ones because we cannot blank on screen (Added If statement)
|| 05/02/14 GHL 10.5.7.9 Added setting of po.ShowAdjustmentsAsSingleLine
|| 05/07/14 GHL 10.5.7.9 Added check of InternalID when using media worksheets
|| 05/08/14 RLB 10.5.7.9 (215598) since fields are locked down in PO allow update to a closed PO
|| 05/14/14 MFT 10.5.7.9 Added tMediaOrder join to duplicate PurchaseOrderNumber check (RETURN -4)
|| 07/28/14 MFT 10.5.8.1 Added ISNULL to MediaOrderKey comparison
|| 08/26/14 GHL 10.5.8.3 Only delete tPurchaseOrderDetailTax records if some exist because this changes POD.SalesTax1Amount and POD.SalesTax2Amount
||                       and this is a problem when trying to create adjustments for the new media screens
|| 05/20/16 PLC 10.6.0.4 Issue 264033 - made it so a voucher row will only stop an update for project
||                         and CompanyMediaKey
|| 06/07/17 GHL 10.616  (348690) Make @CustomFieldKey and @PurchaseOrderTypeKey as 0 if null
||                       that is the way it was done in quote_detail.aspx
|| 08/09/17 GHL 10.619  Added recalc of user dates when company media key is changed
|| 05/10/18 MCM 18.600  (400706) Adding check to make sure VendorKey > 0 (if not, retun -11)
|| 07/24/18 GHL 18.800  DEV1787 todo 4554 Add the Primary contact from the vendor and the company media to the Notify list (BO/IO) 
|| 09/20/19 AMP 19.1.0.0 (477552) Update for Materials Sent, and Materials Sent Date on the PO lines
|| 03/22/21 RLS 21.0.4.0 (546075) Changed @OrderedBy to nvarchar
|| 03/22/21 RLS 21.0.4.0 (546075) Changed @Contact to nvarchar
|| 04/06/21 RLS 21.0.5.0 (550747) Changed @Description to nvarchar
|| 01/28/22 GHL 22.0.2.0 (586145) Added error -11 (there were 2 errors -10)
|| 06/21/23 MAS 23.07.16 Removed old media references, tMediaOrder
|| 05/27/26 AMP 26.07.19 (725241) Added @AllowDuplicatePONumber to check and give users a warning when saving a duplicate PO number
*/

DECLARE @Address1 varchar(100)
DECLARE @Address2 varchar(100)
DECLARE @Address3 varchar(100)
DECLARE @City varchar(100)
DECLARE @State varchar(50)
DECLARE @PostalCode varchar(20)
DECLARE @Country varchar(50)
DECLARE @TranType varchar(2)
DECLARE @RetVal	int
DECLARE @NextTranNo varchar(100)
DECLARE @UseClientCosting tinyint
DECLARE @BCUseClientCosting tinyint
DECLARE @IOUseClientCosting tinyint
DECLARE @BCShowAdjustmentsAsSingleLine tinyint
DECLARE @IOShowAdjustmentsAsSingleLine tinyint
	
DECLARE @CurrentStatus smallint
DECLARE @Revision int
DECLARE @ApprovedDate smalldatetime
DECLARE @ExistingCompanyMediaKey int
DECLARE @MultiCurrency int 
DECLARE @PrimaryContact int

DECLARE @Today smalldatetime
SELECT  @Today = getdate()
SELECT  @Today = dbo.fFormatDateNoTime(@Today)

IF @MediaPrintSpaceKey > 0
	SELECT	@MediaPrintSpaceID = NULL
	
IF @MediaPrintPositionKey > 0
	SELECT	@MediaPrintPositionID = NULL

SELECT @BCUseClientCosting = ISNULL(BCUseClientCosting, 0),
			@IOUseClientCosting = ISNULL(IOUseClientCosting, 0),
			@MultiCurrency = ISNULL(MultiCurrency, 0),
			@BCShowAdjustmentsAsSingleLine = isnull(BCShowAdjustmentsAsSingleLine, 1),
			@IOShowAdjustmentsAsSingleLine = isnull(IOShowAdjustmentsAsSingleLine, 1)
		FROM tPreference (NOLOCK) 
		WHERE CompanyKey = @CompanyKey
		
-- this is to be consistent with quotes, keep 0 instead of nulls
select @CustomFieldKey = isnull(@CustomFieldKey, 0)
select @PurchaseOrderTypeKey = isnull(@PurchaseOrderTypeKey, 0)

if @MultiCurrency = 0
begin
	select @CurrencyID = null 
		  ,@ExchangeRate = 1
		  ,@PCurrencyID = null 
		  ,@PExchangeRate = 1
end
else 
begin
	if isnull(@ExchangeRate, 0) <=0
		select @ExchangeRate = 1 -- no division by 0 allowed

	if isnull(@CurrencyID, '''') = ''''
		select @CurrencyID = null -- no empty string
			  ,@ExchangeRate = 1

	if isnull(@PExchangeRate, 0) <=0
		select @PExchangeRate = 1

	if isnull(@PCurrencyID, '''') = ''''
		select @PCurrencyID = null -- no empty string
			  ,@PExchangeRate = 1
end

IF ISNULL(@PurchaseOrderKey, 0) <= 0
	BEGIN --INSERT LOGIC
		IF @VendorKey = 0
			RETURN -11  --Adding check to make sure the vendor key exists

		--Make sure MediaEstimate and IO/BC belong to same company. 
		IF (@POKind = 1 OR @POKind = 2) AND @MediaEstimateKey IS NOT NULL
			IF EXISTS(SELECT 1
				FROM  tMediaEstimate (nolock) 
				WHERE MediaEstimateKey = @MediaEstimateKey
				AND   ISNULL(GLCompanyKey, 0) <> ISNULL(@GLCompanyKey, 0))
			RETURN -7

		IF @AllowDuplicatePONumber = 0
			IF EXISTS(SELECT 1 FROM tPurchaseOrder (NOLOCK) WHERE CompanyKey = @CompanyKey AND POKind = @POKind AND PurchaseOrderNumber = @PurchaseOrderNumber)
				RETURN -8
		
		IF ISNULL(@ProjectKey, 0) > 0
			IF NOT EXISTS(SELECT 1 FROM tProject p (nolock) INNER JOIN tProjectStatus ps (nolock) ON p.ProjectStatusKey = ps.ProjectStatusKey
					WHERE p.ProjectKey = @ProjectKey AND ps.ExpenseActive = 1)
				RETURN -9
		
		-- if we have a media worksheet, the internal ID should be unique
		-- in VB do not trap the error, at this time, I want it to fail silently
		-- this is a patch for the copy function of the new media screen (if you select 2 dates to copy, it will create duplicates with same ID)
		if @MediaWorksheetKey > 0 
		begin
			if exists (select 1 from tPurchaseOrder (nolock) where MediaWorksheetKey = @MediaWorksheetKey and InternalID = @InternalID)
				return -10
		end

		-- Get the next number
		IF @POKind = 0
			BEGIN
				SELECT @UseClientCosting = 0
				SELECT @TranType = ''PO''
			END
		IF @POKind = 1
			BEGIN
				SELECT @UseClientCosting = @IOUseClientCosting
				SELECT @TranType = ''IO''
			END
		IF @POKind = 2
			BEGIN
				SELECT @UseClientCosting = @BCUseClientCosting
				SELECT @TranType = ''BC''
			END
		IF ISNULL(@MediaWorksheetKey, 0) = 0
		BEGIN
			IF @PurchaseOrderNumber IS NULL OR @PurchaseOrderNumber = ''''
				BEGIN
					EXEC spGetNextTranNo
						@CompanyKey,
						@TranType,		-- TranType
						@RetVal		      OUTPUT,
						@NextTranNo 		OUTPUT
					
					IF @RetVal <> 1
						RETURN -8
				END
			ELSE
				SELECT @NextTranNo = @PurchaseOrderNumber
		END
		
		IF @CompanyMediaKey is null
			SELECT 
				@Address1 = CASE WHEN ap.AddressKey IS NULL THEN ad.Address1 ELSE ap.Address1 END ,
				@Address2 = CASE WHEN ap.AddressKey IS NULL THEN ad.Address2 ELSE ap.Address2 END ,
				@Address3 = CASE WHEN ap.AddressKey IS NULL THEN ad.Address3 ELSE ap.Address3 END ,
				@City = CASE WHEN ap.AddressKey IS NULL THEN ad.City ELSE ap.City END ,
				@State = CASE WHEN ap.AddressKey IS NULL THEN ad.State ELSE ap.State END , 
				@PostalCode = CASE WHEN ap.AddressKey IS NULL THEN ad.PostalCode ELSE ap.PostalCode END ,
				@Country = CASE WHEN ap.AddressKey IS NULL THEN ad.Country ELSE ap.Country END 
			FROM
				tCompany c (NOLOCK)
				LEFT OUTER JOIN tAddress ad (nolock) ON c.DefaultAddressKey = ad.AddressKey 
				LEFT OUTER JOIN tAddress ap (nolock) ON c.PaymentAddressKey = ap.AddressKey 
			WHERE
				c.CompanyKey = @VendorKey
		ELSE
			SELECT
				@Address1 = Address1,
				@Address2 = Address2,
				@Address3 = Address3,
				@City = City,
				@State = State, 
				@PostalCode = PostalCode,
				@Country = Country
			FROM
				tCompanyMedia (NOLOCK) 
			WHERE
				CompanyMediaKey = @CompanyMediaKey
		
		INSERT tPurchaseOrder
		(
			CompanyKey,
			POKind,
			PurchaseOrderTypeKey,
			PurchaseOrderNumber,
			VendorKey,
			ProjectKey,
			TaskKey,
			ItemKey,
			ClassKey,
			Contact,
			PODate,
			DueDate,
			OrderedBy,
			Revision,
			ApprovedByKey,
			Closed,
			DateCreated,
			DateUpdated,
			ApprovedDate,
			Address1,
			Address2,
			Address3,
			City,
			State,
			PostalCode,
			Country,
			Status,
			CustomFieldKey,
			HeaderTextKey,
			FooterTextKey,
			CreatedByKey,
			CompanyMediaKey,
			MediaEstimateKey,
			OrderDisplayMode,
			BillAt,
			SalesTaxKey,
			SalesTax2Key,	
			FlightStartDate,
			FlightEndDate,
			FlightInterval,
			PrintTraffic,
			GLCompanyKey,
			CompanyAddressKey,
			UseClientCosting,
			PrintOption,
			Emailed,
			MediaWorksheetKey,
			InternalID,
			MediaPrintSpaceKey,
			MediaPrintPositionKey,
			CompanyMediaPrintContractKey,
			MediaUnitTypeKey,
			CompanyMediaRateCardKey,
			MediaPrintSpaceID,
			MediaMarketKey,
			MediaPrintPositionID,
			CurrencyID, 
		    ExchangeRate,
		    PCurrencyID,  
		    PExchangeRate,
		    PlacementTag,
			Description,
			MediaAffiliateKey,
			MediaDayKey,
			MediaDayPartKey,
			MediaLen,
			BillingBase,
			BillingAdjPercent,
			BillingAdjBase,
			MediaCategoryKey,
			MediaWorksheetDemoKey,
			ShowAdjustmentsAsSingleLine
		)
		VALUES
		(
			@CompanyKey,
			@POKind,
			@PurchaseOrderTypeKey,
			RTRIM(LTRIM(@NextTranNo)), -- @PurchaseOrderNumber,
			@VendorKey,
			@ProjectKey,
			@TaskKey,
			@ItemKey,
			@ClassKey,
			@Contact,
			@PODate,
			@DueDate,
			@OrderedBy,
			0,
			@ApprovedByKey,
			0,
			CAST( CAST(MONTH(GETDATE()) as varchar) + ''/'' + CAST(DAY(GETDATE()) as varchar) + ''/'' + CAST(YEAR(GETDATE()) as varchar) as smalldatetime),
			CAST( CAST(MONTH(GETDATE()) as varchar) + ''/'' + CAST(DAY(GETDATE()) as varchar) + ''/'' + CAST(YEAR(GETDATE()) as varchar) as smalldatetime),
			NULL,
			@Address1,
			@Address2,
			@Address3,
			@City,
			@State,
			@PostalCode,
			@Country,
			1,
			@CustomFieldKey,
			@HeaderTextKey,
			@FooterTextKey,
			@CreatedByKey,
			@CompanyMediaKey,
			@MediaEstimateKey,
			@OrderDisplayMode,
			@BillAt,
			@SalesTaxKey,
			@SalesTax2Key,			
			@FlightStartDate,
			@FlightEndDate,
			@FlightInterval,
			@PrintTraffic,
			@GLCompanyKey,
			@CompanyAddressKey,
			@UseClientCosting,
			@PrintOption,
			@Emailed,
			@MediaWorksheetKey,
			@InternalID,
			@MediaPrintSpaceKey,
			@MediaPrintPositionKey,
			@CompanyMediaPrintContractKey,
			@MediaUnitTypeKey,
			@CompanyMediaRateCardKey,
			@MediaPrintSpaceID,
			@MediaMarketKey,
			@MediaPrintPositionID,
			@CurrencyID, 
		    @ExchangeRate,
		    @PCurrencyID,  
		    @PExchangeRate,
		    @PlacementTag,
			@Description,
			@MediaAffiliateKey,
			@MediaDayKey,
			@MediaDayPartKey,
			@MediaLen,
			@BillingBase,
			@BillingAdjPercent,
			@BillingAdjBase,
			@MediaCategoryKey,
			@MediaWorksheetDemoKey,
			case @POKind 
				when 1 then @IOShowAdjustmentsAsSingleLine
				when 2 then @BCShowAdjustmentsAsSingleLine
				else 1
			end
		)
		
		SELECT @PurchaseOrderKey = @@IDENTITY
		
		-- if it is an IO or BC and we have media, insert default order contacts from media default contacts if no contact specified
		-- DEV1787 todo 4554 add the Primary contact from the vendor and the company media 
		IF (@POKind = 1 or @POKind = 2) 
			EXEC sptPurchaseOrderUserDefault @PurchaseOrderKey, @CompanyMediaKey
		
		RETURN @PurchaseOrderKey
	END --INSERT LOGIC

--UPDATE LOGIC
IF @SkipLineValidation = 0 AND EXISTS(SELECT 1
		FROM tVoucherDetail vd (nolock), tPurchaseOrderDetail pod (nolock), tPurchaseOrder po (nolock)
		WHERE po.PurchaseOrderKey = @PurchaseOrderKey 
		AND po.PurchaseOrderKey = pod.PurchaseOrderKey 
		AND pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey
		and (po.ProjectKey <> @ProjectKey or po.CompanyMediaKey <> @CompanyMediaKey) -- issue 264033
		)
	RETURN -1
/*IF EXISTS (SELECT 1
		FROM tPurchaseOrder po (nolock)
		WHERE po.PurchaseOrderKey = @PurchaseOrderKey AND po.Closed = 1)
	RETURN -2 
IF ISNULL(@ProjectKey, 0) > 0
	IF NOT EXISTS(SELECT 1 from tProject p (nolock) INNER JOIN tProjectStatus ps (nolock) ON p.ProjectStatusKey = ps.ProjectStatusKey
			WHERE p.ProjectKey = @ProjectKey and ps.ExpenseActive = 1)
		RETURN -3*/
IF @SkipLineValidation = 0 AND EXISTS(SELECT 1
		FROM tPurchaseOrderDetail pod (nolock) INNER JOIN tProject p ON pod.ProjectKey = p.ProjectKey
		WHERE pod.PurchaseOrderKey = @PurchaseOrderKey AND ISNULL(p.GLCompanyKey, 0) <> ISNULL(@GLCompanyKey, 0))
	RETURN -6
IF @SkipLineValidation = 0 AND @POKind = 2 --check broadcast order details to make sure they are within flight dates
	IF EXISTS(SELECT 1
			FROM tPurchaseOrderDetail (nolock)
			WHERE PurchaseOrderKey = @PurchaseOrderKey AND (DetailOrderDate < @FlightStartDate	OR DetailOrderEndDate > @FlightEndDate))
		RETURN -5
--Make sure MediaEstimate and IO/BC belong to same company. 
IF (@POKind = 1 OR @POKind = 2) AND @MediaEstimateKey IS NOT NULL
	IF EXISTS(SELECT 1
			FROM tPurchaseOrder po (nolock) INNER JOIN tMediaEstimate me ON po.MediaEstimateKey = me.MediaEstimateKey
			WHERE po.PurchaseOrderKey = @PurchaseOrderKey AND ISNULL(me.GLCompanyKey, 0) <> ISNULL(@GLCompanyKey, 0))
		RETURN -7

DECLARE @OldSalesTaxKey INT,
		@OldSalesTax2Key INT,
		@OldBillAt INT,
		@OldMediaWorksheetKey INT,
		@OldInternalID INT,
		@OldMediaPrintSpaceKey INT,
		@OldMediaPrintPositionKey INT,
		@OldCompanyMediaPrintContractKey INT,
		@OldMediaUnitTypeKey INT,
		@OldCompanyMediaRateCardKey INT,
		@OldMediaPrintSpaceID varchar(500),
		@OldMediaMarketKey INT,
		@OldMediaPrintPositionID varchar(500),
		@OldPlacementTag varchar(500),
		@OldMediaAffiliateKey int,
		@OldMediaDayKey int,
		@OldMediaDayPartKey int,
		@OldMediaLen int,
		@OldBillingBase smallint,
		@OldBillingAdjPercent decimal(24, 4),
		@OldBillingAdjBase smallint,
		@OldMediaCategoryKey int,
		@OldMediaWorksheetDemoKey int,
		@OldCompanyMediaKey int,
		@OldMaterialsSent int

SELECT @ExistingCompanyMediaKey = ISNULL(CompanyMediaKey,0)
      ,@OldSalesTaxKey = ISNULL(SalesTaxKey, 0)
      ,@OldSalesTax2Key = ISNULL(SalesTax2Key, 0)
	  ,@OldBillAt = ISNULL(BillAt, 0)
	  ,@OldMediaWorksheetKey = MediaWorksheetKey
	  ,@OldInternalID = InternalID
	  ,@OldMediaPrintSpaceKey = MediaPrintSpaceKey
	  ,@OldMediaPrintPositionKey = MediaPrintPositionKey
	  ,@OldCompanyMediaPrintContractKey = CompanyMediaPrintContractKey
	  ,@OldMediaUnitTypeKey = MediaUnitTypeKey
	  ,@OldCompanyMediaRateCardKey = CompanyMediaRateCardKey
	  ,@OldMediaPrintSpaceID = MediaPrintSpaceID
	  ,@OldMediaMarketKey = MediaMarketKey
	  ,@OldMediaPrintPositionID = MediaPrintPositionID
	  ,@OldPlacementTag = PlacementTag
	  ,@OldMediaAffiliateKey = MediaAffiliateKey
	  ,@OldMediaDayKey = MediaDayKey
	  ,@OldMediaDayPartKey = MediaDayPartKey
	  ,@OldMediaLen = MediaLen
	  ,@OldBillingBase = BillingBase
	  ,@OldBillingAdjPercent = BillingAdjPercent
	  ,@OldBillingAdjBase = BillingAdjBase
	  ,@OldMediaCategoryKey = MediaCategoryKey
	  ,@OldMediaWorksheetDemoKey = MediaWorksheetDemoKey
	  ,@OldCompanyMediaKey = CompanyMediaKey
	  ,@OldMaterialsSent = MaterialsSent
FROM tPurchaseOrder (nolock)
WHERE PurchaseOrderKey = @PurchaseOrderKey

-- If the Prebill At changes, check if some PODs have been prebilled or applied
IF @OldBillAt <> @BillAt
BEGIN
	IF EXISTS (SELECT 1 FROM tPurchaseOrderDetail (NOLOCK) WHERE PurchaseOrderKey = @PurchaseOrderKey
		AND InvoiceLineKey > 0)
		RETURN -11

	IF EXISTS (SELECT 1 FROM tPurchaseOrderDetail pod (NOLOCK) 
		INNER JOIN tVoucherDetail vd (NOLOCK) ON pod.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey 
		WHERE pod.PurchaseOrderKey = @PurchaseOrderKey)
		RETURN -11
END

IF @Emailed IS NULL
	SELECT	@Emailed = Emailed
	FROM	tPurchaseOrder (nolock)
	WHERE	PurchaseOrderKey = @PurchaseOrderKey

/* Code segment added in case a order under a worksheet is updated from another source */

IF ISNULL(@MediaWorksheetKey, 0) = 0 AND ISNULL(@OldMediaWorksheetKey, 0) > 0
BEGIN
	SELECT @MediaWorksheetKey = @OldMediaWorksheetKey
	IF @InternalID IS NULL SELECT @InternalID = @OldInternalID
	IF @MediaPrintSpaceKey IS NULL AND @MediaPrintSpaceID IS NULL SELECT @MediaPrintSpaceKey = @OldMediaPrintSpaceKey
	IF @MediaPrintPositionKey IS NULL AND @MediaPrintPositionID IS NULL SELECT @MediaPrintPositionKey = @OldMediaPrintPositionKey
	IF @CompanyMediaPrintContractKey IS NULL SELECT @CompanyMediaPrintContractKey = @OldCompanyMediaPrintContractKey
	IF @MediaUnitTypeKey IS NULL SELECT @MediaUnitTypeKey = @OldMediaUnitTypeKey
	IF @CompanyMediaRateCardKey IS NULL SELECT @CompanyMediaRateCardKey = @OldCompanyMediaRateCardKey
	IF @MediaPrintSpaceID IS NULL SELECT @MediaPrintSpaceID = @OldMediaPrintSpaceID
	IF @MediaMarketKey IS NULL SELECT @MediaMarketKey = @OldMediaMarketKey
	IF @MediaPrintPositionID IS NULL SELECT @MediaPrintPositionID = @OldMediaPrintPositionID
	IF @PlacementTag IS NULL SELECT @PlacementTag = @OldPlacementTag
	IF @MediaAffiliateKey IS NULL SELECT @MediaAffiliateKey = @OldMediaAffiliateKey
	IF @MediaDayKey IS NULL SELECT @MediaDayKey = @OldMediaDayKey
	IF @MediaDayPartKey IS NULL SELECT @MediaDayPartKey = @OldMediaDayPartKey
	IF @MediaLen IS NULL SELECT @MediaLen = @OldMediaLen
	IF @BillingBase IS NULL SELECT @BillingBase = @OldBillingBase
	IF @BillingAdjPercent IS NULL SELECT @BillingAdjPercent = @OldBillingAdjPercent
	IF @BillingAdjBase IS NULL SELECT @BillingAdjBase = @OldBillingAdjBase
	IF @MediaCategoryKey IS NULL SELECT @MediaCategoryKey = @OldMediaCategoryKey
	IF @MediaWorksheetDemoKey IS NULL SELECT @MediaWorksheetDemoKey = @OldMediaWorksheetDemoKey
END


UPDATE
	tPurchaseOrder
SET
	CompanyKey = @CompanyKey,
	PurchaseOrderNumber = @PurchaseOrderNumber,
	VendorKey = @VendorKey,
	ProjectKey = @ProjectKey,
	TaskKey = @TaskKey,
	ItemKey = @ItemKey,
	ClassKey = @ClassKey,
	Contact = @Contact,
	PODate = @PODate,
	DueDate = @DueDate,
	OrderedBy = @OrderedBy,
	Printed = @Printed,
	PrintOption = @PrintOption,
	Downloaded = @Downloaded,
	CustomFieldKey = @CustomFieldKey,
	HeaderTextKey = @HeaderTextKey,
	FooterTextKey = @FooterTextKey,
	ApprovedByKey = @ApprovedByKey,
	CompanyMediaKey = @CompanyMediaKey,
	MediaEstimateKey = @MediaEstimateKey,
	OrderDisplayMode = @OrderDisplayMode,
	BillAt = @BillAt,
	SalesTaxKey = @SalesTaxKey,
	SalesTax2Key = @SalesTax2Key,
	FlightStartDate = @FlightStartDate,
	FlightEndDate = @FlightEndDate,
	FlightInterval = @FlightInterval,
	PrintClientOnOrder = @PrintClientOnOrder,
	PrintTraffic = @PrintTraffic,
	GLCompanyKey = @GLCompanyKey,
	CompanyAddressKey = @CompanyAddressKey,
	DateUpdated = CAST(CAST(MONTH(GETDATE()) AS varchar) + ''/'' + CAST(DAY(GETDATE()) AS varchar) + ''/'' + CAST(YEAR(GETDATE()) AS varchar) AS smalldatetime),
	LastUpdateBy = @LastUpdateBy,
	Emailed = @Emailed,
	MediaWorksheetKey = @MediaWorksheetKey,
	InternalID = @InternalID,
	MediaPrintSpaceKey = @MediaPrintSpaceKey,
	MediaPrintPositionKey = @MediaPrintPositionKey,
	CompanyMediaPrintContractKey = @CompanyMediaPrintContractKey,
	MediaUnitTypeKey = @MediaUnitTypeKey,
	CompanyMediaRateCardKey = @CompanyMediaRateCardKey,
	MediaPrintSpaceID = @MediaPrintSpaceID,
	MediaMarketKey = @MediaMarketKey,
	MediaPrintPositionID = @MediaPrintPositionID,
	CurrencyID = @CurrencyID,
	ExchangeRate = @ExchangeRate,
	PCurrencyID = @PCurrencyID,
	PExchangeRate = @PExchangeRate,
	PlacementTag = @PlacementTag,
	Description = @Description,
	MediaAffiliateKey = @MediaAffiliateKey,
	MediaDayKey = @MediaDayKey,
	MediaDayPartKey = @MediaDayPartKey,
	MediaLen = @MediaLen,
	BillingBase = @BillingBase,
	BillingAdjPercent = @BillingAdjPercent,
	BillingAdjBase = @BillingAdjBase,
	MediaCategoryKey = @MediaCategoryKey,
	MediaWorksheetDemoKey = @MediaWorksheetDemoKey,
	MaterialsSent = @MaterialsSent
WHERE
	PurchaseOrderKey = @PurchaseOrderKey 

-- if it is an IO or BC and we have media, insert default order contacts from media default contacts
IF (@POKind = 1 OR @POKind = 2) AND isnull(@CompanyMediaKey,0) <> isnull(@ExistingCompanyMediaKey,0)
	EXEC sptPurchaseOrderUserDefault @PurchaseOrderKey, @CompanyMediaKey

/* Taxes should be handled in the PO line UI 
So only recalc if they change sales taxes
*/

IF ISNULL(@OldSalesTaxKey, 0) <> ISNULL(@SalesTaxKey, 0) OR ISNULL(@OldSalesTax2Key, 0) <> ISNULL(@SalesTax2Key, 0)
BEGIN
	-- Do this only if we have tPurchaseOrderDetailTax records, because this changes POD.SalesTax1Amount and POD.SalesTax2Amount
	-- and this is a problem when trying to create adjustments for the new media screens

	if exists (select 1 from tPurchaseOrderDetailTax podt (nolock)
				inner join tPurchaseOrderDetail pod (nolock) on podt.PurchaseOrderDetailKey = pod.PurchaseOrderDetailKey
				where pod.PurchaseOrderKey = @PurchaseOrderKey)
	begin 
		DELETE tPurchaseOrderDetailTax
		FROM tPurchaseOrderDetail vd (NOLOCK) 
		WHERE vd.PurchaseOrderKey = @PurchaseOrderKey
		AND   tPurchaseOrderDetailTax.PurchaseOrderDetailKey = vd.PurchaseOrderDetailKey
		AND   tPurchaseOrderDetailTax.SalesTaxKey IN (@SalesTaxKey, @SalesTax2Key)
	
		-- this will do the rollup also	
		EXEC sptPurchaseOrderRecalcAmounts @PurchaseOrderKey
	end 
	else
	begin
		EXEC sptPurchaseOrderRollupAmounts @PurchaseOrderKey
	end
END
ELSE
BEGIN
	EXEC sptPurchaseOrderRollupAmounts @PurchaseOrderKey
END

if isnull(@OldCompanyMediaKey, 0) <> isnull(@CompanyMediaKey, 0) 
BEGIN
	-- for calculations of dates from tCompanyMedia
	declare @Date1Days int
	declare @Date2Days int

	if isnull(@CompanyMediaKey, 0) > 0
	begin
		select @Date1Days =  isnull(Date1Days, 0), @Date2Days =  isnull(Date2Days, 0)
		from tCompanyMedia (nolock)
		where CompanyMediaKey = @CompanyMediaKey

		update tPurchaseOrderDetail
		set    UserDate1 = DateAdd(day, isnull(@Date1Days, 0), DetailOrderDate)
		      ,UserDate2 = DateAdd(day, isnull(@Date2Days, 0), DetailOrderDate)
		where PurchaseOrderKey = @PurchaseOrderKey
	end	

END

--Only update the detail here when the Materials Sent has changed on the header
--If header is marked as ''Materials Sent'', update any detail rows not already marked to sent, as ''Materials Sent'' with Today''s date
IF isnull(@OldMaterialsSent, 0) <> isnull(@MaterialsSent, 0) 
BEGIN
	IF (@MaterialsSent = 1)
   	BEGIN
		update tPurchaseOrderDetail
			set MaterialsSentDate = @Today,
				MaterialsSent = 1
			where PurchaseOrderKey = @PurchaseOrderKey
			and isnull(MaterialsSent, 0) != 1
	END
--If header is marked as ''Materials Not Sent'', update all detail rows to ''Materials Not Sent''
	IF (@MaterialsSent = 0)
   	BEGIN
		update tPurchaseOrderDetail
		set MaterialsSentDate = NULL,
		MaterialsSent = 0
		where PurchaseOrderKey = @PurchaseOrderKey
 	END
END

EXEC sptProjectRollupUpdateEntity ''tPurchaseOrder'', @PurchaseOrderKey, 0

RETURN @PurchaseOrderKey
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptUserGetByFullName]'
GO
IF OBJECT_ID(N'[dbo].[sptUserGetByFullName]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptUserGetByFullName]
	@CompanyKey int,
	@FullName nvarchar(100)
		
AS --Encrypt

/*
|| When     Who Rel      What
|| 04/29/09 MAS 10.5.0.0 Created
|| 09/29/09 MFT 10.5.1.1 Added OwnerCompanyKey to conditions
|| 09/30/09 MFT 10.5.1.1 Added condition to check for email compare first
|| 10/21/09 MFT 10.5.1.2 Added LTRIM/RTRIM to full name matching
|| 05/18/11 MAS 10.5.4.4 Try and match user on SystemID
|| 10/01/18 MCM 18.9.2.0 (423001) Adding matching on the user ID
|| 07/28/20 MCM 20.0.8.0 (523171) Updated where clause on user ID to make sure matches companyKey or owner companyKey
|| 02/26/24 MCM 24.03.17 (664040) Made userID parameter a nvarchar
|| 07/13/26 MFT 26.08.00 (732660) Privilege active users over inactive
*/

IF EXISTS(
	SELECT 1
	FROM tUser (nolock)
	WHERE
		UPPER(LTRIM(RTRIM(Email))) = UPPER(LTRIM(RTRIM(@FullName))) AND
		(
			CompanyKey = @CompanyKey OR
			OwnerCompanyKey = @CompanyKey
		)
	)
	
	SELECT	*
	FROM	tUser (nolock)
	WHERE
		UPPER(LTRIM(RTRIM(Email))) = UPPER(LTRIM(RTRIM(@FullName))) AND
		(
			CompanyKey = @CompanyKey OR
			OwnerCompanyKey = @CompanyKey
		)
	ORDER BY Active DESC
ELSE
	IF EXISTS(
		SELECT	1
		FROM	tUser (nolock)
		WHERE
			UPPER(LTRIM(RTRIM(FirstName))) + '' '' + UPPER(LTRIM(RTRIM(LastName))) = UPPER(LTRIM(RTRIM(@FullName))) AND
			(
				CompanyKey = @CompanyKey OR
				OwnerCompanyKey = @CompanyKey
			)
		)	
		SELECT	*
		FROM	tUser (nolock)
		WHERE
			UPPER(LTRIM(RTRIM(FirstName))) + '' '' + UPPER(LTRIM(RTRIM(LastName))) = UPPER(LTRIM(RTRIM(@FullName))) AND
			(
				CompanyKey = @CompanyKey OR
				OwnerCompanyKey = @CompanyKey
			)
		ORDER BY Active DESC
ELSE 
	If EXISTS(
		SELECT 1 
		FROM tUser (nolock)
		WHERE 
			UPPER(LTRIM(RTRIM(UserID))) = UPPER(LTRIM(RTRIM(@FullName)))
			 AND
			(
				CompanyKey = @CompanyKey OR
				OwnerCompanyKey = @CompanyKey
			)
		)
		SELECT * 
		FROM tUser (nolock)
		WHERE 
			UPPER(LTRIM(RTRIM(UserID))) = UPPER(LTRIM(RTRIM(@FullName)))
			 AND
			(
				CompanyKey = @CompanyKey OR
				OwnerCompanyKey = @CompanyKey
			)
		ORDER BY Active DESC
	ELSE
		SELECT	*
		FROM	tUser (nolock)
		WHERE
			UPPER(LTRIM(RTRIM(SystemID)))= UPPER(LTRIM(RTRIM(@FullName))) AND
			(
				CompanyKey = @CompanyKey OR
				OwnerCompanyKey = @CompanyKey
			)
		ORDER BY Active DESC'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[spApiAIUserLookupGet]'
GO
IF OBJECT_ID(N'[dbo].[spApiAIUserLookupGet]', 'P') IS NULL
EXEC sp_executesql N'CREATE   PROCEDURE [dbo].[spApiAIUserLookupGet]
    (
        @CompanyKey int,
        @UserKey int
    )
AS --Encrypt

/*
|| When      Who Rel      What
|| 07/16/26  GAR 26.08.16 (733142)  Created. Rights-scoped replacement for the spInitLoad ''tUser'' branch used by
||                        the MCP get_lookup_list tool. Returns an explicit allow-list of tUser columns.
||                        Column groups mirror the rights that gate the tabs on the Employee admin page:
||                          admineditlogin        -> Security Controls fields (login, security group, SSO, lock state)
||                          user_billing          -> Accounting fields (rates, costs, limits, approvers, GL/vendor)
||                          employee_project_time -> Projects & Time fields (assignment defaults, subscriptions)
||                        Users without a group''s right receive NULL for that group''s columns.
||                        Credentials and tokens (Password, 2FA codes, OAuth/API tokens, Uid) are never returned.
||                        Result sets: 1) right flags  2) user rows. On access denial returns the standard
||                        #errors result set and -103.
*/

set nocount on

declare @SecurityGroupKey int
declare @Administrator int
declare @RestrictToGLCompany int

declare @HasAdminEmployee int = 0
declare @HasLogin int = 0        -- admineditlogin
declare @HasBilling int = 0      -- user_billing
declare @HasProjectTime int = 0  -- employee_project_time
declare @HasService int = 0      -- user_billing OR employee_project_time (default service fields)

select * into #errors from tAPIErrorTemplate where 1 = 2

select  @SecurityGroupKey = SecurityGroupKey,
        @Administrator = ISNULL(Administrator, 0)
from    tUser (nolock)
where   UserKey = @UserKey
and     (CompanyKey = @CompanyKey or OwnerCompanyKey = @CompanyKey)

if @Administrator is null
begin
    insert into #errors (errorType, errorCode, errorMessage, fieldName)
    values (''error'', ''ACCESS_DENIED'', ''Calling user was not found in this company.'', ''general'')

    select errorType, errorCode, errorMessage, fieldName from #errors
    drop table #errors
    return -103
end

if @Administrator = 1
begin
    select @HasAdminEmployee = 1, @HasLogin = 1, @HasBilling = 1, @HasProjectTime = 1
end
else
begin
    select  @HasAdminEmployee = ISNULL(max(case when r.RightID = ''adminemployee''         then 1 else 0 end), 0),
            @HasLogin         = ISNULL(max(case when r.RightID = ''admineditlogin''        then 1 else 0 end), 0),
            @HasBilling       = ISNULL(max(case when r.RightID = ''user_billing''          then 1 else 0 end), 0),
            @HasProjectTime   = ISNULL(max(case when r.RightID = ''employee_project_time'' then 1 else 0 end), 0)
    from    tRight r (nolock)
    inner join tRightAssigned ra (nolock) on r.RightKey = ra.RightKey
    where   ra.EntityType = ''Security Group''
    and     ra.EntityKey = @SecurityGroupKey
    and     r.RightID in (''adminemployee'', ''admineditlogin'', ''user_billing'', ''employee_project_time'')
end

if @HasAdminEmployee = 0
begin
    insert into #errors (errorType, errorCode, errorMessage, fieldName)
    values (''error'', ''ACCESS_DENIED'', ''Retrieving the User list requires the adminemployee right or administrator access.'', ''general'')

    select errorType, errorCode, errorMessage, fieldName from #errors
    drop table #errors
    return -103
end

if @HasBilling = 1 or @HasProjectTime = 1
    select @HasService = 1

select @RestrictToGLCompany = ISNULL(RestrictToGLCompany, 0) from tPreference (nolock) where CompanyKey = @CompanyKey

-- Result set 1: which optional column groups are populated (the API layer
-- uses this to drop the ungranted groups from the response entirely)
select  @HasLogin as hasLoginFields,
        @HasBilling as hasBillingFields,
        @HasProjectTime as hasProjectTimeFields,
        @HasService as hasServiceFields

-- Result set 2: the user rows. Explicit allow-list only — never u.*.
-- Gated groups return NULL when the caller lacks the corresponding right.
select
        -- Base group: visible with adminemployee (Employee Details tab)
        u.UserKey as userKey,
        u.CompanyKey as companyKey,
        u.FirstName as firstName,
        u.MiddleName as middleName,
        u.LastName as lastName,
        u.Salutation as salutation,
        u.Title as title,
        u.Email as email,
        u.Phone1 as phone1,
        u.Phone2 as phone2,
        u.Cell as cell,
        u.Fax as fax,
        u.DepartmentKey as departmentKey,
        dep.DepartmentName as departmentName,
        u.OfficeKey as officeKey,
        o.OfficeName as officeName,
        u.Active as active,
        u.ClientVendorLogin as clientVendorLogin,
        u.Supervisor as supervisor,
        u.SupervisorKey as supervisorKey,
        u.ReportsToKey as reportsToKey,
        u.UserRole as userRole,
        u.TimeZoneIndex as timeZoneIndex,
        u.LanguageID as languageID,
        u.UserCulture as userCulture,
        u.InOutStatus as inOutStatus,
        u.InOutNotes as inOutNotes,
        u.DateAdded as dateAdded,
        u.DateHired as dateHired,
        u.LastModified as lastModified,
        u.CustomFieldKey as customFieldKey,
        LTRIM(RTRIM(ISNULL(u.FirstName, '''') + '' '' + ISNULL(u.LastName, ''''))) as userName,
        LTRIM(RTRIM(ISNULL(u.FirstName, '''') + '' '' + ISNULL(u.LastName, ''''))) as formattedName,
        case
            when u.MiddleName is null then LTRIM(RTRIM(ISNULL(u.FirstName, '''') + '' '' + ISNULL(u.LastName, '''')))
            else LTRIM(RTRIM(ISNULL(u.FirstName, '''') + '' '' + SUBSTRING(u.MiddleName, 1, 1) + '' '' + ISNULL(u.LastName, '''')))
        end as userFullName,
        SUBSTRING(ISNULL(u.FirstName, ''''), 1, 1) + SUBSTRING(ISNULL(u.MiddleName, ''''), 1, 1) + SUBSTRING(ISNULL(u.LastName, ''''), 1, 1) as initials,

        -- Login group: requires admineditlogin (Security Controls tab)
        case when @HasLogin = 1 then u.UserID else null end as userID,
        case when @HasLogin = 1 then u.SecurityGroupKey else null end as securityGroupKey,
        case when @HasLogin = 1 then u.Administrator else null end as administrator,
        case when @HasLogin = 1 then u.Locked else null end as locked,
        case when @HasLogin = 1 then u.RightLevel else null end as rightLevel,
        case when @HasLogin = 1 then u.SystemID else null end as systemID,
        case when @HasLogin = 1 then u.LastLogin else null end as lastLogin,
        case when @HasLogin = 1 then u.LastPwdChange else null end as lastPwdChange,
        case when @HasLogin = 1 then u.NumberOfAttempts else null end as numberOfAttempts,
        case when @HasLogin = 1 then u.ForcePwdChangeOnNextLogin else null end as forcePwdChangeOnNextLogin,
        case when @HasLogin = 1 then u.SSOAutoUpdateOff else null end as ssoAutoUpdateOff,
        case when @HasLogin = 1 then u.SSOAuthenticationOff else null end as ssoAuthenticationOff,
        case when @HasLogin = 1 then u.EnableAPIMCPUse else null end as enableAPIMCPUse,
        case when @HasLogin = 1 then u.SuspendAdmin else null end as suspendAdmin,
        case when @HasLogin = 1 then u.LoggedOut else null end as loggedOut,
        case when @HasLogin = 1 then u.LastLoggedOutDate else null end as lastLoggedOutDate,

        -- Billing group: requires user_billing (Accounting tab)
        case when @HasBilling = 1 then u.HourlyRate else null end as hourlyRate,
        case when @HasBilling = 1 then u.HourlyCost else null end as hourlyCost,
        case when @HasBilling = 1 then u.HourlyCost2 else null end as hourlyCost2,
        case when @HasBilling = 1 then u.MonthlyCost else null end as monthlyCost,
        case when @HasBilling = 1 then u.OvertimeCost else null end as overtimeCost,
        case when @HasBilling = 1 then u.VendorCost else null end as vendorCost,
        case when @HasBilling = 1 then u.OvertimeVendorCost else null end as overtimeVendorCost,
        case when @HasBilling = 1 then u.RateLevel else null end as rateLevel,
        case when @HasBilling = 1 then u.POLimit else null end as poLimit,
        case when @HasBilling = 1 then u.IOLimit else null end as ioLimit,
        case when @HasBilling = 1 then u.BCLimit else null end as bcLimit,
        case when @HasBilling = 1 then u.TimeApprover else null end as timeApproverKey,
        case when @HasBilling = 1 then u.ExpenseApprover else null end as expenseApproverKey,
        case when @HasBilling = 1 then u.CreditCardApprover else null end as creditCardApproverKey,
        case when @HasBilling = 1 then u.CalendarApprover else null end as calendarApproverKey,
        case when @HasBilling = 1 then u.BackupApprover else null end as backupApproverKey,
        case when @HasBilling = 1 then u.GLCompanyKey else null end as glCompanyKey,
        case when @HasBilling = 1 then glc.GLCompanyID else null end as glCompanyID,
        case when @HasBilling = 1 then glc.GLCompanyName else null end as glCompanyName,
        case when @HasBilling = 1 then u.ClassKey else null end as classKey,
        case when @HasBilling = 1 then u.VendorKey else null end as vendorKey,
        case when @HasBilling = 1 then u.TitleKey else null end as titleKey,
        case when @HasBilling = 1 then u.Contractor else null end as contractor,

        -- Projects & Time group: requires employee_project_time (Projects & Time tab)
        case when @HasProjectTime = 1 then u.AutoAssign else null end as autoAssign,
        case when @HasProjectTime = 1 then u.NoUnassign else null end as noUnassign,
        case when @HasProjectTime = 1 then u.SubscribeDiary else null end as subscribeDiary,
        case when @HasProjectTime = 1 then u.SubscribeDiaryPA else null end as subscribeDiaryPA,
        case when @HasProjectTime = 1 then u.SubscribeToDo else null end as subscribeToDo,
        case when @HasProjectTime = 1 then u.SubscribeToDoPA else null end as subscribeToDoPA,
        case when @HasProjectTime = 1 then u.SubscribeFileUpload else null end as subscribeFileUpload,
        case when @HasProjectTime = 1 then u.DeliverableReviewer else null end as deliverableReviewer,
        case when @HasProjectTime = 1 then u.DeliverableNotify else null end as deliverableNotify,
        case when @HasProjectTime = 1 then u.RequireUserTimeDetails else null end as requireUserTimeDetails,

        -- Service group: requires user_billing OR employee_project_time
        case when @HasService = 1 then u.DefaultServiceKey else null end as defaultServiceKey,
        case when @HasService = 1 then s.Description else null end as serviceDescription,
        case when @HasService = 1 then s.ServiceCode else null end as serviceCode

from    tUser u (nolock)
left join tService s (nolock) on u.DefaultServiceKey = s.ServiceKey
left join tOffice o (nolock) on u.OfficeKey = o.OfficeKey
left join tDepartment dep (nolock) on u.DepartmentKey = dep.DepartmentKey
left join tGLCompany glc (nolock) on u.GLCompanyKey = glc.GLCompanyKey
where   (
        u.CompanyKey = @CompanyKey
        or (u.OwnerCompanyKey = @CompanyKey and u.ClientVendorLogin = 0 and u.UserID is not null and u.Active = 1)
        )
and     (@RestrictToGLCompany = 0
        or u.GLCompanyKey in (select GLCompanyKey from tUserGLCompanyAccess (nolock) where UserKey = @UserKey)
        )
order by u.FirstName, u.LastName

drop table #errors
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptUserGetAllDetails]'
GO
IF OBJECT_ID(N'[dbo].[sptUserGetAllDetails]', 'P') IS NOT NULL
EXEC sp_executesql N'
-- Stored Procedure

ALTER PROCEDURE [dbo].[sptUserGetAllDetails]
(
  @UserKey int
 ,@AllDetails int = 1
 ,@OwnerUserKey int = -1
 )

AS --Encrypt

  /*
  || When     Who Rel      What
  || 05/22/09 GHL 10.5     Added AllDetails to get basic info 
  || 08/05/09 RLB 10.506   (58891)An issue on app where there was data for UserKey = 0 in some tables
  || 08/28/09 MFT 10.508   Added @IsContact logic to filter out some data tables for employee records
  || 9/10/09  CRG 10.5.1.0 Added Default Calendar query
  || 9/11/09  CRG 10.5.1.0 Added call to SP to ensure that existing employees have a default calendar when they''re pulled up
  || 12/11/09 GWG 10.5.1.4 Added in the joins for the lookups 
  || 03/02/11 GHL 10.5.4.2 Added FolderName for mobile contact screen
  || 05/25/11 QMD 10.5.4.4 (112424) Added the join to tSyncFolder to get sync direction and google folder name 
  || 07/27/11 QMD 10.5.4.6 (117171) Added the join to tSyncFolder to get sync direction for exchange 
  || 03/20/12 GWG 10.5.5.4 Added GL Company Access list.
  || 06/13/12 GHL 10.5.5.7 Added another GL Company Access list
  || 08/20/13 MFT 10.5.7.1 Added CreditCardApproverName (and tUser join) to support lookup
  || 04/23/14 QMD 10.5.7.9 Added UserToken
  || 06/19/14 MFT 10.5.8.1 Added join for ReportsTo
  || 07/03/14 MFT 10.5.8.1 Added tSocialMedia
  || 07/22/14 MFT 10.5.8.2 Added tAppFavorite join
  || 09/18/14 MFT 10.5.8.4 Added extra @AllDetails values to further limit return
  || 10/13/14 WDF 10.5.8.5 Added TitleName and TitleID
  || 10/27/14 RLB 10.5.8.5 Added ContactOwnerName
  || 10/28/14 RLB 10.5.8.5 Added TimeZoneDescription and added glcompany name and id on the restrict
  || 11/03/14 MFT 10.5.8.6 Removed tSocialMedia
  || 12/04/14 QMD 10.5.8.6 UserToken changed to PublicUserToken
  || 12/05/14 MFT 10.5.8.6 Added ContactFullName
  || 12/18/14 RLB 10.5.8.7 Pulling New Goal Table data
  || 03/04/15 RLB 10.5.9.0 Added CompanyOwnerKey and FolderUserKey for rights check
  || 11/23/16 GAR 10.6.1.0 Added user names for TimeApprover, BackupApprover, and ExpenseReportApprover
  || 11/23/16 GAR 10.6.1.1 Added service description for default service
  || 01/31/17 GAR 10.6.1.2 Added vendor name for use in the drop down.
  || 04/25/17 GWG 10.6.1.5 Added UserTimeZoneIndex to properly default through the levels of timezone.
  || 06/19/17 WDF 10.6.1.7 (350017) Added IsContact to User Details 
  || 07/25/17 QMD 10.6.1.8 (350017) Added DefaultService into the select
  || 01/20/18 GWG 18.2.0   Adding Min Hours per week
  || 02/02/18 KMC 18.2.0   Added GoogleLastSync
  || 02/07/18 MCM 18.2.0   (385051) Adding service code and service description so data is valid for the api
  || 04/05/18 GWG 18.5.0   Added empty string for culture name
  || 04/23/18 RLB 18.5.0.0 (397285) Added LinkedCompanyAddressKey 
  || 05/22/18 GAR 18.6.0   (402221) Added ClientDivisionName and ClientProductName
  || 08/30/18 RLS 18.9.0   (417869) Added join on tAppCalendar
  || 11/14/18 WDF 18.9.3.0 (430789) Added Delete of Address Record if there is no data in any of the Address segments
  || 05/2/19  GWG 19.0.5.0 Added Language name
  || 10/18/19 RLB 19.1.1.0 (457226) Added SupervisorName and Supervisor Count
  || 07/19/22 GHL 22.0.8.0 (604153) Added pref @TrackOvertime
  || 08/29/22 RLS 22.0.9.18 (609726) Removed space from SupervisorName
  || 09/01/22 RLS 22.0.9.18 (610776) Wrap ExpenseApproverName in LTRIM(RTRIM(ISNULL())). Also did the same for CreatedByName,ModifiedByName,CreditCardApproverName,ReportsToName,ContactOwnerName,TimeApproverName and BackupApproverName
  || 09/13/22 QMD 22.10.16.0 (606349) Added SecurityGroup for the api to keep inline with other procs.
  || 09/13/22 AMP 22.10.16 (612089) Removed u.* to eliminate the Encrypted Password from being returned
  || 06/27/23 RLB 23.07.16 (631684) Added sales person option
  || 12/04/23 CRG 24.01.14 (644751) Added CalendarApprover
  || 03/26/24 RLB 24.05.19 (667979) added HourlyCost2
  || 09/20/24 QMD 24.10.20.0000   (682987) Added DateDeactivated
  || 12/18/24 RLB 25.01.19 (688771) added options SubscribeDiaryPA and SubscribeToDoPA
  || 2/1/25   GWG 25.02.16  Added in Theme calls
  || 10/10/25 KMC 25.11.16 (698233) Removed tUserPreference EmailMailBox, EmailUserID, and EmailPassword
  || 06/12/26 GAR 26.07.19 (730742) Adding a user level permission, EnableAPIMCPUse, to allow a user to use the API or MCP
*/ 

Declare @MinActivityDate smalldatetime, @CompanyKey int, @ClientProductKey int, @ClientDivisionKey int, @ReportsToKey int, @IsContact bit, @ContactCompanyKey int, @AddressKey int, @AddressLen int

SELECT @IsContact = 0 
Select @IsContact = CASE WHEN ISNULL(OwnerCompanyKey, 0) > 0 THEN 1 ELSE 0 END, @CompanyKey = ISNULL(OwnerCompanyKey, CompanyKey), @ContactCompanyKey = CompanyKey, @ClientProductKey = ClientProductKey, @ClientDivisionKey = ClientDivisionKey, @ReportsToKey = ReportsToKey from tUser (nolock) Where UserKey = @UserKey and @UserKey > 0  

-- If it''s an existing employee, make sure they have a default calendar 
IF @IsContact = 0 AND @UserKey > 0 
	EXEC spCalendarManagerEnsureUserDefaultCalendar @UserKey 

declare @TrackOvertime int
select @TrackOvertime = isnull(TrackOvertime, 0) from tPreference (nolock) where CompanyKey = @CompanyKey

IF @AllDetails IN (0, 1, 9) 
	BEGIN

		SELECT	a.UserKey, Max(a.DateDeactivated) AS DateDeactivated
		INTO	#Deactivations
		FROM	tActivationLog a (NOLOCK)
		WHERE	NOT EXISTS (SELECT	al.UserKey 
							FROM	tActivationLog al (NOLOCK)
							WHERE	al.DateDeactivated IS NULL
									AND al.DateActivated IS NOT NULL
									AND al.UserKey = a.UserKey
							)
				AND a.DateDeactivated IS NOT NULL
		GROUP BY a.UserKey

		Select @IsContact as IsContact, u.UserKey
		,u.CompanyKey
		,u.FirstName
		,u.MiddleName
		,u.LastName
		,u.Salutation
		,u.DepartmentKey
		,u.Phone1
		,u.Phone2
		,u.Cell
		,u.Fax
		,u.Pager
		,u.Title
		,u.Email
		,u.SecurityGroupKey
		,u.Administrator
		,u.UserID    
		,u.SystemID
		,u.OwnerCompanyKey
		,u.LastLogin
		,u.ContactMethod
		,u.Active
		,u.AutoAssign
		,u.NoUnassign
		,u.HourlyRate
		,u.HourlyCost
		,u.HourlyCost2
		,u.TimeApprover
		,u.ExpenseApprover
		,u.POLimit
		,u.BCLimit
		,u.IOLimit
		,u.VendorKey
		,u.ClassKey
		,u.CustomFieldKey
		,u.InOutStatus
		,u.InOutNotes
		,u.UserDefined1
		,u.UserDefined2
		,u.UserDefined3
		,u.UserDefined4
		,u.UserDefined5
		,u.UserDefined6
		,u.UserDefined7
		,u.UserDefined8
		,u.UserDefined9
		,u.UserDefined10
		,u.OfficeKey
		,u.RateLevel
		,u.TrafficNotification
		,u.ClientVendorLogin
		,u.DateAdded
		,u.DateUpdated
		,u.TimeZoneIndex
		,u.NumberOfAttempts
		,u.Locked
		,u.LastPwdChange
		,u.Supervisor
		,u.DefaultReminderTime
		,u.LinkID
		,u.AddressKey
		,u.DefaultServiceKey
		,u.SystemMessage
		,u.GLCompanyKey
		,u.MonthlyCost
		,u.LastModified
		,u.OwnerKey
		,u.CMFolderKey
		,u.DoNotCall
		,u.DoNotEmail
		,u.DoNotMail
		,u.DoNotFax
		,u.AddedByKey
		,u.UpdatedByKey
		,u.HomeAddressKey
		,u.OtherAddressKey
		,u.ClientDivisionKey
		,u.ClientProductKey
		,u.Department
		,u.UserRole
		,u.ReportsToKey
		,u.Assistant
		,u.AssistantPhone
		,u.AssistantEmail
		,u.Birthday
		,u.SpouseName
		,u.Children
		,u.Anniversary
		,u.Hobbies
		,u.Comments
		,u.UserCompanyName
		,u.LastActivityKey
		,u.NextActivityKey
		,u.DefaultCMFolderKey
		,u.WWPCurrentLevel
		,u.DefaultCalendarColor
		,u.DateConverted
		,u.DefaultContactCMFolderKey
		,u.SyncMLDirection
		,u.CalendarReminder
		,u.DateLeadCreated
		,u.QuickMeeting
		,u.LinkedCompanyAddressKey
		,u.MarketingMessage
		,u.SubscribeDiary
		,u.SubscribeToDo
		,u.SubscribeDiaryPA
		,u.SubscribeToDoPA
		,u.DeliverableReviewer
		,u.DeliverableNotify
		,u.RightLevel
		,u.Contractor
		,u.RequireUserTimeDetails
		,u.CreditCardApprover
		,u.BackupApprover
		,u.DateHired
		,u.ExternalMarketingKey
		,u.LanguageID
		,u.ForcePwdChangeOnNextLogin
		,u.Uid
		,u.OriginalVCard
		,u.GoogleAuthToken
		,u.GoogleAuthTokenExpires
		,u.GoogleRefreshToken
		,u.GoogleRefreshTokenExpires
		,u.TitleKey
		,u.InvoiceEmails
		,u.TwitterID
		,u.LinkedInURL
		,u.Signature
		,u.DefaultActionID
		,u.SignatureFont
		,u.LoggedOut
		,u.RequestToken
		,u.UserDesktopImage
		,u.UserCulture
		,u.SSOAutoUpdateOff
		,u.SupervisorKey
		,u.SubscribeFileUpload
		,u.SlackMemberID
		,u.SSOAuthenticationOff
		,u.VendorCost
		,u.OvertimeCost
		,u.OvertimeVendorCost 
		,@TrackOvertime as TrackOvertime -- because this is not part of the preferences returned (in fact we return tUserPreference, not tPreference) 
		,CASE 
			WHEN LEN(ISNULL(u.FirstName, '''') + ISNULL(u.LastName, '''')) > 0 THEN 
				ISNULL(u.FirstName, '''') + CASE WHEN LEN(ISNULL(u.FirstName, '''')) > 0 THEN '' '' ELSE '''' END + ISNULL(u.LastName, '''') 
			ELSE ISNULL(u.UserCompanyName, ISNULL(c.CompanyName, '''')) 
			END AS ContactFullName 
		,c.CompanyName as LinkedCompanyName 
		,ISNULL(c.ContactOwnerKey, 0) as CompanyOwnerKey 
		,c.DefaultAddressKey 
		,LTRIM(RTRIM(ISNULL(cb.FirstName + '' '', '''')  + ISNULL(cb.LastName,''''))) As CreatedByName
		,LTRIM(RTRIM(ISNULL(mb.FirstName + '' '', '''')  + ISNULL(mb.LastName,''''))) As ModifiedByName
		,LTRIM(RTRIM(ISNULL(ca.FirstName + '' '', '''')  + ISNULL(ca.LastName,''''))) As CreditCardApproverName
		,LTRIM(RTRIM(ISNULL(rt.FirstName + '' '', '''')  + ISNULL(rt.LastName,''''))) As ReportsToName
		,LTRIM(RTRIM(ISNULL(co.FirstName + '' '', '''')  + ISNULL(co.LastName,''''))) As ContactOwnerName
		,up.PublicUserToken 
		,up.RequireMinHoursPerWeek
		,up.MinHoursPerWeek
		,v.VendorID 
		,v.CompanyName 
		,cl.ClassID 
		,cl.ClassName 
		,o.OfficeName 
		,d.DepartmentName 
		,gl.GLCompanyID 
		,gl.GLCompanyName 
		,t.TitleName 
		,t.TitleID 
		,cf.FolderName 
		,cf.UserKey as FolderUserKey 
		,ISNULL(u.TimeZoneIndex, oc.TimeZoneIndex) as UserTimeZoneIndex 
		,'''' as TimeZoneDescription 
		,'''' as CultureName
		,CASE WHEN ISNULL(af.AppFavoriteKey, 0) > 0 THEN 1 ELSE 0 END AS IsFavorite 
		,LTRIM(RTRIM(ISNULL(ta.FirstName + '' '', '''')  + ISNULL(ta.LastName,''''))) as TimeApproverName
		,LTRIM(RTRIM(ISNULL(ba.FirstName + '' '', '''')  + ISNULL(ba.LastName,''''))) as BackupApproverName
		,LTRIM(RTRIM(ISNULL(ea.FirstName + '' '', '''')  + ISNULL(ea.LastName,''''))) as ExpenseApproverName
		,LTRIM(RTRIM(ISNULL(sp.FirstName + '' '', '''')  + ISNULL(sp.LastName,''''))) As SupervisorName
		,sg.GroupName 
		,sg.GroupName AS SecurityGroup
		,sv.Description as ServiceDescription 
		,v.CompanyName as VendorName 
		,sv.ServiceCode as DefaultService	
		,lca.AddressName as LinkedCompanyAddressName
		,lca.Address1 AS LinkedAddress1
		,lca.Address2 AS LinkedkAddress2
		,lca.Address3 AS LinkedAddress3
		,lca.City AS LinkedCity
		,lca.State AS LinkedState
		,lca.PostalCode AS LinkedPostalCode
		,lca.Country AS LinkedCountry	
		,cd.DivisionName AS DivisionName
		,clp.ProductName AS ProductName
		,case u.LanguageID when ''EN'' then ''English'' when ''FR'' then ''French'' when ''ES'' then ''Spanish'' when ''GR'' then ''German'' end as LanguageName
		,CASE WHEN ISNULL(u.Supervisor, 0) = 0 THEN 0
				WHEN ISNULL(u.Supervisor, 0) = 1 THEN (SELECT COUNT(*) from tUser (nolock) where SupervisorKey = u.UserKey)
		END as SupervisorCount
		,u.SalesPerson
		,u.CalendarApprover
		,calApp.UserName AS CalendarApproverName
		,de.DateDeactivated
		,u.Theme as Theme
		,Case u.Theme When 1 then ''Next Era'' when 2 then ''Next Era Dark'' when 3 then ''Moody Blues'' when 4 then ''Workamajig Classic'' end as ThemeName
		,u.EnableAPIMCPUse
		from tUser u (nolock)  
		left outer join tPreference p (nolock) on ISNULL(u.CompanyKey, u.OwnerCompanyKey) = p.CompanyKey
		left outer join tCompany oc (nolock) on ISNULL(u.CompanyKey, u.OwnerCompanyKey) = oc.CompanyKey 
		left outer join tCompany c (nolock) on u.CompanyKey = c.CompanyKey 
		left outer join tUser cb (nolock) on u.AddedByKey = cb.UserKey 
		left outer join tUser mb (nolock) on u.UpdatedByKey = mb.UserKey 
		left outer join tUser co (nolock) on u.OwnerKey = co.UserKey 
		left outer join tUser ca (nolock) on u.CreditCardApprover = ca.UserKey 
		left outer join tUser rt (nolock) on u.ReportsToKey = rt.UserKey 
		left outer join tUser ta (nolock) on u.TimeApprover = ta.UserKey 
		left outer join tUser ba (nolock) on u.BackupApprover = ba.UserKey 
		left outer join tUser ea (nolock) on u.ExpenseApprover = ea.UserKey 
		left outer join tUser sp (nolock) on u.SupervisorKey = sp.UserKey 
		left outer join tTitle t (nolock) ON u.TitleKey = t.TitleKey 
		left outer join tUserPreference up (nolock) on u.UserKey = up.UserKey 
		left outer join tGLCompany gl (nolock) on u.GLCompanyKey = gl.GLCompanyKey 
		left outer join tCompany v (nolock) on u.VendorKey = v.CompanyKey 
		left outer join tClass cl (nolock) on u.ClassKey = cl.ClassKey 
		left outer join tOffice o (nolock) on u.OfficeKey = o.OfficeKey 
		left outer join tDepartment d (nolock) on u.DepartmentKey = d.DepartmentKey 
		left outer join tCMFolder cf (nolock) on u.CMFolderKey = cf.CMFolderKey 
		LEFT JOIN tAppFavorite af (nolock) ON u.UserKey = af.ActionKey AND af.ActionID = ''cm.contacts'' AND af.UserKey = @OwnerUserKey 
		left outer join tSecurityGroup sg (nolock) ON u.SecurityGroupKey = sg.SecurityGroupKey 
		left outer join tService sv (nolock) ON u.DefaultServiceKey = sv.ServiceKey 
		LEFT outer JOIN tAddress lca (nolock) ON u.LinkedCompanyAddressKey = lca.AddressKey
		LEFT OUTER JOIN tClientDivision cd (nolock) ON u.ClientDivisionKey = cd.ClientDivisionKey
		LEFT OUTER JOIN tClientProduct clp (nolock) ON u.ClientProductKey = clp.ClientProductKey
		LEFT OUTER JOIN vUserName calApp ON u.CalendarApprover = calApp.UserKey
		LEFT OUTER JOIN #Deactivations de (NOLOCK) ON u.UserKey = de.UserKey
		Where u.UserKey = @UserKey and @UserKey > 0 

	END

-- no need to stress the database if all details are not required 
IF @AllDetails = 0 
	RETURN 1 

-- last activity 
IF @IsContact = 1 AND @AllDetails IN (1, 2) 
	Select a.*, u.FirstName + '' '' + u.LastName as AssignedUserName 
		from tActivity a (nolock) 
		inner join tUser cont (nolock) on cont.LastActivityKey = a.ActivityKey 
		left outer join tUser u (nolock) on a.AssignedUserKey = u.UserKey 
	Where  
		cont.UserKey = @UserKey and @UserKey > 0 

-- next activity 
IF @IsContact = 1 AND @AllDetails IN (1, 2) 
	Select a.*, u.FirstName + '' '' + u.LastName as AssignedUserName 
		from tActivity a (nolock) 
		inner join tUser cont (nolock) on cont.NextActivityKey = a.ActivityKey 
		left outer join tUser u (nolock) on a.AssignedUserKey = u.UserKey 
	Where  
		cont.UserKey = @UserKey and @UserKey > 0 

-- Skills 
IF @AllDetails IN (1, 3) 
	Select * from tUserSkill (nolock) Where UserKey = @UserKey and @UserKey > 0 

-- Specialties 
IF @AllDetails IN (1, 4) 
	Select * from tUserSkillSpecialty (nolock) Where UserKey = @UserKey and @UserKey > 0 

-- Notifications 
IF @AllDetails IN (1, 5) 
	Select * from tUserNotification (nolock) Where UserKey = @UserKey and @UserKey > 0  

-- Preferences 
IF @AllDetails IN (1, 6) 
	Select * from tUserPreference (nolock) Where UserKey = @UserKey and @UserKey > 0 

-- Services 
IF @AllDetails IN (1, 7) 
	Select us.*, s.ServiceCode, s.Description as ServiceDescription
	from tUserService us (nolock) 
	Left Outer JOIN tService s (nolock) on us.ServiceKey = s.ServiceKey
	Where UserKey = @UserKey and @UserKey > 0 

-- MarketingLists 
IF @IsContact = 1 AND @AllDetails IN (1, 8) 
	Select * from tMarketingListList (nolock) Where Entity = ''tUser'' and EntityKey = @UserKey and @UserKey > 0 

-- Address List 
IF @AllDetails IN (1, 9)
--
--  If all of the Address segments are null/blank, then remove the record
--
	 Select @AddressKey = -1
	 WHILE (1=1)
	 BEGIN
		Select @AddressKey = MIN(AddressKey)
		  from tAddress (nolock)
		 Where Entity = ''tUser'' 
		   and EntityKey = @UserKey 
		   and AddressKey > @AddressKey

		IF @AddressKey IS NULL
			BREAK

		-- Perform action here
 		Select @AddressLen =  LEN(ISNULL(Address1, '''')) + LEN(ISNULL(Address2, '''')) + LEN(ISNULL(Address3, '''')) + LEN(ISNULL(City, '''')) + 
		                      LEN(ISNULL(State, '''')) + LEN(ISNULL(PostalCode, '''')) + LEN(ISNULL(Country, ''''))
		  from tAddress (nolock)
		 Where AddressKey = @AddressKey

		If @AddressLen = 0
			EXEC [dbo].[sptAddressDelete] @AddressKey = @AddressKey
	 END
--
--  Pull any remaining Addresses
--
	Select *, ''Personal'' as AddressType from tAddress (nolock) 
	Where Entity = ''tUser'' and EntityKey = @UserKey and @UserKey > 0 
	Order By AddressName 

-- level history 
IF @IsContact = 1 AND @AllDetails IN (1, 10) 
	SELECT * 
	FROM   tLevelHistory lh (NOLOCK) 
	WHERE  EntityKey = @UserKey and Entity = ''tUser'' and @UserKey > 0 
	Order By LevelDate DESC 

-- Default Calendar 
IF @IsContact = 0 AND @AllDetails IN (1, 11) 
	SELECT	f.*, ac.CalendarColor AS DefaultCalendarColor, u.UserID, 1 AS IsDefault, 1 AS IncludeInSync, sf.SyncDirection, s.SyncDirection AS GoogleSyncDirection,  
	s.SyncFolderName AS GoogleSyncFolderName, s.GoogleLastSync, ac.WhiteText
	FROM	tCMFolder f (nolock) 
	INNER JOIN tUser u (nolock) ON f.CMFolderKey = u.DefaultCMFolderKey 
	INNER JOIN tAppCalendar ac (nolock) on u.UserKey = ac.UserKey AND u.DefaultCMFolderKey = ac.EntityKey AND ac.Entity = ''tCMFolder''
	LEFT JOIN tSyncFolder sf (nolock) ON sf.SyncFolderKey = f.SyncFolderKey 
	LEFT JOIN tSyncFolder s (nolock) ON f.GoogleSyncFolderKey = s.SyncFolderKey  
	WHERE	u.UserKey = @UserKey and @UserKey > 0 

	-- add in a restriction layer if the person is not allowed to access a particular company 
IF @AllDetails IN (1, 12) 
	select glc.GLCompanyKey, glc.GLCompanyID, glc.GLCompanyName,  
		(Select 1 from tUserGLCompanyAccess glca (nolock) Where glca.GLCompanyKey = glc.GLCompanyKey and glca.UserKey = @UserKey) as Selected 
	from tGLCompany glc (nolock)  
	Where glc.CompanyKey = @CompanyKey and glc.Active = 1 
	order by glc.GLCompanyID, glc.GLCompanyName 

	-- Access restriction 
IF @AllDetails IN (1, 13) 
	SELECT glca.*, glc.GLCompanyID, glc.GLCompanyName 
	FROM   tGLCompanyAccess glca (nolock) 
		inner join tGLCompany glc (nolock) on glca.GLCompanyKey = glc.GLCompanyKey 
	WHERE  glca.CompanyKey = @CompanyKey 
	AND    glca.Entity = ''tUser'' 
	AND    glca.EntityKey = @UserKey 
	order by glc.GLCompanyName 

	-- get Goal data 
IF @AllDetails IN (1, 14) 
	SELECT * 
	FROM   tGoal gl (nolock) 
	WHERE gl.Entity = ''tUser'' 
	AND    gl.EntityKey = @UserKey 
	order by gl.Year

	-- Linked Company Addresses 
IF @AllDetails IN (1, 15) 
	Select *, ''Company'' as AddressType from tAddress (nolock)
	Where CompanyKey = @ContactCompanyKey and Entity is null
	Order By AddressName
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptUserUpdateEmployee]'
GO
IF OBJECT_ID(N'[dbo].[sptUserUpdateEmployee]', 'P') IS NOT NULL
EXEC sp_executesql N'-- Stored Procedure

ALTER PROCEDURE [dbo].[sptUserUpdateEmployee]
	@UserKey int = 0,
	@CompanyKey int,
	@FirstName nvarchar(100),
	@MiddleName nvarchar(100),
	@LastName nvarchar(100),
	@Salutation varchar(10),
	@Phone1 varchar(50),
	@Phone2 varchar(50),
	@Cell varchar(50),
	@Fax varchar(50),
	@Pager varchar(50),
	@Title nvarchar(200),
	@Email varchar(100),
	@SystemID varchar(500),
	@ContactMethod tinyint,
	@DepartmentKey int,
	@OfficeKey int,
	@TimeZoneIndex int,
	@Supervisor tinyint,
	@DefaultServiceKey int,
	@SecurityGroupKey int,
	@Locked tinyint,
	@UserRole varchar(300),
	@Assistant nvarchar(300),
	@AssistantPhone varchar(50),
	@AssistantEmail varchar(100),
	@Birthday datetime,
	@SpouseName nvarchar(300),
	@Children nvarchar(500),
	@Anniversary datetime,
	@Hobbies nvarchar(500),
	@Comments nvarchar(max),
	@HourlyCost money,
	@MonthlyCost money,
	@HourlyRate money,
	@RateLevel int,
	@TimeApprover int,
	@ExpenseApprover int,
	@GLCompanyKey int,
	@VendorKey int,
	@ClassKey int,
	@AutoAssign tinyint,
	@NoUnassign tinyint,
	@POLimit money,
	@BCLimit money,
	@IOLimit money,
	@SubscribeDiary tinyint,
	@SubscribeToDo tinyint,
	@SubscribeFileUpload tinyint = 0,
	@DeliverableReviewer tinyint,
	@DeliverableNotify tinyint,
	@Contractor tinyint,
	@RequireUserTimeDetails tinyint,
	@BackupApprover int,
	@CreditCardApprover int,
	@DateHired smalldatetime,
	@TitleKey int,
	@SignatureFont varchar(100),
	@OwnerCompanyKey int = NULL,
	@UserCulture int = NULL,
	@SSOAutoUpdateOff int = NULL,
	@LanguageID varchar(10) = NULL,
	@SupervisorKey int = null,
	@UpdateFrom varchar(50) = ''Classic'',
	@SlackMemberID varchar(300) = NULL,
	@SSOAuthenticationOff int = NULL,
	@VendorCost money = null,
	@OvertimeCost money = null,
	@OvertimeVendorCost money = null,
	@SalesPerson tinyint,
	@CalendarApprover int = null,
	@HourlyCost2 money = null,
	@AddedByKey int = NULL,
	@SubscribeDiaryPA tinyint = 0,
	@SubscribeToDoPA tinyint = 0,
	@Theme smallint = null,
	@EnableAPIMCPUse tinyint = 0

AS --Encrypt

/*
|| When      Who Rel      What
|| 08/28/09  MFT 10.5.0.8 Created
|| 9/10/09   CRG 10.5.1.0 Removed DefaultCalendarColor
|| 10/5/09   GWG 10.5.1.1 Removed Owner Company Key
|| 10/14/09  MFT 10.5.1.2 Removed CustomeFieldKey
|| 12/21/10  GHL 10.5.3.9 Added Subscribe Diary and ToDo params
|| 12/10/11  GWG 10.5.5.0 Added the default deliverable flags
|| 05/30/12  GHL 10.5.5.6 (145013) Added Contractor field
|| 06/18/12  RLB 10.5.5.7 Added for HMI Changes
|| 09/19/12	 KMC 10.5.6.0 Added BackupApprover
|| 09/19/12	 GHL 10.5.6.0 Added CreditCardApprover
|| 10/29/12  MFT 10.5.6.1 Added DateHired
|| 05/08/13  WDF 10.5.6.8 (177487) Added SystemMessage defaulted to 1 for New employee
|| 05/16/14  WDF 10.5.8.0 (216580) Removed ''IF @TimeZoneIndex < 0 SELECT @TimeZoneIndex = 4''
|| 09/23/14  MAS 10.5.8.3 Ableson & Taylor - Added @TitleKey
|| 10/20/14  WDF 10.5.8.4 Ableson & Taylor - Don''t allow TitleKey update for existing employees when imported
|| 06/21/16  GAR 10.6.0.5 Add code to update TaskUserStatusKeys if security group is changed
|| 09/13/16  GAR 10.6.0.8 (303290) Add SignatureFont to use when approving estimates
|| 04/05/17  GAR 10.6.1.5 Had to add ContactCompanyKey in case we were updating a contact info
|| 04/05/18  GWG 18.5.0   Adding Culture
|| 05/17/18  GHL 18.6.0   (401814) Default Rate Level to 1
|| 01/28/19  MAS 19.0.2.0 (440626) Added optional @SSOAutoUpdateOff - Flag is used to control whether or not the user record should be auto-updated everytime they login using SSO
|| 04/17/19  MCM 19.0.5.0 (455866) Updated where if insert new user, set the TimeApprover, ExpenseApprover, and CreditCardApprover to the new user
|| 05/02/19  GWG 19.0.5.0 Added Language ID
|| 10/18/19  RLB 19.1.1.0 (457226) Added SupervisorKey and way to know where update is from since it is used in flex
|| 04/10/20  GAR 20.0.5.0 (493286) Added SubscribeFileUpload to employee update screen
|| 04/22/20  RLS 20.0.5.0 (505920) Changed GETDATE() to GETUTCDATE() for DateUpdated
|| 02/17/21  RLS 21.0.3.0 (546075) Changed @FirstName @Middlename and @LastName to nvarchar
|| 08/17/21  GAR 21.12.19 (DEV2501) Added Slack User Name - not sure when this will be released so I put December 
|| 01/28/19  MAS 21.11.14 (440626) Added optional @SSOAutoUpdateOff - Flag is used to control whether or not the user record should be auto-updated everytime they login using SSO 
|| 12/20/21  GHL 22.01.16 (579674) Added parameter @VendorCost which is used on vendor invoices 
|| 08/17/21  GAR 22.03.20 (DEV2501) Changed Slack User Name to SlackMemberID
|| 07/18/22  RLS 22.0.8.0 (606282) Changed @Title, @Comments, @Assistant, @SpouseName, @Children, @Hobbies to nvarchar
|| 07/18/22  GHL 22.0.8.0 (604153) Added fields to Track Overtime labor. See sptTimeGetUnpaid for an explanation of these costs
|| 06/27/23  RLB 23.07.16 (631684) Added sales person option
|| 12/04/23  CRG 24.01.14 (644751) Added CalendarApprover
|| 03/26/24  RLB 24.05.19 (667979) Added HourCost2
|| 05/28/24  RLB 24.06.16 (673347) added defualt vault to HourCost2
|| 09/05/24  RLB 24.10.20 (682444) SEt hourcost2 = null to not require it
|| 09/19/24  RLS 24.10.20 (682529) Added @AddedByKey
|| 12/18/24  RLB 25.01.19 (688771) added auto subscribe AM/PM for Project Conversations and To Do Conversations
|| 2/1/25    GWG 25.02.16  Added in Theme calls
|| 06/12/26  GAR 26.07.19  (730742) Adding a user level permission, EnableAPIMCPUse, to allow a user to use the API or MCP
*/

DECLARE @ActionOnName varchar(201), @CurrentTitleKey int, @CurrentTitleID varchar(50), @NewTitleID varchar(50)
DECLARE @CharIdx int, @Msg varchar(4000), @CurrentDate as datetime
DECLARE @CurerntUserCulture int, @CurrentSSOAutoUpdateOff int, @CurrentLanguageID varchar(10), @CurrentSupervisorKey int

DECLARE @CurrentSecurityGroupKey AS INT
SET @CurrentSecurityGroupKey = (SELECT ISNULL(SecurityGroupKey, 0) FROM tUser WHERE UserKey = @UserKey)

-- the rate level cannot be null
select @RateLevel = isnull(@RateLevel, 1)

if isnull(@VendorKey, 0) = 0
	select @VendorCost = null
	      ,@OvertimeVendorCost = null

IF @UserKey > 0
	BEGIN
	 Declare @TrackOvertime int
	 select @TrackOvertime = pref.TrackOvertime
	 from   tPreference pref (nolock)
		inner join tUser u (nolock) on pref.CompanyKey = ISNULL(u.OwnerCompanyKey, u.CompanyKey)
	 Where u.UserKey = @UserKey

	 if isnull(@TrackOvertime,0) = 0
		select @OvertimeCost = null
	      ,@OvertimeVendorCost = null

	select @CharIdx = charindex(''billingtitles'',Customizations)
	  from tPreference (nolock)
	 where CompanyKey = @CompanyKey

	if @CharIdx > 0
	begin
		select @ActionOnName = FirstName + '' '' + LastName
		      ,@CurrentTitleKey = ISNULL(t.TitleKey, ISNULL(@TitleKey, 0)), @CurrentTitleID = ISNULL(t.TitleID, '''')
		  from tUser u (nolock) LEFT JOIN tTitle t (nolock) on u.TitleKey = t.TitleKey
		 where u.CompanyKey = @CompanyKey
		   and u.UserKey = @UserKey

		if ISNULL(@TitleKey, 0) <> @CurrentTitleKey
		BEGIN
			select @NewTitleID = TitleID from tTitle (nolock) where CompanyKey = @CompanyKey and TitleKey = @TitleKey
		    select @CurrentDate = GETUTCDATE()
			select @Msg = ''Billing Title for '' + @ActionOnName + '' was blocked from being updated from '''''' + @CurrentTitleID + '''''' to '''''' + @NewTitleID  + '''''' through the Employee Import''

			EXEC sptActionLogInsert ''User'', @UserKey, @CompanyKey, 0, ''Billing Title Blocked'', @CurrentDate, ''Employee Import''
							       ,@Msg, @CurrentTitleKey, NULL, NULL   

			SELECT @TitleKey = @CurrentTitleKey
		END
	end
	-- if updated from classic keep these fields
	if @UpdateFrom = ''Classic''
		SELECT @UserCulture = UserCulture, @SSOAutoUpdateOff = SSOAutoUpdateOff, @LanguageID = LanguageID, @SupervisorKey = SupervisorKey From tUser (NOLOCK) WHERE UserKey = @UserKey 

	UPDATE
		tUser
	SET
		CompanyKey = @CompanyKey,
		FirstName = @FirstName,
		MiddleName = @MiddleName,
		LastName = @LastName,
		Salutation = @Salutation,
		Phone1 = @Phone1,
		Phone2 = @Phone2,
		Cell = @Cell,
		Fax = @Fax,
		Pager = @Pager,
		Title = @Title,
		Email = @Email,
		SystemID = @SystemID,
		OwnerCompanyKey = @OwnerCompanyKey,
		ContactMethod = @ContactMethod,
		DepartmentKey = @DepartmentKey,
		OfficeKey = @OfficeKey,
		TimeZoneIndex = @TimeZoneIndex,
		Supervisor = @Supervisor,
		DefaultServiceKey = @DefaultServiceKey,
		DateUpdated = GETUTCDATE(),
		SecurityGroupKey = @SecurityGroupKey,
		Locked = @Locked,
		UserRole = @UserRole,
		Assistant = @Assistant,
		AssistantPhone = @AssistantPhone,
		AssistantEmail = @AssistantEmail,
		Birthday = @Birthday,
		SpouseName = @SpouseName,
		Children = @Children,
		Anniversary = @Anniversary,
		Hobbies = @Hobbies,
		Comments = @Comments,
		HourlyCost = @HourlyCost,
		MonthlyCost = @MonthlyCost,
		HourlyRate = @HourlyRate,
		RateLevel = @RateLevel,
		TimeApprover = @TimeApprover,
		ExpenseApprover = @ExpenseApprover,
		GLCompanyKey = @GLCompanyKey,
		VendorKey = @VendorKey,
		ClassKey = @ClassKey,
		AutoAssign = @AutoAssign,
		NoUnassign = @NoUnassign,
		POLimit = @POLimit,
		BCLimit = @BCLimit,
		IOLimit = @IOLimit,
		SubscribeDiary = @SubscribeDiary,
		SubscribeToDo = @SubscribeToDo,
		SubscribeFileUpload = @SubscribeFileUpload,
		DeliverableReviewer = @DeliverableReviewer,
		DeliverableNotify = @DeliverableNotify,
		Contractor = @Contractor,
		RequireUserTimeDetails = @RequireUserTimeDetails,
		BackupApprover = @BackupApprover,
		CreditCardApprover = @CreditCardApprover,
		DateHired = @DateHired,
		TitleKey = @TitleKey,
		SignatureFont = @SignatureFont,
		UserCulture = @UserCulture,
		SSOAutoUpdateOff = @SSOAutoUpdateOff,
		LanguageID = @LanguageID,
		SupervisorKey = @SupervisorKey,
		SlackMemberID = @SlackMemberID,
		SSOAuthenticationOff = @SSOAuthenticationOff,
		VendorCost = @VendorCost,
		OvertimeCost = @OvertimeCost,
		OvertimeVendorCost = @OvertimeVendorCost,
		SalesPerson = @SalesPerson,
		CalendarApprover = @CalendarApprover,
		HourlyCost2 = @HourlyCost2,
		SubscribeDiaryPA = @SubscribeDiaryPA,
		SubscribeToDoPA = @SubscribeToDoPA,
		Theme = @Theme,
		EnableAPIMCPUse = @EnableAPIMCPUse
	WHERE
		UserKey = @UserKey 

	IF @CurrentSecurityGroupKey <> ISNULL(@SecurityGroupKey,0) OR ISNULL(@SecurityGroupKey,0) > 0
		BEGIN
			SELECT @CompanyKey = ISNULL(OwnerCompanyKey, CompanyKey) from tUser (nolock) Where UserKey = @UserKey

			IF EXISTS (SELECT * FROM tTaskUserStatus WHERE Entity = ''securitygroup'' AND EntityKey = @SecurityGroupKey)
			BEGIN
				-- If there is a security group setting for the new security groups.
				UPDATE tTaskUser
				SET TaskUserStatusKey = (SELECT TaskUserStatusKey FROM tTaskUserStatus tus (nolock)
											WHERE tus.Entity = ''securitygroup'' AND tus.EntityKey = @SecurityGroupKey AND LOWER(tus.StatusName) = LOWER(tTaskUserStatus.StatusName))
				FROM tTaskUser
					INNER JOIN tTaskUserStatus ON tTaskUser.TaskUserStatusKey = tTaskUserStatus.TaskUserStatusKey
				WHERE UserKey = @UserKey
			END
			ELSE IF EXISTS (SELECT * FROM tTaskUserStatus WHERE Entity = ''securitygroup'' AND EntityKey = @CurrentSecurityGroupKey)
			BEGIN
				-- If there is a security group setting for the old security group but not the new one.
				UPDATE tTaskUser
				SET TaskUserStatusKey = (SELECT TaskUserStatusKey FROM tTaskUserStatus tus (nolock)
											WHERE tus.Entity = ''company'' AND tus.EntityKey = @CompanyKey AND LOWER(tus.StatusName) = LOWER(tTaskUserStatus.StatusName))
				FROM tTaskUser
					INNER JOIN tTaskUserStatus ON tTaskUser.TaskUserStatusKey = tTaskUserStatus.TaskUserStatusKey
				WHERE UserKey = @UserKey
			END
			-- If no security group setting for old or new group then we should leave it as is because its for the company anyway.
		END

	END
ELSE
	BEGIN
		DECLARE @CurPrimaryCont int

		INSERT tUser
		(
			CompanyKey,
			FirstName,
			MiddleName,
			LastName,
			Salutation,
			Phone1,
			Phone2,
			Cell,
			Fax,
			Pager,
			Title,
			Email,
			SystemID,
			OwnerCompanyKey,
			ContactMethod,
			DepartmentKey,
			OfficeKey,
			TimeZoneIndex,
			Supervisor,
			DefaultServiceKey,
			DateAdded,
			DateUpdated,
			Active,
			SecurityGroupKey,
			Locked,
			UserRole,
			Assistant,
			AssistantPhone,
			AssistantEmail,
			Birthday,
			SpouseName,
			Children,
			Anniversary,
			Hobbies,
			Comments,
			HourlyCost,
			MonthlyCost,
			HourlyRate,
			RateLevel,
			TimeApprover,
			ExpenseApprover,
			GLCompanyKey,
			VendorKey,
			ClassKey,
			AutoAssign,
			NoUnassign,
			POLimit,
			BCLimit,
			IOLimit,
			SystemMessage,
			SubscribeDiary,
			SubscribeToDo,
			SubscribeFileUpload,
			DeliverableReviewer,
			DeliverableNotify,
			Contractor,
			RequireUserTimeDetails,
			BackupApprover,
			CreditCardApprover,
			DateHired,
			TitleKey,
			SignatureFont,
			SSOAutoUpdateOff,
			LanguageID,
			SupervisorKey,
			SlackMemberID,
			SSOAuthenticationOff,
			VendorCost,
			OvertimeCost,
			OvertimeVendorCost,
			SalesPerson,
			CalendarApprover,
			HourlyCost2,
			AddedByKey,
			SubscribeDiaryPA,
			SubscribeToDoPA,
			EnableAPIMCPUse
		)
		VALUES
		(
			@CompanyKey,
			@FirstName,
			@MiddleName,
			@LastName,
			@Salutation,
			@Phone1,
			@Phone2,
			@Cell,
			@Fax,
			@Pager,
			@Title,
			@Email,
			@SystemID,
			@OwnerCompanyKey,
			@ContactMethod,
			@DepartmentKey,
			@OfficeKey,
			@TimeZoneIndex,
			@Supervisor,
			@DefaultServiceKey,
			GETDATE(),
			GETDATE(),
			1,
			@SecurityGroupKey,
			@Locked,
			@UserRole,
			@Assistant,
			@AssistantPhone,
			@AssistantEmail,
			@Birthday,
			@SpouseName,
			@Children,
			@Anniversary,
			@Hobbies,
			@Comments,
			@HourlyCost,
			@MonthlyCost,
			@HourlyRate,
			@RateLevel,
			@TimeApprover,
			@ExpenseApprover,
			@GLCompanyKey,
			@VendorKey,
			@ClassKey,
			@AutoAssign,
			@NoUnassign,
			@POLimit,
			@BCLimit,
			@IOLimit,
			1,
			@SubscribeDiary,
		    @SubscribeToDo,
			@SubscribeFileUpload,
			@DeliverableReviewer,
		    @DeliverableNotify,
			@Contractor,
			@RequireUserTimeDetails,
			@BackupApprover,
			@CreditCardApprover,
			@DateHired,
			@TitleKey,
			@SignatureFont,
			@SSOAutoUpdateOff,
			@LanguageID,
			@SupervisorKey,
			@SlackMemberID,
			@SSOAuthenticationOff,
			@VendorCost,
			@OvertimeCost,
			@OvertimeVendorCost,
			@SalesPerson,
			@CalendarApprover,
			@HourlyCost2,
			@AddedByKey,
			@SubscribeDiaryPA,
		    @SubscribeToDoPA,
			@EnableAPIMCPUse
		)

		SELECT @UserKey = SCOPE_IDENTITY()

		SELECT @CurPrimaryCont = PrimaryContact
		FROM tCompany (nolock)
		WHERE CompanyKey = @CompanyKey

		IF @CurPrimaryCont = 0
			UPDATE tCompany
			SET PrimaryContact = @UserKey
			WHERE CompanyKey = @CompanyKey

		DECLARE @MyTimeApprover int
		DECLARE @MyCreditCardApprover int
		DECLARE @MyExpenseApprover int
		DECLARE	@MyCalendarApprover int

		SELECT @MyTimeApprover = TimeApprover, @MyCreditCardApprover=CreditCardApprover, @MyExpenseApprover = ExpenseApprover, @MyCalendarApprover = CalendarApprover From tUser (nolock) WHERE UserKey = @UserKey

		if IsNULL(@MyTimeApprover, 0) = 0 
			UPDATE tUser SET TimeApprover = @UserKey  WHERE UserKey = @UserKey
		if IsNULL(@MyCreditCardApprover, 0) = 0 
			UPDATE tUser SET CreditCardApprover = @UserKey  WHERE UserKey = @UserKey
		if IsNULL(@MyExpenseApprover, 0) = 0 
			UPDATE tUser SET ExpenseApprover = @UserKey  WHERE UserKey = @UserKey
		IF ISNULL(@MyCalendarApprover, 0) = 0
			UPDATE tUser SET CalendarApprover = @UserKey WHERE UserKey = @UserKey
	END

IF @Supervisor = 0
	DELETE tUserNotification
	WHERE UserKey = @UserKey
	AND NotificationID IN (''ODTIME'', ''NOHOURS'')
	AND Value = 3 -- The people I supervise

RETURN @UserKey
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptReviewDeliverableGetDashboard]'
GO
IF OBJECT_ID(N'[dbo].[sptReviewDeliverableGetDashboard]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER Procedure [dbo].[sptReviewDeliverableGetDashboard]
	@CompanyKey INT,
	@UserKey INT,
	@ProjectKey INT,
	@CampaignKey INT = NULL,
	@ClientKey INT = NULL,
	@HideCompletedTasks tinyint,
	@HideApprovedCompleted tinyint,
	@AccountManagerKey INT = NULL,  -- not used
	@OwnerKey INT = NULL,  -- not used
	@ProjectStatusKey INT = NULL,  -- not used
	@ReviewDeliverableKey INT = NULL --passed in by RTN to update just one record in the grid
  
AS --Encrypt

  /*
  || When		Who Rel			What
  || 09/30/15   GAR 10.5.9.6    Created for deliverables dashboard.
  || 03/30/17   GWG 10.6.1.4    Add in security restrictions in the sp	
  || 12/4/19    GWG 19.1.2.0	Adding in conversation count
  || 04/07/20   RLS 20.0.5.0    (508916) Added r.Status
  || 06/09/20   RLS 20.0.7.0    (517205)  Added a.Subject
  || 10/28/20   RLB 20.1.1.0    (534457)(534455) added OwnerUserKey because it was getting cleared on grid update and default TaskKey
  || 03/16/21   RLB 21.04.18    (550876) Adding option to filter out completed tasks or approved/complete deliverables
  || 03/18/21   RLB 21.04.18    (552161) Added Completed
  || 03/25/21   RLB 21.04.18    (549892) added a check on the task to see if it is a budget tracking task for time entry
  || 09/09/21   RLS 21.0.7.0    (564658) Changes StatusName to nvarchar(500) to match the table
  || 09/30/21   RLB 21.10.17    (572517) making this match project dash board deliverables
  || 10/06/21   CRG 21.11.14    (553254) Added @ReviewDeliverableKey parm to return just one record to update deliverable board grid after RTN
  || 10/28/21   AMP xx.xx.xx    (DEV2506-502) Added a flag to hide the task on the deliverable board 
  || 03/22/22   GAR 22.04.17    (585938) Added attachments for the ImageField - changing from Base64 to an attachment
  || 03/23/22   GAR 22.04.17    (585938) Added the office key from the project
  || 03/25/22   AMP 22.04.17    (592515) When Deliverable Status Color is removed it will be displayed as blank in the list, instead of white
  || 04/12/22   RLB 22.05.15    (587411) change filter approvedcomplete to just filter out completed
  || 04/13/22   GAR 22.04.17    (595557) AFixed an issue where the wrong attachmentkey was being grabbed
  || 04/27/22   RLB 22.04.17    (596854) removed taskkey filter to dos on deliverable
  || 06/18/26   RLB 26.07.19    (730729) Added pulling campaign deliverable when a campaignkey is passed in
  */
  
	DECLARE @DefaultDeliverableStatusKey INT, @DefaultTaskKey int, @SecurityGroupKey int, @Administrator int, @RestrictToGLCompany int, @ViewAny tinyint, @StatusName nvarchar(500), @Color varchar(30), @TaskName varchar(500), @DefaultBudgetTaskKey int, @DefaultTaskTracksBudget tinyint,  @DefaultBudgetTaskName varchar(500), @CurrentUserAssignedToProject tinyint

	if @ProjectKey is null and @CampaignKey is null and @ClientKey is null
		return 1


	select @SecurityGroupKey = SecurityGroupKey, @Administrator = Administrator from tUser (nolock) where UserKey = @UserKey
	Select @RestrictToGLCompany = isnull(RestrictToGLCompany, 0) from tPreference (nolock) where CompanyKey = @CompanyKey

	if @ProjectKey is not null
		Select @ClientKey = null, @CampaignKey = null

	if exists (select 1 from tRightAssigned ra (nolock) Where ra.EntityKey = @SecurityGroupKey and ra.RightKey = 90918)  --prjAccessAny
		select @ViewAny = 1
	else
		select @ViewAny = 0

	if @Administrator = 1
		select @ViewAny = 1

	SET @DefaultDeliverableStatusKey = 
		(SELECT DeliverableStatusKey 
		FROM tDeliverableStatus (nolock)
		WHERE CompanyKey = @CompanyKey 
			AND DisplayOrder = (
				SELECT MIN(DisplayOrder) 
				FROM tDeliverableStatus (nolock)
				WHERE CompanyKey = @CompanyKey))
	Select @StatusName = StatusName, 
		   @Color = (Select CASE StatusColor WHEN ''#E1E1E1'' then '''' else StatusColor END AS StatusColor
					 FROM tDeliverableStatus (nolock)
				     Where DeliverableStatusKey = @DefaultDeliverableStatusKey)
	from tDeliverableStatus (nolock) Where DeliverableStatusKey = @DefaultDeliverableStatusKey


	SET @DefaultTaskKey = 
		(SELECT TaskKey 
		FROM tTask (nolock)
		WHERE ProjectKey = @ProjectKey
			AND ProjectOrder = (
				SELECT MIN(ProjectOrder) 
				FROM tTask (nolock)
				WHERE ProjectKey = @ProjectKey and TaskType = 2 and ScheduleTask = 1))

	Select @TaskName = TaskID + '' - '' + TaskName, @DefaultBudgetTaskKey = BudgetTaskKey from tTask (nolock) Where TaskKey = @DefaultTaskKey

	Select @DefaultBudgetTaskName = TaskID + '' - '' + TaskName from tTask (nolock) Where TaskKey = @DefaultBudgetTaskKey

	IF @DefaultTaskKey = @DefaultBudgetTaskKey
		SELECT @DefaultTaskTracksBudget = 1
	else
		SELECT @DefaultTaskTracksBudget = 0

	Select
		 ISNULL(s.DeliverableStatusKey, @DefaultDeliverableStatusKey) as DeliverableStatusKey
		,ISNULL(s.StatusName, @StatusName) as StatusName
		,CASE StatusColor WHEN ''#E1E1E1'' then '''' else StatusColor END AS StatusColor
		,rd.ReviewDeliverableKey
		,rd.DeliverableName
		,rd.Description
		,rd.DeliverableID
		,rd.DueDate
		,ISNULL(rd.Completed, 0) as Completed
		,CASE ISNULL(rd.Completed, 0) WHEN 1 THEN ''Yes'' ELSE ''No'' END as IsCompleted
		,ISNULL(rd.Approved, 0) as Approved
		,CASE ISNULL(rd.Approved, 0) WHEN 1 THEN ''Yes'' ELSE ''No'' END as IsApproved
		,rd.ApprovedDate
		,rd.OwnerKey as OwnerUserKey
		,RTRIM(LTRIM(ISNull(u.FirstName,'''') + '' '' + ISNULL(u.LastName,''''))) as OwnerName
		,RTRIM(LTRIM(ISNull(am.FirstName,'''') + '' '' + ISNULL(am.LastName,''''))) as AccountManager
		,pt.ProjectTypeName as ProjectType
		,p.ProjectNumber
		,p.ProjectName
		,p.StartDate
		,p.CompleteDate
		,ca.CampaignID + '' - '' + ca.CampaignName as CampaignFullName
		,cl.CustomerID + '' - '' + cl.CompanyName as CompanyFullName
		,(Select count(*) from tReviewRound rr (nolock) Where rr.ReviewDeliverableKey = rd.ReviewDeliverableKey) as RoundCount
		,ps.ProjectStatus as ProjectStatus
		,ISNULL((Select count(*) from tActivity a (nolock) Where a.ParentActivityKey = 0 and a.ReviewDeliverableKey = rd.ReviewDeliverableKey and a.Completed = 0), 0) as OpenIssueCount
		,ISNULL((Select count(*) from tActivity a (nolock) Where a.ParentActivityKey = 0 and a.ReviewDeliverableKey = rd.ReviewDeliverableKey and a.Completed = 1), 0) as ClosedIssueCount
		,ISNULL((Select count(*) from tActivity a (nolock) inner join tActivityLink al (nolock) on a.ActivityKey = al.ActivityKey  Where al.Entity = ''tReviewDeliverable'' and al.EntityKey = rd.ReviewDeliverableKey and a.ParentActivityKey = 0), 0) as ConversationCount
		,p.ProjectColor
		,pt.ProjectTypeColor
		,p.Closed as ClosedProject
		,rd.CustomFieldKey
		,ofs.FieldSetKey
		,rd.ProjectKey
		,rd.ImageField
		,ISNULL(rd.StatusOrder, 0) as StatusOrder
		,ISNULL(rd.TaskOrder, 0) as TaskOrder
		,(SELECT ISNULL(MAX(ReviewRoundKey),0) FROM tReviewRound (nolock) WHERE ReviewDeliverableKey = rd.ReviewDeliverableKey AND Status > 1) AS LastReviewRoundKey
		,CASE a.Internal 
			WHEN 1 THEN ''Internal''
			WHEN 0 THEN ''External''
		 END AS CurrentStep
		,r.ReviewRoundKey
		,Case When a.ActiveStep = 1 then a.ApproverStatus 
		 Else
			Case When ISNULL(rd.Approved, 0) = 1 then case rd.ApprovedWithChanges when 1 then ''Approved With Changes'' else ''Approved'' end
			Else 
				Case 
					When r.Status = 5 then case r.ApprovedWithChanges when 1 then ''Approved With Changes'' else ''Approved'' end
					When r.Status = 4 then ''Cancelled''  
					When r.Status = 6 then ''Paused'' 
					When r.Status = 3 then ''Resubmit''
					When r.Status = 2 then ''Not Sent''
					When r.Status IS NULL or r.Status = 1 then ''Unsubmitted''
				End 
			End 
		 End as ApprovalStatus
		 ,r.RoundName
		 ,r.Status
		 ,dt.TypeName
		 ,dt.TypeColor
		 ,ISNULL(rd.TaskKey, @DefaultTaskKey) as TaskKey
		 ,Case When rd.TaskKey is null then @TaskName else t.TaskID + '' - '' + TaskName end as TaskName
		 ,Case When rd.TaskKey is null then 1 else 0 end as DefaultTaskSet
		 ,Case When rd.TaskKey is null then @DefaultTaskTracksBudget 
			else case when t.TaskKey = t.BudgetTaskKey then 1 else 0 end
		  end as DefaultTaskTracksBudget
		  ,@DefaultBudgetTaskKey as DefaultBudgetTaskKey
		  ,@DefaultBudgetTaskName as DefaultBudgetTaskName
		 ,a.Subject as CurrentStepName
		 ,t.AllowAnyone as TaskAllowAnyone
		 ,t.PercComp as TaskPercComp
		 ,t.PredecessorsComplete as TaskPredComplete
		 ,t.BudgetTaskKey
		 ,CASE ISNULL((Select count(*) from tTaskUser tu (nolock) where t.TaskKey = tu.TaskKey and tu.UserKey = @UserKey), 0)
			when 0 then 0 else 1
		end as UserIsAssigned
		,cf.*
		,att.AttachmentKey
		,att.Path
		,att.FileName
		,att.Size
		,att.FileID
		,p.OfficeKey
	From tReviewDeliverable rd (nolock)
		left outer join tDeliverableStatus s (nolock) on ISNULL(rd.DeliverableStatusKey, @DefaultDeliverableStatusKey) = s.DeliverableStatusKey
		left outer join tProject p (nolock) on rd.ProjectKey = p.ProjectKey AND rd.ProjectKey > 0
		left outer join tTask t (nolock) on rd.TaskKey = t.TaskKey
		left outer join tCampaign ca (nolock) on ca.CampaignKey = ISNULL(p.CampaignKey, CASE WHEN rd.ProjectKey < 0 THEN ABS(rd.ProjectKey) ELSE NULL END)
		left outer join tUser u (nolock) on u.UserKey = rd.OwnerKey
		left outer join tCompany cl (nolock) on p.ClientKey = cl.CompanyKey
		left outer join tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
		left outer join tUser am (nolock) on p.AccountManager = am.UserKey
		left outer join tProjectType pt (nolock) on p.ProjectTypeKey = pt.ProjectTypeKey
		left outer join tReviewRound r (NOLOCK) ON rd.ReviewDeliverableKey = r.ReviewDeliverableKey AND r.LatestRound = 1
		left outer join tApprovalStep a (nolock) on a.EntityKey = r.ReviewRoundKey and a.Entity = ''tReviewRound'' and a.ActiveStep = 1
		left outer join tDeliverableType dt (nolock) on rd.DeliverableTypeKey = dt.DeliverableTypeKey
		left outer join tObjectFieldSet ofs (nolock) on rd.CustomFieldKey = ofs.ObjectFieldSetKey
		LEFT OUTER JOIN #tCustomFields1 cf (nolock) ON rd.CustomFieldKey = cf.CustomFieldKey
		left outer join tAttachment att (nolock) on att.AttachmentKey = (SELECT TOP 1 AttachmentKey FROM tAttachment WHERE EntityKey = rd.ReviewDeliverableKey AND AssociatedEntity = ''tReviewDeliverable'')

	Where rd.CompanyKey = @CompanyKey
	AND (@ReviewDeliverableKey IS NULL OR rd.ReviewDeliverableKey = @ReviewDeliverableKey)
	and (@ProjectKey is not null OR rd.ProjectKey < 0 OR p.Active = 1)
	AND (@ProjectKey is null OR rd.ProjectKey = @ProjectKey)
	AND (
		@CampaignKey is null
		OR p.CampaignKey = @CampaignKey
		OR (rd.ProjectKey < 0 AND ABS(rd.ProjectKey) = @CampaignKey)
	)
	and (@ClientKey is null or p.ClientKey = @ClientKey or rd.ProjectKey < 0)
	AND (@HideCompletedTasks = 0 OR (@HideCompletedTasks = 1 and (t.PercComp < 100 OR t.TaskKey IS NULL)))
	AND (@HideApprovedCompleted = 0 OR (@HideApprovedCompleted = 1 and ISNULL(rd.Completed, 0) = 0))
	and (@RestrictToGLCompany = 0
			Or rd.ProjectKey < 0  -- campaign deliverables have no GL company
			Or p.GLCompanyKey in (select GLCompanyKey from tUserGLCompanyAccess (nolock) where UserKey = @UserKey)
			)
		and (
			@ViewAny = 1
			OR rd.ProjectKey < 0  -- campaign deliverables not restricted to project assignment
			OR p.ProjectKey in (Select ProjectKey from tAssignment a (nolock) Where UserKey = @UserKey)
			)
	 AND isnull(t.HideFromDeliverable,0) <> 1
	/*	and (@AccountManagerKey is null OR p.AccountManager = @AccountManagerKey)
		and (@OwnerKey is null OR rd.OwnerKey = @OwnerKey)
		and (@ProjectStatusKey is null OR p.ProjectStatusKey = @ProjectStatusKey)			
    */



'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptTaskGet]'
GO
IF OBJECT_ID(N'[dbo].[sptTaskGet]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptTaskGet]
	@TaskKey int

AS --Encrypt

/*
|| When      Who Rel	   What
|| 07/09/15  GAR 10.5.9.4  Added constraint description.
|| 07/29/15  GAR 10.5.9.4  Change Work Type to get it from a direct link to task instead of master task.
|| 11/20/15  CRG 10.5.9.8  Added SubtaskCount and Duration for use by ScheduleManager in Platinum
|| 02/05/16  RLB 10.6.0.0  Added fields task update in plat
|| 02/09/17  RLB 10.6.1.3  Added for enhancement 328679
|| 11/10/17  RLB 10.6.2.2  Added BudgetTaskName
|| 04/18/19  CRG 19.0.4.0  (454523) Added PlanningProject
|| 08/20/19  CRG 19.0.8.0  (475158) Added PriorityName for Task Edit screen
|| 10/16/19  GAR 19.1.1.0  (464118) Added CustomerID 
|| 10/13/22  RLB 22.11.20  (610106) added pull of LimitProjectServices
|| 05/08/23  CRG 23.06.18  (604775) Changed Priority to TaskPriorityKey
|| 08/01/24  CRG 24.09.15  (675913) Added ProjectActive
|| 01/05/26  CRG 26.02.15  (548907) Added FreqName
|| 05/13/26   CRG 26.06.14 (724211) Added new recurring frequency options
*/

		SELECT t.*
		      ,p.GetRateFrom
		      ,p.ProjectStatusKey
		      ,p.ProjectNumber
		      ,p.ProjectName
			  ,p.ProjectNumber + '' - '' + p.ProjectName AS Project
			  ,ISNULL(c.CompanyName, ''No Client'') AS CompanyName
			  ,c.CustomerID
			  ,p.ClientKey
			  ,p.StartDate as ProjectStartDate
			  ,p.CompleteDate as ProjectCompleteDate
			  ,p.PercComp as ProjectPercComp
			  ,p.ProjectStatusKey
			  ,ps.ProjectStatus
			  ,ps.ProjectStatusID
			  ,pbs.ProjectBillingStatusKey
			  ,pbs.ProjectBillingStatus
			  ,pbs.ProjectBillingStatusID
			  ,ISNULL(u.UserName, ''No Account Manager'') AS UserName
			  ,u.UserKey as AccountManager
			  ,ISNULL(pt.ProjectTypeName, ''No Project Type'') AS ProjectTypeName
			  ,pt.ProjectTypeKey
			  ,ISNULL(ca.CampaignName, ''No Campaign'') AS CampaignName
			  ,ca.CampaignKey
			  ,ISNULL(cps.SegmentName, ''No Campaign Segment'') AS CampaignSegmentName
			  ,cps.CampaignSegmentKey
			  ,CASE ts.ScheduleTask WHEN 1 THEN t.SummaryTaskKey ELSE 0 END AS SummaryTaskKey
			  ,ts.TaskName as SummaryTaskName
		      ,ts.TaskID as SummaryTaskID
		      ,case 
				when ts.TaskID is null then ts.TaskName
				else ts.TaskID + '' '' + ts.TaskName
				end as SummaryTaskFullName
		      ,tb.TaskID as BudgetTaskID
			  ,tb.TaskName as BudgetTaskName
		      ,case 
				when tb.TaskID is null then tb.TaskName
				else tb.TaskID + '' '' + tb.TaskName
				end as BudgetTaskFullName
		      ,bi.WorkTypeName
		      ,isnull((select count(*) 
						from tTaskPredecessor tp (nolock) 
						where tp.TaskKey = t.TaskKey),0)
		       + isnull((select count(*) 
						from tTaskPredecessor tp (nolock) 
						where tp.PredecessorKey = t.TaskKey),0) as PredecessorRelCount
			  ,(select count(*) from tTask (nolock) 
				where tTask.SummaryTaskKey = t.TaskKey
				and isnull(tTask.ScheduleTask,0) = 1) as ScheduledChildCount
		      ,(Select Count(*) from tTaskUser (nolock) Where tTaskUser.TaskKey = t.TaskKey) as AssignmentCount
			  ,(SELECT COUNT(*) FROM tActivity a (nolock) INNER JOIN tActivityLink al (nolock) ON a.ActivityKey = al.ActivityKey WHERE al.Entity = ''tTask'' AND al.EntityKey = t.TaskKey AND a.Completed = 0) AS OpenActivities
			  ,(SELECT COUNT(*) FROM tActivity a (nolock) WHERE a.TaskKey = t.TaskKey AND Completed = 0 AND a.ActivityEntity = ''ToDo'' AND ParentActivityKey = 0) AS OpenToDos
		      ,tat.TaskAssignmentType
		      ,CASE 
					WHEN ISNULL(t.TaskConstraint,0) = 0 THEN 
						CASE 
							WHEN p.ScheduleDirection = 1 THEN ''As Soon As Possible'' 
							ELSE ''As Late As Possible''
						END
					WHEN ISNULL(t.TaskConstraint,0) = 1 THEN ''Must Start On'' 
					WHEN ISNULL(t.TaskConstraint,0) = 2 THEN ''Must Finish On'' 
					WHEN ISNULL(t.TaskConstraint,0) = 3 THEN ''Finish No Earlier Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 4 THEN ''Finish No Later Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 5 THEN ''Start No Earlier Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 6 THEN ''Start No Later Than'' 
					WHEN ISNULL(t.TaskConstraint,0) = 7 THEN ''Duration Of Project'' 
					ELSE ''Must Start On''
			  END AS ConstraintName
			  --,isnull(bi.WorkTypeName, '''') AS BillingItemName
			  ,tts.SegmentName
			  ,p.CompanyKey
			  ,CASE 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 0 THEN ''Any Day''
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 1 THEN ''Sunday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 2 THEN ''Monday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 3 THEN ''Tuesday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 4 THEN ''Wednesday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 5 THEN ''Thursday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 6 THEN ''Friday'' 
					WHEN ISNULL(t.ConstraintDayOfTheWeek,0) = 7 THEN ''Saturday'' 
					ELSE ''Any Day''
			  END AS ConstraintDayOfTheWeekName
			  ,(SELECT COUNT(*) FROM tTask t2 (NOLOCK) 
				WHERE t2.ProjectKey = p.ProjectKey
				AND   t2.SummaryTaskKey = t.TaskKey) AS SubtaskCount
			  ,t.PlanDuration AS Duration
			  ,ISNULL(tcps.ProjectStatus, '''') as TCProjectStatus
			  ,ISNULL(tcps.ProjectStatusID, '''') as TCProjectStatusID
			  ,p.PlanningProject
			  ,p.LimitProjectServices
			  ,tp.PriorityName
			  ,p.Active AS ProjectActive
			  ,CASE
				WHEN ISNULL(t.RecurringFreq, 0) = 0 THEN ''None''
				WHEN ISNULL(t.RecurringFreq, 0) = 1 THEN ''Weekly''
				WHEN ISNULL(t.RecurringFreq, 0) = 2 THEN ''Monthly (Date)''
				WHEN ISNULL(t.RecurringFreq, 0) = 3 THEN ''Monthly (Relative)''
				WHEN ISNULL(t.RecurringFreq, 0) = 4 THEN ''Quarterly''
			   END AS FreqName
		FROM tTask t (nolock)
			inner join tProject p (nolock) on t.ProjectKey = p.ProjectKey
			left outer join tTask ts (nolock) on t.SummaryTaskKey = ts.TaskKey
			left outer join tTask tb (nolock) on t.BudgetTaskKey = tb.TaskKey
			left outer join tMasterTask mt (nolock) on t.MasterTaskKey = mt.MasterTaskKey
			left outer join tWorkType wt (nolock) on mt.WorkTypeKey = wt.WorkTypeKey	
			left outer join tTaskAssignmentType tat (nolock) on t.TaskAssignmentTypeKey = tat.TaskAssignmentTypeKey
			left outer join tWorkType bi (nolock) on t.WorkTypeKey = bi.WorkTypeKey
			left outer join tTimelineSegment tts on t.TimelineSegmentKey = tts.TimelineSegmentKey
			left outer join tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
			left outer join tProjectStatus tcps (nolock) on t.TCProjectStatusKey = tcps.ProjectStatusKey
			left outer join tProjectBillingStatus pbs (nolock) on p.ProjectBillingStatusKey = pbs.ProjectBillingStatusKey
			left outer join tCompany c (nolock) ON p.ClientKey = c.CompanyKey
			left outer join vUserName u (nolock) ON p.AccountManager = u.UserKey
			left outer join tProjectType pt (nolock) ON p.ProjectTypeKey = pt.ProjectTypeKey
			left outer join tCampaign ca (nolock) ON p.CampaignKey = ca.CampaignKey
			left outer join tCampaignSegment cps (nolock) ON p.CampaignSegmentKey = cps.CampaignSegmentKey
			left outer join tTaskPriority tp (nolock) ON t.TaskPriorityKey = tp.TaskPriorityKey
		WHERE
			t.TaskKey = @TaskKey

	RETURN 1




'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptCMFolderItemsGet]'
GO
IF OBJECT_ID(N'[dbo].[sptCMFolderItemsGet]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER Procedure [dbo].[sptCMFolderItemsGet]
(
	@userKey INT,
	@companyKey INT,
	@cmFolderKey INT,
	@lastModifiedDate DATETIME,
	@application VARCHAR(100) = ''''
)

As --Encrypt

  /*
  || When     Who Rel       What
  || 06/26/08 QMD 10.5      Created for initial Release of 10.5
  || 09/14/09 QMD 10.5.1.0  Added clause for other syncs
  ||                        Added clause for no folder sync
  || 09/22/09 QMD 10.5.1.1  Added Security Group check
  || 02/15/11 QMD 10.5.4.1  Added logic to use the Include In SyncML option
  || 08/15/12 QMD 10.5.5.9  Added logic to sync contacts with google
  || 08/24/12 QMD 10.5.5.9  Added street2 and street3 for google sync
  || 09/12/12 KMC 10.5.6.0  Added GoogleContacts application option
  || 10/11/12 QMD 10.5.6.1  Added street2 and street3 to all queries
  || 05/07/13 QMD 10.5.6.8  Added a replace for a odd character
  || 09/27/13 QMD 10.5.7.3  Added carddav to in
  || 07/09/26 KMC 26.7.19  Removed LastSync column that is no longer used
*/

DECLARE @canEdit TINYINT 
DECLARE @canAdd TINYINT

SET @canEdit = 0
SET @canAdd = 0

IF @application in ( ''syncml'' )
   BEGIN
   
		IF @cmFolderKey = -1 
		   BEGIN 
				exec @canEdit = sptUserGetRight @userKey, ''editOtherContacts''
				exec @canAdd = sptUserGetRight @userKey, ''addContacts''
				
				-- if can edit others then return everything with ownerCompanyKey
				IF @canEdit = 1 
					-- Get the contacts for the given companyKey
					SELECT	CMFolderKey = @cmFolderKey, u.* , comp.CompanyName,

							Replace(bus.Address1,'''','' '')AS BusinessStreet,
							Replace(bus.Address2,'''','' '') AS BusinessStreet2,
							Replace(bus.Address3,'''','' '') AS BusinessStreet3,							
							bus.City AS BusinessCity, 
							bus.State AS BusinessState,
							bus.PostalCode AS BusinessPostalCode,
							bus.Country AS BusinessCountry,

							Replace(home.Address1,'''','' '') AS HomeStreet,
							Replace(home.Address2,'''','' '') as HomeStreet2,
							Replace(home.Address3,'''','' '') as HomeStreet3,							
							home.City AS HomeCity, 
							home.State AS HomeState,
							home.PostalCode AS HomePostalCode,
							home.Country AS HomeCountry,

							Replace(other.Address1,'''','' '') AS OtherStreet,
							other.City AS OtherCity, 
							other.State AS OtherState,
							other.PostalCode AS OtherPostalCode,
							other.Country AS OtherCountry

					FROM	tUser u (NOLOCK)
											LEFT JOIN tCompany comp (NOLOCK) ON u.CompanyKey = comp.CompanyKey
											LEFT JOIN tAddress bus (NOLOCK) ON bus.AddressKey = u.AddressKey
											LEFT JOIN tAddress home (NOLOCK) ON home.AddressKey = u.HomeAddressKey
											LEFT JOIN tAddress other (NOLOCK) ON other.AddressKey = u.OtherAddressKey
					WHERE	u.LastModified > @lastModifiedDate
							AND u.OwnerCompanyKey = @companyKey
									
				ELSE IF @canAdd = 1
					-- Get items for only the userKey passed in
					SELECT	CMFolderKey = @cmFolderKey, u.* , comp.CompanyName,

							Replace(bus.Address1,'''','' '') AS BusinessStreet,
							Replace(bus.Address2,'''','' '') AS BusinessStreet2,
							Replace(bus.Address3,'''','' '') AS BusinessStreet3,							
							bus.City AS BusinessCity, 
							bus.State AS BusinessState,
							bus.PostalCode AS BusinessPostalCode,
							bus.Country AS BusinessCountry,

							Replace(home.Address1,'''','' '') AS HomeStreet,
							Replace(home.Address2,'''','' '') as HomeStreet2,
							Replace(home.Address3,'''','' '') as HomeStreet3,								
							home.City AS HomeCity, 
							home.State AS HomeState,
							home.PostalCode AS HomePostalCode,
							home.Country AS HomeCountry,

							Replace(other.Address1,'''','' '') AS OtherStreet,
							Replace(other.Address2,'''','' '') AS OtherStreet2,
							Replace(other.Address3,'''','' '') AS OtherStreet3,								
							other.City AS OtherCity, 
							other.State AS OtherState,
							other.PostalCode AS OtherPostalCode,
							other.Country AS OtherCountry

					FROM	tUser u (NOLOCK)
											LEFT JOIN tCompany comp (NOLOCK) ON u.CompanyKey = comp.CompanyKey
											LEFT JOIN tAddress bus (NOLOCK) ON bus.AddressKey = u.AddressKey
											LEFT JOIN tAddress home (NOLOCK) ON home.AddressKey = u.HomeAddressKey
											LEFT JOIN tAddress other (NOLOCK) ON other.AddressKey = u.OtherAddressKey
					WHERE	u.LastModified > @lastModifiedDate
							AND u.OwnerKey = @userKey
							AND u.OwnerCompanyKey = @companyKey
			END					
		ELSE		
   			-- Get the folders and items for the userkey 	
			SELECT	c.CMFolderKey, u.* , comp.CompanyName,

					Replace(bus.Address1,'''','' '') AS BusinessStreet,
					Replace(bus.Address2,'''','' '') AS BusinessStreet2,
					Replace(bus.Address3,'''','' '') AS BusinessStreet3,					
					bus.City AS BusinessCity, 
					bus.State AS BusinessState,
					bus.PostalCode AS BusinessPostalCode,
					bus.Country AS BusinessCountry,

					Replace(home.Address1,'''','' '') AS HomeStreet,
					Replace(home.Address2,'''','' '') as HomeStreet2,
					Replace(home.Address3,'''','' '') as HomeStreet3,					
					home.City AS HomeCity, 
					home.State AS HomeState,
					home.PostalCode AS HomePostalCode,
					home.Country AS HomeCountry,

					Replace(other.Address1,'''','' '') AS OtherStreet,
					Replace(other.Address2,'''','' '') AS OtherStreet2,
					Replace(other.Address3,'''','' '') AS OtherStreet3,					
					other.City AS OtherCity, 
					other.State AS OtherState,
					other.PostalCode AS OtherPostalCode,
					other.Country AS OtherCountry

			FROM	tCMFolder c (NOLOCK) INNER JOIN tUser u (NOLOCK) ON u.CMFolderKey = c.CMFolderKey
									LEFT JOIN tCompany comp (NOLOCK) ON u.CompanyKey = comp.CompanyKey
									LEFT JOIN tAddress bus (NOLOCK) ON bus.AddressKey = u.AddressKey
									LEFT JOIN tAddress home (NOLOCK) ON home.AddressKey = u.HomeAddressKey
									LEFT JOIN tAddress other (NOLOCK) ON other.AddressKey = u.OtherAddressKey
			WHERE	(c.CMFolderKey = @cmFolderKey OR c.CMFolderKey IN (SELECT CMFolderKey FROM tCMFolderIncludeInSync WHERE UserKey = @userKey))
					AND u.LastModified > @lastModifiedDate
					AND c.CompanyKey = @companyKey
					AND ( 
						  c.UserKey = @userKey 
							OR 
						  EXISTS (SELECT EntityKey 
								  FROM	 tCMFolderSecurity 
								  WHERE	 (CanView = 1 OR CanAdd = 1) 
										 AND Entity = ''tUser''
										 AND CMFolderKey = c.CMFolderKey)
							OR
						  EXISTS (SELECT EntityKey
								  FROM tCMFolderSecurity fs (NOLOCK) INNER JOIN tUser u (NOLOCK) ON fs.EntityKey = u.SecurityGroupKey
								  WHERE	 (CanView = 1 OR CanAdd = 1) 
										 AND fs.Entity = ''tSecurityGroup''
										 AND fs.CMFolderKey = c.CMFolderKey)		
							 )				
   END
ELSE IF @application in ( ''carddav'' )  
   BEGIN
	-- Get the folders and items for the userkey 	
			SELECT	c.CMFolderKey, u.* , comp.CompanyName,

					Replace(bus.Address1,'''','' '') AS BusinessStreet,
					Replace(bus.Address2,'''','' '') AS BusinessStreet2,
					Replace(bus.Address3,'''','' '') AS BusinessStreet3,					
					bus.City AS BusinessCity, 
					bus.State AS BusinessState,
					bus.PostalCode AS BusinessPostalCode,
					bus.Country AS BusinessCountry,

					Replace(home.Address1,'''','' '') AS HomeStreet,
					Replace(home.Address2,'''','' '') as HomeStreet2,
					Replace(home.Address3,'''','' '') as HomeStreet3,					
					home.City AS HomeCity, 
					home.State AS HomeState,
					home.PostalCode AS HomePostalCode,
					home.Country AS HomeCountry,

					Replace(other.Address1,'''','' '') AS OtherStreet,
					Replace(other.Address2,'''','' '') AS OtherStreet2,
					Replace(other.Address3,'''','' '') AS OtherStreet3,					
					other.City AS OtherCity, 
					other.State AS OtherState,
					other.PostalCode AS OtherPostalCode,
					other.Country AS OtherCountry

			FROM	tCMFolder c (NOLOCK) INNER JOIN tUser u (NOLOCK) ON u.CMFolderKey = c.CMFolderKey
									LEFT JOIN tCompany comp (NOLOCK) ON u.CompanyKey = comp.CompanyKey
									LEFT JOIN tAddress bus (NOLOCK) ON bus.AddressKey = u.AddressKey
									LEFT JOIN tAddress home (NOLOCK) ON home.AddressKey = u.HomeAddressKey
									LEFT JOIN tAddress other (NOLOCK) ON other.AddressKey = u.OtherAddressKey
			WHERE	c.CMFolderKey = @cmFolderKey 
					AND u.LastModified > @lastModifiedDate
					AND c.CompanyKey = @companyKey
					AND ( 
						  c.UserKey = @userKey 
							OR 
						  EXISTS (SELECT EntityKey 
								  FROM	 tCMFolderSecurity 
								  WHERE	 (CanView = 1 OR CanAdd = 1) 
										 AND Entity = ''tUser''
										 AND CMFolderKey = c.CMFolderKey)
							OR
						  EXISTS (SELECT EntityKey
								  FROM tCMFolderSecurity fs (NOLOCK) INNER JOIN tUser u (NOLOCK) ON fs.EntityKey = u.SecurityGroupKey
								  WHERE	 (CanView = 1 OR CanAdd = 1) 
										 AND fs.Entity = ''tSecurityGroup''
										 AND fs.CMFolderKey = c.CMFolderKey)		
							 )			

   END
ELSE IF @application in (''google'', ''googlecontacts'')
	BEGIN
		-- Get the folders and items for the userkey 
		SELECT	c.CMFolderKey, s.FolderID, s.LastModified AS FolderLastModified, s.SyncDirection, u.* , comp.CompanyName,

				bus.Address1 AS BusinessStreet,
				bus.Address2 AS BusinessStreet2,
				bus.Address3 AS BusinessStreet3,
				bus.City AS BusinessCity, 
				bus.State AS BusinessState,
				bus.PostalCode AS BusinessPostalCode,
				bus.Country AS BusinessCountry,

				home.Address1 AS HomeStreet,
				home.Address2 as HomeStreet2,
				home.Address3 as HomeStreet3,
				home.City AS HomeCity, 
				home.State AS HomeState,
				home.PostalCode AS HomePostalCode,
				home.Country AS HomeCountry,

				other.Address1 AS OtherStreet,
				other.Address2 AS OtherStreet2,
				other.Address3 AS OtherStreet3,
				other.City AS OtherCity, 
				other.State AS OtherState,
				other.PostalCode AS OtherPostalCode,
				other.Country AS OtherCountry

		FROM	tCMFolder c (NOLOCK) INNER JOIN tSyncFolder s (NOLOCK) ON c.GoogleSyncFolderKey = s.SyncFolderKey
								INNER JOIN tUser u (NOLOCK) ON u.CMFolderKey = c.CMFolderKey
								LEFT JOIN tCompany comp (NOLOCK) ON u.CompanyKey = comp.CompanyKey
								LEFT JOIN tAddress bus (NOLOCK) ON bus.AddressKey = u.AddressKey
								LEFT JOIN tAddress home (NOLOCK) ON home.AddressKey = u.HomeAddressKey
								LEFT JOIN tAddress other (NOLOCK) ON other.AddressKey = u.OtherAddressKey
		WHERE	c.CMFolderKey = @cmFolderKey
				AND u.LastModified > @lastModifiedDate
				AND c.CompanyKey = @companyKey
				AND ( 
					  c.UserKey = @userKey 
						OR 
					  EXISTS (SELECT EntityKey 
							  FROM	 tCMFolderSecurity 
							  WHERE	 (CanView = 1 OR CanAdd = 1) 
									 AND Entity = ''tUser''
									 AND CMFolderKey = c.CMFolderKey)
						OR
					  EXISTS (SELECT EntityKey
							  FROM tCMFolderSecurity fs (NOLOCK) INNER JOIN tUser u (NOLOCK) ON fs.EntityKey = u.SecurityGroupKey
							  WHERE	 (CanView = 1 OR CanAdd = 1) 
									 AND fs.Entity = ''tSecurityGroup''
									 AND fs.CMFolderKey = c.CMFolderKey)									 
					 )
   END
ELSE
   BEGIN
		-- Get the folders and items for the userkey 
		SELECT	c.CMFolderKey, s.FolderID, s.LastModified AS FolderLastModified, s.SyncDirection, u.* , comp.CompanyName,

				bus.Address1 AS BusinessStreet,
				bus.Address2 AS BusinessStreet2,
				bus.Address3 AS BusinessStreet3,
				bus.City AS BusinessCity, 
				bus.State AS BusinessState,
				bus.PostalCode AS BusinessPostalCode,
				bus.Country AS BusinessCountry,

				home.Address1 AS HomeStreet,
				home.Address2 as HomeStreet2,
				home.Address3 as HomeStreet3,				
				home.City AS HomeCity, 
				home.State AS HomeState,
				home.PostalCode AS HomePostalCode,
				home.Country AS HomeCountry,

				other.Address1 AS OtherStreet,
				other.Address2 AS OtherStreet2,
				other.Address3 AS OtherStreet3,				
				other.City AS OtherCity, 
				other.State AS OtherState,
				other.PostalCode AS OtherPostalCode,
				other.Country AS OtherCountry

		FROM	tCMFolder c (NOLOCK) INNER JOIN tSyncFolder s (NOLOCK) ON c.SyncFolderKey = s.SyncFolderKey
								INNER JOIN tUser u (NOLOCK) ON u.CMFolderKey = c.CMFolderKey
								LEFT JOIN tCompany comp (NOLOCK) ON u.CompanyKey = comp.CompanyKey
								LEFT JOIN tAddress bus (NOLOCK) ON bus.AddressKey = u.AddressKey
								LEFT JOIN tAddress home (NOLOCK) ON home.AddressKey = u.HomeAddressKey
								LEFT JOIN tAddress other (NOLOCK) ON other.AddressKey = u.OtherAddressKey
		WHERE	c.CMFolderKey = @cmFolderKey
				AND u.LastModified > @lastModifiedDate
				AND c.CompanyKey = @companyKey
				AND ( 
					  c.UserKey = @userKey 
						OR 
					  EXISTS (SELECT EntityKey 
							  FROM	 tCMFolderSecurity 
							  WHERE	 (CanView = 1 OR CanAdd = 1) 
									 AND Entity = ''tUser''
									 AND CMFolderKey = c.CMFolderKey)
						OR
					  EXISTS (SELECT EntityKey
							  FROM tCMFolderSecurity fs (NOLOCK) INNER JOIN tUser u (NOLOCK) ON fs.EntityKey = u.SecurityGroupKey
							  WHERE	 (CanView = 1 OR CanAdd = 1) 
									 AND fs.Entity = ''tSecurityGroup''
									 AND fs.CMFolderKey = c.CMFolderKey)									 
					 )
   END

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptSyncItemClean]'
GO
IF OBJECT_ID(N'[dbo].[sptSyncItemClean]', 'P') IS NOT NULL
EXEC sp_executesql N'


ALTER PROCEDURE [dbo].[sptSyncItemClean]
	@CMFolderKey INT,
	@UserKey INT,
	@CompanyKey INT
AS --Encrypt

/*
|| When     Who Rel      What
|| 08/29/09 QMD 10.5.1.0 Initial Release - cleans up tSyncItem, tSyncActivity to allow for a clean sync
|| 09/08/09 QMD 10.5.1.1 Added update to tSyncFolder and made companykey an int .. not varchar
|| 08/26/10 QMD 10.5.3.4 Added logic to check for public folders to clean up the tsyncitem table
|| 04/19/11 QMD 10.5.4.3 Added logic to check for googlesyncfolderkey
|| 08/14/12 QMD 10.5.5.9 Added googleLastSync to update
|| 12/02/14	KMC 10.5.8.6 Updated delete of tSyncItem to handle change to FolderID for Google ClaDAV
|| 12/26/14 KMC 10.5.8.7 Updated for public folders so GoogleLastSyncDate is cleared out
|| 07/09/26 KMC 26.7.19  Removed LastSync column that is no longer used
*/	

DECLARE @folder VARCHAR(1000)
DECLARE @syncFolderKey INT

SET @syncFolderKey = 0

	--Check if CMFolderKey is public folder.  If it is set @UserKey = 0
	IF EXISTS (SELECT * FROM tCMFolder (NOLOCK) WHERE UserKey = 0 AND CMFolderKey = @CMFolderKey)
		SELECT @UserKey = 0

	--Get Folder Info
	IF EXISTS (SELECT * FROM tCMFolder (NOLOCK) WHERE (CMFolderKey = @CMFolderKey AND SyncFolderKey IS NOT NULL) OR (CMFolderKey = @CMFolderKey AND GoogleSyncFolderKey IS NOT NULL))
		SELECT	@folder = FolderID, @syncFolderKey = s.SyncFolderKey
		FROM	tSyncFolder s (NOLOCK) INNER JOIN tCMFolder c (NOLOCK) ON s.SyncFolderKey = c.SyncFolderKey OR s.SyncFolderKey = c.GoogleSyncFolderKey
		WHERE	(s.UserKey = @UserKey or @UserKey = 0)
				AND s.CompanyKey = @CompanyKey
				AND c.CMFolderKey = @CMFolderKey
	
	--Check for syncml
	ELSE IF EXISTS (SELECT SourceURI FROM tSyncActivity (NOLOCK) WHERE CMFolderKey = @CMFolderKey AND UserKey = @UserKey AND CompanyKey = @CompanyKey)
		SELECT	@folder = SourceURI
		FROM	tSyncActivity (NOLOCK)
		WHERE	CMFolderKey = @CMFolderKey 
				AND UserKey = @UserKey 
				AND CompanyKey = @CompanyKey

	BEGIN TRAN
			
		DELETE tSyncActivity WHERE UserKey = @UserKey AND CompanyKey = @CompanyKey AND CMFolderKey = @CMFolderKey
		IF @@ERROR <> 0 
		  BEGIN
			ROLLBACK TRAN
			RETURN -1
		  END 
	
		DELETE tSyncItem WHERE CompanyKey = @CompanyKey AND ApplicationFolderKey = @CMFolderKey AND DataStoreFolderID like (''%'' + @folder + ''%'')
		IF @@ERROR <> 0
		   BEGIN
			 ROLLBACK TRAN
			 RETURN -2
		   END 
		
		IF @syncFolderKey > 0
			BEGIN
				UPDATE tSyncFolder SET GoogleLastSync = NULL WHERE SyncFolderKey = @syncFolderKey
			  IF @@ERROR <> 0
				BEGIN
				  ROLLBACK TRAN
				  RETURN -2
				END 
			END
			  
	COMMIT TRAN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptCompanyUpdateVendor]'
GO
IF OBJECT_ID(N'[dbo].[sptCompanyUpdateVendor]', 'P') IS NOT NULL
EXEC sp_executesql N'ALTER PROCEDURE [dbo].[sptCompanyUpdateVendor]
	@CompanyKey int,
	@OwnerCompanyKey int,
	@CompanyName nvarchar(200),
	@VendorID nvarchar(50),
	@Vendor tinyint,
	@OverheadVendor tinyint,
	@OnHold tinyint,
	@VendorDownloaded tinyint,
	@WebSite varchar(100),
	@Phone varchar(50),
	@Fax varchar(50),
	@Active tinyint,
	@DefaultExpenseAccountKey int,
	@DefaultAPAccountKey int,
	@VendorSalesTaxKey int,
	@VendorSalesTax2Key int,
	@DefaultAPApproverKey int,
	@DefaultMemo nvarchar(500),
	@TermsDays int,
	@TermsPercent decimal(24, 4),
	@TermsNet int,
	@Type1099 smallint,
	@Box1099 varchar(10),
	@FATCAFilingRequirement tinyint,
	@DBA varchar(200),
	@UseDBAForPayment tinyint,
	@EINNumber varchar(100),
	@CCAccepted tinyint,
	@CCAccountKey int,
	@EmailCCToAddress varchar(200),
	@EmailACHToAddress varchar(200),
	@VCardAccepted tinyint,
	@OnePaymentPerVoucher tinyint,
	@CCPayeeName varchar(50),
	@BankAccountNumber varchar(500),
	@BankRoutingNumber varchar(500),
	@BankAccountName varchar(100),
	@BankAccountTypeKey int,
	@PaymentAddressKey int,
	@Address1 varchar(100),
	@Address2 varchar(100),
	@Address3 varchar(100),
	@City varchar(100),
	@State varchar(50),
	@PostalCode varchar(20),
	@Country varchar(50),
	@AddressName varchar(200),
	@PAINEnabled tinyint,
	@BIC varchar(20),
	@IBAN varchar(34),
	@CountryCode char(2),
	@CurrencyID varchar(10),
	@ACHEnabled tinyint,
	@POHeaderStandardTextKey int,
	@POFooterStandardTextKey int,
	@ContactOwnerKey int = NULL,
	@ABAEnabled tinyint,
	@UserKey int,
	@ActiveVendor tinyint = 1,
	@UseDBAForPayment1099 tinyint,
	@AvalaraTaxCodeKey int = null,
	@UseAltAddress tinyint

AS --Encrypt

/*
|| When     Who Rel      What
|| 10/25/16 MFT 10.6.0.9 Created
|| 11/08/16 MFT 10.6.0.9 Added CCAccountKey
|| 11/09/16 MFT 10.6.0.9 Added OnHold, VendorDownloaded, FATCAFilingRequirement, UseDBAForPayment, DefaultMemo, OnePaymentPerVoucher, CCPayeeName, BankAccountNumber, BankRoutingNumber, BankAccountName, PaymentAddressKey
|| 12/01/16 MFT 10.6.1.0 Added fields for PAIN.001: PAINEnabled, BIC, IBAN, CountryCode
|| 03/30/17 WDF 10.6.1.4 (338874) Added CurrencyID
|| 03/31/17 MCM 10.6.1.4 (339415) Added GLCompanyKey
|| 04/14/17 MFT 10.6.1.5 (340791) Increased size of IBAN from 20 to 34
|| 06/19/17 MFT 10.6.1.7 (351119) Added Box1099 param/field
|| 06/21/17 MFT 10.6.1.7 Removed GLCompanyKey param/field
|| 07/16/17 MFT 10.6.1.8 Added ACHEnabled param/field
|| 01/24/19 GHL 19.2.0.0 Added @POHeaderStandardTextKey and @POFooterStandardTextKey for Spark44 customization
|| 02/12/19 GHL 19.3.0.0 (445391) Added UserKey param to set CreatedBy/ModifiedBy 
|| 11/06/19 MCM 19.1.2.0 (487131) Adding ContactOwnerKey so can default it to the current user
|| 01/02/20 MFT 20.0.2.0 (478136) Added ABAEnabled param/field
|| 02/02/21 RLS 21.0.3.0 (546075) Changed @CompanyName to nvarchar
|| 11/12/21 RLS 21.12.19 (574346) Changed @VendorID to nvarchar
|| 12/20/21 MCM 22.01.xx (559367) Added EmailACHToAddress
|| 01/27/22 GHL 22.02.20.0000 (564369) Added ActiveVendor param
|| 07/19/22 MCM 22.08.xx (593839) Added BankAccountTypeKey param
|| 12/13/22 GAR 23.01.15 (DEV2605-701) Added AvalaraTaxCodeKey to vendor record
|| 08/14/23 RLS 23.09.17 (648210) Changed @DefaultMemo to nvarchar
|| 11/29/23 RLB 23.12.17 (653809) added UseDBAForPayment1099 to seperate the options
|| 05/15/26 AMP 26.06.14 (720174) Added UseAltAddress to be used on printed 1099
*/

IF @Vendor = 1
BEGIN
	IF EXISTS(SELECT 1 FROM tCompany (nolock) WHERE 
			CompanyKey <> @CompanyKey AND 
			OwnerCompanyKey = @OwnerCompanyKey AND
			Vendor = 1 AND
			VendorID = @VendorID)
	RETURN -500
END

DECLARE @AddressKey int

IF ISNULL(@CompanyKey, 0) > 0
	UPDATE
		tCompany
	SET
		OwnerCompanyKey = @OwnerCompanyKey,
		CompanyName = @CompanyName,
		VendorID = @VendorID,
		Vendor = @Vendor,
		OverheadVendor = @OverheadVendor,
		OnHold = @OnHold,
		VendorDownloaded = @VendorDownloaded,
		WebSite = @WebSite,
		Phone = @Phone,
		Fax = @Fax,
		Active = @Active,
		DefaultExpenseAccountKey = @DefaultExpenseAccountKey,
		DefaultAPAccountKey = @DefaultAPAccountKey,
		VendorSalesTaxKey = @VendorSalesTaxKey,
		VendorSalesTax2Key = @VendorSalesTax2Key,
		DefaultAPApproverKey = @DefaultAPApproverKey,
		DefaultMemo = @DefaultMemo,
		TermsDays = @TermsDays,
		TermsPercent = @TermsPercent,
		TermsNet = @TermsNet,
		Type1099 = @Type1099,
		Box1099 = @Box1099,
		FATCAFilingRequirement = @FATCAFilingRequirement,
		DBA = @DBA,
		UseDBAForPayment = @UseDBAForPayment,
		EINNumber = @EINNumber,
		CCAccepted = @CCAccepted,
		CCAccountKey = @CCAccountKey,
		EmailCCToAddress = @EmailCCToAddress,
		EmailACHToAddress = @EmailACHToAddress,
		VCardAccepted = @VCardAccepted,
		OnePaymentPerVoucher = @OnePaymentPerVoucher,
		CCPayeeName = @CCPayeeName,
		BankAccountNumber = @BankAccountNumber,
		BankRoutingNumber = @BankRoutingNumber,
		BankAccountName = @BankAccountName,
		BankAccountTypeKey = @BankAccountTypeKey,
		PaymentAddressKey = @PaymentAddressKey,
		PAINEnabled = @PAINEnabled,
		BIC = @BIC,
		IBAN = @IBAN,
		CountryCode = @CountryCode,
		CurrencyID = @CurrencyID,
		ACHEnabled = @ACHEnabled,
		POHeaderStandardTextKey = @POHeaderStandardTextKey,
		POFooterStandardTextKey = @POFooterStandardTextKey,
		ModifiedBy = @UserKey,
		ContactOwnerKey = @ContactOwnerKey,
		ABAEnabled = @ABAEnabled,
		DateUpdated = getutcdate(),
		ActiveVendor = @ActiveVendor,
		AvalaraTaxCodeKey = @AvalaraTaxCodeKey,
		UseDBAForPayment1099 = @UseDBAForPayment1099,
		UseAltAddress = @UseAltAddress
	WHERE
		CompanyKey = @CompanyKey
ELSE
	BEGIN
		IF @Vendor = 1
			SELECT @ActiveVendor = 1 

		INSERT INTO tCompany
		(
			OwnerCompanyKey,
			CompanyName,
			VendorID,
			Vendor,
			OverheadVendor,
			OnHold,
			VendorDownloaded,
			WebSite,
			Phone,
			Fax,
			Active,
			DefaultExpenseAccountKey,
			DefaultAPAccountKey,
			VendorSalesTaxKey,
			VendorSalesTax2Key,
			DefaultAPApproverKey,
			DefaultMemo,
			TermsDays,
			TermsPercent,
			TermsNet,
			Type1099,
			Box1099,
			FATCAFilingRequirement,
			DBA,
			UseDBAForPayment,
			EINNumber,
			CCAccepted,
			CCAccountKey,
			EmailCCToAddress,
			EmailACHToAddress,
			VCardAccepted,
			OnePaymentPerVoucher,
			CCPayeeName,
			BankAccountNumber,
			BankRoutingNumber,
			BankAccountName,
			BankAccountTypeKey,
			PaymentAddressKey,
			PAINEnabled,
			BIC,
			IBAN,
			CountryCode,
			CurrencyID,
			ACHEnabled,
			POHeaderStandardTextKey,
			POFooterStandardTextKey,
			CreatedBy, 
			ModifiedBy, 
			ContactOwnerKey,
			ABAEnabled,
			DateAdded, 
			DateUpdated,
			ActiveVendor,
			AvalaraTaxCodeKey,
			UseDBAForPayment1099,
			UseAltAddress
		)
		VALUES
		(
			@OwnerCompanyKey,
			@CompanyName,
			@VendorID,
			@Vendor,
			@OverheadVendor,
			@OnHold,
			@VendorDownloaded,
			@WebSite,
			@Phone,
			@Fax,
			@Active,
			@DefaultExpenseAccountKey,
			@DefaultAPAccountKey,
			@VendorSalesTaxKey,
			@VendorSalesTax2Key,
			@DefaultAPApproverKey,
			@DefaultMemo,
			@TermsDays,
			@TermsPercent,
			@TermsNet,
			@Type1099,
			@Box1099,
			@FATCAFilingRequirement,
			@DBA,
			@UseDBAForPayment,
			@EINNumber,
			@CCAccepted,
			@CCAccountKey,
			@EmailCCToAddress,
			@EmailACHToAddress,
			@VCardAccepted,
			@OnePaymentPerVoucher,
			@CCPayeeName,
			@BankAccountNumber,
			@BankRoutingNumber,
			@BankAccountName,
			@BankAccountTypeKey,
			@PaymentAddressKey,
			@PAINEnabled,
			@BIC,
			@IBAN,
			@CountryCode,
			@CurrencyID,
			@ACHEnabled,
			@POHeaderStandardTextKey,
			@POFooterStandardTextKey,
			@UserKey,
			@UserKey,
			@ContactOwnerKey,
			@ABAEnabled,
			getutcdate(),
			getutcdate(),
			@ActiveVendor,
			@AvalaraTaxCodeKey,
			@UseDBAForPayment1099,
			@UseAltAddress
		)

		SELECT @CompanyKey = SCOPE_IDENTITY()
	END

IF @AddressName IS NOT NULL
	BEGIN
		INSERT 
			tAddress
			(
				OwnerCompanyKey,
				CompanyKey,
				AddressName,
				Address1,
				Address2,
				Address3,
				City,
				State,
				PostalCode,
				Country
			)
		VALUES
			(
				@OwnerCompanyKey,
				@CompanyKey,
				@AddressName,
				@Address1,
				@Address2,
				@Address3,
				@City,
				@State,
				@PostalCode,
				@Country
			)

		SELECT @AddressKey = SCOPE_IDENTITY()
		
		UPDATE tCompany
		SET DefaultAddressKey = @AddressKey
		WHERE CompanyKey = @CompanyKey
	END

RETURN @CompanyKey'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptRequestGetApproval]'
GO
IF OBJECT_ID(N'[dbo].[sptRequestGetApproval]', 'P') IS NOT NULL
EXEC sp_executesql N'
ALTER PROCEDURE [dbo].[sptRequestGetApproval]
 @RequestKey INT,
 @UserKey INT = 0
 
AS --Encrypt

  /*
  || When		Who Rel			What
  || 08/27/15	GAR 10.5.9.5	Created for new project request approval process.
  || 05/20/16   CRG 10.6.0.4    Added CampaignID, CampaignName, and tRequestDef.DisplayCampaign to the Request query
  || 08/20/16   GWG 10.6.0.7    Added calls for split billing
  || 01/09/17   RLB 10.1.0.1    Per GG removing inner join on ClientKey
  || 05/25/17   KMC 10.6.1.6    Remove backup approver for project requests
  || 05/26/17   KMC 10.6.1.6    Replace join to get backup approver
  || 06/29/17   KMC 10.6.1.7    (346353) Added DISTINCT to subquery for approval status. If there are multiple active steps/users and    
  ||                            both have the same backup approver then the same approval step key was being returned in multiple rows
  || 01/26/18   GHL 18.2.0      (380560) Added division and product + display setting from tRequestDef.DisplayDivisionProduct
  || 04/03/18   RLB 18.4.0      Added backup approver for each of the approval users
  || 04/04/18   RLB 18.5.0      added check for ActiveStep = 1 on approval status subquery because it could pull more than one row if there multiple steps with same user
  || 12/11/18   RLB 19.1.0.0    (418293) Adding Campaign Segment information
  || 05/29/19   RLS 19.0.6.0    (461835) Added ParentCompany and ParentCompanyKey
  || 10/18/19   GWG 19.1.1.0    Adding IncludesDeliverables
  || 09/08/20	KMC 20.1.0.0    (528430) Changed the SELECT DISTINCT to TOP 1 to avoid data problem where more than 1 active step exists
  || 11/23/20   RLB 20.1.2.0    (523390) slightly changed how approved and notify list are pulled for common approvals changes
  || 06/21/22   RLB 22.07.17    (603608) pull client glcompany to default on project create
  || 02/06/24   RLB 24.03.17    (658052) adding requestkey to campaign 
  || 05/15/25   GAR 25.06.15    (701767) Added tRequestDef.Active
  || 05/07/26   RLB 26.06.14    (721431) Added tRequestDef.SendIndividualApprovedEmails
  */
  
  SELECT tRequest.*
			,u.FirstName + '' '' + u.LastName as CreatedBy
			,u2.FirstName + '' '' + u2.LastName as UpdatedBy
			,tRequestDef.RequestName
			,tRequestDef.DisplayProjectFields
			,tRequestDef.DisplayClientProjNbr
			,ISNULL(tRequestDef.SendConfirmation, 0) AS SendConfirmation
			,tRequestDef.ConfirmationMessage
			,tRequestDef.DisplayCampaign
			,tRequestDef.DisplayDivisionProduct
			,ISNULL(tRequestDef.IncludesDeliverables, 0) as IncludesDeliverables
			,ISNULL(tRequestDef.SendIndividualApprovedEmails, 1) as IncludesDeliverables
			,ISNULL(c.CustomerID, '''') as CustomerID
			,ISNULL(c.CompanyName, '''') as CompanyName
			,ISNULL(c.ParentCompany, 0) as ParentCompany
			,ISNULL(c.ParentCompanyKey, 0) as ParentCompanyKey
			,ca.CampaignKey
			,ca.CampaignID
			,ca.CampaignName
			,cs.SegmentName
			,(Select count(*) from tSpecSheet (NOLOCK) Where Entity = ''ProjectRequest'' and EntityKey = @RequestKey) as StepCount
			,tRequestDef.PrintSpecOnSeparatePages
			,rrr.ReasonName AS RejectReasonName
			,-- Get whether or not this request is ready for the user to approve or reject.
				(SELECT TOP 1(tApprovalStep.ApprovalStepKey)
				FROM tApprovalStep (nolock) 
					inner join tApprovalStepUser on tApprovalStep.ApprovalStepKey = tApprovalStepUser.ApprovalStepKey
					inner join tRequest on tApprovalStep.EntityKey = tRequest.RequestKey
					inner join tRequestDef on tRequest.RequestDefKey = tRequestDef.RequestDefKey
					left outer join tCompany on tRequest.ClientKey = tCompany.CompanyKey
				WHERE
				tApprovalStep.Entity = ''ProjectRequest'' and ActiveStep = 1 and
				(tApprovalStepUser.AssignedUserKey = @UserKey or tApprovalStepUser.AssignedUserKey in (select UserKey from tUser (nolock) where BackupApprover = @UserKey)) and
				tApprovalStepUser.ActiveUser = 1 and 
				tApprovalStep.EntityKey = @RequestKey) AS ApprovalStatus
				,cd.DivisionName 
				,cp.ProductName
				,c.GLCompanyKey as DefaultGLCompanyKey
				,glc.GLCompanyName as DefaultGLCompanyName
				,glc.GLCompanyID as DefaultGLCompanyID
				,tRequestDef.Active
		FROM tRequest (NOLOCK) 
			inner join tRequestDef (NOLOCK) on tRequest.RequestDefKey = tRequestDef.RequestDefKey
			left join tCompany c (NOLOCK) on tRequest.ClientKey = c.CompanyKey
			left join tCampaign ca (NOLOCK) on tRequest.CampaignID = ca.CampaignID AND tRequest.CompanyKey = ca.CompanyKey
			left join tUser u (nolock) on tRequest.EnteredByKey = u.UserKey
			left join tUser u2 (nolock) on tRequest.UpdatedByKey = u2.UserKey
			LEFT JOIN tRequestRejectReason rrr (NOLOCK) ON tRequest.RequestRejectReasonKey = rrr.RequestRejectReasonKey
			left outer join tClientDivision cd (nolock) on tRequest.ClientDivisionKey = cd.ClientDivisionKey
			left outer join tClientProduct cp (nolock) on tRequest.ClientProductKey = cp.ClientProductKey
			left outer join tCampaignSegment cs (nolock) on tRequest.CampaignSegmentKey = cs.CampaignSegmentKey
			left outer join tGLCompany glc (nolock) on c.GLCompanyKey = glc.GLCompanyKey
		WHERE
			tRequest.RequestKey = @RequestKey

  -- Get all the steps for this request	  
  SELECT s.*, ISNULL(a.Rejected,0) AS Rejected, s.TimeZoneIndex,
	(Case s.Action When 1 then ''Edit'' when 2 then ''Approve'' when 3 then ''Notify'' end) as ActionText
  FROM tApprovalStep s (NOLOCK) 
			LEFT JOIN ( SELECT	s.ApprovalStepKey, COUNT(ISNULL(asu.Action,0)) as Rejected
					 FROM	tApprovalStep s (NOLOCK) INNER JOIN tApprovalStepUser asu (NOLOCK) ON s.ApprovalStepKey = asu.ApprovalStepKey
					 WHERE	asu.Action = 2
					 GROUP BY s.ApprovalStepKey ) a ON s.ApprovalStepKey = a.ApprovalStepKey
  WHERE s.Entity = ''ProjectRequest''
		And s.EntityKey = @RequestKey
  ORDER BY s.DisplayOrder ASC


  -- Get all the approval (or notify) users for this particular round across all steps
  SELECT su.*,
	LTRIM(RTRIM(ISNULL(u.FirstName,'''') + '' '' + ISNULL(u.LastName, ''''))) As UserName,
	su.AssignedUserKey as UserKey,
	su.DueDate as OriginalDueDate,
	su.NextReminder as OriginalNextReminder,
	CASE 
		WHEN su.DateActivated IS NULL THEN CASE 
											WHEN ISNULL(s.Completed, 0) = 1 THEN CASE su.Action
																					WHEN 1 THEN CASE su.WithChanges
																						WHEN 1 THEN ''Approved With Changes''
																						ELSE ''Approved'' END
																					WHEN 2 THEN ''Resubmit''
																					WHEN 3 THEN ''Skipped''
																					ELSE ''Not Required'' END
											else CASE su.Action
												WHEN 1 THEN CASE su.WithChanges
													WHEN 1 THEN ''Approved With Changes''
													ELSE ''Approved'' END
												WHEN 2 THEN ''Resubmit''
												WHEN 3 THEN ''Skipped''
												ELSE ''Waiting'' END
											end
		else CASE 
				WHEN ISNULL(su.CompletedUser, 0) = 1 THEN CASE su.Action
										WHEN 1 THEN CASE su.WithChanges
											WHEN 1 THEN ''Approved With Changes''
											ELSE ''Approved'' END
										WHEN 2 THEN ''Resubmit''
										WHEN 3 THEN ''Skipped''
										ELSE ''Not Required'' END
				else CASE su.Action
				WHEN 1 THEN CASE su.WithChanges
					WHEN 1 THEN ''Approved With Changes''
					ELSE ''Approved'' END
				WHEN 2 THEN ''Resubmit''
				WHEN 3 THEN ''Skipped''
				ELSE ''Reviewing'' END
		END
	END as ActionDescription,
	u.Email,
	s.Completed,
	su.AssignedUserKey as UserKey,
	rrr.ReasonName AS RejectReasonName,
	u.BackupApprover
  FROM tApprovalStepUser su (NOLOCK)
  INNER JOIN tApprovalStep s (NOLOCK) ON s.ApprovalStepKey = su.ApprovalStepKey
  INNER JOIN tUser u (NOLOCK) ON u.UserKey = su.AssignedUserKey 
  LEFT OUTER JOIN tRequest r (NOLOCK) ON s.EntityKey = r.RequestKey AND s.Entity = ''ProjectRequest''
  LEFT JOIN tRequestRejectReason rrr (NOLOCK) ON r.RequestRejectReasonKey = rrr.RequestRejectReasonKey
  WHERE Entity = ''ProjectRequest''
  And EntityKey = @RequestKey
  Order By su.DisplayOrder


  -- Get all the notify users for this particular round across all steps
  SELECT sn.*,
	LTRIM(RTRIM(ISNULL(u.FirstName,'''') + '' '' + ISNULL(u.LastName, ''''))) As UserName,
	sn.AssignedUserKey as UserKey,
	rrr.ReasonName AS RejectReasonName
  FROM tApprovalStepNotify sn (NOLOCK)
  INNER JOIN tApprovalStep s (NOLOCK) ON s.ApprovalStepKey = sn.ApprovalStepKey
  INNER JOIN tUser u (NOLOCK) ON u.UserKey = sn.AssignedUserKey
  LEFT OUTER JOIN tRequest r (NOLOCK) ON s.EntityKey = r.RequestKey AND s.Entity = ''ProjectRequest''
  LEFT JOIN tRequestRejectReason rrr (NOLOCK) ON r.RequestRejectReasonKey = rrr.RequestRejectReasonKey
  WHERE Entity = ''ProjectRequest''
  And EntityKey = @RequestKey

-- Get whether or not this request is ready for the user to approve or reject.
SELECT ISNULL(step.ApprovalStepKey, 0)
FROM tApprovalStep step (nolock) 
	inner join tApprovalStepUser asu on step.ApprovalStepKey = asu.ApprovalStepKey
	inner join tRequest r on step.EntityKey = r.RequestKey
	inner join tRequestDef rd on r.RequestDefKey = rd.RequestDefKey
	left outer join tCompany c on r.ClientKey = c.CompanyKey
WHERE
step.Entity = ''ProjectRequest'' and
asu.AssignedUserKey = @UserKey and
asu.ActiveUser = 1 and 
step.Entity = ''ProjectRequest'' and
step.EntityKey = @RequestKey


-- get any split billing
Select RequestKey, CompanyKey as ClientKey, CompanyName as ClientName, CustomerID as ClientID, Split
from tRequestSplit rs (nolock)
Inner join tCompany c (nolock) on rs.ClientKey = c.CompanyKey
Where rs.RequestKey = @RequestKey

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[sptProjectGet2]'
GO
IF OBJECT_ID(N'[dbo].[sptProjectGet2]', 'P') IS NOT NULL
EXEC sp_executesql N'

ALTER PROCEDURE [dbo].[sptProjectGet2]
	@CompanyKey int,
	@UserKey int,
	@ProjectKey int = 0,
	@ProjectNumber varchar(100) = NULL,
	@BudgetWarning int = 80
	

AS --Encrypt

/*
  || When       Who Rel      What
  || 03/17/14   MAS 10.5.7.8 Created for the ''New App'' - copied from sptProjectGet
  || 07/07/15   RLB 10.5.9.4 Added fields for plat schedule
  || 07/31/15   RLB 10.5.9.4 Added more fields
  || 07/31/15   GWG 10.5.9.5 Added more fields
  || 09/17/15   GHL 10.5.9.6 Added Template + Favorite fields
  || 10/23/15   GHL 10.5.9.7 Added Opportunity field
  || 11/30/15   CRG 10.5.9.8 Added AutoIDTask
  || 01/06/16   GAR 10.6.0.0 Added Project Status fields
  || 02/16/16   GHL 10.6.0.1 Added Billing Method
  || 04/06/16   CRG 10.6.0.3 (295845) Added TeamKey
  || 10/25/16   GHL 10.6.0.9 Added NonBillable field to hide billing links if not billable
  || 02/15/17   GWG 10.6.1.3 Added Project Request Info
  || 06/11/18   AMP 18.7.0.0 (403220) Added RequestedByName
  || 08/02/18   GHL 18.8.0.0 Added Retainer field, for project dashboard since sections on it
  ||                         must be hiddhen if this is a retainer project
  || 09/24/18   CRG 18.9.1   Added RetainerKey
  || 02/04/18   CRG 19.0.2.0 Added PlanningProject
  || 03/20/19   AMP 19.0.4.0 (442795) Added Project Billing Status
  || 03/27/19   RLB 19.0.5.0 Added UnapprovedChangeOrders for change order lock
  || 04/05/19   GHL 19.0.5.0 (447171) Added project currency ID to show on dashboard
  || 04/09/19   GHL 19.0.5.0 (454785) Added the Bill Option of the Planning Project
  ||                          in order to hide the Billing section on the underlying projects 
  || 04/30/19   GAR 19.0.5.0 (457483) Added campaign information so we can display it on the project dashboard.
  || 06/11/19   AMP 19.0.7.0 (446231) Added currency description for the heading on the Project Budget screen, use project currency. If a project currency is not set use home currency
  || 08/23/19   GAR 19.0.9.0 (473474) Added project manager
  || 12/02/19   CRG 20.0.0.1 (489655) Added ProjectColor
  || 05/12/20   RLS 20.0.6.0 (513828) Added Detailed Notes as NextSteps and StatusNotes
  || 02/09/21   CRG 21.03.14 (521442) Added PlanningProjectAutoRollover
  || 03/12/21   RLS 21.0.4.0 (551480) Added p.LayoutKey
  || 12/13/21   CRG 22.01.16 (578510) Added PlanningProjectAllowPeople
  || 02/07/22   GHL 22.03.00 (585626) Added OpportunityProjectTypeKey needed for ''Make Project Live'' function on project dashboard now 
  ||                         Also added CampaignOpportunity (if 1 do not show on project dashboard)
  || 03/16/22   CRG 22.03.20 (592045) Fixed issue where PlanningProjectAllowPeople wasn''t in all of the queries
  || 03/18/22   GHL 22.04.17 (590582) Added SetTaxableOnInvoice for Finger Marketing enhancement
  || 04/06/22	GAR 22.04.17 (593151) Added SlackChannelID for determining Slack channel
  || 08/26/22   RLB 22.09.18 (610285) moving projectnumber up to varchar100
  || 06/05/23   CRG 23.07.16 (639524) Added AutoScheduleProjects, AutoScheduleTaskEndDate, and ActualDateUpdatesPlan
  || 11/28/23   CRG 23.12.17 (649537) Added WeekendBucket
  || 04/24/24   CRG 23.05.19 (660831) Added LeadKey
  || 07/29/24   CRG 24.08.18 (679325) Added the project work days to all of the queries (they were missing from all but the first query)
  || 09/30/25   GAR 25.10.19 (712209) Adding Client Notes for the new project dashboard
  || 10/03/25   RLS 25.10.19 (712626) Added PrimaryContactOwnerCompanyKey
  || 11/04/25   CRG 25.11.16 (714807) Added OverrideScheduleOptions
  || 01/21/26   CRG 26.02.15 (717807) Added BucketPerWeek
  || 03/19/26   GAR 26.04.19 (724162) Added StatusNotesUpdated, DetailedNotesUpdated, and ClientNotesUpdated for project details dashboard widget
  || 06/26/26   GAR 26.07.19 (731353) Added BudgetWarning as a parameter to go with new fields TaskStatus and FinancialStatusImage
  
*/

Declare @RestrictGLCompany int



SELECT @RestrictGLCompany = isnull(RestrictToGLCompany, 0)
FROM   tPreference (NOLOCK)
WHERE  CompanyKey = @CompanyKey
		
IF @RestrictGLCompany = 0
	BEGIN
		IF @ProjectKey > 0
			SELECT p.ProjectKey  
			, p.ProjectName
			, p.ProjectNumber                                      
			, p.CompanyKey  
			, p.ClientKey                                                                                                                                                                                       
			, p.BillingContact 
			, p.BillingMethod 
			, p.Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
			, p.StartDate               
			, p.CompleteDate
			, p.PercComp
			, p.AccountManager                                                                                                                                                                                                                                           
			, p.GLCompanyKey 
			, p.ProjectCloseDate  
			, p.CustomFieldKey 
			, p.ScheduleDirection 
			, ISNULL(p.ScheduleLockedByKey, 0) as ScheduleLockedByKey
			, p.WorkMon
			, p.WorkTue
			, p.WorkWed
			, p.WorkThur
			, p.WorkFri
			, p.WorkSat
			, p.WorkSun          
			, p.SetupDone
			, p.ScheduleDone
			, p.TeamDone
			, p.EstimateDone    
			, p.Template                                                                                                                                                                                 
			, c.CustomerID as ClientID, isnull(c.CompanyName, '''') as ClientName
			, RTRIM(LTRIM(ISNULL(pc.FirstName,'''') + '' '' + ISNULL(pc.LastName, ''''))) as PrimaryContactName
			, pc.Phone1 as PrimaryContactPhone
			, pc.Email as PrimaryContactEmail
			, pc.OwnerCompanyKey as PrimaryContactOwnerCompanyKey
			, RTRIM(LTRIM(ISNULL(am.FirstName,'''') + '' '' + ISNULL(am.LastName, ''''))) as AccountManagerName
			, (Select COUNT(*) FROM tSpecSheet (NOLOCK) WHERE tSpecSheet.EntityKey = p.ProjectKey) as SpecSheetCount
			, (Select COUNT(*) from tReviewDeliverable (NOLOCK) Where ProjectKey = p.ProjectKey) as DeliverableCount
			,CASE WHEN ISNULL(af.AppFavoriteKey, 0) > 0 THEN 1 ELSE 0 END AS IsFavorite
			,(Select Count(*) From tChange (nolock) where EntityKey = @ProjectKey and Entity = ''Project'' and Status < 4) as UnapprovedChangeOrders
			,p.Opportunity
			,l.ProjectTypeKey as OpportunityProjectTypeKey
			,p.Retainer
			,p.RetainerKey
			,p.AutoIDTask
			,p.ProjectStatusKey
			,ps.ProjectStatus
			,p.ProjectBillingStatusKey
			,bs.ProjectBillingStatus
			,bs.ProjectBillingStatusID
			,bs.DisplayOrder
			,bs.Active
			,ps.Locked as StatusLocked
			,p.Closed
			,p.TeamKey
			,p.NonBillable
			,r.RequestKey
			,r.RequestID
			,r.RequestedByKey 
			, r.RequestedBy as RequestedByName
			,r.Subject as RequestSubject
			,p.OfficeKey
			,p.PlanningProject
			,p.PlanningProjectMultipleTasks
			,CASE WHEN p.CurrencyID is null then pref.CurrencyID ELSE p.CurrencyID END AS CurrencyID --if there is not a currency on the project then use the home currency
			,CASE WHEN p.CurrencyID is null then cur2.Description ELSE cur.Description END AS CurrencyDescription
			,isnull(plan_p.PlanningBillOption,0) as PlanningProjectBillOption -- not the Bill Option of the project but the Bill Option of the parent planning project 
			,p.CampaignKey
			,ca.CampaignID
			,ca.CampaignName
			,isnull(ca.Opportunity,0) as CampaignOpportunity
			,RTRIM(LTRIM(ISNULL(pm.FirstName,'''') + '' '' + ISNULL(pm.LastName, ''''))) as ProjectManagerName
			,p.ProjectColor
			,p.DetailedNotes as NextSteps
			,p.StatusNotes
			,p.PlanningProjectAutoRollover
			,p.PlanningProjectAllowPeople
			,ISNULL(p.LayoutKey, 0) AS LayoutKey
			,p.SetTaxableOnInvoice
			,p.SlackChannelID
			,p.AutoScheduleProjects
			,p.AutoScheduleTaskEndDate
			,p.ActualDateUpdatesPlan
			,p.WeekendBucket
			,p.LeadKey
			,p.ClientNotes
			,p.OverrideScheduleOptions
			,p.BucketPerWeek
			,p.StatusNotesUpdated
			,p.DetailedNotesUpdated
			,p.ClientNotesUpdated
			,p.TaskStatus
			,CASE 
				WHEN (p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) = 0 THEN 1
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) )  > 
						p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense THEN 3
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) ) / 
						(p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) * 100 >= @BudgetWarning THEN 2
				ELSE 1
				END AS FinancialStatusImage
			FROM tProject p (NOLOCK)
			LEFT OUTER JOIN tCompany c (NOLOCK) on p.ClientKey = c.CompanyKey
			LEFT OUTER JOIN tPreference pref (NOLOCK) on pref.CompanyKey =  p.CompanyKey
			LEFT OUTER JOIN tCurrency cur (NOLOCK) on cur.CurrencyID =  p.CurrencyID collate database_default
			LEFT OUTER JOIN tCurrency cur2 (NOLOCK) on cur2.CurrencyID =  pref.CurrencyID collate database_default
			LEFT OUTER JOIN tUser am (NOLOCK) on am.UserKey = p.AccountManager
			LEFT OUTER JOIN tUser pc (nolock) ON pc.UserKey = p.BillingContact
			LEFT OUTER JOIN tRequest r (NOLOCK) on p.RequestKey = r.RequestKey
			LEFT OUTER JOIN tAppFavorite af (nolock) on p.ProjectKey = af.ActionKey AND af.ActionID = ''projects.dashboard.dash'' and af.UserKey = @UserKey
  			LEFT OUTER JOIN tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
		    LEFT OUTER JOIN tProjectBillingStatus bs (nolock) on p.ProjectBillingStatusKey = bs.ProjectBillingStatusKey
			LEFT OUTER JOIN tProject plan_p (nolock) on p.PlanningProjectKey = plan_p.ProjectKey
			LEFT OUTER JOIN tCampaign ca (nolock) on p.CampaignKey = ca.CampaignKey
			LEFT OUTER JOIN tUser pm (NOLOCK) on pm.UserKey = p.ProjectManager
			LEFT OUTER JOIN tLead l (NOLOCK) on p.LeadKey = l.LeadKey
			LEFT OUTER JOIN tProjectRollup pr (nolock)  ON p.ProjectKey = pr.ProjectKey  
  			WHERE p.ProjectKey = @ProjectKey 
  			AND p.CompanyKey = @CompanyKey
		ELSE
			SELECT p.ProjectKey  
			, p.ProjectName
			, p.ProjectNumber                                      
			, p.CompanyKey  
			, p.ClientKey                                                                                                                                                                                       
			, p.BillingContact 
			, p.BillingMethod 
			, p.Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
			, p.StartDate               
			, p.CompleteDate
			, p.PercComp
			, p.AccountManager                                                                                                                                                                                                                                           
			, p.GLCompanyKey 
			, p.ProjectCloseDate 
			, p.ScheduleDirection  
			, ISNULL(p.ScheduleLockedByKey, 0) as ScheduleLockedByKey
			, p.WorkMon
			, p.WorkTue
			, p.WorkWed
			, p.WorkThur
			, p.WorkFri
			, p.WorkSat
			, p.WorkSun  
			, p.CustomFieldKey  
			, p.SetupDone
			, p.ScheduleDone
			, p.TeamDone
			, p.EstimateDone                                                                                                                                                                                                
			, p.Template                                                                                                                                                                                 
			, c.CustomerID as ClientID, isnull(c.CompanyName, '''') as ClientName
			, RTRIM(LTRIM(ISNULL(pc.FirstName,'''') + '' '' + ISNULL(pc.LastName, ''''))) as PrimaryContactName
			, pc.Phone1 as PrimaryContactPhone
			, pc.Email as PrimaryContactEmail
			, pc.OwnerCompanyKey as PrimaryContactOwnerCompanyKey
			, RTRIM(LTRIM(ISNULL(am.FirstName,'''') + '' '' + ISNULL(am.LastName, ''''))) as AccountManagerName
			, (Select COUNT(*) FROM tSpecSheet (NOLOCK) WHERE tSpecSheet.EntityKey = p.ProjectKey) as SpecSheetCount
			, (Select COUNT(*) from tReviewDeliverable (NOLOCK) Where ProjectKey = p.ProjectKey) as DeliverableCount
			,CASE WHEN ISNULL(af.AppFavoriteKey, 0) > 0 THEN 1 ELSE 0 END AS IsFavorite
			,(Select Count(*) From tChange (nolock) where EntityKey = @ProjectKey and Entity = ''Project'' and Status < 4) as UnapprovedChangeOrders
			,p.Opportunity
			,l.ProjectTypeKey as OpportunityProjectTypeKey
			,p.Retainer
			,p.RetainerKey
			,p.AutoIDTask
			,p.ProjectStatusKey
			,ps.ProjectStatus
			,p.ProjectBillingStatusKey
			,bs.ProjectBillingStatus
			,bs.ProjectBillingStatusID
			,bs.DisplayOrder
			,bs.Active
			,ps.Locked as StatusLocked
			,p.Closed
			,p.TeamKey
			,p.NonBillable
			,r.RequestKey
			,r.RequestID
			,r.Subject as RequestSubject
			,p.OfficeKey
			,p.PlanningProject
			,p.PlanningProjectMultipleTasks
			,CASE WHEN p.CurrencyID is null then pref.CurrencyID ELSE p.CurrencyID END AS CurrencyID --if there is not a currency on the project then use the home currency
			,CASE WHEN p.CurrencyID is null then cur2.Description ELSE cur.Description END AS CurrencyDescription
			,isnull(plan_p.PlanningBillOption,0) as PlanningProjectBillOption -- not the Bill Option of the project but the Bill Option of the parent planning project 
			,p.CampaignKey
			,ca.CampaignID
			,ca.CampaignName
			,isnull(ca.Opportunity,0) as CampaignOpportunity
			,RTRIM(LTRIM(ISNULL(pm.FirstName,'''') + '' '' + ISNULL(pm.LastName, ''''))) as ProjectManagerName
			,p.ProjectColor
			,p.DetailedNotes as NextSteps
			,p.StatusNotes
			,p.PlanningProjectAllowPeople
			,ISNULL(p.LayoutKey, 0) AS LayoutKey
			,p.SetTaxableOnInvoice
			,p.SlackChannelID
			,p.AutoScheduleProjects
			,p.AutoScheduleTaskEndDate
			,p.ActualDateUpdatesPlan
			,p.WeekendBucket
			,p.LeadKey
			,p.ClientNotes
			,p.OverrideScheduleOptions
			,p.BucketPerWeek
			,p.StatusNotesUpdated
			,p.DetailedNotesUpdated
			,p.ClientNotesUpdated
			,p.TaskStatus
			,CASE 
				WHEN (p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) = 0 THEN 1
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) )  > 
						p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense THEN 3
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) ) / 
						(p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) * 100 >= @BudgetWarning THEN 2
				ELSE 1
				END AS FinancialStatusImage
			FROM tProject p (NOLOCK)
			LEFT OUTER JOIN tCompany c (NOLOCK) on p.ClientKey = c.CompanyKey
            LEFT OUTER JOIN tPreference pref (NOLOCK) on pref.CompanyKey =  p.CompanyKey
			LEFT OUTER JOIN tCurrency cur (NOLOCK) on cur.CurrencyID =  p.CurrencyID collate database_default
			LEFT OUTER JOIN tCurrency cur2 (NOLOCK) on cur2.CurrencyID =  pref.CurrencyID collate database_default
			LEFT OUTER JOIN tUser am (NOLOCK) on am.UserKey = p.AccountManager
			LEFT OUTER JOIN tUser pc (nolock) ON pc.UserKey = p.BillingContact
			LEFT OUTER JOIN tAppFavorite af (nolock) on p.ProjectKey = af.ActionKey AND af.ActionID = ''projects.dashboard.dash'' and af.UserKey = @UserKey
			LEFT OUTER JOIN tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
			LEFT OUTER JOIN tRequest r (NOLOCK) on p.RequestKey = r.RequestKey
			LEFT OUTER JOIN tProjectBillingStatus bs (nolock) on p.ProjectBillingStatusKey = bs.ProjectBillingStatusKey
			LEFT OUTER JOIN tProject plan_p (nolock) on p.PlanningProjectKey = plan_p.ProjectKey
			LEFT OUTER JOIN tCampaign ca (nolock) on p.CampaignKey = ca.CampaignKey
			LEFT OUTER JOIN tUser pm (NOLOCK) on pm.UserKey = p.ProjectManager
			LEFT OUTER JOIN tLead l (NOLOCK) on p.LeadKey = l.LeadKey
			LEFT OUTER JOIN tProjectRollup pr (nolock)  ON p.ProjectKey = pr.ProjectKey  
  			WHERE p.ProjectNumber = @ProjectNumber 
			AND p.CompanyKey = @CompanyKey 
	END
ELSE
	BEGIN
		IF @ProjectKey > 0
			SELECT p.ProjectKey  
			, p.ProjectName
			, p.ProjectNumber                                      
			, p.CompanyKey  
			, p.ClientKey                                                                                                                                                                                       
			, p.BillingContact 
			, p.BillingMethod 
			, p.Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
			, p.StartDate               
			, p.CompleteDate
			, p.PercComp
			, p.AccountManager                                                                                                                                                                                                                                           
			, p.GLCompanyKey 
			, p.ProjectCloseDate  
			, p.ScheduleDirection 
			, ISNULL(p.ScheduleLockedByKey, 0) as ScheduleLockedByKey  
			, p.WorkMon
			, p.WorkTue
			, p.WorkWed
			, p.WorkThur
			, p.WorkFri
			, p.WorkSat
			, p.WorkSun  
			, p.CustomFieldKey  
			, p.SetupDone
			, p.ScheduleDone
			, p.TeamDone
			, p.EstimateDone
			, p.Template                                                                                                                                                                                              
			, c.CustomerID as ClientID, isnull(c.CompanyName, '''') as ClientName
			, RTRIM(LTRIM(ISNULL(pc.FirstName,'''') + '' '' + ISNULL(pc.LastName, ''''))) as PrimaryContactName
			, pc.Phone1 as PrimaryContactPhone
			, pc.Email as PrimaryContactEmail
			, pc.OwnerCompanyKey as PrimaryContactOwnerCompanyKey
			, RTRIM(LTRIM(ISNULL(am.FirstName,'''') + '' '' + ISNULL(am.LastName, ''''))) as AccountManagerName
			, (Select COUNT(*) FROM tSpecSheet (NOLOCK) WHERE tSpecSheet.EntityKey = p.ProjectKey) as SpecSheetCount
			, (Select COUNT(*) from tReviewDeliverable (NOLOCK) Where ProjectKey = p.ProjectKey) as DeliverableCount
			,CASE WHEN ISNULL(af.AppFavoriteKey, 0) > 0 THEN 1 ELSE 0 END AS IsFavorite
			,(Select Count(*) From tChange (nolock) where EntityKey = @ProjectKey and Entity = ''Project'' and Status < 4) as UnapprovedChangeOrders
			,p.Opportunity
			,l.ProjectTypeKey as OpportunityProjectTypeKey
			,p.Retainer
			,p.RetainerKey
			,p.AutoIDTask
			,p.ProjectStatusKey
			,ps.ProjectStatus
			,p.ProjectBillingStatusKey
			,bs.ProjectBillingStatus
			,bs.ProjectBillingStatusID
			,bs.DisplayOrder
			,bs.Active
			,ps.Locked as StatusLocked
			,p.Closed
			,p.TeamKey
			,p.NonBillable
			,r.RequestKey
			,r.RequestID
			,r.Subject as RequestSubject
			,p.OfficeKey
			,p.PlanningProject
			,p.PlanningProjectMultipleTasks
			,CASE WHEN p.CurrencyID is null then pref.CurrencyID ELSE p.CurrencyID END AS CurrencyID --if there is not a currency on the project then use the home currency
			,CASE WHEN p.CurrencyID is null then cur2.Description ELSE cur.Description END AS CurrencyDescription
			,isnull(plan_p.PlanningBillOption,0) as PlanningProjectBillOption -- not the Bill Option of the project but the Bill Option of the parent planning project 
			,p.CampaignKey
			,ca.CampaignID
			,ca.CampaignName
			,isnull(ca.Opportunity,0) as CampaignOpportunity
			,RTRIM(LTRIM(ISNULL(pm.FirstName,'''') + '' '' + ISNULL(pm.LastName, ''''))) as ProjectManagerName
			,p.ProjectColor
			,p.DetailedNotes as NextSteps
			,p.StatusNotes
			,p.PlanningProjectAllowPeople
			,ISNULL(p.LayoutKey, 0) AS LayoutKey
			,p.SetTaxableOnInvoice
			,p.SlackChannelID
			,p.AutoScheduleProjects
			,p.AutoScheduleTaskEndDate
			,p.ActualDateUpdatesPlan
			,p.WeekendBucket
			,p.LeadKey
			,p.ClientNotes
			,p.OverrideScheduleOptions
			,p.BucketPerWeek
			,p.StatusNotesUpdated
			,p.DetailedNotesUpdated
			,p.ClientNotesUpdated
			,p.TaskStatus
			,CASE 
				WHEN (p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) = 0 THEN 1
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) )  > 
						p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense THEN 3
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) ) / 
						(p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) * 100 >= @BudgetWarning THEN 2
				ELSE 1
				END AS FinancialStatusImage
			FROM tProject p (NOLOCK)
			JOIN tUserGLCompanyAccess glca (NOLOCK) on glca.GLCompanyKey = p.GLCompanyKey
			LEFT OUTER JOIN tCompany c (NOLOCK) on p.ClientKey = c.CompanyKey
            LEFT OUTER JOIN tPreference pref (NOLOCK) on pref.CompanyKey =  p.CompanyKey
			LEFT OUTER JOIN tCurrency cur (NOLOCK) on cur.CurrencyID =  p.CurrencyID collate database_default
			LEFT OUTER JOIN tCurrency cur2 (NOLOCK) on cur2.CurrencyID =  pref.CurrencyID collate database_default
			LEFT OUTER JOIN tUser am (NOLOCK) on am.UserKey = p.AccountManager
			LEFT OUTER JOIN tUser pc (nolock) ON pc.UserKey = p.BillingContact
			LEFT OUTER JOIN tAppFavorite af (nolock) on p.ProjectKey = af.ActionKey AND af.ActionID = ''projects.dashboard.dash'' and af.UserKey = @UserKey
  			LEFT OUTER JOIN tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
			LEFT OUTER JOIN tRequest r (NOLOCK) on p.RequestKey = r.RequestKey
			LEFT OUTER JOIN tProjectBillingStatus bs (nolock) on p.ProjectBillingStatusKey = bs.ProjectBillingStatusKey
			LEFT OUTER JOIN tProject plan_p (nolock) on p.PlanningProjectKey = plan_p.ProjectKey
			LEFT OUTER JOIN tCampaign ca (nolock) on p.CampaignKey = ca.CampaignKey
			LEFT OUTER JOIN tUser pm (NOLOCK) on pm.UserKey = p.ProjectManager
			LEFT OUTER JOIN tLead l (NOLOCK) on p.LeadKey = l.LeadKey
			LEFT OUTER JOIN tProjectRollup pr (nolock)  ON p.ProjectKey = pr.ProjectKey  
  			WHERE p.ProjectKey = @ProjectKey 
  			AND p.CompanyKey = @CompanyKey
  			AND glca.UserKey = @UserKey
		ELSE
			SELECT p.ProjectKey  
			, p.ProjectName
			, p.ProjectNumber                                      
			, p.CompanyKey  
			, p.ClientKey                                                                                                                                                                                       
			, p.BillingContact 
			, p.BillingMethod 
			, p.Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
			, p.StartDate               
			, p.CompleteDate
			, p.PercComp
			, p.AccountManager                                                                                                                                                                                                                                           
			, p.GLCompanyKey 
			, p.ProjectCloseDate  
			, p.ScheduleDirection  
			, ISNULL(p.ScheduleLockedByKey, 0) as ScheduleLockedByKey
			, p.WorkMon
			, p.WorkTue
			, p.WorkWed
			, p.WorkThur
			, p.WorkFri
			, p.WorkSat
			, p.WorkSun  
			, p.CustomFieldKey  
			, p.SetupDone
			, p.ScheduleDone
			, p.TeamDone
			, p.EstimateDone
			, p.Template                                                                                                                                                                                               
			, c.CustomerID as ClientID, isnull(c.CompanyName, '''') as ClientName
			, RTRIM(LTRIM(ISNULL(pc.FirstName,'''') + '' '' + ISNULL(pc.LastName, ''''))) as PrimaryContactName
			, pc.Phone1 as PrimaryContactPhone
			, pc.Email as PrimaryContactEmail
			, pc.OwnerCompanyKey as PrimaryContactOwnerCompanyKey
			, RTRIM(LTRIM(ISNULL(am.FirstName,'''') + '' '' + ISNULL(am.LastName, ''''))) as AccountManagerName
			, (Select COUNT(*) FROM tSpecSheet (NOLOCK) WHERE tSpecSheet.EntityKey = p.ProjectKey) as SpecSheetCount
			, (Select COUNT(*) from tReviewDeliverable (NOLOCK) Where ProjectKey = p.ProjectKey) as DeliverableCount
			,CASE WHEN ISNULL(af.AppFavoriteKey, 0) > 0 THEN 1 ELSE 0 END AS IsFavorite
			,(Select Count(*) From tChange (nolock) where EntityKey = @ProjectKey and Entity = ''Project'' and Status < 4) as UnapprovedChangeOrders
			,p.Opportunity
			,l.ProjectTypeKey as OpportunityProjectTypeKey
			,p.Retainer
			,p.RetainerKey
			,p.AutoIDTask
			,p.ProjectStatusKey
			,ps.ProjectStatus
			,p.ProjectBillingStatusKey
			,bs.ProjectBillingStatus
			,bs.ProjectBillingStatusID
			,bs.DisplayOrder
			,bs.Active
			,ps.Locked as StatusLocked
			,p.Closed
			,p.TeamKey
			,p.NonBillable
			,r.RequestKey
			,r.RequestID
			,r.Subject as RequestSubject
			,p.OfficeKey
			,p.PlanningProject
			,p.PlanningProjectMultipleTasks
			,CASE WHEN p.CurrencyID is null then pref.CurrencyID ELSE p.CurrencyID END AS CurrencyID --if there is not a currency on the project then use the home currency
			,CASE WHEN p.CurrencyID is null then cur2.Description ELSE cur.Description END AS CurrencyDescription
			,isnull(plan_p.PlanningBillOption,0) as PlanningProjectBillOption -- not the Bill Option of the project but the Bill Option of the parent planning project 
			,p.CampaignKey
			,ca.CampaignID
			,ca.CampaignName
			,isnull(ca.Opportunity,0) as CampaignOpportunity
			,RTRIM(LTRIM(ISNULL(pm.FirstName,'''') + '' '' + ISNULL(pm.LastName, ''''))) as ProjectManagerName
			,p.ProjectColor
			,p.DetailedNotes as NextSteps
			,p.StatusNotes
			,p.PlanningProjectAllowPeople
			,ISNULL(p.LayoutKey, 0) AS LayoutKey
			,p.SetTaxableOnInvoice
			,p.SlackChannelID
			,p.AutoScheduleProjects
			,p.AutoScheduleTaskEndDate
			,p.ActualDateUpdatesPlan
			,p.WeekendBucket
			,p.LeadKey
			,p.ClientNotes
			,p.OverrideScheduleOptions
			,p.BucketPerWeek
			,p.StatusNotesUpdated
			,p.DetailedNotesUpdated
			,p.ClientNotesUpdated
			,p.TaskStatus
			,CASE 
				WHEN (p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) = 0 THEN 1
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) )  > 
						p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense THEN 3
				WHEN (ISNULL(pr.LaborGross, 0) + ISNULL(pr.MiscCostGross, 0) + ISNULL(pr.ExpReceiptGross, 0) + ISNULL(pr.VoucherGross, 0) + ISNULL(pr.OpenOrderGross, 0) ) / 
						(p.EstLabor + p.ApprovedCOLabor + p.EstExpenses + p.ApprovedCOExpense) * 100 >= @BudgetWarning THEN 2
				ELSE 1
				END AS FinancialStatusImage
			FROM tProject p (NOLOCK)
			JOIN tUserGLCompanyAccess glca (NOLOCK) on glca.GLCompanyKey = p.GLCompanyKey
			LEFT OUTER JOIN tCompany c (NOLOCK) on p.ClientKey = c.CompanyKey
            LEFT OUTER JOIN tPreference pref (NOLOCK) on pref.CompanyKey =  p.CompanyKey
			LEFT OUTER JOIN tCurrency cur (NOLOCK) on cur.CurrencyID =  p.CurrencyID collate database_default
			LEFT OUTER JOIN tCurrency cur2 (NOLOCK) on cur2.CurrencyID =  pref.CurrencyID collate database_default
			LEFT OUTER JOIN tUser am (NOLOCK) on am.UserKey = p.AccountManager
			LEFT OUTER JOIN tUser pc (nolock) ON pc.UserKey = p.BillingContact
			LEFT OUTER JOIN tAppFavorite af (nolock) on p.ProjectKey = af.ActionKey AND af.ActionID = ''projects.dashboard.dash'' and af.UserKey = @UserKey
			LEFT OUTER JOIN tProjectStatus ps (nolock) on p.ProjectStatusKey = ps.ProjectStatusKey
			LEFT OUTER JOIN tRequest r (NOLOCK) on p.RequestKey = r.RequestKey
			LEFT OUTER JOIN tProjectBillingStatus bs (nolock) on p.ProjectBillingStatusKey = bs.ProjectBillingStatusKey
			LEFT OUTER JOIN tProject plan_p (nolock) on p.PlanningProjectKey = plan_p.ProjectKey
			LEFT OUTER JOIN tCampaign ca (nolock) on p.CampaignKey = ca.CampaignKey
			LEFT OUTER JOIN tUser pm (NOLOCK) on pm.UserKey = p.ProjectManager
			LEFT OUTER JOIN tLead l (NOLOCK) on p.LeadKey = l.LeadKey
			LEFT OUTER JOIN tProjectRollup pr (nolock)  ON p.ProjectKey = pr.ProjectKey  
  			WHERE p.ProjectNumber = @ProjectNumber 
			AND p.CompanyKey = @CompanyKey 
			AND glca.UserKey = @UserKey
	END	
		

RETURN 1

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
-- This statement writes to the SQL Server Log so SQL Monitor can show this deployment.
IF HAS_PERMS_BY_NAME(N'sys.xp_logevent', N'OBJECT', N'EXECUTE') = 1
BEGIN
    DECLARE @databaseName AS nvarchar(2048), @eventMessage AS nvarchar(2048)
    SET @databaseName = REPLACE(REPLACE(DB_NAME(), N'\', N'\\'), N'"', N'\"')
    SET @eventMessage = N'Redgate SQL Compare: { "deployment": { "description": "Redgate SQL Compare deployed to ' + @databaseName + N'", "database": "' + @databaseName + N'" }}'
    EXECUTE sys.xp_logevent 55000, @eventMessage
END
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
	IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
	PRINT 'The database update failed'
END
GO
