﻿--------------------------------------- Hammad  27-12-2022 ------------


CREATE TABLE [dbo].[Rec_ForeignerJobStages](
	[ForeignerJobStageCod] [int] IDENTITY(1,1) NOT NULL,
	[RecruitJobCode] [int] NOT NULL,
	[ForeignerUserCode] [int] NOT NULL,
	[PersonalInterviewStageCode] [int] NOT NULL,
	[StepNumber] [int] NOT NULL,
	[UserCodeResponsibleInterview] [nvarchar](200) NULL,
 CONSTRAINT [PK_Rec_ForeignerJobStages] PRIMARY KEY CLUSTERED 
(
	[ForeignerJobStageCod] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Rec_ForeignerJobStages]  WITH CHECK ADD  CONSTRAINT [FK_Rec_ForeignerJobStages_ForeignerUser] FOREIGN KEY([ForeignerUserCode])
REFERENCES [dbo].[ForeignerUser] ([ForeignerUserCode])
GO

ALTER TABLE [dbo].[Rec_ForeignerJobStages] CHECK CONSTRAINT [FK_Rec_ForeignerJobStages_ForeignerUser]
GO

ALTER TABLE [dbo].[Rec_ForeignerJobStages]  WITH CHECK ADD  CONSTRAINT [FK_Rec_ForeignerJobStages_Rec_PersonalInterviewStages] FOREIGN KEY([PersonalInterviewStageCode])
REFERENCES [dbo].[Rec_PersonalInterviewStages] ([PersonalInterviewStageCode])
GO

ALTER TABLE [dbo].[Rec_ForeignerJobStages] CHECK CONSTRAINT [FK_Rec_ForeignerJobStages_Rec_PersonalInterviewStages]
GO

ALTER TABLE [dbo].[Rec_ForeignerJobStages]  WITH CHECK ADD  CONSTRAINT [FK_Rec_ForeignerJobStages_Rec_RecruitJob] FOREIGN KEY([RecruitJobCode])
REFERENCES [dbo].[Rec_RecruitJob] ([RecruitJobCode])
GO

ALTER TABLE [dbo].[Rec_ForeignerJobStages] CHECK CONSTRAINT [FK_Rec_ForeignerJobStages_Rec_RecruitJob]
GO

--------------------------------------- Hammad  27-12-2022 ------------
--------------------------------------- Hammad  29-12-2022 ------------
INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage]) 
VALUES (658, N'Change Recruit Job Stage', N'تغير مراحل التقدم للوظيفة', 47, N'/Recruitment/ForeignerJobStage', N'Index', N'fa fa-thumb-tack', N'get', 3, 1, 1)
GO
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) 
VALUES (5143, N'تغير مراحل التقدم للوظيفة', N'   Change Recruit Job Stage', 658, 1)
GO
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) 
VALUES (5144, N'عرض تغير مراحل التقدم للوظيفة ', N'View Change Recruit Job Stage', 658, 2)
GO
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType])
 VALUES (5145, N'حفظ تغير مراحل التقدم للوظيفة ', N'Save Change Recruit Job Stage', 658, 2)
GO
INSERT [dbo].[SystemMenuModule] ([SystemMenuCode], [AppModuleCode])
 VALUES (658, 4)
GO
INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES (1076, N'Recruitment', N'ForeignerJobStage', N'Index', 0, N'get', 5143)
GO
INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES (1077, N'Recruitment', N'ForeignerJobStage', N'ForeignerJobStage_Read', 0, N'post', 5144)
GO
INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES (1078, N'Recruitment', N'ForeignerJobStage', N'Save', 0, N'post', 5145)
GO
--------------------------------------- End  29-12-2022 ------------
--------------------------------------- Hammad  29-12-2022 ------------
delete ConfigParameter where ConfigKey='ReadAttendanceFromNextMonth'
GO
--------------------------------------- End  29-12-2022 ------------
--------------------------------------- MOstafa  01-01-2023 ------------
GO
CREATE TABLE [dbo].[MobileToken](
[MobileTokenCode] [int] IDENTITY(1,1) NOT NULL,
[SecurityUserCode] [int] NOT NULL,
[Token] [nvarchar](500) NOT NULL,
[CreationDate] [datetime] NOT NULL,
CONSTRAINT [PK_MobileToken] PRIMARY KEY CLUSTERED 
(
[MobileTokenCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MobileToken]  WITH CHECK ADD  CONSTRAINT [FK_MobileToken_SecurityUser] FOREIGN KEY([SecurityUserCode])
REFERENCES [dbo].[SecurityUser] ([SecurityUserCode])
GO
ALTER TABLE [dbo].[MobileToken] CHECK CONSTRAINT [FK_MobileToken_SecurityUser]
GO
--------------------------------------- End  01-01-2023 ------------
--------------------------------------- Mostafa  03-01-2023 ------------

INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage])
VALUES(1001,N'Candidate Recruitment Steps',N'خطوات تعيين المرشح',47,N'',N'','fa fa-thumb-tack',N'',12,1,1)
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(1001,4)
Go
INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(5146,N'خطوات تعيين المرشح',N'Candidate Recruitment Steps',1001,1)
Go
Update [dbo].[SystemMenu] Set Name=N'Evaluation Stage',Arabic_Name=N'مرحلة التقيم',ParentID=1001,ControllerName=N'/Recruitment/RecruitJobCandidates',ActionName=N'Index',ImageURL='fa fa-thumb-tack',HTTPMethod=N'get',Sequence=1,IsVisible=1,ShowInPrivilegePage=1
Where  SystemMenuCode= 68
Go
delete from [dbo].[SystemMenuModule]
Where  SystemMenuCode =68
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(68,4)
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(68,1)
Go
Update [dbo].[SystemMenu] Set Name=N'Change Recruit Job Stage',Arabic_Name=N'تغير مراحل التقدم للوظيفة',ParentID=1001,ControllerName=N'/Recruitment/ForeignerJobStage',ActionName=N'Index',ImageURL='fa fa-thumb-tack',HTTPMethod=N'get',Sequence=2,IsVisible=1,ShowInPrivilegePage=1
Where  SystemMenuCode= 658
Go
delete from [dbo].[SystemMenuModule]
Where  SystemMenuCode =658
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(658,4)
Go
Update [dbo].[SystemMenu] Set Name=N'Candidate Invitation',Arabic_Name=N'دعوة المرشح',ParentID=1001,ControllerName=N'/Recruitment/CandidateInvitation',ActionName=N'Index',ImageURL='fa fa-thumb-tack',HTTPMethod=N'get',Sequence=3,IsVisible=1,ShowInPrivilegePage=1
Where  SystemMenuCode= 75
Go
delete from [dbo].[SystemMenuModule]
Where  SystemMenuCode =75
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(75,4)
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(75,1)
Go
Update [dbo].[SystemMenu] Set Name=N'Enter Stages Apply Result',Arabic_Name=N'إدخال نتيجة مراحل التقدم',ParentID=1001,ControllerName=N'/Recruitment/InterviewResult',ActionName=N'Index',ImageURL='fa fa-thumb-tack',HTTPMethod=N'get',Sequence=4,IsVisible=1,ShowInPrivilegePage=1
Where  SystemMenuCode= 76
Go
delete from [dbo].[SystemMenuModule]
Where  SystemMenuCode =76
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(76,4)
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(76,1)
Go
Update [dbo].[SystemMenu] Set Name=N'Job Offer',Arabic_Name=N'تقديم العرض',ParentID=1001,ControllerName=N'/Recruitment/JobOffer',ActionName=N'Index',ImageURL='fa fa-thumb-tack',HTTPMethod=N'get',Sequence=5,IsVisible=1,ShowInPrivilegePage=1
Where  SystemMenuCode= 77
Go
delete from [dbo].[SystemMenuModule]
Where  SystemMenuCode =77
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(77,4)
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(77,1)
Go
Update [dbo].[SystemMenu] Set Name=N'Hire Candidates',Arabic_Name=N'تعين المرشحين',ParentID=1001,ControllerName=N'/Recruitment/HireCandidates',ActionName=N'Index',ImageURL='fa fa-thumb-tack',HTTPMethod=N'get',Sequence=6,IsVisible=1,ShowInPrivilegePage=1
Where  SystemMenuCode= 79
Go
delete from [dbo].[SystemMenuModule]
Where  SystemMenuCode =79
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(79,4)
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(79,1)
Go
Update [dbo].[SystemMenu] Set Name=N'Candidate Recruitment Steps',Arabic_Name=N'خطوات تعيين المرشح',ParentID=47,ControllerName=N'',ActionName=N'',ImageURL='fa fa-thumb-tack',HTTPMethod=N'',Sequence=3,IsVisible=1,ShowInPrivilegePage=1
Where  SystemMenuCode= 1001
Go
delete from [dbo].[SystemMenuModule]
Where  SystemMenuCode =1001
Go
INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(1001,4)
Go
--------------------------------------- End  03-01-2023 ------------
--------------------------------------- Hammad  03-01-2023 ------------
INSERT INTO SecurityUserDetail ( SecurityUserID,PrivilegeID, CreationDate, CreatedBy)
    SELECT sec.SecurityUserID,5146, GETDATE(), 1
    FROM SecurityUserDetail sec 
	WHERE  sec.PrivilegeID in
(5053,5054,5055,5056,5063,5064,5065,5066,5067,5068,5070,5071,5072,5073,5074,5075,5076,5077,5078,5079,5086,5121,5143,5144,5145);
Go


INSERT INTO SecurityGroupDetail( SecurityGroupID,PrivilegeID, CreationDate, CreatedBy)
    SELECT gr.SecurityGroupID,5146, GETDATE(), 1
    FROM SecurityGroupDetail gr 
	WHERE  gr.PrivilegeID in
(5053,5054,5055,5056,5063,5064,5065,5066,5067,5068,5070,5071,5072,5073,5074,5075,5076,5077,5078,5079,5086,5121,5143,5144,5145);
Go

INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) 
VALUES (5147, N'عرض ترتيب عناصر العرض الوظيفي', N'View Sorting Job Offer Parameters', 100, 2)
GO
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType])
 VALUES (5148, N'حفظ ترتيب عناصر العرض الوظيفي', N'Save Sorting Job Offer Parameters', 100, 2)
GO


INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) 
VALUES (1079, N'Recruitment', N'JobOfferParameter', N'SortingJobGroupParameter', 0, N'get', 5147)
GO
INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID])
 VALUES (1080, N'Recruitment', N'JobOfferParameter', N'SortingJobGroupParameter_Read', 0, N'post', 5147)
GO
INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID])
 VALUES (1081, N'Recruitment', N'JobOfferParameter', N'UpdateSorting', 0, N'post', 5148)
GO
--------------------------------------- End  03-01-2023 ------------
--------------------------------------- Ali  03-01-2023 ------------


  ALTER TABLE dbo.Rec_JobOfferDetail ADD
	ParameterValueEn nvarchar(100) NULL
GO

ALTER TABLE Rec_JobOffer
ADD SendEmail bit NOT NULL DEFAULT 1
Go
--------------------------------------- End  03-01-2023 ------------
