CREATE TABLE [dbo].[MobileSetup]
(
[MobileSetupID] [int] NOT NULL,
[CompanyID] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[UserName] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Password] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Inactive] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_Inactive] DEFAULT ((0)),
[Token] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TokenObtained] [datetime] NULL,
[TokenExpires] [datetime] NULL,
[RefreshToken] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RefreshTokenExpires] [datetime] NULL,
[DateModified] [datetime] NOT NULL,
[ModifiedBySysUserFID] [int] NOT NULL,
[ActivateMobileCrew] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_ActivateMobileCrew] DEFAULT ((0)),
[ActivateCrewTime] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_ActivateCrewTime] DEFAULT ((0)),
[AllowMobilePasswordReset] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_AllowMobilePasswordReset] DEFAULT ((0)),
[DefaultDocumentTypeFID] [int] NULL,
[FuturePunchSeconds] [int] NULL,
[CrewTimeForCrewLeadOnly] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_CrewTimeForCrewLeadOnly] DEFAULT ((0)),
[LastSyncedDate] [datetime] NULL,
[DefaultOrderNoteTypeFID] [smallint] NULL,
[ChangeOrderDocumentTypeFID] [int] NULL,
[JobSummaryDocumentTypeFID] [int] NULL,
[JobDetailDocumentTypeFID] [int] NULL,
[EmailOrderNoteTypeFID] [smallint] NULL,
[MSCrewFromEmailAddress] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MSCrewFromEmailDisplayName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MSCrewFromEmailFooter] [nvarchar] (2000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CustomerSummaryRoundingMinutes] [int] NOT NULL CONSTRAINT [DF_MobileSetup_CustomerSummaryRoundingMinutes] DEFAULT ((0)),
[CustomerSummaryDetailedTime] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_CustomerSummaryDetailedTime] DEFAULT ((0)),
[IsCrewTimeLocked] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_IsCrewTimeLocked] DEFAULT ((0)),
[IsCrewTimeForCrewLeadLocked] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_IsCrewTimeForCrewLeadLocked] DEFAULT ((0)),
[AllowCrewAdditions] [bit] NOT NULL CONSTRAINT [DF_MobileSetup_AllowCrewAdditions] DEFAULT ((0)),
[PastDaysToShow] [int] NULL,
[FutureDaysToShow] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [CK_CustomerSummaryRoundingMinutes] CHECK (([CustomerSummaryRoundingMinutes]=(30) OR [CustomerSummaryRoundingMinutes]=(15) OR [CustomerSummaryRoundingMinutes]=(0)))
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [CK_MobileSetupID] CHECK (([MobileSetupID]=(1)))
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [PK_MobileSetup] PRIMARY KEY NONCLUSTERED ([MobileSetupID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_ChangeOrderDocumentType] FOREIGN KEY ([ChangeOrderDocumentTypeFID]) REFERENCES [dbo].[DocumentType] ([DocumentTypeID])
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_DocumentType] FOREIGN KEY ([DefaultDocumentTypeFID]) REFERENCES [dbo].[DocumentType] ([DocumentTypeID])
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_NoteType] FOREIGN KEY ([DefaultOrderNoteTypeFID]) REFERENCES [dbo].[NoteType] ([NoteTypeID])
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_EmailNoteType] FOREIGN KEY ([EmailOrderNoteTypeFID]) REFERENCES [dbo].[NoteType] ([NoteTypeID])
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_JobDetailDocumentType] FOREIGN KEY ([JobDetailDocumentTypeFID]) REFERENCES [dbo].[DocumentType] ([DocumentTypeID])
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_JobSummaryDocumentType] FOREIGN KEY ([JobSummaryDocumentTypeFID]) REFERENCES [dbo].[DocumentType] ([DocumentTypeID])
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_MoversConnectSetup] FOREIGN KEY ([MobileSetupID]) REFERENCES [dbo].[MoversConnectSetup] ([MoversConnectSetupID])
GO
ALTER TABLE [dbo].[MobileSetup] ADD CONSTRAINT [FK_MobileSetup_Sysuser] FOREIGN KEY ([ModifiedBySysUserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[MobileSetup] TO [MssExec]
GRANT INSERT ON [dbo].[MobileSetup] TO [MssExec]
GRANT DELETE ON [dbo].[MobileSetup] TO [MssExec]
GRANT UPDATE ON [dbo].[MobileSetup] TO [MssExec]
GO