﻿---------------------------Hammad 2022-08-07---------------
SET IDENTITY_INSERT [dbo].[EmailTemplateType] ON 
GO
INSERT [dbo].[EmailTemplateType] ([EmailTemplateTypeCode], [Name], [Arabic_Name], [IsEditable], [AppModuleCode], [RequestTypeCode], [HaveUserAccount]) 
VALUES (332, N'Update Request ', N'مطلوب تعديل الطلب', 0, 1, 57, 1)
GO
SET IDENTITY_INSERT [dbo].[EmailTemplateType] OFF

INSERT [dbo].[EmailTemplate] ([Name], [Arabic_Name], [EmailTemplateTypeCode], [Subject], [Body], [IsDefault], [SubjectAppendCode], [GeneralTypeCode], [JobTypeCode], [MessageTemplate]) 
VALUES ( N'Update Request ', N'مطلوب تعديل الطلب', 332, N'مطلوب تعديل الطلب', N'مطلوب تعديل الطلب', 1, NULL, NULL, NULL, NULL)
GO
---------------------------End 2022-08-07---------------
---------------------------Ali 2022-08-07---------------

 INSERT[dbo].[ConfigParameter]  ([ConfigKey], [Name], [Arabic_Name], [ConfigValue], [ConfigCategoryCode], [OrderNo], [ConfigType], [IsVisible], [ModifiedBy], [ModificationDate], [RequestTypeId])
VALUES(N'HolidayIncludedInWorkingDays',N'Holiday included in working days',N'الاجازات الرسميه تدخل ضمن ايام العمل',N'false',1,44,1,1,Null,Null,Null)
Go


 INSERT[dbo].[ConfigParameter]  ([ConfigKey], [Name], [Arabic_Name], [ConfigValue], [ConfigCategoryCode], [OrderNo], [ConfigType], [IsVisible], [ModifiedBy], [ModificationDate], [RequestTypeId])
VALUES(N'DayOffIncludedInWorkingDays',N'Days Off included in working days',N'الراحات الاسبوعية تدخل ضمن ايام العمل',N'false',1,45,1,1,Null,Null,Null)
Go


CREATE procedure [dbo].[Emp_GetDayOffCount] 
(
	 @StartDate AS DATETIME ,
    @EndDate AS DATETIME ,
    @employeeCode int

)
AS


 declare @TimeScheduleTypeCode int 
declare @Count int 
declare @QueryCount1 int 
declare @QueryCount2 int 
declare @Dayoff int 


SET @Count = 0


 select  top(1) @TimeScheduleTypeCode = TimeScheduleTypeCode from EmployeesExtend where  EmployeeExtendCode = @employeeCode

 WHILE (@StartDate <= @EndDate)
BEGIN

select @Dayoff=  dbo.GetDayOffByDate(@StartDate)
select @QueryCount1 = COUNT(*) from TimeScheduleTypes where TimeScheduleTypeCode=@TimeScheduleTypeCode and(DayoffNumber2=@Dayoff or DayoffNumber1=@Dayoff)

select @QueryCount2 = COUNT(*) from HolidaysMap where DayDate=@StartDate


if @QueryCount1 >0 or  @QueryCount2 >0
  set @Count=@Count+1
 

SET @StartDate = convert(varchar(30), dateadd(day,1, @StartDate), 101); 

END

select @Count as dayCount

Go

CREATE procedure [dbo].[Emp_GetHolidayCount] 
(
	 @StartDate AS DATETIME ,
    @EndDate AS DATETIME ,
    @employeeCode int

)
AS


 declare @TimeScheduleTypeCode int 
declare @Count int 
declare @QueryCount1 int 
declare @QueryCount2 int 
declare @Dayoff int 


SET @Count = 0


 select  top(1) @TimeScheduleTypeCode = TimeScheduleTypeCode from EmployeesExtend where  EmployeeExtendCode = @employeeCode

 WHILE (@StartDate <= @EndDate)
BEGIN


select @QueryCount2 = COUNT(*) from HolidaysMap where DayDate=@StartDate


if @QueryCount2 >0
  set @Count=@Count+1
 

SET @StartDate = convert(varchar(30), dateadd(day,1, @StartDate), 101); 

END

select @Count as dayCount

Go



---------------------------End 2022-08-07---------------

---------------------------Ali 2022-08-08---------------
 INSERT[dbo].[ConfigParameter]  ([ConfigKey], [Name], [Arabic_Name], [ConfigValue], [ConfigCategoryCode], [OrderNo], [ConfigType], [IsVisible], [ModifiedBy], [ModificationDate], [RequestTypeId])
VALUES(N'WF_WorkingByAllowanceTypeMoneyAndBalance',N'"Working By Compensation Allowance Type "Money And Balance',N'العمل بنوع بدل التعويض " مالى ورصيد "',N'true',2,20,1,1,Null,Null,3)
Go
  INSERT [dbo].[ConfigLookup] ([ConfigLookupCode], [Name], [Arabic_Name], [ConfigKey]) 
  VALUES (89, N'Closing Month End', N'نهاية شهر الاقفال', N'VacDayoffBalanceCalcPeriod')
GO
---------------------------End 2022-08-08---------------
