-------------------------------Sayed 2020-11-30--------------------------

CREATE TABLE [dbo].[WF_CostCenter](
	[CostCenterCode] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](150) NULL,
	[Arabic_Name] [nvarchar](150) NULL,
	[HirarchyCode] [nvarchar](50) NULL,
	[FinancailPaymentRealated] [tinyint] NOT NULL,
	[CreatedBy] [int] NOT NULL,
	[CreationDate] [datetime] NOT NULL,
	[ModifiedBy] [int] NULL,
	[ModificationDate] [datetime] NULL,
 CONSTRAINT [PK_WF_CostCenter] PRIMARY KEY CLUSTERED 
(
	[CostCenterCode] 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].[WF_CostCenter] ADD  CONSTRAINT [DF_WF_CostCenter_FinancailPaymentRealated]  DEFAULT ((3)) FOR [FinancailPaymentRealated]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1:Section 2:Department 3:Division' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'WF_CostCenter', @level2type=N'COLUMN',@level2name=N'HirarchyRelatedType'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1:Employee 2:HR 3:ALl' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'WF_CostCenter', @level2type=N'COLUMN',@level2name=N'FinancailPaymentRealated'
GO
------------------------------End 2020-11-30--------------------------------
------------------------------Ali 2020-11-30--------------------------------

INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage])
VALUES(395,N'Cost Centers',N'مراكز التكلفة',28,N'/WorkFlow/CostCenter',N'Index','fa fa-thumb-tack',N'get',24,1,1)
Go

INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(395,1)
Go

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(3595,N'مراكز التكلفة',N'Cost Centers',395,1)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(3596,N'عرض مراكز التكلفة',N'View Cost Centers',395,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(3597,N'إضافة مراكز التكلفة',N'Add Cost Centers',395,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(3598,N'تعديل مراكز التكلفة',N'Edit Cost Centers',395,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(3599,N'حذف مراكز التكلفة',N'Delete Cost Centers',395,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(3600,N'حفظ مراكز التكلفة',N'Save Cost Centers',395,2)

Go
------------------------------End 2020-11-30--------------------------------
------------------------------Ali 2020-12-01--------------------------------
  INSERT [dbo].[ConfigParameter] ([ConfigKey], [Name], [Arabic_Name], [ConfigValue], [ConfigCategoryCode], [OrderNo], [ConfigType], [IsVisible], [ModifiedBy], [ModificationDate], [RequestTypeId]) VALUES (N'WFHirarchyTypeRealated', N'Hirarchy Type Realated', N'نوع الهيكل المرتبط به', N'64', 2, 1, 6, 1, NULL, NULL, 30)
  Go

  INSERT [dbo].[ConfigLookup] ([ConfigLookupCode], [Name], [Arabic_Name], [ConfigKey]) VALUES (64, N'Section', N'قسم', N'WFHirarchyTypeRealated')
INSERT [dbo].[ConfigLookup] ([ConfigLookupCode], [Name], [Arabic_Name], [ConfigKey]) VALUES (65, N'Department', N'اداوة', N'WFHirarchyTypeRealated')
INSERT [dbo].[ConfigLookup] ([ConfigLookupCode], [Name], [Arabic_Name], [ConfigKey]) VALUES (66, N'Division', N'قطاع', N'WFHirarchyTypeRealated')
GO



ALTER proc [dbo].[Emp_GetEmployeeLeaveTransaction]
(
	@EmpCode			int ,
	@YEAR int = null

)
AS
SELECT  [Serial]
      ,[EmployeeCode]
      ,[VacationCode]
      ,[FromDate]
      ,[ToDate]
      ,[FromDateHijri]
      ,[ToDateHijri]
      ,[Comment]
      ,[DaysCount]
      ,[AddBy]
      ,[AddDate]
      ,[LastChangeBy]
      ,[ChangeDate]
      ,[VacationRequestSerial]
      ,[MainType]
      ,[Return]
      ,[RequiredReturnNotification]
      ,[FCClosed]
      ,[VacationStatusCode],
	  (select Name from VacationType where VacationCode=LeaveTransaction.VacationCode) as VacationNameEN,
	  (select Arabic_Name from VacationType where VacationCode=LeaveTransaction.VacationCode) as VacationNameAR
  FROM [dbo].[LeaveTransaction]


   where 
   ----YEAR (FromDate)=@YEAR
   (@YEAR IS NULL OR YEAR (FromDate)=@YEAR)
   and
	EmployeeCode= @EmpCode


	Go
------------------------------End 2020-12-01--------------------------------
------------------------------Hammad 2020-12-01-----------------------------

  
CREATE TABLE [dbo].[WF_FinancialPaymentRequest](
	[MasterRequestCode] [int] NOT NULL,
	[FinancialPaymentTypeCode] [int] NOT NULL,
	[CostCenterCode] [int] NOT NULL,
	[InvoiceNumber] [nvarchar](50) NULL,
	[InvoiceAmount] [float] NULL,
 CONSTRAINT [PK_WF_FinancialPaymentRequest] PRIMARY KEY CLUSTERED 
(
	[MasterRequestCode] 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].[WF_FinancialPaymentRequest]  WITH CHECK ADD  CONSTRAINT [FK_WF_FinancialPayment_WF_CostCenter] FOREIGN KEY([CostCenterCode])
REFERENCES [dbo].[WF_CostCenter] ([CostCenterCode])
GO

ALTER TABLE [dbo].[WF_FinancialPaymentRequest] CHECK CONSTRAINT [FK_WF_FinancialPayment_WF_CostCenter]
GO

ALTER TABLE [dbo].[WF_FinancialPaymentRequest]  WITH CHECK ADD  CONSTRAINT [FK_WF_FinancialPayment_WF_FinancialPaymentType] FOREIGN KEY([FinancialPaymentTypeCode])
REFERENCES [dbo].[WF_FinancialPaymentType] ([FinancialPaymentTypeCode])
GO

ALTER TABLE [dbo].[WF_FinancialPaymentRequest] CHECK CONSTRAINT [FK_WF_FinancialPayment_WF_FinancialPaymentType]
GO

ALTER TABLE [dbo].[WF_FinancialPaymentRequest]  WITH CHECK ADD  CONSTRAINT [FK_WF_FinancialPaymentRequest_WF_MasterRequests] FOREIGN KEY([MasterRequestCode])
REFERENCES [dbo].[WF_MasterRequests] ([MasterRequestCode])
GO

ALTER TABLE [dbo].[WF_FinancialPaymentRequest] CHECK CONSTRAINT [FK_WF_FinancialPaymentRequest_WF_MasterRequests]
GO


SET IDENTITY_INSERT [dbo].[EmailTemplateType] ON 
INSERT [dbo].[EmailTemplateType] ([EmailTemplateTypeCode], [Name], [Arabic_Name], [IsEditable], [AppModuleCode]) VALUES (166, N'Financial Payment Request Sending', N'ارسال طلب السدادات المالية', 0, 1)
INSERT [dbo].[EmailTemplateType] ([EmailTemplateTypeCode], [Name], [Arabic_Name], [IsEditable], [AppModuleCode]) VALUES (167, N'Financial Payment Request Accept', N'الموافقة طلب السدادات المالية', 0, 1)
INSERT [dbo].[EmailTemplateType] ([EmailTemplateTypeCode], [Name], [Arabic_Name], [IsEditable], [AppModuleCode]) VALUES (168, N'Financial Payment Request Refuse', N'رفض طلب السدادات المالية', 0, 1)
INSERT [dbo].[EmailTemplateType] ([EmailTemplateTypeCode], [Name], [Arabic_Name], [IsEditable], [AppModuleCode]) VALUES (169, N'Financial Payment Refuse', N'رفض طلب السدادات المالية', 0, 1)
SET IDENTITY_INSERT [dbo].[EmailTemplateType] OFF

SET IDENTITY_INSERT [dbo].[EmailTemplate] ON 
INSERT [dbo].[EmailTemplate] ([EmailTemplateCode], [Name], [Arabic_Name], [EmailTemplateTypeCode], [Subject], [Body], [IsDefault], [SubjectAppendCode]) VALUES (166, N'Financial Payment Sending', N'ارسال طلب السدادات المالية', 166, N'ارسال طلب السدادات المالية', N' نرجو الموافقة على طلب السدادات المالية', 1, NULL)
INSERT [dbo].[EmailTemplate] ([EmailTemplateCode], [Name], [Arabic_Name], [EmailTemplateTypeCode], [Subject], [Body], [IsDefault], [SubjectAppendCode]) VALUES (167, N'Financial Payment Accept', N'الموافقة على طلب السدادات المالية', 167, N'الموافقة على طلب السدادات المالية', N'<p>تمت الموافقة</p>', 1, NULL)
INSERT [dbo].[EmailTemplate] ([EmailTemplateCode], [Name], [Arabic_Name], [EmailTemplateTypeCode], [Subject], [Body], [IsDefault], [SubjectAppendCode]) VALUES (168, N'Financial Payment Request Refuse', N'رفض طلب السدادات المالية', 168, N'رفض طلب السدادات المالية', N'تم رفض الطلب', 1, NULL)
INSERT [dbo].[EmailTemplate] ([EmailTemplateCode], [Name], [Arabic_Name], [EmailTemplateTypeCode], [Subject], [Body], [IsDefault], [SubjectAppendCode]) VALUES (169, N'Financial Payment Request Cancellation', N'الغاء طلب السدادات المالية', 169, N'الغاء طلب السدادات المالية', N'تم إلغاء الطلب', 1, NULL)
SET IDENTITY_INSERT [dbo].[EmailTemplate] OFF

INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage]) VALUES (396, N'Financial Payment Employee  Request', N'طلب السدادات المالية للموظف', 29, N'/WorkFlow/FinancialPaymentRequest', N'Index', N'fa fa-thumb-tack', N'get', 42, 1, 1)
INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage]) VALUES (397, N'Financial Payment Employee Request Signature', N'إعتماد طلب السدادات المالية للموظف', 108, N'/WorkFlow/FinancialPaymentRequestSignature', N'Index', N'fa fa-thumb-tack', N'get', 45, 1, 1)

Go

INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3601, N'طلب السدادات المالية', N'Financial Payment Request  ', 396, 1)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3602, N'عرض طلب السدادات المالية', N'View Financial Payment Request', 396, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3603, N'اضافة طلبم وثرات شهرية', N'Add Financial Payment Request', 396, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3604, N'تعديل طلب السدادات المالية', N'Edit Financial Payment Request', 396, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3605, N'حفظ طلب السدادات المالية', N'Save Financial Payment Request', 396, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3606, N'حذف طلب السدادات المالية', N'Delete Financial Payment Request       ', 396, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3607, N'الغاء طلب السدادات المالية', N'Cancel Financial Payment Request ', 396, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3608, N'اعتماد طلب السدادات المالية', N' Financial Payment Request Signature', 397, 1)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3609, N'عرض اعتماد طلب السدادات المالية', N'View  Financial Payment Request Signature', 397, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3610, N'تعديل اعتماد طلب السدادات المالية', N'Edit  Financial Payment Request Signature', 397, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3611, N'حفظ اعتماد طلب السدادات المالية', N'Save  Financial Payment Request Signature', 397, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3612, N'حفظ متعدد اعتماد طلب السدادات المالية', N' Multiple Save  Financial Payment Signature', 397, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3613, N'عرض سجل الموظف', N'View Employee History', 397, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3614, N'ارجاع طلب السدادات المالية', N'Inverse  Financial Payment Request', 397, 2)
INSERT [dbo].[SecurityPrivilege] ([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES (3615, N'اختيار كل الطلبات', N'Choose All Requests', 397, 2)

Go

INSERT [dbo].[SystemMenuModule] ( [SystemMenuCode], [AppModuleCode]) VALUES (396, 1)
INSERT [dbo].[SystemMenuModule] ( [SystemMenuCode], [AppModuleCode]) VALUES (397, 1)
Go

INSERT [dbo].[WF_RequestType] ([RequestTypeId], [RequestTypeName], [RequestTypeNameEn], [IsEditable], [SenderUserName], [SenderFrom], [SenderPassword], [SenderHostName], [SenderPort], [SenderName], [SubmitBeforRequestDate], [SubmitAfterRequestDate], [IsUsed]) VALUES (30, N'طلب السدادات المالية', N'Financial Payment Request', 0, N'sayedmustafa84@yahoo.com', N'sayedmustafa84@yahoo.com', N'1', N'smtp.sendgrid.net', 587, N'SST', NULL, NULL, 1)
GO

------------------------------End 2020-12-01---------------