----------------------------End 2020-12-06----------------------------



/****** Object:  StoredProcedure [dbo].[Emp_GetEmployeeProfile]    Script Date: 08/12/2020 8:20:46 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-----------------------------End 2020-03-09--------------------------------


-------------------------------Ali 2020-12-08---------------


ALTER procedure [dbo].[Emp_GetEmployeeProfile] 
(
	@userCode	int
)
AS
SELECT  
	   e.[EmployeeCode]
      ,e.[Name]
      ,e.[Arabic_Name]
      ,[Sex]
      ,[BirthDate]
      ,[BirthCityCode]
      ,[BirthDestination]
      ,[BirthDestinationArabic]
          
      ,[LokerNumber]
      ,[IDTypeCode]
      ,[IdIssueFrom]
      ,[IdIssueFromArabic]
      ,[IdNumber]
      ,[IDpolice_station]
      ,[IdCityCode]
      ,[IdIssueDate]
      ,[IdExpireDate]
     
      ,[Children_Number]
     
      ,[HiringDate]
      ,[ContractDate]
      ,[ContractExpireDate]    
     
      ,[InsuranceNumber]
      ,e.[ReligionCode]      
    
      ,[ResignationCode]
      ,[ResignationDate]     
      ,[Active]
   
      ,[CityCode]
      ,[EngFullAddress]
      ,[ArabicFullAddress]
      ,[OldFullAddress]    
      ,[Police_Station]
      ,[EngArea]
      ,[EngPolice_Station]
     
      ,[MotherName]
      ,e.[Telephone]
      ,[Mobile]
      ,e.[EMail]
      ,[CurrPercent]
      ,[Hidden]
      ,[Transfer]
      ,[VacationCalcCode]
      ,[DayRate]
      ,[WorkHoures]     
      ,[RoomNumber]     
      ,[BasicSalary]
    
      ,[StopSalaryReason]
      ,[NotApplicableToTransportationAllowance]
      ,[StopSalary]
      ,[ResignationPostingDate]
       
      ,[EmployeeType]
      ,[BirthDateHijri]
      ,[ContractDateHijri]
      ,[ContractExpireDateHijri]
      ,[HiringDateHijri]
	  ,[ProbationDate]
      ,[ProbationDateHijri]
      ,[ExperienceDateHijri]
      ,[LastWageHijri]
      ,[InsureDateHijri]
      ,[ResignationDateHijri]
      ,[ResignationPostingDateHijri]
      
	  ,dbo.Location.[Name] LocationNameEn
	  ,dbo.Location.[Arabic_Name] LocationNameAr	
	  ,dbo.SocialInsurance.[BasicEmployeeShare]
	  ,dbo.SocialInsurance.[BasicCompanyShare]
	  ,dbo.SocialInsurance.[VariableEmployeeShare]
	  ,dbo.SocialInsurance.[VariableCompanyShare]
	  ,dbo.SocialInsurance.[InsuranceDate]
	  ,dbo.SocialInsurance.[InsuranceDateHijri]
	   ,dbo.SocialInsurance.MaxBasic

	  ,dbo.Insurer.[Name] as InsurerNameEn
	  ,dbo.Insurer.[Arabic_Name] as InsurerNameAr
	  ,dbo.InsuranceTypes.[Name] as InsuranceTypesNameEn
	  ,dbo.InsuranceTypes.[Arabic_Name] as InsuranceTypesNameAr
	  ,dbo.Sections.Name SectionsNameEn
	  ,dbo.Sections.Arabic_Name SectionsNameAr
	  ,dbo.Departments.Name DepartmentsNameEn
	  ,dbo.Departments.Arabic_Name DepartmentsNameAr
	  ,dbo.Divisions.Name DivisionsNameEn
	  ,dbo.Divisions.Arabic_Name DivisionsNameAr
	  ,dbo.Nationality.[Name] NationalityNameEn
	  ,dbo.Nationality.[Arabic_Name] NationalityNameAr
	  ,dbo.Nationality.[CountryName]
	  ,dbo.Nationality.[CountryArabic_Name]
	  ,dbo.MaritalStatus.[Name] MaritalStatusNameEn
	  ,dbo.MaritalStatus.[Arabic_Name] MaritalStatusNameAr
	  ,dbo.EmployeeEducationData.[EducationDescription]
	  ,dbo.[Contract].[Name] ContractNameEn
	  ,dbo.[Contract].[Arabic_Name] ContractNameAr
	  ,dbo.[Currencies].[Name] CurrenciesNameEn
	  ,dbo.[Currencies].[Arabic_Name] CurrenciesNameAr
	  ,dbo.Levels.Name LevelsNameEn
	  ,dbo.Levels.Arabic_Name LevelsNameAr
	  ,dbo.Positions.Name PositionsNameEn
	  ,dbo.Positions.Arabic_Name PositionsNameAr
	  ,dbo.[GeneralTypes].[Name] GeneralTypesNameEn
	  ,dbo.[GeneralTypes].[Arabic_Name] GeneralTypesNameAr
	  ,UserImage
	  ,RecieveEmailNotifications
	  ,UserName



	  ,dbo.EmployeesExtend.[IssuePlace] as EmpExtendIssuePlace
	  ,dbo.EmployeesExtend.[CardNumber] as  EmpExtendCardNumber
	  ,dbo.EmployeesExtend.[IssueDate] as EmpExtendIssueDate
	  ,dbo.EmployeesExtend.[IssueDateHijri] as EmpExtendIssueDateHijri
	  ,dbo.EmployeesExtend.[ExpireDate] as EmpExtendExpireDate
	  ,dbo.EmployeesExtend.[ExpireDateHijri] as EmpExtendExpireDateHijri
	  ,dbo.EmployeesExtend.ExtensionNumber
	  ,dbo.EmployeesExtend.EMail2 

	  ,dbo.[HealthInsuranceTypes].[Name] as MedicalInsuranceTypeNameEn
	  ,dbo.[HealthInsuranceTypes].[Arabic_Name] as MedicalInsuranceTypeNameAr
	

   
FROM [dbo].[SecurityUser]

left join [dbo].[Employees] e on [dbo].SecurityUser.[EmployeeCode] = e.EmployeeCode
left join [dbo].[Location] on [dbo].Location.[LocationCode] = e.LocationCode
left join [dbo].[SocialInsurance] on [dbo].SocialInsurance.[EmployeeCode] = e.EmployeeCode
left join [dbo].[Insurer] on [dbo].Insurer.[InsurerCode] = [dbo].SocialInsurance.[InsurerCode]
left join [dbo].[InsuranceTypes] on [dbo].InsuranceTypes.InsuranceCode = e.InsuranceCode
left join [dbo].[Sections] on [dbo].Sections.SectionCode = e.SectionCode
left join [dbo].[Departments] on [dbo].Departments.DepartmentCode = [dbo].Sections.DepartmentCode
left join [dbo].Divisions on [dbo].Divisions.DivisionCode = [dbo].Departments.DivisionCode
left join [dbo].[Nationality] on [dbo].Nationality.[NationalityCode] = e.NationalityCode
left join [dbo].[MaritalStatus] on [dbo].MaritalStatus.[MaritalCode] = e.MaritalCode
left join [dbo].[EmployeeEducationData] on [dbo].EmployeeEducationData.[EmployeeCode] = e.EmployeeCode
left join [dbo].[Contract] on [dbo].[Contract].[ContractCode] = e.ContractCode
left join [dbo].[Currencies] on [dbo].[Currencies].CurrencyCode = e.CurrencyCode
left join [dbo].[Levels] on [dbo].Levels.LevelCode = e.LevelCode
left join [dbo].[GeneralTypes] on [dbo].GeneralTypes.[GeneralTypeCode] = e.GeneralTypeCode
left join [dbo].[Positions] on [dbo].Positions.PositionCode = e.PositionCode

left join [dbo].[EmployeesExtend] on [dbo].EmployeesExtend.[EmployeeExtendCode] = e.EmployeeCode
left join [dbo].[HealthInsuranceTypes] on [dbo].HealthInsuranceTypes.HealthInsuranceTypeCode = [dbo].[EmployeesExtend].HealthInsuranceTypeCode

where [dbo].[SecurityUser].[EmployeeCode] = @userCode;
Go




INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage]) VALUES (401, N'Work Settings', N'إعدادات العمل', 48, N'/Recruitment/SystemConfig', N'Index', N'fa fa-thumb-tack', N'get', 14, 1, 1)
Go

INSERT [dbo].[SystemMenuModule] ( [SystemMenuCode], [AppModuleCode]) VALUES ( 401, 4)

INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (1233, N'إعدادات العمل', N'WorkFlow Config', 401, 1)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (1234, N'عرض إعدادات العمل', N'View WorkFlow Config', 401, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (1235, N'حفظ إعدادات العمل', N'Save WorkFlow  Config', 401, 2)
Go

INSERT [dbo].[ConfigCategory] ([ConfigCategoryCode], [Name], [Arabic_Name]) VALUES (4, N'Recruitment', N'التوظيف')
Go

INSERT [dbo].[ConfigParameter] ([ConfigKey], [Name], [Arabic_Name], [ConfigValue], [ConfigCategoryCode], [OrderNo], [ConfigType], [IsVisible], [ModifiedBy], [ModificationDate], [RequestTypeId]) VALUES (N'REDisplayMilitaryStatus', N'Display Military Status', N'عرض الموقف من التجنيد', N'true', 4, 1, 1, 1, NULL, NULL, NULL)
Go

  ALTER TABLE [Rec_RecruitEmployee]
ALTER COLUMN [MilitaryCode] tinyint NULL
Go
-------------------------------End 2020-12-08---------------

