V1_0_1__structure_database.sql 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. USE [callmaster]
  2. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ticket]') AND type in (N'U')) DROP TABLE [dbo].[ticket]
  3. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tag]') AND type in (N'U')) DROP TABLE [dbo].[tag]
  4. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[schedule]') AND type in (N'U')) DROP TABLE [dbo].[schedule]
  5. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[report]') AND type in (N'U')) DROP TABLE [dbo].[report]
  6. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_user]') AND type in (N'U')) DROP TABLE [dbo].[web_user]
  7. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[query_field]') AND type in (N'U')) DROP TABLE [dbo].[query_field]
  8. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[profile]') AND type in (N'U')) DROP TABLE [dbo].[profile]
  9. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pinsetup]') AND type in (N'U')) DROP TABLE [dbo].[pinsetup]
  10. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phoneuserpbx]') AND type in (N'U')) DROP TABLE [dbo].[phoneuserpbx]
  11. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phone_number]') AND type in (N'U')) DROP TABLE [dbo].[phone_number]
  12. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ldap_log]') AND type in (N'U')) DROP TABLE [dbo].[ldap_log]
  13. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ldapconfig]') AND type in (N'U')) DROP TABLE [dbo].[ldapconfig]
  14. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[holiday]') AND type in (N'U')) DROP TABLE [dbo].[holiday]
  15. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hlr]') AND type in (N'U')) DROP TABLE [dbo].[hlr]
  16. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cpx_authorization]') AND type in (N'U')) DROP TABLE [dbo].[cpx_authorization]
  17. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[counter]') AND type in (N'U')) DROP TABLE [dbo].[counter]
  18. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[client]') AND type in (N'U')) DROP TABLE [dbo].[client]
  19. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cdrmodifier]') AND type in (N'U')) DROP TABLE [dbo].[cdrmodifier]
  20. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[calltransaction]') AND type in (N'U')) DROP TABLE [dbo].[calltransaction]
  21. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[budget]') AND type in (N'U')) DROP TABLE [dbo].[budget]
  22. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[authorization_consent]') AND type in (N'U')) DROP TABLE [dbo].[authorization_consent]
  23. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[additional_cost]') AND type in (N'U')) DROP TABLE [dbo].[additional_cost]
  24. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[account]') AND type in (N'U')) DROP TABLE [dbo].[account]
  25. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phone_user]') AND type in (N'U')) DROP TABLE [dbo].[phone_user]
  26. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[trunk]') AND type in (N'U')) DROP TABLE [dbo].[trunk]
  27. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[rate]') AND type in (N'U')) DROP TABLE [dbo].[rate]
  28. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[zone]') AND type in (N'U')) DROP TABLE [dbo].[zone]
  29. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[rate_page]') AND type in (N'U')) DROP TABLE [dbo].[rate_page]
  30. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pbx]') AND type in (N'U')) DROP TABLE [dbo].[pbx]
  31. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[provider]') AND type in (N'U')) DROP TABLE [dbo].[provider]
  32. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[organization]') AND type in (N'U')) DROP TABLE [dbo].[organization]
  33. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[destination_group]') AND type in (N'U')) DROP TABLE [dbo].[destination_group]
  34. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cost_center]') AND type in (N'U')) DROP TABLE [dbo].[cost_center]
  35. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[corcos]') AND type in (N'U')) DROP TABLE [dbo].[corcos]
  36. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[area]') AND type in (N'U')) DROP TABLE [dbo].[area]
  37. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[account]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[account] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[name] [varchar](100) NOT NULL ,[number] [varchar](4000) NOT NULL ,[counter_cost] [float] NULL ,[counter_duration] [int] NULL ,[counter_freq] [int] NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKg0r31xiwjpn6bes07nsurpgh9] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKns3goek4kokjp7d9yl68uobml] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  38. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[additional_cost]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[additional_cost] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[continued] [int] NULL ,[cr_applied_date] [datetime2](6) NULL ,[cr_direction] [varchar](50) NULL ,[cr_expired_date] [datetime2](6) NULL ,[description] [varchar](255) NULL ,[percentage] [float] NOT NULL ,[percentage_baseon] [varchar](255) NULL ,[sequence] [varchar](255) NULL ,[target] [char](1) NULL ,[value] [float] NOT NULL ,[cr_account_uid] [varchar](255) NULL ,[cr_cost_center_uid] [varchar](255) NULL ,[cr_organization_uid] [varchar](255) NULL ,[cr_phone_user_uid] [varchar](255) NULL ,[cr_rate_page_uid] [varchar](255) NULL ,[cr_trunk_uid] [varchar](255) NULL ,[cr_zone_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKda1te60ega2mx55dcaqf2floe] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKrrqriq0740hbquewaq32l0d7o] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  39. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[area]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[area] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[latitude] [float] NULL ,[longitude] [float] NULL ,[name] [varchar](100) NOT NULL ,[provinsi] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UCAreaCode] UNIQUE NONCLUSTERED ([code] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKefagkhb6w9a5vmwxm8kjnp8ey] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKfhtwmbks1uty2y9fvejl1parb] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  40. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[authorization_consent]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[authorization_consent] ( [principal_name] [varchar](255) NOT NULL ,[registered_client_id] [varchar](255) NOT NULL ,[authorities] [varchar](max) NULL ,PRIMARY KEY CLUSTERED ( [principal_name] ASC ,[registered_client_id] ASC ) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] END
  41. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[budget]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[budget] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[accumulate] [bit] NULL ,[annual_cost] [int] NULL ,[max_auto_calculate] [varchar](255) NULL ,[max_cost] [varchar](255) NULL ,[max_dur] [varchar](255) NULL ,[max_freq] [varchar](255) NULL ,[temp_cost] [varchar](255) NULL ,[type] [char](1) NULL ,[user_type] [char](1) NULL ,[user_uid] [varchar](50) NULL ,[warn_cost_percentage] [varchar](255) NULL ,[warn_dur] [varchar](255) NULL ,[warn_freq] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  42. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[calltransaction]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[calltransaction] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[cost] [float] NOT NULL ,[currency] [varchar](6) NULL ,[direction] [char](3) NULL ,[discount] [float] NOT NULL ,[duration] [int] NOT NULL ,[extension] [varchar](50) NULL ,[number] [varchar](50) NULL ,[phone_type] [char](1) NULL ,[pin] [varchar](100) NULL ,[raw_data] [varchar](8000) NULL ,[service] [float] NOT NULL ,[start_of_call] [datetime2](6) NULL ,[tag] [varchar](4000) NULL ,[tax] [float] NOT NULL ,[account_uid] [varchar](255) NULL ,[area_uid] [varchar](255) NULL ,[cost_center_uid] [varchar](255) NULL ,[destination_group_uid] [varchar](255) NULL ,[organization_uid] [varchar](255) NULL ,[phone_user_uid] [varchar](255) NULL ,[zone_uid] [varchar](255) NULL ,[rate_id] [bigint] NULL ,[trunk_uid] [varchar](255) NULL ,[pbx_uid] [varchar](255) NULL ,[caller_number] [varchar](50) NULL ,[end_of_call] [datetime2](6) NULL ,[ext_transfer_from] [varchar](50) NULL ,[ext_transfer_to] [varchar](50) NULL ,[owner_pin] [varchar](50) NULL ,[pulse] [varchar](50) NULL ,[start_of_answer] [datetime2](6) NULL ,[communication_type] [char](1) NULL ,[conference_type] [char](1) NULL ,[transfer_type] [char](1) NULL ,[access_number] [varchar](12) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  43. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cdrmodifier]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[cdrmodifier] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[action] [varchar](8000) NULL ,[continued] [bit] NOT NULL ,[criteria] [varchar](8000) NULL ,[description] [varchar](255) NOT NULL ,[match] [char](1) NULL ,[order_number] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  44. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[client]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[client] ( [id] [varchar](255) NOT NULL ,[authorization_grant_types] [varchar](max) NULL ,[client_authentication_methods] [varchar](max) NULL ,[client_id] [varchar](255) NULL ,[client_id_issued_at] [datetimeoffset](6) NULL ,[client_name] [varchar](255) NULL ,[client_secret] [varchar](255) NULL ,[client_secret_expires_at] [datetimeoffset](6) NULL ,[client_settings] [varchar](max) NULL ,[post_logout_redirect_uris] [varchar](max) NULL ,[redirect_uris] [varchar](max) NULL ,[scopes] [varchar](max) NULL ,[token_settings] [varchar](max) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] END
  45. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[corcos]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[corcos] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[command] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[name] [varchar](100) NOT NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK95r2819upm5y65lh6ulpngwv1] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKcwf2lhfa03ovdy8pcko9dwfkp] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  46. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cost_center]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[cost_center] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[email] [varchar](255) NULL ,[email_on_over_budget] [bit] NULL ,[name] [varchar](100) NOT NULL ,[structure] [varchar](255) NULL ,[parent_uid] [varchar](255) NULL ,[counter_cost] [float] NULL ,[counter_duration] [int] NULL ,[counter_freq] [int] NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK90f9ok3nekbikmy8s0wajs234] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKg5ij4nw8lpl4sdhg0aoqtbrqt] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  47. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[counter]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[counter] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[account] [int] NULL ,[cost_center] [int] NULL ,[destination_group] [int] NULL ,[organization] [int] NULL ,[phone_user] [int] NULL ,[reset_direction] [char](1) NULL ,[reset_exec_date] [int] NULL ,[reset_exec_time] [datetime2](6) NULL ,[reset_period] [char](1) NULL ,[reset_target] [char](1) NULL ,[trunk] [int] NULL ,[reset_rate_page_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  48. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cpx_authorization]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[cpx_authorization] ( [id] [varchar](255) NOT NULL ,[access_token_expires_at] [datetimeoffset](6) NULL ,[access_token_issued_at] [datetimeoffset](6) NULL ,[access_token_metadata] [varchar](max) NULL ,[access_token_scopes] [varchar](max) NULL ,[access_token_type] [varchar](255) NULL ,[access_token_value] [varchar](max) NULL ,[attributes] [varchar](max) NULL ,[authorization_code_expires_at] [datetimeoffset](6) NULL ,[authorization_code_issued_at] [datetimeoffset](6) NULL ,[authorization_code_metadata] [varchar](255) NULL ,[authorization_code_value] [varchar](max) NULL ,[authorization_grant_type] [varchar](255) NULL ,[authorized_scopes] [varchar](1000) NULL ,[device_code_expires_at] [datetimeoffset](6) NULL ,[device_code_issued_at] [datetimeoffset](6) NULL ,[device_code_metadata] [varchar](max) NULL ,[device_code_value] [varchar](max) NULL ,[oidc_id_token_claims] [varchar](max) NULL ,[oidc_id_token_expires_at] [datetimeoffset](6) NULL ,[oidc_id_token_issued_at] [datetimeoffset](6) NULL ,[oidc_id_token_metadata] [varchar](max) NULL ,[oidc_id_token_value] [varchar](max) NULL ,[principal_name] [varchar](255) NULL ,[refresh_token_expires_at] [datetimeoffset](6) NULL ,[refresh_token_issued_at] [datetimeoffset](6) NULL ,[refresh_token_metadata] [varchar](max) NULL ,[refresh_token_value] [varchar](max) NULL ,[registered_client_id] [varchar](255) NULL ,[state] [varchar](500) NULL ,[user_code_expires_at] [datetimeoffset](6) NULL ,[user_code_issued_at] [datetimeoffset](6) NULL ,[user_code_metadata] [varchar](max) NULL ,[user_code_value] [varchar](max) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] END
  49. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[destination_group]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[destination_group] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[name] [varchar](100) NOT NULL ,[number] [varchar](4000) NOT NULL ,[type] [char](1) NULL ,[counter_cost] [float] NULL ,[counter_duration] [int] NULL ,[counter_freq] [int] NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKqw7y6gcbp5nluu5vrtgxlgnln] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKsgrorq9e0fxpl3eod6gm761og] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  50. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hlr]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[hlr] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[area] [varchar](50) NOT NULL ,[city_name] [varchar](100) NOT NULL ,[domain] [varchar](6) NOT NULL ,[holiday] [int] NULL ,[phone_type] [char](1) NULL ,[prefix] [varchar](12) NOT NULL ,[sub_domain] [varchar](6) NULL ,[provider_uid] [varchar](255) NULL ,[zone_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKe89x0s7xmqjdn22ip2s4f1sxw] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKocgju2or3vy6hnv283rp5eatp] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  51. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[holiday]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[holiday] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[annual] [bit] NULL ,[description] [varchar](255) NOT NULL ,[holiday] [datetime2](6) NULL ,[page] [int] NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  52. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ldap_log]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[ldap_log] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[detail] [varchar](255) NULL ,[ldap_uid] [varchar](255) NULL ,[import_time] [datetime2](6) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  53. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ldapconfig]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[ldapconfig] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[attr_code] [varchar](100) NULL ,[attr_email] [varchar](100) NULL ,[attr_ext] [varchar](100) NULL ,[attr_name] [varchar](100) NULL ,[attr_org_code] [varchar](100) NULL ,[attr_org_name] [varchar](100) NULL ,[attr_pin] [varchar](100) NULL ,[auth_type] [char](1) NULL ,[basedn] [varchar](255) NOT NULL ,[conn_type] [char](1) NULL ,[filter_attr] [varchar](255) NULL ,[host] [varchar](100) NOT NULL ,[login_attr] [varchar](100) NULL ,[name] [varchar](100) NOT NULL ,[password] [varchar](255) NOT NULL ,[period] [char](1) NULL ,[period_time] [time](7) NULL ,[port] [varchar](3) NOT NULL ,[username] [varchar](255) NOT NULL ,[version] [varchar](1) NOT NULL ,[date_schedule] [int] NULL ,[datetime_start] [datetime2](6) NULL ,[day_schedule] [char](1) NULL ,[hour_schedule] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK9br9e6d42cwsn4u08mpiij2e3] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKiu377pir58unid8w4g8nc0q1w] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  54. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[organization]') AND type IN(N'U')) BEGIN CREATE TABLE [dbo].[organization] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[email] [varchar](255) NULL ,[email_on_over_budget] [bit] NULL ,[name] [varchar](100) NOT NULL ,[structure] [varchar](255) NULL ,[parent_uid] [varchar](255) NULL ,[counter_cost] [float] NULL ,[counter_duration] [int] NULL ,[counter_freq] [int] NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ,CONSTRAINT [UKgan7juxxybpr7dnc6rq9rgf1b] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKo582oodbehae8ilakotnoqyfa] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  55. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pbx]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[pbx] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[location] [varchar](100) NULL ,[name] [varchar](50) NOT NULL ,[pbx_supporter] [int] NULL ,[area_uid] [varchar](255) NULL ,[provider_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK6v26ap07yhri3gjhrqms41ccc] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKbo6ykneanq0s86b9mrmi4ln32] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  56. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phone_number]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[phone_number] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[name] [varchar](100) NOT NULL ,[number] [varchar](50) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKo4xmgnniquxt3xxf0e8fwiwpa] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKoxj2wfoq9h0dqehod6myjwsmo] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  57. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phone_user]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[phone_user] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[category] [varchar](50) NULL ,[code] [varchar](12) NOT NULL ,[counter_cost] [float] NULL ,[counter_duration] [int] NULL ,[counter_freq] [int] NULL ,[email] [varchar](255) NULL ,[name] [varchar](50) NOT NULL ,[phone_book_rights] [varchar](255) NULL ,[position] [varchar](50) NULL ,[report_order] [varchar](255) NULL ,[tags] [varchar](4000) NULL ,[whatsapp] [varchar](50) NULL ,[corcos_block_uid] [varchar](255) NULL ,[corcos_normal_uid] [varchar](255) NULL ,[corcos_reducing_uid] [varchar](255) NULL ,[cost_center_uid] [varchar](255) NULL ,[destination_group_uid] [varchar](255) NULL ,[organization_uid] [varchar](255) NULL ,[rate_page_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK2lwj0henswh1er2pgr99w45d0] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKedhq4soinr7r0kmj54a6495f8] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  58. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phoneuserpbx]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[phoneuserpbx] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[extension] [varchar](4000) NULL ,[pin] [varchar](100) NULL ,[pbx_uid] [varchar](255) NULL ,[phone_user_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK8e06t1jj2hlha6ro7qwnc8il5] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKj1chy8r2ksbqg4anj2prpwddm] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  59. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pinsetup]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[pinsetup] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[exec_date] [int] NULL ,[exec_time] [time](7) NULL ,[flag] [char](1) NULL ,[period] [char](1) NULL ,[start_date] [datetime2](6) NULL ,[target] [char](1) NULL ,[user_target] [varchar](255) NULL ,[pbx_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  60. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[profile]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[profile] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[name] [varchar](100) NOT NULL ,[rights] [varchar](100) NOT NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UCProfileName] UNIQUE NONCLUSTERED ([name] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK72ubcp4jyvymgs58u2qebwtl2] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKt3dqc5xqio84wwjq350e8cr6w] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  61. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[provider]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[provider] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[code] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[name] [varchar](50) NOT NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UCProviderCode] UNIQUE NONCLUSTERED ([code] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKep9duujaqlym9k5xl93p0u8dw] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKml34l3gm0pj4oges8rovutexg] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  62. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[query_field]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[query_field] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[column_name] [varchar](50) NOT NULL ,[data_type] [varchar](50) NOT NULL ,[description] [varchar](255) NULL ,[join_table] [varchar](50) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  63. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[rate]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[rate] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[day_code] [varchar](8) NULL ,[tarif] [varchar](8000) NULL ,[provider_from_uid] [varchar](255) NOT NULL ,[provider_to_uid] [varchar](255) NULL ,[rate_page_uid] [varchar](255) NULL ,[zone_uid] [varchar](255) NOT NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  64. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[rate_page]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[rate_page] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[name] [varchar](100) NOT NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UCRatePageName] UNIQUE NONCLUSTERED ([name] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK2j1gxqkqosdp8u6w6yf8uvbdv] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKqtm1hasulqwx0nkrak8sdqqo0] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  65. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[report]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[report] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[description] [varchar](255) NOT NULL ,[display_column] [varchar](255) NULL ,[filter_list] [varchar](255) NULL ,[lang] [char](1) NULL ,[sort_list] [varchar](255) NULL ,[template_name] [varchar](50) NOT NULL ,[title] [varchar](100) NOT NULL ,[rights] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK1ie06vhy3begtwuuvrv0f71se] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKjctupmv448qg1txp89cn2tvnn] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  66. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[schedule]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[schedule] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[date_schedule] [int] NULL ,[datetime_exec] [datetime2](6) NULL ,[datetime_start] [datetime2](6) NULL ,[day_schedule] [char](1) NULL ,[display_column] [varchar](255) NULL ,[email] [varchar](255) NOT NULL ,[file_format] [char](1) NULL ,[filter_label] [varchar](255) NULL ,[hour_schedule] [varchar](255) NULL ,[iterance] [char](1) NULL ,[report_filter] [varchar](255) NULL ,[sort_label] [varchar](255) NULL ,[title] [varchar](255) NULL ,[unit] [char](1) NULL ,[unit_count] [int] NULL ,[report_uid] [varchar](255) NULL ,[report_sort] [varchar](255) NULL ,[unit_flag] [bit] NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  67. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tag]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[tag] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[description] [varchar](255) NULL ,[flag] [bit] NULL ,[name] [varchar](100) NOT NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKeelbh6x3t14h473mxxnwugclj] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKjhsskogott48402sr2wjiudr] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  68. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ticket]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[ticket] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[request_date] [datetime2](6) NULL ,[request_group] [varchar](4000) NULL ,[request_note] [varchar](255) NULL ,[request_type] [char](1) NULL ,[request_value] [float] NULL ,[result] [char](1) NULL ,[result_date] [datetime2](6) NULL ,[result_group] [varchar](4000) NULL ,[result_note] [varchar](255) NULL ,[result_value] [float] NULL ,[ticket] [varchar](255) NULL ,[type] [char](1) NULL ,[request_corcos_uid] [varchar](255) NULL ,[request_pbx_uid] [varchar](255) NULL ,[requester_uid] [varchar](255) NULL ,[result_by_uid] [varchar](255) NULL ,[tag_uid] [varchar](255) NULL ,[target_corcos_uid] [varchar](255) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  69. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[trunk]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[trunk] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[applied_date] [datetime2](6) NULL ,[expired_date] [datetime2](6) NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[abonemen] [float] NULL ,[code] [varchar](12) NOT NULL ,[direction] [varchar](50) NULL ,[name] [varchar](100) NOT NULL ,[subscribed_no] [varchar](50) NULL ,[area_uid] [varchar](255) NULL ,[pbx_uid] [varchar](255) NOT NULL ,[provider_uid] [varchar](255) NULL ,[counter_cost] [float] NULL ,[counter_duration] [int] NULL ,[counter_freq] [int] NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKkng4lg3dsslt3h4w701cli9m] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKrdxxkyi2hij8j1jgq43wcol2o] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  70. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_user]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[web_user] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[last_edit_by] [varchar](255) NULL ,[last_edit_time] [datetime2](6) NULL ,[cost_center] [varchar](4000) NULL ,[destination_group] [varchar](4000) NULL ,[lang] [char](1) NULL ,[last_login] [datetime2](6) NULL ,[name] [varchar](255) NOT NULL ,[organization] [varchar](4000) NULL ,[password] [varchar](255) NOT NULL ,[phone_user_tag] [varchar](4000) NULL ,[rights] [varchar](255) NULL ,[rights_budget_pin] [varchar](4000) NULL ,[rights_group] [varchar](4000) NULL ,[username] [varchar](100) NOT NULL ,[ldap_uid] [varchar](255) NULL ,[phone_user_uid] [varchar](255) NULL ,[pinext_uid] [varchar](255) NULL ,[profile_uid] [varchar](255) NULL ,[last_active_datetime] [datetime2](6) NULL ,[rights_approval] [char](1) NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UCWebUserUsername] UNIQUE NONCLUSTERED ([username] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK3583rwkvhq1st255fk01dqidp] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKgqp8bs2nvynsedxok0pq7n24q] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  71. IF NOT EXISTS( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[zone]') AND type IN (N'U')) BEGIN CREATE TABLE [dbo].[zone] ( [id] [bigint] IDENTITY(1, 1) NOT NULL ,[uid] [varchar](255) NOT NULL ,[code] [varchar](12) NOT NULL ,[description] [varchar](255) NULL ,[name] [varchar](100) NOT NULL ,PRIMARY KEY CLUSTERED ([id] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UCZoneCode] UNIQUE NONCLUSTERED ([code] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UK7ma27s0bh5jx5y32dth08yvqg] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ,CONSTRAINT [UKotmclh5xwnrkho38m52d4eehx] UNIQUE NONCLUSTERED ([uid] ASC) WITH ( PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] END
  72. IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal4]')) DROP VIEW [dbo].[quartal4]
  73. IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal3]')) DROP VIEW [dbo].[quartal3]
  74. IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal2]')) DROP VIEW [dbo].[quartal2]
  75. IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal1]')) DROP VIEW [dbo].[quartal1]
  76. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal1]')) EXEC dbo.sp_executesql @statement = N' CREATE VIEW [dbo].[quartal1] AS SELECT TOP 100 PERCENT o.name ,(b.annual_cost / 12) * 3 AS budget_1 ,CASE WHEN month(getdate()) BETWEEN 1 AND 3 THEN( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) AND dateadd(mm, - 9, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) AND organization_uid = o.uid) ELSE 0 END AS actual_1 ,(b.annual_cost / 12) * 3 - CASE WHEN month(getdate()) BETWEEN 1 AND 3 THEN ( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) AND dateadd(mm, - 9, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) AND organization_uid = o.uid ) ELSE 0 END AS variance_1 FROM budget b LEFT JOIN organization o ON o.uid = b.user_uid LEFT JOIN calltransaction c ON o.uid = c.organization_uid WHERE b.user_type = 1 AND o.counter_cost > 0 AND c.start_of_call BETWEEN DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) AND dateadd(mm, - 9, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) GROUP BY o.name ,o.counter_cost ,b.annual_cost ,o.uid ORDER BY b.annual_cost DESC '
  77. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal2]')) EXEC dbo.sp_executesql @statement = N' CREATE VIEW [dbo].[quartal2] AS SELECT TOP 100 PERCENT o.name ,(b.annual_cost / 12) * 3 AS budget_1 ,CASE WHEN month(getdate()) BETWEEN 4 AND 6 THEN( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN dateadd(mm, 3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND dateadd(mm, - 6, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) AND organization_uid = o.uid) ELSE 0 END AS actual_1 ,(b.annual_cost / 12) * 3 - CASE WHEN month(getdate()) BETWEEN 4 AND 6 THEN ( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN dateadd(mm, 3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND dateadd(mm, - 6, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) AND organization_uid = o.uid ) ELSE 0 END AS variance_1 FROM budget b LEFT JOIN organization o ON o.uid = b.user_uid LEFT JOIN calltransaction c ON o.uid = c.organization_uid WHERE b.user_type = 1 AND o.counter_cost > 0 AND c.start_of_call BETWEEN dateadd(mm, 3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND dateadd(mm, - 6, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) GROUP BY o.name ,o.counter_cost ,b.annual_cost ,o.uid ORDER BY b.annual_cost DESC '
  78. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal3]')) EXEC dbo.sp_executesql @statement = N' CREATE VIEW [dbo].[quartal3] AS SELECT TOP 100 PERCENT o.name ,(b.annual_cost / 12) * 3 AS budget_1 ,CASE WHEN month(getdate()) BETWEEN 7 AND 9 THEN( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN dateadd(mm, 6, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND dateadd(mm, - 3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) AND organization_uid = o.uid) ELSE 0 END AS actual_1 ,(b.annual_cost / 12) * 3 - CASE WHEN month(getdate()) BETWEEN 7 AND 9 THEN ( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN dateadd(mm, 6, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND dateadd(mm, - 3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) AND organization_uid = o.uid ) ELSE 0 END AS variance_1 FROM budget b LEFT JOIN organization o ON o.uid = b.user_uid LEFT JOIN calltransaction c ON o.uid = c.organization_uid WHERE b.user_type = 1 AND o.counter_cost > 0 AND c.start_of_call BETWEEN dateadd(mm, 6, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND dateadd(mm, - 3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1)) GROUP BY o.name ,o.counter_cost ,b.annual_cost ,o.uid ORDER BY b.annual_cost DESC '
  79. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[quartal4]')) EXEC dbo.sp_executesql @statement = N' CREATE VIEW [dbo].[quartal4] AS SELECT TOP 100 PERCENT o.name ,(b.annual_cost / 12) * 3 AS budget_1 ,CASE WHEN month(getdate()) BETWEEN 10 AND 12 THEN( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN dateadd(mm, 9, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1) AND organization_uid = o.uid) ELSE 0 END AS actual_1 ,(b.annual_cost / 12) * 3 - CASE WHEN month(getdate()) BETWEEN 10 AND 12 THEN ( SELECT isnull(sum(cost), 0) FROM calltransaction WHERE start_of_call BETWEEN dateadd(mm, 9, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1) AND organization_uid = o.uid ) ELSE 0 END AS variance_1 FROM budget b LEFT JOIN organization o ON o.uid = b.user_uid LEFT JOIN calltransaction c ON o.uid = c.organization_uid WHERE b.user_type = 1 AND o.counter_cost > 0 AND c.start_of_call BETWEEN dateadd(mm, 9, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1) GROUP BY o.name ,o.counter_cost ,b.annual_cost ,o.uid ORDER BY b.annual_cost DESC '
  80. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reset_counter]') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].[reset_counter]
  81. IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reset_counter]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) BEGIN EXECUTE dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[reset_counter] AS BEGIN BEGIN UPDATE phone_user SET counter_cost = 0; UPDATE organization SET counter_cost = 0; UPDATE cost_center SET counter_cost = 0; UPDATE budget SET temp_cost = ''0;0;0;0;0;0;0;0;0;0;0;0'' END; END; ' END
  82. CREATE UNIQUE NONCLUSTERED INDEX [UCHolidayDate] ON [dbo].[holiday]( [holiday] ASC) WHERE ([holiday] IS NOT NULL) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  83. CREATE UNIQUE NONCLUSTERED INDEX [UCHolidayDatePage] ON [dbo].[holiday]( [holiday] ASC, [page] ASC) WHERE ([holiday] IS NOT NULL AND [page] IS NOT NULL) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  84. CREATE UNIQUE NONCLUSTERED INDEX [UCTicketNumber] ON [dbo].[ticket]( [ticket] ASC) WHERE ([ticket] IS NOT NULL) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  85. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CONSTRAINT [FKAdditionalAccount] FOREIGN KEY([cr_account_uid]) REFERENCES [dbo].[account] ([uid])
  86. ALTER TABLE [dbo].[additional_cost] CHECK CONSTRAINT [FKAdditionalAccount]
  87. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CONSTRAINT [FKAdditionalCostCenter] FOREIGN KEY([cr_cost_center_uid]) REFERENCES [dbo].[cost_center] ([uid])
  88. ALTER TABLE [dbo].[additional_cost] CHECK CONSTRAINT [FKAdditionalCostCenter]
  89. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CONSTRAINT [FKAdditionalCostRatePage] FOREIGN KEY([cr_rate_page_uid]) REFERENCES [dbo].[rate_page] ([uid])
  90. ALTER TABLE [dbo].[additional_cost] CHECK CONSTRAINT [FKAdditionalCostRatePage]
  91. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CONSTRAINT [FKAdditionalCostZone] FOREIGN KEY([cr_zone_uid]) REFERENCES [dbo].[zone] ([uid])
  92. ALTER TABLE [dbo].[additional_cost] CHECK CONSTRAINT [FKAdditionalCostZone]
  93. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CONSTRAINT [FKAdditionalOrganization] FOREIGN KEY([cr_organization_uid]) REFERENCES [dbo].[organization] ([uid])
  94. ALTER TABLE [dbo].[additional_cost] CHECK CONSTRAINT [FKAdditionalOrganization]
  95. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CONSTRAINT [FKAdditionalPhoneUser] FOREIGN KEY([cr_phone_user_uid]) REFERENCES [dbo].[phone_user] ([uid])
  96. ALTER TABLE [dbo].[additional_cost] CHECK CONSTRAINT [FKAdditionalPhoneUser]
  97. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CONSTRAINT [FKAdditionalTrunk] FOREIGN KEY([cr_trunk_uid]) REFERENCES [dbo].[trunk] ([uid])
  98. ALTER TABLE [dbo].[additional_cost] CHECK CONSTRAINT [FKAdditionalTrunk]
  99. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionAccount] FOREIGN KEY([account_uid]) REFERENCES [dbo].[account] ([uid])
  100. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionAccount]
  101. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionArea] FOREIGN KEY([area_uid]) REFERENCES [dbo].[area] ([uid])
  102. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionArea]
  103. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionCostCenter] FOREIGN KEY([cost_center_uid]) REFERENCES [dbo].[cost_center] ([uid])
  104. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionCostCenter]
  105. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionDestinationGroup] FOREIGN KEY([destination_group_uid]) REFERENCES [dbo].[destination_group] ([uid])
  106. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionDestinationGroup]
  107. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionOrganization] FOREIGN KEY([organization_uid]) REFERENCES [dbo].[organization] ([uid])
  108. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionOrganization]
  109. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionPbx] FOREIGN KEY([pbx_uid]) REFERENCES [dbo].[pbx] ([uid])
  110. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionPbx]
  111. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionPhoneUser] FOREIGN KEY([phone_user_uid]) REFERENCES [dbo].[phone_user] ([uid])
  112. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionPhoneUser]
  113. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionRate] FOREIGN KEY([rate_id]) REFERENCES [dbo].[rate] ([id])
  114. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionRate]
  115. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionTrunk] FOREIGN KEY([trunk_uid]) REFERENCES [dbo].[trunk] ([uid])
  116. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionTrunk]
  117. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CONSTRAINT [FKTransactionZone] FOREIGN KEY([zone_uid]) REFERENCES [dbo].[zone] ([uid])
  118. ALTER TABLE [dbo].[calltransaction] CHECK CONSTRAINT [FKTransactionZone]
  119. ALTER TABLE [dbo].[cost_center] WITH CHECK ADD CONSTRAINT [FKCostCenterParent] FOREIGN KEY([parent_uid]) REFERENCES [dbo].[cost_center] ([uid])
  120. ALTER TABLE [dbo].[cost_center] CHECK CONSTRAINT [FKCostCenterParent]
  121. ALTER TABLE [dbo].[counter] WITH CHECK ADD CONSTRAINT [FKCounterRatePage] FOREIGN KEY([reset_rate_page_uid]) REFERENCES [dbo].[rate_page] ([uid])
  122. ALTER TABLE [dbo].[counter] CHECK CONSTRAINT [FKCounterRatePage]
  123. ALTER TABLE [dbo].[hlr] WITH CHECK ADD CONSTRAINT [FKHlrProvider] FOREIGN KEY([provider_uid]) REFERENCES [dbo].[provider] ([uid])
  124. ALTER TABLE [dbo].[hlr] CHECK CONSTRAINT [FKHlrProvider]
  125. ALTER TABLE [dbo].[hlr] WITH CHECK ADD CONSTRAINT [FKHlrZone] FOREIGN KEY([zone_uid]) REFERENCES [dbo].[zone] ([uid])
  126. ALTER TABLE [dbo].[hlr] CHECK CONSTRAINT [FKHlrZone]
  127. ALTER TABLE [dbo].[ldap_log] WITH CHECK ADD CONSTRAINT [FKLapConfigLdapLog] FOREIGN KEY([ldap_uid]) REFERENCES [dbo].[ldapconfig] ([uid])
  128. ALTER TABLE [dbo].[ldap_log] CHECK CONSTRAINT [FKLapConfigLdapLog]
  129. ALTER TABLE [dbo].[organization] WITH CHECK ADD CONSTRAINT [FKOrganizationParent] FOREIGN KEY([parent_uid]) REFERENCES [dbo].[organization] ([uid])
  130. ALTER TABLE [dbo].[organization] CHECK CONSTRAINT [FKOrganizationParent]
  131. ALTER TABLE [dbo].[pbx] WITH CHECK ADD CONSTRAINT [FKPbxArea] FOREIGN KEY([area_uid]) REFERENCES [dbo].[area] ([uid])
  132. ALTER TABLE [dbo].[pbx] CHECK CONSTRAINT [FKPbxArea]
  133. ALTER TABLE [dbo].[pbx] WITH CHECK ADD CONSTRAINT [FKPbxProvider] FOREIGN KEY([provider_uid]) REFERENCES [dbo].[provider] ([uid])
  134. ALTER TABLE [dbo].[pbx] CHECK CONSTRAINT [FKPbxProvider]
  135. ALTER TABLE [dbo].[phone_user] WITH CHECK ADD CONSTRAINT [FKPhoneUserCorcosBlock] FOREIGN KEY([corcos_block_uid]) REFERENCES [dbo].[corcos] ([uid])
  136. ALTER TABLE [dbo].[phone_user] CHECK CONSTRAINT [FKPhoneUserCorcosBlock]
  137. ALTER TABLE [dbo].[phone_user] WITH CHECK ADD CONSTRAINT [FKPhoneUserCorcosNormal] FOREIGN KEY([corcos_normal_uid]) REFERENCES [dbo].[corcos] ([uid])
  138. ALTER TABLE [dbo].[phone_user] CHECK CONSTRAINT [FKPhoneUserCorcosNormal]
  139. ALTER TABLE [dbo].[phone_user] WITH CHECK ADD CONSTRAINT [FKPhoneUserCorcosReducing] FOREIGN KEY([corcos_reducing_uid]) REFERENCES [dbo].[corcos] ([uid])
  140. ALTER TABLE [dbo].[phone_user] CHECK CONSTRAINT [FKPhoneUserCorcosReducing]
  141. ALTER TABLE [dbo].[phone_user] WITH CHECK ADD CONSTRAINT [FKPhoneUserCostCenter] FOREIGN KEY([cost_center_uid]) REFERENCES [dbo].[cost_center] ([uid])
  142. ALTER TABLE [dbo].[phone_user] CHECK CONSTRAINT [FKPhoneUserCostCenter]
  143. ALTER TABLE [dbo].[phone_user] WITH CHECK ADD CONSTRAINT [FKPhoneUserDestinationGroup] FOREIGN KEY([destination_group_uid]) REFERENCES [dbo].[destination_group] ([uid])
  144. ALTER TABLE [dbo].[phone_user] CHECK CONSTRAINT [FKPhoneUserDestinationGroup]
  145. ALTER TABLE [dbo].[phone_user] WITH CHECK ADD CONSTRAINT [FKPhoneUserOrganization] FOREIGN KEY([organization_uid]) REFERENCES [dbo].[organization] ([uid])
  146. ALTER TABLE [dbo].[phone_user] CHECK CONSTRAINT [FKPhoneUserOrganization]
  147. ALTER TABLE [dbo].[phone_user] WITH CHECK ADD CONSTRAINT [FKPhoneUserRatePage] FOREIGN KEY([rate_page_uid]) REFERENCES [dbo].[rate_page] ([uid])
  148. ALTER TABLE [dbo].[phone_user] CHECK CONSTRAINT [FKPhoneUserRatePage]
  149. ALTER TABLE [dbo].[phoneuserpbx] WITH CHECK ADD CONSTRAINT [FKPhoneUserPbxPbx] FOREIGN KEY([pbx_uid]) REFERENCES [dbo].[pbx] ([uid])
  150. ALTER TABLE [dbo].[phoneuserpbx] CHECK CONSTRAINT [FKPhoneUserPbxPbx]
  151. ALTER TABLE [dbo].[phoneuserpbx] WITH CHECK ADD CONSTRAINT [FKPhoneUserPbxPhoneUser] FOREIGN KEY([phone_user_uid]) REFERENCES [dbo].[phone_user] ([uid])
  152. ALTER TABLE [dbo].[phoneuserpbx] CHECK CONSTRAINT [FKPhoneUserPbxPhoneUser]
  153. ALTER TABLE [dbo].[pinsetup] WITH CHECK ADD CONSTRAINT [FKPinSetupPbx] FOREIGN KEY([pbx_uid]) REFERENCES [dbo].[pbx] ([uid])
  154. ALTER TABLE [dbo].[pinsetup] CHECK CONSTRAINT [FKPinSetupPbx]
  155. ALTER TABLE [dbo].[rate] WITH CHECK ADD CONSTRAINT [FKRateProviderFrom] FOREIGN KEY([provider_from_uid]) REFERENCES [dbo].[provider] ([uid])
  156. ALTER TABLE [dbo].[rate] CHECK CONSTRAINT [FKRateProviderFrom]
  157. ALTER TABLE [dbo].[rate] WITH CHECK ADD CONSTRAINT [FKRateProviderTo] FOREIGN KEY([provider_to_uid]) REFERENCES [dbo].[provider] ([uid])
  158. ALTER TABLE [dbo].[rate] CHECK CONSTRAINT [FKRateProviderTo]
  159. ALTER TABLE [dbo].[rate] WITH CHECK ADD CONSTRAINT [FKRateRatePage] FOREIGN KEY([rate_page_uid]) REFERENCES [dbo].[rate_page] ([uid])
  160. ALTER TABLE [dbo].[rate] CHECK CONSTRAINT [FKRateRatePage]
  161. ALTER TABLE [dbo].[rate] WITH CHECK ADD CONSTRAINT [FKRateZone] FOREIGN KEY([zone_uid]) REFERENCES [dbo].[zone] ([uid])
  162. ALTER TABLE [dbo].[rate] CHECK CONSTRAINT [FKRateZone]
  163. ALTER TABLE [dbo].[schedule] WITH CHECK ADD CONSTRAINT [FKReportSchedule] FOREIGN KEY([report_uid]) REFERENCES [dbo].[report] ([uid])
  164. ALTER TABLE [dbo].[schedule] CHECK CONSTRAINT [FKReportSchedule]
  165. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CONSTRAINT [FKTicketCorcos] FOREIGN KEY([target_corcos_uid]) REFERENCES [dbo].[corcos] ([uid])
  166. ALTER TABLE [dbo].[ticket] CHECK CONSTRAINT [FKTicketCorcos]
  167. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CONSTRAINT [FKTicketRequestCorcos] FOREIGN KEY([request_corcos_uid]) REFERENCES [dbo].[corcos] ([uid])
  168. ALTER TABLE [dbo].[ticket] CHECK CONSTRAINT [FKTicketRequestCorcos]
  169. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CONSTRAINT [FKTicketRequestPbx] FOREIGN KEY([request_pbx_uid]) REFERENCES [dbo].[pbx] ([uid])
  170. ALTER TABLE [dbo].[ticket] CHECK CONSTRAINT [FKTicketRequestPbx]
  171. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CONSTRAINT [FKTicketTag] FOREIGN KEY([tag_uid]) REFERENCES [dbo].[tag] ([uid])
  172. ALTER TABLE [dbo].[ticket] CHECK CONSTRAINT [FKTicketTag]
  173. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CONSTRAINT [FKTicketWebUserRequester] FOREIGN KEY([requester_uid]) REFERENCES [dbo].[web_user] ([uid])
  174. ALTER TABLE [dbo].[ticket] CHECK CONSTRAINT [FKTicketWebUserRequester]
  175. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CONSTRAINT [FKTicketWebUserResultBy] FOREIGN KEY([result_by_uid]) REFERENCES [dbo].[web_user] ([uid])
  176. ALTER TABLE [dbo].[ticket] CHECK CONSTRAINT [FKTicketWebUserResultBy]
  177. ALTER TABLE [dbo].[trunk] WITH CHECK ADD CONSTRAINT [FKTrunkArea] FOREIGN KEY([area_uid]) REFERENCES [dbo].[area] ([uid])
  178. ALTER TABLE [dbo].[trunk] CHECK CONSTRAINT [FKTrunkArea]
  179. ALTER TABLE [dbo].[trunk] WITH CHECK ADD CONSTRAINT [FKTrunkPbx] FOREIGN KEY([pbx_uid]) REFERENCES [dbo].[pbx] ([uid])
  180. ALTER TABLE [dbo].[trunk] CHECK CONSTRAINT [FKTrunkPbx]
  181. ALTER TABLE [dbo].[trunk] WITH CHECK ADD CONSTRAINT [FKTrunkProvider] FOREIGN KEY([provider_uid]) REFERENCES [dbo].[provider] ([uid])
  182. ALTER TABLE [dbo].[trunk] CHECK CONSTRAINT [FKTrunkProvider]
  183. ALTER TABLE [dbo].[web_user] WITH CHECK ADD CONSTRAINT [FKWebUserLdapConfig] FOREIGN KEY([ldap_uid]) REFERENCES [dbo].[ldapconfig] ([uid])
  184. ALTER TABLE [dbo].[web_user] CHECK CONSTRAINT [FKWebUserLdapConfig]
  185. ALTER TABLE [dbo].[web_user] WITH CHECK ADD CONSTRAINT [FKWebUserPBX] FOREIGN KEY([pinext_uid]) REFERENCES [dbo].[pbx] ([uid])
  186. ALTER TABLE [dbo].[web_user] CHECK CONSTRAINT [FKWebUserPBX]
  187. ALTER TABLE [dbo].[web_user] WITH CHECK ADD CONSTRAINT [FKWebUserPhoneUser] FOREIGN KEY([phone_user_uid]) REFERENCES [dbo].[phone_user] ([uid])
  188. ALTER TABLE [dbo].[web_user] CHECK CONSTRAINT [FKWebUserPhoneUser]
  189. ALTER TABLE [dbo].[web_user] WITH CHECK ADD CONSTRAINT [FKWebUserProfile] FOREIGN KEY([profile_uid]) REFERENCES [dbo].[profile] ([uid])
  190. ALTER TABLE [dbo].[web_user] CHECK CONSTRAINT [FKWebUserProfile]
  191. ALTER TABLE [dbo].[additional_cost] WITH CHECK ADD CHECK (([target]>=(0) AND [target]<=(4)))
  192. ALTER TABLE [dbo].[budget] WITH CHECK ADD CHECK (([type]>=(0) AND [type]<=(2)))
  193. ALTER TABLE [dbo].[budget] WITH CHECK ADD CHECK (([user_type]>=(0) AND [user_type]<=(6)))
  194. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CHECK (([communication_type]>=(0) AND [communication_type]<=(2)))
  195. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CHECK (([conference_type]>=(0) AND [conference_type]<=(1)))
  196. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CHECK (([direction]>=(0) AND [direction]<=(3)))
  197. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CHECK (([phone_type]>=(0) AND [phone_type]<=(2)))
  198. ALTER TABLE [dbo].[calltransaction] WITH CHECK ADD CHECK (([transfer_type]>=(0) AND [transfer_type]<=(3)))
  199. ALTER TABLE [dbo].[cdrmodifier] WITH CHECK ADD CHECK (([match]>=(0) AND [match]<=(2)))
  200. ALTER TABLE [dbo].[counter] WITH CHECK ADD CHECK (([reset_direction]>=(0) AND [reset_direction]<=(3)))
  201. ALTER TABLE [dbo].[counter] WITH CHECK ADD CHECK (([reset_period]>=(0) AND [reset_period]<=(4)))
  202. ALTER TABLE [dbo].[counter] WITH CHECK ADD CHECK (([reset_target]>=(0) AND [reset_target]<=(3)))
  203. ALTER TABLE [dbo].[destination_group] WITH CHECK ADD CHECK (([type]>=(0) AND [type]<=(2)))
  204. ALTER TABLE [dbo].[hlr] WITH CHECK ADD CHECK (([phone_type]>=(0) AND [phone_type]<=(2)))
  205. ALTER TABLE [dbo].[ldapconfig] WITH CHECK ADD CHECK (([auth_type]>=(0) AND [auth_type]<=(2)))
  206. ALTER TABLE [dbo].[ldapconfig] WITH CHECK ADD CHECK (([conn_type]>=(0) AND [conn_type]<=(4)))
  207. ALTER TABLE [dbo].[ldapconfig] WITH CHECK ADD CHECK (([day_schedule]>=(0) AND [day_schedule]<=(8)))
  208. ALTER TABLE [dbo].[ldapconfig] WITH CHECK ADD CHECK (([period]>=(0) AND [period]<=(6)))
  209. ALTER TABLE [dbo].[pinsetup] WITH CHECK ADD CHECK (([flag]>=(0) AND [flag]<=(2)))
  210. ALTER TABLE [dbo].[pinsetup] WITH CHECK ADD CHECK (([period]>=(0) AND [period]<=(4)))
  211. ALTER TABLE [dbo].[pinsetup] WITH CHECK ADD CHECK (([target]>=(0) AND [target]<=(2)))
  212. ALTER TABLE [dbo].[report] WITH CHECK ADD CHECK (([lang]>=(0) AND [lang]<=(2)))
  213. ALTER TABLE [dbo].[schedule] WITH CHECK ADD CHECK (([day_schedule]>=(0) AND [day_schedule]<=(3)))
  214. ALTER TABLE [dbo].[schedule] WITH CHECK ADD CHECK (([file_format]>=(0) AND [file_format]<=(4)))
  215. ALTER TABLE [dbo].[schedule] WITH CHECK ADD CHECK (([iterance]>=(0) AND [iterance]<=(6)))
  216. ALTER TABLE [dbo].[schedule] WITH CHECK ADD CHECK (([unit]>=(0) AND [unit]<=(3)))
  217. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CHECK (([request_type]>=(0) AND [request_type]<=(2)))
  218. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CHECK (([result]>=(0) AND [result]<=(3)))
  219. ALTER TABLE [dbo].[ticket] WITH CHECK ADD CHECK (([type]>=(0) AND [type]<=(4)))
  220. ALTER TABLE [dbo].[web_user] WITH CHECK ADD CHECK (([lang]>=(0) AND [lang]<=(2)))
  221. ALTER TABLE [dbo].[web_user] WITH CHECK ADD CHECK (([rights_approval]>=(0) AND [rights_approval]<=(3)))
  222. ALTER DATABASE [callmaster] SET READ_WRITE