











declare @AdminUserRelID       as int, @AdminUserMyOrgRelID	as int
declare @AdminRelID           as int, @AdminMyOrgRelID		as int
declare @ExecutivesRelID      as int
declare @PortfolioMgrRelID    as int, @PortfolioMgrMyOrgRelID   as int
declare @ProjMgrRelID         as int, @ProjMgrMyProjectsRelID   as int, @ProjMgrMyOrgRelID  as int
declare @ResMgrRelID          as int, @ResMgrMyResourcesRelID   as int, @ResMgrMyProjectsRelID as int
declare @TeamLeadRelID        as int, @TeamLeadMyProjectsRelID  as int
declare @TeamMemberRelID      as int, @TeamMemberMyTasksRelID   as int
declare @ResMgrGrpGUID        as uniqueidentifier

select @AdminUserRelID     = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_RESOURCES R where R.WRES_ID=1 and SCR.WSEC_SP_GUID=R.WRES_GUID and SCR.WSEC_CAT_ID=0
select @AdminRelID         = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=1 and SCR.WSEC_CAT_ID=0
select @ExecutivesRelID    = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=2 and SCR.WSEC_CAT_ID=0
select @PortfolioMgrRelID  = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=3 and SCR.WSEC_CAT_ID=0
select @ProjMgrRelID       = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=4 and SCR.WSEC_CAT_ID=0
select @ResMgrRelID        = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=5 and SCR.WSEC_CAT_ID=0
select @TeamLeadRelID      = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=6 and SCR.WSEC_CAT_ID=0
select @TeamMemberRelID    = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=7 and SCR.WSEC_CAT_ID=0

select @AdminUserMyOrgRelID     = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_RESOURCES R where R.WRES_ID=1 and SCR.WSEC_SP_GUID=R.WRES_GUID and SCR.WSEC_CAT_ID=1
select @AdminMyOrgRelID         = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=1 and SCR.WSEC_CAT_ID=1
select @PortfolioMgrMyOrgRelID  = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=3 and SCR.WSEC_CAT_ID=1
select @ProjMgrMyOrgRelID       = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=4 and SCR.WSEC_CAT_ID=1
select @ProjMgrMyProjectsRelID  = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=4 and SCR.WSEC_CAT_ID=2
select @ResMgrMyResourcesRelID  = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=5 and SCR.WSEC_CAT_ID=4
select @ResMgrMyProjectsRelID   = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=5 and SCR.WSEC_CAT_ID=2
select @TeamLeadMyProjectsRelID = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=6 and SCR.WSEC_CAT_ID=2
select @TeamMemberMyTasksRelID  = WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR, MSP_WEB_SECURITY_GROUPS G where SCR.WSEC_SP_GUID=G.WSEC_GRP_GUID and G.WSEC_GRP_ID=7 and SCR.WSEC_CAT_ID=3

select @ResMgrGrpGUID        = WSEC_GRP_GUID from MSP_WEB_SECURITY_GROUPS where WSEC_GRP_ID=5


















IF @TeamLeadRelID IS NOT NULL
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
    select @TeamLeadRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID in (601,602,604) and WSEC_FEA_ACT_ID not in ( select WSEC_FEA_ACT_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID = @TeamLeadRelID)


SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  311,  311,  303,  506, N'w0PMdlPj.htm?PWAHELPTOP=1',          N'Modeling/Modeler.asp')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  312,  312,  303,  506, N'w0PMdlPj.htm?PWAHELPTOP=1',          N'Modeling/Modelmulti.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;


SET IDENTITY_INSERT MSP_WEB_WORKGROUP_FIELDS_INFO ON

insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2001,  255852833, 22001, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2002,  255852842, 22002, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2003,  255852851, 22003, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2004,  255852860, 22004, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2005,  255852869, 22005, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2006,  255852878, 22006, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2007,  255852887, 22007, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2008,  255852896, 22008, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2009,  255852905, 22009, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2010,  255852914, 22010, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2011,  255852834, 22011, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2012,  255852843, 22012, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2013,  255852852, 22013, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2014,  255852861, 22014, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2015,  255852870, 22015, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2016,  255852879, 22016, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2017,  255852888, 22017, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2018,  255852897, 22018, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2019,  255852906, 22019, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2020,  255852915, 22020, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2021,  255852839, 22021, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2022,  255852848, 22022, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2023,  255852857, 22023, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2024,  255852866, 22024, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2025,  255852875, 22025, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2026,  255852884, 22026, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2027,  255852893, 22027, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2028,  255852902, 22028, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2029,  255852911, 22029, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2030,  255852920, 22030, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2031,  255852840, 22031, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2032,  255852849, 22032, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2033,  255852858, 22033, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2034,  255852867, 22034, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2035,  255852876, 22035, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2036,  255852885, 22036, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2037,  255852894, 22037, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2038,  255852903, 22038, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2039,  255852912, 22039, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (2040,  255852921, 22040, N'')
SET IDENTITY_INSERT MSP_WEB_WORKGROUP_FIELDS_INFO OFF





if exists (select WPRD_ID from MSP_WEB_TIME_PERIODS where WPRD_ID=1)
 	update MSP_WEB_TIME_PERIODS 
		set WPRD_START_DATE= {ts'1984-01-01 00:00:00'}, WPRD_FINISH_DATE ={ts'1999-12-31 23:59:59'}, WPRD_STATE=1
		where WPRD_ID=1
else
   Begin
      SET IDENTITY_INSERT MSP_WEB_TIME_PERIODS ON
      INSERT INTO MSP_WEB_TIME_PERIODS (WPRD_ID, WPRD_START_DATE,WPRD_FINISH_DATE,WPRD_STATE) VALUES (1,{ts'1984-01-01 00:00:00'},{ts'1999-12-31 23:59:59'},1)
      SET IDENTITY_INSERT MSP_WEB_TIME_PERIODS OFF
   END

if exists (select WPRD_ID from MSP_WEB_TIME_PERIODS where WPRD_ID=2)
      update MSP_WEB_TIME_PERIODS 
		set WPRD_START_DATE= {ts'2000-01-01 00:00:00'}, WPRD_FINISH_DATE ={ts'2049-12-31 23:59:59'}, WPRD_STATE=1
		where WPRD_ID=2
else
   BEGIN
      SET IDENTITY_INSERT MSP_WEB_TIME_PERIODS ON
      INSERT INTO MSP_WEB_TIME_PERIODS (WPRD_ID, WPRD_START_DATE,WPRD_FINISH_DATE,WPRD_STATE) VALUES (2,{ts'2000-01-01 00:00:00'},{ts'2049-12-31 23:59:59'},1)
      SET IDENTITY_INSERT MSP_WEB_TIME_PERIODS OFF
   END

if exists (select WPRD_ID from MSP_WEB_TIME_PERIODS where WPRD_ID>=100)
begin
 	update MSP_WEB_TIME_PERIODS SET WPRD_FINISH_DATE = T1.MinDate FROM (SELECT DATEADD(second, -1,MIN (WPRD_START_DATE)) AS MinDate FROM MSP_WEB_TIME_PERIODS WHERE WPRD_ID>=100) T1 WHERE WPRD_ID=1
	update MSP_WEB_TIME_PERIODS SET WPRD_START_DATE  = T1.MaxDate FROM (SELECT DATEADD(second,  1,MAX (WPRD_FINISH_DATE)) AS MaxDate FROM MSP_WEB_TIME_PERIODS WHERE WPRD_ID>=100) T1 WHERE WPRD_ID=2
end


insert into MSP_WEB_ADMIN_AD (WADMIN_AD_GRP_ENABLE_UPDATE,WADMIN_AD_GRP_UPDATE_FREQ_EVERY,WADMIN_AD_GRP_UPDATE_FREQ_UNIT,WADMIN_AD_ERESPOOL_ENABLE_UPDATE,WADMIN_AD_ERESPOOL_UPDATE_FREQ_EVERY,WADMIN_AD_ERESPOOL_UPDATE_FREQ_UNIT) values (0,1,1,0,1,1)


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL= N'Admin/StsAdMod.asp' where WSEC_PAGE_ID=993




SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  966,  966,  301, 1010, N'w1PBuild.htm?PWAHELPTOP=1',                 N'Admin/Ent_Team.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;


SET IDENTITY_INSERT MSP_WEB_WORKGROUP_FIELDS_INFO ON
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6222,  205521596, 26228, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6223,  205521598, 26229, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6224,  205521600, 26230, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6225,  205521602, 26231, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6226,  205521604, 26232, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6227,  205521606, 26233, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6228,  205521608, 26234, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6229,  205521610, 26235, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6230,  205521612, 26236, N'')
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (6231,  205521614, 26237, N'')
SET IDENTITY_INSERT MSP_WEB_WORKGROUP_FIELDS_INFO OFF

insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521596, 26228, 'ResourceEnterpriseRMV20ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521598, 26229, 'ResourceEnterpriseRMV21ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521600, 26230, 'ResourceEnterpriseRMV22ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521602, 26231, 'ResourceEnterpriseRMV23ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521604, 26232, 'ResourceEnterpriseRMV24ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521606, 26233, 'ResourceEnterpriseRMV25ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521608, 26234, 'ResourceEnterpriseRMV26ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521610, 26235, 'ResourceEnterpriseRMV27ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521612, 26236, 'ResourceEnterpriseRMV28ID',          '',                        3, 21, 1, 0, 0, 1, 0)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521614, 26237, 'ResourceEnterpriseRMV29ID',          '',                        3, 21, 1, 0, 0, 1, 0)


SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 513,  500, 1, 1, 90513)
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 514,  500, 1, 0, 90514)
SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 513, 1, 0, 1, 1)
insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 514, 1, 0, 1, 1)

IF @AdminUserMyOrgRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminUserMyOrgRelID,    513, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminUserMyOrgRelID and WSEC_FEA_ACT_ID=513)
IF @AdminMyOrgRelID     IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminMyOrgRelID,        513, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminMyOrgRelID and WSEC_FEA_ACT_ID=513)
IF @AdminUserRelID      IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminUserRelID,    514, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminUserRelID and WSEC_FEA_ACT_ID=514)
IF @AdminRelID          IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminRelID,        514, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminRelID and WSEC_FEA_ACT_ID=514)


SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values(1103, 1100, 1, 0, 91103)
SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES (1103, 1, 0, 1, 1)

IF @AdminUserRelID  IS NOT NULL insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminUserRelID,   1103, 1, 0, 1)
IF @AdminRelID      IS NOT NULL insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminRelID,       1103, 1, 0, 1)
IF @ProjMgrRelID    IS NOT NULL insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ProjMgrRelID,     1103, 1, 0, 1)
IF @ResMgrRelID     IS NOT NULL insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ResMgrRelID,      1103, 1, 0, 1)
IF @TeamLeadRelID   IS NOT NULL insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@TeamLeadRelID,    1103, 1, 0, 1)
IF @TeamMemberRelID IS NOT NULL insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@TeamMemberRelID,  1103, 1, 0, 1)

SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS  ON
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values ( 1000, 51010,   -1, 10, 1000, 0, 1)
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values ( 1001, 51011, 1000,  1, 1001, 0, 0)
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values ( 1002, 51012, 1000,  2, 1002, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS  OFF

SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values ( 1000, 1000, 1000, 1103, N'w1KTOC.htm?PWAHELPTOP=1', N'Library/WssMain.asp?list=ris')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values ( 1001, 1001, 1001, 1103, N'w1KTOC.htm?PWAHELPTOP=1', N'Risks/RiskShel.asp')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values ( 1002, 1002, 1002, 1103, N'w1KTOC.htm?PWAHELPTOP=1', N'Library/WssMain.asp?list=ris')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values ( 1003, 1003, 1003, 1103, N'w1KTOC.htm?PWAHELPTOP=1', N'Risks/RiskMain.asp?my=1')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values ( 1004, 1004, 1004, 1103, N'w1KTOC.htm?PWAHELPTOP=1', N'Risks/RiskMain.asp')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  994,  994,  909,  790, N'w1APrtSt.htm.htm?PWAHELPTOP=1',  N'Admin/portal.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF


update MSP_WEB_SECURITY_MENUS set WSEC_MENU_NAME_ID=51010 
	where WSEC_MENU_ID=1000 and WSEC_MENU_NAME_ID=51000 and WSEC_MENU_PARENT_ID=1 
	and WSEC_MENU_SEQ=7 and WSEC_MENU_PAGE_ID=1000 and WSEC_MENU_IS_CUSTOM=0
	and WSEC_MENU_IS_TOP_LEVEL=1 

update MSP_WEB_SECURITY_MENUS set WSEC_MENU_NAME_ID=51011, WSEC_MENU_PARENT_ID=1000
	where WSEC_MENU_ID=1001 and WSEC_MENU_NAME_ID=51001 and WSEC_MENU_PARENT_ID=800
	and WSEC_MENU_SEQ=1 and WSEC_MENU_PAGE_ID=1001 and WSEC_MENU_IS_CUSTOM=0
	and WSEC_MENU_IS_TOP_LEVEL=0 

update MSP_WEB_SECURITY_MENUS set WSEC_MENU_NAME_ID=51012,WSEC_MENU_PARENT_ID=1000
	where WSEC_MENU_ID=1002 and WSEC_MENU_NAME_ID=51002 and WSEC_MENU_PARENT_ID=800
	and WSEC_MENU_SEQ=2 and WSEC_MENU_PAGE_ID=1002 and WSEC_MENU_IS_CUSTOM=0
	and WSEC_MENU_IS_TOP_LEVEL=0


insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (2178, 21286, 'AssignmentBookingType',            'ASSN_BOOKING_TYPE',        2, 54, 1, 0, 1, 0)



update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and A.WASSN_REMOVED_BY_RESOURCE=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.ASSN_START_DATE'
	where WRMND_TYPE_ID=11001 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=1
	and WRMND_EMAIL_TITLE=901 and WRMND_EMAIL_TAIL1=401 
	and WRMND_TYPE_DESC=N'TSR_001: Remind me [x] [days] before my tasks start'
	and WRMND_QUERY= N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 order by A.WPROJ_ID, A.ASSN_START_DATE'

update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY= N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and A.WASSN_REMOVED_BY_RESOURCE=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=11002 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=1
	and WRMND_EMAIL_TITLE=902 and WRMND_EMAIL_TAIL1=401 
	and WRMND_TYPE_DESC=N'TSR_002: Remind me [x] [days] beofre my tasks are due'
	and WRMND_QUERY= N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'


update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and A.WASSN_REMOVED_BY_RESOURCE=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=11003 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=1 
	and WRMND_EMAIL_TITLE=903 and WRMND_EMAIL_TAIL1=401 
	and WRMND_TYPE_DESC=N'TSR_003:   Then remind me [every] [day] until my tasks are complete'
	and WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'

update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and A.WASSN_REMOVED_BY_RESOURCE=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=11004 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=1
	and WRMND_EMAIL_TITLE=904 and WRMND_EMAIL_TAIL1=401 
	and WRMND_TYPE_DESC=N'TSR_004: Remind me [every] [day] of my incomplete tasks'
	and WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'

update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and A.WASSN_REMOVED_BY_RESOURCE=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=11005 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=1
	and WRMND_EMAIL_TITLE=905 and WRMND_EMAIL_TAIL1=401 
	and WRMND_TYPE_DESC=N'TSR_005: Remind me when tasks are [x] [days] overdue'
	and WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'

update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and A.WASSN_REMOVED_BY_RESOURCE=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=11006 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=1
	and WRMND_EMAIL_TITLE=906 and WRMND_EMAIL_TAIL1=401 
	and WRMND_TYPE_DESC=N'TSR_006:   Then remind me [every] [day] until my tasks are complete'
	and WRMND_QUERY=N'select A.WPROJ_ID, A.TASK_NAME, A.ASSN_START_DATE, A.ASSN_FINISH_DATE, A.ASSN_WORK, A.ASSN_REM_WORK from MSP_WEB_ASSIGNMENTS A, MSP_WEB_PROJECTS P where A.WRES_ID=^0 and (^1) and A.WPROJ_ID=P.WPROJ_ID and P.WPROJ_IS_NONWORKING=0 order by A.WPROJ_ID, A.ASSN_FINISH_DATE'

update MSP_WEB_REMINDER_TYPES
	set WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.WRES_ID, ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=21001 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=0
	and WRMND_EMAIL_TITLE=917 and WRMND_EMAIL_TAIL1=403
	and WRMND_TYPE_DESC=N'TMR_001: Remind them [x] [days] before their tasks are due'
	and WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID order by A.WPROJ_ID, A.WRES_ID, ASSN_FINISH_DATE'

update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.WRES_ID, ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=21002 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=0
	and WRMND_EMAIL_TITLE=918 and WRMND_EMAIL_TAIL1=403
	and WRMND_TYPE_DESC=N'TMR_002: Remind them when their tasks are [x] [days] overdue'
	and WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID order by A.WPROJ_ID, A.WRES_ID, ASSN_FINISH_DATE'

update MSP_WEB_REMINDER_TYPES
	set WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.WRES_ID, ASSN_FINISH_DATE'
	where WRMND_TYPE_ID=21003 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=0
	and WRMND_EMAIL_TITLE=919 and WRMND_EMAIL_TAIL1=403
	and WRMND_TYPE_DESC=N'TMR_003:   Then remind them [every] [day] until their tasks are complete.'
	and WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID order by A.WPROJ_ID, A.WRES_ID, ASSN_FINISH_DATE'

update MSP_WEB_REMINDER_TYPES 
	set WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID and A.ASSN_BOOKING_TYPE=0 and A.WASSN_DELETED_IN_PROJ=0 and P.WPROJ_ADMINPROJECT=0 order by A.WPROJ_ID, A.WRES_ID, ASSN_START_DATE'
	where WRMND_TYPE_ID=21004 and WRMND_TABLE_ID=2 and WRMND_IS_SELF=0
	and WRMND_EMAIL_TITLE=920 and WRMND_EMAIL_TAIL1=403
	and WRMND_TYPE_DESC=N'TMR_004: Remind them when their tasks have started for [x] [days] but have no actual work.' 
	and WRMND_QUERY=N'select A.WPROJ_ID, A.WRES_ID, TASK_ID, TASK_NAME, RES_NAME, ASSN_START_DATE, ASSN_FINISH_DATE, ASSN_WORK, ASSN_REM_WORK  from MSP_WEB_ASSIGNMENTS A, MSP_WEB_RESOURCES R, MSP_WEB_PROJECTS P where A.WPROJ_ID=P.WPROJ_ID and WRES_ID_MGR=^0 and (^1) and A.WRES_ID=R.WRES_ID order by A.WPROJ_ID, A.WRES_ID, ASSN_START_DATE'
	


SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS  ON
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values (  406, 50406,  400,  4,  406, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS  OFF


SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES  ON
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  406,  406,  406,  514, N'w1RAdjuA.htm?PWAHELPTOP=1',     N'Views/AdjActs.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES  OFF


SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS  ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 107,  100, 1, 0, 90107)
SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS  OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 107, 1, 0, 1, 1)


insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (51,6006, 9)







update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL= N'Risks/RiskShel.asp' where WSEC_PAGE_ID=1001




update MSP_WEB_ADMIN set WADMIN_STS_TEMPLATE_LCID=3082,WADMIN_STS_TEMPLATE_ID=N'PWA'


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_DATABASE_SETTINGS = NULL where WSEC_PAGE_ID=402


insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (     6007, 26238, 'ResourceBookingType',                '',                        3, 54, 1, 0, 0, 1, 0)


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = (N'DocLib/DocLibMain.asp?ProjID=-99') where WSEC_PAGE_ID=703


SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  209,  209,  206,  201, N'w1TOutlk.htm?PWAHELPTOP=1', N'Tasks/outladdn.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;

SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS ON;
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values (  206, 50206,  200,  6,  209, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS OFF;


IF @AdminUserRelID    IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminUserRelID,    107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminUserRelID    and WSEC_FEA_ACT_ID=107)
IF @AdminRelID        IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminRelID,        107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminRelID        and WSEC_FEA_ACT_ID=107)
IF @ExecutivesRelID   IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ExecutivesRelID,   107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ExecutivesRelID   and WSEC_FEA_ACT_ID=107)
IF @PortfolioMgrRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @PortfolioMgrRelID, 107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@PortfolioMgrRelID and WSEC_FEA_ACT_ID=107)
IF @ProjMgrRelID      IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ProjMgrRelID,      107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ProjMgrRelID      and WSEC_FEA_ACT_ID=107)
IF @ResMgrRelID       IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ResMgrRelID,       107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ResMgrRelID       and WSEC_FEA_ACT_ID=107)
IF @TeamLeadRelID     IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @TeamLeadRelID,     107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@TeamLeadRelID     and WSEC_FEA_ACT_ID=107)
IF @TeamMemberRelID   IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @TeamMemberRelID,   107, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@TeamMemberRelID   and WSEC_FEA_ACT_ID=107)


update MSP_WEB_SECURITY_MENUS set WSEC_MENU_SEQ=8 where WSEC_MENU_ID=908
update MSP_WEB_SECURITY_MENUS set WSEC_MENU_SEQ=9 where WSEC_MENU_ID=907


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL='Notifications/Self_Notifications.asp?AlertUI=7' where WSEC_PAGE_ID=102
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL='Notifications/Mgr_Notifications.asp?AlertUI=7' where WSEC_PAGE_ID=103



SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  313,  313,  310, 1017, N'w1PCheck.htm?PWAHELPTOP=1',          N'Tasks/checkin.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;

SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS ON;
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values (  310, 50310,  300,  8,  313, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS OFF;

set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values(1017, 1000, 1, 0, 91017)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES (1017, 1, 0, 1, 1)

IF @AdminUserRelID    IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminUserRelID,    1017, 1, 0, 1)
IF @AdminRelID        IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminRelID,        1017, 1, 0, 1)
IF @ExecutivesRelID   IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ExecutivesRelID,   1017, 1, 0, 1)
IF @PortfolioMgrRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@PortfolioMgrRelID, 1017, 1, 0, 1)
IF @ProjMgrRelID      IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ProjMgrRelID,      1017, 1, 0, 1)
IF @ResMgrRelID       IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ResMgrRelID,       1017, 1, 0, 1)
IF @TeamLeadRelID     IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@TeamLeadRelID,     1017, 1, 0, 1)
IF @TeamMemberRelID   IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@TeamMemberRelID,   1017, 1, 0, 1)


set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values(1018, 1000, 1, 0, 91018)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES (1018, 1, 0, 1, 1)

IF @AdminUserRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminUserRelID,   1018, 1, 0, 1)
IF @AdminRelID     IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminRelID,       1018, 1, 0, 1)
IF @ProjMgrRelID   IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ProjMgrRelID,     1018, 1, 0, 1)


-- Add new global permission "Create Administrative Projects"
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 207,  200, 1, 0, 90207)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES (207, 1, 0, 1, 1)

IF @AdminUserRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminUserRelID,   207, 1, 0, 1)
IF @AdminRelID     IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminRelID,       207, 1, 0, 1)
IF @ResMgrRelID    IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ResMgrRelID,      207, 1, 0, 1)

-- Add new page "Manage Administrative Projects" under Tasks Menu.
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS ON;
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values (  311, 50311,  300,  8,  314, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS OFF;
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  314,  314,  311,  207, N'w1PNonWk.htm?PWAHELPTOP=1',                   N'Tasks/AdmProj.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;

-- delete the "Transfer nonworking time from your Outlook calendar" page from menu
delete from MSP_WEB_SECURITY_PAGES where WSEC_PAGE_ID = 204
delete from MSP_WEB_SECURITY_MENUS where WSEC_MENU_ID = 204

-- delete the global permission "Transfer Calendar Entries" (205).
delete from MSP_WEB_SECURITY_FEATURES_ACTIONS     where WSEC_FEA_ACT_ID = 205
delete from MSP_WEB_SECURITY_ORG_PERMISSIONS      where WSEC_FEA_ACT_ID = 205
delete from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS   where WSEC_FEA_ACT_ID = 205
delete from MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS where WSEC_ACT_ID = 205

-- Change the "Notify your manager of a change in your work days" page to "Notify your manager of time you are not available for project work" page.
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Tasks/nwrkntfy.asp' where WSEC_PAGE_ID = 205



SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  210,  210,  210,  210, N'w0TTOC.htm?PWAHELPTOP=1',                          N'Tasks/newassn.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;

SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS ON;
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values (  210, 50210,  200,  7,  210, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS OFF;

set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 210,  200, 1, 0, 90210)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES (210, 1, 0, 1, 1)

IF @AdminUserRelID IS NOT NULL   insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminUserRelID,    210, 1, 0, 1)
IF @AdminRelID IS NOT NULL       insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@AdminRelID,        210, 1, 0, 1)
IF @ProjMgrRelID IS NOT NULL     insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ProjMgrRelID,      210, 1, 0, 1)
IF @TeamMemberRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@TeamMemberRelID,   210, 1, 0, 1)



insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (2179, 21287, ''                      ,           'TPMAccept',                0, 48,0, 0, 1, 0);

set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 211,  200, 1, 0, 90211)
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 212,  200, 1, 1, 90212)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

set IDENTITY_INSERT MSP_WEB_SECURITY_CATEGORIES ON
insert into MSP_WEB_SECURITY_CATEGORIES (WSEC_CAT_ID, WSEC_CAT_NAME, WSEC_CAT_DESC) values (5, N'Superviso directamente a',N'Categ. predet. Project Server: Mis informes directos')
set IDENTITY_INSERT MSP_WEB_SECURITY_CATEGORIES OFF

insert into MSP_WEB_SECURITY_CATEGORY_RULES (WSEC_CAT_ID, WSEC_OBJ_TYPE, WSEC_OBJ_RULE_TYPE) values (5, 2, 5)

set IDENTITY_INSERT MSP_WEB_SECURITY_SP_CAT_RELATIONS ON
insert into MSP_WEB_SECURITY_SP_CAT_RELATIONS (WSEC_REL_ID, WSEC_SP_GUID, WSEC_CAT_ID) values (19, @ResMgrGrpGUID, 5)
set IDENTITY_INSERT MSP_WEB_SECURITY_SP_CAT_RELATIONS OFF

IF @AdminUserMyOrgRelID IS NOT NULL
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
    select @AdminUserMyOrgRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID in (212)

IF @AdminMyOrgRelID IS NOT NULL
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
    select @AdminMyOrgRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID in (212)

IF @ResMgrRelID IS NOT NULL
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS)
    select @ResMgrRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID in (211)

insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
  select 19, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID in (212)

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) select WSEC_FEA_ACT_ID, 0, 1, 1, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS WHERE WSEC_FEA_ACT_ID=211 OR WSEC_FEA_ACT_ID=212

SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS ON;
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values (  407, 50407,  400,  5,  407, 0, 0)
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values (  408, 50408,  400,  6,  408, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS OFF;

SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  407,  407,  407,  211, N'w1RApprv.htm?PWAHELPTOP=1',     N'Views/TSSum.asp')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  408,  408,  408,  211, N'w1RApprv.htm?PWAHELPTOP=1',     N'Views/TSApp.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;


SET IDENTITY_INSERT MSP_WEB_VIEW_REPORTS ON;
insert into MSP_WEB_VIEW_REPORTS (WVIEW_ID,WVIEW_NAME,WVIEW_DESCRIPTION,WVIEW_TYPE,WVIEW_DISPLAY_TYPE,WVIEW_REPORT_KIND,WGANTT_SCHEME_ID,WTABLE_ID,WGROUP_SCHEME_ID,WVIEW_TIMESTAMP) values (99,N'Parte de horas',       N'Muestra información básica de los partes de horas',   5,2,0,1,0,2,newID());
SET IDENTITY_INSERT MSP_WEB_VIEW_REPORTS OFF;

insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       1022, 0);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       2173, 1);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       2000, 2);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       2006, 3);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       2117, 4);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       2122, 5);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       2050, 6);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       2176, 7);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       1051, 8);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       1050, 9);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       4006, 10);
insert into MSP_WEB_VIEW_REPORTS_FIELDS (WVIEW_ID,WFIELD_ID,WVIEW_FIELD_ORDER) values (99,       4008, 11);


insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (     4008, 24188, '',                             'TLeadName',                1, 21, 0, 0, 1, 0, 0);


delete from MSP_WEB_SECURITY_MENUS where WSEC_MENU_ID=309
update MSP_WEB_SECURITY_MENUS set WSEC_MENU_SEQ=7 where WSEC_MENU_ID=310


SET IDENTITY_INSERT MSP_WEB_WORKGROUP_FIELDS_INFO ON;
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (1258,  188744819, 21288, N'');
insert into MSP_WEB_WORKGROUP_FIELDS_INFO (CUSTFIELD_INFO_ID,FIELD_ID,CONV_VALUE,CUSTFIELD_NAME) values (1259,  188744820, 21289, N'');
SET IDENTITY_INSERT MSP_WEB_WORKGROUP_FIELDS_INFO OFF;

insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (188744819 , 21288, 'TaskActualWorkProtected ',    'TASK_ACT_WORK_PROT',	   1,  8, 1, 1, 1, 1);
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (188744820 , 21289, 'TaskActualOvertimeWorkProtected',	 'TASK_ACT_OVT_WORK_PROT',   1,  8, 1, 1, 1, 1);
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (255853174, 21288, 'AssignmentActualWorkProtected',             'ASSN_ACT_WORK_PROT',            2,  8, 1, 0, 0, 0);
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (255853175, 21289, 'AssignmentActualOvertimeWorkProtected',     'ASSN_ACT_OVT_WORK_PROT',        2,  8, 1, 0, 0, 0);
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521616, 21288, 'ResourceActualWorkProtected',                      'RES_ACT_WORK_PROT',            3,  8, 1, 0, 0, 0, 0);
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_ENTRES_FIELD,WFIELD_IS_CUSTOM_FIELD) values (205521617, 21289, 'ResourceActualOvertimeWorkProtected',              'RES_ACT_OVT_WORK_PROT',        3,  8, 1, 0, 0, 0, 0);


UPDATE MSP_WEB_RESOURCES set RESERVED_DATA3 = CONVERT(int, RAND(DATEPART(ms, GETDATE())) * 1000000000), RESERVED_DATA4 = CONVERT(int, RAND(DATEPART(ms, GETDATE()) * 2) * 1000000000) where WRES_ID=1



SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 150,  100, 1, 0, 90150)
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 151,  100, 1, 0, 90151)
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 152,  100, 1, 0, 90152)
SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 150, 1, 0, 1, 1)
insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 151, 1, 0, 1, 1)
insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 152, 1, 0, 1, 1)


insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT WSEC_REL_ID, 150, 1, 0, 1 FROM MSP_WEB_SECURITY_SP_CAT_RELATIONS WHERE WSEC_CAT_ID=0
insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT WSEC_REL_ID, 151, 1, 0, 1 FROM MSP_WEB_SECURITY_SP_CAT_RELATIONS WHERE WSEC_CAT_ID=0
insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT WSEC_REL_ID, 152, 1, 0, 1 FROM MSP_WEB_SECURITY_SP_CAT_RELATIONS WHERE WSEC_CAT_ID=0


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_A_AdminTOC.htm?PWAHELPTOP=1', 'w0ATOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_D_TOC.htm?PWAHELPTOP=1', 'w0DTOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_H_TOC.htm?PWAHELPTOP=1', 'w0HTOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_I_TOC.htm?PWAHELPTOP=1', 'w0ITOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_P_TOC.htm?PWAHELPTOP=1', 'w0PTOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_R_TOC.htm?PWAHELPTOP=1', 'w0RTOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_S_TOC.htm?PWAHELPTOP=1', 'w0STOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_T_TasksTOC.htm?PWAHELPTOP=1', 'w0TTOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p10_U_TOC.htm?PWAHELPTOP=1', 'w0UTOC.htm?PWAHELPTOP=1')
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = replace(WSEC_PAGE_HELP_URL, 'ps_p11_RK_TOC.htm?PWAHELPTOP=1', 'w1KTOC.htm?PWAHELPTOP=1')


delete from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID=402
delete from MSP_WEB_SECURITY_PAGES where WSEC_PAGE_ID=602
delete from MSP_WEB_SECURITY_MENUS where WSEC_MENU_ID=602
delete from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_FEA_ACT_ID=402


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL = N'w1KTOC.htm?PWAHELPTOP=1' where WSEC_PAGE_ID in (1000, 1001, 1002)


update MSP_WEB_ADMIN set WADMIN_STS_TEMPLATE_ID = N'PWA'


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_ACT_ID = 207 where WSEC_PAGE_ID = 314



update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=200 where WVIEW_ID=1 and WFIELD_ID=1048
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=65 where WVIEW_ID=1 and WFIELD_ID=1610612765
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=135 where WVIEW_ID=1 and WFIELD_ID=2122

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=200 where WVIEW_ID=2 and WFIELD_ID=1048
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=135 where WVIEW_ID=2 and WFIELD_ID=2122
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=135 where WVIEW_ID=2 and WFIELD_ID=2050

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=200 where WVIEW_ID=3 and WFIELD_ID=1048
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=75 where WVIEW_ID=3 and WFIELD_ID=1073741832
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=3 and WFIELD_ID=1073741829

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=200 where WVIEW_ID=4 and WFIELD_ID=1048
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=4 and WFIELD_ID=1073741836
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=4 and WFIELD_ID=1073741835

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=200 where WVIEW_ID=5 and WFIELD_ID=1048
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=5 and WFIELD_ID=2173
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=95 where WVIEW_ID=5 and WFIELD_ID=1073741825

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=11 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=11 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=65 where WVIEW_ID=11 and WFIELD_ID=1610612765

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=12 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=12 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=65 where WVIEW_ID=12 and WFIELD_ID=1610612765

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=13 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=13 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=100 where WVIEW_ID=13 and WFIELD_ID=1073741844

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=14 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=14 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=100 where WVIEW_ID=14 and WFIELD_ID=1073741844

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=15 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=15 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=135 where WVIEW_ID=15 and WFIELD_ID=1034

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=16 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=16 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=75 where WVIEW_ID=16 and WFIELD_ID=1073741832

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=17 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=17 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=17 and WFIELD_ID=1073741836

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=18 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=18 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=135 where WVIEW_ID=18 and WFIELD_ID=1034

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=19 and WFIELD_ID=1046
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=19 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=19 and WFIELD_ID=1045

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=21 and WFIELD_ID=2136
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=21 and WFIELD_ID=2119
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=21 and WFIELD_ID=2173

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=22 and WFIELD_ID=2136
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=22 and WFIELD_ID=2119
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=22 and WFIELD_ID=2039

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=23 and WFIELD_ID=2136
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=23 and WFIELD_ID=2119
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=135 where WVIEW_ID=23 and WFIELD_ID=2122

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=24 and WFIELD_ID=2136
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=24 and WFIELD_ID=2119
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=24 and WFIELD_ID=2015

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=25 and WFIELD_ID=2136
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=25 and WFIELD_ID=2119
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=25 and WFIELD_ID=2013

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=26 and WFIELD_ID=2136
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=26 and WFIELD_ID=2119
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=26 and WFIELD_ID=2173

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=31 and WFIELD_ID=3087
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=31 and WFIELD_ID=3092
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=100 where WVIEW_ID=31 and WFIELD_ID=3083
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=65 where WVIEW_ID=31 and WFIELD_ID=3091
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=31 and WFIELD_ID=3130
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=95 where WVIEW_ID=31 and WFIELD_ID=3139
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=100 where WVIEW_ID=31 and WFIELD_ID=3128
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=31 and WFIELD_ID=3017
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=31 and WFIELD_ID=3187
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=31 and WFIELD_ID=3140
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=31 and WFIELD_ID=3052

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=32 and WFIELD_ID=3087
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=130 where WVIEW_ID=32 and WFIELD_ID=3092
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=32 and WFIELD_ID=3017
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=95 where WVIEW_ID=32 and WFIELD_ID=3010
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=95 where WVIEW_ID=32 and WFIELD_ID=3019
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=80 where WVIEW_ID=32 and WFIELD_ID=3002
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=32 and WFIELD_ID=3134
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=32 and WFIELD_ID=3140
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=32 and WFIELD_ID=3052

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=33 and WFIELD_ID=3087
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=33 and WFIELD_ID=3092
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=33 and WFIELD_ID=3000
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=33 and WFIELD_ID=3187
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=33 and WFIELD_ID=3129
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=105 where WVIEW_ID=33 and WFIELD_ID=3011
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=100 where WVIEW_ID=33 and WFIELD_ID=3188
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=85 where WVIEW_ID=33 and WFIELD_ID=3005
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=110 where WVIEW_ID=33 and WFIELD_ID=3137
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=33 and WFIELD_ID=3140
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=33 and WFIELD_ID=3052

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=40 where WVIEW_ID=34 and WFIELD_ID=3087
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=130 where WVIEW_ID=34 and WFIELD_ID=3092
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=34 and WFIELD_ID=3013
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=34 and WFIELD_ID=3012
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=34 and WFIELD_ID=3006
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=34 and WFIELD_ID=3151
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=34 and WFIELD_ID=3030
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=34 and WFIELD_ID=3017
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=95 where WVIEW_ID=34 and WFIELD_ID=3010
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=34 and WFIELD_ID=3186
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=34 and WFIELD_ID=3140
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=34 and WFIELD_ID=3052

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=200 where WVIEW_ID=41 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=65 where WVIEW_ID=41 and WFIELD_ID=2176
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=135 where WVIEW_ID=41 and WFIELD_ID=1051

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=75 where WVIEW_ID=51 and WFIELD_ID=3184
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=51 and WFIELD_ID=3092
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=70 where WVIEW_ID=51 and WFIELD_ID=3183
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=51 and WFIELD_ID=3090
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=65 where WVIEW_ID=51 and WFIELD_ID=3091
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=90 where WVIEW_ID=51 and WFIELD_ID=6002
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=100 where WVIEW_ID=51 and WFIELD_ID=6003
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=95 where WVIEW_ID=51 and WFIELD_ID=6004
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=100 where WVIEW_ID=51 and WFIELD_ID=205521540
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=50 where WVIEW_ID=51 and WFIELD_ID=6006

update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=99 and WFIELD_ID=1022
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=45 where WVIEW_ID=99 and WFIELD_ID=2173
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=99 and WFIELD_ID=2000
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=110 where WVIEW_ID=99 and WFIELD_ID=2117
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=99 and WFIELD_ID=2122
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=99 and WFIELD_ID=2050
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=120 where WVIEW_ID=99 and WFIELD_ID=2176
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=150 where WVIEW_ID=99 and WFIELD_ID=1051
update MSP_WEB_VIEW_REPORTS_FIELDS set WVIEW_FIELD_AUTOSIZE=0, WVIEW_FIELD_WIDTH=130 where WVIEW_ID=99 and WFIELD_ID=1050

update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=430 where WVIEW_ID=1
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=500 where WVIEW_ID=2
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=350 where WVIEW_ID=3
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=330 where WVIEW_ID=4
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=370 where WVIEW_ID=5

update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=285 where WVIEW_ID=11
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=285 where WVIEW_ID=12
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=285 where WVIEW_ID=13
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=285 where WVIEW_ID=14
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=355 where WVIEW_ID=15
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=295 where WVIEW_ID=16
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=270 where WVIEW_ID=17
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=355 where WVIEW_ID=18
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=265 where WVIEW_ID=19

update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=330 where WVIEW_ID=21
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=335 where WVIEW_ID=22
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=420 where WVIEW_ID=23
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=330 where WVIEW_ID=24
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=335 where WVIEW_ID=25
update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=330 where WVIEW_ID=26

update MSP_WEB_VIEW_REPORTS set WVIEW_SPLITTER_POS=430 where WVIEW_ID=41


update MSP_WEB_VIEW_FIELDS set WFIELD_IN_PROJECT_VIEW=0 where WFIELD_ID = 6002
update MSP_WEB_VIEW_FIELDS set WFIELD_IN_PROJECT_VIEW=0 where WFIELD_ID = 6003
update MSP_WEB_VIEW_FIELDS set WFIELD_IN_PROJECT_VIEW=0 where WFIELD_ID = 6004
update MSP_WEB_VIEW_FIELDS set WFIELD_IN_PROJECT_VIEW=0 where WFIELD_ID = 6005


IF @ExecutivesRelID IS NOT NULL
Begin
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ExecutivesRelID,   1101, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ExecutivesRelID and WSEC_FEA_ACT_ID=1101)
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ExecutivesRelID,   1102, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ExecutivesRelID and WSEC_FEA_ACT_ID=1102)
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ExecutivesRelID,   1103, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ExecutivesRelID and WSEC_FEA_ACT_ID=1103)
End



update MSP_WEB_VIEW_FIELDS set WFIELD_IN_WEBCLIENT_VIEW=0 where WFIELD_ID=1073741873


delete from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=13 and WSEC_FEA_ACT_ID=203



delete from MSP_WEB_SECURITY_PAGES where WSEC_PAGE_ID=704
delete from MSP_WEB_SECURITY_MENUS where WSEC_MENU_ID=704


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PTOC.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=302
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PMdlPj.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=303
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PCrTDL.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=305
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PTOC.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=309



update MSP_WEB_GROUP_SETTINGS set WGROUP_TEXT_COLOR=7 where WGROUP_SCHEME_ID=1 and WGROUP_STYLE_ID<=3
update MSP_WEB_GROUP_SETTINGS set WGROUP_ROW_COLOR=15, WGROUP_ROW_PATTERN=1, WGROUP_TEXT_COLOR=7 where WGROUP_SCHEME_ID>=2 and WGROUP_SCHEME_ID<=11 and WGROUP_STYLE_ID<=3
update MSP_WEB_GROUP_SETTINGS set WGROUP_TEXT_COLOR=11 where WGROUP_SCHEME_ID=2 and WGROUP_STYLE_ID in (1, 3)


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PTOC.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=302
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PMdlPj.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=303
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PCrTDL.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=305
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PTOC.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=309


SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values(1019, 1000, 1, 1, 91019)
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values(1020, 1000, 1, 1, 91020)
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values(1021, 1000, 1, 0, 91021)
SET IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 1019, 1, 0, 1, 1)
insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 1020, 1, 0, 1, 1)
insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 1021, 1, 0, 1, 1)

set IDENTITY_INSERT MSP_WEB_SECURITY_SP_CAT_RELATIONS ON
insert into MSP_WEB_SECURITY_SP_CAT_RELATIONS (WSEC_REL_ID, WSEC_SP_GUID, WSEC_CAT_ID) values (20, @ResMgrGrpGUID, 1)
set IDENTITY_INSERT MSP_WEB_SECURITY_SP_CAT_RELATIONS OFF

IF @PortfolioMgrRelID      IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@PortfolioMgrRelID, 1021, 1, 0, 1)
IF @PortfolioMgrMyOrgRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@PortfolioMgrMyOrgRelID, 1019, 1, 0, 1)
IF @PortfolioMgrMyOrgRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@PortfolioMgrMyOrgRelID, 1020, 1, 0, 1)
IF @ProjMgrRelID           IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ProjMgrRelID, 1021, 1, 0, 1)
IF @ProjMgrMyProjectsRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ProjMgrMyProjectsRelID, 1019, 1, 0, 1)
IF @ProjMgrMyOrgRelID      IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ProjMgrMyOrgRelID, 1020, 1, 0, 1)
IF @ResMgrRelID            IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ResMgrRelID, 1021, 1, 0, 1)
IF @ResMgrMyResourcesRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) VALUES (@ResMgrMyResourcesRelID, 1020, 1, 0, 1)
insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS)
  select 20, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID in (1019)



set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 213,  200, 1, 1, 90213)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 213, 1, 0, 1, 1)

IF @AdminUserMyOrgRelID     IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminUserMyOrgRelID,    213, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminUserMyOrgRelID and WSEC_FEA_ACT_ID=213)
IF @AdminMyOrgRelID         IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminMyOrgRelID,        213, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminMyOrgRelID and WSEC_FEA_ACT_ID=213)
IF @ProjMgrMyProjectsRelID  IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ProjMgrMyProjectsRelID, 213, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ProjMgrMyProjectsRelID and WSEC_FEA_ACT_ID=213)
IF @ResMgrMyProjectsRelID   IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ResMgrMyProjectsRelID, 213, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ResMgrMyProjectsRelID and WSEC_FEA_ACT_ID=213)
IF @TeamLeadMyProjectsRelID IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @TeamLeadMyProjectsRelID, 213, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@TeamLeadMyProjectsRelID and WSEC_FEA_ACT_ID=213)
IF @TeamMemberMyTasksRelID  IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @TeamMemberMyTasksRelID, 213, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@TeamMemberMyTasksRelID and WSEC_FEA_ACT_ID=213)




set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values(108,  100, 1, 0, 90108)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 108, 1, 0, 1, 1 )

IF @AdminUserRelID  IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) values (@AdminUserRelID, 108, 1, 0, 1)
IF @AdminRelID      IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) values (@AdminRelID, 108, 1, 0, 1)


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_ACT_ID=201 where WSEC_PAGE_ID=507


-- Everybody has the custom global permission 151, 152, 153 --
delete MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_FEA_ACT_ID in (151,152,153)
insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) select SCR.WSEC_REL_ID, 151, 1, 0, 1 from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR where SCR.WSEC_CAT_ID=0
insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) select SCR.WSEC_REL_ID, 152, 1, 0, 1 from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR where SCR.WSEC_CAT_ID=0
insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) select SCR.WSEC_REL_ID, 153, 1, 0, 1 from MSP_WEB_SECURITY_SP_CAT_RELATIONS SCR where SCR.WSEC_CAT_ID=0


SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS ON;
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL,WSEC_MENU_LINKGROUP_NAME_ID) values (  803, 50803,  800,  3,  803, 0, 0, 51005)
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL,WSEC_MENU_LINKGROUP_NAME_ID) values (  804, 50804,  800,  4,  804, 0, 0, 51005)
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values ( 1003, 51013, 1000,  3, 1003, 0, 0)
insert into MSP_WEB_SECURITY_MENUS (WSEC_MENU_ID,WSEC_MENU_NAME_ID,WSEC_MENU_PARENT_ID,WSEC_MENU_SEQ,WSEC_MENU_PAGE_ID,WSEC_MENU_IS_CUSTOM,WSEC_MENU_IS_TOP_LEVEL) values ( 1004, 51014, 1000,  4, 1004, 0, 0)
SET IDENTITY_INSERT MSP_WEB_SECURITY_MENUS OFF;

update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Library/WssMain.asp?list=doc' where WSEC_PAGE_ID = 700
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Library/WssMain.asp?list=doc' where WSEC_PAGE_ID = 701
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Library/WssMain.asp?list=doc' where WSEC_PAGE_ID = 702
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Library/WssMain.asp?list=iss' where WSEC_PAGE_ID = 800
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Library/WssMain.asp?list=iss' where WSEC_PAGE_ID = 802
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Library/WssMain.asp?list=ris' where WSEC_PAGE_ID = 1000
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_URL = N'Library/WssMain.asp?list=ris' where WSEC_PAGE_ID = 1002

SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES ON;
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  803,  803,  803, 1102, N'w0ITOC.htm?PWAHELPTOP=1', N'Issues/IssueMain.asp?my=1')
insert into MSP_WEB_SECURITY_PAGES (WSEC_PAGE_ID,WSEC_PAGE_MASTER_PAGE_ID,WSEC_PAGE_MENU_ID,WSEC_PAGE_ACT_ID,WSEC_PAGE_HELP_URL,WSEC_PAGE_URL) values (  804,  804,  804, 1102, N'w0ITOC.htm?PWAHELPTOP=1', N'Issues/IssueMain.asp')
SET IDENTITY_INSERT MSP_WEB_SECURITY_PAGES OFF;



DELETE FROM MSP_WEB_RESOURCE_SETTINGS





DECLARE @projid int
DECLARE sql_cursor CURSOR FOR
select PROJ_ID from MSP_PROJECTS WHERE PROJ_TYPE=0

OPEN sql_cursor
FETCH NEXT FROM sql_cursor INTO @projid
WHILE (@@FETCH_STATUS = 0)
BEGIN
  declare @vers_default int
  select @vers_default = VERS_DEFAULT from MSP_VERSIONS
    where LOWER(VERS_VERSION) in
    (select LOWER(PROJ_VERSION) from MSP_PROJECTS where PROJ_ID = @projid)
  IF @vers_default = 1 
    BEGIN
      exec dbo.MSP_PDS_SP_UpdateSummaryAssnVersions @projid
    END
  ELSE
    BEGIN
      exec dbo.MSP_PDS_SP_CreateDummySummaryResAssn @projid
    END
  FETCH NEXT FROM sql_cursor INTO @projid
END
CLOSE sql_cursor
DEALLOCATE sql_cursor



update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0HChPsw.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=101
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w1SAlert.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=102
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w1SAlert.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=103
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0HGoOff.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=104









update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0HChPsw.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=101
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0HSetNo.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=102
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0HSetNo.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=103
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0HGoOff.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=104
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0TCreNT.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=202
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0TDelgT.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=203
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w1TNonW.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=205
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0TDelgT.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=206
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0TCreNT.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=208
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PMgTDL.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=306
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0RSaveL.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=308
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PTOC.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=310
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PMdlPj.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=311
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0PMdlPj.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=312
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0RVwAv.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=401
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0RVwAs.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=402
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0RAnRes.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=403
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SSubSR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=502
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SMgASR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=503
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SVwSR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=504
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SVwSR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=506
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SSubSR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=507
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SVwSR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=508
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SVwSR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=509
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0SSubSR.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=510
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0USetRu.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=603
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0UViewH.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=604
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0AAuthO.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=926
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0AMgDSN.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=932
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0AModMe.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=942
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0AGtCFO.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=952
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0AGrpFO.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=953
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0ANotif.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=957
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w1PBuild.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=966
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0ACUpDB.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=980
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0ASPDfS.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=990
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0AMgSPS.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=991
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0ASynSP.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=992
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0ARegSP.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=993
update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w1APrtSt.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=994


update MSP_WEB_ADMIN set WADMIN_VERSION_MAJOR = 11, WADMIN_VERSION_MINOR = 0, WADMIN_VERSION_BUILD = 20030816, WADMIN_VERSION_REVISION = 15 


update MSP_WEB_VIEW_FIELDS set WFIELD_IN_PROJECT_VIEW=0 where WFIELD_ID=6006


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w1TNonW.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=205





delete MSP_WEB_SECURITY_PAGES where WSEC_PAGE_ID=961
update MSP_WEB_SECURITY_MENUS set WSEC_MENU_PAGE_ID=962 where WSEC_MENU_ID=906


update MSP_WEB_SECURITY_PAGES set WSEC_PAGE_HELP_URL=N'w0RAnRes.htm?PWAHELPTOP=1' where WSEC_PAGE_ID=302


delete from MSP_WEB_VIEW_FIELDS where WFIELD_ID in (1073741826, 2006)
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (1073741826, 21060, 'TaskActualWork',	          'TASK_ACT_WORK',	           1,  8, 1, 0, 0, 1);
insert into MSP_WEB_VIEW_FIELDS (WFIELD_ID,WFIELD_NAME_CONV_VALUE,WFIELD_NAME_OLEDB,WFIELD_NAME_SQL,WTABLE_ID,WFIELD_TEXTCONV_TYPE,WFIELD_IN_PROJECT_VIEW,WFIELD_IN_PORTFOLIO_VIEW,WFIELD_IN_WEBCLIENT_VIEW,WFIELD_IS_CUSTOM_FIELD) values (2006, 21060, 'AssignmentActualWork',             'ASSN_ACT_WORK',            2,  8, 1, 1, 1, 0);


set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS ON
insert into MSP_WEB_SECURITY_FEATURES_ACTIONS (WSEC_FEA_ACT_ID, WSEC_FEA_ACT_PARENT, WSEC_IS_ACTION, WSEC_ON_OBJECT, WSEC_FEA_ACT_NAME_ID) values( 781,  200, 1, 1, 90781)
set IDENTITY_INSERT MSP_WEB_SECURITY_FEATURES_ACTIONS OFF

insert into MSP_WEB_SECURITY_ORG_PERMISSIONS (WSEC_FEA_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS, WSEC_PAID) VALUES ( 781, 1, 0, 1, 1)

IF @AdminUserMyOrgRelID     IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminUserMyOrgRelID,    781, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminUserMyOrgRelID and WSEC_FEA_ACT_ID=781)
IF @AdminMyOrgRelID         IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @AdminMyOrgRelID,        781, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@AdminMyOrgRelID and WSEC_FEA_ACT_ID=781)
IF @ProjMgrMyProjectsRelID  IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @ProjMgrMyProjectsRelID, 781, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@ProjMgrMyProjectsRelID and WSEC_FEA_ACT_ID=781)
IF @PortfolioMgrMyOrgRelID  IS NOT NULL  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) SELECT @PortfolioMgrMyOrgRelID, 781, 1, 0, 1 WHERE NOT EXISTS(select WSEC_REL_ID from MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_REL_ID=@PortfolioMgrMyOrgRelID and WSEC_FEA_ACT_ID=781)




delete from MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS where WSEC_TMPL_ID <= 1000 and WSEC_ACT_ID <= 10000

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 1, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_FEA_ACT_ID<=10000 and WSEC_IS_ACTION=1

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 2, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID in (101,102,103,104,105,106,107,150,151,152,301,302,303,501,502,503,504,505,506,507,508,509,510,512,601,602,604,1014,1017,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 2, WSEC_FEA_ACT_ID, 0, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID<=10000 and WSEC_IS_ACTION=1 and WSEC_FEA_ACT_ID not in (101,102,103,104,105,106,107,150,151,152,301,302,303,501,502,503,504,505,506,507,508,509,510,512,601,602,604,1014,1017,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 3, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID in (101,102,103,104,105,106,107,150,151,152,501,502,503,504,505,506,507,508,509,510,512,730,760,781,801,1004,1005,1006,1007,1010,1011,1012,1013,1014,1015,1016,1017,1019,1020,1021,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 3, WSEC_FEA_ACT_ID, 0, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID<=10000 and WSEC_IS_ACTION=1 and WSEC_FEA_ACT_ID not in (101,102,103,104,105,106,107,150,151,152,501,502,503,504,505,506,507,508,509,510,512,730,760,781,801,1004,1005,1006,1007,1010,1011,1012,1013,1014,1015,1016,1017,1019,1020,1021,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 4, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID in (101,102,103,104,105,106,107,150,151,152,201,202,203,204,210,213,301,302,303,401,403,501,502,503,508,509,510,512,601,602,604,781,801,901,902,903,904,1004,1006,1010,1011,1012,1013,1014,1016,1017,1018,1019,1021,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 4, WSEC_FEA_ACT_ID, 0, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID<=10000 and WSEC_IS_ACTION=1 and WSEC_FEA_ACT_ID not in (101,102,103,104,105,106,107,150,151,152,201,202,203,204,210,213,301,302,303,401,403,501,502,503,508,509,510,512,601,602,604,781,801,901,902,903,904,1004,1006,1010,1011,1012,1013,1014,1016,1017,1018,1019,1021,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 5, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID in (101,102,103,104,105,106,107,150,151,152,207,211,213,301,302,303,501,502,503,504,507,508,512,601,602,604,1005,1006,1010,1017,1021,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 5, WSEC_FEA_ACT_ID, 0, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID<=10000 and WSEC_IS_ACTION=1 and WSEC_FEA_ACT_ID not in (101,102,103,104,105,106,107,150,151,152,207,211,213,301,302,303,501,502,503,504,507,508,512,601,602,604,1005,1006,1010,1017,1021,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 6, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID in (101,102,103,104,105,106,107,150,151,152,213,301,302,303,502,508,509,510,512,601,602,604,1017,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 6, WSEC_FEA_ACT_ID, 0, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID<=10000 and WSEC_IS_ACTION=1 and WSEC_FEA_ACT_ID not in (101,102,103,104,105,106,107,150,151,152,213,301,302,303,502,508,509,510,512,601,602,604,1017,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 7, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID in (101,102,103,104,106,107,150,151,152,201,202,204,206,210,213,301,302,303,501,503,508,509,512,601,602,1017,1101,1102,1103)

insert into MSP_WEB_SECURITY_TEMPLATE_PERMISSIONS (WSEC_TMPL_ID, WSEC_ACT_ID, WSEC_ALLOW, WSEC_DENY, WSEC_ACCESS) 
  select 7, WSEC_FEA_ACT_ID, 0, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS 
   where WSEC_FEA_ACT_ID<=10000 and WSEC_IS_ACTION=1 and WSEC_FEA_ACT_ID not in (101,102,103,104,106,107,150,151,152,201,202,204,206,210,213,301,302,303,501,503,508,509,512,601,602,1017,1101,1102,1103)


IF @AdminUserRelID IS NOT NULL
Begin
   delete MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_FEA_ACT_ID<=10000 and WSEC_REL_ID=@AdminUserRelID
   insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
      select @AdminUserRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_IS_ACTION=1 and WSEC_ON_OBJECT=0 and WSEC_FEA_ACT_ID<=10000
End

IF @AdminUserMyOrgRelID IS NOT NULL
Begin
  delete MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_FEA_ACT_ID<=10000 and WSEC_REL_ID=@AdminUserMyOrgRelID
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
     select @AdminUserMyOrgRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_IS_ACTION=1 and WSEC_ON_OBJECT=1 and WSEC_FEA_ACT_ID<=10000
End

IF @AdminRelID IS NOT NULL
Begin
   delete MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_FEA_ACT_ID<=10000 and WSEC_REL_ID=@AdminRelID
   insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
      select @AdminRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_IS_ACTION=1 and WSEC_ON_OBJECT=0 and WSEC_FEA_ACT_ID<=10000
End

IF @AdminMyOrgRelID  IS NOT NULL
Begin
  delete MSP_WEB_SECURITY_SP_CAT_PERMISSIONS where WSEC_FEA_ACT_ID<=10000 and WSEC_REL_ID=@AdminMyOrgRelID
  insert into MSP_WEB_SECURITY_SP_CAT_PERMISSIONS (WSEC_REL_ID,WSEC_FEA_ACT_ID,WSEC_ALLOW,WSEC_DENY,WSEC_ACCESS) 
     select @AdminMyOrgRelID, WSEC_FEA_ACT_ID, 1, 0, 1 from MSP_WEB_SECURITY_FEATURES_ACTIONS where WSEC_IS_ACTION=1 and WSEC_ON_OBJECT=1 and WSEC_FEA_ACT_ID<=10000
End




