﻿---------------------------Hammad 2021-06-01---------------------

SET IDENTITY_INSERT [dbo].[EmailTemplateType] ON 
INSERT [dbo].[EmailTemplateType] ([EmailTemplateTypeCode], [Name], [Arabic_Name], [IsEditable], [AppModuleCode]) 
VALUES (260, N'Complete Hiring Data', N'إستكمال بيانات التعيين ', 0, 4)
SET IDENTITY_INSERT [dbo].[EmailTemplateType] OFF
SET IDENTITY_INSERT [dbo].[EmailTemplate] ON 
INSERT [dbo].[EmailTemplate] ([EmailTemplateCode], [Name], [Arabic_Name], [EmailTemplateTypeCode], [Subject], [Body], [IsDefault], [SubjectAppendCode], [GeneralTypeCode], [JobTypeCode]) 
VALUES (260, N'Complete Hiring Data', N'إستكمال بيانات تعيين  ', 260, N'إستكمال بيانات تعيين', N'إستكمال بيانات تعيين', 1, NULL, NULL, NULL)
SET IDENTITY_INSERT [dbo].[EmailTemplate] OFF
Go
---------------------------End 2021-06-1------------------
---------------------------Ali 2021-06-1------------------
 ALTER TABLE dbo.Contract ADD
	ContractGroupCode int NULL
GO
---------------------------End 2021-06-1------------------
---------------------------Ali 2021-06-02------------------
INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) 
VALUES(14193,N'التقارير',N'Reports',387,1)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) 
VALUES(14194,N'عرض التقارير',N'View Reports',387,2)
Go
---------------------------End 2021-06-02------------------

-----------------mostafa 03/06/2021---------------
alter table WF_RequestType add CategoryCode int null;
GO
UPDATE WF_RequestType
SET CategoryCode = 2
WHERE RequestTypeId in (32,33,34,35,36,37,38,39,40,41) 
GO
UPDATE WF_RequestType
SET CategoryCode = 1
WHERE RequestTypeId in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,42,43,44,45,46,47,48,49,50,51,52) 
go
-----------------end 03/06/2021---------------

---------------------------Ali 2021-06-03------------------


/****** Object:  StoredProcedure [dbo].[GetOrganizationChartLevels]    Script Date: 03/06/2021 4:04:26 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[GetOrganizationChartLevels]
    @id [int],
    @groupId [int]
AS
BEGIN
    
    declare @tblorganizationLevels table(
    		Id int
    			
    	);
    
    	             with organizationLevels as(
    	             	select OrganizationStructureId from OrganizationStructure where OrganizationStructureId = @Id
    	             	union all
    	             	select org2.OrganizationStructureId from OrganizationStructure org2, organizationLevels  
    	             	where org2.ParentId = organizationLevels.OrganizationStructureId
    	             ) Insert into @tblorganizationLevels select * from organizationLevels option (maxrecursion 0);
    
    	             select
    					 dbo.OrganizationStructure.OrganizationStructureId as OrganizationStructureId 
    					, dbo.OrganizationStructure.OrganizationStructureCode as OrganizationStructureCode 
    					, dbo.OrganizationStructure.ParentId as ParentId 
    					, dbo.OrganizationStructure.Nickname as Nickname 
    					, dbo.OrganizationStructure.Arabic_Nickname as Arabic_Nickname 
    					, dbo.OrganizationStructure.Name as Name 
    					, dbo.OrganizationStructure.Arabic_Name as Arabic_Name 
    
    					, dbo.OrganizationCategory.FontSize as CategoryFontSize 
    					, dbo.OrganizationCategory.Color as CategoryBackgroundColor 
    					, dbo.OrganizationCategory.FontColor as CategoryFontColor 
    , dbo.OrganizationCategory.ViewInOrgChart as ViewInOrgChart 
    
    					,dbo.Employees.Arabic_Name as EmployeNameAr 
    					,dbo.Employees.Name as EmployeName 
						,dbo.Employees.HiringDate as HiringDate
    					,dbo.Employees.EmployeeCode as EmployeeCode 
    	               				 


						,dbo.Positions.Name as PositionName
						,dbo.Positions.Arabic_Name as PositionNameAr

						,dbo.Sections.Name as SectionName
						,dbo.Sections.Arabic_Name as SectionNameAr

    					  from [dbo].OrganizationStructure
    					   join [dbo].[OrganizationCategory] on [dbo].[OrganizationCategory].OrganizationCategoryCode = [dbo].OrganizationStructure.OrganizationCategoryCode
    					   join [dbo].OrganizationStructureAndGroups on [dbo].[OrganizationStructureAndGroups].OrganizationStructureId = [dbo].OrganizationStructure.OrganizationStructureId and 
    				      [dbo].[OrganizationStructureAndGroups].OrganizationGroupCode = @groupId
    					   join [dbo].[Employees] on [dbo].[Employees].EmployeeCode = [dbo].OrganizationStructureAndGroups.ManagerCode
                       inner join [dbo].Positions on [dbo].[Employees].PositionCode= Positions.PositionCode
                       inner join [dbo].Sections on [dbo].[Employees].SectionCode= Sections.SectionCode
    
    					 where [dbo].OrganizationStructure.OrganizationStructureId in (select * from @tblorganizationLevels)
    
END
Go
---------------------------End 2021-06-03------------------
--------------------------AK 2021-06-07--------------------------------
INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage])
VALUES(537,N'Quick query',N'الاستعلام السريع', 163 ,N'/ConsolidatedDashboard/quickquery',N'Index','fa fa-thumb-tack',N'GET',7,1,1)
Go

INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(537,9)
Go

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(11038,N'الاستعلام السريع',N'Quick query',537,1)
INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(11039,N'عرض الاستعلام السريع',N'View Quick query',537,2)
Go
 --------------------------End 2021-06-07--------------------------------